use of android.os.Handler in project ActivityAnimationLib by dkmeteor.
the class SplitEffect method animate.
public void animate(final Activity destActivity, final int duration) {
final Interpolator interpolator = new DecelerateInterpolator();
destActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
new Handler().post(new Runnable() {
@Override
public void run() {
mSetAnim = new AnimatorSet();
mTopImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mBottomImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mSetAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
clean(destActivity);
}
@Override
public void onAnimationCancel(Animator animation) {
clean(destActivity);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
Animator anim1 = ObjectAnimator.ofFloat(mTopImage, "translationY", mTopImage.getHeight() * -1);
Animator anim2 = ObjectAnimator.ofFloat(mBottomImage, "translationY", mBottomImage.getHeight());
if (interpolator != null) {
anim1.setInterpolator(interpolator);
anim2.setInterpolator(interpolator);
}
mSetAnim.setDuration(duration);
mSetAnim.playTogether(anim1, anim2);
mSetAnim.start();
}
});
}
use of android.os.Handler in project ActivityAnimationLib by dkmeteor.
the class TwisterEffect method animate.
public void animate(final Activity destActivity, final int duration) {
new Handler().post(new Runnable() {
@Override
public void run() {
final Handler callBack = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 101:
mTopImage.invalidate();
break;
case 102:
clean(destActivity);
break;
}
}
};
Thread animationThread = new Thread(new Runnable() {
@Override
public void run() {
while (t < 1) {
t += 0.08;
callBack.sendEmptyMessage(101);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
callBack.sendEmptyMessage(102);
}
});
animationThread.start();
}
});
}
use of android.os.Handler in project ActivityAnimationLib by dkmeteor.
the class CloseEffect method animate.
public void animate(final Activity destActivity, final int duration) {
//make sure it is run in main thread
new Handler().post(new Runnable() {
@Override
public void run() {
//callback UI thread
final Handler callBack = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 101:
mTopImage.invalidate();
break;
case 102:
clean(destActivity);
break;
}
}
};
Thread animationThread = new Thread(new Runnable() {
@Override
public void run() {
while (t < 1) {
t += 0.08;
callBack.sendEmptyMessage(101);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
callBack.sendEmptyMessage(102);
}
});
animationThread.start();
}
});
}
use of android.os.Handler in project Meizhi by drakeet.
the class FloatView method setNotification.
public void setNotification(final HeadsUp headsUp) {
this.headsUp = headsUp;
mHandle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (headsUp.isActivateStatusBar()) {
HeadsUpManager.getInstant(getContext()).silencerNotify(headsUp);
}
HeadsUpManager.getInstant(getContext()).animDismiss(headsUp);
}
};
cutDownTime = new CutDownTime();
if (!headsUp.isSticky()) {
cutDownTime.start();
}
cutDown = headsUp.getDuration();
if (headsUp.getCustomView() == null) {
View defaultView = LayoutInflater.from(getContext()).inflate(R.layout.notification, rootView, false);
rootView.addView(defaultView);
ImageView imageView = (ImageView) defaultView.findViewById(R.id.iconIM);
TextView titleTV = (TextView) defaultView.findViewById(R.id.titleTV);
TextView timeTV = (TextView) defaultView.findViewById(R.id.timeTV);
TextView messageTV = (TextView) defaultView.findViewById(R.id.messageTV);
imageView.setImageResource(headsUp.getIcon());
titleTV.setText(headsUp.getTitleStr());
messageTV.setText(headsUp.getMsgStr());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
timeTV.setText(simpleDateFormat.format(new Date()));
if (headsUp.isExpand() && headsUp.getActions().size() > 0) {
defaultView.findViewById(R.id.menuL).setVisibility(VISIBLE);
defaultView.findViewById(R.id.line).setVisibility(VISIBLE);
defaultView.findViewById(R.id.menu1).setVisibility(VISIBLE);
ImageView imageView1 = (ImageView) defaultView.findViewById(R.id.menuIM1);
ImageView imageView2 = (ImageView) defaultView.findViewById(R.id.menuIM2);
ImageView imageView3 = (ImageView) defaultView.findViewById(R.id.menuIM3);
TextView text1 = (TextView) defaultView.findViewById(R.id.menuText1);
TextView text2 = (TextView) defaultView.findViewById(R.id.menuText2);
TextView text3 = (TextView) defaultView.findViewById(R.id.menuText3);
imageView1.setImageResource(headsUp.getActions().get(0).icon);
text1.setText(headsUp.getActions().get(0).title);
defaultView.findViewById(R.id.menu1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(0).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
if (headsUp.getActions().size() > 1) {
defaultView.findViewById(R.id.menu2).setVisibility(VISIBLE);
imageView2.setImageResource(headsUp.getActions().get(1).icon);
text2.setText(headsUp.getActions().get(1).title);
defaultView.findViewById(R.id.menu2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(1).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
if (headsUp.getActions().size() > 2) {
defaultView.findViewById(R.id.menu3).setVisibility(VISIBLE);
imageView3.setImageResource(headsUp.getActions().get(2).icon);
text3.setText(headsUp.getActions().get(2).title);
defaultView.findViewById(R.id.menu3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(2).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
}
} else {
setCustomView(headsUp.getCustomView());
}
}
use of android.os.Handler in project Meizhi by drakeet.
the class MainActivity method onPostCreate.
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
new Handler().postDelayed(() -> setRefresh(true), 358);
loadData(true);
}
Aggregations