Java Code Examples for android.view.View.postDelayed()

The following are Jave code examples for showing how to use postDelayed() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PicKing   File: Attacher.java   Source Code and License Vote up 7 votes
private void postOnAnimation(View view, Runnable runnable) {
    if (Build.VERSION.SDK_INT >= 16) {
        view.postOnAnimation(runnable);
    } else {
        view.postDelayed(runnable, 16L);
    }
}
 
Example 2
Project: fuckView   File: Hook.java   Source Code and License Vote up 7 votes
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);
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                view.setBackgroundDrawable(background);
            }
        }, 800);
    } catch (Throwable ignored) {

    }
}
 
Example 3
Project: garras   File: BaseFragment.java   Source Code and License Vote up 7 votes
public void backToFinish(View view) {
    if (mBackPressed + TIME_INTERVAL > System.currentTimeMillis()) {
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                finish();
                if (null != getActivity()) getActivity().supportFinishAfterTransition();
                android.os.Process.killProcess(android.os.Process.myPid());
            }
        }, 80);
        return;
    } else {
        showSnackbar(view, getString(R.string.back_exit));
    }
    mBackPressed = System.currentTimeMillis();
}
 
Example 4
Project: Mire   File: TransitionAnimation.java   Source Code and License Vote up 7 votes
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);
}
 
Example 5
Project: OSchina_resources_android   File: AccountHelper.java   Source Code and License Vote up 7 votes
/**
 * 退出登陆操作需要传递一个View协助完成延迟检测操作
 *
 * @param view     View
 * @param runnable 当清理完成后回调方法
 */
public static void logout(final View view, final Runnable runnable) {
    // 清除用户缓存
    clearUserCache();
    // 等待缓存清理完成
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.removeCallbacks(this);
            User user = SharedPreferencesHelper.load(instances.application, User.class);
            // 判断当前用户信息是否清理成功
            if (user == null || user.getId() <= 0) {
                clearAndPostBroadcast(instances.application);
                runnable.run();
            } else {
                view.postDelayed(this, 200);
            }
        }
    }, 200);

}
 
Example 6
Project: JD-Test   File: SimpleClickListener.java   Source Code and License Vote up 7 votes
private void resetPressedView(final View pressedView) {
    if (pressedView!=null){
        pressedView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (pressedView!=null){
                    pressedView.setPressed(false);
                }

            }
        },50);
    }

    mIsPrepressed = false;
    mPressedView = null;
}
 
Example 7
Project: PeSanKita-android   File: RepeatableImageKey.java   Source Code and License Vote up 7 votes
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example 8
Project: Orin   File: ArtistDetailActivity.java   Source Code and License Vote up 7 votes
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);
}
 
Example 9
Project: filepicker   File: Compat.java   Source Code and License Vote up 6 votes
public static void postOnAnimation(View view, Runnable runnable) {
	if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
		SDK16.postOnAnimation(view, runnable);
	} else {
		view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
	}
}
 
Example 10
Project: XinFramework   File: SupportHelper.java   Source Code and License Vote up 6 votes
/**
 * 显示软键盘
 */
public static void showSoftInput(final View view) {
    if (view == null || view.getContext() == null) return;
    final InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    view.requestFocus();
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
        }
    }, SHOW_SPACE);
}
 
Example 11
Project: ucar-weex-core   File: WXSliderNeighbor.java   Source Code and License Vote up 6 votes
private void updateAdapterScaleAndAlpha(final float alpha, final float scale) {
    final List<View> pageViews = mAdapter.getViews();
    final int curPos = mViewPager.getCurrentItem();

    if(pageViews.size() > 0) {
        final View currentPage = pageViews.get(curPos);
        updateScaleAndAlpha(((ViewGroup)currentPage).getChildAt(0), 1.0F, mCurrentItemScale);

        if(pageViews.size() < 2) {
            return;
        }
        //make sure View's width & height are measured.
        currentPage.postDelayed(WXThread.secure(new Runnable() {
            @Override
            public void run() {
                //change left and right page's translation
                updateNeighbor(currentPage, alpha, scale);

            }
        }), 17);

        // make sure only display view current, left, right.
        int left = (curPos == 0) ? pageViews.size()-1 : curPos-1;
        int right = (curPos == pageViews.size()-1) ? 0 : curPos+1;
        for(int i =0; i<mAdapter.getRealCount(); i++) {
            if(i != left && i != curPos && i != right) {
                ((ViewGroup)pageViews.get(i)).getChildAt(0).setAlpha(0F);
            }
        }
    }
}
 
Example 12
Project: GitHub   File: OpenCloseActivity.java   Source Code and License Vote up 6 votes
public void click4(View view) {
    mAdapter.notifyFirstLoading();
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            mAdapter.notifyFirst(getFirst());
        }
    }, 2000);
}
 
Example 13
Project: DeviceInfo   File: Methods.java   Source Code and License Vote up 6 votes
/***
 * To prevent from double clicking the row item and so prevents overlapping fragment.
 * **/
public static void avoidDoubleClicks(final View view) {
    final long DELAY_IN_MS = 500;
    if (!view.isClickable()) {
        return;
    }
    view.setClickable(false);
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.setClickable(true);
        }
    }, DELAY_IN_MS);
}
 
Example 14
Project: GCSApp   File: Compat.java   Source Code and License Vote up 6 votes
public static void postOnAnimation(View view, Runnable runnable) {
	if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
		SDK16.postOnAnimation(view, runnable);
	} else {
		view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
	}
}
 
Example 15
Project: MultiTypeRecyclerViewAdapter   File: RxStandardLinearActivity.java   Source Code and License Vote up 6 votes
public void click1(View view) {

        helper.notifyLoadingChanged();
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                helper.notifyDataSetChanged(initData());
            }
        }, 3000);

    }
 
Example 16
Project: encdroidMC   File: Compat.java   Source Code and License Vote up 6 votes
public static void postOnAnimation(View view, Runnable runnable) {
	if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
		SDK16.postOnAnimation(view, runnable);
	} else {
		view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
	}
}
 
Example 17
Project: boohee_v5.6   File: ViewCompat.java   Source Code and License Vote up 6 votes
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= 16) {
        SDK16.postOnAnimation(view, runnable);
    } else {
        view.postDelayed(runnable, 16);
    }
}
 
Example 18
Project: sctalk   File: ViewCompat.java   Source Code and License Vote up 6 votes
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);
	}
}
 
Example 19
Project: CustomAndroidOneSheeld   File: ViewCompat.java   Source Code and License Vote up 6 votes
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);
	}
}
 
Example 20
Project: HandyGridView   File: OnceRunnable.java   Source Code and License Vote up 5 votes
public void postDelaySelf(View carrier, int delay) {
    if (!mScheduled) {
        carrier.postDelayed(this, delay);
        mScheduled = true;
    }
}