Getting screen width on API Level 30 (Android 11): getDefaultDisplay() and getMetrics() are now deprecated. What should we use instead?

For calculating screen width minus any system bars, this should work: public static int getScreenWidth(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { WindowMetrics windowMetrics = activity.getWindowManager().getCurrentWindowMetrics(); Insets insets = windowMetrics.getWindowInsets() .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()); return windowMetrics.getBounds().width() – insets.left – insets.right; } else { DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; } } Note that this isn’t … Read more

Preprocessing in scikit learn – single sample – Depreciation warning

Just listen to what the warning is telling you: Reshape your data either X.reshape(-1, 1) if your data has a single feature/column and X.reshape(1, -1) if it contains a single sample. For your example type(if you have more than one feature/column): temp = temp.reshape(1,-1) For one feature/column: temp = temp.reshape(-1,1)

Django 1.9 deprecation warnings app_label

Similar error. In my case the error was: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and either isn’t in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9. class Site(models.Model): My solution was: Added ‘django.contrib.sites’ to INSTALLED_APPS

DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version

UPDATE mongodb@3.6.5 is out. Just update mongodb driver and mongoose: npm i mongodb mongoose This is caused by the mongodb@3.6.4 native driver which is used by mongoose. #1 You can downgrade mongodb to version 3.6.3 (described here). #2 Or downgrade mongoose from 5.11.16 back to 5.11.15: npm uninstall mongoose npm install mongoose@5.11.15 #3 Or just … Read more

getCurrentPosition() and watchPosition() are deprecated on insecure origins

Because switching to HTTPS can be painful or impossible depending on your architecture, I found a workaround solution: you can use the Google Maps Geolocation API. Although it has usage limits, it does the job. You will need an browser API key, so don’t forget to limit it’s usage to your page hostname. I use … Read more

How to warn about class (name) deprecation

Maybe I could make OldClsName a function which emits a warning (to logs) and constructs the NewClsName object from its parameters (using *args and **kvargs) but it doesn’t seem elegant enough (or maybe it is?). Yup, I think that’s pretty standard practice: def OldClsName(*args, **kwargs): from warnings import warn warn(“get with the program!”) return NewClsName(*args, … Read more

onBackPressed() deprecated, What is the alternative?

According your API level register: onBackInvokedDispatcher.registerOnBackInvokedCallback for API level 33+ onBackPressedDispatcher callback for backword compatibility “API level 13+” This requires to at least use appcompat:1.6.0-alpha03; the current is 1.6.0-alpha04: implementation ‘androidx.appcompat:appcompat:1.6.0-alpha04’ // kotlin import androidx.activity.addCallback if (BuildCompat.isAtLeastT()) { onBackInvokedDispatcher.registerOnBackInvokedCallback( OnBackInvokedDispatcher.PRIORITY_DEFAULT ) { // Back is pressed… Finishing the activity finish() } } else { onBackPressedDispatcher.addCallback(this … Read more

React 16.7 – React.SFC is now deprecated

You should use React.FunctionComponent: Rename React’s SFC to ‘FunctionalComponent This PR renames React.SFC and React.StatelessComponent to React.FunctionComponent, while introducing deprecated aliases for the old names. So your example would become: const example: React.FunctionComponent<IExample> = ({propsType}) => (); or const example: React.FC<IExample> = ({propsType}) => ();

How should I mark a method as “obsolete” in JS?

There are a couple of things you can do in a transition period. Add the @deprecated JSDoc flag. Add a console warning message that indicates that the function is deprecated. A sample: /** * @deprecated Since version 1.0. Will be deleted in version 3.0. Use bar instead. */ function foo() { console.warn(“Calling deprecated function!”); bar(); … Read more

setBackgroundDrawable() deprecated

It’s an interesting topic. The way you are doing it is correct, apparently. It is actually just a naming decision change. As this answer points out, setBackground() just calls setBackgroundDrawable(): public void setBackground(Drawable background) { //noinspection deprecation setBackgroundDrawable(background); } @Deprecated public void setBackgroundDrawable(Drawable background) { … } You can see this thread for more information … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)