mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Storing the widget item views in Widget holder, to avoid looks on every bind/recycle
Change-Id: Ifad34f419b1b4f2bf97cc4ff533277867598a719
This commit is contained in:
@@ -91,19 +91,14 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
|
||||
@Override
|
||||
public String scrollToPositionAtProgress(float touchFraction) {
|
||||
// Skip early if widgets are not bound.
|
||||
if (mWidgets == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Skip early if there are no widgets.
|
||||
int rowCount = mWidgets.getPackageSize();
|
||||
if (rowCount == 0) {
|
||||
if (isModelNotReady()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Stop the scroller if it is scrolling
|
||||
stopScroll();
|
||||
|
||||
int rowCount = mWidgets.getPackageSize();
|
||||
getCurScrollState(mScrollPosState, -1);
|
||||
float pos = rowCount * touchFraction;
|
||||
int availableScrollHeight = getAvailableScrollHeight(rowCount);
|
||||
@@ -121,14 +116,7 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
|
||||
@Override
|
||||
public void onUpdateScrollbar(int dy) {
|
||||
// Skip early if widgets are not bound.
|
||||
if (mWidgets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip early if there are no widgets.
|
||||
int rowCount = mWidgets.getPackageSize();
|
||||
if (rowCount == 0) {
|
||||
mScrollbar.setThumbOffset(-1, -1);
|
||||
if (isModelNotReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +127,7 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronizeScrollBarThumbOffsetToViewScroll(mScrollPosState, rowCount);
|
||||
synchronizeScrollBarThumbOffsetToViewScroll(mScrollPosState, mWidgets.getPackageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,15 +139,10 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
|
||||
stateOut.itemPos = -1;
|
||||
|
||||
// Skip early if widgets are not bound.
|
||||
if (mWidgets == null) {
|
||||
if (isModelNotReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Return early if there are no items
|
||||
int rowCount = mWidgets.getPackageSize();
|
||||
if (rowCount == 0) {
|
||||
return;
|
||||
}
|
||||
View child = getChildAt(0);
|
||||
int position = getChildPosition(child);
|
||||
|
||||
@@ -178,4 +161,8 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
|
||||
View child = getChildAt(0);
|
||||
return child.getMeasuredHeight() * rowIndex;
|
||||
}
|
||||
|
||||
private boolean isModelNotReady() {
|
||||
return mWidgets == null || mWidgets.getPackageSize() == 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user