Search in sources :

Example 21 with Handler

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();
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) Handler(android.os.Handler) Interpolator(android.view.animation.Interpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet)

Example 22 with Handler

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();
        }
    });
}
Also used : Message(android.os.Message) Handler(android.os.Handler)

Example 23 with Handler

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();
        }
    });
}
Also used : Message(android.os.Message) Handler(android.os.Handler)

Example 24 with Handler

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());
    }
}
Also used : Message(android.os.Message) Handler(android.os.Handler) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 25 with Handler

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);
}
Also used : Handler(android.os.Handler)

Aggregations

Handler (android.os.Handler)1843 Message (android.os.Message)253 View (android.view.View)201 Intent (android.content.Intent)165 HandlerThread (android.os.HandlerThread)135 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 TextView (android.widget.TextView)114 ArrayList (java.util.ArrayList)95 Test (org.junit.Test)80 Context (android.content.Context)67 RemoteException (android.os.RemoteException)63 IOException (java.io.IOException)61 IntentFilter (android.content.IntentFilter)57 ComponentName (android.content.ComponentName)56 ImageView (android.widget.ImageView)55 RecyclerView (android.support.v7.widget.RecyclerView)52 Bundle (android.os.Bundle)51 Looper (android.os.Looper)51 File (java.io.File)45 HashMap (java.util.HashMap)44