Example usage for android.os SystemClock sleep

List of usage examples for android.os SystemClock sleep

Introduction

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

Prototype

public static void sleep(long ms) 

Source Link

Document

Waits a given number of milliseconds (of uptimeMillis) before returning.

Usage

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.timeline);/*from w w  w . ja v  a2s.c  o  m*/

    messagesActivity = this;

    ((ImageView) findViewById(R.id.bg_screen)).setBackgroundDrawable(new BitmapDrawable(getResources(),
            BitmapFactory.decodeStream(getResources().openRawResource(+R.drawable.bg))));

    timeline = (TimelineObject) getIntent().getSerializableExtra(ConstantKeys.TIMELINE);

    setTitle(timeline.getParty().getName());
    getActionBar().setIcon(R.drawable.ic_timeline_light);

    updateBottom = (ImageView) findViewById(R.id.update_bottom);
    messageTextView = (TextView) findViewById(R.id.message);
    myAnimationDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);

    timelineEnabledTextView = (TextView) findViewById(R.id.enabledMessage);

    adapter = new MessageListAdapter(messagesActivity, messageList, updateBottom, timeline);

    listView = (ListView) findViewById(R.id.list);
    listView.setAdapter(adapter);

    ((ImageButton) findViewById(R.id.send_button)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            sendMessage();
        }
    });

    ((ImageView) findViewById(R.id.attach_delete)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mFileCaptureUri = null;
            fromGallery = false;
            ((RelativeLayout) messagesActivity.findViewById(R.id.atach_layer)).setVisibility(View.GONE);

        }
    });

    ((EditText) findViewById(R.id.upload_description_content)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (listView.getLastVisiblePosition() == listView.getCount() - 1) {
                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... params) {
                        SystemClock.sleep(300);
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        listView.setSelection(listView.getCount());
                    }
                }.execute();
            }
        }
    });

    configurePopup();
    configureCallPopup();
    configurePullToRrefresh();

    fromOnCreate = true;
}

From source file:com.guayaba.tapir.ui.fragments.profile.LastAddedFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName,
                    mArtistName);//  w w  w.  j a v a  2s . co m
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.guayaba.tapir.ui.fragments.profile.FavoriteFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.REMOVE_FROM_FAVORITES:
            FavoritesStore.getInstance(getActivity()).removeItem(mSelectedId);
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default://from  ww w .j a  v  a2 s. co m
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.profile.LastAddedFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new Song[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSong(mSelectedId.getId(), mSelectedId.getHost(),
                    mSongName, mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new Song[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String mPlaylistId = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), new Song[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId.getId());
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:// ww w  .j  a  va2  s  .c  o m
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.profile.FavoriteFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new Song[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new Song[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String mPlaylistId = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), new Song[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId.getId());
            return true;
        case FragmentMenuItems.REMOVE_FROM_FAVORITES:
            FavoritesStore.getInstance(getActivity()).removeSong(mSelectedId.getId(), mSelectedId.getHost());
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:/* w w w. j a va  2 s  .  c  o  m*/
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.sentaroh.android.SMBExplorer.FileIo.java

private void waitMediaScanner(boolean ds) {
    boolean time_out = false;
    int timeout_val = 0;
    while (true) {
        if (mediaScanner.isConnected() == ds)
            break;
        SystemClock.sleep(10);
        timeout_val++;
        if (timeout_val >= 501) {
            time_out = true;/*from  w  ww. j a va 2  s  .  c  o  m*/
            break;
        }
    }
    if (time_out)
        sendLogMsg("E", "MediaScannerConnection timeout occured.");
}

From source file:com.ls.sip.CameraFragment.java

@SuppressWarnings({ "unused", "ConstantConditions" })
public void onEventMainThread(CameraEngine.VideoTakenEvent event) {
    if (event.exception == null) {
        if (getArguments().getBoolean(ARG_UPDATE_MEDIA_STORE, false)) {
            final Context app = getActivity().getApplicationContext();
            Uri output = getArguments().getParcelable(ARG_OUTPUT);
            final String path = output.getPath();

            new Thread() {
                @Override// w w  w. j  av  a  2  s . co  m
                public void run() {
                    SystemClock.sleep(2000);
                    MediaScannerConnection.scanFile(app, new String[] { path }, new String[] { "video/mp4" },
                            null);
                }
            }.start();
        }

        isVideoRecording = false;
        btnTakePicture.setImageResource(R.drawable.cwac_cam2_ic_videocam);
    } else {
        getActivity().finish();
    }
}

From source file:org.openremote.android.test.console.net.ORNetworkCheckTest.java

private void enableWifi(boolean enable) {

    WifiManager wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);

    if (enable && wifi.isWifiEnabled())
        return;/*from www. ja  v  a 2 s .com*/

    if (!enable && !wifi.isWifiEnabled())
        return;

    if (enable && !wifi.isWifiEnabled()) {
        if (!wifi.setWifiEnabled(true))
            fail("Cannot enable WiFi");
    } else {
        wifi.disconnect();
        wifi.setWifiEnabled(false);
    }

    // wait for it...

    for (int iterations = 0; iterations < 10; iterations++) {
        SystemClock.sleep(500);

        if (enable && wifi.isWifiEnabled())
            break;
        if (!enable && !wifi.isWifiEnabled())
            break;
    }
}

From source file:com.guayaba.tapir.ui.fragments.profile.PlaylistSongFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName,
                    mArtistName);/*  w ww  .  jav a2 s  .c  o  m*/
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long playlistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, playlistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            mAdapter.remove(mSong);
            mAdapter.notifyDataSetChanged();
            MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId);
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.profile.PlaylistSongFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new Song[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSong(mSelectedId.getId(), mSelectedId.getHost(),
                    mSongName, mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new Song[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String playlistId = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), new Song[] { mSelectedId }, playlistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId.getId());
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            mAdapter.remove(mSong);//from   www. ja v  a  2  s  .co  m
            mAdapter.notifyDataSetChanged();
            MusicUtils.removeFromPlaylist(getActivity(), mSong.getId(), mPlaylistId);
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}