зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset c1a1079daea1 (bug 1220928)
This commit is contained in:
Родитель
b10f5a4809
Коммит
401ca562d8
|
@ -47,7 +47,6 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
|
||||
private List<RemoteClient> remoteClients = Collections.emptyList();
|
||||
private List<RemoteTab> clientChildren;
|
||||
private int remoteClientIndexOfParent = -1;
|
||||
private Cursor historyCursor;
|
||||
|
||||
// Maintain group collapsed and hidden state. Only accessed from the UI thread.
|
||||
|
@ -62,7 +61,9 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
|
||||
private final Context context;
|
||||
|
||||
public CombinedHistoryAdapter(Context context, int savedParentIndex) {
|
||||
private boolean inChildView = false;
|
||||
|
||||
public CombinedHistoryAdapter(Context context) {
|
||||
super();
|
||||
this.context = context;
|
||||
sectionHeaders = new SparseArray<>();
|
||||
|
@ -75,7 +76,6 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
if (sState == null) {
|
||||
sState = new RemoteTabsExpandableListState(GeckoSharedPrefs.forProfile(context));
|
||||
}
|
||||
remoteClientIndexOfParent = savedParentIndex;
|
||||
}
|
||||
|
||||
public void setClients(List<RemoteClient> clients) {
|
||||
|
@ -184,30 +184,22 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
return null;
|
||||
}
|
||||
|
||||
public int getParentIndex() {
|
||||
return remoteClientIndexOfParent;
|
||||
}
|
||||
|
||||
private boolean isInChildView() {
|
||||
return remoteClientIndexOfParent != -1;
|
||||
}
|
||||
|
||||
public void showChildView(int parentPosition) {
|
||||
if (clientChildren == null) {
|
||||
clientChildren = new ArrayList<>();
|
||||
}
|
||||
// Handle "back" view.
|
||||
clientChildren.add(null);
|
||||
remoteClientIndexOfParent = transformAdapterPositionForDataStructure(ItemType.CLIENT, parentPosition);
|
||||
clientChildren.addAll(remoteClients.get(remoteClientIndexOfParent).tabs);
|
||||
clientChildren.addAll(remoteClients.get(transformAdapterPositionForDataStructure(ItemType.CLIENT, parentPosition)).tabs);
|
||||
inChildView = true;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public boolean exitChildView() {
|
||||
if (!isInChildView()) {
|
||||
if (!inChildView) {
|
||||
return false;
|
||||
}
|
||||
remoteClientIndexOfParent = -1;
|
||||
inChildView = false;
|
||||
clientChildren.clear();
|
||||
notifyDataSetChanged();
|
||||
return true;
|
||||
|
@ -293,7 +285,7 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (isInChildView()) {
|
||||
if (inChildView) {
|
||||
if (position == 0) {
|
||||
return ItemType.itemTypeToViewType(ItemType.NAVIGATION_BACK);
|
||||
}
|
||||
|
@ -318,13 +310,8 @@ public class CombinedHistoryAdapter extends RecyclerView.Adapter<CombinedHistory
|
|||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (isInChildView()) {
|
||||
if (clientChildren == null) {
|
||||
clientChildren = new ArrayList<>();
|
||||
clientChildren.add(null);
|
||||
clientChildren.addAll(remoteClients.get(remoteClientIndexOfParent).tabs);
|
||||
}
|
||||
return clientChildren.size();
|
||||
if (inChildView) {
|
||||
return (clientChildren == null) ? 0 : clientChildren.size();
|
||||
} else {
|
||||
final int historySize = historyCursor == null ? 0 : historyCursor.getCount();
|
||||
return remoteClients.size() + historySize + sectionHeaders.size();
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.app.AlertDialog;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
|
@ -83,7 +82,6 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
private CombinedHistoryRecyclerView mRecyclerView;
|
||||
private CombinedHistoryAdapter mAdapter;
|
||||
private CursorLoaderCallbacks mCursorLoaderCallbacks;
|
||||
private int mSavedParentIndex = -1;
|
||||
|
||||
private OnPanelLevelChangeListener.PanelLevel mPanelLevel = OnPanelLevelChangeListener.PanelLevel.PARENT;
|
||||
private Button mPanelFooterButton;
|
||||
|
@ -108,7 +106,7 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mRecyclerView = (CombinedHistoryRecyclerView) view.findViewById(R.id.combined_recycler_view);
|
||||
mAdapter = new CombinedHistoryAdapter(getContext(), mSavedParentIndex);
|
||||
mAdapter = new CombinedHistoryAdapter(getContext());
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
|
||||
|
@ -127,17 +125,6 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (isVisible()) {
|
||||
// The parent stack is saved just so that the folder state can be
|
||||
// restored on rotation.
|
||||
mSavedParentIndex = mAdapter.getParentIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(LOADER_ID_HISTORY, null, mCursorLoaderCallbacks);
|
||||
|
@ -298,7 +285,7 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
break;
|
||||
|
||||
case CHILD:
|
||||
final JSONArray tabUrls = mAdapter.getCurrentChildTabs();
|
||||
final JSONArray tabUrls = ((CombinedHistoryAdapter) mRecyclerView.getAdapter()).getCurrentChildTabs();
|
||||
if (tabUrls != null) {
|
||||
final JSONObject message = new JSONObject();
|
||||
try {
|
||||
|
@ -438,7 +425,7 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.home_remote_tabs_hide_client) {
|
||||
mAdapter.removeItem(info.position);
|
||||
((CombinedHistoryAdapter) mRecyclerView.getAdapter()).removeItem(info.position);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -465,7 +452,7 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
|
|||
|
||||
@Override
|
||||
public void onClients(List<RemoteClient> clients) {
|
||||
mAdapter.unhideClients(clients);
|
||||
((CombinedHistoryAdapter) mRecyclerView.getAdapter()).unhideClients(clients);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче