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

Commit 757920b6 authored by Danesh M's avatar Danesh M
Browse files

Dialer : Don't hold on to views used in listviews

Lets not hold references to views used inside of a listview adapter since it
will try to recycle it and if something is holding a reference to that view it is
trying to recycle, it will block things on the ui thread and queue up all events during that time
and only dispatch once focus is lost.

Change-Id: Idd113e4f13f08d706a33fd4d07fd9a12f5382671
parent 6b47b9af
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
    <Button
            android:id="@+id/all_contacts_button"
            android:fontFamily="@string/favorites_menu_all_contacts_font_family"
            android:onClick="allContactsClick"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/favorites_menu_all_contacts_height"
            android:paddingLeft="@dimen/favorites_menu_padding_horizontal"
+4 −0
Original line number Diff line number Diff line
@@ -1037,6 +1037,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
    }

    public void allContactsClick(View v) {
        onShowAllContacts();
    }

    @Override
    public void onShowAllContacts() {
        final Intent intent = new Intent(this, AllContactsActivity.class);
+1 −19
Original line number Diff line number Diff line
@@ -199,7 +199,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen

    private PhoneFavoriteListView mListView;

    private View mPhoneFavoritesMenu;
    private View mContactTileFrame;

    private TileInteractionTeaserView mTileInteractionTeaserView;
@@ -291,16 +290,13 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen

        mEmptyView = mParentView.findViewById(R.id.phone_no_favorites_view);

        mPhoneFavoritesMenu = inflater.inflate(R.layout.phone_favorites_menu, mListView, false);
        prepareFavoritesMenu(mPhoneFavoritesMenu);

        mContactTileFrame = mParentView.findViewById(R.id.contact_tile_frame);

        mTileInteractionTeaserView = (TileInteractionTeaserView) inflater.inflate(
                R.layout.tile_interactions_teaser_view, mListView, false);

        mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), this, mContactTileAdapter,
                mCallLogAdapter, mPhoneFavoritesMenu, mTileInteractionTeaserView);
                mCallLogAdapter, mTileInteractionTeaserView);

        mTileInteractionTeaserView.setAdapter(mAdapter);

@@ -663,18 +659,4 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
        fetchCalls();
    }

    /**
     * Prepares the favorites menu which contains the static label "Speed Dial" and the
     * "All Contacts" button.  Sets the onClickListener for the "All Contacts" button.
     */
    private void prepareFavoritesMenu(View favoritesMenu) {
        Button allContactsButton = (Button) favoritesMenu.findViewById(R.id.all_contacts_button);
        // Set the onClick listener for the button to bring up the all contacts view.
        allContactsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                showAllContacts();
            }
        });
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
    private static final int FAVORITES_MENU_ITEM_ID = -3;
    private final PhoneFavoritesTileAdapter mContactTileAdapter;
    private final CallLogAdapter mCallLogAdapter;
    private final View mPhoneFavoritesMenu;
    private final PhoneFavoriteFragment mFragment;
    private final TileInteractionTeaserView mTileInteractionTeaserView;

@@ -103,7 +102,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
            PhoneFavoriteFragment fragment,
            PhoneFavoritesTileAdapter contactTileAdapter,
            CallLogAdapter callLogAdapter,
            View phoneFavoritesMenu,
            TileInteractionTeaserView tileInteractionTeaserView) {
        final Resources resources = context.getResources();
        mContext = context;
@@ -114,7 +112,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
        mObserver = new CustomDataSetObserver();
        mCallLogAdapter.registerDataSetObserver(mObserver);
        mContactTileAdapter.registerDataSetObserver(mObserver);
        mPhoneFavoritesMenu = phoneFavoritesMenu;
        mTileInteractionTeaserView = tileInteractionTeaserView;
        mCallLogQueryHandler = new CallLogQueryHandler(mContext.getContentResolver(),
                mCallLogQueryHandlerListener);
@@ -262,9 +259,12 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
            wrapper.addView(view);
            return wrapper;
        } else if (position == callLogAdapterCount) {
            if (convertView == null) {
                convertView = View.inflate(mContext, R.layout.phone_favorites_menu, null);
            }
            // If position is just after the entries in the mCallLogAdapter (most recent call),
            // return the favorites menu.
            return mPhoneFavoritesMenu;
            return convertView;
        }

        // Set position to the position of the actual favorite contact in the favorites adapter.