List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:android.example.com.animationdemos.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 www . jav a 2 s . c o m * <p/> * <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> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ 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. 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. 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); startBounds.offset(-globalOffset.x, -globalOffset.y); 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). 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:com.fugueweb.pub.animation.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 w ww .java2 s .c o m * * <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> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ 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. 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. Math. 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); startBounds.offset(-globalOffset.x, -globalOffset.y); 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). 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:cn.androidy.materialdesignsample.animations.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:/*ww w . j a v a 2 s . c o m*/ * * <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> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ 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. 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. 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); startBounds.offset(-globalOffset.x, -globalOffset.y); 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). 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:com.google.samples.apps.iosched.ui.BaseActivity.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that * shows which account the user is logged in as, and lets them switch accounts. It also * shows the user's Google+ cover photo as background. *//*ww w . j ava2 s . c o m*/ private void setupAccountBox() { mAccountListContainer = (LinearLayout) findViewById(R.id.account_list); if (mAccountListContainer == null) { //This activity does not have an account box return; } final View chosenAccountView = findViewById(R.id.chosen_account_view); Account chosenAccount = AccountUtils.getActiveAccount(this); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); mAccountListContainer.setVisibility(View.INVISIBLE); } AccountManager am = AccountManager.get(this); Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE); List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray)); accounts.remove(chosenAccount); ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text); TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text); mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); String name = AccountUtils.getPlusName(this); if (name == null) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setVisibility(View.VISIBLE); nameTextView.setText(name); } String imageUrl = AccountUtils.getPlusImageUrl(this); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(this); if (coverImageUrl != null) { findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(getResources().getColor(R.color.light_content_scrim)); } email.setText(chosenAccount.name); if (accounts.isEmpty()) { // There's only one account on the device, so no need for a switcher. mExpandAccountBoxIndicator.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); chosenAccountView.setEnabled(false); return; } chosenAccountView.setEnabled(true); mExpandAccountBoxIndicator.setVisibility(View.VISIBLE); chosenAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountBoxExpanded = !mAccountBoxExpanded; setupAccountBoxToggle(); } }); setupAccountBoxToggle(); populateAccountList(accounts); }
From source file:info.guardianproject.otr.app.im.app.ChatView.java
private synchronized void initEmoji() { if (emojiManager == null) { emojiManager = EmojiManager.getInstance(mContext); try {// w ww.j a v a 2s . co m emojiManager.addJsonPlugins(); } catch (JsonSyntaxException jse) { Log.e(ImApp.LOG_TAG, "could not parse json", jse); } catch (IOException fe) { Log.e(ImApp.LOG_TAG, "could not load emoji definition", fe); } catch (Exception fe) { Log.e(ImApp.LOG_TAG, "could not load emoji definition", fe); } } mEmojiPager = (ViewPager) this.findViewById(R.id.emojiPager); ImageView btnEmoji = (ImageView) findViewById(R.id.btnEmoji); Collection<EmojiGroup> emojiGroups = emojiManager.getEmojiGroups(); if (emojiGroups.size() > 0) { btnEmoji.setVisibility(View.VISIBLE); EmojiPagerAdapter emojiPagerAdapter = new EmojiPagerAdapter(mNewChatActivity, mComposeMessage, new ArrayList<EmojiGroup>(emojiGroups)); mEmojiPager.setAdapter(emojiPagerAdapter); btnEmoji.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // mActionBox.setVisibility(View.GONE); if (mEmojiPager.getVisibility() == View.GONE) mEmojiPager.setVisibility(View.VISIBLE); else mEmojiPager.setVisibility(View.GONE); } }); } else { btnEmoji.setVisibility(View.GONE); btnEmoji.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //what? prompt to install? } }); } }
From source file:org.catnut.adapter.TweetAdapter.java
private void injectThumbs(final Context context, final String originUri, String mediumThumbUrl, String smallThumbUrl, final ImageView thumbs) { switch (mThumbsOption) { case SMALL:// w w w.j a va 2 s . c o m case MEDIUM: if (!TextUtils.isEmpty(originUri)) { if (mStayInLatest) { // not in offline mode RequestCreator creator; if (mThumbsOption == ThumbsOption.MEDIUM) { creator = Picasso.with(context).load(mediumThumbUrl).centerCrop().resize(mScreenWidth, (int) (mScreenWidth * Constants.GOLDEN_RATIO)); } else { creator = Picasso.with(context).load(smallThumbUrl); } creator.placeholder(android.R.drawable.ic_menu_report_image).error(R.drawable.error) .into(thumbs); thumbs.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return CatnutUtils.imageOverlay(v, event); } }); thumbs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { thumbs.getDrawable().clearColorFilter(); thumbs.invalidate(); Intent intent = SingleFragmentActivity.getIntent(context, SingleFragmentActivity.PHOTO_VIEWER); intent.putExtra(Constants.PIC, originUri); mContext.startActivity(intent); } }); } else { // sometimes, the user may read timeline in offline mode(may opening the 2/3g), // so, don' t load the image // todo, may be we need to check it in cache or place the network unavailable image? thumbs.setImageResource(android.R.drawable.ic_menu_report_image); } thumbs.setVisibility(View.VISIBLE); break; } // otherwise, fall through... case NONE: case ORIGINAL: default: thumbs.setVisibility(View.GONE); break; } }
From source file:com.example.imac.animationsdemo.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 www . j a va 2s.c om * <p/> * <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> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ 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. 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. 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); startBounds.offset(-globalOffset.x, -globalOffset.y); 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). 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; //? ??? 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). Log.e("==startBounds===", startBounds.left + " " + startBounds.top); AnimatorSet set = new AnimatorSet(); Log.e("=====", startBounds.left + " " + startBounds.top + " " + thumbView.getLeft() + " " + thumbView.getTop()); set.play(ObjectAnimator.ofFloat(expandedImageView, "X", startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, "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:com.android.mtkex.chips.BaseRecipientAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /// M: add view holder to improve performance. DropDownListViewHolder viewHolder;/*from ww w . ja va 2s . co m*/ /// M: get view holder from convert view. @{ if (convertView == null) { convertView = mInflater.inflate(getItemLayout(), parent, false); viewHolder = new DropDownListViewHolder(); if (convertView != null) { viewHolder.name = (TextView) convertView.findViewById(getDisplayNameId()); viewHolder.dest = (TextView) convertView.findViewById(getDestinationId()); viewHolder.destType = (TextView) convertView.findViewById(getDestinationTypeId()); viewHolder.img = (ImageView) convertView.findViewById(getPhotoId()); convertView.setTag(viewHolder); } } else { viewHolder = (DropDownListViewHolder) convertView.getTag(); } /// @} final RecipientEntry entry = getEntries().get(position); String displayName = entry.getDisplayName(); String destination = entry.getDestination(); if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, destination)) { displayName = destination; // We only show the destination for secondary entries, so clear it // only for the first level. if (entry.isFirstLevel()) { destination = null; } } /// M: get properties from view holder. @{ final View itemView = convertView; final TextView displayNameView = viewHolder.name; final TextView destinationView = viewHolder.dest; final TextView destinationTypeView = viewHolder.destType; final ImageView imageView = viewHolder.img; /// @} displayNameView.setText(displayName); if (!TextUtils.isEmpty(destination)) { destinationView.setText(destination); } else { destinationView.setText(null); } if (destinationTypeView != null) { CharSequence destinationType = null; if (mShowPhoneAndEmail) { /// M: Current query is phone query, but there may exist email results as well. /// Hence, we need to get destinationType of email results by Queries.EMAIL. @{ if (entry.getDestinationKind() == RecipientEntry.ENTRY_KIND_EMAIL) { destinationType = Queries.EMAIL.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } else { destinationType = Queries.PHONE.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } /// @} } else { destinationType = mQuery.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } destinationTypeView.setText(destinationType); } if (entry.isFirstLevel()) { displayNameView.setVisibility(View.VISIBLE); if (imageView != null) { imageView.setVisibility(View.VISIBLE); final byte[] photoBytes = entry.getPhotoBytes(); if (photoBytes != null) { /// M: get bitmap from recipient entry Bitmap photo = entry.getBitmap(); /// M: cache bitmap if unavailable. @{ if (photo == null) { photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length); entry.setBitmap(photo); } /// @} imageView.setImageBitmap(photo); } else { imageView.setImageResource(getDefaultPhotoResource()); } } } else { displayNameView.setVisibility(View.GONE); if (imageView != null) { imageView.setVisibility(View.INVISIBLE); } } return itemView; }
From source file:ua.mkh.settings.full.MainActivity.java
public void operator() { manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); TextOper.setText(manager.getSimOperatorName()); if (TextOper.getText().toString().length() == 0) { LinearLayout LinearLayoutSotSvyaz = (LinearLayout) findViewById(R.id.LinearLayoutSotSvyaz); LinearLayout LinearLayoutApn = (LinearLayout) findViewById(R.id.LinearLayoutApn); LinearLayout LinearLayoutOperator = (LinearLayout) findViewById(R.id.LinearLayoutOperator); //LinearLayoutSotSvyaz.setVisibility(View.GONE); //LinearLayoutApn.setVisibility(View.GONE); //LinearLayoutOperator.setVisibility(View.GONE); btn_operator.setTextColor(getResources().getColor(R.color.hint_text)); //btn_operator.setEnabled(false); btn_sota.setTextColor(getResources().getColor(R.color.hint_text)); btn_sota.setEnabled(false);/* w w w . ja va 2 s.c o m*/ btn_vpn.setTextColor(getResources().getColor(R.color.hint_text)); btn_vpn.setEnabled(false); textVPN.setVisibility(View.GONE); ImageView ImageView07 = (ImageView) findViewById(R.id.ImageView07); ImageView07.setVisibility(View.GONE); ImageView ImageView05 = (ImageView) findViewById(R.id.ImageView05); ImageView05.setVisibility(View.GONE); ImageView ImageView75 = (ImageView) findViewById(R.id.ImageView75); ImageView75.setVisibility(View.GONE); } }
From source file:com.tweetlanes.android.core.view.ProfileFragment.java
void configureView() { TextView fullNameTextView = (TextView) mProfileView.findViewById(R.id.fullNameTextView); TextView followingTextView = (TextView) mProfileView.findViewById(R.id.followState); TextView descriptionTextView = (TextView) mProfileView.findViewById(R.id.bioTextView); TextView tweetCount = (TextView) mProfileView.findViewById(R.id.tweetCountLabel); TextView followingCount = (TextView) mProfileView.findViewById(R.id.followingCountLabel); TextView followersCount = (TextView) mProfileView.findViewById(R.id.followersCountLabel); TextView favoritesCount = (TextView) mProfileView.findViewById(R.id.favorites_count); LinearLayout linkLayout = (LinearLayout) mProfileView.findViewById(R.id.linkLayout); TextView link = (TextView) mProfileView.findViewById(R.id.link); LinearLayout locationLayout = (LinearLayout) mProfileView.findViewById(R.id.locationLayout); TextView location = (TextView) mProfileView.findViewById(R.id.location); LinearLayout detailsLayout = (LinearLayout) mProfileView.findViewById(R.id.detailsLayout); ImageView privateAccountImage = (ImageView) mProfileView.findViewById(R.id.private_account_image); mFriendshipButton = (Button) mProfileView.findViewById(R.id.friendship_button); mFriendshipDivider = mProfileView.findViewById(R.id.friendship_divider); if (mUser != null) { ImageView avatar = (ImageView) mProfileView.findViewById(R.id.profileImage); // String imageUrl = // TwitterManager.getProfileImageUrl(mUser.getScreenName(), // TwitterManager.ProfileImageSize.ORIGINAL); String imageUrl = mUser.getProfileImageUrl(TwitterManager.ProfileImageSize.ORIGINAL); UrlImageViewHelper.setUrlDrawable(avatar, imageUrl, R.drawable.ic_contact_picture); // avatar.setImageURL(imageUrl); ImageView coverImage = (ImageView) mProfileView.findViewById(R.id.coverImage); if (coverImage != null) { String url = mUser.getCoverImageUrl(); if (url != null) { UrlImageViewHelper.setUrlDrawable(coverImage, url, R.drawable.ic_contact_picture); }/*w ww. j a v a 2s . com*/ } fullNameTextView.setText(mUser.getName()); if (mFollowsLoggedInUser != null && mFollowsLoggedInUser.booleanValue()) { followingTextView.setText(R.string.follows_you); } else { followingTextView.setText(null); } String description = mUser.getDescription(); URLEntity[] urlEntities = mUser.getUrlEntities(); if (description != null) { String descriptionMarkup = TwitterUtil.getTextMarkup(description, urlEntities); descriptionTextView.setText(Html.fromHtml(descriptionMarkup + " ")); descriptionTextView.setMovementMethod(LinkMovementMethod.getInstance()); URLSpanNoUnderline.stripUnderlines(descriptionTextView); } if (mUser.getUrl() != null) { linkLayout.setVisibility(View.VISIBLE); String urlMarkup = TwitterUtil.getTextMarkup(mUser.getUrl(), urlEntities); link.setText(Html.fromHtml(urlMarkup + "")); link.setMovementMethod(LinkMovementMethod.getInstance()); URLSpanNoUnderline.stripUnderlines(link); } else { linkLayout.setVisibility(View.GONE); } detailsLayout.setVisibility(View.VISIBLE); privateAccountImage.setVisibility(mUser.getProtected() ? View.VISIBLE : View.GONE); tweetCount.setText(Util.getPrettyCount(mUser.getStatusesCount())); followingCount.setText(Util.getPrettyCount(mUser.getFriendsCount())); followersCount.setText(Util.getPrettyCount(mUser.getFollowersCount())); if (favoritesCount != null) { favoritesCount.setText(Util.getPrettyCount(mUser.getFavoritesCount())); } if (mUser.getLocation() != null) { locationLayout.setVisibility(View.VISIBLE); location.setText(mUser.getLocation()); } else { locationLayout.setVisibility(View.GONE); } configureFriendshipButtonVisibility(mLoggedInUserFollows); } else { fullNameTextView.setText(null); followingTextView.setText(null); descriptionTextView.setText(null); detailsLayout.setVisibility(View.GONE); linkLayout.setVisibility(View.GONE); locationLayout.setVisibility(View.GONE); mFriendshipButton.setVisibility(View.GONE); mFriendshipDivider.setVisibility(View.GONE); privateAccountImage.setVisibility(View.GONE); } }