Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.msn.support.gallery.ZoomActivity.java

/**
 * "Zooms" in a thumbnail view by assigning the high resolution image to a hidden "zoomed-in"
 * image view and animating its bounds to fit the entire activity content area. More
 * specifically://from ww  w . j a  v  a 2  s  . c  om
 * <ol>
 *   <li>Assign the high-res image to the hidden "zoomed-in" (expanded) image view.</li>
 *   <li>Calculate the starting and ending bounds for the expanded view.</li>
 *   <li>Animate each of four positioning/sizing properties (X, Y, SCALE_X, SCALE_Y)
 *       simultaneously, from the starting bounds to the ending bounds.</li>
 *   <li>Zoom back out by running the reverse animation on click.</li>
 * </ol>
 * ??ImageView?
 * Activity
 * <ol>
 *     <li>???ImageView</li>
 *     <li>?ImageView?</li>
 *     <li>??ImageView?/?X, Y, SCALE_X, SCALE_Y
 *     ??</li>
 *     <li>???</li>
 * @param thumbView  The thumbnail view to zoom in. 
 * @param imageResId The high-resolution version of the image represented by the thumbnail.
 *                   
 */
@TargetApi(11)
private void zoomImageFromThumb(final View thumbView, int imageResId) {
    // If there's an animation in progress, cancel it immediately and proceed with this one.
    // ?
    if (mCurrentAnimator != null) {
        mCurrentAnimator.cancel();
    }

    // Load the high-resolution "zoomed-in" image.?ImageView
    final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image);
    expandedImageView.setImageResource(imageResId);

    // Calculate the starting and ending bounds for the zoomed-in image. This step
    // involves lots of math. Yay, math.
    //?ImageView??
    final Rect startBounds = new Rect();
    final Rect finalBounds = new Rect();
    final Point globalOffset = new Point();

    // The start bounds are the global visible rectangle of the thumbnail, and the
    // final bounds are the global visible rectangle of the container view. Also
    // set the container view's offset as the origin for the bounds, since that's
    // the origin for the positioning animation properties (X, Y).
    // ?????
    // ????
    thumbView.getGlobalVisibleRect(startBounds);
    findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset);
    Log.e("Test", "globalOffset.x=" + globalOffset.x + " globalOffset.y=" + globalOffset.y);
    Log.e("Test", "startBounds.top=" + startBounds.top + " startBounds.left=" + startBounds.left);
    startBounds.offset(-globalOffset.x, -globalOffset.y);
    Log.e("Test", "startBounds2.top=" + startBounds.top + " startBounds2.left=" + startBounds.left);
    finalBounds.offset(-globalOffset.x, -globalOffset.y);

    // Adjust the start bounds to be the same aspect ratio as the final bounds using the
    // "center crop" technique. This prevents undesirable stretching during the animation.
    // Also calculate the start scaling factor (the end scaling factor is always 1.0).
    // ??"center crop"???
    // ????1.0
    float startScale;
    if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width()
            / startBounds.height()) {
        // Extend start bounds horizontally ?
        startScale = (float) startBounds.height() / finalBounds.height();
        float startWidth = startScale * finalBounds.width();
        float deltaWidth = (startWidth - startBounds.width()) / 2;
        startBounds.left -= deltaWidth;
        startBounds.right += deltaWidth;
    } else {
        // Extend start bounds vertically ?
        startScale = (float) startBounds.width() / finalBounds.width();
        float startHeight = startScale * finalBounds.height();
        float deltaHeight = (startHeight - startBounds.height()) / 2;
        startBounds.top -= deltaHeight;
        startBounds.bottom += deltaHeight;
    }

    // Hide the thumbnail and show the zoomed-in view. When the animation begins,
    // it will position the zoomed-in view in the place of the thumbnail.
    //thumbView.setAlpha(0f);
    expandedImageView.setVisibility(View.VISIBLE);

    // Set the pivot point for SCALE_X and SCALE_Y transformations to the top-left corner of
    // the zoomed-in view (the default is the center of the view).
    expandedImageView.setPivotX(0f);
    expandedImageView.setPivotY(0f);

    // Construct and run the parallel animation of the four translation and scale properties
    // (X, Y, SCALE_X, and SCALE_Y).
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left))
            .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top))
            .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f))
            .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f));
    set.setDuration(mShortAnimationDuration);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mCurrentAnimator = null;
        }
    });
    set.start();
    mCurrentAnimator = set;

    // Upon clicking the zoomed-in image, it should zoom back down to the original bounds
    // and show the thumbnail instead of the expanded image.
    final float startScaleFinal = startScale;
    expandedImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentAnimator != null) {
                mCurrentAnimator.cancel();
            }

            // Animate the four positioning/sizing properties in parallel, back to their
            // original values.
            AnimatorSet set = new AnimatorSet();
            set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left))
                    .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top))
                    .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal))
                    .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal));
            set.setDuration(mShortAnimationDuration);
            set.setInterpolator(new DecelerateInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    thumbView.setAlpha(1f);
                    expandedImageView.setVisibility(View.GONE);
                    mCurrentAnimator = null;
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    thumbView.setAlpha(1f);
                    expandedImageView.setVisibility(View.GONE);
                    mCurrentAnimator = null;
                }
            });
            set.start();
            mCurrentAnimator = set;
        }
    });
}

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

protected void onResume() {
    super.onResume();
    // try{//from w  w  w .  j a v a 2 s  . co m
    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.yaniv.online.MainActivity.java

private void cleanUI() {

    //update old participant ui;

    ImageView myCard;

    ((TextView) findViewById(R.id.leftName)).setText("");
    (findViewById(R.id.leftName)).setVisibility(View.GONE);
    (findViewById(R.id.leftPlayIcon)).setVisibility(View.GONE);
    ((TextView) findViewById(R.id.rightName)).setText("");
    (findViewById(R.id.rightName)).setVisibility(View.GONE);
    (findViewById(R.id.rightPlayIcon)).setVisibility(View.GONE);
    ((TextView) findViewById(R.id.topName)).setText("");
    (findViewById(R.id.topName)).setVisibility(View.GONE);
    (findViewById(R.id.topPlayIcon)).setVisibility(View.GONE);
    for (int j = 0; j < 5; j++) {
        myCard = (ImageView) findViewById(cardsRightID[j]);
        myCard.setVisibility(View.GONE);

        myCard = (ImageView) findViewById(cardsLeftID[j]);
        myCard.setVisibility(View.GONE);

        myCard = (ImageView) findViewById(cardsTopID[j]);
        myCard.setVisibility(View.GONE);

        myCard = (ImageView) findViewById(cardsID[j]);
        myCard.setVisibility(View.GONE);

        myCard = (ImageView) findViewById(droppedID[j]);
        myCard.setVisibility(View.GONE);

    }//from  www. j av a  2s  . com

}

From source file:jahirfiquitiva.iconshowcase.fragments.WallpapersFragment.java

private static void setupLayout(final boolean fromTask, final Activity context, final ImageView noConnection) {

    if (WallpapersList.getWallpapersList() != null && WallpapersList.getWallpapersList().size() > 0) {
        context.runOnUiThread(new Runnable() {
            @Override/*from   w w w .  j a  v  a2s . c o  m*/
            public void run() {
                mAdapter = new WallpapersAdapter(context, new WallpapersAdapter.ClickListener() {
                    @Override
                    public void onClick(WallpapersAdapter.WallsHolder view, int position, boolean longClick) {
                        if ((longClick && !ShowcaseActivity.wallsPicker) || ShowcaseActivity.wallsPicker) {
                            final MaterialDialog dialog = new MaterialDialog.Builder(context)
                                    .content(R.string.downloading_wallpaper).progress(true, 0).cancelable(false)
                                    .show();

                            WallpaperItem wallItem = WallpapersList.getWallpapersList().get(position);

                            Glide.with(context).load(wallItem.getWallURL()).asBitmap()
                                    .into(new SimpleTarget<Bitmap>() {
                                        @Override
                                        public void onResourceReady(final Bitmap resource,
                                                GlideAnimation<? super Bitmap> glideAnimation) {
                                            if (resource != null) {
                                                new ApplyWallpaper(context, dialog, resource,
                                                        ShowcaseActivity.wallsPicker, layout).execute();
                                            }
                                        }
                                    });
                        } else {
                            final Intent intent = new Intent(context, ViewerActivity.class);

                            intent.putExtra("item", WallpapersList.getWallpapersList().get(position));
                            intent.putExtra("transitionName", ViewCompat.getTransitionName(view.wall));

                            Bitmap bitmap;

                            if (view.wall.getDrawable() != null) {
                                bitmap = Utils.drawableToBitmap(view.wall.getDrawable());

                                try {
                                    String filename = "temp.png";
                                    FileOutputStream stream = context.openFileOutput(filename,
                                            Context.MODE_PRIVATE);
                                    bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
                                    stream.close();
                                    intent.putExtra("image", filename);
                                } catch (Exception e) {
                                    Utils.showLog(context, "Error getting drawable " + e.getLocalizedMessage());
                                }

                                ActivityOptionsCompat options = ActivityOptionsCompat
                                        .makeSceneTransitionAnimation(context, view.wall,
                                                ViewCompat.getTransitionName(view.wall));
                                context.startActivity(intent, options.toBundle());
                            } else {
                                context.startActivity(intent);
                            }
                        }
                    }
                });

                mAdapter.setData(WallpapersList.getWallpapersList());

                mRecyclerView.setAdapter(mAdapter);

                fastScroller = (RecyclerFastScroller) layout.findViewById(R.id.rvFastScroller);

                fastScroller.attachRecyclerView(mRecyclerView);

                if (fastScroller.getVisibility() != View.VISIBLE) {
                    fastScroller.setVisibility(View.VISIBLE);
                }

                if (Utils.hasNetwork(context)) {
                    hideProgressBar();
                    noConnection.setVisibility(View.GONE);
                    mRecyclerView.setVisibility(View.VISIBLE);
                    fastScroller.setVisibility(View.VISIBLE);
                    mSwipeRefreshLayout.setEnabled(false);
                    mSwipeRefreshLayout.setRefreshing(false);
                } else {
                    hideStuff(noConnection);
                }
            }
        });
    } else {
        context.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (layout != null) {
                    noConnection.setVisibility(View.GONE);
                    showProgressBar();
                    Timer timer = new Timer();
                    timer.schedule(new TimerTask() {
                        @Override
                        public void run() {
                            context.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    hideStuff(noConnection);
                                }
                            });
                        }
                    }, 7500);
                }
            }
        });
    }
}

From source file:com.kll.collect.android.activities.FormEntryActivity.java

/**
 * Creates a view given the View type and an event
 *
 * @param event// ww w .  j  av a  2 s  . c o m
 * @param advancingPage
 *            -- true if this results from advancing through the form
 * @return newly created View
 */
private View createView(int event, boolean advancingPage, int swipeCase) {
    FormController formController = Collect.getInstance().getFormController();
    /*   setTitle(getString(R.string.app_name) + " > "
    + formController.getFormTitle());*/
    int questioncount = formController.getFormDef().getDeepChildCount();

    switch (event) {
    case FormEntryController.EVENT_BEGINNING_OF_FORM:
        progressValue = 0.0;
        progressUpdate(progressValue, questioncount);
        View startView = View.inflate(this, R.layout.form_entry_start, null);
        /*setTitle(getString(R.string.app_name) + " > "
              + formController.getFormTitle());*/

        Drawable image = null;
        File mediaFolder = formController.getMediaFolder();
        String mediaDir = mediaFolder.getAbsolutePath();
        BitmapDrawable bitImage = null;
        // attempt to load the form-specific logo...
        // this is arbitrarily silly
        bitImage = new BitmapDrawable(getResources(), mediaDir + File.separator + "form_logo.png");

        if (bitImage != null && bitImage.getBitmap() != null && bitImage.getIntrinsicHeight() > 0
                && bitImage.getIntrinsicWidth() > 0) {
            image = bitImage;
        }

        if (image == null) {
            // show the opendatakit zig...
            // image =
            // getResources().getDrawable(R.drawable.opendatakit_zig);
            ((ImageView) startView.findViewById(R.id.form_start_bling)).setVisibility(View.GONE);
        } else {
            ImageView v = ((ImageView) startView.findViewById(R.id.form_start_bling));
            v.setImageDrawable(image);
            v.setContentDescription(formController.getFormTitle());
        }

        // change start screen based on navigation prefs
        String navigationChoice = PreferenceManager.getDefaultSharedPreferences(this)
                .getString(PreferencesActivity.KEY_NAVIGATION, PreferencesActivity.KEY_NAVIGATION);
        Boolean useSwipe = false;
        Boolean useButtons = false;
        ImageView ia = ((ImageView) startView.findViewById(R.id.image_advance));
        ImageView ib = ((ImageView) startView.findViewById(R.id.image_backup));
        TextView ta = ((TextView) startView.findViewById(R.id.text_advance));
        TextView tb = ((TextView) startView.findViewById(R.id.text_backup));
        TextView d = ((TextView) startView.findViewById(R.id.description));

        if (navigationChoice != null) {
            if (navigationChoice.contains(PreferencesActivity.NAVIGATION_SWIPE)) {
                useSwipe = true;
            }
            if (navigationChoice.contains(PreferencesActivity.NAVIGATION_BUTTONS)) {
                useButtons = true;
            }
        }
        if (useSwipe && !useButtons) {
            d.setText(getString(R.string.swipe_instructions, formController.getFormTitle()));
        } else if (useButtons && !useSwipe) {
            ia.setVisibility(View.GONE);
            ib.setVisibility(View.GONE);
            ta.setVisibility(View.GONE);
            tb.setVisibility(View.GONE);
            d.setText(getString(R.string.buttons_instructions, formController.getFormTitle()));
        } else {
            d.setText(getString(R.string.swipe_buttons_instructions, formController.getFormTitle()));
        }

        if (mBackButton.isShown()) {
            mBackButton.setEnabled(false);
        }
        if (mNextButton.isShown()) {
            mNextButton.setEnabled(true);
        }

        return startView;
    case FormEntryController.EVENT_END_OF_FORM:
        progressValue = questioncount;
        progressUpdate(progressValue, questioncount);
        View endView = View.inflate(this, R.layout.form_entry_end, null);

        ((ImageView) endView.findViewById(R.id.completed))
                .setImageDrawable(getResources().getDrawable(R.drawable.complete_tick));
        ((TextView) endView.findViewById(R.id.description))
                .setText(getString(R.string.save_enter_data_description, formController.getFormTitle()));

        // checkbox for if finished or ready to send
        final CheckBox instanceComplete = ((CheckBox) endView.findViewById(R.id.mark_finished));
        instanceComplete.setChecked(isInstanceComplete(true));

        if (!mAdminPreferences.getBoolean(AdminPreferencesActivity.KEY_MARK_AS_FINALIZED, true)) {
            instanceComplete.setVisibility(View.GONE);
        }

        // edittext to change the displayed name of the instance
        final EditText saveAs = (EditText) endView.findViewById(R.id.save_name);

        // disallow carriage returns in the name
        InputFilter returnFilter = new InputFilter() {
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                    int dend) {
                for (int i = start; i < end; i++) {
                    if (Character.getType((source.charAt(i))) == Character.CONTROL) {
                        return "";
                    }
                }
                return null;
            }
        };
        saveAs.setFilters(new InputFilter[] { returnFilter });
        String saveName = getSaveName();

        if (saveName == null) {
            // no meta/instanceName field in the form -- see if we have a
            // name for this instance from a previous save attempt...
            if (getContentResolver().getType(getIntent().getData()) == InstanceColumns.CONTENT_ITEM_TYPE) {
                Uri instanceUri = getIntent().getData();
                Cursor instance = null;
                try {
                    instance = getContentResolver().query(instanceUri, null, null, null, null);
                    if (instance.getCount() == 1) {
                        instance.moveToFirst();
                        saveName = instance.getString(instance.getColumnIndex(InstanceColumns.DISPLAY_NAME));
                    }
                } finally {
                    if (instance != null) {
                        instance.close();
                    }
                }
            }
            if (saveName == null) {
                // last resort, default to the form title
                saveName = formController.getFormTitle();
            }
            // present the prompt to allow user to name the form
            TextView sa = (TextView) endView.findViewById(R.id.save_form_as);
            sa.setVisibility(View.VISIBLE);
            saveAs.setText(saveName);
            saveAs.setEnabled(true);
            saveAs.setVisibility(View.VISIBLE);
        } else {
            // if instanceName is defined in form, this is the name -- no
            // revisions
            // display only the name, not the prompt, and disable edits
            TextView sa = (TextView) endView.findViewById(R.id.save_form_as);
            sa.setVisibility(View.GONE);
            saveAs.setText(saveName);
            saveAs.setEnabled(false);
            saveAs.setBackgroundColor(Color.WHITE);
            saveAs.setVisibility(View.VISIBLE);
        }

        // override the visibility settings based upon admin preferences
        if (!mAdminPreferences.getBoolean(AdminPreferencesActivity.KEY_SAVE_AS, true)) {
            saveAs.setVisibility(View.GONE);
            TextView sa = (TextView) endView.findViewById(R.id.save_form_as);
            sa.setVisibility(View.GONE);
        }

        // Create 'save' button
        ((Button) endView.findViewById(R.id.save_exit_button)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "createView.saveAndExit",
                        instanceComplete.isChecked() ? "saveAsComplete" : "saveIncomplete");
                // Form is marked as 'saved' here.
                if (saveAs.getText().length() < 1) {
                    Toast.makeText(FormEntryActivity.this, R.string.save_as_error, Toast.LENGTH_SHORT).show();
                } else {
                    saveDataToDisk(EXIT, instanceComplete.isChecked(), saveAs.getText().toString());
                }
            }
        });

        if (mBackButton.isShown()) {
            mBackButton.setEnabled(true);
        }
        if (mNextButton.isShown()) {
            mNextButton.setEnabled(false);
        }

        return endView;
    case FormEntryController.EVENT_QUESTION:
    case FormEntryController.EVENT_GROUP:
    case FormEntryController.EVENT_REPEAT:
        ODKView odkv = null;
        // should only be a group here if the event_group is a field-list
        try {
            double depth = (double) formController.getFormIndex().getDepth();
            double local_index = (double) formController.getFormIndex().getLocalIndex();
            double instance_index = (double) formController.getFormIndex().getInstanceIndex();
            Log.i("Question coint", Integer.toString(questioncount));

            Log.i("Depth", Integer.toString(formController.getFormIndex().getDepth()));
            Log.i("Local Index", Integer.toString(formController.getFormIndex().getLocalIndex()));
            Log.i("Instance Index", Integer.toString(formController.getFormIndex().getInstanceIndex()));

            if (swipeCase == NEXT) {

                Log.i("progressValue", Double.toString(progressValue));

            }
            if (swipeCase == PREVIOUS) {
                progressValue = progressValue - (1 - (instance_index * local_index / questioncount * depth));

                Log.i("progressValue", Double.toString(progressValue));
            }
            Log.i("progressValue", Double.toString(progressValue));
            progressUpdate(progressValue, questioncount);
            FormEntryPrompt[] prompts = formController.getQuestionPrompts();
            FormEntryCaption[] groups = formController.getGroupsForCurrentIndex();
            odkv = new ODKView(this, formController.getQuestionPrompts(), groups, advancingPage);
            Log.i(t, "created view for group "
                    + (groups.length > 0 ? groups[groups.length - 1].getLongText() : "[top]") + " "
                    + (prompts.length > 0 ? prompts[0].getQuestionText() : "[no question]"));
        } catch (RuntimeException e) {
            Log.e(t, e.getMessage(), e);
            // this is badness to avoid a crash.
            try {
                event = formController.stepToNextScreenEvent();
                createErrorDialog(e.getMessage(), DO_NOT_EXIT);
            } catch (JavaRosaException e1) {
                Log.e(t, e1.getMessage(), e1);
                createErrorDialog(e.getMessage() + "\n\n" + e1.getCause().getMessage(), DO_NOT_EXIT);
            }
            return createView(event, advancingPage, swipeCase);
        }

        // Makes a "clear answer" menu pop up on long-click
        for (QuestionWidget qw : odkv.getWidgets()) {
            if (!qw.getPrompt().isReadOnly()) {
                registerForContextMenu(qw);
            }
        }

        if (mBackButton.isShown() && mNextButton.isShown()) {
            mBackButton.setEnabled(true);
            mNextButton.setEnabled(true);
        }
        return odkv;
    default:
        Log.e(t, "Attempted to create a view that does not exist.");
        // this is badness to avoid a crash.
        try {
            event = formController.stepToNextScreenEvent();
            createErrorDialog(getString(R.string.survey_internal_error), EXIT);
        } catch (JavaRosaException e) {
            Log.e(t, e.getMessage(), e);
            createErrorDialog(e.getCause().getMessage(), EXIT);
        }
        return createView(event, advancingPage, swipeCase);
    }

}

From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java

public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId,
        Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description,
        final TextView breadcrumb) {
    // Pull out the root layout of the dialog and set the background drawable, to be
    // faded in during the transition.
    final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0);
    twoPane.setVisibility(View.INVISIBLE);

    // If the appropriate data is embedded in the intent and there is an icon specified
    // in the content fragment, we animate the icon from its initial position to the final
    // position. Otherwise, we perform a simpler transition in which the ActionFragment
    // slides in and the ContentFragment text fields slide in.
    mIntroAnimationInProgress = true;//from   ww w.j  av  a 2s . c om
    List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent());
    TransitionImageAnimation ltransitionAnimation = null;
    final Uri iconUri;
    final int color;
    if (images != null && images.size() > 0) {
        if (iconResourceId != 0) {
            iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId));
        } else if (iconResourceUri != null) {
            iconUri = iconResourceUri;
        } else {
            iconUri = null;
        }
        TransitionImage src = images.get(0);
        color = src.getBackground();
        if (iconUri != null) {
            ltransitionAnimation = new TransitionImageAnimation(contentView);
            ltransitionAnimation.addTransitionSource(src);
            ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0)
                    .interpolator(new DecelerateInterpolator(1f));
        }
    } else {
        iconUri = null;
        color = 0;
    }
    final TransitionImageAnimation transitionAnimation = ltransitionAnimation;

    // Fade out the old activity, and hard cut the new activity.
    activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out);

    int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background);
    mBgDrawable.setColor(bgColor);
    mBgDrawable.setAlpha(0);
    twoPane.setBackground(mBgDrawable);

    // If we're animating the icon, we create a new ImageView in which to place the embedded
    // bitmap. We place it in the root layout to match its location in the previous activity.
    mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout);
    if (transitionAnimation != null) {
        transitionAnimation.listener(new TransitionImageAnimation.Listener() {
            @Override
            public void onRemovedView(TransitionImage src, TransitionImage dst) {
                if (icon != null) {
                    //want to make sure that users still see at least the source image
                    // if the dst image is too large to finish downloading before the
                    // animation is done. Check if the icon is not visible. This mean
                    // BaseContentFragement have not finish downloading the image yet.
                    if (icon.getVisibility() != View.VISIBLE) {
                        icon.setImageDrawable(src.getBitmap());
                        int intrinsicWidth = icon.getDrawable().getIntrinsicWidth();
                        LayoutParams lp = icon.getLayoutParams();
                        lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth;
                        icon.setVisibility(View.VISIBLE);
                    }
                    icon.setAlpha(1f);
                }
                if (mShadowLayer != null) {
                    mShadowLayer.setShadowsAlpha(1f);
                }
                onIntroAnimationFinished();
            }
        });
        icon.setAlpha(0f);
        if (mShadowLayer != null) {
            mShadowLayer.setShadowsAlpha(0f);
        }
    }

    // We need to defer the remainder of the animation preparation until the first
    // layout has occurred, as we don't yet know the final location of the icon.
    twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time,  the texture is actually not created
            // delay a little so we can make sure all hardware layer is created before
            // animation, in that way we can avoid the jittering of start animation
            twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY);
        }

        final Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!mFragment.isAdded()) {
                    // We have been detached before this could run, so just bail
                    return;
                }

                twoPane.setVisibility(View.VISIBLE);
                final int secondaryDelay = SLIDE_IN_DISTANCE;

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255);
                oa.setDuration(ANIMATE_IN_DURATION);
                oa.setStartDelay(secondaryDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                View actionFragmentView = activity.findViewById(mActionAreaId);
                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
                int endDist = isRtl ? -actionFragmentView.getMeasuredWidth()
                        : actionFragmentView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                if (icon != null && transitionAnimation != null) {
                    // now we get the icon view in place,  update the transition target
                    TransitionImage target = new TransitionImage();
                    target.setUri(iconUri);
                    target.createFromImageView(icon);
                    if (icon.getBackground() instanceof ColorDrawable) {
                        ColorDrawable d = (ColorDrawable) icon.getBackground();
                        target.setBackground(d.getColor());
                    }
                    transitionAnimation.addTransitionTarget(target);
                    transitionAnimation.startTransition();
                } else if (icon != null) {
                    prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                            new DecelerateInterpolator(1.0f), true /* is the icon */);
                    if (mShadowLayer != null) {
                        mShadowLayer.setShadowsAlpha(0f);
                    }
                }
            }
        };
    });
}

From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java

private void addWoodObstacles(int screens) {
    int totalSlots = screens * SLOTS_PER_SCREEN;
    for (int i = 0; i < totalSlots;) {
        // Any given "slot" has a 1 in 3 chance of having an obstacle
        if (mRandom.nextInt(3) == 0) {
            View view = mInflater.inflate(R.layout.obstacle_layout, null);
            ImageView top = (ImageView) view.findViewById(R.id.top_view);
            ImageView bottom = (ImageView) view.findViewById(R.id.bottom_view);
            ImageView back = (ImageView) view.findViewById(R.id.back_view);

            // Which obstacle?
            int width = 0;
            //            int obstacle = mRandom.nextInt((WOOD_OBSTACLES.length/3));
            if ((mWoodObstacleIndex % 20) == 0) {
                ObstacleLoadTask task = new ObstacleLoadTask(getResources(), WOOD_OBSTACLES, mWoodObstacles,
                        mWoodObstacleList, mWoodObstacleIndex + 20, 3, mScaleX, mScaleY);
                task.execute();//from  w w w  .  j  av  a 2s  .com
            }
            int obstacle = mWoodObstacleList.get(mWoodObstacleIndex++);
            if (mWoodObstacleIndex >= mWoodObstacleList.size()) {
                mWoodObstacleIndex = 0;
            }
            int topIndex = obstacle * 3;
            int bottomIndex = topIndex + 1;
            int backIndex = topIndex + 2;
            if (WOOD_OBSTACLES[backIndex] != -1) {
                Bitmap bmp = null;
                synchronized (mWoodObstacles) {
                    bmp = mWoodObstacles.get(WOOD_OBSTACLES[backIndex]);
                }
                while (bmp == null) {
                    synchronized (mWoodObstacles) {
                        bmp = mWoodObstacles.get(WOOD_OBSTACLES[backIndex]);
                        if (bmp == null) {
                            try {
                                mWoodObstacles.wait();
                            } catch (InterruptedException e) {
                            }
                        }
                    }
                }
                width = bmp.getWidth();
                back.setImageBitmap(bmp);
            } else {
                back.setVisibility(View.GONE);
            }

            int currentObstacle = 0; // Same values as mLastObstacle
            if (WOOD_OBSTACLES[topIndex] != -1) {
                currentObstacle |= 1;
                Bitmap bmp = null;
                synchronized (mWoodObstacles) {
                    bmp = mWoodObstacles.get(WOOD_OBSTACLES[topIndex]);
                }
                while (bmp == null) {
                    synchronized (mWoodObstacles) {
                        bmp = mWoodObstacles.get(WOOD_OBSTACLES[topIndex]);
                        if (bmp == null) {
                            try {
                                mWoodObstacles.wait();
                            } catch (InterruptedException e) {
                            }
                        }
                    }
                }
                width = bmp.getWidth();
                top.setImageBitmap(bmp);
            } else {
                top.setVisibility(View.GONE);
            }

            if (WOOD_OBSTACLES[bottomIndex] != -1) {
                currentObstacle |= 2;
                Bitmap bmp = null;
                synchronized (mWoodObstacles) {
                    bmp = mWoodObstacles.get(WOOD_OBSTACLES[bottomIndex]);
                }
                while (bmp == null) {
                    synchronized (mWoodObstacles) {
                        bmp = mWoodObstacles.get(WOOD_OBSTACLES[bottomIndex]);
                        if (bmp == null) {
                            try {
                                mWoodObstacles.wait();
                            } catch (InterruptedException e) {
                            }
                        }
                    }
                }
                if (bmp.getWidth() > width) {
                    width = bmp.getWidth();
                }
                bottom.setImageBitmap(bmp);
            } else {
                bottom.setVisibility(View.GONE);
            }
            int slots = (width / mSlotWidth) + 2;

            // If last obstacle had a top and this is a bottom or vice versa, insert a space
            if ((mLastObstacle & 0x1) > 0) {
                if ((currentObstacle & 0x2) > 0) {
                    addSpaceOrPresent(mSlotWidth);
                    i++;
                }
            } else if ((mLastObstacle & 0x2) > 0) {
                if ((currentObstacle & 0x1) > 0) {
                    addSpaceOrPresent(mSlotWidth);
                    i++;
                }
            }

            // If the new obstacle is too wide for the remaining space, skip it and fill spacer instead
            if ((i + slots) > totalSlots) {
                addSpaceOrPresent(mSlotWidth * (totalSlots - i));
                i = totalSlots;
            } else {
                mLastObstacle = currentObstacle;
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(slots * mSlotWidth,
                        LinearLayout.LayoutParams.WRAP_CONTENT);
                view.setLayoutParams(lp);
                mObstacleLayout.addView(view);
                i += slots;
            }
        } else {
            addSpaceOrPresent(mSlotWidth);
            i++;
        }
    }

    // Account for rounding errors in mSlotWidth
    int extra = ((screens * mScreenWidth) - (totalSlots * mSlotWidth));
    if (extra > 0) {
        // Add filler to ensure sync with background/foreground scrolls!
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(extra,
                LinearLayout.LayoutParams.MATCH_PARENT);
        View view = new View(this);
        mObstacleLayout.addView(view, lp);
    }
}

From source file:org.telegram.ui.GalleryImageViewer.java

@SuppressWarnings("unchecked")
@Override/*from   w  ww. j  av a2  s .com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Display display = getWindowManager().getDefaultDisplay();
    if (android.os.Build.VERSION.SDK_INT < 13) {
        displaySize.set(display.getWidth(), display.getHeight());
    } else {
        display.getSize(displaySize);
    }

    classGuid = ConnectionsManager.Instance.generateClassGuid();
    setContentView(R.layout.gallery_layout);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setTitle(getString(R.string.Gallery));
    actionBar.show();

    mViewPager = (GalleryViewPager) findViewById(R.id.gallery_view_pager);
    ImageView shareButton = (ImageView) findViewById(R.id.gallery_view_share_button);
    ImageView deleteButton = (ImageView) findViewById(R.id.gallery_view_delete_button);
    nameTextView = (TextView) findViewById(R.id.gallery_view_name_text);
    timeTextView = (TextView) findViewById(R.id.gallery_view_time_text);
    bottomView = findViewById(R.id.gallery_view_bottom_view);
    fakeTitleView = (TextView) findViewById(R.id.fake_title_view);
    loadingProgress = (ProgressBar) findViewById(R.id.action_progress);

    title = (TextView) findViewById(R.id.action_bar_title);
    if (title == null) {
        final int titleId = getResources().getIdentifier("action_bar_title", "id", "android");
        title = (TextView) findViewById(titleId);
    }

    NotificationCenter.Instance.addObserver(this, FileLoader.FileDidFailedLoad);
    NotificationCenter.Instance.addObserver(this, FileLoader.FileDidLoaded);
    NotificationCenter.Instance.addObserver(this, FileLoader.FileLoadProgressChanged);
    NotificationCenter.Instance.addObserver(this, MessagesController.mediaCountDidLoaded);
    NotificationCenter.Instance.addObserver(this, MessagesController.mediaDidLoaded);
    NotificationCenter.Instance.addObserver(this, MessagesController.userPhotosLoaded);
    NotificationCenter.Instance.addObserver(this, 658);

    Integer index = null;
    if (localPagerAdapter == null) {
        final MessageObject file = (MessageObject) NotificationCenter.Instance.getFromMemCache(51);
        final TLRPC.FileLocation fileLocation = (TLRPC.FileLocation) NotificationCenter.Instance
                .getFromMemCache(53);
        final ArrayList<MessageObject> messagesArr = (ArrayList<MessageObject>) NotificationCenter.Instance
                .getFromMemCache(54);
        index = (Integer) NotificationCenter.Instance.getFromMemCache(55);
        Integer uid = (Integer) NotificationCenter.Instance.getFromMemCache(56);
        if (uid != null) {
            user_id = uid;
        }

        if (file != null) {
            ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>();
            HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>();
            imagesArr.add(file);
            if (file.messageOwner.action == null
                    || file.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) {
                needSearchMessage = true;
                imagesByIds.put(file.messageOwner.id, file);
                if (file.messageOwner.dialog_id != 0) {
                    currentDialog = file.messageOwner.dialog_id;
                } else {
                    if (file.messageOwner.to_id.chat_id != 0) {
                        currentDialog = -file.messageOwner.to_id.chat_id;
                    } else {
                        if (file.messageOwner.to_id.user_id == UserConfig.clientUserId) {
                            currentDialog = file.messageOwner.from_id;
                        } else {
                            currentDialog = file.messageOwner.to_id.user_id;
                        }
                    }
                }
            }
            localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds);
        } else if (fileLocation != null) {
            ArrayList<TLRPC.FileLocation> arr = new ArrayList<TLRPC.FileLocation>();
            arr.add(fileLocation);
            withoutBottom = true;
            deleteButton.setVisibility(View.INVISIBLE);
            nameTextView.setVisibility(View.INVISIBLE);
            timeTextView.setVisibility(View.INVISIBLE);
            localPagerAdapter = new LocalPagerAdapter(arr);
        } else if (messagesArr != null) {
            ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>();
            HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>();
            imagesArr.addAll(messagesArr);
            Collections.reverse(imagesArr);
            for (MessageObject message : imagesArr) {
                imagesByIds.put(message.messageOwner.id, message);
            }
            index = imagesArr.size() - index - 1;

            MessageObject object = imagesArr.get(0);
            if (object.messageOwner.dialog_id != 0) {
                currentDialog = object.messageOwner.dialog_id;
            } else {
                if (object.messageOwner.to_id.chat_id != 0) {
                    currentDialog = -object.messageOwner.to_id.chat_id;
                } else {
                    if (object.messageOwner.to_id.user_id == UserConfig.clientUserId) {
                        currentDialog = object.messageOwner.from_id;
                    } else {
                        currentDialog = object.messageOwner.to_id.user_id;
                    }
                }
            }
            localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds);
        }
    }

    mViewPager.setPageMargin(Utilities.dp(20));
    mViewPager.setOffscreenPageLimit(1);
    mViewPager.setAdapter(localPagerAdapter);

    if (index != null) {
        fromAll = true;
        mViewPager.setCurrentItem(index);
    }

    shareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                TLRPC.FileLocation file = getCurrentFile();
                File f = new File(Utilities.getCacheDir(), file.volume_id + "_" + file.local_id + ".jpg");
                if (f.exists()) {
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("image/jpeg");
                    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
                    startActivity(intent);
                }
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
        }
    });

    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mViewPager == null || localPagerAdapter == null || localPagerAdapter.imagesArr == null) {
                return;
            }
            int item = mViewPager.getCurrentItem();
            MessageObject obj = localPagerAdapter.imagesArr.get(item);
            if (obj.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENT) {
                ArrayList<Integer> arr = new ArrayList<Integer>();
                arr.add(obj.messageOwner.id);
                MessagesController.Instance.deleteMessages(arr);
                finish();
            }
        }
    });

    if (currentDialog != 0 && totalCount == 0) {
        MessagesController.Instance.getMediaCount(currentDialog, classGuid, true);
    }
    if (user_id != 0) {
        MessagesController.Instance.loadUserPhotos(user_id, 0, 30, 0, true, classGuid);
    }
    checkCurrentFile();
}

From source file:com.android.launcher2.Launcher.java

private boolean updateGlobalSearchIcon() {
    final View searchButtonContainer = findViewById(R.id.search_button_container);
    final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);
    final View voiceButtonProxy = findViewById(R.id.voice_button_proxy);

    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName activityName = searchManager.getGlobalSearchActivity();
    if (activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName,
                R.drawable.ic_home_search_normal_holo, TOOLBAR_SEARCH_ICON_METADATA_NAME);
        if (sGlobalSearchIcon[coi] == null) {
            sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName,
                    R.drawable.ic_home_search_normal_holo, TOOLBAR_ICON_METADATA_NAME);
        }/*from   w w w  .  ja  va 2  s .  c o  m*/

        if (searchButtonContainer != null)
            searchButtonContainer.setVisibility(View.VISIBLE);
        searchButton.setVisibility(View.VISIBLE);
        invalidatePressedFocusedStates(searchButtonContainer, searchButton);
        return true;
    } else {
        // We disable both search and voice search when there is no global search provider
        if (searchButtonContainer != null)
            searchButtonContainer.setVisibility(View.GONE);
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        searchButton.setVisibility(View.GONE);
        voiceButton.setVisibility(View.GONE);
        if (voiceButtonProxy != null) {
            voiceButtonProxy.setVisibility(View.GONE);
        }
        return false;
    }
}