Example usage for android.widget FrameLayout getChildAt

List of usage examples for android.widget FrameLayout getChildAt

Introduction

In this page you can find the example usage for android.widget FrameLayout getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:Main.java

public static LinearLayout fetchAppLayout(Activity activity) {
    FrameLayout rootView = (FrameLayout) activity.getWindow().getDecorView().getRootView();
    LinearLayout rootLayout = (LinearLayout) rootView.getChildAt(0);
    return ((LinearLayout) ((FrameLayout) rootLayout.getChildAt(1)).getChildAt(0));
}

From source file:com.king.base.BaseActivity.java

public static View getContentView(Activity activity) {
    ViewGroup view = (ViewGroup) activity.getWindow().getDecorView();
    FrameLayout content = (FrameLayout) view.findViewById(android.R.id.content);
    return content.getChildAt(0);
}

From source file:com.example.PagerCoverFlow.PagerContainer.java

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    //Force the container to redraw on scrolling.
    //Without this the outer pages render initially and then stay static

    int rotationAngle = (int) (positionOffset * mMaxRotationAngle);
    if (Math.abs(rotationAngle) > mMaxRotationAngle) {
        rotationAngle = (rotationAngle < 0) ? -mMaxRotationAngle : mMaxRotationAngle;
    }/*from  w  w  w.  j av a  2s  .  c  o  m*/
    FrameLayout frameLayout = (FrameLayout) mPager.getChildAt(position);
    ImageView imageview = (ImageView) frameLayout.getChildAt(0);
    Log.i("Test", "positino2:" + rotationAngle);

    transformImageBitmap((ImageView) imageview, imageview.getImageMatrix(), rotationAngle);

    //        Matrix m = mPager.getMatrix();
    //        RectF drawableRect = new RectF(0, 0, width - rotationAngle, width - rotationAngle);
    //        RectF viewRect = new RectF(0, 0, imageview.getWidth(), imageview.getHeight());
    //        m.setRectToRect(drawableRect, viewRect, Matrix.ScaleToFit.CENTER);
    //        mPager.setMa

    if (mNeedsRedraw)
        invalidate();
}

From source file:com.android.settings.PreviewPagerAdapter.java

void setPreviewLayer(int newLayerIndex, int currentLayerIndex, int currentFrameIndex, final boolean animate) {
    for (FrameLayout previewFrame : mPreviewFrames) {
        if (currentLayerIndex >= 0) {
            final View lastLayer = previewFrame.getChildAt(currentLayerIndex);
            if (mViewStubInflated[currentFrameIndex][currentLayerIndex]) {
                // Explicitly set to INVISIBLE only when the stub has
                // already been inflated.
                if (previewFrame == mPreviewFrames[currentFrameIndex]) {
                    setVisibility(lastLayer, View.INVISIBLE, animate);
                } else {
                    setVisibility(lastLayer, View.INVISIBLE, false);
                }//www  .  j a  v  a2  s .  c o  m
            }
        }

        // Set next layer visible, as well as inflate necessary views.
        View nextLayer = previewFrame.getChildAt(newLayerIndex);
        if (previewFrame == mPreviewFrames[currentFrameIndex]) {
            // Inflate immediately if the stub has not yet been inflated.
            if (!mViewStubInflated[currentFrameIndex][newLayerIndex]) {
                nextLayer = ((ViewStub) nextLayer).inflate();
                nextLayer.setAlpha(0.0f);
            }
            setVisibility(nextLayer, View.VISIBLE, animate);
        } else {
            setVisibility(nextLayer, View.VISIBLE, false);
        }
    }
}

From source file:com.smoothsync.smoothsetup.MicroFragmentHostActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.smoothsetup_activity_microfragment_host);

    mCollapsingToolbar = findViewById(R.id.collapsing_toolbar);
    setSupportActionBar(mCollapsingToolbar.findViewById(R.id.toolbar));
    mActionBar = getSupportActionBar();/*from   w w w .j  a  v a 2  s .  c o  m*/
    mMicroFragmentStateDovecote = new ParcelableDovecote<>(this, "hostactivity", this);
    mBackDovecote = new BooleanDovecote(this, "backresult", aBoolean -> {
        if (!aBoolean) {
            finish();
        }
    });

    if (savedInstanceState == null) {
        // load the initial MicroFragment
        Bundle nestedExtras = getIntent().getBundleExtra("org.dmfs.nestedExtras");
        MicroFragment<?> initialMicroFragment = nestedExtras.getParcelable("MicroFragment");
        mMicroFragmentHost = new SimpleMicroFragmentFlow(initialMicroFragment, R.id.microfragment_host)
                .withPigeonCage(mMicroFragmentStateDovecote.cage()).start(this);
    } else {
        mMicroFragmentHost = savedInstanceState.getParcelable("microfragmenthost");
    }
    mAppBarLayout = findViewById(R.id.appbar);
    mFragmentHostView = findViewById(R.id.microfragment_host);
    mFragmentHostView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
        // collapse appbar if the microfragment content doesn't fit on the screen
        Rect windowRect = new Rect();
        mAppBarLayout.getWindowVisibleDisplayFrame(windowRect);

        FrameLayout bottomView = mFragmentHostView
                .findViewById(org.dmfs.android.microfragments.R.id.microfragments_host);
        if (bottomView.getChildCount() > 0) {
            View childView = bottomView.getChildAt(0);
            Rect childRect = new Rect();
            childView.getGlobalVisibleRect(childRect);
            if (!"collapsed".equals(childView.getTag()) && !windowRect.contains(childRect)) {
                mAppBarLayout.postDelayed(() -> mAppBarLayout.setExpanded(false, true), 100);
                // tag the child as "collapsed" so we don't collapse it again while visible
                childView.setTag("collapsed");
            }
        }
    });
}

From source file:org.dalol.orthodoxmezmurmedia.modules.home.MezmurDashboardActivity.java

private void initializeViews() {
    mNavigationView.setItemIconTintList(null);
    mNavigationView.setNavigationItemSelectedListener(mNavigationItemSelectedListener);
    if (CommonUtils.getScreenWidthInDensityPixel(this) <= 360) {
        mNavigationView.getLayoutParams().width = getResources().getDisplayMetrics().widthPixels
                - CommonUtils.computeTypedValue(this, TypedValue.COMPLEX_UNIT_DIP, 56);
    }//  w  w w.j a  v  a 2s.c o  m

    FrameLayout view = (FrameLayout) mNavigationView.getMenu().findItem(R.id.menu_favourites).getActionView();
    int count = 65;
    TextView txt = (TextView) view.getChildAt(0);
    txt.setText(count > 0 ? String.valueOf(count) : null);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.openDrawer, R.string.closeDrawer) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
            supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            invalidateOptionsMenu();
            supportInvalidateOptionsMenu();
        }
    };

    mNavHeaderImageView = (ImageView) mNavigationView.getHeaderView(0)
            .findViewById(R.id.navigation_view_header_background_image);
    Glide.with(this).load(R.drawable.back_round).into(mNavHeaderImageView);

    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    OMMPagerAdapter pagerAdapter = new OMMPagerAdapter(getSupportFragmentManager());
    pagerAdapter.addFragment(DashboardFragment.newInstance(), "Categories");
    pagerAdapter.addFragment(OtherMenusFragment.newInstance(), "Other Menus");

    mViewPager.setAdapter(pagerAdapter);
    mTabLayout.setupWithViewPager(mViewPager);
}

From source file:pum.android.project.tools.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from   w  w w .java2  s .  c  om
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(1)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:kuta.adrian.cv.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*  w ww  .  j  a  v  a2 s  .  c om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(0)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(ContextCompat.getColor(imageView.getContext(), android.R.color.transparent)),
                drawable });
        // Set background to loading bitmap
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        else
            imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:pum.android.project.tools.displayingbitmaps.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link pum.android.project.tools.displayingbitmaps.ImageWorker#processBitmap(Object)} to define the processing logic). A memory and
 * disk cache will be used if an {@link ImageCache} has been added using
 * {@link pum.android.project.tools.displayingbitmaps.ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the
 * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask}
 * will be created to asynchronously load the bitmap.
 *
 * @param data      The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *//*  w w w  .java  2s.co  m*/
public void loadImage(Object data, ImageView imageView) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        try {
            ViewGroup viewGroup = (ViewGroup) imageView.getParent();
            if (viewGroup instanceof FrameLayout) {
                FrameLayout parent = (FrameLayout) viewGroup;
                View view;
                if ((view = parent.getChildAt(1)) instanceof ProgressBar)
                    view.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
        }
        //BEGIN_INCLUDE(execute_background_task)
        final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR);
        //END_INCLUDE(execute_background_task)
    }
}

From source file:kuta.adrian.cv.displayingbitmaps.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and
 * disk cache will be used if an {@link ImageCache} has been added using
 * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the
 * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask}
 * will be created to asynchronously load the bitmap.
 *
 * @param data      The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *//*from ww w  .jav  a 2  s . c  o m*/
public void loadImage(Object data, ImageView imageView) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        try {
            ViewGroup viewGroup = (ViewGroup) imageView.getParent();
            if (viewGroup instanceof FrameLayout) {
                FrameLayout parent = (FrameLayout) viewGroup;
                View view;
                if ((view = parent.getChildAt(0)) instanceof ProgressBar)
                    view.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
        }
        //BEGIN_INCLUDE(execute_background_task)
        final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR);
        //END_INCLUDE(execute_background_task)
    }
}