本文整理汇总了Java中android.view.View.postDelayed方法的典型用法代码示例。如果您正苦于以下问题:Java View.postDelayed方法的具体用法?Java View.postDelayed怎么用?Java View.postDelayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.postDelayed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postOnAnimation
import android.view.View; //导入方法依赖的package包/类
private void postOnAnimation(View view, Runnable runnable) {
if (Build.VERSION.SDK_INT >= 16) {
view.postOnAnimation(runnable);
} else {
view.postDelayed(runnable, 16L);
}
}
示例2: addViewShape
import android.view.View; //导入方法依赖的package包/类
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) {
}
}
示例3: backToFinish
import android.view.View; //导入方法依赖的package包/类
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();
}
示例4: startExitAnimation
import android.view.View; //导入方法依赖的package包/类
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);
}
示例5: logout
import android.view.View; //导入方法依赖的package包/类
/**
* 退出登陆操作需要传递一个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);
}
示例6: resetPressedView
import android.view.View; //导入方法依赖的package包/类
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;
}
示例7: onTouch
import android.view.View; //导入方法依赖的package包/类
@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;
}
}
示例8: setUpSongListView
import android.view.View; //导入方法依赖的package包/类
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);
}
示例9: postOnAnimation
import android.view.View; //导入方法依赖的package包/类
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);
}
}
示例10: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* 显示软键盘
*/
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);
}
示例11: updateAdapterScaleAndAlpha
import android.view.View; //导入方法依赖的package包/类
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);
}
}
}
}
示例12: click4
import android.view.View; //导入方法依赖的package包/类
public void click4(View view) {
mAdapter.notifyFirstLoading();
view.postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.notifyFirst(getFirst());
}
}, 2000);
}
示例13: avoidDoubleClicks
import android.view.View; //导入方法依赖的package包/类
/***
* 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);
}
示例14: click1
import android.view.View; //导入方法依赖的package包/类
public void click1(View view) {
helper.notifyLoadingChanged();
view.postDelayed(new Runnable() {
@Override
public void run() {
helper.notifyDataSetChanged(initData());
}
}, 3000);
}
示例15: postOnAnimation
import android.view.View; //导入方法依赖的package包/类
public static void postOnAnimation(View view, Runnable runnable) {
if (VERSION.SDK_INT >= 16) {
SDK16.postOnAnimation(view, runnable);
} else {
view.postDelayed(runnable, 16);
}
}