下面列出了android.widget.ImageView#clearAnimation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void rotateIcon(View view)
{
final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); //getIconImageView();
if(icon!=null)
{
icon.clearAnimation();
ObjectAnimator anim = ObjectAnimator.ofFloat(icon, View.ROTATION, isExpanded() ? 0 : 180);
anim.setDuration(200);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
icon.setHasTransientState(true);
anim.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
icon.setHasTransientState(false);
}
});
anim.start();
}
}
public static void cleanAnim(ImageView animView) {
if (animView == null)
return;
animView.setImageResource(0);
animView.clearAnimation();
animView.setVisibility(View.GONE);
}
public static void cleanAnim(ImageView animView) {
if (animView == null)
return;
animView.setImageResource(0);
animView.clearAnimation();
animView.setVisibility(View.GONE);
}
/**
* 隐藏进度显示动画
*/
public void hideProgressAnimation(ImageView view) {
if (view == null) return;
view.clearAnimation();
view.setVisibility(View.GONE);
}
/**
* 隐藏进度显示动画
*/
public void hideProgressAnimation(ImageView view) {
if (view == null) return;
view.clearAnimation();
view.setVisibility(View.GONE);
}
private void showFlash(ImageView iv) {
ImageView[] ivs = new ImageView[]{ivHotLight, ivColdLight, ivServerLight};
for (ImageView v : ivs) {
if (v != iv) {
v.clearAnimation();
v.setVisibility(View.INVISIBLE);
}
}
if (iv != null) {
iv.setVisibility(View.VISIBLE);
iv.startAnimation(AnimationUtils.loadAnimation(getActivity(),
R.anim.hdm_keychain_add_one_part_flash));
}
}
public void viewStopANimation(ImageView view) {
if (mRotateAnim != null) {
view.clearAnimation();
mRotateAnim = null;
mProgressLayout.setVisibility(View.GONE);
}
}
protected void showImageInView(ImageView iv, Bitmap bitmap, boolean animate) {
iv.clearAnimation();
if (animate)
iv.setAlpha(0f);
iv.setImageBitmap(bitmap);
setProgressBarVisibility(iv, false);
if (animate)
iv.animate().alpha(1f).setDuration(200).start();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_item_dialog_tweet_progress, null);
}
final LocalAccount account = (LocalAccount)getItem(position);
ImageView ivProfileImage = (ImageView) convertView.findViewById(R.id.ivProfileImage);
ivProfileImage.setImageDrawable(GlobalResource.getDefaultMinHeader(context));
String profileImageUrl = account.getUser().getProfileImageUrl();
if (StringUtil.isNotEmpty(profileImageUrl)) {
new ImageLoad4HeadTask(ivProfileImage, profileImageUrl, true).execute();
}
TextView screenName = (TextView) convertView.findViewById(R.id.tvScreenName);
TextView spName = (TextView) convertView.findViewById(R.id.tvSPName);
ImageView ivTweetState = (ImageView) convertView.findViewById(R.id.ivTweetState);
State state = mapState.get(account);
if (state == null) {
state = State.Waiting;
mapState.put(account, state);
}
ivTweetState.setImageLevel(state.getState());
if (state == State.Loading) {
ivTweetState.startAnimation(rotateAnimation);
} else {
ivTweetState.clearAnimation();
}
screenName.setText(account.getUser().getScreenName());
String snNameText = account.getServiceProvider().getSpName();
spName.setText(snNameText);
return convertView;
}
public void rotateIconAndChangeState(View view)
{
if(!isExpanded())
rotateExpandedIcons();
final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); //getIconImageView();
if(icon!=null)
{
IS_ANIMATING = true;
icon.clearAnimation();
ObjectAnimator anim = ObjectAnimator.ofFloat(icon, View.ROTATION, isExpanded() ? 0 : 180);
anim.setDuration(200);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
icon.setHasTransientState(true);
anim.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
if (isExpanded())
collapse();
else
{
collapseAll();
expand();
}
getAdapter().notifyDataSetChanged();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
icon.setHasTransientState(false);
IS_ANIMATING = false;
}
});
anim.start();
}
else
{
if(isExpanded())
collapse();
else
expand();
}
}
private void StartAnimations(){
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l = (LinearLayout)findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView)findViewById(R.id.splash);
iv.clearAnimation();
iv.startAnimation(anim);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
// Splash screen pause time
while (waited < 2500) {
sleep(100);
waited += 100;
}
Intent intent = new Intent(SplashActivity.this,
SpotifyLoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
overridePendingTransition(R.anim.pull_up_from_bottom, R.anim.hold);
SplashActivity.this.finish();
} catch (InterruptedException e) {
// do nothing
} finally {
SplashActivity.this.finish();
}
}
};
splashTread.start();
}
public static void decorate(
@Nullable final TextView title,
@Nullable final ImageView image,
@Nullable final TextView imageText,
Song song,
@NonNull final AppCompatActivity activity,
boolean showAlbumImage)
{
final boolean isPlaying = MusicPlayerRemote.isPlaying(song);
if (title != null) {
title.setTypeface(null, isPlaying ? Typeface.BOLD : Typeface.NORMAL);
}
if (image != null) {
image.setVisibility((isPlaying || showAlbumImage) ? View.VISIBLE : View.GONE);
final boolean animateIcon = PreferenceUtil.getInstance().animatePlayingSongIcon();
if (isPlaying) {
image.setScaleType(ImageView.ScaleType.CENTER);
final int color = ATHUtil.resolveColor(activity, R.attr.iconColor, ThemeStore.textColorSecondary(activity));
image.setColorFilter(color, PorterDuff.Mode.SRC_IN);
final int size = (int)(24 * activity.getResources().getDisplayMetrics().density);
// Note: No transition for Glide, the animation is explicitly controlled
GlideApp.with(activity)
.asBitmap()
.load(sIconPlaying)
.override(size)
.into(image);
if (animateIcon) { image.startAnimation(sIconAnimation); }
}
else {
image.clearColorFilter();
if (animateIcon) { image.clearAnimation(); }
}
}
if (imageText != null) {
imageText.setVisibility((isPlaying || showAlbumImage) ? View.GONE : View.VISIBLE);
}
}
private void displayImageView(final ImageView view, final String urlKey, final FileLocationMethod method,
boolean isFling, boolean isMultiPictures) {
view.clearAnimation();
if (!shouldReloadPicture(view, urlKey)) {
return;
}
final Bitmap bitmap = getBitmapFromMemCache(urlKey);
if (bitmap != null) {
view.setImageBitmap(bitmap);
view.setTag(urlKey);
if (view.getAlpha() != 1.0f) {
view.setAlpha(1.0f);
}
cancelPotentialDownload(urlKey, view);
} else {
if (isFling) {
view.setImageResource(defaultPictureResId);
return;
}
if (!cancelPotentialDownload(urlKey, view)) {
return;
}
final LocalOrNetworkChooseWorker newTask = new LocalOrNetworkChooseWorker(view, urlKey, method, isMultiPictures);
PictureBitmapDrawable downloadedDrawable = new PictureBitmapDrawable(newTask);
view.setImageDrawable(downloadedDrawable);
// listview fast scroll performance
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (getBitmapDownloaderTask(view) == newTask) {
newTask.executeOnNormal();
}
return;
}
}, 400);
}
}
private void styleFileView(IndexedFile file, View view) {
String mime = FileUtils.getMimeType(file.getExtension());
if (FileUtils.isImageOrVideo(mime)
&& file.getThumbFile().exists()
&& GeneralSettingsManager.isThumbnailsShown()) {
if (file.getThumbnail() == null) {
// there is no thumbnail yet to set. it still has to be created or retrieved.
// so for now show the normal view
styleFiletypeView(file, view);
}
styleThumbView(file, view);
} else {
styleFiletypeView(file, view);
}
ImageView statusImage = (ImageView) view.findViewById(R.id.file_status);
ImageView statusImageBG = (ImageView) view.findViewById(R.id.file_status_background);
View statusBar = view.findViewById(R.id.content_item_status_line);
if (file.isUnlocked()) {
statusImage.clearAnimation();
statusImage.setImageResource(R.drawable.ic_status_unlocked);
statusImageBG.setBackgroundColor(Utils.color(R.color.unlocked));
view.findViewById(R.id.content_item_status_line).setBackgroundColor(Utils.color(R.color.unlocked));
}
else if (file.isLocked()) {
statusImage.clearAnimation();
statusImage.setImageResource(R.drawable.ic_status_locked);
statusImageBG.setBackgroundColor(Utils.color(R.color.locked));
statusBar.setBackgroundColor(Utils.color(R.color.locked));
}
else {
statusImage.setImageResource(R.drawable.ic_status_processing);
statusImageBG.setBackgroundColor(Utils.color(R.color.processing));
statusBar.setBackgroundColor(Utils.color(R.color.processing));
if (view.getContext() != null) {
statusImage.setAnimation(AnimationUtils.loadAnimation(view.getContext(), R.anim.rotate));
}
}
}
private void displayImageView(final ImageView view, final String urlKey, final FileLocationMethod method,
boolean isFling, boolean isMultiPictures) {
view.clearAnimation();
if (!shouldReloadPicture(view, urlKey)) {
return;
}
final Bitmap bitmap = getBitmapFromMemCache(urlKey);
if (bitmap != null) {
view.setImageBitmap(bitmap);
view.setTag(urlKey);
if (view.getAlpha() != 1.0f) {
view.setAlpha(1.0f);
}
cancelPotentialDownload(urlKey, view);
} else {
if (isFling) {
view.setImageResource(defaultPictureResId);
return;
}
if (!cancelPotentialDownload(urlKey, view)) {
return;
}
final LocalOrNetworkChooseWorker newTask = new LocalOrNetworkChooseWorker(view, urlKey, method, isMultiPictures);
PictureBitmapDrawable downloadedDrawable = new PictureBitmapDrawable(newTask);
view.setImageDrawable(downloadedDrawable);
// listview fast scroll performance
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (getBitmapDownloaderTask(view) == newTask) {
newTask.executeOnNormal();
}
return;
}
}, 400);
}
}