Example usage for android.view View LAYER_TYPE_NONE

List of usage examples for android.view View LAYER_TYPE_NONE

Introduction

In this page you can find the example usage for android.view View LAYER_TYPE_NONE.

Prototype

int LAYER_TYPE_NONE

To view the source code for android.view View LAYER_TYPE_NONE.

Click Source Link

Document

Indicates that the view does not have a layer.

Usage

From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java

private AnimatorSet newExpandRightAnimator() {
    ObjectAnimator tcTransX = ObjectAnimator.ofFloat(thingContainer, "translationX", 0, leftWidth);

    AnimatorSet as = new AnimatorSet();
    as.setDuration(durationMs).play(tcTransX);
    as.addListener(new AnimatorListenerAdapter() {
        @Override/*  w w w  .j  a  va  2  s  .c om*/
        public void onAnimationStart(Animator animation) {
            if (leftContainer != null) {
                leftContainer.setVisibility(View.GONE);
            }
            rightContainer.setVisibility(View.VISIBLE);
            thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            thingContainer.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            thingContainer.setLayerType(View.LAYER_TYPE_NONE, null);
        }
    });
    return as;
}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

private void startOpenAnimation() {
    containerView.setVisibility(View.VISIBLE);

    if (!onCustomOpenAnimation()) {
        if (Build.VERSION.SDK_INT >= 20) {
            container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }/*  w ww .  j  a v  a 2  s .  c  o  m*/
        containerView.setTranslationY(containerView.getMeasuredHeight());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
                ObjectAnimator.ofInt(backDrawable, "alpha", 51));
        animatorSet.setDuration(200);
        animatorSet.setStartDelay(20);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    if (delegate != null) {
                        delegate.onOpenAnimationEnd();
                    }
                    container.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}

From source file:kr.wdream.ui.ActionBar.BottomSheet.java

private void startOpenAnimation() {
    if (dismissed) {
        return;//w ww. ja  va 2  s .  co  m
    }
    containerView.setVisibility(View.VISIBLE);

    if (!onCustomOpenAnimation()) {
        if (Build.VERSION.SDK_INT >= 20) {
            container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
        containerView.setTranslationY(containerView.getMeasuredHeight());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
                ObjectAnimator.ofInt(backDrawable, "alpha", 51));
        animatorSet.setDuration(200);
        animatorSet.setStartDelay(20);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    if (delegate != null) {
                        delegate.onOpenAnimationEnd();
                    }
                    container.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}

From source file:org.michaelbel.bottomsheet.BottomSheet.java

private void startOpenAnimation() {
    containerView.setVisibility(View.VISIBLE);

    if (Build.VERSION.SDK_INT >= 20) {
        container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }/*w ww.  ja v  a2 s. c o  m*/

    containerView.setTranslationY(containerView.getMeasuredHeight());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
            ObjectAnimator.ofInt(backDrawable, "alpha", 51));
    animatorSet.setDuration(200);
    animatorSet.setStartDelay(20);
    animatorSet.setInterpolator(new DecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
                container.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                currentSheetAnimation = null;
            }
        }
    });
    animatorSet.start();
    currentSheetAnimation = animatorSet;
}

From source file:com.wangdao.our.spread_2.widget_pull.PullToRefreshBase.java

/**
 * Helper method which just calls scrollTo() in the correct scrolling
 * direction./* www .j a va  2 s . c o m*/
 * 
 * @param value - New Scroll value
 */
protected final void setHeaderScroll(int value) {
    if (DEBUG) {
        Log.d(LOG_TAG, "setHeaderScroll: " + value);
    }

    // Clamp value to with pull scroll range
    final int maximumPullScroll = getMaximumPullScroll();
    value = Math.min(maximumPullScroll, Math.max(-maximumPullScroll, value));

    if (mLayoutVisibilityChangesEnabled) {
        if (value < 0) {
            mHeaderLayout.setVisibility(View.VISIBLE);
        } else if (value > 0) {
            mFooterLayout.setVisibility(View.VISIBLE);
        } else {
            mHeaderLayout.setVisibility(View.INVISIBLE);
            mFooterLayout.setVisibility(View.INVISIBLE);
        }
    }

    if (USE_HW_LAYERS) {
        /**
         * Use a Hardware Layer on the Refreshable View if we've scrolled at
         * all. We don't use them on the Header/Footer Views as they change
         * often, which would negate any HW layer performance boost.
         */
        com.wangdao.our.spread_2.widget_pull.ViewCompat.setLayerType(mRefreshableViewWrapper,
                value != 0 ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE);
    }

    switch (getPullToRefreshScrollDirection()) {
    case VERTICAL:
        scrollTo(0, value);
        break;
    case HORIZONTAL:
        scrollTo(value, 0);
        break;
    }
}

From source file:com.taobao.weex.ui.component.WXComponent.java

/********************************
 *  end hook Activity life cycle callback
 ********************************************************/

public void destroy() {
    if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
        throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
    }//from   w ww.ja va2s  . com
    if (mHost != null && mHost.getLayerType() == View.LAYER_TYPE_HARDWARE) {
        mHost.setLayerType(View.LAYER_TYPE_NONE, null);
    }
    removeAllEvent();
    removeStickyStyle();
    if (mDomObj != null) {
        mDomObj = null;
    }

    mIsDestroyed = true;
}

From source file:org.telegram.ui.ChannelAdminLogActivity.java

private void destroyTextureView() {
    if (roundVideoContainer == null || roundVideoContainer.getParent() == null) {
        return;//from  w w  w  .  j  av a  2 s.c  om
    }
    contentView.removeView(roundVideoContainer);
    aspectRatioFrameLayout.setDrawingReady(false);
    roundVideoContainer.setVisibility(View.INVISIBLE);
    if (Build.VERSION.SDK_INT < 21) {
        roundVideoContainer.setLayerType(View.LAYER_TYPE_NONE, null);
    }
}

From source file:com.lambergar.verticalviewpager.VerticalViewPager.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void enableLayers(boolean enable) {
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final int layerType = enable ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
        getChildAt(i).setLayerType(layerType, null);
    }/*from www .j ava  2s  . com*/
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded,
        final AppsCustomizePagedView.ContentType contentType) {
    if (mStateAnimation != null) {
        mStateAnimation.setDuration(0);//from  w ww.j  a va2  s  .  c o  m
        mStateAnimation.cancel();
        mStateAnimation = null;
    }

    boolean material = Utilities.isLmpOrAbove();

    final Resources res = getResources();

    final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime);
    final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger);

    final View fromView = mWorkspace;
    final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;

    final ArrayList<View> layerViews = new ArrayList<View>();

    Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets
            ? Workspace.State.OVERVIEW_HIDDEN
            : Workspace.State.NORMAL_HIDDEN;
    Animator workspaceAnim = mWorkspace.getChangeStateAnimation(workspaceState, animated, layerViews);
    // Set the content type for the all apps/widgets space
    mAppsCustomizeTabHost.setContentTypeImmediate(contentType);

    // If for some reason our views aren't initialized, don't animate
    boolean initialized = getAllAppsButton() != null;

    if (animated && initialized) {
        mStateAnimation = LauncherAnimUtils.createAnimatorSet();
        final AppsCustomizePagedView content = (AppsCustomizePagedView) toView
                .findViewById(R.id.apps_customize_pane_content);

        final View page = content.getPageAt(content.getCurrentPage());
        final View revealView = toView.findViewById(R.id.fake_page);

        final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets;
        revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel));

        // Hide the real page background, and swap in the fake one
        content.setPageBackgroundsVisible(false);
        revealView.setVisibility(View.VISIBLE);
        // We need to hide this view as the animation start will be posted.
        revealView.setAlpha(0);

        int width = revealView.getMeasuredWidth();
        int height = revealView.getMeasuredHeight();
        float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4);

        revealView.setTranslationY(0);
        revealView.setTranslationX(0);

        // Get the y delta between the center of the page and the center of the all apps button
        int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, getAllAppsButton(), null);

        float alpha = 0;
        float xDrift = 0;
        float yDrift = 0;
        if (material) {
            alpha = isWidgetTray ? 0.3f : 1f;
            yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1];
            xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0];
        } else {
            yDrift = 2 * height / 3;
            xDrift = 0;
        }
        final float initAlpha = alpha;

        revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        layerViews.add(revealView);
        PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f);
        PropertyValuesHolder panelDriftY = PropertyValuesHolder.ofFloat("translationY", yDrift, 0);
        PropertyValuesHolder panelDriftX = PropertyValuesHolder.ofFloat("translationX", xDrift, 0);

        ObjectAnimator panelAlphaAndDrift = ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha,
                panelDriftY, panelDriftX);

        panelAlphaAndDrift.setDuration(revealDuration);
        panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));

        mStateAnimation.play(panelAlphaAndDrift);

        if (page != null) {
            page.setVisibility(View.VISIBLE);
            page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            layerViews.add(page);

            ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
            page.setTranslationY(yDrift);
            pageDrift.setDuration(revealDuration);
            pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
            pageDrift.setStartDelay(itemsAlphaStagger);
            mStateAnimation.play(pageDrift);

            page.setAlpha(0f);
            ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0f, 1f);
            itemsAlpha.setDuration(revealDuration);
            itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
            itemsAlpha.setStartDelay(itemsAlphaStagger);
            mStateAnimation.play(itemsAlpha);
        }

        View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator);
        pageIndicators.setAlpha(0.01f);
        ObjectAnimator indicatorsAlpha = ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f);
        indicatorsAlpha.setDuration(revealDuration);
        mStateAnimation.play(indicatorsAlpha);

        if (material) {
            final View allApps = getAllAppsButton();
            int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid()
                    .getDeviceProfile().allAppsButtonVisualSize;
            float startRadius = isWidgetTray ? 0 : allAppsButtonSize / 2;
            Animator reveal = ViewAnimationUtils.createCircularReveal(revealView, width / 2, height / 2,
                    startRadius, revealRadius);
            reveal.setDuration(revealDuration);
            reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

            reveal.addListener(new AnimatorListenerAdapter() {
                public void onAnimationStart(Animator animation) {
                    if (!isWidgetTray) {
                        allApps.setVisibility(View.INVISIBLE);
                    }
                }

                public void onAnimationEnd(Animator animation) {
                    if (!isWidgetTray) {
                        allApps.setVisibility(View.VISIBLE);
                    }
                }
            });
            mStateAnimation.play(reveal);
        }

        mStateAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                dispatchOnLauncherTransitionEnd(fromView, animated, false);
                dispatchOnLauncherTransitionEnd(toView, animated, false);

                revealView.setVisibility(View.INVISIBLE);
                revealView.setLayerType(View.LAYER_TYPE_NONE, null);
                if (page != null) {
                    page.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                content.setPageBackgroundsVisible(true);

                // This can hold unnecessary references to views.
                mStateAnimation = null;
            }

        });

        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }

        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        final AnimatorSet stateAnimation = mStateAnimation;
        final Runnable startAnimRunnable = new Runnable() {
            public void run() {
                // Check that mStateAnimation hasn't changed while
                // we waited for a layout/draw pass
                if (mStateAnimation != stateAnimation)
                    return;
                dispatchOnLauncherTransitionStart(fromView, animated, false);
                dispatchOnLauncherTransitionStart(toView, animated, false);

                revealView.setAlpha(initAlpha);
                if (Utilities.isLmpOrAbove()) {
                    for (int i = 0; i < layerViews.size(); i++) {
                        View v = layerViews.get(i);
                        if (v != null) {
                            if (Utilities.isViewAttachedToWindow(v))
                                v.buildLayer();
                        }
                    }
                }
                mStateAnimation.start();
            }
        };
        toView.bringToFront();
        toView.setVisibility(View.VISIBLE);
        toView.post(startAnimRunnable);
    } else {
        toView.setTranslationX(0.0f);
        toView.setTranslationY(0.0f);
        toView.setScaleX(1.0f);
        toView.setScaleY(1.0f);
        toView.setVisibility(View.VISIBLE);
        toView.bringToFront();

        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionStart(fromView, animated, false);
        dispatchOnLauncherTransitionEnd(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        dispatchOnLauncherTransitionStart(toView, animated, false);
        dispatchOnLauncherTransitionEnd(toView, animated, false);
    }
}

From source file:org.telegram.ui.ProfileActivity.java

@Override
protected AnimatorSet onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) {
    if (playProfileAnimation && allowProfileAnimation) {
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(180);//from   w ww  . ja v  a  2s . c  o m
        if (Build.VERSION.SDK_INT > 15) {
            listView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
        ActionBarMenu menu = actionBar.createMenu();
        if (menu.getItem(10) == null) {
            if (animatingItem == null) {
                animatingItem = menu.addItem(10, R.drawable.ic_ab_other);
            }
        }
        if (isOpen) {
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) onlineTextView[1]
                    .getLayoutParams();
            layoutParams.rightMargin = (int) (-21 * AndroidUtilities.density + AndroidUtilities.dp(8));
            onlineTextView[1].setLayoutParams(layoutParams);

            int width = (int) Math.ceil(AndroidUtilities.displaySize.x - AndroidUtilities.dp(118 + 8)
                    + 21 * AndroidUtilities.density);
            float width2 = nameTextView[1].getPaint().measureText(nameTextView[1].getText().toString()) * 1.12f
                    + getSideDrawablesSize(nameTextView[1]);
            layoutParams = (FrameLayout.LayoutParams) nameTextView[1].getLayoutParams();
            if (width < width2) {
                layoutParams.width = (int) Math.ceil(width / 1.12f);
            } else {
                layoutParams.width = LayoutHelper.WRAP_CONTENT;
            }
            nameTextView[1].setLayoutParams(layoutParams);

            initialAnimationExtraHeight = AndroidUtilities.dp(88);
            fragmentView.setBackgroundColor(0);
            setAnimationProgress(0);
            ArrayList<Animator> animators = new ArrayList<>();
            animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 0.0f, 1.0f));
            if (writeButton != null) {
                writeButton.setScaleX(0.2f);
                writeButton.setScaleY(0.2f);
                writeButton.setAlpha(0.0f);
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
            }
            for (int a = 0; a < 2; a++) {
                onlineTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
                nameTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
                animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
                animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
            }
            if (animatingItem != null) {
                animatingItem.setAlpha(1.0f);
                animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 0.0f));
            }
            animatorSet.playTogether(animators);
        } else {
            initialAnimationExtraHeight = extraHeight;
            ArrayList<Animator> animators = new ArrayList<>();
            animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 1.0f, 0.0f));
            if (writeButton != null) {
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f));
                animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
            }
            for (int a = 0; a < 2; a++) {
                animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
                animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
            }
            if (animatingItem != null) {
                animatingItem.setAlpha(0.0f);
                animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 1.0f));
            }
            animatorSet.playTogether(animators);
        }
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (Build.VERSION.SDK_INT > 15) {
                    listView.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                if (animatingItem != null) {
                    ActionBarMenu menu = actionBar.createMenu();
                    menu.clearItems();
                    animatingItem = null;
                }
                callback.run();
            }
        });
        animatorSet.setInterpolator(new DecelerateInterpolator());

        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                animatorSet.start();
            }
        }, 50);
        return animatorSet;
    }
    return null;
}