mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Converting widget panel into a floating view
> The widget panel is only inflated when needed > Using the swipe up/down interaction for widgets tray > Removing additional view wrappers from all-apps > Widget tray is preserved across activity recreation > Launcher no longer has WIDGET state, the actual code around the states will be removed in a follow-up cl Bug: 67678570 Bug: 67585158 Change-Id: Ia29a7c33ec81e6c53cc24e2906b7022b6f41755b
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.widget;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.IconCache;
|
||||
@@ -26,26 +27,18 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Do diff on widget's tray list items and call the {@link NotifyListener} methods accordingly.
|
||||
* Do diff on widget's tray list items and call the {@link RecyclerView.Adapter}
|
||||
* methods accordingly.
|
||||
*/
|
||||
public class WidgetsDiffReporter {
|
||||
private final boolean DEBUG = false;
|
||||
private final String TAG = "WidgetsDiffReporter";
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String TAG = "WidgetsDiffReporter";
|
||||
|
||||
private final IconCache mIconCache;
|
||||
private NotifyListener mListener;
|
||||
private final RecyclerView.Adapter mListener;
|
||||
|
||||
public interface NotifyListener {
|
||||
void notifyDataSetChanged();
|
||||
void notifyItemChanged(int index);
|
||||
void notifyItemInserted(int index);
|
||||
void notifyItemRemoved(int index);
|
||||
}
|
||||
|
||||
public WidgetsDiffReporter(IconCache iconCache) {
|
||||
public WidgetsDiffReporter(IconCache iconCache, RecyclerView.Adapter listener) {
|
||||
mIconCache = iconCache;
|
||||
}
|
||||
|
||||
public void setListener(NotifyListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@@ -55,9 +48,17 @@ public class WidgetsDiffReporter {
|
||||
Log.d(TAG, "process oldEntries#=" + currentEntries.size()
|
||||
+ " newEntries#=" + newEntries.size());
|
||||
}
|
||||
if (currentEntries.size() == 0 && newEntries.size() > 0) {
|
||||
currentEntries.addAll(newEntries);
|
||||
mListener.notifyDataSetChanged();
|
||||
// Early exit if either of the list is empty
|
||||
if (currentEntries.isEmpty() || newEntries.isEmpty()) {
|
||||
// Skip if both list are empty.
|
||||
// On rotation, we open the widget tray with empty. Then try to fetch the list again
|
||||
// when the animation completes (which still gives empty). And we get the final result
|
||||
// when the bind actually completes.
|
||||
if (currentEntries.size() != newEntries.size()) {
|
||||
currentEntries.clear();
|
||||
currentEntries.addAll(newEntries);
|
||||
mListener.notifyDataSetChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
ArrayList<WidgetListRowEntry> orgEntries =
|
||||
|
||||
Reference in New Issue
Block a user