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