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.lgallardo.youtorrentcontroller.RefreshListener.java

public void refreshWithDelay(final String state, int seconds) {

    seconds *= 1000;//from w  w  w  . j a v a2  s  . c o m

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            // Do something after 5s = 5000ms
            refresh(state);
        }
    }, seconds);
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private boolean setScreenSwitchToHome() {
    //      moveTaskToBack(true);
    Handler hndl = new Handler();
    hndl.postDelayed(new Runnable() {
        @Override//from   w  w  w.ja  v a 2 s.co m
        public void run() {
            Intent in = new Intent();
            in.setAction(Intent.ACTION_MAIN);
            in.addCategory(Intent.CATEGORY_HOME);
            startActivity(in);
        }
    }, 100);
    return true;
}

From source file:ua.mkh.settings.full.MainActivity.java

protected void onResume() {
    super.onResume();
    // try{/*  w w w .  j a  va2  s  .  com*/
    ButtonTextWifi();
    Airmode();
    ButtonTextBth();
    operator();
    //check_pirat();
    zimowets();

    ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = conMgr.getActiveNetworkInfo();

    if (info != null && info.isConnected()) {
        mTask = new GetContacts();
        mTask.execute();
    }

    ///////////////// ?   Google
    try {
        if (account_name.length() == 0) {
            btn_iCloud.setText(R.string.icloud);
            //textView2.setText("");
            //textView1.setText("");
        } else {
            String t2 = getString(R.string.icloud) + "<br />" + "<font color=\"#808080\" >" + "<small><small>"
                    + account_name + "</small></small>" + "</font>";
            btn_iCloud.setText(Html.fromHtml(t2), TextView.BufferType.SPANNABLE);
        }
    } catch (NullPointerException e) {
        btn_iCloud.setText(R.string.icloud);
    }

    if (isSharingWiFi(wifi) == true) {
        textVPN.setText(R.string.on);
    } else {
        textVPN.setText(R.string.off);
    }

    ////Start page
    SharedPreferences sp = getSharedPreferences(MY_SETTINGS, Context.MODE_PRIVATE);
    // ?,    ?? 
    boolean hasVisited = sp.getBoolean("hasVisited", false);

    if (!hasVisited) {
        //   ?
        Intent intent = new Intent(this, ActivityStart.class);
        startActivity(intent);
        Editor e = sp.edit();
        e.putBoolean("hasVisited", true);
        e.apply(); //    ?
        stok();
    }
    //////////////////////////////////////        ////////

    ////ChangeLog

    PackageInfo pInfo;

    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        versionNow = pInfo.versionName;
    } catch (NameNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    Log.d("HEY!", versionNow);

    String changeLog = sp.getString("version", "1.0");

    if (changeLog.contains(versionNow)) {

    } else {
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                update();
            }
        }, 500);
        Editor e = sp.edit();
        e.putString("version", versionNow);
        e.apply(); //    ?

    }

    /////DATABASE     
    String DATA = mSettings.getString(APP_PREFERENCES_DATABASE, "0");
    if (DATA.contains(getString(R.string.ver_database))) {

    } else {
        copyDataBase();
        Editor editor = mSettings.edit();
        editor.putString(APP_PREFERENCES_DATABASE, getString(R.string.ver_database));
        editor.commit();
    }

    if (mSettings.contains(APP_PREFERENCES_NETWORK)) {
        //  ?  ?
        String network = mSettings.getString(APP_PREFERENCES_NETWORK, null);
        TextOper.setText(network);
        ImageView ImageView07 = (ImageView) findViewById(R.id.ImageView07);
        ImageView07.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_tgb_menu)) {
        //  ?  ?
        Boolean menu = mSettings.getBoolean(APP_PREFERENCES_tgb_menu, true);
        if (menu == true) {
            menui = 1;
        } else {
            menui = 0;
        }
    }

    if (mSettings.contains(APP_PREFERENCES_MAIL)) {
        //  ?  ?
        mail_app = mSettings.getString(APP_PREFERENCES_MAIL, null);
        LinearLayoutMail.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NOTES)) {
        //  ?  ?
        notes_app = mSettings.getString(APP_PREFERENCES_NOTES, null);
        LinearLayoutNotes.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_PHONE)) {
        //  ?  ?
        phone_app = mSettings.getString(APP_PREFERENCES_PHONE, null);
        LinearLayoutPhone.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_MESSAGES)) {
        //  ?  ?
        messages_app = mSettings.getString(APP_PREFERENCES_MESSAGES, null);
        LinearLayoutMessages.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_SAFARI)) {
        //  ?  ?
        safari_app = mSettings.getString(APP_PREFERENCES_SAFARI, null);
        LinearLayoutSafari.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_MUSIC)) {
        //  ?  ?
        music_app = mSettings.getString(APP_PREFERENCES_MUSIC, null);
        LinearLayoutMusic.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_GAMECENTER)) {
        //  ?  ?
        gamecenter_app = mSettings.getString(APP_PREFERENCES_GAMECENTER, null);
        LinearLayoutGameCenter.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_WEATHER)) {
        //  ?  ?
        weather_app = mSettings.getString(APP_PREFERENCES_WEATHER, null);
        LinearLayoutWeather.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_COMPASS)) {
        //  ?  ?
        compass_app = mSettings.getString(APP_PREFERENCES_COMPASS, null);
        LinearLayoutCompass.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_MAPS)) {
        //  ?  ?
        maps_app = mSettings.getString(APP_PREFERENCES_MAPS, null);
        LinearLayoutMaps.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NOTIFICATIONS)) {
        //  ?  ?
        notifications_app = mSettings.getString(APP_PREFERENCES_NOTIFICATIONS, null);
        LinearLayoutNotif.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_CONTROL)) {
        //  ?  ?
        control_app = mSettings.getString(APP_PREFERENCES_CONTROL, null);
        LinearLayoutControl.setVisibility(View.VISIBLE);
    }
    /*
    if (mSettings.contains(APP_PREFERENCES_ICLOUD)) {
    //  ?  ?
    icloud_app = mSettings.getString(APP_PREFERENCES_ICLOUD, null); }
    else {
      btn_iCloud.setEnabled(false);
      ImageView img81 = (ImageView)findViewById(R.id.ImageView81);
      img81.setVisibility(View.GONE);
    }
    */
    if (mSettings.contains(APP_PREFERENCES_ITUNES)) {
        //  ?  ?
        itunes_app = mSettings.getString(APP_PREFERENCES_ITUNES, null);
        LinearLayoutTunes.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NEW1)) {
        //  ?  ?
        new1_app = mSettings.getString(APP_PREFERENCES_NEW1, null);
        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = pm.getApplicationInfo(new1_app, 0);
        } catch (final NameNotFoundException e) {
        }
        final String title1 = (String) ((applicationInfo != null) ? pm.getApplicationLabel(applicationInfo)
                : "???");

        btn_new1.setText(title1);
        ImageView in1 = (ImageView) findViewById(R.id.ImageView62);
        Drawable icon1 = null;
        try {
            icon1 = getPackageManager().getApplicationIcon(new1_app);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        in1.setImageDrawable(icon1);

        LinearLayoutNew1.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NEW2)) {
        //  ?  ?
        new2_app = mSettings.getString(APP_PREFERENCES_NEW2, null);

        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = pm.getApplicationInfo(new2_app, 0);
        } catch (final NameNotFoundException e) {
        }
        final String title2 = (String) ((applicationInfo != null) ? pm.getApplicationLabel(applicationInfo)
                : "???");

        btn_new2.setText(title2);
        ImageView in2 = (ImageView) findViewById(R.id.ImageView63);
        Drawable icon2 = null;
        try {
            icon2 = getPackageManager().getApplicationIcon(new2_app);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        in2.setImageDrawable(icon2);

        LinearLayoutNew2.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NEW3)) {
        //  ?  ?
        new3_app = mSettings.getString(APP_PREFERENCES_NEW3, null);

        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = pm.getApplicationInfo(new3_app, 0);
        } catch (final NameNotFoundException e) {
        }
        final String title3 = (String) ((applicationInfo != null) ? pm.getApplicationLabel(applicationInfo)
                : "???");

        btn_new3.setText(title3);
        ImageView in3 = (ImageView) findViewById(R.id.ImageView66);
        Drawable icon3 = null;
        try {
            icon3 = getPackageManager().getApplicationIcon(new3_app);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        in3.setImageDrawable(icon3);

        LinearLayoutNew3.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_NEW4)) {
        //  ?  ?
        new4_app = mSettings.getString(APP_PREFERENCES_NEW4, null);

        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = pm.getApplicationInfo(new4_app, 0);
        } catch (final NameNotFoundException e) {
        }
        final String title4 = (String) ((applicationInfo != null) ? pm.getApplicationLabel(applicationInfo)
                : "???");

        btn_new4.setText(title4);
        ImageView in4 = (ImageView) findViewById(R.id.ImageView69);
        Drawable icon4 = null;
        try {
            icon4 = getPackageManager().getApplicationIcon(new4_app);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        in4.setImageDrawable(icon4);
        LinearLayoutNew4.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_VK)) {
        //  ?  ?
        vk_app = mSettings.getString(APP_PREFERENCES_VK, null);
        LinearLayoutVk.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_VIBER)) {
        //  ?  ?
        viber_app = mSettings.getString(APP_PREFERENCES_VIBER, null);
        LinearLayoutViber.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_OK)) {
        //  ?  ?
        ok_app = mSettings.getString(APP_PREFERENCES_OK, null);
        LinearLayoutOk.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_SKYPE)) {
        //  ?  ?
        skype_app = mSettings.getString(APP_PREFERENCES_SKYPE, null);
        LinearLayoutSkype.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_WHATSAPP)) {
        //  ?  ?
        whatsapp_app = mSettings.getString(APP_PREFERENCES_WHATSAPP, null);
        LinearLayoutWhatsapp.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_TWITTER)) {
        //  ?  ?
        twitter_app = mSettings.getString(APP_PREFERENCES_TWITTER, null);
        LinearLayoutTwitter.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_FACEBOOK)) {
        //  ?  ?
        facebook_app = mSettings.getString(APP_PREFERENCES_FACEBOOK, null);
        LinearLayoutFacebook.setVisibility(View.VISIBLE);
    }

    if (mSettings.contains(APP_PREFERENCES_INSTAGRAM)) {
        //  ?  ?
        instagram_app = mSettings.getString(APP_PREFERENCES_INSTAGRAM, null);
        LinearLayoutInstagram.setVisibility(View.VISIBLE);
    }
    /*
     if (mSettings.contains(APP_PREFERENCES_tgb_apn)) {
    //  ?  ?
       Boolean apn = mSettings.getBoolean(APP_PREFERENCES_tgb_apn, true);
    if (apn == true){
    LinearLayoutApn.setVisibility(View.VISIBLE);}
    else
       LinearLayoutApn.setVisibility(View.GONE);
    }
             
     if (mSettings.contains(APP_PREFERENCES_tgb_passcode)) {
    //  ?  ?
    Boolean passcode = mSettings.getBoolean(APP_PREFERENCES_tgb_passcode, true);
    if (passcode == true){
    LinearLayoutPasscode.setVisibility(View.VISIBLE);}
    else
       LinearLayoutPasscode.setVisibility(View.GONE);
     }
             
     if (mSettings.contains(APP_PREFERENCES_tgb_privacy)) {
    //  ?  ?
    Boolean privacy = mSettings.getBoolean(APP_PREFERENCES_tgb_privacy, true);
    if (privacy == true){
    LinearLayoutPrivacy.setVisibility(View.VISIBLE);}
    else
       LinearLayoutPrivacy.setVisibility(View.GONE);
    }
     */
    if (mSettings.contains(APP_PREFERENCES_bold_text)) {
        //  ?  ?
        Boolean bold = mSettings.getBoolean(APP_PREFERENCES_bold_text, true);
        if (bold == true) {
            btn_avia.setTypeface(typefaceBold);
            btn_wifi.setTypeface(typefaceBold);

            if (bt != null) {
                btn_bluetooth.setTypeface(typefaceBold);
                textbt.setTypeface(typefaceBold);
            }
            btn_battery.setTypeface(typefaceBold);
            btn_sota.setTypeface(typefaceBold);
            btn_operator.setTypeface(typefaceBold);
            btn_osnova.setTypeface(typefaceBold);
            btn_passcode.setTypeface(typefaceBold);
            btn_privacy.setTypeface(typefaceBold);
            btn_zvuki.setTypeface(typefaceBold);
            btn_oboi.setTypeface(typefaceBold);
            btn_notification.setTypeface(typefaceBold);
            btn_control.setTypeface(typefaceBold);
            btn_disturb.setTypeface(typefaceBold);
            btn_gps.setTypeface(typefaceBold);
            btn_mail.setTypeface(typefaceBold);
            btn_notes.setTypeface(typefaceBold);
            btn_messages.setTypeface(typefaceBold);
            btn_phone.setTypeface(typefaceBold);
            btn_safari.setTypeface(typefaceBold);
            btn_music.setTypeface(typefaceBold);
            btn_compass.setTypeface(typefaceBold);
            btn_weather.setTypeface(typefaceBold);
            btn_games.setTypeface(typefaceBold);
            btn_new1.setTypeface(typefaceBold);
            btn_new2.setTypeface(typefaceBold);
            btn_new3.setTypeface(typefaceBold);
            btn_new4.setTypeface(typefaceBold);
            btn_vpn.setTypeface(typefaceBold);
            btn_display.setTypeface(typefaceBold);
            textwifi.setTypeface(typefaceBold);
            TextOper.setTypeface(typefaceBold);
            btn_iCloud.setTypeface(typefaceBold);
            btn_iTunes.setTypeface(typefaceBold);
            textView1.setTypeface(typefaceBold);
            textView2.setTypeface(typefaceBold);
            textView3.setTypeface(typefaceBold);
            textVPN.setTypeface(typefaceBold);
            btn_maps.setTypeface(typefaceBold);
            btn_vk.setTypeface(typefaceBold);
            btn_viber.setTypeface(typefaceBold);
            btn_ok.setTypeface(typefaceBold);
            btn_skype.setTypeface(typefaceBold);
            btn_whatsapp.setTypeface(typefaceBold);
            btn_twitter.setTypeface(typefaceBold);
            btn_facebook.setTypeface(typefaceBold);
            btn_instagram.setTypeface(typefaceBold);

        }
    }

    int speed = mSettings.getInt(APP_PREFERENCES_ANIM_SPEED, 1);
    if (speed == 1) {
        center_to_right = R.anim.slide_center_to_right_short;
        center_to_right2 = R.anim.slide_center_to_right2_short;
        center_to_left = R.anim.slide_center_to_left_short;
        center_to_left2 = R.anim.slide_center_to_left2_short;
    }
    if (speed == 2) {
        center_to_right = R.anim.slide_center_to_right_medium;
        center_to_right2 = R.anim.slide_center_to_right2_medium;
        center_to_left = R.anim.slide_center_to_left_medium;
        center_to_left2 = R.anim.slide_center_to_left2_medium;
    }
    if (speed == 3) {
        center_to_right = R.anim.slide_center_to_right_long;
        center_to_right2 = R.anim.slide_center_to_right2_long;
        center_to_left = R.anim.slide_center_to_left_long;
        center_to_left2 = R.anim.slide_center_to_left2_long;
    }

    if (mSettings.contains(APP_PREFERENCES_text_size)) {
        //  ?  ?
        String size = mSettings.getString(APP_PREFERENCES_text_size, null);
        if (size.contains("Small")) {
            btn_avia.setTextSize(13);
            btn_wifi.setTextSize(13);

            if (bt != null) {
                btn_bluetooth.setTextSize(13);
                textbt.setTextSize(13);
            }
            btn_battery.setTextSize(13);
            btn_sota.setTextSize(13);
            btn_operator.setTextSize(13);
            btn_osnova.setTextSize(13);
            btn_passcode.setTextSize(13);
            btn_privacy.setTextSize(13);
            btn_zvuki.setTextSize(13);
            btn_oboi.setTextSize(13);
            btn_notification.setTextSize(13);
            btn_control.setTextSize(13);
            btn_disturb.setTextSize(13);
            btn_gps.setTextSize(13);
            btn_mail.setTextSize(13);
            btn_notes.setTextSize(13);
            btn_messages.setTextSize(13);
            btn_phone.setTextSize(13);
            btn_safari.setTextSize(13);
            btn_music.setTextSize(13);
            btn_compass.setTextSize(13);
            btn_weather.setTextSize(13);
            btn_games.setTextSize(13);
            btn_new1.setTextSize(13);
            btn_new2.setTextSize(13);
            btn_new3.setTextSize(13);
            btn_new4.setTextSize(13);
            btn_vpn.setTextSize(13);
            btn_display.setTextSize(13);
            textwifi.setTextSize(13);
            TextOper.setTextSize(13);
            btn_iCloud.setTextSize(13);
            btn_iTunes.setTextSize(13);
            textView1.setTextSize(13);
            textView2.setTextSize(9);
            textView3.setTextSize(12);
            textVPN.setTextSize(13);
            btn_maps.setTextSize(13);
            btn_vk.setTextSize(13);
            btn_viber.setTextSize(13);
            btn_ok.setTextSize(13);
            btn_skype.setTextSize(13);
            btn_whatsapp.setTextSize(13);
            btn_twitter.setTextSize(13);
            btn_facebook.setTextSize(13);
            btn_instagram.setTextSize(13);

        }
        if (size.contains("Normal")) {
            btn_avia.setTextSize(15);
            btn_wifi.setTextSize(15);

            if (bt != null) {
                btn_bluetooth.setTextSize(15);
                textbt.setTextSize(15);
            }
            btn_battery.setTextSize(15);
            btn_sota.setTextSize(15);
            btn_operator.setTextSize(15);
            btn_osnova.setTextSize(15);
            btn_passcode.setTextSize(15);
            btn_privacy.setTextSize(15);
            btn_zvuki.setTextSize(15);
            btn_oboi.setTextSize(15);
            btn_notification.setTextSize(15);
            btn_control.setTextSize(15);
            btn_disturb.setTextSize(15);
            btn_gps.setTextSize(15);
            btn_mail.setTextSize(15);
            btn_notes.setTextSize(15);
            btn_messages.setTextSize(15);
            btn_phone.setTextSize(15);
            btn_safari.setTextSize(15);
            btn_music.setTextSize(15);
            btn_compass.setTextSize(15);
            btn_weather.setTextSize(15);
            btn_games.setTextSize(15);
            btn_new1.setTextSize(15);
            btn_new2.setTextSize(15);
            btn_new3.setTextSize(15);
            btn_new4.setTextSize(15);
            btn_vpn.setTextSize(15);
            btn_display.setTextSize(15);
            textwifi.setTextSize(15);
            TextOper.setTextSize(15);
            btn_iCloud.setTextSize(15);
            btn_iTunes.setTextSize(15);
            //textView1.setTextSize(15);
            //textView2.setTextSize(11);
            textView3.setTextSize(13);
            textVPN.setTextSize(15);
            btn_maps.setTextSize(15);
            btn_vk.setTextSize(15);
            btn_viber.setTextSize(15);
            btn_ok.setTextSize(15);
            btn_skype.setTextSize(15);
            btn_whatsapp.setTextSize(15);
            btn_twitter.setTextSize(15);
            btn_facebook.setTextSize(15);
            btn_instagram.setTextSize(15);

        }
        if (size.contains("Large")) {
            btn_avia.setTextSize(18);
            btn_wifi.setTextSize(18);

            if (bt != null) {
                btn_bluetooth.setTextSize(18);
                textbt.setTextSize(18);
            }
            btn_battery.setTextSize(18);
            btn_sota.setTextSize(18);
            btn_operator.setTextSize(18);
            btn_osnova.setTextSize(18);
            btn_passcode.setTextSize(18);
            btn_privacy.setTextSize(18);
            btn_zvuki.setTextSize(18);
            btn_oboi.setTextSize(18);
            btn_notification.setTextSize(18);
            btn_control.setTextSize(18);
            btn_disturb.setTextSize(18);
            btn_gps.setTextSize(18);
            btn_mail.setTextSize(18);
            btn_notes.setTextSize(18);
            btn_messages.setTextSize(18);
            btn_phone.setTextSize(18);
            btn_safari.setTextSize(18);
            btn_music.setTextSize(18);
            btn_compass.setTextSize(18);
            btn_weather.setTextSize(18);
            btn_games.setTextSize(18);
            btn_new1.setTextSize(18);
            btn_new2.setTextSize(18);
            btn_new3.setTextSize(18);
            btn_new4.setTextSize(18);
            btn_vpn.setTextSize(18);
            btn_display.setTextSize(18);
            textwifi.setTextSize(18);
            TextOper.setTextSize(18);
            btn_iCloud.setTextSize(18);
            btn_iTunes.setTextSize(18);
            //textView1.setTextSize(18);
            //textView2.setTextSize(13);
            textView3.setTextSize(17);
            textVPN.setTextSize(18);
            btn_maps.setTextSize(18);
            btn_vk.setTextSize(18);
            btn_viber.setTextSize(18);
            btn_ok.setTextSize(18);
            btn_skype.setTextSize(18);
            btn_whatsapp.setTextSize(18);
            btn_twitter.setTextSize(18);
            btn_facebook.setTextSize(18);
            btn_instagram.setTextSize(18);

        }
        if (size.contains("xLarge")) {
            btn_avia.setTextSize(20);
            btn_wifi.setTextSize(20);

            if (bt != null) {
                btn_bluetooth.setTextSize(20);
                textbt.setTextSize(20);
            }
            btn_battery.setTextSize(20);
            btn_sota.setTextSize(20);
            btn_operator.setTextSize(20);
            btn_osnova.setTextSize(20);
            btn_passcode.setTextSize(20);
            btn_privacy.setTextSize(20);
            btn_zvuki.setTextSize(20);
            btn_oboi.setTextSize(20);
            btn_notification.setTextSize(20);
            btn_control.setTextSize(20);
            btn_disturb.setTextSize(20);
            btn_gps.setTextSize(20);
            btn_mail.setTextSize(20);
            btn_notes.setTextSize(20);
            btn_messages.setTextSize(20);
            btn_phone.setTextSize(20);
            btn_safari.setTextSize(20);
            btn_music.setTextSize(20);
            btn_compass.setTextSize(20);
            btn_weather.setTextSize(20);
            btn_games.setTextSize(20);
            btn_new1.setTextSize(20);
            btn_new2.setTextSize(20);
            btn_new3.setTextSize(20);
            btn_new4.setTextSize(20);
            btn_vpn.setTextSize(20);
            btn_display.setTextSize(20);
            textwifi.setTextSize(20);
            TextOper.setTextSize(20);
            btn_iCloud.setTextSize(20);
            btn_iTunes.setTextSize(20);
            //textView1.setTextSize(20);
            //textView2.setTextSize(15);
            textView3.setTextSize(18);
            textVPN.setTextSize(20);
            btn_maps.setTextSize(20);
            btn_vk.setTextSize(20);
            btn_viber.setTextSize(20);
            btn_ok.setTextSize(20);
            btn_skype.setTextSize(20);
            btn_whatsapp.setTextSize(20);
            btn_twitter.setTextSize(20);
            btn_facebook.setTextSize(20);
            btn_instagram.setTextSize(20);

        }
    }
    ifest();
    /*}
    catch(Exception e){
      StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String stacktrace = sw.toString();
            
        // CREATE AN EMAIL INTENT TO SEND TO YOURSELF
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "maxim.khaydarov@yandex.ru" });
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "On Resume BUG REPORT");
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, stacktrace);
            
        // START THE EMAIL ACTIVITY - NOTE YOU NEED TO START IT WITH A CHOOSER
        startActivity(Intent.createChooser(emailIntent, "Send error report..."));
    }*/
}

From source file:com.tcs.geofenceplugin.GeofenceTransitionsIntentService.java

private void getGeofenceTransitionDetails(Context context, int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    ArrayList triggeringGeofencesIdsList = new ArrayList();
    Handler mHandler = new Handler();
    for (Geofence geofence : triggeringGeofences) {

        String geofenceTransitionString = getTransitionString(geofenceTransition);
        geofenceTransitionString += geofence.getRequestId();
        URL url;/*  w w  w .j  a v  a  2 s.c  o m*/
        HttpURLConnection urlConnection = null;
        JSONArray response = new JSONArray();
        String notificationtext = "";
        String place = "";
        String startdate = "";
        String enddate = "";
        JSONObject obj = new JSONObject();
        try {
            int restid = Integer.parseInt(geofence.getRequestId());
            url = new URL("https://apphonics.tcs.com/geofence/SelectTrigger?triggerid=" + restid);
            urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("GET");

            urlConnection.connect();
            int responseCode = urlConnection.getResponseCode();
            Log.d("Komal3", responseCode + "");

            if (responseCode == 200) {

                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(urlConnection.getInputStream(), "utf-8"));
                StringBuilder sb = new StringBuilder();
                try {

                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }

                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (reader != null) {
                        try {
                            reader.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }

                obj = new JSONObject(sb.toString());
                JSONArray arr = obj.getJSONArray("notificationdata");

                for (int i = 0; i < arr.length(); i++) {
                    JSONObject O = arr.getJSONObject(i);
                    notificationtext = O.getString("notification_text");
                    place = O.getString("place");
                    startdate = O.getString("startdate");
                    enddate = O.getString("enddate");
                }
                //response = new JSONArray(responseString);
            } else {
                Log.d(TAG, "Response code:" + responseCode);
            }

        } catch (Exception e) {
            e.printStackTrace();
            if (urlConnection != null)
                urlConnection.disconnect();
        }

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date datestart, dateend;
        try {
            datestart = format.parse(startdate);
            dateend = format2.parse(enddate);
            if (datestart.compareTo(new Date()) <= 0 && dateend.compareTo(new Date()) >= 0) {
                sendNotification(geofenceTransitionString, notificationtext, place);
            }

            mHandler.postDelayed(new Runnable() {
                public void run() {

                }
            }, 5000);

        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

}

From source file:org.witness.ssc.xfer.utils.PublishingUtils.java

public Thread videoUploadToFTPserver(final Activity activity, final Handler handler,
        final String latestVideoFile_filename, final String latestVideoFile_absolutepath,
        final String emailAddress, final long sdrecord_id) {

    Log.d(TAG, "doVideoFTP starting");

    // Make the progress bar view visible.
    ((SSCXferActivity) activity).startedUploading();

    final Resources res = activity.getResources();

    Thread t = new Thread(new Runnable() {
        public void run() {
            // Do background task.
            // FTP; connect preferences here!
            ////from  w ww  .  ja va2  s.co  m
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
            String ftpHostName = prefs.getString("defaultFTPhostPreference", null);
            String ftpUsername = prefs.getString("defaultFTPusernamePreference", null);
            String ftpPassword = prefs.getString("defaultFTPpasswordPreference", null);

            // use name of local file.
            String ftpRemoteFtpFilename = latestVideoFile_filename;

            // FTP
            FTPClient ftpClient = new FTPClient();
            InetAddress uploadhost = null;
            try {

                uploadhost = InetAddress.getByName(ftpHostName);
            } catch (UnknownHostException e1) {
                // If DNS resolution fails then abort immediately - show
                // dialog to
                // inform user first.
                e1.printStackTrace();
                Log.e(TAG, " got exception resolving " + ftpHostName + " - video uploading failed.");
                uploadhost = null;
            }

            if (uploadhost == null) {

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                        new AlertDialog.Builder(activity).setMessage(R.string.cant_find_upload_host)
                                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {

                                    }
                                })

                                .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {

                                    }
                                }).show();

                    }
                }, 0);

                return;
            }

            boolean connected = false;

            try {
                ftpClient.connect(uploadhost);
                connected = true;

            } catch (SocketException e) {
                e.printStackTrace();
                connected = false;

            } catch (UnknownHostException e) {
                //
                e.printStackTrace();
                connected = false;
            } catch (IOException e) {
                //
                e.printStackTrace();
                connected = false;
            }

            if (!connected) {

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                        new AlertDialog.Builder(activity).setMessage(R.string.cant_login_upload_host)
                                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {

                                    }
                                })

                                .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {

                                    }
                                }).show();

                    }
                }, 0);

                return;
            }

            boolean reply = false;
            try {

                reply = ftpClient.login(ftpUsername, ftpPassword);
            } catch (IOException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on ftp.login - video uploading failed.");
            }

            // check the reply code here
            // If we cant login, abort after showing user a dialog.
            if (!reply) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    //
                    e.printStackTrace();
                }

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                        new AlertDialog.Builder(activity).setMessage(R.string.cant_login_upload_host)
                                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {

                                    }
                                }).show();
                    }
                }, 0);

                return;
            }

            // Set File type to binary
            try {
                ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
            } catch (IOException e) {
                //
                e.printStackTrace();
                // keep going?!
            }

            // BEYOND HERE DONT USE DIALOGS!

            // Construct the input stream to send to Ftp server, from the
            // local
            // video file on the sd card
            BufferedInputStream buffIn = null;
            File file = new File(latestVideoFile_absolutepath);

            try {
                buffIn = new BufferedInputStream(new FileInputStream(file));
            } catch (FileNotFoundException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on local video file - video uploading failed.");

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                    }
                }, 0);

                // This is a bad error, lets abort.
                // user dialog ?! shouldnt happen, but still...
                return;
            }

            ftpClient.enterLocalPassiveMode();

            try {
                // UPLOAD THE LOCAL VIDEO FILE.
                ftpClient.storeFile(ftpRemoteFtpFilename, buffIn);
            } catch (IOException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on storeFile - video uploading failed.");

                // This is a bad error, lets abort.
                // user dialog ?! shouldnt happen, but still...
                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                    }
                }, 0);
                return;
            }
            try {
                buffIn.close();
            } catch (IOException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on buff.close - video uploading failed.");

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                    }
                }, 0);
                return;
            }
            try {
                ftpClient.logout();
            } catch (IOException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on ftp logout - video uploading failed.");

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                    }
                }, 0);
                return;
            }
            try {
                ftpClient.disconnect();
            } catch (IOException e) {
                //
                e.printStackTrace();
                Log.e(TAG, " got exception on ftp disconnect - video uploading failed.");

                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Hide the progress bar
                        ((SSCXferActivity) activity).finishedUploading(false);
                        ((SSCXferActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_ftp_host_failed_));

                    }
                }, 0);
                return;
            }

            if (emailAddress != null && ftpHostName != null) {

                // EmailSender through IR controlled gmail system.
                SSLEmailSender sender = new SSLEmailSender(
                        activity.getString(R.string.automatic_email_username),
                        activity.getString(R.string.automatic_email_password)); // consider
                // this
                // public
                // knowledge.
                try {
                    sender.sendMail(activity.getString(R.string.vidiom_automatic_email), // subject.getText().toString(),
                            activity.getString(R.string.url_of_hosted_video_is_) + " " + ftpHostName, // body.getText().toString(),
                            activity.getString(R.string.automatic_email_from), // from.getText().toString(),
                            emailAddress // to.getText().toString()
                    );
                } catch (Exception e) {
                    Log.e(TAG, e.getMessage(), e);
                }
            }

            // Log record of this URL in POSTs table
            dbutils.creatHostDetailRecordwithNewVideoUploaded(sdrecord_id, ftpHostName, ftpHostName, "");

            // Use the handler to execute a Runnable on the
            // main thread in order to have access to the
            // UI elements.
            handler.postDelayed(new Runnable() {
                public void run() {
                    // Update UI

                    // Indicate back to calling activity the result!
                    // update uploadInProgress state also.

                    ((SSCXferActivity) activity).finishedUploading(true);
                    ((SSCXferActivity) activity)
                            .createNotification(res.getString(R.string.upload_to_ftp_host_succeeded_));

                }
            }, 0);

        }
    });

    t.start();

    return t;
}

From source file:com.aimfire.demo.CamcorderActivity.java

private void handleRecordingStop(final String filepath) {
    mMpegFilepath = filepath;/*from www .j  a va2s .  c om*/

    if (!mInSync || mIsLeft) {
        /*
         * add audio/visual indication. shutter sound is delayed to avoid recording it
         */
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                playShutterSound(false);
            }
        }, 500);
        mCaptureButton.setImageResource(R.drawable.ic_videocam_black_24dp);

        stopRecordingAnim();
    }
}

From source file:com.abhijitvalluri.android.fitnotifications.setup.AppIntroActivity.java

private void addDemoSlide() {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean dismissPlaceholderNotif = preferences
            .getBoolean(getString(R.string.dismiss_placeholder_notif_key), false);
    final int placeholderNotifDismissDelayMillis = preferences
            .getInt(getString(R.string.placeholder_dismiss_delay_key), Constants.DEFAULT_DELAY_SECONDS) * 1000;
    final Handler handler = new Handler();

    // Demo/*from w  ww .ja v  a2s. c o m*/
    addSlide(new SimpleSlide.Builder().layout(R.layout.fragment_intro).title(R.string.intro_done_title)
            .description(R.string.intro_done_desc).image(R.drawable.intro_done).background(R.color.colorAccent)
            .backgroundDark(R.color.colorAccentDark).buttonCtaLabel(R.string.test_notification)
            .buttonCtaClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Bundle newExtra = new Bundle();

                    NotificationCompat.Builder builder = new NotificationCompat.Builder(AppIntroActivity.this);
                    String notificationText = "Sample notification subject";
                    String notificationBigText = "Sample notification body. This is where the details of the notification will be shown.";

                    StringBuilder sb = new StringBuilder();
                    sb.append("[").append("example").append("] ");
                    sb.append(notificationText);
                    if (notificationBigText.length() > 0) {
                        sb.append(" -- ").append(notificationBigText);
                    }

                    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
                    contentView.setTextViewText(R.id.customNotificationText,
                            getString(R.string.placeholder_notification_text));
                    builder.setSmallIcon(R.drawable.ic_sms_white_24dp).setContentText(sb.toString())
                            .setExtras(newExtra).setContentTitle("Sample Notification Title")
                            .setContent(contentView);

                    // Creates an explicit intent for the SettingsActivity in the app
                    Intent settingsIntent = new Intent(AppIntroActivity.this, SettingsActivity.class);

                    // The stack builder object will contain an artificial back stack for the
                    // started Activity.
                    // This ensures that navigating backward from the Activity leads out of
                    // the application to the Home screen.
                    TaskStackBuilder stackBuilder = TaskStackBuilder.create(AppIntroActivity.this);
                    // Adds the back stack for the Intent (but not the Intent itself)
                    stackBuilder.addParentStack(SettingsActivity.class);
                    // Adds the Intent that starts the Activity to the top of the stack
                    stackBuilder.addNextIntent(settingsIntent);
                    PendingIntent settingsPendingIntent = stackBuilder.getPendingIntent(0,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    builder.setContentIntent(settingsPendingIntent).setAutoCancel(true);

                    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID,
                            builder.build());

                    Toast.makeText(AppIntroActivity.this, getString(R.string.test_notification_sent),
                            Toast.LENGTH_LONG).show();

                    if (dismissPlaceholderNotif) {
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
                                        .cancel(NOTIFICATION_ID);
                            }
                        }, placeholderNotifDismissDelayMillis);
                    }
                }
            }).build());
}

From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java

private void setupBTabSelectionClosestDock(final Place _from) {

    dismissOnboardingHint();//from w  w w.  j  a v a2  s.  c o  m

    //Remove any previous selection
    getListPagerAdapter().removeStationHighlightForPage(StationListPagerAdapter.DOCK_STATIONS);

    if (mTripDetailsWidget.getVisibility() == View.INVISIBLE) {
        mStationMapFragment
                .setMapPaddingLeft((int) getResources().getDimension(R.dimen.trip_details_widget_width));
        setupTripDetailsWidget();
        showTripDetailsWidget();
    } else {
        hideSetupShowTripDetailsWidget();
    }

    getListPagerAdapter().setupUI(StationListPagerAdapter.DOCK_STATIONS,
            RootApplication.getBikeNetworkStationList(), true, R.drawable.ic_destination_arrow_white_24dp,
            R.drawable.ic_pin_search_24dp_white, "",
            new StationRecyclerViewAdapter.TotalTripTimeComparator(Utils.getAverageWalkingSpeedKmh(this),
                    Utils.getAverageBikingSpeedKmh(this), mCurrentUserLatLng,
                    mStationMapFragment.getMarkerALatLng(), _from.getLatLng()));

    mStationMapFragment.setMapPaddingRight((int) getResources().getDimension(R.dimen.map_fab_padding));
    mClearFAB.show();
    mFavoritesSheetFab.hideSheetThenFab();
    mSearchFAB.hide();

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {

            if (getListPagerAdapter().isRecyclerViewReadyForItemSelection(StationListPagerAdapter.DOCK_STATIONS)
                    && mRedrawMarkersTask == null) {
                //highlight B station in list

                //the following is why the handler is required (to let time for things to settle after calling getListPagerAdapter().setupUI)
                String stationId = Utils.extractClosestAvailableStationIdFromProcessedString(
                        getListPagerAdapter().retrieveClosestRawIdAndAvailability(false));

                getListPagerAdapter().hideStationRecap();
                mStationMapFragment.setPinOnStation(false, stationId);//set B pin on closest station with available dock
                getListPagerAdapter().highlightStationForPage(stationId, StationListPagerAdapter.DOCK_STATIONS);
                getListPagerAdapter().setClickResponsivenessForPage(StationListPagerAdapter.BIKE_STATIONS,
                        true);

                mStationMapFragment.setPinForPickedPlace(_from.getName().toString(), _from.getLatLng(),
                        _from.getAttributions());

                mStationMapFragment
                        .setMapPaddingRight((int) getResources().getDimension(R.dimen.map_infowindow_padding));
                animateCameraToShow((int) getResources().getDimension(R.dimen.camera_search_infowindow_padding),
                        _from.getLatLng(), mStationMapFragment.getMarkerBVisibleLatLng(), null);

                getListPagerAdapter().smoothScrollHighlightedInViewForPage(
                        StationListPagerAdapter.DOCK_STATIONS, isAppBarExpanded());
            } else { //This is a repost if RecyclerView is not ready for selection

                //hackfix. On some devices timing issues led to infinite loop with isRecyclerViewReadyForItemSelection always returning false
                //so, retry setting up the UI before repost
                //Replace recyclerview content
                getListPagerAdapter().setupUI(StationListPagerAdapter.DOCK_STATIONS,
                        RootApplication.getBikeNetworkStationList(), true,
                        R.drawable.ic_destination_arrow_white_24dp, R.drawable.ic_pin_search_24dp_white, "",
                        new StationRecyclerViewAdapter.TotalTripTimeComparator(
                                Utils.getAverageWalkingSpeedKmh(NearbyActivity.this),
                                Utils.getAverageBikingSpeedKmh(NearbyActivity.this), mCurrentUserLatLng,
                                mStationMapFragment.getMarkerALatLng(), _from.getLatLng()));
                //end hackfix

                handler.postDelayed(this, 10);
            }
        }
    }, 10);
}

From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java

private void setupBTabSelectionClosestDock(final String _favoriteId) {

    dismissOnboardingHint();//ww w  . j  a v  a  2 s . co  m

    //Remove any previous selection
    getListPagerAdapter().removeStationHighlightForPage(StationListPagerAdapter.DOCK_STATIONS);

    //Silent parameter is ignored because widget needs refresh
    //TODO: find a more elegant solution than this damn _silent boolean, which is a hackfix - probably a refactor by splitting method in pieces
    //and call them independently as required from client
    if (mTripDetailsWidget.getVisibility() == View.INVISIBLE) {
        mStationMapFragment
                .setMapPaddingLeft((int) getResources().getDimension(R.dimen.trip_details_widget_width));
        setupTripDetailsWidget();
        showTripDetailsWidget();
    } else {
        hideSetupShowTripDetailsWidget();
    }

    final FavoriteItemBase favorite = DBHelper.getFavoriteItemForId(this, _favoriteId);

    getListPagerAdapter().setupUI(StationListPagerAdapter.DOCK_STATIONS,
            RootApplication.getBikeNetworkStationList(), true, R.drawable.ic_destination_arrow_white_24dp,
            R.drawable.ic_pin_favorite_24dp_white, "",
            new StationRecyclerViewAdapter.TotalTripTimeComparator(Utils.getAverageWalkingSpeedKmh(this),
                    Utils.getAverageBikingSpeedKmh(this), mCurrentUserLatLng,
                    mStationMapFragment.getMarkerALatLng(),
                    favorite.getLocation() != null ? favorite.getLocation()
                            : getLatLngForStation(favorite.getId())));

    mStationMapFragment.setMapPaddingRight((int) getResources().getDimension(R.dimen.map_fab_padding));
    mClearFAB.show();
    mFavoritesSheetFab.hideSheetThenFab();
    mSearchFAB.hide();

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {

            if (getListPagerAdapter()
                    .isRecyclerViewReadyForItemSelection(StationListPagerAdapter.DOCK_STATIONS)) {
                //highlight B station in list

                //the following is why the handler is required (to let time for things to settle after calling getListPagerAdapter().setupUI)
                String stationId = Utils.extractClosestAvailableStationIdFromProcessedString(
                        getListPagerAdapter().retrieveClosestRawIdAndAvailability(false));

                getListPagerAdapter().hideStationRecap();
                mStationMapFragment.setPinOnStation(false, stationId);//set B pin on closest station with available dock
                getListPagerAdapter().highlightStationForPage(stationId, StationListPagerAdapter.DOCK_STATIONS);
                getListPagerAdapter().setClickResponsivenessForPage(StationListPagerAdapter.BIKE_STATIONS,
                        true);

                if (!stationId.equalsIgnoreCase(favorite.getId())) {
                    //This is a three legged journey (either to a favorite station that has no dock or a place)

                    LatLng location = favorite.getLocation() != null ? favorite.getLocation()
                            : getLatLngForStation(favorite.getId());

                    mStationMapFragment.setPinForPickedFavorite(favorite.getDisplayName(), location,
                            favorite.getAttributions());

                    mStationMapFragment.setMapPaddingRight(
                            (int) getResources().getDimension(R.dimen.map_infowindow_padding));
                    animateCameraToShow(
                            (int) getResources().getDimension(R.dimen.camera_search_infowindow_padding),
                            location, mStationMapFragment.getMarkerBVisibleLatLng(), null);
                } else //trip to a favorite station that has docks
                {
                    mStationMapFragment
                            .setPinForPickedFavorite(favorite.getDisplayName(),
                                    favorite.getLocation() != null ? favorite.getLocation()
                                            : getLatLngForStation(favorite.getId()),
                                    favorite.getAttributions());
                    mStationMapFragment.animateCamera(CameraUpdateFactory
                            .newLatLngZoom(mStationMapFragment.getMarkerBVisibleLatLng(), 15));
                }

                getListPagerAdapter().smoothScrollHighlightedInViewForPage(
                        StationListPagerAdapter.DOCK_STATIONS, isAppBarExpanded());

            } else { //This is a repost if RecyclerView is not ready for selection

                //hackfix. On some devices timing issues led to infinite loop with isRecyclerViewReadyForItemSelection always returning false
                //so, retry stting up the UI before repost
                //Replace recyclerview content
                getListPagerAdapter().setupUI(StationListPagerAdapter.DOCK_STATIONS,
                        RootApplication.getBikeNetworkStationList(), true,
                        R.drawable.ic_destination_arrow_white_24dp, R.drawable.ic_pin_favorite_24dp_white, "",
                        new StationRecyclerViewAdapter.TotalTripTimeComparator(
                                Utils.getAverageWalkingSpeedKmh(NearbyActivity.this),
                                Utils.getAverageBikingSpeedKmh(NearbyActivity.this), mCurrentUserLatLng,
                                mStationMapFragment.getMarkerALatLng(),
                                favorite.getLocation() != null ? favorite.getLocation()
                                        : getLatLngForStation(favorite.getId())));
                //end hackfix

                handler.postDelayed(this, 10);
            }
        }
    }, 10);
}