List of usage examples for android.view ViewGroup getChildAt
public View getChildAt(int index)
From source file:com.yangc.swipebacklayout.helper.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *///from w ww. j a va 2 s .c o m protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance // first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.juick.android.JuickMessagesAdapter.java
public void recycleView(View view) { if (view instanceof ViewGroup) { ListRowRuntime lrr = (ListRowRuntime) view.getTag(); if (lrr != null) { if (lrr.userpicListener != null) { lrr.removeListenerIfExists(); }//from w w w. j av a2 s . c o m } ViewGroup vg = (ViewGroup) view; if (vg.getChildCount() > 1 && vg.getChildAt(1) instanceof ImageGallery && vg instanceof PressableLinearLayout) { PressableLinearLayout pll = (PressableLinearLayout) vg; // our view ImageGallery gallery = (ImageGallery) vg.getChildAt(1); Object tag = gallery.getTag(); if (tag instanceof HashMap) { HashMap<Integer, ImageLoaderConfiguration> loaders = (HashMap<Integer, ImageLoaderConfiguration>) tag; for (ImageLoaderConfiguration imageLoader : loaders.values()) { imageLoader.loader.terminate(); } } pll.blockLayoutRequests = true; gallery.cleanup(); gallery.setTag(null); vg.removeViewAt(1); vg.measure(View.MeasureSpec.makeMeasureSpec(vg.getRight() - vg.getLeft(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); vg.layout(vg.getLeft(), vg.getTop(), vg.getRight(), vg.getTop() + vg.getMeasuredHeight()); pll.blockLayoutRequests = false; } } }
From source file:com.cyanogenmod.filemanager.ui.widgets.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *//* ww w . j a va2 s .com*/ protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (v.canScrollHorizontally(-dx) || v.canScrollVertically(-dy)); }
From source file:com.dk.view.FolderDrawerLayout.java
private void replaceView() { ViewGroup left = (ViewGroup) findDrawerWithGravity(Gravity.LEFT); mLeftCache = left.getChildAt(0); left.removeAllViews();// w w w . ja v a 2 s .c om mMeshImageView = new MeshImageView(getContext()); mMeshImageView.setImageBitmap(mDrawingCache); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-1, -1); left.addView(mMeshImageView, params); if (isDrawerOpen(Gravity.LEFT)) { mCoreCalc.setDirection(Direction.LEFT); } else { mCoreCalc.setDirection(Direction.RIGHT); } mMeshImageView.setMeshVerts(mCoreCalc.createOffsetVerts(1, mInitialMotionY)); // mMeshImageView.getViewTreeObserver().addOnPreDrawListener(new // OnPreDrawListener() { // // @Override // public boolean onPreDraw() { // // // return false; // } // }); }
From source file:de.azapps.mirakel.main_activity.MainActivity.java
/** * Initialize the ViewPager and setup the rest of the layout *///from w w w .j av a 2 s. c om private void setupLayout() { if (this.currentList == null) { setCurrentList(SpecialList.firstSpecialSafe()); } // clear tabletfragments final ViewGroup all = (ViewGroup) this.findViewById(R.id.multi_pane_box); if ((all != null) && MirakelCommonPreferences.isTablet()) { for (int i = 0; i < all.getChildCount(); i++) { final ViewGroup group = (ViewGroup) all.getChildAt(i); group.removeAllViews(); Log.d(TAG, "Clear view " + i); } } // Initialize ViewPager /* * TODO We need the try catch because it throws sometimes a * runtimeexception when adding fragments. */ try { initViewPager(); } catch (final Exception e) { Log.wtf(TAG, "initViewPager throwed an exception", e); } initNavDrawer(); this.startIntent = getIntent(); handleIntent(this.startIntent); }
From source file:com.dk.view.FolderDrawerLayout.java
private boolean createCache() { ViewGroup left = (ViewGroup) findDrawerWithGravity(Gravity.LEFT); if (left.getChildCount() > 0 && !(left.getChildAt(0) instanceof MeshImageView)) { mDrawingCache = drawViewToBitmap(mDrawingCache, left, left.getWidth(), left.getHeight(), 1, new BitmapDrawable()); if (mCoreCalc == null) mCoreCalc = new CoreCalc(left.getWidth(), left.getHeight()); return true; } else {// w w w . j a va 2 s . co m return false; } }
From source file:cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java
/** * Activity /* w ww . j a v a 2 s.c om*/ * * @param activity */ public void attachToActivity(Activity activity) { mActivity = activity; setSliderFadeColor(Color.TRANSPARENT); mShadowView = new View(activity); setIsNeedShowShadow(mIsNeedShowShadow); addView(mShadowView, 0, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); mContentView = decorView.getChildAt(0); decorView.removeView(mContentView); decorView.addView(this); addView(mContentView, 1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); }
From source file:com.jzh.stuapp.view.MyViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * //w w w . ja va2s .com * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.wunderlist.slidinglayer.SlidingLayer.java
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; }//from ww w . j a va2s. c o m } } return checkV && ((allowedDirection() == HORIZONTAL && ViewCompat.canScrollHorizontally(v, -dx) || allowedDirection() == VERTICAL && ViewCompat.canScrollVertically(v, -dy))); }
From source file:ayushi.view.customview.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *///from w w w . j ava 2s . com protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }