Example usage for android.view View postDelayed

List of usage examples for android.view View postDelayed

Introduction

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

Prototype

public boolean postDelayed(Runnable action, long delayMillis) 

Source Link

Document

Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.

Usage

From source file:Main.java

public static void requestFocusDelayed(final View view, long delayMillis) {
    view.postDelayed(new Runnable() {
        @Override/*  w  ww.  j av  a2  s.c o  m*/
        public void run() {
            view.requestFocus();
        }
    }, delayMillis);
}

From source file:Main.java

public static void doPostDelay(View v, long delay, Runnable run) {
    if (v != null && run != null && delay >= 0) {
        v.postDelayed(run, delay);
    }//w  ww  .  j  av  a2  s.c  o  m
}

From source file:Main.java

public static void setVisibility(final View v, long delay, final int visibility) {
    if (v != null && delay >= 0) {
        v.postDelayed(new Runnable() {
            @Override/*w  w  w.ja  v  a  2 s  .c om*/
            public void run() {
                v.setVisibility(visibility);
            }
        }, delay);
    }
}

From source file:Main.java

@SuppressWarnings("WeakerAccess")
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {/* w  ww  .  ja  v  a 2s  .  c  o m*/
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}

From source file:Main.java

public static void postAnimation(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;// w w  w  .j  a v a 2s. co  m
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new OvershootInterpolator(0.8f));
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:Main.java

public static void postAnimationBottom(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;//  ww w.  ja  v a  2 s. c om
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:com.kogitune.activitytransition.core.TransitionAnimation.java

public static void startExitAnimation(MoveData moveData, TimeInterpolator interpolator,
        final Runnable endAction) {
    if (Build.VERSION.SDK_INT >= 21) {
        endAction.run();//w  w  w.  j av a 2s . c o  m
        return;
    }
    View view = moveData.toView;
    int duration = moveData.duration;
    int leftDelta = moveData.leftDelta;
    int topDelta = moveData.topDelta;
    float widthScale = moveData.widthScale;
    float heightScale = moveData.heightScale;
    view.animate().setDuration(duration).scaleX(widthScale).scaleY(heightScale).setInterpolator(interpolator)
            .translationX(leftDelta).translationY(topDelta);
    view.postDelayed(endAction, duration);
}

From source file:org.mozilla.focus.utils.ViewUtils.java

/**
 * Create a snackbar with Focus branding (See #193).
 *//*from ww w.  j  a  v  a 2 s.c om*/
public static void showBrandedSnackbar(View view, @StringRes int resId, int delayMillis) {
    final Context context = view.getContext();
    final Snackbar snackbar = Snackbar.make(view, resId, Snackbar.LENGTH_LONG);

    final View snackbarView = snackbar.getView();
    snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.snackbarBackground));

    final TextView snackbarTextView = (TextView) snackbarView
            .findViewById(android.support.design.R.id.snackbar_text);
    snackbarTextView.setTextColor(ContextCompat.getColor(context, R.color.snackbarTextColor));
    snackbarTextView.setGravity(Gravity.CENTER);
    snackbarTextView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);

    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            snackbar.show();
        }
    }, delayMillis);
}

From source file:com.commonsware.android.feedfrags.AbstractFeedsActivity.java

private void lightsOut() {
    final View view = findViewById(android.R.id.content);

    view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
    getActionBar().hide();//from w w w.  j  a  v  a  2s .co  m

    view.postDelayed(new Runnable() {
        public void run() {
            view.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
            getActionBar().show();
        }
    }, 5000);
}

From source file:net.gsantner.opoc.activity.GsFragmentBase.java

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.postDelayed(() -> {
        synchronized (_fragmentFirstTimeVisibleSync) {
            if (getUserVisibleHint() && isVisible() && _fragmentFirstTimeVisible) {
                _fragmentFirstTimeVisible = false;
                onFragmentFirstTimeVisible();
            }// w w w.  ja  va 2s.com
        }
    }, 1);
}