Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator.

Prototype

public DecelerateInterpolator(float factor) 

Source Link

Document

Constructor

Usage

From source file:com.android.mail.browse.ConversationItemView.java

/**
 * Grow the height of the item and fade it in when bringing a conversation
 * back from a destructive action.//w  ww .  j av  a 2s .com
 */
public Animator createUndoAnimation() {
    ObjectAnimator height = createHeightAnimation(true);
    Animator fade = ObjectAnimator.ofFloat(this, "alpha", 0, 1.0f);
    fade.setDuration(sShrinkAnimationDuration);
    fade.setInterpolator(new DecelerateInterpolator(2.0f));
    AnimatorSet transitionSet = new AnimatorSet();
    transitionSet.playTogether(height, fade);
    transitionSet.addListener(new HardwareLayerEnabler(this));
    return transitionSet;
}

From source file:com.android.launcher3.Workspace.java

private void animateBackgroundGradient(float finalAlpha, boolean animated) {
    final DragLayer dragLayer = mLauncher.getDragLayer();

    if (mBackgroundFadeInAnimation != null) {
        mBackgroundFadeInAnimation.cancel();
        mBackgroundFadeInAnimation = null;
    }/*w  ww  .j ava  2 s.  com*/
    if (mBackgroundFadeOutAnimation != null) {
        mBackgroundFadeOutAnimation.cancel();
        mBackgroundFadeOutAnimation = null;
    }
    float startAlpha = dragLayer.getBackgroundAlpha();
    if (finalAlpha != startAlpha) {
        if (animated) {
            mBackgroundFadeOutAnimation = LauncherAnimUtils.ofFloat(this, startAlpha, finalAlpha);
            mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() {
                public void onAnimationUpdate(ValueAnimator animation) {
                    dragLayer.setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
                }
            });
            mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
            mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
            mBackgroundFadeOutAnimation.start();
        } else {
            dragLayer.setBackgroundAlpha(finalAlpha);
        }
    }
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) {
    if (mState == state) {
        return null;
    }/*  w w w. java 2s  .co  m*/

    // Initialize animation arrays for the first time if necessary
    initAnimationArrays();

    AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null;

    final State oldState = mState;
    final boolean oldStateIsNormal = (oldState == State.NORMAL);
    final boolean oldStateIsOverview = (oldState == State.OVERVIEW);
    setState(state);
    final boolean stateIsNormal = (state == State.NORMAL);
    final boolean stateIsOverview = (state == State.OVERVIEW);
    float finalBackgroundAlpha = stateIsOverview ? 1.0f : 0f;
    float finalPageIndicatorAlpha = stateIsOverview ? 0f : 1f;
    float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
    float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0;

    boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
    boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);

    mNewScale = 1.0f;

    if (state != State.NORMAL) {
        if (stateIsOverview) {
            mNewScale = mOverviewModeShrinkFactor;
        }
    }

    final int duration = getResources().getInteger(R.integer.config_overviewTransitionTime);

    for (int i = 0; i < getChildCount(); i++) {
        final CellLayout cl = (CellLayout) getChildAt(i);
        float finalAlpha = 1f;

        if (stateIsOverview) {
            cl.setVisibility(VISIBLE);
            cl.setTranslationX(0f);
            cl.setTranslationY(0f);
            cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setRotation(0f);
            cl.setRotationY(0f);
            cl.setRotationX(0f);
            cl.setScaleX(1f);
            cl.setScaleY(1f);
            cl.setShortcutAndWidgetAlpha(1f);
        }

        mOldAlphas[i] = cl.getShortcutsAndWidgets().getAlpha();
        mNewAlphas[i] = finalAlpha;
        if (animated) {
            mOldBackgroundAlphas[i] = cl.getBackgroundAlpha();
            mNewBackgroundAlphas[i] = finalBackgroundAlpha;
        } else {
            cl.setBackgroundAlpha(finalBackgroundAlpha);
            cl.setShortcutAndWidgetAlpha(finalAlpha);
        }
    }

    final View overviewPanel = mLauncher.getOverviewPanel();
    if (animated) {
        anim.setDuration(duration);
        LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this);
        scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY)
                .setInterpolator(mZoomInInterpolator);
        anim.play(scale);
        ValueAnimator invalidate = ValueAnimator.ofFloat(0f, 1f);
        invalidate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                invalidate();
            }
        });
        anim.play(invalidate);
        ObjectAnimator pageIndicatorAlpha = null;
        if (getPageIndicator() != null) {
            pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalPageIndicatorAlpha);
        }
        ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha",
                finalOverviewPanelAlpha);

        overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));

        if (overviewToWorkspace) {
            overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2));
        }

        if (getPageIndicator() != null) {
            pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator()));
        }

        anim.play(overviewPanelAlpha);
        anim.play(pageIndicatorAlpha);

        for (int index = 0; index < getChildCount(); index++) {
            final int i = index;

            final CellLayout cl = (CellLayout) getChildAt(i);
            if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) {
                cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
                cl.getShortcutsAndWidgets().setAlpha(mNewAlphas[i]);
            } else {
                LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
                a.alpha(mNewAlphas[i]).setDuration(duration).setInterpolator(mZoomInInterpolator);
                anim.play(a);
                if (mOldBackgroundAlphas[i] != 0 || mNewBackgroundAlphas[i] != 0) {
                    ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f);
                    bgAnim.setInterpolator(mZoomInInterpolator);
                    bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
                        public void onAnimationUpdate(float a, float b) {
                            cl.setBackgroundAlpha(a * mOldBackgroundAlphas[i] + b * mNewBackgroundAlphas[i]);
                        }
                    });
                    anim.play(bgAnim);
                }
            }
        }

        anim.setStartDelay(delay);
    } else {
        overviewPanel.setAlpha(finalOverviewPanelAlpha);
        AlphaUpdateListener.updateVisibility(overviewPanel);
        if (getPageIndicator() != null) {
            getPageIndicator().setAlpha(finalPageIndicatorAlpha);
            AlphaUpdateListener.updateVisibility(getPageIndicator());
        }
        setScaleX(mNewScale);
        setScaleY(mNewScale);
        setTranslationY(finalWorkspaceTranslationY);
    }
    return anim;
}

From source file:com.android.mail.browse.ConversationItemView.java

private ObjectAnimator createTranslateXAnimation(boolean show) {
    SwipeableListView parent = getListView();
    // If we can't get the parent...we have bigger problems.
    int width = parent != null ? parent.getMeasuredWidth() : 0;
    final float start = show ? width : 0f;
    final float end = show ? 0f : width;
    ObjectAnimator slide = ObjectAnimator.ofFloat(this, "translationX", start, end);
    slide.setInterpolator(new DecelerateInterpolator(2.0f));
    slide.setDuration(sSlideAnimationDuration);
    return slide;
}

From source file:com.android.mail.browse.ConversationItemView.java

private ObjectAnimator createHeightAnimation(boolean show) {
    final float start = show ? 0f : 1.0f;
    final float end = show ? 1.0f : 0f;
    ObjectAnimator height = ObjectAnimator.ofFloat(this, "animatedHeightFraction", start, end);
    height.setInterpolator(new DecelerateInterpolator(2.0f));
    height.setDuration(sShrinkAnimationDuration);
    return height;
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Animates our toolbar to the given direction
 *
 * @param toY our translation length./*from ww  w  .  j av a 2s .  co m*/
 */
private void animateToolbar(final float toY) {
    if (activity != null) {
        View toolbarView = activity.findViewById(R.id.toolbar);

        if (toolbarView != null) {
            toolbarView.animate().translationY(toY).setInterpolator(new DecelerateInterpolator(2))
                    .setDuration(200).start();
            mSlidingTabLayout.animate().translationY(toY).setInterpolator(new DecelerateInterpolator(2))
                    .setDuration(200).start();

            if (toY == 0) {
                upDyKey = true;
                downDyKey = false;
                downDy = 9999999;
            } else {
                downDyKey = true;
                upDyKey = false;
                upDy = -9999999;
            }

        }
    }
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Instant shows our toolbar. Used when click on movie details from movies list and toolbar is hidden.
 */// w w  w .j a v  a  2s.c  o m
public void showInstantToolbar() {
    if (activity != null) {
        View toolbarView = activity.findViewById(R.id.toolbar);

        if (toolbarView != null) {
            toolbarView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).setDuration(0)
                    .start();
            mSlidingTabLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .setDuration(0).start();

            upDyKey = true;
            downDyKey = false;
            downDy = 9999999;

        }
    }
}

From source file:com.amaze.filemanager.activities.MainActivity.java

void initialiseViews() {
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);

    if (!ImageLoader.getInstance().isInited()) {

        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }/*from w  w  w. j a va2s  . c o  m*/
    displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
            .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
            .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1)
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0)
        divider.setImageResource(R.color.divider);
    else
        divider.setImageResource(R.color.divider_dark);

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
}

From source file:com.filemanager.free.activities.MainActivity.java

@SuppressLint("InflateParams")
private void initialiseViews() {
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }/*from  ww w.  j  a  v a2  s . c o  m*/
    if (displayImageOptions != null) {
        displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
                .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
                .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
    }

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else {
        assert mDrawerLinear != null;
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    }
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1) {
        assert v != null;
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    }

    assert v != null;
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            utils.revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0) {
        assert divider != null;
        divider.setImageResource(R.color.divider);
    } else {
        assert divider != null;
        divider.setImageResource(R.color.divider_dark);
    }

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        assert settingsbutton != null;
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert settingsbutton != null;
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        assert appbutton != null;
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert appbutton != null;
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
    //admob
    mAdView = (View) findViewById(R.id.ads);
}

From source file:com.xhr.launcher.Workspace.java

Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) {
    if (mState == state) {
        return null;
    }/*  w  ww .j  av a2s. c o m*/

    // Initialize animation arrays for the first time if necessary
    initAnimationArrays();

    AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null;

    final State oldState = mState;
    final boolean oldStateIsNormal = (oldState == State.NORMAL);
    final boolean oldStateIsSpringLoaded = (oldState == State.SPRING_LOADED);
    final boolean oldStateIsSmall = (oldState == State.SMALL);
    final boolean oldStateIsOverview = (oldState == State.OVERVIEW);
    setState(state);
    final boolean stateIsNormal = (state == State.NORMAL);
    final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED);
    final boolean stateIsSmall = (state == State.SMALL);
    final boolean stateIsOverview = (state == State.OVERVIEW);
    float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f;
    float finalHotseatAndPageIndicatorAlpha = (stateIsOverview || stateIsSmall) ? 0f : 1f;
    float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
    float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f;
    float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0;

    boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall);
    boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal);
    boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
    boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);

    mNewScale = 1.0f;

    if (oldStateIsOverview) {
        disableFreeScroll(snapPage);
    } else if (stateIsOverview) {
        enableFreeScroll();
    }

    if (state != State.NORMAL) {
        if (stateIsSpringLoaded) {
            mNewScale = mSpringLoadedShrinkFactor;
        } else if (stateIsOverview) {
            mNewScale = mOverviewModeShrinkFactor;
        } else if (stateIsSmall) {
            mNewScale = mOverviewModeShrinkFactor - 0.3f;
        }
        if (workspaceToAllApps) {
            updateChildrenLayersEnabled(false);
        }
    }

    final int duration;
    if (workspaceToAllApps) {
        duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime);
    } else if (workspaceToOverview || overviewToWorkspace) {
        duration = getResources().getInteger(R.integer.config_overviewTransitionTime);
    } else {
        duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
    }

    for (int i = 0; i < getChildCount(); i++) {
        final CellLayout cl = (CellLayout) getChildAt(i);
        boolean isCurrentPage = (i == getNextPage());
        float initialAlpha = cl.getShortcutsAndWidgets().getAlpha();
        float finalAlpha = stateIsSmall ? 0f : 1f;

        // If we are animating to/from the small state, then hide the side pages and fade the
        // current page in
        if (!mIsSwitchingState) {
            if (workspaceToAllApps || allAppsToWorkspace) {
                if (allAppsToWorkspace && isCurrentPage) {
                    initialAlpha = 0f;
                } else if (!isCurrentPage) {
                    initialAlpha = finalAlpha = 0f;
                }
                cl.setShortcutAndWidgetAlpha(initialAlpha);
            }
        }

        mOldAlphas[i] = initialAlpha;
        mNewAlphas[i] = finalAlpha;
        if (animated) {
            mOldBackgroundAlphas[i] = cl.getBackgroundAlpha();
            mNewBackgroundAlphas[i] = finalBackgroundAlpha;
        } else {
            cl.setBackgroundAlpha(finalBackgroundAlpha);
            cl.setShortcutAndWidgetAlpha(finalAlpha);
        }
    }

    final View searchBar = mLauncher.getQsbBar();
    final View overviewPanel = mLauncher.getOverviewPanel();
    final View hotseat = mLauncher.getHotseat();
    if (animated) {
        anim.setDuration(duration);
        LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this);
        scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY)
                .setInterpolator(mZoomInInterpolator);
        anim.play(scale);
        for (int index = 0; index < getChildCount(); index++) {
            final int i = index;
            final CellLayout cl = (CellLayout) getChildAt(i);
            float currentAlpha = cl.getShortcutsAndWidgets().getAlpha();
            if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) {
                cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
                cl.setShortcutAndWidgetAlpha(mNewAlphas[i]);
            } else {
                if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) {
                    LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator(
                            cl.getShortcutsAndWidgets());
                    alphaAnim.alpha(mNewAlphas[i]).setInterpolator(mZoomInInterpolator);
                    anim.play(alphaAnim);
                }
                if (mOldBackgroundAlphas[i] != 0 || mNewBackgroundAlphas[i] != 0) {
                    ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f);
                    bgAnim.setInterpolator(mZoomInInterpolator);
                    bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
                        public void onAnimationUpdate(float a, float b) {
                            cl.setBackgroundAlpha(a * mOldBackgroundAlphas[i] + b * mNewBackgroundAlphas[i]);
                        }
                    });
                    anim.play(bgAnim);
                }
            }
        }
        ObjectAnimator pageIndicatorAlpha = null;
        if (getPageIndicator() != null) {
            pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha",
                    finalHotseatAndPageIndicatorAlpha);
        }
        ObjectAnimator hotseatAlpha = ObjectAnimator.ofFloat(hotseat, "alpha",
                finalHotseatAndPageIndicatorAlpha);
        ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(searchBar, "alpha", finalSearchBarAlpha);
        ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha",
                finalOverviewPanelAlpha);

        overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));
        hotseatAlpha.addListener(new AlphaUpdateListener(hotseat));
        searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));

        if (workspaceToOverview) {
            hotseatAlpha.setInterpolator(new DecelerateInterpolator(2));
        } else if (overviewToWorkspace) {
            overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2));
        }

        if (getPageIndicator() != null) {
            pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator()));
        }

        anim.play(overviewPanelAlpha);
        anim.play(hotseatAlpha);
        anim.play(searchBarAlpha);
        anim.play(pageIndicatorAlpha);
        anim.setStartDelay(delay);
    } else {
        overviewPanel.setAlpha(finalOverviewPanelAlpha);
        AlphaUpdateListener.updateVisibility(overviewPanel);
        hotseat.setAlpha(finalHotseatAndPageIndicatorAlpha);
        AlphaUpdateListener.updateVisibility(hotseat);
        if (getPageIndicator() != null) {
            getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha);
            AlphaUpdateListener.updateVisibility(getPageIndicator());
        }
        searchBar.setAlpha(finalSearchBarAlpha);
        AlphaUpdateListener.updateVisibility(searchBar);
        updateCustomContentVisibility();
        setScaleX(mNewScale);
        setScaleY(mNewScale);
        setTranslationY(finalWorkspaceTranslationY);
    }
    //  mLauncher.updateVoiceButtonProxyVisible(false);

    if (stateIsSpringLoaded) {
        // Right now we're covered by Apps Customize
        // Show the background gradient immediately, so the gradient will
        // be showing once AppsCustomize disappears
        animateBackgroundGradient(
                getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false);
    } else if (stateIsOverview) {
        animateBackgroundGradient(
                getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true);
    } else {
        // Fade the background gradient away
        animateBackgroundGradient(0f, animated);
    }
    return anim;
}