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

Commit 5b9215ab authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert "Avoid selecting group item every time when groups are loaded""...

Merge "Revert "Avoid selecting group item every time when groups are loaded"" into ub-contactsdialer-f-dev
parents 91c8356a c1c8baae
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package com.android.contacts.group;

import java.util.Objects;

/**
 * Meta-data for a contact group.  We load all groups associated with the contact's
 * constituent accounts.
@@ -85,36 +83,4 @@ public final class GroupListItem {
    public String getSystemId() {
        return mSystemId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mAccountName, mAccountType, mDataSet, mGroupId, mTitle,
                mIsFirstGroupInAccount, mMemberCount, mIsReadOnly, mSystemId);
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }

        if (!(other instanceof GroupListItem)) {
            return false;
        }

        final GroupListItem otherGroup = (GroupListItem) other;
        if (!Objects.equals(mAccountName, otherGroup.getAccountName())
                || !Objects.equals(mAccountType, otherGroup.getAccountType())
                || !Objects.equals(mDataSet, otherGroup.getDataSet())
                || !(mGroupId == otherGroup.getGroupId())
                || !Objects.equals(mTitle, otherGroup.getTitle())
                || !(mIsFirstGroupInAccount == otherGroup.isFirstGroupInAccount())
                || !(mMemberCount == otherGroup.getMemberCount())
                || !(mIsReadOnly == otherGroup.isReadOnly())
                || !Objects.equals(mSystemId, otherGroup.getSystemId())) {
            return false;
        }

        return true;
    }
}
 No newline at end of file
+3 −19
Original line number Diff line number Diff line
@@ -18,11 +18,11 @@ package com.android.contacts.group;

import android.app.Fragment;
import android.app.LoaderManager;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;

import com.android.contacts.GroupListLoader;

@@ -34,8 +34,6 @@ import java.util.List;
 */
public final class GroupsFragment extends Fragment {

    private static final String TAG = GroupsFragment.class.getSimpleName();

    private static final int LOADER_GROUPS = 1;

    /**
@@ -59,26 +57,12 @@ public final class GroupsFragment extends Fragment {

                @Override
                public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
                    final List<GroupListItem> newGroupListItems = new ArrayList<>();
                    mGroupListItems.clear();
                    for (int i = 0; i < data.getCount(); i++) {
                        if (data.moveToNext()) {
                            newGroupListItems.add(GroupUtil.getGroupListItem(data, i));
                        }
                    }

                    if (mGroupListItems.equals(newGroupListItems)) {
                        if (Log.isLoggable(TAG, Log.VERBOSE)) {
                            Log.v(TAG, "The same groups loaded, returning.");
                            mGroupListItems.add(GroupUtil.getGroupListItem(data, i));
                        }
                        return;
                    }

                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "New group(s) loaded.");
                    }

                    mGroupListItems.clear();
                    mGroupListItems.addAll(newGroupListItems);
                    if (mListener != null) {
                        mListener.onGroupsLoaded(mGroupListItems);
                    }