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

Commit e87079ee authored by blong's avatar blong Committed by Gerrit - the friendly Code Review server
Browse files

Fix NullPointerException in monkey test

- When fragment recreate in the background,need initial them
  in the activity,so the FC will not happen

CRs-Fixed: 1059756

Change-Id: I9b6906f645eb72876c0211965635eb9650e2f0db
parent 5200e62f
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ public class MultiPickContactsActivity extends Activity implements ViewPager.OnP
            // so the Fragment will only be created once. If we add a TAG manually, there will
            // occur crash.
            position = getRtlPosition(position);

            if (mAreTabsHiddenInViewPager) {
                if (mPickMode.isPickCall()) {
                    mDelCallLogFragment = new DelCallLogFragment();
@@ -289,6 +290,53 @@ public class MultiPickContactsActivity extends Activity implements ViewPager.OnP
        public int getCount() {
            return mAreTabsHiddenInViewPager ? 1 : TAB_INDEX_COUNT;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {

            Fragment f = (Fragment) super.instantiateItem(container, position);

            if (mAreTabsHiddenInViewPager) {
                if (mPickMode.isPickCall()) {
                    if (mDelCallLogFragment == null) {
                        mDelCallLogFragment = (DelCallLogFragment) f;
                        mDelCallLogFragment
                                .setCheckListListener(new CheckListListener());
                    }
                } else {
                    if (mContactsFragment == null) {
                        mContactsFragment = (ContactsFragment) f;
                        mContactsFragment
                                .setCheckListListener(new CheckListListener());
                    }
                }
            } else {
                switch (position) {
                case TAB_INDEX_RECENT:
                    if (mCallLogFragment == null) {
                        mCallLogFragment = (CallLogFragment) f;
                        mCallLogFragment
                                .setCheckListListener(new CheckListListener());
                    }
                    break;
                case TAB_INDEX_CONTACTS:
                    if (mContactsFragment == null) {
                        mContactsFragment = (ContactsFragment) f;
                        mContactsFragment
                                .setCheckListListener(new CheckListListener());
                    }
                    break;
                case TAB_INDEX_GROUP:
                    if (mGroupFragment == null) {
                        mGroupFragment = (GroupsFragment) f;
                        mGroupFragment
                                .setCheckListListener(new CheckListListener());
                    }
                    break;
                }
            }
            return f;
        }
    }

    @Override