Example usage for android.os CountDownTimer CountDownTimer

List of usage examples for android.os CountDownTimer CountDownTimer

Introduction

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

Prototype

public CountDownTimer(long millisInFuture, long countDownInterval) 

Source Link

Usage

From source file:edu.Groove9.TunesMaster.songplayer.SongPlayerFragment.java

public void showButtonFeedback(Button button, Drawable pressed, Drawable normal) {
    button.setBackground(pressed);//from   w w w  . j  av  a 2 s.  com

    final Button but = button;
    final Drawable norm = normal;
    final int delay = 1000;
    new CountDownTimer(delay, delay) {
        public void onTick(long millisUntilFinished) {
            /*ignore*/}

        public void onFinish() {
            but.setBackground(norm);
        }

    }.start();
}

From source file:org.site_monitor.activity.MainActivity.java

private void scheduleTimer() {
    if (countDownTimer != null) {
        countDownTimer.cancel();//from   ww w.  j av  a 2  s.  co m
    }
    final long nextAlarmTime = alarmUtil.getNextAlarmTime(this);
    final long nextAlarmInterval = alarmUtil.getCountUntilNextAlarmTime(this);
    if (nextAlarmInterval > 0) {
        timerBannerView.setVisibility(View.VISIBLE);
        countDownTimer = new CountDownTimer(nextAlarmInterval, TimeUtil._1_SEC * 5) {
            public void onTick(long millisUntilFinished) {
                chronometer.setText(DateUtils.getRelativeTimeSpanString(nextAlarmTime));
                chronometer.setText(DateUtils.getRelativeTimeSpanString(nextAlarmTime,
                        System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS));
            }

            public void onFinish() {
                chronometer.setText(R.string.imminent);
            }
        }.start();
    } else {
        timerBannerView.setVisibility(View.GONE);
    }
}

From source file:org.linphone.CallActivity.java

public void createTimerForDialog(long time) {
    timer = new CountDownTimer(time, 1000) {
        public void onTick(long millisUntilFinished) {
            TimeRemind = millisUntilFinished;
        }/*from   w  w  w . j  a  v a  2 s  . co  m*/

        public void onFinish() {
            if (dialog != null) {
                dialog.dismiss();
                dialog = null;
            }
            acceptCallUpdate(false);
        }
    }.start();
}

From source file:com.coinblesk.client.MainActivity.java

private void initSwitch(Menu menu) {
    MenuItem item = menu.findItem(R.id.myswitch);
    View view = item.getActionView();
    final Switch mySwitch = (Switch) view.findViewById(R.id.switchAB);
    final AtomicReference<CountDownTimer> ref = new AtomicReference<>();
    mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/*  ww  w .  j  a  v  a 2  s  .c  o m*/
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                //enable BT
                ref.set(new CountDownTimer(30000, 1000) {
                    int i = 0;

                    public void onTick(final long millisUntilFinished) {
                        mySwitch.setButtonDrawable(
                                (i++ % 2) == 0 ? R.drawable.bluetooth_onon : R.drawable.bluetooth_on);
                        mySwitch.setTextOn("" + millisUntilFinished / 1000);
                    }

                    public void onFinish() {
                        mySwitch.setButtonDrawable(R.drawable.bluetooth_on);
                        mySwitch.setChecked(false);
                    }

                });
                ref.get().start();
                LocalBroadcastManager.getInstance(MainActivity.this)
                        .sendBroadcast(new Intent(Constants.START_CLIENTS_ACTION));

            } else {
                //mySwitch.setShowText(false);
                CountDownTimer tmp;
                if ((tmp = ref.getAndSet(null)) != null) {
                    tmp.cancel();
                }
                LocalBroadcastManager.getInstance(MainActivity.this)
                        .sendBroadcast(new Intent(Constants.STOP_CLIENTS_ACTION));
            }
        }
    });
}

From source file:com.filemanager.free.activities.MainActivity.java

/**
 * Called when the activity is first created.
 */// w w w .j  ava2 s.c o  m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    context = this;
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception ignored) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
    }
    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,
                R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.addDrawerListener(mDrawerToggle);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
        mDrawerToggle.syncState();
    }

    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(con, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }

    //search
    searchView();
    //admob
    mInterstitialAd = new InterstitialAd(this);
    // set the ad unit ID
    mInterstitialAd.setAdUnitId("ca-app-pub-2257698129050878/4313141545");
    requestNewInterstitial();
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *//*  ww  w. j a v a2s  . co m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();
    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {

        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception e) {

    }
    updateDrawer();

    // setting window background color instead of each item, in order to reduce pixel overdraw
    if (theme1 == 0) {
        /*if(Main.IS_LIST) {
                
        getWindow().setBackgroundDrawableResource(android.R.color.white);
        } else {
                
        getWindow().setBackgroundDrawableResource(R.color.grid_background_light);
        }*/
        getWindow().setBackgroundDrawableResource(android.R.color.white);
    } else {
        getWindow().setBackgroundDrawableResource(R.color.holo_dark_background);
    }

    if (savedInstanceState == null) {

        if (openprocesses) {
            android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager()
                    .beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
        //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
    }

    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer_l, /* nav drawer image to replace 'Up' caret */
                R.string.drawer_open, /* "open drawer" description for accessibility */
                R.string.drawer_close /* "close drawer" description for accessibility */
        ) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mDrawerToggle.syncState();
    } /*((ImageButton) findViewById(R.id.drawer_buttton)).setOnClickListener(new ImageView.OnClickListener() {
      @Override
      public void onClick(View view) {
          if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
              mDrawerLayout.closeDrawer(mDrawerLinear);
          } else mDrawerLayout.openDrawer(mDrawerLinear);
      }
      });*/
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor((currentTab == 1 ? skinTwo : skin)));
        ((Activity) this).setTaskDescription(taskDescription);
    }
}

From source file:com.msted.lensrocket.activities.RocketsListActivity.java

private void startCountdownTimer(final Rocket rocket) {
    int position = mLensRocketService.getLocalRockets().indexOf(rocket);
    if (rocket == null)
        LensRocketLogger.i(TAG, "Rocket is null");
    LensRocketLogger.i(TAG, "Position: " + position);
    if (mLvRockets == null)
        LensRocketLogger.i(TAG, "mlvrockets is null");
    View view = mLvRockets.getChildAt(position);
    final TextView lblTime = (TextView) view.findViewById(R.id.lblTime);
    //Only start a countdown if we haven't already
    if (lblTime.getText().equals("")) {
        final ImageView imgIndicator = (ImageView) view.findViewById(R.id.imgIndicator);
        final TextView lblInstructions = (TextView) view.findViewById(R.id.lblInstructions);
        int timeToLive = rocket.getTimeToLive();
        lblTime.setText(timeToLive + "");
        new CountDownTimer(timeToLive * 1000, 1000) {
            public void onTick(long millisUntilFinished) {
                lblTime.setText(millisUntilFinished / 1000 + "");
            }//from  www .  j  a  v a  2 s  .  c o m

            public void onFinish() {
                imgIndicator.setImageResource(R.drawable.rocket_seen);
                lblTime.setText(R.string.empty_string);
                lblInstructions.setText(R.string.instructions_seen_rocket);
                rocket.setHasUserSeen(true);
                if (mViewingDialog.isShowing())
                    mViewingDialog.dismiss();
                if (mBitmapHolder != null && !mBitmapHolder.isRecycled())
                    mBitmapHolder.recycle();
                if (mVideoFile != null)
                    mVideoFile.delete();
            }
        }.start();
    }
}

From source file:com.amaze.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 */// w ww  . j av a 2 s  . c  om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Sp = PreferenceManager.getDefaultSharedPreferences(this);
    initialisePreferences();
    setTheme();
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    DataUtils.clear();
    DataUtils.registerOnDataChangedListener(this);
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();
    //requesting storage permissions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        if (!checkStoragePermission())
            requestStoragePermission();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    if (mAsyncHelperFragment != null) {

        FragmentManager fm = getSupportFragmentManager();
        mAsyncHelperFragment = (AsyncHelper) fm.findFragmentByTag(TAG_ASYNC_HELPER);
    }

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {

        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            crossfadeInverse();
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception e) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager()
                    .beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
        //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
    }

    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer_l, /* nav drawer image to replace 'Up' caret */
                R.string.drawer_open, /* "open drawer" description for accessibility */
                R.string.drawer_close /* "close drawer" description for accessibility */
        ) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mDrawerToggle.syncState();
    } /*((ImageButton) findViewById(R.id.drawer_buttton)).setOnClickListener(new ImageView.OnClickListener() {
      @Override
      public void onClick(View view) {
          if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
              mDrawerLayout.closeDrawer(mDrawerLinear);
          } else mDrawerLayout.openDrawer(mDrawerLinear);
      }
      });*/
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
}

From source file:jp.realglobe.sugo.actor.android.hitoe.MainActivity.java

/**
 * ??/*from   w w  w . j a  va 2s.c o m*/
 */
private synchronized void warn() {
    if (this.state != State.MAIN) {
        // ????
        return;
    }

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final long delay = Long.parseLong(
            sharedPreferences.getString(getString(R.string.key_delay), getString(R.string.default_delay)));

    setContentView(R.layout.activity_warning);
    this.state = State.WARNING;
    this.timer.removeCallbacksAndMessages(null);
    if (this.callTimer != null) {
        this.callTimer.cancel();
    }
    this.callTimer = new CountDownTimer(1_000L * delay, 100) {
        @Override
        public void onTick(long l) {
            final TextView view = (TextView) findViewById(R.id.text_counter_count);
            if (view == null) {
                return;
            }
            view.setText(String.format(Locale.US, "%d", (int) Math.ceil(l / 1_000.0)));
        }

        @Override
        public void onFinish() {
            call();
        }
    };
    this.callTimer.start();

    this.vibrator.vibrate(new long[] { 500, 1_000 }, 0);
    this.ringtone.play();
    if (!(this.googleApiClient.isConnecting() || this.googleApiClient.isConnected())) {
        this.googleApiClient.connect();
    }

    findViewById(R.id.button_call).setOnClickListener(view -> callAfterDialog());
    findViewById(R.id.button_stop)
            .setOnClickListener(view -> (new CancelDialog()).show(getFragmentManager(), "dialog"));

    this.heartrateView = (TextView) findViewById(R.id.text_heartrate_value);
    this.heartrateView.setText(String.format(Locale.US, "%d", heartrate.second));

    startReport();

    relayWarningView();

    Log.d(LOG_TAG, "Warning mode started");
}

From source file:de.toshsoft.tsremote.configuration.ConfigurationMainFragment.java

private void prepareRemote(View remoteView, Cursor currentRemote) {
    currentRemote.moveToFirst();/*ww w  .j ava2s  .c  o m*/

    final String remoteName = currentRemote
            .getString(currentRemote.getColumnIndex(DatabaseHelper.DB_COLUMN_NAME));

    Iterator remoteIterator = DatabaseHelper.UI_TO_DB_MAP.keySet().iterator();
    while (remoteIterator.hasNext()) {
        final String dbName = (String) remoteIterator.next();
        final int currentId = (DatabaseHelper.UI_TO_DB_MAP.get(dbName)).intValue();

        View currentButton = remoteView.findViewById(currentId);
        int currentButtonIndex = currentRemote.getColumnIndex(dbName);
        if (currentButtonIndex < 0)
            continue;

        String currentButtonName = currentRemote.getString(currentButtonIndex);
        currentButton.getBackground().setColorFilter(
                currentButtonName.compareTo("none") == 0 ? Color.RED : Color.GREEN, PorterDuff.Mode.MULTIPLY);
        currentButton.setOnLongClickListener(new Button.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                IrHelper.getInstance().learnKeyNative(remoteName, dbName, ConfigurationMainFragment.this, v);
                learingAlertDialog.setMessage(
                        String.format(getResources().getString(R.string.learn_string_alert_countdown), 3));
                learingAlertDialog.show();
                learingAlertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        learingAlertDialog.show();
                    }
                });

                TextView messageView = (TextView) learingAlertDialog.findViewById(android.R.id.message);
                messageView.setGravity(Gravity.CENTER);

                new CountDownTimer(3000, 1000) {
                    @Override
                    public void onTick(long millisUntilFinished) {
                        learingAlertDialog.setMessage(
                                String.format(getResources().getString(R.string.learn_string_alert_countdown),
                                        (millisUntilFinished / 1000)));
                    }

                    @Override
                    public void onFinish() {
                        learingAlertDialog.setMessage(getResources().getString(R.string.learn_string_alert));
                    }
                }.start();

                return true;
            }
        });
    }
}