Search in sources :

Example 1 with Message

use of android.os.Message 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 2 with Message

use of android.os.Message in project Launcher3 by chislon.

the class LauncherTransitionable method sendAdvanceMessage.

private void sendAdvanceMessage(long delay) {
    mHandler.removeMessages(ADVANCE_MSG);
    Message msg = mHandler.obtainMessage(ADVANCE_MSG);
    mHandler.sendMessageDelayed(msg, delay);
    mAutoAdvanceSentTime = System.currentTimeMillis();
}
Also used : Message(android.os.Message)

Example 3 with Message

use of android.os.Message in project PlayerHater by chrisrhoden.

the class SongQueue method getHandler.

private static Handler getHandler() {
    if (sHandler == null) {
        HandlerThread thread = new HandlerThread("SongQueue");
        thread.start();
        sHandler = new Handler(thread.getLooper()) {

            @Override
            public void handleMessage(Message msg) {
                SongMessage m = (SongMessage) msg.obj;
                switch(msg.what) {
                    case CURRENT_SONG:
                        m.queue.sendSongChanged(m.song, m.oldSong);
                        break;
                    case NEXT_SONG:
                        m.queue.sendNextSongChanged(m.song, m.oldSong);
                }
            }
        };
    }
    return sHandler;
}
Also used : HandlerThread(android.os.HandlerThread) Message(android.os.Message) Handler(android.os.Handler)

Example 4 with Message

use of android.os.Message in project AndroidDynamicLoader by mmin18.

the class AsyncTask method postResult.

private Result postResult(Result result) {
    @SuppressWarnings("unchecked") Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(this, result));
    message.sendToTarget();
    return result;
}
Also used : Message(android.os.Message)

Example 5 with Message

use of android.os.Message in project qksms by moezbhatti.

the class TransactionService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        // Call onNewIntent (below) on the Transaction thread.
        Message msg = mServiceHandler.obtainMessage(EVENT_NEW_INTENT);
        msg.arg1 = startId;
        msg.obj = intent;
        mServiceHandler.sendMessage(msg);
    }
    // [1]: http://developer.android.com/reference/android/app/Service.html#START_NOT_STICKY
    return Service.START_NOT_STICKY;
}
Also used : Message(android.os.Message)

Aggregations

Message (android.os.Message)3198 Handler (android.os.Handler)347 RemoteException (android.os.RemoteException)263 Bundle (android.os.Bundle)210 Test (org.junit.Test)144 Intent (android.content.Intent)130 IOException (java.io.IOException)124 Point (android.graphics.Point)86 HashMap (java.util.HashMap)77 SomeArgs (com.android.internal.os.SomeArgs)67 SmallTest (android.test.suitebuilder.annotation.SmallTest)64 Messenger (android.os.Messenger)63 ArrayList (java.util.ArrayList)59 View (android.view.View)52 File (java.io.File)50 MediumTest (android.test.suitebuilder.annotation.MediumTest)43 TextView (android.widget.TextView)41 IBinder (android.os.IBinder)38 Map (java.util.Map)37 PendingIntent (android.app.PendingIntent)33