Remove code duplication
Bug: 72222505 Test: Manual Change-Id: I6ae6ac7474b44c16bd765635e32d2e843bc02cac
This commit is contained in:
parent
b05b489f04
commit
98913d0c95
|
@ -1495,12 +1495,20 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||||
return Math.abs(delta) > 0;
|
return Math.abs(delta) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollLeft() {
|
public boolean scrollLeft() {
|
||||||
if (getNextPage() > 0) snapToPage(getNextPage() - 1);
|
if (getNextPage() > 0) {
|
||||||
|
snapToPage(getNextPage() - 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollRight() {
|
public boolean scrollRight() {
|
||||||
if (getNextPage() < getChildCount() -1) snapToPage(getNextPage() + 1);
|
if (getNextPage() < getChildCount() - 1) {
|
||||||
|
snapToPage(getNextPage() + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1551,22 +1559,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||||
event.setScrollable(getPageCount() > 1);
|
event.setScrollable(getPageCount() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean accessibilityScrollLeft() {
|
|
||||||
if (getCurrentPage() > 0) {
|
|
||||||
scrollLeft();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean accessibilityScrollRight() {
|
|
||||||
if (getCurrentPage() < getPageCount() - 1) {
|
|
||||||
scrollRight();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||||
if (super.performAccessibilityAction(action, arguments)) {
|
if (super.performAccessibilityAction(action, arguments)) {
|
||||||
|
@ -1575,12 +1567,12 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||||
final boolean pagesFlipped = isPageOrderFlipped();
|
final boolean pagesFlipped = isPageOrderFlipped();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||||
if (pagesFlipped ? accessibilityScrollLeft() : accessibilityScrollRight()) {
|
if (pagesFlipped ? scrollLeft() : scrollRight()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
|
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
|
||||||
if (pagesFlipped ? accessibilityScrollRight() : accessibilityScrollLeft()) {
|
if (pagesFlipped ? scrollRight() : scrollLeft()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2961,25 +2961,29 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scrollLeft() {
|
public boolean scrollLeft() {
|
||||||
|
boolean result = false;
|
||||||
if (!workspaceInModalState() && !mIsSwitchingState) {
|
if (!workspaceInModalState() && !mIsSwitchingState) {
|
||||||
super.scrollLeft();
|
result = super.scrollLeft();
|
||||||
}
|
}
|
||||||
Folder openFolder = Folder.getOpen(mLauncher);
|
Folder openFolder = Folder.getOpen(mLauncher);
|
||||||
if (openFolder != null) {
|
if (openFolder != null) {
|
||||||
openFolder.completeDragExit();
|
openFolder.completeDragExit();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scrollRight() {
|
public boolean scrollRight() {
|
||||||
|
boolean result = false;
|
||||||
if (!workspaceInModalState() && !mIsSwitchingState) {
|
if (!workspaceInModalState() && !mIsSwitchingState) {
|
||||||
super.scrollRight();
|
result = super.scrollRight();
|
||||||
}
|
}
|
||||||
Folder openFolder = Folder.getOpen(mLauncher);
|
Folder openFolder = Folder.getOpen(mLauncher);
|
||||||
if (openFolder != null) {
|
if (openFolder != null) {
|
||||||
openFolder.completeDragExit();
|
openFolder.completeDragExit();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue