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

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

Merge "Dialer: FPS is low when scrolling call logs"

parents 0b597cc7 78e1f922
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -71,7 +73,8 @@ import java.util.LinkedList;
 * Adapter class to fill in data for the Call Log.
 */
public class CallLogAdapter extends GroupingListAdapter
        implements CallLogAdapterHelper.Callback, CallLogGroupBuilder.GroupCreator {
        implements CallLogAdapterHelper.Callback, CallLogGroupBuilder.GroupCreator,
        OnScrollListener {

    private static final String TAG = CallLogAdapter.class.getSimpleName();
    private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10;
@@ -470,7 +473,10 @@ public class CallLogAdapter extends GroupingListAdapter
                    Calls.DURATION_TYPE_ACTIVE, subId, operator);
        }

        if (!mAdapterHelper.isBusy()) {
            // Only update views when ListView's scroll state is not SCROLL_STATE_FLING.
            mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details);
        }

        int contactType = ContactPhotoManager.TYPE_DEFAULT;

@@ -536,10 +542,8 @@ public class CallLogAdapter extends GroupingListAdapter
     * @return The day group for the call.
     */
    private int getDayGroupForCall(long callId) {
        if (mDayGroups.containsKey(callId)) {
            return mDayGroups.get(callId);
        }
        return CallLogGroupBuilder.DAY_GROUP_NONE;
        Integer result = mDayGroups.get(callId);
        return result == null ? CallLogGroupBuilder.DAY_GROUP_NONE : result.intValue();
    }
    /**
     * Determines if a call log row with the given Id is expanded.
@@ -1155,4 +1159,27 @@ public class CallLogAdapter extends GroupingListAdapter
        DialerUtils.startActivityWithErrorToast(mContext, intent,
                R.string.add_contact_not_available);
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        switch (scrollState) {
            case OnScrollListener.SCROLL_STATE_IDLE:
                mAdapterHelper.setBusy(false);
                dataSetChanged();
                break;
            case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
                mAdapterHelper.setBusy(false);
                break;
            case OnScrollListener.SCROLL_STATE_FLING:
                // Do not update views when scroll state is SCROLL_STATE_FLING
                mAdapterHelper.setBusy(true);
                break;
        }
    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                         int totalItemCount) {
        // no-op
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -137,6 +137,9 @@ public class CallLogAdapterHelper implements ViewTreeObserver.OnPreDrawListener
                // Check if thread is finished, and if so return immediately.
                if (mDone) return;

                // only update contact info when scroll state is not fling.
                if (mBusy) continue;

                // Obtain next request, if any is available.
                // Keep synchronized section small.
                ContactInfoRequest req = null;
@@ -201,6 +204,8 @@ public class CallLogAdapterHelper implements ViewTreeObserver.OnPreDrawListener
    /** Can be set to true by tests to disable processing of requests. */
    private volatile boolean mRequestProcessingDisabled = false;

    private boolean mBusy;

    /**
     * List of requests to update contact details.
     * <p>
@@ -228,6 +233,14 @@ public class CallLogAdapterHelper implements ViewTreeObserver.OnPreDrawListener
        }
    };

    public void setBusy(boolean isBusy) {
        mBusy = isBusy;
    }

    public boolean isBusy(){
        return mBusy;
    }

    /**
     * Enqueues a request to look up the contact details for the given phone number.
     * <p>
+1 −0
Original line number Diff line number Diff line
@@ -312,6 +312,7 @@ public class CallLogFragment extends AnalyticsListFragment
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getListView().setEmptyView(view.findViewById(R.id.empty_list_view));
        getListView().setOnScrollListener(mAdapter);
        getListView().setItemsCanFocus(true);
        maybeAddFooterView();