List of usage examples for android.os SystemClock sleep
public static void sleep(long ms)
From source file:com.farmerbb.taskbar.service.TaskbarService.java
private void tempHideTaskbar(boolean monitorPositionChanges) { if (!taskbarShownTemporarily) { SharedPreferences pref = U.getSharedPreferences(TaskbarService.this); if (pref.getBoolean("collapsed", false)) taskbarHiddenTemporarily = true; }/*from ww w . j av a 2 s . c om*/ hideTaskbar(false); if (taskbarShownTemporarily) taskbarShownTemporarily = false; if (monitorPositionChanges && showHideAutomagically && !positionIsVertical) { if (thread2 != null) thread2.interrupt(); handler2 = new Handler(); thread2 = new Thread(() -> { stopThread2 = false; while (!stopThread2) { SystemClock.sleep(refreshInterval); handler2.post(() -> stopThread2 = checkPositionChange()); } startThread2 = false; }); thread2.start(); } }
From source file:com.siahmsoft.soundroid.sdk7.provider.tracks.TracksStore.java
private void executeRequestNotSigned(HttpPut put, ResponseHandler handler) throws IOException { HttpEntity entity = null;//from w w w . jav a2 s. c o m try { SystemClock.sleep(500); final HttpResponse response = HttpManager.execute(put); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) { entity = response.getEntity(); final InputStream in = entity.getContent(); handler.handleResponse(in); } } finally { if (entity != null) { entity.consumeContent(); } } }
From source file:com.siahmsoft.soundroid.sdk7.provider.tracks.TracksStore.java
private void executeRequestNotSigned(HttpPost post, ResponseHandler handler) throws IOException { HttpEntity entity = null;/* w w w . java2 s.co m*/ try { SystemClock.sleep(500); final HttpResponse response = HttpManager.execute(post); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) { entity = response.getEntity(); final InputStream in = entity.getContent(); handler.handleResponse(in); } } finally { if (entity != null) { entity.consumeContent(); } } }
From source file:com.hzx.luoyechat.activity.ChatActivity.java
/** * // w w w .j a va 2s.c om */ public void setModeVoice(final View view) { hideKeyboard(); iv_emoticons_checked.setVisibility(View.INVISIBLE); exeTask(new Runnable() { @Override public void run() { SystemClock.sleep(SLEEP_MILLIES); runOnUiThread(new Runnable() { @Override public void run() { edittext_layout.setVisibility(View.GONE); more.setVisibility(View.GONE); view.setVisibility(View.GONE); buttonSetModeKeyboard.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); btnMore.setVisibility(View.VISIBLE); buttonPressToSpeak.setVisibility(View.VISIBLE); iv_emoticons_normal.setVisibility(View.VISIBLE); btnContainer.setVisibility(View.VISIBLE); emojiIconContainer.setVisibility(View.GONE); } }); } }); }
From source file:com.google.sample.cast.refplayer.Synchronization.java
public void setVideo() { mHandler = new Handler(); loadViews();/*from www .ja v a2 s . c o m*/ if (Channel == 0) srcPath = "android.resource://com.google.sample.cast.refplayer/" + R.raw.shishan; else if (Channel == 1) srcPath = "android.resource://com.google.sample.cast.refplayer/" + R.raw.smarttv_35_2; else if (Channel == 2) srcPath = "android.resource://com.google.sample.cast.refplayer/" + R.raw.smarttv_10; mVideoView.setVideoURI(Uri.parse(srcPath)); SystemClock.sleep(1000); if (Role == 1) { mVideoView.start(); } if (Role == 2) { mProgressBar.setVisibility(View.INVISIBLE); } SysStartTime = System.currentTimeMillis(); CurSysTime = System.currentTimeMillis(); mProgressBar.setProgress(0); SetNormalProgressBar(); // Condition 1: Video Condition if (condition == 1) { if (Role == 1) { mSendVideo.setVisibility(View.VISIBLE); mSendVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int start = 0; int end = pgDuration; Log.d(TAG, "clip: " + start + "-" + end); VideoTime = getVideoTime(); sendMessage("C&&" + VideoTime + "&&" + UserIndex + "&&" + start + "-" + end); SetSendFeedbackText(); } }); } if (Role == 2) { //mPreview.setVisibility(View.INVISIBLE); //SetPreviewBtn(); } } // Condition 2: Clip Condition if (condition == 2 || condition == 3) { if (condition == 3 && Role == 2) { /* Assume receiver get the prev_end_p time point */ /* mVideoView.seekTo(prev_end_p); mVideoView.start(); mVideoView.pause();*/ } else { if (condition == 2 && Role == 1) { SetNormalClipBar(); } if (condition == 3 && Role == 1) { SetNormalClipBar(); button_takeSnapshot.setVisibility(View.VISIBLE); } if (condition == 2 && Role == 2) { mPreview.setVisibility(View.INVISIBLE); } SetPreviewBtn(); if (condition == 2) { SetSendClip(); mSendClip.setVisibility(View.INVISIBLE); } } } //if(condition==3) button_takeSnapshot.setVisibility(View.VISIBLE); // Condition 3: Snapshot Condition }
From source file:com.hzx.luoyechat.activity.ChatActivity.java
/** * ??/* www .j a v a2 s.co m*/ * * @param view */ public void toggleMore(View view) { if (more.getVisibility() == View.GONE) { EMLog.d(TAG, "more gone"); hideKeyboard(); exeTask(new Runnable() { @Override public void run() { SystemClock.sleep(SLEEP_MILLIES); runOnUiThread(new Runnable() { @Override public void run() { more.setVisibility(View.VISIBLE); btnContainer.setVisibility(View.VISIBLE); emojiIconContainer.setVisibility(View.GONE); } }); } }); } else { if (emojiIconContainer.getVisibility() == View.VISIBLE) { emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.VISIBLE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); } else { more.setVisibility(View.GONE); } } }
From source file:com.koma.music.service.MusicService.java
/** * Reloads the queue as the user left it the last time they stopped using * Apollo/*from www.ja v a 2 s.co m*/ */ private void reloadQueue() { int id = mCardId; if (mPreferences.contains("cardid")) { id = mPreferences.getInt("cardid", ~mCardId); } if (id == mCardId) { mPlaylist = mPlaybackStateStore.getQueue(); } if (mPlaylist.size() > 0) { final int pos = mPreferences.getInt("curpos", 0); if (pos < 0 || pos >= mPlaylist.size()) { mPlaylist.clear(); return; } mPlayPos = pos; updateCursor(mPlaylist.get(mPlayPos).mId); if (mCursor == null) { SystemClock.sleep(3000); updateCursor(mPlaylist.get(mPlayPos).mId); } synchronized (this) { closeCursor(); mOpenFailedCounter = 20; openCurrentAndNext(); } if (!mPlayer.isInitialized()) { mPlaylist.clear(); return; } final long seekpos = mPreferences.getLong("seekpos", 0); seek(seekpos >= 0 && seekpos < duration() ? seekpos : 0); LogUtils.d(TAG, "restored queue, currently at position " + position() + "/" + duration() + " (requested " + seekpos + ")"); int repmode = mPreferences.getInt("repeatmode", MusicServiceConstants.REPEAT_NONE); if (repmode != MusicServiceConstants.REPEAT_ALL && repmode != MusicServiceConstants.REPEAT_CURRENT) { repmode = MusicServiceConstants.REPEAT_NONE; } mRepeatMode = repmode; int shufmode = mPreferences.getInt("shufflemode", MusicServiceConstants.SHUFFLE_NONE); if (shufmode != MusicServiceConstants.SHUFFLE_AUTO && shufmode != MusicServiceConstants.SHUFFLE_NORMAL) { shufmode = MusicServiceConstants.SHUFFLE_NONE; } if (shufmode != MusicServiceConstants.SHUFFLE_NONE) { mHistory = mPlaybackStateStore.getHistory(mPlaylist.size()); } if (shufmode == MusicServiceConstants.SHUFFLE_AUTO) { if (!makeAutoShuffleList()) { shufmode = MusicServiceConstants.SHUFFLE_NONE; } } mShuffleMode = shufmode; } }
From source file:com.bluros.music.MusicService.java
private void reloadQueue() { int id = mCardId; if (mPreferences.contains("cardid")) { id = mPreferences.getInt("cardid", ~mCardId); }//from www. ja v a2 s . c o m if (id == mCardId) { mPlaylist = mPlaybackStateStore.getQueue(); } if (mPlaylist.size() > 0) { final int pos = mPreferences.getInt("curpos", 0); if (pos < 0 || pos >= mPlaylist.size()) { mPlaylist.clear(); return; } mPlayPos = pos; updateCursor(mPlaylist.get(mPlayPos).mId); if (mCursor == null) { SystemClock.sleep(3000); updateCursor(mPlaylist.get(mPlayPos).mId); } synchronized (this) { closeCursor(); mOpenFailedCounter = 20; openCurrentAndNext(); } if (!mPlayer.isInitialized()) { mPlaylist.clear(); return; } final long seekpos = mPreferences.getLong("seekpos", 0); seek(seekpos >= 0 && seekpos < duration() ? seekpos : 0); if (D) { Log.d(TAG, "restored queue, currently at position " + position() + "/" + duration() + " (requested " + seekpos + ")"); } int repmode = mPreferences.getInt("repeatmode", REPEAT_NONE); if (repmode != REPEAT_ALL && repmode != REPEAT_CURRENT) { repmode = REPEAT_NONE; } mRepeatMode = repmode; int shufmode = mPreferences.getInt("shufflemode", SHUFFLE_NONE); if (shufmode != SHUFFLE_AUTO && shufmode != SHUFFLE_NORMAL) { shufmode = SHUFFLE_NONE; } if (shufmode != SHUFFLE_NONE) { mHistory = mPlaybackStateStore.getHistory(mPlaylist.size()); } if (shufmode == SHUFFLE_AUTO) { if (!makeAutoShuffleList()) { shufmode = SHUFFLE_NONE; } } mShuffleMode = shufmode; } }
From source file:org.mariotaku.harmony.MusicPlaybackService.java
private void reloadQueue() { String q = null;/*from w ww . j a v a2 s .c o m*/ final int id = mPreferences.getIntState(STATE_KEY_CARDID, mCardId); if (id == mCardId) { // Only restore the saved playlist if the card is still // the same one as when the playlist was saved q = mPreferences.getStringState(STATE_KEY_QUEUE, ""); } int qlen = q != null ? q.length() : 0; if (qlen > 1) { // Log.i("@@@@ service", "loaded queue: " + q); int plen = 0; int n = 0; int shift = 0; for (int i = 0; i < qlen; i++) { char c = q.charAt(i); if (c == ';') { ensurePlayListCapacity(plen + 1); mPlayList[plen] = n; plen++; n = 0; shift = 0; } else { if (c >= '0' && c <= '9') { n += c - '0' << shift; } else if (c >= 'a' && c <= 'f') { n += 10 + c - 'a' << shift; } else { // bogus playlist data plen = 0; break; } shift += 4; } } mPlayListLen = plen; int pos = mPreferences.getIntState(STATE_KEY_CURRPOS, 0); if (pos < 0 || pos >= mPlayListLen) { // The saved playlist is bogus, discard it mPlayListLen = 0; return; } mPlayPos = pos; // When reloadQueue is called in response to a card-insertion, // we might not be able to query the media provider right away. // To deal with this, try querying for the current file, and if // that fails, wait a while and try again. If that too fails, // assume there is a problem and don't restore the state. Cursor crsr = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[] { "_id" }, "_id=" + mPlayList[mPlayPos], null, null); if (crsr == null || crsr.getCount() == 0) { // wait a bit and try again SystemClock.sleep(3000); crsr = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, CURSOR_COLUMNS, "_id=" + mPlayList[mPlayPos], null, null); } if (crsr != null) { crsr.close(); } mOpenFailedCounter = 20; mQuietMode = true; openCurrent(); mQuietMode = false; if (!mPlayer.isInitialized()) { // couldn't restore the saved state mPlayListLen = 0; return; } long seekpos = mPreferences.getLongState(STATE_KEY_SEEKPOS, 0); seek(seekpos >= 0 && seekpos < getDuration() ? seekpos : 0); Log.d(LOGTAG_SERVICE, "restored queue, currently at position " + getPosition() + "/" + getDuration() + " (requested " + seekpos + ")"); setRepeatMode(mPreferences.getIntPref(PREFERENCE_KEY_REPEAT_MODE, REPEAT_MODE_NONE)); setShuffleMode(mPreferences.getIntPref(PREFERENCE_KEY_SHUFFLE_MODE, SHUFFLE_MODE_NONE)); if (mShuffleMode != SHUFFLE_MODE_NONE) { // in shuffle mode we need to restore the history too q = mPreferences.getStringState(STATE_KEY_HISTORY, ""); qlen = q != null ? q.length() : 0; if (qlen > 1) { plen = 0; n = 0; shift = 0; mHistory.clear(); for (int i = 0; i < qlen; i++) { char c = q.charAt(i); if (c == ';') { if (n >= mPlayListLen) { // bogus history data mHistory.clear(); break; } if (!mHistory.contains(mPlayPos)) { mHistory.add(mPlayPos); } n = 0; shift = 0; } else { if (c >= '0' && c <= '9') { n += c - '0' << shift; } else if (c >= 'a' && c <= 'f') { n += 10 + c - 'a' << shift; } else { // bogus history data mHistory.clear(); break; } shift += 4; } } } } } }
From source file:com.cyanogenmod.eleven.MusicPlaybackService.java
/** * Reloads the queue as the user left it the last time they stopped using * Apollo//from ww w .j ava 2s. com */ private void reloadQueue() { int id = mCardId; if (mPreferences.contains("cardid")) { id = mPreferences.getInt("cardid", ~mCardId); } if (id == mCardId) { mPlaylist = mPlaybackStateStore.getQueue(); } if (mPlaylist.size() > 0) { final int pos = mPreferences.getInt("curpos", 0); if (pos < 0 || pos >= mPlaylist.size()) { mPlaylist.clear(); return; } mPlayPos = pos; updateCursor(mPlaylist.get(mPlayPos).mId); if (mCursor == null) { SystemClock.sleep(3000); updateCursor(mPlaylist.get(mPlayPos).mId); } synchronized (this) { closeCursor(); mOpenFailedCounter = 20; openCurrentAndNext(); } if (!mPlayer.isInitialized()) { mPlaylist.clear(); return; } final long seekpos = mPreferences.getLong("seekpos", 0); seek(seekpos >= 0 && seekpos < duration() ? seekpos : 0); if (D) { Log.d(TAG, "restored queue, currently at position " + position() + "/" + duration() + " (requested " + seekpos + ")"); } int repmode = mPreferences.getInt("repeatmode", REPEAT_NONE); if (repmode != REPEAT_ALL && repmode != REPEAT_CURRENT) { repmode = REPEAT_NONE; } mRepeatMode = repmode; int shufmode = mPreferences.getInt("shufflemode", SHUFFLE_NONE); if (shufmode != SHUFFLE_AUTO && shufmode != SHUFFLE_NORMAL) { shufmode = SHUFFLE_NONE; } if (shufmode != SHUFFLE_NONE) { mHistory = mPlaybackStateStore.getHistory(mPlaylist.size()); } if (shufmode == SHUFFLE_AUTO) { if (!makeAutoShuffleList()) { shufmode = SHUFFLE_NONE; } } mShuffleMode = shufmode; } }