android.view.View#postDelayed ( )源码实例Demo

下面列出了android.view.View#postDelayed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Orin   文件: ArtistDetailActivity.java
private void setUpSongListView() {
    setUpSongListPadding();
    songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
    songListView.addHeaderView(songListHeader);

    songAdapter = new ArtistSongAdapter(this, getArtist().getSongs(), this);
    songListView.setAdapter(songAdapter);

    final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
    contentView.postDelayed(new Runnable() {
        @Override
        public void run() {
            songListBackground.getLayoutParams().height = contentView.getHeight();
            observableScrollViewCallbacks.onScrollChanged(-(artistImageViewHeight + titleViewHeight), false, false);
        }
    }, 1000);
}
 
源代码2 项目: AndroidSkinAnimator   文件: SkinRotateAnimator3.java
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("scaleX",
                    1, 0.5f, 0.2f, 0.05f, 0.8f, 1),
            PropertyValuesHolder.ofFloat("scaleY",
                    1, 0.5f, 0.2f, 0.05f, 0.8f, 1),
            PropertyValuesHolder.ofFloat("rotationY", 0, 720))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new LinearInterpolator());

    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            if(action != null){
                action.action();
            }
        }
    }, PRE_DURATION);

    preAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    return this;
}
 
源代码3 项目: candybar-library   文件: TransitionAnimation.java
public static void startExitAnimation(MoveData moveData, TimeInterpolator interpolator, final Runnable endAction) {
    if (Build.VERSION.SDK_INT >= 21) {
        endAction.run();
        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);
}
 
源代码4 项目: smartcoins-wallet   文件: LockableActivity.java
public void showKeyboard(View view) {
    InputMethodManager imm = (InputMethodManager)
            getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);

    if (imm.isAcceptingText()) {
        Log.d(TAG, "Software Keyboard was shown");
    } else {
        Log.d(TAG, "Software Keyboard was not shown.");
        //Sometimes the android doesn't show the keyboard at start up. Scheduling a new open solved for all tested cases
        if (view.getVisibility() == View.VISIBLE) {
            Log.d(TAG, "View is still visible. Scheduling a new input opening attempt...");
            final View runnableView = view;
            view.postDelayed(new Runnable() {
                public void run() {
                    // do work
                    showKeyboard(runnableView);
                }
            }, 100);
        }
    }
}
 
源代码5 项目: prayer-times-android   文件: MainFragment.java
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (Preferences.SHOW_COMPASS_NOTE.get()) {

        final ViewGroup root = (ViewGroup) (view.getRootView());
        final View toast = LayoutInflater.from(getActivity()).inflate(R.layout.compass_toast_menu, root, false);
        root.addView(toast);

        toast.setOnClickListener(v -> root.removeView(toast));
        toast.postDelayed(() -> {
            if (toast.getRootView() == root)
                root.removeView(toast);
        }, 10000);
    }
}
 
源代码6 项目: kimai-android   文件: ActivityUtils.java
public ActivityUtils setSoftKeyboardVisibile(boolean visible, View... editView) {
    final Activity activity = _activity;
    if (activity != null) {
        final View v = (editView != null && editView.length > 0) ? (editView[0]) : (activity.getCurrentFocus() != null && activity.getCurrentFocus().getWindowToken() != null ? activity.getCurrentFocus() : null);
        final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        if (v != null && imm != null) {
            Runnable r = () -> {
                if (visible) {
                    v.requestFocus();
                    imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
                } else {
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                }
            };
            r.run();
            for (int d : new int[]{100, 350}) {
                v.postDelayed(r, d);
            }
        }
    }
    return this;
}
 
源代码7 项目: fuckView   文件: Hook.java
/**
 * 给View加上红边~~
 *
 * @param view the view to be bounded
 */
private static void addViewShape(final View view) {
    try {
        GradientDrawable gd = new GradientDrawable();
        gd.setStroke(4, Color.RED);
        final Drawable background = view.getBackground();
        view.setBackgroundDrawable(gd);
        //Then recover the background.
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                view.setBackgroundDrawable(background);
            }
        }, 800);
    } catch (Throwable ignored) {

    }
}
 
源代码8 项目: renderthread   文件: MainActivity.java
private void startTest(final View button, TestView... testViews) {

        // start animation for 3s
        button.setEnabled(false);
        for (TestView testView : testViews) {
            testView.startAnimation(3000);
        }

        // after 1s -> pause UI thread (for 1s)
        button.postDelayed(
                new Runnable() {
                    @Override
                    public void run() {
                        pauseUiThread(1000);
                    }
                },
                1000);

        // after 3s -> re-enable button
        button.postDelayed(
                new Runnable() {
                    @Override
                    public void run() {
                        button.setEnabled(true);
                    }
                },
                3000);
    }
 
源代码9 项目: ParticleView   文件: SpinnerActivity.java
@Override
public void onClick(View view) {
    showLoading();
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            hideLoading();
        }
    }, 4500);
}
 
源代码10 项目: PhotoDraweeView   文件: Attacher.java
private void postOnAnimation(View view, Runnable runnable) {
    if (Build.VERSION.SDK_INT >= 16) {
        view.postOnAnimation(runnable);
    } else {
        view.postDelayed(runnable, 16L);
    }
}
 
源代码11 项目: Favorite-Android-Client   文件: ViewCompat.java
public static void postOnAnimation(View view, Runnable runnable) {
	if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
		SDK16.postOnAnimation(view, runnable);
	} else {
		view.postDelayed(runnable, 16);
	}
}
 
源代码12 项目: android-project-wo2b   文件: Compat.java
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
源代码13 项目: Album   文件: Compat.java
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
源代码15 项目: OmniList   文件: Compat.java
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
源代码16 项目: RefreashTabView   文件: LinkMovement.java
private void checkForLongClick(View target, int delayOffset) {
    if (!target.isLongClickable()) {
        return;
    }
    if (longPress == null) {
        longPress = new CheckForLongPress(target);
    }
    target.postDelayed(longPress, ViewConfiguration.getLongPressTimeout() - delayOffset);
}
 
源代码17 项目: android-recipes-app   文件: ViewCompat.java
public void postOnAnimation(View view, Runnable action) {
    view.postDelayed(action, getFrameTime());
}
 
源代码18 项目: ProjectX   文件: Compat.java
public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
    view.postDelayed(action, getFrameTime() + delayMillis);
}
 
源代码19 项目: SmartSwipe   文件: ShuttersConsumer.java
protected void refreshBitmap() {
    if (lastRefreshTime == 0) {
        lastRefreshTime = SystemClock.elapsedRealtime();
    }
    View v = mWrapper.getContentView();
    final int leavesCount = this.mLeavesCount;
    int width = (int) (mWidth * 1F / (mHorizontalSwiping ? leavesCount : 1) + 0.5F);
    int height = (int) (mHeight * 1F / (mHorizontalSwiping ? 1 : leavesCount) + 0.5F);
    int lastWidth = mHorizontalSwiping ? (mWidth - width * (leavesCount - 1)) : width;
    int lastHeight = mHorizontalSwiping ? height : (mHeight - height * (leavesCount - 1));
    //TODO reuse bitmap array. Tried to use buffer bitmap array, but a blink bug happens when refreshable enabled
    Bitmap[] array = new Bitmap[leavesCount];
    CountDownLatch latch = new CountDownLatch(leavesCount);
    int scrollX = 0, scrollY = 0;
    for (int i = 0; i < leavesCount; i++) {
        if (mHorizontalSwiping) {
            scrollX = width * i;
        } else {
            scrollY = height * i;
        }
        if (i == leavesCount - 1) {
            if (lastWidth <= 0 || lastHeight <= 0) {
                latch.countDown();
            } else {
                SwipeUtil.runInThreadPool(new ScreenshotCreateRunnable(lastWidth, lastHeight, i, array, latch, v, scrollX, scrollY));
            }
        } else {
            SwipeUtil.runInThreadPool(new ScreenshotCreateRunnable(width, height, i, array, latch, v, scrollX, scrollY));
        }
    }
    try {
        latch.await();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if (!mSwiping && (mProgress <= 0 || mProgress >= 1)) {
        setRefreshing(false);
    }
    if (!mRefreshing) {
        return;
    }
    boolean hasNull = false;
    for (Bitmap bitmap : array) {
        if (bitmap == null) {
            hasNull = true;
            break;
        }
    }
    if (!hasNull) {
        this.mScreenshots = array;
    }
    v.post(refreshWrapperRunnable);
    if (mRefreshable) {
        long timePass = SystemClock.elapsedRealtime() - lastRefreshTime;
        lastRefreshTime = SystemClock.elapsedRealtime();
        if (timePass < refreshDelay) {
            v.postDelayed(new Runnable() {
                @Override
                public void run() {
                    SwipeUtil.runInThreadPool(refreshBitmapRunnable);
                }
            }, refreshDelay - timePass);
        } else {
            SwipeUtil.runInThreadPool(refreshBitmapRunnable);
        }
    } else {
        setRefreshing(false);
    }
}
 
源代码20 项目: MiBandDecompiled   文件: a.java
static void a(View view, Runnable runnable)
{
    view.postDelayed(runnable, 10L);
}
 
 方法所在类
 同类方法