diff options
author | Tony Wickham <twickham@google.com> | 2018-03-12 18:08:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-12 18:08:11 +0000 |
commit | dcdeffdfd5446886759e128d4b59ffa1cb3c2dc1 (patch) | |
tree | 55ac09334c0658372e55e11f3dbcb59171214d99 /quickstep | |
parent | 4c8fbb9c95f9952ce30669b59c041d423b46750a (diff) | |
parent | 8ee1fe5041b9046536d0bc6109a0c7ac4f251c4b (diff) | |
download | android_packages_apps_Trebuchet-dcdeffdfd5446886759e128d4b59ffa1cb3c2dc1.tar.gz android_packages_apps_Trebuchet-dcdeffdfd5446886759e128d4b59ffa1cb3c2dc1.tar.bz2 android_packages_apps_Trebuchet-dcdeffdfd5446886759e128d4b59ffa1cb3c2dc1.zip |
Merge "Code cleanup: remove some unnecessary methods/variables" into ub-launcher3-master
Diffstat (limited to 'quickstep')
-rw-r--r-- | quickstep/src/com/android/quickstep/QuickScrubController.java | 6 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/RecentsView.java | 38 |
2 files changed, 15 insertions, 29 deletions
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java index dc1c0d2ac..b9d96b97e 100644 --- a/quickstep/src/com/android/quickstep/QuickScrubController.java +++ b/quickstep/src/com/android/quickstep/QuickScrubController.java @@ -50,7 +50,6 @@ public class QuickScrubController implements OnAlarmListener { private boolean mInQuickScrub; private int mQuickScrubSection; - private int mStartPage; private boolean mStartedFromHome; private boolean mHasAlarmRun; @@ -65,7 +64,6 @@ public class QuickScrubController implements OnAlarmListener { public void onQuickScrubStart(boolean startingFromHome) { mInQuickScrub = true; - mStartPage = 0; mStartedFromHome = startingFromHome; mQuickScrubSection = 0; mHasAlarmRun = false; @@ -139,7 +137,7 @@ public class QuickScrubController implements OnAlarmListener { } private void goToPageWithHaptic(int pageToGoTo) { - pageToGoTo = Utilities.boundToRange(pageToGoTo, mStartPage, mRecentsView.getPageCount() - 1); + pageToGoTo = Utilities.boundToRange(pageToGoTo, 0, mRecentsView.getPageCount() - 1); if (pageToGoTo != mRecentsView.getNextPage()) { int duration = Math.abs(pageToGoTo - mRecentsView.getNextPage()) * QUICKSCRUB_SNAP_DURATION_PER_PAGE; @@ -155,7 +153,7 @@ public class QuickScrubController implements OnAlarmListener { if (mQuickScrubSection == NUM_QUICK_SCRUB_SECTIONS && currPage < mRecentsView.getPageCount() - 1) { goToPageWithHaptic(currPage + 1); - } else if (mQuickScrubSection == 0 && currPage > mStartPage) { + } else if (mQuickScrubSection == 0 && currPage > 0) { goToPageWithHaptic(currPage - 1); } mHasAlarmRun = true; diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java index fdfca84ab..9481390f1 100644 --- a/quickstep/src/com/android/quickstep/RecentsView.java +++ b/quickstep/src/com/android/quickstep/RecentsView.java @@ -86,7 +86,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer private TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() { @Override public void onTaskSnapshotChanged(int taskId, ThumbnailData snapshot) { - for (int i = mFirstTaskIndex; i < getChildCount(); i++) { + for (int i = 0; i < getChildCount(); i++) { final TaskView taskView = (TaskView) getChildAt(i); if (taskView.getTask().key.id == taskId) { taskView.getThumbnail().setThumbnail(taskView.getTask(), snapshot); @@ -97,7 +97,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer }; private RecentsViewStateController mStateController; - private int mFirstTaskIndex; private final RecentsModel mModel; private int mLoadPlanId = -1; @@ -152,7 +151,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } public TaskView updateThumbnail(int taskId, ThumbnailData thumbnailData) { - for (int i = mFirstTaskIndex; i < getChildCount(); i++) { + for (int i = 0; i < getChildCount(); i++) { final TaskView taskView = (TaskView) getChildAt(i); if (taskView.getTask().key.id == taskId) { taskView.onTaskDataLoaded(taskView.getTask(), thumbnailData); @@ -194,7 +193,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer protected void onFinishInflate() { super.onFinishInflate(); Resources res = getResources(); - mFirstTaskIndex = getPageCount(); mFastFlingVelocity = res.getDimensionPixelSize(R.dimen.recents_fast_fling_velocity); } @@ -255,10 +253,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } } - public int getFirstTaskIndex() { - return mFirstTaskIndex; - } - public boolean isTaskViewVisible(TaskView tv) { // For now, just check if it's the active task or an adjacent task return Math.abs(indexOfChild(tv) - getNextPage()) <= 1; @@ -316,7 +310,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer final ArrayList<Task> tasks = new ArrayList<>(stack.getTasks()); setLayoutTransition(null); - final int requiredChildCount = tasks.size() + mFirstTaskIndex; + final int requiredChildCount = tasks.size(); for (int i = getChildCount(); i < requiredChildCount; i++) { final TaskView taskView = (TaskView) inflater.inflate(R.layout.task, this, false); addView(taskView); @@ -331,8 +325,8 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer setLayoutTransition(mLayoutTransition); // Rebind and reset all task views - for (int i = tasks.size() - 1; i >= 0; i--) { - final int pageIndex = tasks.size() - i - 1 + mFirstTaskIndex; + for (int i = requiredChildCount - 1; i >= 0; i--) { + final int pageIndex = requiredChildCount - i - 1; final Task task = tasks.get(i); final TaskView taskView = (TaskView) getChildAt(pageIndex); taskView.bind(task); @@ -462,9 +456,9 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer private void loadVisibleTaskData() { RecentsTaskLoader loader = mModel.getRecentsTaskLoader(); int centerPageIndex = getPageNearestToCenterOfScreen(); - int lower = Math.max(mFirstTaskIndex, centerPageIndex - 2); + int lower = Math.max(0, centerPageIndex - 2); int upper = Math.min(centerPageIndex + 2, getChildCount() - 1); - for (int i = mFirstTaskIndex; i < getChildCount(); i++) { + for (int i = 0; i < getChildCount(); i++) { TaskView taskView = (TaskView) getChildAt(i); Task task = taskView.getTask(); boolean visible = lower <= i && i <= upper; @@ -486,7 +480,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer public void onTaskDismissed(TaskView taskView) { ActivityManagerWrapper.getInstance().removeTask(taskView.getTask().key.id); removeView(taskView); - if (getTaskCount() == 0) { + if (getChildCount() == 0) { mLauncher.getStateManager().goToState(NORMAL); } } @@ -496,10 +490,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer setCurrentPage(0); } - public int getTaskCount() { - return getChildCount() - mFirstTaskIndex; - } - public int getRunningTaskId() { return mRunningTaskId; } @@ -523,17 +513,17 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer */ public void showTask(int runningTaskId) { boolean needsReload = false; - if (getTaskCount() == 0) { + if (getChildCount() == 0) { needsReload = true; // Add an empty view for now setLayoutTransition(null); final TaskView taskView = (TaskView) LayoutInflater.from(getContext()) .inflate(R.layout.task, this, false); - addView(taskView, mFirstTaskIndex); + addView(taskView, 0); setLayoutTransition(mLayoutTransition); } mRunningTaskId = runningTaskId; - setCurrentPage(mFirstTaskIndex); + setCurrentPage(0); if (!needsReload) { needsReload = !mModel.isLoadPlanValid(mLoadPlanId); } @@ -542,9 +532,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } else { loadVisibleTaskData(); } - if (mCurrentPage >= mFirstTaskIndex) { - getPageAt(mCurrentPage).setAlpha(0); - } + getPageAt(mCurrentPage).setAlpha(0); } public QuickScrubController getQuickScrubController() { @@ -561,7 +549,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer private void applyIconScale(boolean animate) { float scale = mFirstTaskIconScaledDown ? 0 : 1; - TaskView firstTask = (TaskView) getChildAt(mFirstTaskIndex); + TaskView firstTask = (TaskView) getChildAt(0); if (firstTask != null) { if (animate) { firstTask.animateIconToScale(scale); |