List of usage examples for android.view KeyEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view KeyEvent ACTION_DOWN.
Click Source Link
From source file:mgks.os.webview.MainActivity.java
@Override public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (asw_view.canGoBack()) { asw_view.goBack();//from ww w.ja v a 2 s. com } else { finish(); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.grass.caishi.cc.activity.SettingUserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { // ?//from w w w . ja v a 2 s .c o m if (isRefresh) { Intent it = new Intent(); it.putExtra("info", userInfo); setResult(888, it); finish(); } } return super.onKeyDown(keyCode, event); }
From source file:com.undatech.opaque.RemoteCanvasActivity.java
@Override public boolean onKey(View v, int keyCode, KeyEvent evt) { boolean consumed = false; if (keyCode == KeyEvent.KEYCODE_MENU) { if (evt.getAction() == KeyEvent.ACTION_DOWN) return super.onKeyDown(keyCode, evt); else/* w w w . j a v a 2 s. c om*/ return super.onKeyUp(keyCode, evt); } try { if (evt.getAction() == KeyEvent.ACTION_DOWN || evt.getAction() == KeyEvent.ACTION_MULTIPLE) { consumed = inputHandler.onKeyDown(keyCode, evt); } else if (evt.getAction() == KeyEvent.ACTION_UP) { consumed = inputHandler.onKeyUp(keyCode, evt); } resetOnScreenKeys(keyCode); } catch (NullPointerException e) { } return consumed; }
From source file:com.supremainc.biostar2.main.HomeActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MENU: if (event.getAction() == KeyEvent.ACTION_DOWN) { mLayout.onDrawMenu();//from w w w . j a v a 2 s. c o m } return true; } return super.dispatchKeyEvent(event); }
From source file:me.spadival.podmode.PodModeService.java
public void run() { podCommand pCommand = null;//from ww w . ja va 2 s.c om podResponse pResponse = null; byte[] respBytes = null; long eventtime; Intent downIntent = null; KeyEvent downEvent = null; Intent upIntent = null; KeyEvent upEvent = null; // serialWrite(new byte[] { (byte) 0xFF, 0x55, 0x02, 0x00, 0x00, // (byte) 0xFE }); while (mPodRunning) { pCommand = readCommand(); if (pCommand == null) continue; if (pCommand.mode == 0x03) mPodStatus = podStat.DISPLAYREMOTE; if (mAccessoryName != null && (mPodStatus == podStat.SIMPLEREMOTE || mPodStatus == podStat.DISPLAYREMOTE || mPodStatus == podStat.ADVANCEDREMOTE || mPodStatus == podStat.ADVANCEDHACK) && mHTTPsend) { mHTTPsend = false; mHttpThread.start(); } if (mLaunchFirstTime && (pCommand.mode == 02 || (pCommand.mode == 04 && !mAdvancedRemoteApp.equals(PACKAGENAME)))) { String launchApp = null; if (pCommand.mode == 02) { mBanner = getString(R.string.simple_remote); launchApp = mSimpleRemoteApp; } if (pCommand.mode == 04) { mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; mBanner = getString(R.string.advanced_remote); launchApp = mAdvancedRemoteApp; } if (launchApp != null) { PackageManager pm = getPackageManager(); Intent LaunchIntent = pm.getLaunchIntentForPackage(launchApp); startActivity(LaunchIntent); ResolveInfo info = pm.resolveActivity(LaunchIntent, PackageManager.MATCH_DEFAULT_ONLY); mSongTitle = (String) info.loadLabel(pm); mElapsedTime = 0; if (pCommand.mode == 04) mRetriever.changeApp(false, mSongTitle, getString(R.string.advanced_remote), 999); mAlbumArtUri = "android.resource://" + launchApp + "/" + String.valueOf(info.getIconResource()); setUpAsForeground(mBanner); localBroadcast(false); } mLaunchFirstTime = false; } if (pCommand.mode == 02) { mPodStatus = podStat.SIMPLEREMOTE; switch (pCommand.command) { case RemoteRelease: respBytes = new byte[] { (byte) 0x01, 0x00, 0x00 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case RemotePlayPause: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteJustPlay: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteJustPause: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteSkipFwd: eventtime = SystemClock.uptimeMillis(); if (downEvent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_NEXT || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { if ((eventtime - downEvent.getEventTime()) > 1000) { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } } else { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); } break; case RemoteSkipRwd: eventtime = SystemClock.uptimeMillis(); if (downEvent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PREVIOUS || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_REWIND) { if ((eventtime - downEvent.getEventTime()) > 1000) { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_REWIND, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_REWIND, 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } } else { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); } break; case RemoteStop: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_STOP, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteButtonRel: eventtime = SystemClock.uptimeMillis(); if (downIntent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_NEXT || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PREVIOUS) sendOrderedBroadcast(downIntent, null); if (downEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_FAST_FORWARD && downEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_REWIND) { upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(downEvent.getDownTime(), eventtime, KeyEvent.ACTION_UP, downEvent.getKeyCode(), 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } downIntent = null; downEvent = null; upIntent = null; upEvent = null; break; default: break; } } else { switch (pCommand.command) { case AppCmd: byte[] appNameBytes = new byte[pCommand.params.length - 3]; System.arraycopy(pCommand.params, 2, appNameBytes, 0, appNameBytes.length); String appName = ""; try { appName = new String(appNameBytes, "UTF8"); Log.d("PodMode", "AppCmd " + appName); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } break; case AppAck: break; case GetUpdateFlag: respBytes = new byte[] { 0x00, 0x0A, mUpdateFlag }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetUpdateFlag: mUpdateFlag = pCommand.params[0]; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchToMainPlaylist: if (mPodStatus == podStat.ADVANCEDHACK) { mNowPlaying = 0; mPrevPlaying = 0; } else mNowPlaying = 0; mRetriever.switchToMainPlaylist(); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchToItem: int itemNo = 0; itemNo = pCommand.params[4] & 0xFF; itemNo += ((pCommand.params[3] & 0xFF) << 8); itemNo += ((pCommand.params[2] & 0xFF) << 16); itemNo += ((pCommand.params[1] & 0xFF) << 24); if ((mPodStatus == podStat.ADVANCEDHACK && mNotifyHack)) { mNotifyHack = false; } else { if (mRetriever.switchToItem((int) pCommand.params[0], itemNo)) { if (pCommand.params[0] == (byte) 0x05) { mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); } } } respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetCountForType: respBytes = new byte[] { 0x00, 0x19, 0x00, 0x00, 0x00, 0x00 }; int num = mRetriever.getCountForType((int) pCommand.params[0]); respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetItemNames: int startPos = 0; int count = 0; startPos = pCommand.params[4] & 0xFF; startPos += ((pCommand.params[3] & 0xFF) << 8); startPos += ((pCommand.params[2] & 0xFF) << 16); startPos += ((pCommand.params[1] & 0xFF) << 24); count = pCommand.params[8] & 0xFF; count += ((pCommand.params[7] & 0xFF) << 8); count += ((pCommand.params[6] & 0xFF) << 16); count += ((pCommand.params[5] & 0xFF) << 24); String[] itemNames = mRetriever.GetItemNames((int) pCommand.params[0], startPos, count); if (itemNames != null) { for (int i = 0; i < itemNames.length; i++) { byte[] part1 = { (byte) 0x00, (byte) 0x1B, (byte) (startPos >>> 24), (byte) (startPos >>> 16), (byte) (startPos >>> 8), (byte) startPos }; startPos++; respBytes = new String(new String(part1) + itemNames[i] + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } } break; case GetTimeStatus: respBytes = new byte[] { 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; if (mState != State.Preparing && mState != State.Retrieving) { int trackLen = 0; if (mPlayer != null) trackLen = mPlayer.getDuration(); respBytes[2] = (byte) (trackLen >>> 24); respBytes[3] = (byte) (trackLen >>> 16); respBytes[4] = (byte) (trackLen >>> 8); respBytes[5] = (byte) trackLen; int elapsedTime = 0; if (mPlayer != null) elapsedTime = mPlayer.getCurrentPosition(); respBytes[6] = (byte) (elapsedTime >>> 24); respBytes[7] = (byte) (elapsedTime >>> 16); respBytes[8] = (byte) (elapsedTime >>> 8); respBytes[9] = (byte) elapsedTime; switch (mState) { case Stopped: respBytes[10] = (byte) 0x00; break; case Playing: respBytes[10] = (byte) 0x01; break; case Paused: respBytes[10] = (byte) 0x02; break; case Preparing: respBytes[10] = (byte) 0x01; break; case Retrieving: respBytes[10] = (byte) 0x01; break; } } pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPlaylistPos: respBytes = new byte[] { 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00 }; respBytes[2] = (byte) ((mNowPlaying) >>> 24); respBytes[3] = (byte) ((mNowPlaying) >>> 16); respBytes[4] = (byte) ((mNowPlaying) >>> 8); respBytes[5] = (byte) mNowPlaying; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongTitle: byte[] part1 = new byte[] { 0x00, 0x21 }; int index; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).title + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongArtist: part1 = new byte[] { 0x00, 0x23 }; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).artist + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongAlbum: part1 = new byte[] { 0x00, 0x25 }; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).album + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case PollingMode: respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); mPollSpeed = (byte) pCommand.params[0]; if (pCommand.params[0] == (byte) 0x01 && mUpdateFlag != (byte) 0x01) { mUpdateFlag = pCommand.params[0]; if (mMediaChangeTimer == null) mMediaChangeTimer = new Timer(); mMediaChangeTimer.scheduleAtFixedRate(mMediaChangeTask, 0, 500); } else if (pCommand.params[0] == (byte) 0x00 && mUpdateFlag != (byte) 0x00) { mUpdateFlag = pCommand.params[0]; if (mMediaChangeTimer != null) mMediaChangeTimer.cancel(); } break; case ExecPlaylist: itemNo = pCommand.params[3] & 0xFF; itemNo += ((pCommand.params[2] & 0xFF) << 8); itemNo += ((pCommand.params[1] & 0xFF) << 16); itemNo += ((pCommand.params[0] & 0xFF) << 24); if (itemNo == -1) itemNo = 0; mRetriever.ExecPlaylist(); if (mPodShuffleMode == modeStat.Songs) mRetriever.shuffleTracks(); mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case PlaybackControl: switch (pCommand.params[0]) { case 0x01: // processStopRequest(); processTogglePlaybackRequest(); break; case 0x02: processStopRequest(); break; case 0x03: processPauseRequest(); processSkipRequest(); break; case 0x04: processPauseRequest(); processSkipRwdRequest(); break; case 0x05: // processSkipRequest(); break; case 0x06: // processRewindRequest(); break; case 0x07: // TODO Add Stop FF/RR function break; } respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPlayListSongNum: respBytes = new byte[] { 0x00, 0x36, 0x00, 0x00, 0x00, 0x00 }; num = mRetriever.getCount(); respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case JumpToSong: itemNo = pCommand.params[3] & 0xFF; itemNo += ((pCommand.params[2] & 0xFF) << 8); itemNo += ((pCommand.params[1] & 0xFF) << 16); itemNo += ((pCommand.params[0] & 0xFF) << 24); mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case FrankPlaylist: respBytes = new byte[] { 0x00, 0x4F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }; num = mRetriever.getPlaylistNum(); if (num != -1) { respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); } pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case StartID: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodProtocols: // start respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); if (pCommand.rawBytes[13] == (byte) 0x00 && pCommand.rawBytes[14] == (byte) 0x00 && pCommand.rawBytes[15] == (byte) 0x00 && pCommand.rawBytes[16] == (byte) 0x00) { // respBytes = new byte[] { 0x00 }; // pResponse = new podResponse(pCommand, respBytes); // serialWrite(pResponse.getBytes()); } else { respBytes = new byte[] { 0x14 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } break; case DeviceAuthInfo: if (pCommand.length == 4) { respBytes = new byte[] { 0x16 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x17, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } else { if (pCommand.rawBytes[7] != pCommand.rawBytes[8]) { respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } else { respBytes = new byte[] { 0x16 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x17, 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } } break; case DeviceAuthSig: respBytes = new byte[] { 0x19 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodOptions: // start if (pCommand.rawBytes[5] == 0x00) respBytes = new byte[] { 0x4C }; else respBytes = new byte[] { (byte) 0x02, 0x04 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodOption: // start respBytes = new byte[] { 0x25 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetIdTokens: respBytes = new byte[] { 0x3A }; pResponse = new podResponse(pCommand, respBytes); if (mAccessoryName == null) { mAccessoryName = pResponse.accessoryName; mAccessoryMnf = pResponse.accessoryMnf; mAccessoryModel = pResponse.accessoryModel; mHTTPsend = true; } serialWrite(pResponse.getBytes()); break; case EndID: respBytes = new byte[] { 0x3C }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x14 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetProtoVersion: respBytes = new byte[] { 0x0F }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DeviceDetails: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevName: respBytes = new byte[] { 0x00, 0x15, 0x50, 0x6F, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevTypeSize: pResponse = new podResponse(pCommand, DEVTYPESIZE); serialWrite(pResponse.getBytes()); break; case StateInfo: respBytes = new byte[] { 0x0D }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case RemoteNotify: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchRemote: mPodStatus = podStat.SIMPLEREMOTE; break; case ReqAdvRemote: respBytes = new byte[] { 0x04, 0x00 }; if (mPodStatus == podStat.ADVANCEDREMOTE || mPodStatus == podStat.ADVANCEDHACK) respBytes[1] = 0x04; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case StartAdvRemote: mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; respBytes = new byte[] { 0x2 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case EndAdvRemote: mPodStatus = podStat.WAITING; respBytes = new byte[] { 0x2 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSoftVersion: respBytes = new byte[] { 0x0A }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSerialNum: respBytes = new byte[] { 0x0C }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevModel: respBytes = new byte[] { 0x0E }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchAdvanced: mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; break; case SetRepeatMode: if (pCommand.params[0] == (byte) 0x00) mPodRepeatMode = modeStat.Off; else if (pCommand.params[0] == (byte) 0x01) mPodRepeatMode = modeStat.Songs; else mPodRepeatMode = modeStat.Albums; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetRepeatMode: respBytes = new byte[] { 0x00, 0x30, 0x00 }; if (mPodRepeatMode == modeStat.Songs) respBytes[2] = 0x01; if (mPodRepeatMode == modeStat.Albums) respBytes[2] = 0x02; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetShuffleMode: if (pCommand.params[0] == (byte) 0x00) mPodShuffleMode = modeStat.Off; else if (pCommand.params[0] == (byte) 0x01) mPodShuffleMode = modeStat.Songs; else mPodShuffleMode = modeStat.Albums; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetShuffleMode: respBytes = new byte[] { 0x00, 0x2D, 0x00 }; if (mPodShuffleMode == modeStat.Songs) respBytes[2] = 0x01; if (mPodShuffleMode == modeStat.Albums) respBytes[2] = 0x02; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetScreenSize: respBytes = new byte[] { 0x00, 0x34 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; default: break; } } } }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
private boolean configureEmailAutoComplete(boolean autoShowSuggestions) { T.UI();//from w ww. j ava 2s .c o m final boolean getAccountsPermissionWasGranted = mService.isPermitted(Manifest.permission.GET_ACCOUNTS); if (getAccountsPermissionWasGranted) { mAccountManager = new AccountManager(this); mAccounts = mAccountManager.getAccounts(); List<String> emails = new ArrayList<String>(); for (Account account : mAccounts) { if (RegexPatterns.EMAIL.matcher(account.name).matches() && !emails.contains(account.name)) emails.add(account.name); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, emails); mEnterEmailAutoCompleteTextView.setAdapter(adapter); mEnterEmailAutoCompleteTextView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { requestPin(); } }); mEnterEmailAutoCompleteTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { mEnterEmailAutoCompleteTextView.setThreshold(1); return false; } }); if (autoShowSuggestions) mEnterEmailAutoCompleteTextView.showDropDown(); } mEnterEmailAutoCompleteTextView.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_GO || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { requestPin(); return true; } return false; } }); return getAccountsPermissionWasGranted; }
From source file:github.madmarty.madsonic.util.Util.java
private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing) { // Use the same text for the ticker and the expanded notification String title = song.getTitle(); String arist = song.getArtist(); String album = song.getAlbum(); // Set the album art. try {//from w ww. j a v a 2 s.c o m int size = context.getResources().getDrawable(R.drawable.unknown_album).getIntrinsicHeight(); Bitmap bitmap = FileUtil.getAlbumArtBitmap(context, song, size); if (bitmap == null) { // set default album art rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } else { rv.setImageViewBitmap(R.id.notification_image, bitmap); } } catch (Exception x) { LOG.warn("Failed to get notification cover art", x); rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } rv.setImageViewResource(R.id.control_starred, song.isStarred() ? android.R.drawable.btn_star_big_on : android.R.drawable.btn_star_big_off); // set the text for the notifications rv.setTextViewText(R.id.notification_title, title); rv.setTextViewText(R.id.notification_artist, arist); rv.setTextViewText(R.id.notification_album, album); Pair<Integer, Integer> colors = getNotificationTextColors(context); if (colors.getFirst() != null) { rv.setTextColor(R.id.notification_title, colors.getFirst()); } if (colors.getSecond() != null) { rv.setTextColor(R.id.notification_artist, colors.getSecond()); } if (!playing) { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_play); rv.setImageViewResource(R.id.control_previous, R.drawable.notification_stop); } // Create actions for media buttons PendingIntent pendingIntent; if (playing) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class)); prevIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS)); pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0); rv.setOnClickPendingIntent(R.id.control_previous, pendingIntent); } else { Intent prevIntent = new Intent("KEYCODE_MEDIA_STOP"); prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class)); prevIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_STOP)); pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0); rv.setOnClickPendingIntent(R.id.control_previous, pendingIntent); } Intent starredIntent = new Intent("KEYCODE_MEDIA_STARRED"); starredIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class)); starredIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_STAR)); pendingIntent = PendingIntent.getService(context, 0, starredIntent, 0); rv.setOnClickPendingIntent(R.id.control_starred, pendingIntent); Intent pauseIntent = new Intent("KEYCODE_MEDIA_PLAY_PAUSE"); pauseIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class)); pauseIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)); pendingIntent = PendingIntent.getService(context, 0, pauseIntent, 0); rv.setOnClickPendingIntent(R.id.control_pause, pendingIntent); Intent nextIntent = new Intent("KEYCODE_MEDIA_NEXT"); nextIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class)); nextIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT)); pendingIntent = PendingIntent.getService(context, 0, nextIntent, 0); rv.setOnClickPendingIntent(R.id.control_next, pendingIntent); }
From source file:org.awesomeapp.messenger.ui.ConversationView.java
protected void initViews() { // mStatusIcon = (ImageView) mActivity.findViewById(R.id.statusIcon); // mDeliveryIcon = (ImageView) mActivity.findViewById(R.id.deliveryIcon); // mTitle = (TextView) mActivity.findViewById(R.id.title); mHistory = (RecyclerView) mActivity.findViewById(R.id.history); LinearLayoutManager llm = new LinearLayoutManager(mHistory.getContext()); llm.setStackFromEnd(true);/*from w w w . ja v a2s .co m*/ mHistory.setLayoutManager(llm); mComposeMessage = (EditText) mActivity.findViewById(R.id.composeMessage); mSendButton = (ImageButton) mActivity.findViewById(R.id.btnSend); mMicButton = (ImageButton) mActivity.findViewById(R.id.btnMic); mButtonTalk = (TextView) mActivity.findViewById(R.id.buttonHoldToTalk); mButtonDeleteVoice = (ImageView) mActivity.findViewById(R.id.btnDeleteVoice); mViewDeleteVoice = mActivity.findViewById(R.id.viewDeleteVoice); mButtonDeleteVoice.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) { int resolvedColor = mHistory.getResources().getColor(android.R.color.holo_red_light); mButtonDeleteVoice.setBackgroundColor(resolvedColor); } return false; } }); mButtonAttach = (ImageButton) mActivity.findViewById(R.id.btnAttach); mViewAttach = mActivity.findViewById(R.id.attachPanel); mStatusWarningView = mActivity.findViewById(R.id.warning); mWarningText = (TextView) mActivity.findViewById(R.id.warningText); mButtonAttach.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleAttachMenu(); } }); mActivity.findViewById(R.id.btnAttachPicture).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActivity.startImagePicker(); } }); mActivity.findViewById(R.id.btnTakePicture).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActivity.startPhotoTaker(); } }); /** mActivity.findViewById(R.id.btnAttachFile).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActivity.startFilePicker(); } });*/ mActivity.findViewById(R.id.btnAttachSticker).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleAttachMenu(); showStickers(); } }); mMicButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //this is the tap to change to hold to talk mode if (mMicButton.getVisibility() == View.VISIBLE) { mComposeMessage.setVisibility(View.GONE); mMicButton.setVisibility(View.GONE); // Check if no view has focus: View view = mActivity.getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } mSendButton.setImageResource(R.drawable.ic_keyboard_black_36dp); mSendButton.setVisibility(View.VISIBLE); mButtonTalk.setVisibility(View.VISIBLE); } } }); final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { public void onLongPress(MotionEvent e) { //this is for recording audio directly from one press mActivity.startAudioRecording(); } @Override public boolean onSingleTapUp(MotionEvent e) { if (mActivity.isAudioRecording()) { boolean send = true;//inViewInBounds(mMicButton, (int) motionEvent.getX(), (int) motionEvent.getY()); mActivity.stopAudioRecording(send); } return super.onSingleTapUp(e); } }); mMicButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { return gestureDetector.onTouchEvent(motionEvent); } }); mButtonTalk.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View btnTalk, MotionEvent theMotion) { switch (theMotion.getAction()) { case MotionEvent.ACTION_DOWN: mActivity.startAudioRecording(); mButtonTalk.setText(mActivity.getString(R.string.recording_release)); mViewDeleteVoice.setVisibility(View.VISIBLE); break; case MotionEvent.ACTION_MOVE: boolean inBounds = inViewInBounds(btnTalk, (int) theMotion.getX(), (int) theMotion.getY()); if (!inBounds) mButtonTalk.setText(mActivity.getString(R.string.recording_delete)); else { mButtonTalk.setText(mActivity.getString(R.string.recording_release)); mViewDeleteVoice.setVisibility(View.VISIBLE); } break; case MotionEvent.ACTION_UP: mButtonTalk.setText(mActivity.getString(R.string.push_to_talk)); boolean send = inViewInBounds(btnTalk, (int) theMotion.getX(), (int) theMotion.getY()); mActivity.stopAudioRecording(send); mViewDeleteVoice.setVisibility(View.GONE); break; } return true; } }); /** mHistory.setOnItemLongClickListener(new OnItemLongClickListener () { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (arg1 instanceof MessageView) { String textToCopy = ((MessageView)arg1).getLastMessage(); int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(textToCopy); // } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("chat",textToCopy); clipboard.setPrimaryClip(clip); // } Toast.makeText(mActivity, mContext.getString(R.string.toast_chat_copied_to_clipboard), Toast.LENGTH_SHORT).show(); return true; } return false; } });**/ mWarningText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showVerifyDialog(); } }); mComposeMessage.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { sendTypingStatus(true); return false; } }); mComposeMessage.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { sendTypingStatus(hasFocus); } }); mComposeMessage.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: sendMessage(); return true; case KeyEvent.KEYCODE_ENTER: if (event.isAltPressed()) { mComposeMessage.append("\n"); return true; } } } return false; } }); mComposeMessage.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null) { if (event.isAltPressed()) { return false; } } InputMethodManager imm = (InputMethodManager) mContext .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null && imm.isActive(v)) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } sendMessage(); return true; } }); // TODO: this is a hack to implement BUG #1611278, when dispatchKeyEvent() works with // the soft keyboard, we should remove this hack. mComposeMessage.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int before, int after) { } public void onTextChanged(CharSequence s, int start, int before, int after) { } public void afterTextChanged(Editable s) { doWordSearch(); userActionDetected(); } }); mSendButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (mComposeMessage.getVisibility() == View.VISIBLE) sendMessage(); else { mSendButton.setImageResource(R.drawable.ic_send_holo_light); if (mLastSessionStatus == SessionStatus.ENCRYPTED) mSendButton.setImageResource(R.drawable.ic_send_secure); mSendButton.setVisibility(View.GONE); mButtonTalk.setVisibility(View.GONE); mComposeMessage.setVisibility(View.VISIBLE); mMicButton.setVisibility(View.VISIBLE); } } }); mMessageAdapter = new ConversationRecyclerViewAdapter(mActivity, null); mHistory.setAdapter(mMessageAdapter); }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
private void configureMailView() { T.UI();// w w w. ja v a2 s. c om final AutoCompleteTextView emailText = (AutoCompleteTextView) findViewById(R.id.add_via_email_text_field); emailText.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, new ArrayList<String>())); emailText.setThreshold(1); if (mService.isPermitted(Manifest.permission.READ_CONTACTS)) { mService.postAtFrontOfBIZZHandler(new SafeRunnable() { @SuppressWarnings("unchecked") @Override protected void safeRun() throws Exception { L.d("AddFriendsActivity getEmailAddresses"); List<String> emailList = ContactListHelper.getEmailAddresses(AddFriendsActivity.this); ArrayAdapter<String> a = (ArrayAdapter<String>) emailText.getAdapter(); for (int i = 0; i < emailList.size(); i++) { a.add(emailList.get(i)); } a.notifyDataSetChanged(); L.d("AddFriendsActivity gotEmailAddresses"); } }); } final SafeViewOnClickListener onClickListener = new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String email = emailText.getText().toString().trim(); if (RegexPatterns.EMAIL.matcher(email).matches()) { if (mFriendsPlugin.inviteFriend(email, null, null, true)) { emailText.setText(null); UIUtils.hideKeyboard(AddFriendsActivity.this, emailText); } else { UIUtils.showLongToast(AddFriendsActivity.this, getString(R.string.friend_invite_failed)); } } else { AlertDialog.Builder builder = new AlertDialog.Builder(AddFriendsActivity.this); builder.setMessage(R.string.registration_email_not_valid); builder.setPositiveButton(R.string.rogerthat, null); builder.create().show(); } } }; ((Button) findViewById(R.id.add_via_email_button)).setOnClickListener(onClickListener); emailText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { onClickListener.onClick(view); return true; } return false; } }); }
From source file:com.flipzu.flipzu.Player.java
@Override public void onResponseReceived(BroadcastDataSet bcast) { /* unset loading progress */ setProgressBarIndeterminateVisibility(Boolean.FALSE); if (bcast != null) { debug.logV(TAG, "onResponseReceived called with bcast " + bcast.getId()); } else {//from ww w .j a v a 2 s. c om debug.logV(TAG, "onResponseReceived called with bcast NULL"); } boolean newBcast = false; if (bcast != null) { /* start async call to fetch user data */ AsyncFlipInterface.getUser(bcast.getUsername(), user.getToken(), this); if (isNewBcast(bcast)) { debug.logV(TAG, "onResponseReceived, is a new broadcast"); saveBcast(bcast); newBcast = true; } else { debug.logV(TAG, "onResponseReceived, is not a new broadcast"); } } else { // try again with bcast from settings... if (!mSavedBcast) { mSavedBcast = true; AsyncFlipInterface.getBroadcast(getBcastFromSettings(), this); } return; } this.bcast = bcast; mUrl = getCurrentUrl(bcast); if (bcast != null) { mTitle = bcast.getUsername(); if (bcast.getText() != null) mTitle += " - " + bcast.getText(); } debug.logV(TAG, "onResponseReceived, got URL " + mUrl); /* layout */ ImageView bg = (ImageView) findViewById(R.id.user_avatar); final TextView title_tv = (TextView) findViewById(R.id.title); final TextView time_tv = (TextView) findViewById(R.id.time_str); final TextView listeners_tv = (TextView) findViewById(R.id.listeners); final TextView username_tv = (TextView) findViewById(R.id.username); username_tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Player.this, Profile.class); i.putExtra("user", ((TextView) findViewById(R.id.username)).getText()); startActivity(i); } }); bg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Player.this, Profile.class); i.putExtra("user", ((TextView) findViewById(R.id.username)).getText()); startActivity(i); } }); final TextView bottom_title_tv = (TextView) findViewById(R.id.player_title_bottom); // fix padding for player // ScrollingTextView sc_tv = (ScrollingTextView) findViewById(R.id.actionbar_title); // sc_tv.setPadding(35, 0, 0, 0); /* action bar */ // ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar); // actionBar.setHomeLogo(R.drawable.logo2); if (bcast != null) { UrlImageViewHelper.setUrlDrawable(bg, bcast.getImgUrl(), R.drawable.icon_sq); getSupportActionBar().setTitle(bcast.getUsername()); username_tv.setText(bcast.getUsername()); CharSequence title = bcast.getText(); if (title == null) title = getText(R.string.empty_title); title_tv.setText(title); bottom_title_tv.setText(mTitle); bottom_title_tv.setSelected(true); // hack to make text scroll if (bcast.getTimeStr() != null) { time_tv.setText(bcast.getTimeStr()); } if (bcast.getListens() == null) { // maybe erased? Go back... Player.this.finish(); } try { Integer listens = Integer.parseInt(bcast.getListens()) + 1; listeners_tv.setText(listens.toString()); } catch (NumberFormatException e) { Player.this.finish(); } } // EditText comment listener final EditText comment_et = (EditText) findViewById(R.id.post_comment_et); comment_et.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press postComment(); return true; } return false; } }); /* start bcast if it's a new one */ if (newBcast) { debug.logV(TAG, "onResponseReceived, newBcast, sending PLAY"); sendPlay(); } else { if (mState == playerState.STOPPED) sendPlay(); } /* stats thread */ if (bcast != null) { if (bcast.getId() != null) { AsyncFlipInterface.getComments(Integer.parseInt(bcast.getId()), Player.this); } if (bcast.isLive()) { if (mState == playerState.PLAYING) setLiveVisible(true); liveHandler.removeCallbacks(mCheckLiveTask); liveHandler.postDelayed(mCheckLiveTask, 5000); } else { timerHandler.removeCallbacks(mTimerTask); timerHandler.postDelayed(mTimerTask, 1000); } } }