Example usage for android.os Message Message

List of usage examples for android.os Message Message

Introduction

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

Prototype

public Message() 

Source Link

Document

Constructor (but the preferred way to get a Message is to call #obtain() Message.obtain() ).

Usage

From source file:com.nbplus.iotlib.IoTInterface.java

private boolean proceedKeepAliveDeviceCommand(String uuid) {
    Log.d(TAG, ">> proceedKeepAliveDeviceCommand() uuid = " + uuid);

    if (mKeepAliveDeviceList.get(uuid) == null) {
        Log.w(TAG, "Unknown uuid...");
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 0;/*from  w w w  . j  a v a 2s.c  o  m*/
        mHandler.sendMessage(disconnMsg);
        return false;
    }

    // try first scenario command
    IoTDeviceScenario scenario = mKeepAliveDeviceList.get(uuid).getNextScenario();
    if (scenario == null) {
        Log.w(TAG, "Device scenario is not found.. ");
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 0;
        mHandler.sendMessage(disconnMsg);
        return false;
    }

    Bundle extras = new Bundle();
    IoTHandleData data = new IoTHandleData();
    data.setDeviceId(mKeepAliveDeviceList.get(uuid).getDeviceId());
    data.setDeviceTypeId(mKeepAliveDeviceList.get(uuid).getDeviceTypeId());
    data.setCharacteristicUuid(scenario.getCharacteristic());
    data.setServiceUuid(scenario.getService());

    int cmd = -1;
    switch (scenario.getCmd()) {
    case IoTDeviceScenario.CMD_READ:
        cmd = IoTServiceCommand.DEVICE_READ_DATA;
        break;
    case IoTDeviceScenario.CMD_WRITE:
        cmd = IoTServiceCommand.DEVICE_WRITE_DATA;
        if (StringUtils.isEmptyString(scenario.getDataType())) {
            // data type ?  data ?  ?.
            if (StringUtils.isEmptyString(scenario.getData())) {
                // data ? ? .
                Log.w(TAG, "Can't find data type or data");
                mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
                Message disconnMsg = new Message();
                disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
                disconnMsg.arg1 = 0;
                mHandler.sendMessage(disconnMsg);
                return false;
            }

            byte[] setData = DataParser.getHextoBytes(scenario.getData());
            data.setValue(setData);
        } else {
            if (scenario.getDataType().equals("current_time")) {
                byte[] dataByte = DataGenerator.getCurrentTimeData();
                data.setValue(dataByte);
            } else {
                Log.w(TAG, "Unknown data type..");
                mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
                Message disconnMsg = new Message();
                disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
                disconnMsg.arg1 = 0;
                mHandler.sendMessage(disconnMsg);
                return false;
            }
        }
        break;
    case IoTDeviceScenario.CMD_NOTIFY:
        cmd = IoTServiceCommand.DEVICE_SET_NOTIFICATION;
        break;
    default: {
        Log.w(TAG, "Unknown device command... skip this device");
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 0;
        mHandler.sendMessage(disconnMsg);
        return false;
    }
    }

    if (cmd == -1) {
        Log.w(TAG, "may be end of command...");
        return true;
    }
    extras.putParcelable(IoTServiceCommand.KEY_DATA, data);
    sendMessageToService(cmd, extras);
    return true;
}

From source file:com.roiland.crm.sm.ui.view.ScOppoInfoFragment.java

/**
 * //from  w w w . j  a  v a 2s  .  c o m
 * <pre>
 * ??
 * </pre>
 *
 * @param item ??
 */
public void editButtonClick(MenuItem item, boolean b) {
    //?
    if (b) {
        item.setIcon(R.drawable.oppoinfo_save_btn);
        carInfoAdapter.setEditable(true);
        customerInfoAdapter.setEditable(true);
        bottomBar.setVisible(false);
    } else {
        //????
        if (!project.getPurchaseCarIntention().isHasActiveDrive() && isSubmitNewCar) {
            DialogUtils.hasDriveTestConfirm(getActivity(), null, getString(R.string.prompts),
                    getString(R.string.prompts_drivetest_message),
                    //yes
                    new Runnable() {
                        @Override
                        public void run() {
                            Message msg = new Message();
                            msg.what = 1;
                            handler.sendMessage(msg);
                        }

                    }, new Runnable() {

                        @Override
                        public void run() {
                            editFlag = true;
                            return;
                        }
                    }, -1, -1);
        } else {
            checkMust();
        }

    }
}

From source file:com.nbplus.iotlib.IoTInterface.java

private boolean retryDeviceCommand() {
    Log.d(TAG, ">> proceedDeviceCommand()");
    // try first scenario command
    IoTDeviceScenario scenario = mCurrentRetrieveDevice.getCurrentScenario();
    if (scenario == null) {
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 1;/* w  ww  .  j  ava 2 s .  co m*/
        mHandler.sendMessage(disconnMsg);
        return true;
    }

    Bundle extras = new Bundle();
    IoTHandleData data = new IoTHandleData();
    data.setDeviceId(mCurrentRetrieveDevice.getDeviceId());
    data.setDeviceTypeId(mCurrentRetrieveDevice.getDeviceTypeId());
    data.setCharacteristicUuid(scenario.getCharacteristic());
    data.setServiceUuid(scenario.getService());

    int cmd = -1;
    switch (scenario.getCmd()) {
    case IoTDeviceScenario.CMD_READ:
        cmd = IoTServiceCommand.DEVICE_READ_DATA;
        break;
    case IoTDeviceScenario.CMD_WRITE:
        cmd = IoTServiceCommand.DEVICE_WRITE_DATA;
        if (StringUtils.isEmptyString(scenario.getDataType())) {
            // data type ?  data ?  ?.
            if (StringUtils.isEmptyString(scenario.getData())) {
                // data ? ? .
                Log.w(TAG, "Can't find data type or data");
                mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
                Message disconnMsg = new Message();
                disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
                disconnMsg.arg1 = 1;
                mHandler.sendMessage(disconnMsg);
                return false;
            }

            byte[] setData = DataParser.getHextoBytes(scenario.getData());
            data.setValue(setData);
        } else {
            if (scenario.getDataType().equals("current_time")) {
                byte[] dataByte = DataGenerator.getCurrentTimeData();
                data.setValue(dataByte);
            } else if (scenario.getDataType().startsWith("miscale_")) {
                String dataString = scenario.getData();
                Log.d(TAG, "miscale write data hex string = " + dataString);
                byte[] dataByte = DataParser.getHextoBytes(dataString);
                data.setValue(dataByte);
            } else if (scenario.getDataType().equals("glucose_report_number")) {
                String dataString = scenario.getData();

                byte[] reportNumber = new byte[] { (byte) 0x04, (byte) 0x01 };
                // op, operator, filter type, next seq(2bytes)...
                byte[] reportRecords = new byte[] { (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x00,
                        (byte) 0x01 };

                Log.d(TAG, "glucose_report_number write data hex string = "
                        + DataParser.getHexString(reportNumber));
                data.setValue(reportNumber);
            } else {
                Log.w(TAG, "Unknown data type..");
                mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
                Message disconnMsg = new Message();
                disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
                disconnMsg.arg1 = 1;
                mHandler.sendMessage(disconnMsg);
                return false;
            }
        }
        break;
    case IoTDeviceScenario.CMD_NOTIFY:
        cmd = IoTServiceCommand.DEVICE_SET_NOTIFICATION;
        break;
    default: {
        Log.w(TAG, "Unknown device command... skip this device");
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 1;
        mHandler.sendMessage(disconnMsg);
        return false;
    }
    }

    if (cmd == -1) {
        Log.w(TAG, "Unknown device command... skip this device");
        mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
        Message disconnMsg = new Message();
        disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
        disconnMsg.arg1 = 1;
        mHandler.sendMessage(disconnMsg);
        return false;
    }
    extras.putParcelable(IoTServiceCommand.KEY_DATA, data);
    sendMessageToService(cmd, extras);
    return true;
}

From source file:com.linkbubble.ui.ContentView.java

private void onUrlLongClick(final WebView webView, final String urlAsString, final int type) {
    Resources resources = getResources();

    final ArrayList<String> longClickSelections = new ArrayList<String>();

    final String shareLabel = resources.getString(R.string.action_share);
    longClickSelections.add(shareLabel);

    String defaultBrowserLabel = Settings.get().getDefaultBrowserLabel();

    final String leftConsumeBubbleLabel = Settings.get().getConsumeBubbleLabel(BubbleAction.ConsumeLeft);
    if (leftConsumeBubbleLabel != null) {
        if (defaultBrowserLabel == null || defaultBrowserLabel.equals(leftConsumeBubbleLabel) == false) {
            longClickSelections.add(leftConsumeBubbleLabel);
        }/*from   ww w . j  a  va 2s  .co m*/
    }

    final String rightConsumeBubbleLabel = Settings.get().getConsumeBubbleLabel(BubbleAction.ConsumeRight);
    if (rightConsumeBubbleLabel != null) {
        if (defaultBrowserLabel == null || defaultBrowserLabel.equals(rightConsumeBubbleLabel) == false) {
            longClickSelections.add(rightConsumeBubbleLabel);
        }
    }

    // Long pressing for a link doesn't work reliably, re #279
    //final String copyLinkLabel = resources.getString(R.string.action_copy_to_clipboard);
    //longClickSelections.add(copyLinkLabel);

    Collections.sort(longClickSelections);

    final String openLinkInNewBubbleLabel = resources.getString(R.string.action_open_link_in_new_bubble);
    final String openImageInNewBubbleLabel = resources.getString(R.string.action_open_image_in_new_bubble);
    if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        longClickSelections.add(0, openImageInNewBubbleLabel);
    }
    if (type == WebView.HitTestResult.SRC_ANCHOR_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        longClickSelections.add(0, openLinkInNewBubbleLabel);
    }

    final String openInBrowserLabel = defaultBrowserLabel != null
            ? String.format(resources.getString(R.string.action_open_in_browser), defaultBrowserLabel)
            : null;
    if (openInBrowserLabel != null) {
        longClickSelections.add(1, openInBrowserLabel);
    }

    final String saveImageLabel = resources.getString(R.string.action_save_image);
    if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
        longClickSelections.add(saveImageLabel);
    }

    ListView listView = new ListView(getContext());
    listView.setAdapter(new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,
            longClickSelections.toArray(new String[0])));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CrashTracking.log("ContentView listView.setOnItemClickListener");
            String string = longClickSelections.get(position);
            if (string.equals(openLinkInNewBubbleLabel)
                    && type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
                Message msg = new Message();
                msg.setTarget(new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        Bundle b = msg.getData();
                        if (b != null && b.getString("url") != null) {
                            MainController.get().openUrl(b.getString("url"), System.currentTimeMillis(), false,
                                    Analytics.OPENED_URL_FROM_NEW_TAB);
                        }
                    }
                });
                webView.requestFocusNodeHref(msg);
            }
            if (string.equals(openLinkInNewBubbleLabel) || string.equals(openImageInNewBubbleLabel)) {
                MainController controller = MainController.get();
                if (null != controller) {
                    controller.openUrl(urlAsString, System.currentTimeMillis(), false,
                            Analytics.OPENED_URL_FROM_NEW_TAB);
                } else {
                    MainApplication.openLink(getContext(), urlAsString, Analytics.OPENED_URL_FROM_NEW_TAB);
                }
            } else if (openInBrowserLabel != null && string.equals(openInBrowserLabel)) {
                openInBrowser(urlAsString);
            } else if (string.equals(shareLabel)) {
                showSelectShareMethod(urlAsString, false);
            } else if (string.equals(saveImageLabel)) {
                saveImage(urlAsString);
            } else if (leftConsumeBubbleLabel != null && string.equals(leftConsumeBubbleLabel)) {
                MainApplication.handleBubbleAction(getContext(), BubbleAction.ConsumeLeft, urlAsString, -1);
            } else if (rightConsumeBubbleLabel != null && string.equals(rightConsumeBubbleLabel)) {
                MainApplication.handleBubbleAction(getContext(), BubbleAction.ConsumeRight, urlAsString, -1);
                //} else if (string.equals(copyLinkLabel)) {
                //    MainApplication.copyLinkToClipboard(getContext(), urlAsString, R.string.link_copied_to_clipboard);
            }

            if (mLongPressAlertDialog != null) {
                mLongPressAlertDialog.dismiss();
            }
        }
    });
    listView.setBackgroundColor(Settings.get().getThemedContentViewColor());

    mLongPressAlertDialog = new AlertDialog.Builder(getContext()).create();
    mLongPressAlertDialog.setView(listView);
    mLongPressAlertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    mLongPressAlertDialog.show();
}

From source file:de.tudresden.inf.rn.mobilis.mxa.XMPPRemoteService.java

/**
 * Forwards the MSG_RECONNECT to the XMPPRemoteService.
 */// w  ww . ja v  a 2 s.c  o m
protected void reconnect() {
    Message msg = new Message();
    msg.what = ConstMXA.MSG_RECONNECT;
    xmppWriteWorker.mHandler.sendMessage(msg);
}

From source file:de.tudresden.inf.rn.mobilis.mxa.XMPPRemoteService.java

/**
 * Forwards the MSG_CONNECT to the XMPPRemoteService.
 *//*from  w  ww  .j  av a 2 s.  c  o m*/
protected void connect() {
    Message msg = new Message();
    msg.what = ConstMXA.MSG_CONNECT;
    xmppWriteWorker.mHandler.sendMessage(msg);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void registerIntentReceivers() {
    boolean useNotifReceiver = PersonaAlmostNexusSettingsHelper.getNotifReceiver(this);
    if (useNotifReceiver && mCounterReceiver == null) {
        mCounterReceiver = new PersonaCounterReceiver(this);
        mCounterReceiver.setCounterListener(new PersonaCounterReceiver.OnCounterChangedListener() {
            public void onTrigger(String pname, int counter, int color) {
                PersonaLog.d("personalauncher", "updateCountersForPackage called from registerIntentReceivers");
                //updateCountersForPackage(pname, counter, color, 0);
                Bundle b = new Bundle();

                b.putString("package", "com.cognizant.trumobi");
                b.putInt("counter", counter);
                b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
                b.putInt("updateCountFor", 0);
                Message m = new Message();
                m.setData(b);/*from w  ww  . j  ava 2  s.  c  o m*/
                UiHandler.sendMessage(m);
            }
        });
        registerReceiver(mCounterReceiver, mCounterReceiver.getFilter());
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    registerReceiver(mApplicationsReceiver, filter);
    filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    registerReceiver(mCloseSystemDialogsReceiver, filter);
    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    registerReceiver(mApplicationsReceiver, filter);

}

From source file:com.nbplus.iotlib.IoTInterface.java

private void handleXiaomiScale(int msgWhat, IoTHandleData data) {
    if (data == null) {
        return;//w w w.j ava2 s.c om
    }
    //   ?  ?.
    // 0. set notify 2a2f
    // 1. write 2a2f - for notify saved record number
    // 2. write result
    // 3. notify 2a2f - saved recoreds number count (value? 1byte ? 0x01)
    // 4. (if (number > 0)) write 2a2f - for notify saved records
    // 5.                   write result
    // 6.                   notify saved record (value? 1byte ? 0x62)
    // 7.                   notify end of record (value? 1byte ? 0x03)
    // 8.                   write 2a2f - delete saved records
    byte[] values = data.getValue();
    if (values == null) {
        Log.w(TAG, "handleXiaomiScale() value is not found..");
    }
    switch (msgWhat) {
    case IoTServiceCommand.DEVICE_SET_NOTIFICATION_RESULT: {
        proceedDeviceCommand();
        break;
    }
    case IoTServiceCommand.DEVICE_WRITE_DATA_RESULT: {
        switch (values[0] & 0xff) {
        case 0x01: // get number success.. data will be notify
            Log.d(TAG, "xiaomi sclae : get number success.. data will be notified..");
            break;
        case 0x02:
            Log.d(TAG, "xiaomi sclae : get data success.. data will be notified..");
            break;
        case 0x03:
            Log.d(TAG, "xiaomi sclae : stop saved notification data .. success");
            proceedDeviceCommand(); // delete saved record.
            break;
        case 0x04:
            Log.d(TAG, "xiaomi sclae : remove all saved data success... ");
            Log.d(TAG, "xiaomi scale : disconnect.... ");
            mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
            Message disconnMsg = new Message();
            disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
            disconnMsg.arg1 = 1;
            mHandler.sendMessage(disconnMsg);
            break;
        }
        break;
    }
    case IoTServiceCommand.DEVICE_NOTIFICATION_DATA: {
        switch (values[0] & 0xFF) {
        case 0x01: // get saved number
            int savedNumber = DataParser.getUint16(Arrays.copyOfRange(values, 1, 3));
            Log.d(TAG, ">> xiaomi sclae : Saved Data Num is " + savedNumber);
            if (savedNumber > 0) {
                proceedDeviceCommand(); // next command - notify record.
            } else {
                // disconnect ...
                Log.d(TAG, "xiaomi scale : disconnect.... ");
                mHandler.removeMessages(HANDLER_WAIT_FOR_NOTIFY_DATA);
                Message disconnMsg = new Message();
                disconnMsg.what = HANDLER_WAIT_FOR_NOTIFY_DATA;
                disconnMsg.arg1 = 1;
                mHandler.sendMessage(disconnMsg);
            }
            break;
        //                        case 0x02 :     // do not reached
        //                            break;
        case 0x03: // end of saved data ??
            Log.d(TAG, ">> xiaomi sclae : End of saved data flag received...");
            proceedDeviceCommand(); // stop notifications.
            break;
        case 0x62: // saved data
            // send to server
            String address = data.getDeviceId();
            String characUuid = data.getCharacteristicUuid();
            ArrayList<WeightMeasurement> measurements = WeightMeasurement.parseWeightMeasurement(address,
                    characUuid, values);

            for (WeightMeasurement measurement : measurements) {
                if (measurement != null) {
                    IoTCollectedData.IoTData iotData = new IoTCollectedData.IoTData();
                    iotData.setIotDeviceId(address);
                    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
                    Calendar calendar = measurement.getTimestamp();
                    iotData.setDate(df.format(calendar.getTime()));
                    iotData.setValue(Double.toString(measurement.getWeight()));

                    Log.d(TAG, "xiaomi sclae : Weight = " + iotData.getValue() + ""
                            + measurement.getMeasurementUnitString() + ", timestamp = " + iotData.getDate());
                    mCollectedData.addIoTData(iotData);
                }
            }
            break;
        }
        break;
    }
    }

}

From source file:com.cognizant.trumobi.PersonaLauncher.java

public int getMissedCallCount() {
    String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.CACHED_NAME };
    missedCount = 0;/*from  w  w  w .j  a va 2s. c o m*/
    String where = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.NEW + "= 1 ";
    // String where =
    // CallLog.Calls.TYPE+"="+CallLog.Calls.MISSED_TYPE+" AND "+CallLog.Calls.IS_READ+"= 0 ";
    Cursor c = Email.getAppContext().getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, where,
            null, null);
    if (c != null && c.getCount() > 0 && c.moveToFirst()) {
        try {
            missedCount = c.getCount();
            DialerLog.d("MissedCall Count", "Call Count is " + missedCount);
            // new
            // com.TruBoxSDK.SharedPreferences(CognizantEmail.getAppContext()).edit().putInt("MissedCallCounts",
            // c.getCount()).commit();
        } catch (Exception e) {
            DialerLog.d("MissedCall Count", "Call Count exception" + e.getMessage());
        }

    } else {
        DialerLog.d("MissedCall Count", "Call Count is zero");
        missedCount = 0;
        // new
        // com.TruBoxSDK.SharedPreferences(CognizantEmail.getAppContext()).edit().putInt("MissedCallCounts",
        // 0).commit();

    }
    Bundle b = new Bundle();

    b.putString("package", "com.cognizant.trumobi");
    b.putInt("counter", missedCount);
    b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
    b.putInt("updateCountFor", 1);
    Message m = new Message();
    m.setData(b);
    UiHandler.sendMessage(m);

    return missedCount;

}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*************************************
 * // w  ww .j  av a2s.c  o  m
 * playPauseClickListenerHelper
 * 
 *************************************/
public void playPauseClickListenerHelper() {
    try {
        // TODO: UI related updates----
        //   these are just mockups
        if (playerServiceIface.isPlaying()) {
            playerServiceIface.pause();
            //            AlphaAnimation albumPlayingFadeOut = new AlphaAnimation((float)1.0, (float)0.66);
            //            albumPlayingFadeOut.setFillAfter(true);
            //            albumPlayingFadeOut.setDuration(200);
            //            currentAlbumPlayingLayout.startAnimation(albumPlayingFadeOut);
            //playPauseImage.setImageResource(android.R.drawable.ic_media_play);
            TransitionDrawable playPauseTDrawable = (TransitionDrawable) playPauseImage.getDrawable();
            playPauseTDrawable.setCrossFadeEnabled(true);
            playPauseTDrawable.reverseTransition(300);
            playPauseTDrawable.invalidateSelf();
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 50);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 100);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 150);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 200);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 250);
            //            TransitionDrawable playPauseBgTDrawable = (TransitionDrawable) playPauseImage.getBackground();
            //            playPauseBgTDrawable.startTransition(500);
            //            playPauseBgTDrawable.invalidateSelf();
            //            playPauseOverlayHandler.sendEmptyMessageDelayed(0, 500);
            //            currentAlbumPlayingLayout.invalidate();
            //TODO: reverse transition with an handler
            //            
            //            playPauseImageOverlay.setVisibility(View.VISIBLE);
            //            AlphaAnimation playPauseImageOverlayFadeIn = new AlphaAnimation(0.0f, 1.0f);
            //            playPauseImageOverlayFadeIn.setFillAfter(true);
            //            playPauseImageOverlayFadeIn.setDuration(200);
            //            playPauseImageOverlayFadeIn.setAnimationListener(playPauseOverlayFadeInAnimationListener);
            //            playPauseImageOverlay.startAnimation(playPauseImageOverlayFadeIn);
            //currentAlbumPlayingLayout.setBackgroundColor(Color.argb(128, 255, 255, 255));
            if (songProgressTimer != null)
                songProgressTimer.cancel();
        } else {
            //playerServiceIface.resume(); - use a delayed timer to not interfere with the button animations
            Message msg = new Message();
            msg.what = 0;
            playerServiceResumeHandler.sendMessageDelayed(new Message(), 900);
            //            AlphaAnimation albumPlayingFadeIn = new AlphaAnimation((float)0.66, (float)1.0);
            //            albumPlayingFadeIn.setFillAfter(true);
            //            albumPlayingFadeIn.setDuration(200);
            //            currentAlbumPlayingLayout.startAnimation(albumPlayingFadeIn);
            //playPauseImage.setImageResource(android.R.drawable.ic_media_pause);
            TransitionDrawable playPauseTDrawable = (TransitionDrawable) playPauseImage.getDrawable();
            playPauseTDrawable.setCrossFadeEnabled(true);
            playPauseTDrawable.startTransition(500);
            playPauseTDrawable.invalidateSelf();
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 150);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 300);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 450);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 600);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 750);
            //            TransitionDrawable playPauseBgTDrawable = (TransitionDrawable) playPauseImage.getBackground();
            //            playPauseBgTDrawable.startTransition(500);
            //            playPauseBgTDrawable.invalidateSelf();
            //            playPauseOverlayHandler.sendEmptyMessageDelayed(0, 500);
            //            currentAlbumPlayingLayout.invalidate();
            //TODO: reverse transition with an handler
            //            
            //            playPauseImageOverlay.setVisibility(View.VISIBLE);
            //            AlphaAnimation playPauseImageOverlayFadeIn = new AlphaAnimation(0.0f, 1.0f);
            //            playPauseImageOverlayFadeIn.setFillAfter(true);
            //            playPauseImageOverlayFadeIn.setDuration(250);
            //            playPauseImageOverlayFadeIn.setAnimationListener(playPauseOverlayFadeInAnimationListener);
            //            playPauseImageOverlay.startAnimation(playPauseImageOverlayFadeIn);
            //currentAlbumPlayingLayout.setBackgroundColor(Color.argb(0, 255, 255, 255));
            //Log.i("RES", "1");
            //            songProgressTimer = new Timer();
            //            Log.i("RES", "7");
            //            songProgressTimer.scheduleAtFixedRate(new SongProgressTimerTask(), 100, 1000);
            //            Log.i("RES", "8");
            updateSongTextUI(); // starts the progress timer
            //triggerSongProgress();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}