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

Commit cf785d39 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Fix group member refresh double problem"

parents 335db0f8 70058d65
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ public class MergeContactActivity extends ListActivity {
            List<String> simNumberList = new ArrayList<>();
            List<String> simEmailList = new ArrayList<>();

            boolean needUpdate = false;
            int subscription = -1;
            ArrayList<Long> delContactIds = new ArrayList<>();
            HashMap<Long, ArrayList<Long>> delRawIdsMap = new HashMap<>();
@@ -309,6 +310,7 @@ public class MergeContactActivity extends ListActivity {
                        }
                    }
                    if (!containsNumber) {
                        needUpdate = true;
                        simNumberList.add(number);
                    }
                }
@@ -326,6 +328,7 @@ public class MergeContactActivity extends ListActivity {
                                }
                            }
                            if (!containsAnr) {
                                needUpdate = true;
                                simNumberList.add(splitAnr[j]);
                            }
                        }
@@ -337,6 +340,7 @@ public class MergeContactActivity extends ListActivity {
                    for (int j = 0; j < splitEmail.length; j++) {
                        if (!TextUtils.isEmpty(splitEmail[j]) && !simEmailList
                                .contains(splitEmail[j])) {
                            needUpdate = true;
                            simEmailList.add(splitEmail[j]);
                        }
                    }
@@ -383,7 +387,9 @@ public class MergeContactActivity extends ListActivity {
            sourceValues.remove(SimContactsConstants.ACCOUNT_TYPE);
            sourceValues.remove(SimContactsConstants.ACCOUNT_NAME);
            // update the contacts in sim.
            int simResult = mSimContactsOperation.update(sourceValues, subscription);
            int simResult = 1;
            if (needUpdate)
                mSimContactsOperation.update(sourceValues, subscription);

            // if update sim contacts fail, stop merging.
            if (simResult <= 0) {
@@ -415,6 +421,9 @@ public class MergeContactActivity extends ListActivity {
                                .CONTENT_URI, String.valueOf(list.get(j)));
                        rawDelList.add(ContentProviderOperation.newDelete(uri).build());
                    }
                } else {
                    Toast.makeText(MergeContactActivity.this, R.string.merge_fail,
                            Toast.LENGTH_SHORT).show();
                }
            }
            return true;
+26 −6
Original line number Diff line number Diff line
@@ -106,6 +106,9 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
    public static final int REQUEST_CODE_PICK_GROUP_MEM = 1001;
    private static final int MAX_CACHE_MEMBER_SIZE = 500;

    //when save completed,close activity directly,no need reload group member.
    private boolean mClose = false;

    public static interface Listener {
        /**
         * Group metadata was not found, close the fragment now.
@@ -239,7 +242,7 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
            onRestoreInstanceState(savedInstanceState);
            if (mStatus == Status.SELECTING_ACCOUNT) {
                // Account select dialog is showing.  Don't setup the editor yet.
            } else if (mStatus == Status.LOADING || getCacheSize() == 0) {
            } else if (mStatus == Status.LOADING || mListToDisplay.size() == 0) {
                startGroupMetaDataLoader();
            } else {
                setupEditorForAccount();
@@ -297,6 +300,12 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
                    mListMembersToRemove);
            outState.putParcelableArrayList(KEY_MEMBERS_TO_DISPLAY,
                    mListToDisplay);
        } else if (mListMembersToAdd.size() + mListMembersToRemove.size()
                < MAX_CACHE_MEMBER_SIZE) {
            outState.putParcelableArrayList(KEY_MEMBERS_TO_ADD,
                    mListMembersToAdd);
            outState.putParcelableArrayList(KEY_MEMBERS_TO_REMOVE,
                    mListMembersToRemove);
        }
    }

@@ -316,6 +325,14 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
        mListMembersToAdd = state.getParcelableArrayList(KEY_MEMBERS_TO_ADD);
        mListMembersToRemove = state.getParcelableArrayList(KEY_MEMBERS_TO_REMOVE);
        mListToDisplay = state.getParcelableArrayList(KEY_MEMBERS_TO_DISPLAY);

        if (mListMembersToAdd == null)
            mListMembersToAdd = new ArrayList<Member>();
        if (mListMembersToRemove == null)
            mListMembersToRemove = new ArrayList<Member>();
        if (mListToDisplay == null)
            mListToDisplay = new ArrayList<Member>();

    }

    private int getCacheSize() {
@@ -662,7 +679,7 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
            }
            return false;
        }

        mClose = true;
        // If we are about to close the editor - there is no need to refresh the data
        getLoaderManager().destroyLoader(LOADER_EXISTING_MEMBERS);

@@ -843,12 +860,15 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
            if (!mClose) {
                bindGroupMetaData(data);

                // Load existing members
                getLoaderManager().initLoader(LOADER_EXISTING_MEMBERS, null,
                        mGroupMemberListLoaderListener);
            }
            mClose = false;
        }

        @Override
        public void onLoaderReset(Loader<Cursor> loader) {}