use of android.view.View in project Launcher3 by chislon.
the class PagedView method focusableViewAvailable.
/**
* If one of our descendant views decides that it could be focused now, only
* pass that along if it's on the current page.
*
* This happens when live folders requery, and if they're off page, they
* end up calling requestFocus, which pulls it on page.
*/
@Override
public void focusableViewAvailable(View focused) {
View current = getPageAt(mCurrentPage);
View v = focused;
while (true) {
if (v == current) {
super.focusableViewAvailable(focused);
return;
}
if (v == this) {
return;
}
ViewParent parent = v.getParent();
if (parent instanceof View) {
v = (View) v.getParent();
} else {
return;
}
}
}
use of android.view.View in project Launcher3 by chislon.
the class PagedView method requestDisallowInterceptTouchEvent.
/**
* {@inheritDoc}
*/
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
if (disallowIntercept) {
// We need to make sure to cancel our long press if
// a scrollable widget takes over touch events
final View currentPage = getPageAt(mCurrentPage);
currentPage.cancelLongPress();
}
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
use of android.view.View in project Launcher3 by chislon.
the class PagedView method getLayoutTransitionOffsetForPage.
// While layout transitions are occurring, a child's position may stray from its baseline
// position. This method returns the magnitude of this stray at any given time.
public int getLayoutTransitionOffsetForPage(int index) {
if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) {
return 0;
} else {
View child = getChildAt(index);
int scrollOffset = (getViewportWidth() - child.getMeasuredWidth()) / 2;
int baselineX = mPageScrolls[index] + scrollOffset + getViewportOffsetX();
return (int) (child.getX() - baselineX);
}
}
use of android.view.View in project Launcher3 by chislon.
the class PagedViewCellLayout method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean result = super.onTouchEvent(event);
int count = getPageChildCount();
if (count > 0) {
// We only intercept the touch if we are tapping in empty space after the final row
View child = getChildOnPageAt(count - 1);
int bottom = child.getBottom();
int numRows = (int) Math.ceil((float) getPageChildCount() / getCellCountX());
if (numRows < getCellCountY()) {
// Add a little bit of buffer if there is room for another row
bottom += mCellHeight / 2;
}
result = result || (event.getY() < bottom);
}
return result;
}
use of android.view.View in project Launcher3 by chislon.
the class Workspace method reinflateWidgetsIfNecessary.
protected void reinflateWidgetsIfNecessary() {
final int clCount = getChildCount();
for (int i = 0; i < clCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
ShortcutAndWidgetContainer swc = cl.getShortcutsAndWidgets();
final int itemCount = swc.getChildCount();
for (int j = 0; j < itemCount; j++) {
View v = swc.getChildAt(j);
if (v.getTag() instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag();
LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView;
if (lahv != null && lahv.orientationChangedSincedInflation()) {
mLauncher.removeAppWidget(info);
// Remove the current widget which is inflated with the wrong orientation
cl.removeView(lahv);
mLauncher.bindAppWidget(info);
}
}
}
}
}
Aggregations