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

Commit e96c995a authored by blong's avatar blong
Browse files

Fix ClassCastException during monkey test

- Add fragment type judge before initial
- Initial listener when activity created

CRs-Fixed: 1072080

Change-Id: Ic97c68e33454cbe7a9e4c90456de19e67404adf8
parent 8a99ff69
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ public class MultiPickContactsActivity extends Activity implements ViewPager.OnP
            // occur crash.
            position = getRtlPosition(position);

            if (mAreTabsHiddenInViewPager || !mPickMode.isPickPhone()) {
            if (!mPickMode.isPickPhone()) {
                if (mPickMode.isPickCall()) {
                    mDelCallLogFragment = new DelCallLogFragment();
                    mDelCallLogFragment.setCheckListListener(new CheckListListener());
@@ -295,15 +295,15 @@ public class MultiPickContactsActivity extends Activity implements ViewPager.OnP
        public Object instantiateItem(ViewGroup container, int position) {

            Fragment f = (Fragment) super.instantiateItem(container, position);
            if (mAreTabsHiddenInViewPager || !mPickMode.isPickPhone()) {
            if (!mPickMode.isPickPhone()) {
                if (mPickMode.isPickCall()) {
                    if (mDelCallLogFragment == null) {
                    if (mDelCallLogFragment == null && f instanceof DelCallLogFragment) {
                        mDelCallLogFragment = (DelCallLogFragment) f;
                        mDelCallLogFragment
                                .setCheckListListener(new CheckListListener());
                    }
                } else {
                    if (mContactsFragment == null) {
                    if (mContactsFragment == null && f instanceof ContactsFragment) {
                        mContactsFragment = (ContactsFragment) f;
                        mContactsFragment
                                .setCheckListListener(new CheckListListener());
@@ -312,21 +312,21 @@ public class MultiPickContactsActivity extends Activity implements ViewPager.OnP
            } else {
                switch (position) {
                case TAB_INDEX_RECENT:
                    if (mCallLogFragment == null) {
                    if (mCallLogFragment == null && f instanceof CallLogFragment) {
                        mCallLogFragment = (CallLogFragment) f;
                        mCallLogFragment
                                .setCheckListListener(new CheckListListener());
                    }
                    break;
                case TAB_INDEX_CONTACTS:
                    if (mContactsFragment == null) {
                    if (mContactsFragment == null && f instanceof ContactsFragment) {
                        mContactsFragment = (ContactsFragment) f;
                        mContactsFragment
                                .setCheckListListener(new CheckListListener());
                    }
                    break;
                case TAB_INDEX_GROUP:
                    if (mGroupFragment == null) {
                    if (mGroupFragment == null && f instanceof GroupsFragment) {
                        mGroupFragment = (GroupsFragment) f;
                        mGroupFragment
                                .setCheckListListener(new CheckListListener());
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.widget.AbsListView;
import android.widget.TextView;

import com.android.contacts.R;
import com.android.contacts.activities.MultiPickContactsActivity;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.util.UriUtils;
@@ -175,6 +176,10 @@ public class CallLogFragment extends ListFragment {
        resolver = mContext.getContentResolver();
        resolver.registerContentObserver(Calls.CONTENT_URI, true, mCallLogObserver);

        if (mCheckListListener == null) {
            mCheckListListener = ((MultiPickContactsActivity) getActivity())
                    .createListener();
        }
        if (mCallLogListAdapter == null) {
            mCallLogListAdapter = new CallLogItemListAdapter(mContext);
            mContactsCheckedList = new ArrayList<String>();
+4 −0
Original line number Diff line number Diff line
@@ -187,6 +187,10 @@ public class GroupsFragment extends ExpandableListFragment implements OnGroupCli
        mList.setOnGroupClickListener(this);
        mList.setOnChildClickListener(this);
        mList.setDivider(null);
        if (mCheckListListener == null) {
            mCheckListListener = ((MultiPickContactsActivity) getActivity())
                    .createListener();
        }
        if (mAdapter == null) {
            if (mAllContactsCurosrMap == null) {
                mAllContactsCurosrMap = new HashMap<Long, String[]>();