Example usage for android.os Handler postDelayed

List of usage examples for android.os Handler postDelayed

Introduction

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

Prototype

public final boolean postDelayed(Runnable r, long delayMillis) 

Source Link

Document

Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.

Usage

From source file:com.ihc.cefet.cidadealerta.MyFavoritesActivity.java

@Override
public void onRefresh() {
    AndroidUtils.changeSwipeVisibility(swipe, true);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            AndroidUtils.changeSwipeVisibility(swipe, false);
        }//from  w ww  .  j a va 2  s. c o  m
    }, 2000);
}

From source file:com.material.tblagodarova.design.ui.LayoutChangesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_layout_changes);

    mContainerView = (ViewGroup) findViewById(R.id.container);
    findViewById(android.R.id.empty).setVisibility(View.GONE);
    addItem();/*from   ww w.  java2s.  co m*/
    Handler h = new Handler();
    h.postDelayed(new Runnable() {
        @Override
        public void run() {
            findViewById(android.R.id.empty).setVisibility(View.GONE);
            addItem();
        }
    }, 5500);
}

From source file:com.degreat.apps.kwamelearn.CorrectWrongDialog.java

@Override
public void onResume() {
    super.onResume();
    Handler timeOutHandler = new Handler();
    timeOutHandler.postDelayed(new Runnable() {
        @Override/*  ww w. j a v  a 2 s  .  com*/
        public void run() {
            CorrectWrongDialog.this.dismiss();
        }
    }, 1200);
}

From source file:appocorrencias.com.appocorrencias.Activitys.DelayedProgressDialog.java

private void cancelWhenNotShowing() {
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override//from  w w  w . j a  v a 2 s.c o m
        public void run() {
            dismissAllowingStateLoss();
        }
    }, DELAY_MILLISECOND);
}

From source file:appocorrencias.com.appocorrencias.Activitys.DelayedProgressDialog.java

@Override
public void show(final FragmentManager fm, final String tag) {
    mStartMillisecond = System.currentTimeMillis();
    startedShowing = false;/* ww w . j a v a2  s. c o m*/
    mStopMillisecond = Long.MAX_VALUE;

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (mStopMillisecond > System.currentTimeMillis())
                showDialogAfterDelay(fm, tag);
        }
    }, DELAY_MILLISECOND);
}

From source file:com.ihc.cefet.cidadealerta.MyFavoritesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_favorites);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);/*from w w  w  .ja v a  2s .  c om*/
    configActionBar("Ocorrncias Favoritas", true);
    toolbar.setTitle(R.string.cidade_alerta);
    toolbar.setTitleTextColor(getResources().getColor(android.R.color.white));

    swipe.setOnRefreshListener(this);
    swipe.setColorSchemeResources(R.color.colorPrimary);
    AndroidUtils.changeSwipeVisibility(swipe, true);

    final ArrayList<Item> items = Item.getTestingList();
    for (Item i : items) {
        i.setFavorited(true);
    }
    adapter = SimpleFoldingCellListAdapter.newInstance(this, items);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    //recyclerView.setLayoutManager(layoutManager);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            //recyclerView.setAdapter(adapter);

            AndroidUtils.changeSwipeVisibility(swipe, false);
        }
    }, 2000);
}

From source file:com.ihc.cefet.cidadealerta.MyIssuesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_created_issues);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);//from w  ww.j av a2 s.  c o m
    configActionBar("Minhas Ocorrncias", true);
    toolbar.setTitleTextColor(getResources().getColor(android.R.color.white));

    swipe.setOnRefreshListener(this);
    swipe.setColorSchemeResources(R.color.colorPrimary);
    AndroidUtils.changeSwipeVisibility(swipe, true);

    final ArrayList<Item> items = Item.getTestingList();
    for (Item i : items) {
        i.setUserCreated(true);
    }
    adapter = SimpleFoldingCellListAdapter.newInstance(this, items);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            recyclerView.setAdapter(adapter);

            AndroidUtils.changeSwipeVisibility(swipe, false);
        }
    }, 2000);
}

From source file:appocorrencias.com.appocorrencias.Activitys.DelayedProgressDialog.java

private void cancelWhenShowing() {
    if (mStopMillisecond < mStartMillisecond + DELAY_MILLISECOND + SHOW_MIN_MILLISECOND) {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override/*from   ww  w.j a v  a2 s .c  o m*/
            public void run() {
                dismissAllowingStateLoss();
            }
        }, SHOW_MIN_MILLISECOND);
    } else {
        dismissAllowingStateLoss();
    }
}

From source file:com.bluros.music.fragments.PlaylistFragment.java

public void updatePlaylists(final long id) {
    final List<Playlist> playlists = PlaylistLoader.getPlaylists(getActivity(), true);
    playlistcount = playlists.size();//from  www  . j a v  a  2s . co m
    adapter.notifyDataSetChanged();
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < playlists.size(); i++) {
                long playlistid = playlists.get(i).id;
                if (playlistid == id) {
                    pager.setCurrentItem(i);
                    break;
                }
            }
        }
    }, 200);

}

From source file:com.cryart.sabbathschool.adapter.SSReadingViewAdapter.java

@Override
public Object instantiateItem(ViewGroup collection, int position) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.ss_reading_view, collection, false);
    collection.addView(layout);/*from  ww  w.jav  a  2  s .  c om*/

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.mContext);
    SSReadingDisplayOptions ssReadingDisplayOptions = new SSReadingDisplayOptions(
            prefs.getString(SSConstants.SS_SETTINGS_THEME_KEY, SSReadingDisplayOptions.SS_THEME_LIGHT),
            prefs.getString(SSConstants.SS_SETTINGS_SIZE_KEY, SSReadingDisplayOptions.SS_SIZE_MEDIUM),
            prefs.getString(SSConstants.SS_SETTINGS_FONT_KEY, SSReadingDisplayOptions.SS_FONT_LATO));

    final SSReadingView ssReadingView = layout.findViewById(R.id.ss_reading_view);
    ssReadingView.setReadingDisplayOptions(ssReadingDisplayOptions);
    ssReadingView.setContextMenuCallback(ssReadingViewModel);
    ssReadingView.setHighlightsCommentsCallback(ssReadingViewModel);
    ssReadingView.setReadHighlights(ssReadHighlights.get(position));
    ssReadingView.setReadComments(ssReadComments.get(position));
    ssReadingView.loadRead(ssReads.get(position));

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (ssReadingView != null) {
                ssReadingView.updateHighlights();
                ssReadingView.updateComments();
            }
        }
    }, 800);

    layout.setTag("ssReadingView_" + position);

    return layout;
}