Search in sources :

Example 81 with Handler

use of android.os.Handler in project chromeview by pwnall.

the class DeviceMotionAndOrientation method getHandler.

private Handler getHandler() {
    // use the same polling thread (also see crbug/234282).
    synchronized (mHandlerLock) {
        if (mHandler == null) {
            HandlerThread thread = new HandlerThread("DeviceMotionAndOrientation");
            thread.start();
            // blocks on thread start
            mHandler = new Handler(thread.getLooper());
        }
        return mHandler;
    }
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler)

Example 82 with Handler

use of android.os.Handler in project chromeview by pwnall.

the class AwWebContentsDelegateAdapter method showRepostFormWarningDialog.

@Override
public void showRepostFormWarningDialog(final ContentViewCore contentViewCore) {
    // TODO(mkosiba) We should be using something akin to the JsResultReceiver as the
    // callback parameter (instead of ContentViewCore) and implement a way of converting
    // that to a pair of messages.
    final int MSG_CONTINUE_PENDING_RELOAD = 1;
    final int MSG_CANCEL_PENDING_RELOAD = 2;
    // TODO(sgurun) Remember the URL to cancel the reload behavior
    // if it is different than the most recent NavigationController entry.
    final Handler handler = new Handler(Looper.getMainLooper()) {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_CONTINUE_PENDING_RELOAD:
                    {
                        contentViewCore.continuePendingReload();
                        break;
                    }
                case MSG_CANCEL_PENDING_RELOAD:
                    {
                        contentViewCore.cancelPendingReload();
                        break;
                    }
                default:
                    throw new IllegalStateException("WebContentsDelegateAdapter: unhandled message " + msg.what);
            }
        }
    };
    Message resend = handler.obtainMessage(MSG_CONTINUE_PENDING_RELOAD);
    Message dontResend = handler.obtainMessage(MSG_CANCEL_PENDING_RELOAD);
    mContentsClient.onFormResubmission(dontResend, resend);
}
Also used : Message(android.os.Message) ConsoleMessage(android.webkit.ConsoleMessage) Handler(android.os.Handler)

Example 83 with Handler

use of android.os.Handler in project weiciyuan by qii.

the class ShowcaseViews method createShowcaseViewDismissListener.

private View.OnClickListener createShowcaseViewDismissListener(final ShowcaseView showcaseView) {
    return new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //Needed for TYPE_ONE_SHOT
            showcaseView.onClick(showcaseView);
            int fadeOutTime = showcaseView.getConfigOptions().fadeOutDuration;
            if (fadeOutTime > 0) {
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        showNextView(showcaseView);
                    }
                }, fadeOutTime);
            } else {
                showNextView(showcaseView);
            }
        }
    };
}
Also used : Handler(android.os.Handler) View(android.view.View)

Example 84 with Handler

use of android.os.Handler in project weiciyuan by qii.

the class AnimationUtils method createMovementAnimation.

public static AnimatorSet createMovementAnimation(View view, float canvasX, float canvasY, float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY, final AnimationEndListener listener) {
    view.setAlpha(INVISIBLE);
    ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE, VISIBLE).setDuration(500);
    ObjectAnimator setUpX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetStartX).setDuration(INSTANT);
    ObjectAnimator setUpY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetStartY).setDuration(INSTANT);
    ObjectAnimator moveX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetEndX).setDuration(1000);
    ObjectAnimator moveY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetEndY).setDuration(1000);
    moveX.setStartDelay(1000);
    moveY.setStartDelay(1000);
    ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE).setDuration(500);
    alphaOut.setStartDelay(2500);
    AnimatorSet as = new AnimatorSet();
    as.play(setUpX).with(setUpY).before(alphaIn).before(moveX).with(moveY).before(alphaOut);
    Handler handler = new Handler();
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            listener.onAnimationEnd();
        }
    };
    handler.postDelayed(runnable, 3000);
    return as;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Handler(android.os.Handler) AnimatorSet(android.animation.AnimatorSet)

Example 85 with Handler

use of android.os.Handler in project weiciyuan by qii.

the class SimpleTextNotificationService method buildNotification.

private void buildNotification(String uid) {
    ValueWrapper valueWrapper = valueBagHashMap.get(uid);
    if (valueWrapper == null) {
        return;
    }
    final AccountBean accountBean = valueWrapper.accountBean;
    final UnreadBean unreadBean = valueWrapper.unreadBean;
    Intent clickToOpenAppPendingIntentInner = valueWrapper.clickToOpenAppPendingIntentInner;
    String ticker = valueWrapper.ticker;
    final RecordOperationAppBroadcastReceiver clearNotificationEventReceiver = valueWrapper.clearNotificationEventReceiver;
    Notification.Builder builder = new Notification.Builder(getBaseContext()).setTicker(ticker).setContentText(accountBean.getUsernick()).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setContentIntent(getPendingIntent(clickToOpenAppPendingIntentInner)).setOnlyAlertOnce(true);
    builder.setContentTitle(ticker);
    Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(GlobalContext.getInstance(), clearNotificationEventReceiver);
    valueWrapper.clearNotificationEventReceiver = new RecordOperationAppBroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        new ClearUnreadDao(accountBean.getAccess_token()).clearMentionStatusUnread(unreadBean, accountBean.getUid());
                        new ClearUnreadDao(accountBean.getAccess_token()).clearMentionCommentUnread(unreadBean, accountBean.getUid());
                        new ClearUnreadDao(accountBean.getAccess_token()).clearCommentUnread(unreadBean, accountBean.getUid());
                    } catch (WeiboException ignored) {
                    } finally {
                        Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(GlobalContext.getInstance(), clearNotificationEventReceiver);
                        if (Utility.isDebugMode()) {
                            new Handler(Looper.getMainLooper()).post(new Runnable() {

                                @Override
                                public void run() {
                                    Toast.makeText(getApplicationContext(), "weiciyuan:remove notification items", Toast.LENGTH_SHORT).show();
                                }
                            });
                        }
                    }
                }
            }).start();
        }
    };
    IntentFilter intentFilter = new IntentFilter(RESET_UNREAD_MENTIONS_WEIBO_ACTION);
    GlobalContext.getInstance().registerReceiver(valueWrapper.clearNotificationEventReceiver, intentFilter);
    Intent broadcastIntent = new Intent(RESET_UNREAD_MENTIONS_WEIBO_ACTION);
    PendingIntent deletedPendingIntent = PendingIntent.getBroadcast(GlobalContext.getInstance(), accountBean.getUid().hashCode(), broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setDeleteIntent(deletedPendingIntent);
    Utility.configVibrateLedRingTone(builder);
    NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(getMentionsWeiboNotificationId(accountBean), builder.build());
}
Also used : Context(android.content.Context) GlobalContext(org.qii.weiciyuan.support.utils.GlobalContext) IntentFilter(android.content.IntentFilter) NotificationManager(android.app.NotificationManager) Handler(android.os.Handler) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RecordOperationAppBroadcastReceiver(org.qii.weiciyuan.support.lib.RecordOperationAppBroadcastReceiver) Notification(android.app.Notification) ClearUnreadDao(org.qii.weiciyuan.dao.unread.ClearUnreadDao) UnreadBean(org.qii.weiciyuan.bean.UnreadBean) WeiboException(org.qii.weiciyuan.support.error.WeiboException) PendingIntent(android.app.PendingIntent) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Aggregations

Handler (android.os.Handler)1906 Message (android.os.Message)254 View (android.view.View)207 Intent (android.content.Intent)174 HandlerThread (android.os.HandlerThread)156 TextView (android.widget.TextView)118 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 ArrayList (java.util.ArrayList)97 Test (org.junit.Test)85 Context (android.content.Context)71 IntentFilter (android.content.IntentFilter)69 RemoteException (android.os.RemoteException)63 IOException (java.io.IOException)63 ComponentName (android.content.ComponentName)57 ImageView (android.widget.ImageView)57 Bundle (android.os.Bundle)56 RecyclerView (android.support.v7.widget.RecyclerView)54 Looper (android.os.Looper)53 File (java.io.File)46 ContentObserver (android.database.ContentObserver)44