Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db1b6acc authored by tom hsu's avatar tom hsu
Browse files

[Panlingual] Fix settings crash due to no content view.

 - Sometimes, listview may not created instantly, so move the action of
   addHeaderView after fragment finished the onResume;

Bug: 228563549
Test: local
Change-Id: Ie5d53c962bed35783decd374c743a168a98cbf6a
parent 18bdecad
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -87,12 +87,6 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
        launchLocalePickerPage();
    }

    @Override
    public void onResume() {
        super.onResume();
        mLocalePickerWithRegion.getListView().addHeaderView(launchAppLocaleDetailsPage());
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
@@ -136,7 +130,19 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
    void launchLocalePickerPage() {
        // LocalePickerWithRegion use android.app.ListFragment. Thus, it can not use
        // getSupportFragmentManager() to add this into container.
        getFragmentManager().beginTransaction()
        android.app.FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.registerFragmentLifecycleCallbacks(
                new android.app.FragmentManager.FragmentLifecycleCallbacks() {
                    @Override
                    public void onFragmentResumed(
                            android.app.FragmentManager fm,
                            android.app.Fragment f) {
                        super.onFragmentResumed(fm, f);
                        mLocalePickerWithRegion.getListView()
                                .addHeaderView(launchAppLocaleDetailsPage());
                    }
                }, true);
        fragmentManager.beginTransaction()
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .replace(R.id.content_frame, mLocalePickerWithRegion)
                .commit();