Example usage for android.widget TextView postDelayed

List of usage examples for android.widget TextView postDelayed

Introduction

In this page you can find the example usage for android.widget TextView postDelayed.

Prototype

public boolean postDelayed(Runnable action, long delayMillis) 

Source Link

Document

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

Usage

From source file:us.shandian.blacklight.ui.main.MainActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
    if ((parent != mOther || position == 0) && mLastChoice != null) {
        mLastChoice.getPaint().setFakeBoldText(false);
        mLastChoice.invalidate();//from w w  w  .j a v  a  2 s.c o  m
    }

    if (mGroups != null && mGroups.getSize() > 0 && (parent != mOther || position != 1)) {
        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        getActionBar().setDisplayShowTitleEnabled(true);
    }

    if (parent == mMy) {
        TextView tv = (TextView) view;
        tv.getPaint().setFakeBoldText(true);
        tv.invalidate();
        mLastChoice = tv;
        mNext = position;
        if (mFragments[position] != null) {
            tv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(position);
                    } catch (Exception e) {

                    }

                    if (position == 0 && mGroups != null && mGroups.getSize() > 0) {
                        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
                        getActionBar().setDisplayShowTitleEnabled(false);
                        updateActionSpinner();
                    }
                }
            }, 400);
        }
    } else if (parent == mAtMe) {
        TextView tv = (TextView) view;
        tv.getPaint().setFakeBoldText(true);
        tv.invalidate();
        mLastChoice = tv;
        mNext = position + 4;
        if (mFragments[4 + position] != null) {
            tv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(4 + position);
                    } catch (Exception e) {

                    }
                }
            }, 400);
        }
    } else if (parent == mOther) {
        switch (position) {
        case 0: {
            mNext = 6;
            view.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(6);
                    } catch (Exception e) {

                    }
                }
            }, 400);
            break;
        }
        case 1: {
            Intent i = new Intent();
            i.setAction(Intent.ACTION_MAIN);
            i.setClass(this, SettingsActivity.class);
            startActivity(i);
            break;
        }
        case 2: {
            mLoginCache.logout();
            Intent i = new Intent();
            i.setAction(Intent.ACTION_MAIN);
            i.setClass(this, EntryActivity.class);
            startActivity(i);
            finish();
            break;
        }
        }
    }

    mDrawer.closeDrawer(mDrawerGravity);
}