下面列出了android.widget.TextView#postDelayed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void removeVideoList() {
mask.setVisibility(View.GONE);
int size = mList.size() - 1;
for (int i = size; i > 0; i--) {
mList.remove(i);
}
mAdapter.notifyItemRangeRemoved(1, size);
final View v = mRecycler.getChildAt(0);
final int[] location = new int[2];
v.getLocationOnScreen(location);
final PlayerContainer container = v.findViewById(R.id.container);
final TextView title = v.findViewById(R.id.video_title);
final RelativeLayout bottomLayout = v.findViewById(R.id.bottom_layout);
title.postDelayed(new Runnable() {
@Override
public void run() {
title.animate().alpha(0f).setDuration(DURATION);
bottomLayout.animate().alpha(0f).setDuration(DURATION);
container.animate().scaleX((float) mAttr.getWidth() / container.getWidth())
.scaleY((float) mAttr.getHeight() / container.getHeight())
.setDuration(DURATION);
v.animate().translationY(mAttr.getY() - location[1] - (container.getHeight() - mAttr.getHeight()) / 2 - title.getHeight()).setDuration(DURATION);
bgAnimator.reverse();
}
}, 250);
}
@Override
public void notifyViewChange() {
if (target == null) {
return;
}
final TextView t = target.get();
if (isViewSet && t != null && spanned != null) {
try {
//这儿会有索引越界
t.removeCallbacks(updateRunable);
t.postDelayed(updateRunable, 200);
} catch (Exception ignored) {
}
}
}
void add(Device device) {
Device dev = null;
for (Device item : getItems()) {
if (item.equals(device)) {
dev = item;
break;
}
}
if (dev == null) {
updateTimeMap.put(device.getAddress(), System.currentTimeMillis());
getItems().add(device);
notifyDataSetChanged();
} else {
Long time = updateTimeMap.get(device.getAddress());
if (time == null || System.currentTimeMillis() - time > 2000) {
updateTimeMap.put(device.getAddress(), System.currentTimeMillis());
if (dev.getRssi() != device.getRssi()) {
dev.setRssi(device.getRssi());
final TextView tvRssi = rssiViews.get(device.getAddress());
if (tvRssi != null) {
tvRssi.setText("" + device.getRssi());
tvRssi.setTextColor(Color.BLACK);
tvRssi.postDelayed(() -> tvRssi.setTextColor(0xFF909090), 800);
}
}
}
}
}
public void removeVideoList() {
int size = mList.size() - 1;
for (int i = size; i > 0; i--) {
mList.remove(i);
}
mAdapter.notifyItemRangeRemoved(1, size);
final View view = mRecycler.getChildAt(0);
final int[] location = new int[2];
view.getLocationOnScreen(location);
final ImageView image = view.findViewById(R.id.adapter_video_list_image);
final FrameLayout container = view.findViewById(R.id.adapter_video_list_container);
final TextView title = view.findViewById(R.id.adapter_video_list_title);
final LinearLayout bottom = view.findViewById(R.id.bottom_layout);
title.postDelayed(new Runnable() {
@Override
public void run() {
title.setVisibility(View.GONE);
bottom.setVisibility(View.GONE);
image.setVisibility(View.GONE);
container.animate().scaleX((float) mAttr.getWidth() / container.getMeasuredWidth())
.scaleY((float) mAttr.getHeight() / container.getMeasuredHeight())
.setDuration(DURATION);
view.animate().translationY(mAttr.getY() - location[1]).setDuration(DURATION);
ObjectAnimator animator = ObjectAnimator.ofInt(mRoot, "backgroundColor", 0xff000000, 0x00000000);
animator.setEvaluator(new ArgbEvaluator());
animator.setDuration(DURATION);
animator.start();
}
}, 250);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Rx线性排布");
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
textView1 = (TextView) findViewById(R.id.text1);
textView2 = (TextView) findViewById(R.id.text2);
textView3 = (TextView) findViewById(R.id.text3);
textView4 = (TextView) findViewById(R.id.text4);
helper = new RxAdapterHelper();
SimpleRxHelperAdapter adapter = new SimpleRxHelperAdapter(helper);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new StickyHeaderDecoration(adapter));
recyclerView.setAdapter(adapter);
helper.notifyLoadingDataAndHeaderChanged(SimpleHelper.LEVEL_THIRD, 3);
textView3.postDelayed(() -> {
Random random = new Random();
int rand = random.nextInt(6);
List<MultiHeaderEntity> list = new ArrayList<>();
for (int i = 0, size = rand + 1; i < size; i++) {
list.add(new ThirdItem(String.format(Locale.getDefault(), "我是第三种类型%d", i), 12 + i));
}
textView3.setText(String.format(Locale.getDefault(), "类型3的数量:%d", list.size()));
helper.notifyModuleDataAndHeaderChanged(list, new HeaderThirdItem("我是第三种类型的头", IDUtil.getId()), SimpleHelper.LEVEL_THIRD);
}, 3000);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("线性排布");
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
textView1 = (TextView) findViewById(R.id.text1);
textView2 = (TextView) findViewById(R.id.text2);
textView3 = (TextView) findViewById(R.id.text3);
textView4 = (TextView) findViewById(R.id.text4);
helper = new SimpleHelper();
SimpleHelperAdapter adapter = new SimpleHelperAdapter(helper);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new StickyHeaderDecoration(adapter));
recyclerView.setAdapter(adapter);
helper.notifyLoadingDataAndHeaderChanged(SimpleHelper.LEVEL_THIRD, 3);
textView3.postDelayed(() -> {
Random random = new Random();
int rand = random.nextInt(6);
List<MultiHeaderEntity> list = new ArrayList<>();
for (int i = 0, size = rand + 1; i < size; i++) {
list.add(new ThirdItem(String.format(Locale.getDefault(), "我是第三种类型%d", i), 12 + i));
}
textView3.setText(String.format(Locale.getDefault(), "类型3的数量:%d", list.size()));
helper.notifyModuleDataAndHeaderChanged(list, new HeaderThirdItem("我是第三种类型的头", IDUtil.getId()), SimpleHelper.LEVEL_THIRD);
}, 3000);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
TextView buildTimeTv = findViewById(R.id.tv_build_time);
buildTimeTv.setText(String.format(getString(R.string.splash_build_time), BuildConfig.BUILD_TIME));
buildTimeTv.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, 2000);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compare_performace);
hwBubblesView = (NormalBubblesView) findViewById(R.id.hw_bubble_view);
swBubblesView = (SurfaceBubblesView) findViewById(R.id.sw_bubble_view);
glBubblesView = (GLBubblesView) findViewById(R.id.gl_bubble_view);
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_robot);
hwBubblesView.setBitmap(bitmap);
swBubblesView.setBitmap(bitmap);
glBubblesView.setBitmap(bitmap);
oneText = (TextView) findViewById(R.id.count_one);
twoText = (TextView) findViewById(R.id.count_two);
threeText = (TextView) findViewById(R.id.count_three);
threeText.postDelayed(new Runnable() {
@Override
public void run() {
if (isFinishing()) {
return;
}
oneText.setText(String.format(Locale.CHINA, "hw canvas:%d", hwBubblesView.getCnt()));
twoText.setText(String.format(Locale.CHINA, "sw canvas:%d", swBubblesView.getCnt()));
threeText.setText(String.format(Locale.CHINA, "gl canvas:%d", glBubblesView.getCnt()));
threeText.postDelayed(this, 500);
}
}, 500);
new Thread(new Runnable() {
@Override
public void run() {
}
}).start();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
TextView tv_logo = findViewById(R.id.tv_logo);
tv_logo.postDelayed(this::jump,500L);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView tv2 = (TextView) findViewById(R.id.mTv2);
tv2.postDelayed(new Runnable() {
@Override
public void run() {
tv2.setText("Hello world!");
tv2.setVisibility(View.VISIBLE);
}
}, 200);
}
public void setupView() {
mRootView.setVisibility(View.VISIBLE);
mAvatar = findById(mRootView, R.id.mToAvatar);
Picasso.with(mContext).load(mToUserAvatar).into(mAvatar);
CountdownView countdownView = findById(mRootView, R.id.mCountDownTimber);
countdownView.start(INVITE_EXPIRE_MILLIS);
countdownView.setOnCountdownEndListener(new CountdownView.OnCountdownEndListener() {
@Override
public void onEnd(CountdownView cv) {
if (mController != null) {
mController.denied();
}
}
});
TextView tvToUsername = findById(mRootView, R.id.mTvToUsername);
tvToUsername.setText(mToUsername);
// TODO simulate accepted
tvToUsername.postDelayed(new Runnable() {
@Override
public void run() {
if (mController != null) {
mController.accepted(mFromUserAvatar, mFromUsername, mToUserAvatar, mToUsername,
mToUid);
}
}
}, 5000);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvIcon1 = (TextView) findViewById(R.id.tv_icon_1);
tvIcon2 = (TextView) findViewById(R.id.tv_icon_2);
tvIcon3 = (TextView) findViewById(R.id.tv_icon_3);
tvIcon4 = (TextView) findViewById(R.id.tv_icon_4);
tvColor1 = (TextView) findViewById(R.id.tv_color_1);
tvColor2 = (TextView) findViewById(R.id.tv_color_2);
tvColor3 = (TextView) findViewById(R.id.tv_color_3);
Drawable icon1 = OneDrawable.createBgDrawable(this, R.drawable.ic_action_add);
tvIcon1.setBackgroundDrawable(icon1);
tvIcon1.setClickable(true);
tvIcon1.setEnabled(false);
tvIcon1.postDelayed(new Runnable() {
@Override
public void run() {
tvIcon1.setEnabled(true);
}
}, 3000);
Drawable icon2 = OneDrawable.createBgDrawableWithDarkMode(this, R.drawable.ic_action_add, 0.4f);
tvIcon2.setBackgroundDrawable(icon2);
tvIcon2.setClickable(true);
Drawable icon3 = OneDrawable.createBgDrawableWithAlphaMode(this, R.drawable.ic_action_name);
tvIcon3.setBackgroundDrawable(icon3);
tvIcon3.setClickable(true);
Drawable icon4 = OneDrawable.createBgDrawableWithAlphaMode(this, R.drawable.ic_action_name, 0.3f);
tvIcon4.setBackgroundDrawable(icon4);
tvIcon4.setClickable(true);
Drawable color1 = OneDrawable.createBgColorWithAlphaMode(this, getResources().getColor(R.color.colorPrimary));
tvColor1.setBackgroundDrawable(color1);
tvColor1.setClickable(true);
Drawable color2 = OneDrawable.createBgColor(this, getResources().getColor(R.color.colorAccent));
tvColor2.setBackgroundDrawable(color2);
tvColor2.setClickable(true);
tvColor2.setEnabled(false);
tvColor2.postDelayed(new Runnable() {
@Override
public void run() {
tvColor2.setEnabled(true);
}
}, 1000);
Drawable color3 = OneDrawable.createBgColor(this, Color.parseColor("#cccccc"));
tvColor3.setBackgroundDrawable(color3);
tvColor3.setClickable(true);
tvColor3.setEnabled(false);
tvColor3.postDelayed(new Runnable() {
@Override
public void run() {
tvColor3.setEnabled(true);
}
}, 1000);
}
@Override
protected void onInit(Bundle savedInstanceState) {
Intent intent = getIntent();
if (intent != null) {
String id = intent.getStringExtra("Id");
mId = UUID.fromString(id);
}
// Init presenter
mPresenter = new RecordDetailPresenter(this);
// Init View
mYearMonth = (TextView) findViewById(R.id.txt_year_month);
mBrief = (TextView) findViewById(R.id.txt_brief);
mOperation = findViewById(R.id.lay_scroll_operation);
mSimpleDate = (SimpleDateView) findViewById(R.id.simple_date);
mLunar = (TextView) findViewById(R.id.txt_lunar);
mDate = (TextView) findViewById(R.id.txt_date);
mTop = findViewById(R.id.lay_top);
mDate.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Hero.otf"));
AnimJagDrawable drawable = new AnimJagDrawable();
drawable.setFluCount(new Rect(0, 0, 0, 36));
mTop.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mTop.setBackgroundDrawable(drawable);
findViewById(R.id.container).setOnClickListener(this);
findViewById(R.id.detail_btn_share).setOnClickListener(this);
findViewById(R.id.detail_btn_save).setOnClickListener(this);
findViewById(R.id.detail_btn_edit).setOnClickListener(this);
findViewById(R.id.detail_btn_delete).setOnClickListener(this);
mDate.postDelayed(new Runnable() {
@Override
public void run() {
Animation anim = AnimationUtils.loadAnimation(RecordDetailActivity.this,
R.anim.anim_record_detail_content_in);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
super.onAnimationEnd(animation);
mDate.setVisibility(View.VISIBLE);
}
});
mDate.clearAnimation();
mDate.startAnimation(anim);
}
}, 64);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContainer = (RelativeLayout) findViewById(R.id.mRlContainer);
mTextView = (TextView) findViewById(R.id.mTv);
mTextView2 = (TextView) findViewById(R.id.mTv2);
mTextView3 = (TextView) findViewById(R.id.mTv3);
final MoveGestureDetector moveGestureDetector =
new MoveGestureDetector(this, new SimpleOnMoveGestureListener() {
@Override
public boolean onMove(MoveGestureDetector detector) {
Log.d("MainActivity", "" + mIsShowing + ", " + detector.getFocusDelta().y);
if (mIsShowing) {
mMoveUpY += detector.getFocusDelta().y;
if (mMoveUpY > 0) {
mMoveUpY = 0;
}
if (mMoveUpY < -TRIGGER_MOVED_Y) {
hidePanel();
}
} else {
mMoveDownY += detector.getFocusDelta().y;
if (mMoveDownY < 0) {
mMoveDownY = 0;
}
if (mMoveDownY > TRIGGER_MOVED_Y) {
showPanel();
}
}
return true;
}
});
mContainer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return moveGestureDetector.onTouchEvent(event);
}
});
mTextView.postDelayed(mHidingRunnable, 2000);
}