Merge pull request #5178 from Isira-Seneviratne/Use_ActivityCompat_recreate
Use ActivityCompat.recreate().
This commit is contained in:
commit
276f50a944
3 changed files with 7 additions and 7 deletions
|
@ -50,6 +50,7 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -218,7 +219,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
toggleServices();
|
||||
}
|
||||
if (lastService != ServiceHelper.getSelectedServiceId(MainActivity.this)) {
|
||||
new Handler(Looper.getMainLooper()).post(MainActivity.this::recreate);
|
||||
ActivityCompat.recreate(MainActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -497,10 +498,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
Log.d(TAG, "Theme has changed, recreating activity...");
|
||||
}
|
||||
sharedPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, false).apply();
|
||||
// https://stackoverflow.com/questions/10844112/
|
||||
// Briefly, let the activity resume
|
||||
// properly posting the recreate call to end of the message queue
|
||||
new Handler(Looper.getMainLooper()).post(MainActivity.this::recreate);
|
||||
ActivityCompat.recreate(this);
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean(Constants.KEY_MAIN_PAGE_CHANGE, false)) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -140,7 +141,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (redraw) {
|
||||
recreate();
|
||||
ActivityCompat.recreate(this);
|
||||
redraw = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.provider.Settings;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -31,7 +32,7 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
|||
|
||||
if (!newValue.equals(startThemeKey) && getActivity() != null) {
|
||||
// If it's not the current theme
|
||||
getActivity().recreate();
|
||||
ActivityCompat.recreate(requireActivity());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue