Example usage for android.os Message getWhen

List of usage examples for android.os Message getWhen

Introduction

In this page you can find the example usage for android.os Message getWhen.

Prototype

public long getWhen() 

Source Link

Document

Return the targeted delivery time of this message, in milliseconds.

Usage

From source file:mp.teardrop.PlaybackService.java

@Override
public boolean handleMessage(Message message) {
    switch (message.what) {
    case CALL_GO:
        if (message.arg1 == 0)
            playPause();// w w w .  j a  v a 2  s  .c o m
        else
            setCurrentSong(message.arg1, false);
        break;
    case SAVE_STATE:
        // For unexpected terminations: crashes, task killers, etc.
        // In most cases onDestroy will handle this
        saveState(0);
        break;
    case PROCESS_SONG:
        processSong((Song) message.obj, (message.arg1 == FORCE_PLAYBACK));
        break;
    case QUERY:
        runQuery((QueryTask) message.obj);
        break;
    case CLOUD_SONGS:
        runDropboxQuery((ArrayList<CloudSongMetadata>) message.obj, message.arg1);
        break;
    case IDLE_TIMEOUT:
        if ((mState & FLAG_PLAYING) != 0) {
            mHandler.sendMessage(mHandler.obtainMessage(FADE_OUT, 0));
        }
        break;
    case FADE_OUT:
        if (mFadeOut <= 0.0f) {
            mIdleStart = SystemClock.elapsedRealtime();
            unsetFlag(FLAG_PLAYING);
        } else {
            mFadeOut -= 0.01f;
            mHandler.sendMessageDelayed(mHandler.obtainMessage(FADE_OUT, 0), 50);
        }
        refreshReplayGainValues(); /* Updates the volume using the new mFadeOut value */
        break;
    case PROCESS_STATE:
        processNewState(message.arg1, message.arg2);
        break;
    case BROADCAST_CHANGE:
        broadcastChange(message.arg1, (Song) message.obj, message.getWhen());
        break;
    case RELEASE_WAKE_LOCK:
        if (mWakeLock != null && mWakeLock.isHeld())
            mWakeLock.release();
        break;
    case SKIP_BROKEN_SONG:
        /* Advance to next song if the user didn't already change.
         * But we are restoring the Playing state in ANY case as we are most
         * likely still stopped due to the error
         * Note: This is somewhat racy with user input but also is the - by far - simplest
         *       solution */
        if (getTimelinePosition() == message.arg1) {
            setCurrentSong(1, true);
        }
        break;
    default:
        return false;
    }

    return true;
}