android.graphics.drawable.TransitionDrawable Java Examples

The following examples show how to use android.graphics.drawable.TransitionDrawable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLoader.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap    The new bitmap to set.
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {

    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[]{
                        new ColorDrawable(android.R.color.transparent),
                        new BitmapDrawable(mResources, bitmap)
                });
        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}
 
Example #2
Source File: AsyncImageDownloadTask.java    From HomeGenie-Android with GNU General Public License v3.0 6 votes vote down vote up
private void setImage(ImageView imageView, Bitmap bitmap) {
    if (animate) {
        Resources resources = imageView.getResources();
        BitmapDrawable drawable = new BitmapDrawable(resources, bitmap);
        Drawable currentDrawable = imageView.getDrawable();
        if (currentDrawable != null) {
            Drawable[] arrayDrawable = new Drawable[2];
            arrayDrawable[0] = currentDrawable;
            arrayDrawable[1] = drawable;
            final TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable);
            transitionDrawable.setCrossFadeEnabled(true);
            imageView.setImageDrawable(transitionDrawable);
            transitionDrawable.startTransition(150);
        } else {
            imageView.setImageDrawable(drawable);
        }
    } else {
        imageView.setImageBitmap(bitmap);
    }
}
 
Example #3
Source File: ImageWorker.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example #4
Source File: MainActivity.java    From Torchie-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle("");

    but_flash = (ImageButton) findViewById(R.id.but_flash_pto);
    sw_func_toggle = (SwitchCompat) findViewById(R.id.sw_func_toggle);

    transAnimButFlash = (TransitionDrawable) but_flash.getBackground();
    transAnimButFlash.resetTransition();

    if (SettingsUtils.isFirstTime(this)) {
        this.showDialogWelcome();
    }
}
 
Example #5
Source File: ImageWorker.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example #6
Source File: ImageWorker.java    From BubbleCloudView with MIT License 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[]{
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example #7
Source File: LightSwitchActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	if (BuildConfig.DEBUG) {
		Log.i("CATEGORY", "AHHHHH!!!");
	}
	
	final ImageView image = (ImageView) findViewById(R.id.image);
	final ToggleButton button = (ToggleButton) findViewById(R.id.button);
	button.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(final View v) {
			TransitionDrawable drawable = (TransitionDrawable) image
					.getDrawable();
			if (button.isChecked()) {
				drawable.startTransition(1000);
			} else {
				drawable.reverseTransition(1000);
			}
		}
	});
}
 
Example #8
Source File: LightSwitchActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	final ImageView image = (ImageView) findViewById(R.id.image);
	final ToggleButton button = (ToggleButton) findViewById(R.id.button);
	button.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(final View v) {
			TransitionDrawable drawable = (TransitionDrawable) image
					.getDrawable();
			if (button.isChecked()) {
				drawable.startTransition(1000);
			} else {
				drawable.reverseTransition(1000);
			}
		}
	});
}
 
Example #9
Source File: ImageWorker.java    From RoMote with Apache License 2.0 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example #10
Source File: CrossbowImageTest.java    From CrossBow with Apache License 2.0 6 votes vote down vote up
@Test
public void testImageFadeDrawable() {
    ColorDrawable defaultDrawable = new ColorDrawable(Color.BLUE);

    CrossbowImage.Builder builder = new CrossbowImage.Builder(RuntimeEnvironment.application, null, null);
    builder.placeholder(defaultDrawable);
    builder.scale(ImageView.ScaleType.CENTER);
    builder.fade(200);
    CrossbowImage crossbowImage = builder.into(imageView).load();

    Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8);
    crossbowImage.setBitmap(bitmap, false);

    TransitionDrawable drawable = (TransitionDrawable) imageView.getDrawable();
    assertTrue(drawable.getNumberOfLayers() == 2);
}
 
Example #11
Source File: AppViewFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void setupAppcAppView() {
  TypedValue value = new TypedValue();
  this.getContext()
      .getTheme()
      .resolveAttribute(R.attr.appview_toolbar_bg_appc, value, true);
  int drawableId = value.resourceId;

  TransitionDrawable transition =
      (TransitionDrawable) ContextCompat.getDrawable(getContext(), drawableId);
  collapsingToolbarLayout.setBackgroundDrawable(transition);
  transition.startTransition(APPC_TRANSITION_MS);

  AlphaAnimation animation1 = new AlphaAnimation(0f, 1.0f);
  animation1.setDuration(APPC_TRANSITION_MS);
  collapsingAppcBackground.setAlpha(1f);
  collapsingAppcBackground.setVisibility(View.VISIBLE);
  collapsingAppcBackground.startAnimation(animation1);

  install.setBackgroundDrawable(getContext().getResources()
      .getDrawable(R.drawable.appc_gradient_rounded));
  downloadProgressBar.setProgressDrawable(
      ContextCompat.getDrawable(getContext(), R.drawable.appc_progress));
  flagThisAppSection.setVisibility(View.GONE);
}
 
Example #12
Source File: ActivityEditor.java    From Clip-Stack with MIT License 6 votes vote down vote up
private void setStarredIcon() {
    if (starItem == null) return;
    final TransitionDrawable mFabBackground = (TransitionDrawable) mFAB.getBackground();
    if (isStarred) {
        starItem.setIcon(R.drawable.ic_action_star_white);
    } else {
        starItem.setIcon(R.drawable.ic_action_star_outline_white);
    }
    mFAB.animate().scaleX(0).setDuration(160);
    mFAB.animate().scaleY(0);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if (isStarred) {
                mFAB.setImageResource(R.drawable.ic_action_star_white);
                mFabBackground.startTransition((int) mFAB.animate().getDuration());
            } else {
                mFAB.setImageResource(R.drawable.ic_action_copy);
                mFabBackground.resetTransition();
            }
            mFAB.animate().scaleX(1);
            mFAB.animate().scaleY(1);
        }
    }, 220);
}
 
Example #13
Source File: ImageLoader.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap    The new bitmap to set.
 */
private void setImageBitmap(CircleImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[]{
                        new ColorDrawable(android.R.color.transparent),
                        new BitmapDrawable(mResources, bitmap)
                });
        //imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}
 
Example #14
Source File: SnippetArticleViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
private void fadeThumbnailIn(SnippetArticle snippet, Bitmap thumbnail) {
    mImageCallback = null;
    if (thumbnail == null) return; // Nothing to do, we keep the placeholder.

    // We need to crop and scale the downloaded bitmap, as the ImageView we set it on won't be
    // able to do so when using a TransitionDrawable (as opposed to the straight bitmap).
    // That's a limitation of TransitionDrawable, which doesn't handle layers of varying sizes.
    Resources res = mThumbnailView.getResources();
    int targetSize = res.getDimensionPixelSize(R.dimen.snippets_thumbnail_size);
    Bitmap scaledThumbnail = ThumbnailUtils.extractThumbnail(
            thumbnail, targetSize, targetSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);

    // Store the bitmap to skip the download task next time we display this snippet.
    snippet.setThumbnailBitmap(scaledThumbnail);

    // Cross-fade between the placeholder and the thumbnail.
    Drawable[] layers = {mThumbnailView.getDrawable(),
            new BitmapDrawable(mThumbnailView.getResources(), scaledThumbnail)};
    TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
    mThumbnailView.setImageDrawable(transitionDrawable);
    transitionDrawable.startTransition(FADE_IN_ANIMATION_TIME_MS);
}
 
Example #15
Source File: MainActivity.java    From android-art-res with Apache License 2.0 6 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        // test transition
        View v = findViewById(R.id.test_transition);
        TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
        drawable.startTransition(1000);

        // test scale
        View testScale = findViewById(R.id.test_scale);
        ScaleDrawable testScaleDrawable = (ScaleDrawable) testScale.getBackground();
        testScaleDrawable.setLevel(10);

        // test clip
        ImageView testClip = (ImageView) findViewById(R.id.test_clip);
        ClipDrawable testClipDrawable = (ClipDrawable) testClip.getDrawable();
        testClipDrawable.setLevel(8000);
        
        // test custom drawable
        View testCustomDrawable = findViewById(R.id.test_custom_drawable);
        CustomDrawable customDrawable = new CustomDrawable(Color.parseColor("#0ac39e"));
        testCustomDrawable.setBackgroundDrawable(customDrawable);
    }
}
 
Example #16
Source File: SampleGridPagerAdapter.java    From android-GridViewPager with Apache License 2.0 6 votes vote down vote up
@Override
protected Drawable create(final Point page) {
    // place bugdroid as the background at row 2, column 1
    if (page.y == 2 && page.x == 1) {
        int resid = R.drawable.bugdroid_large;
        new DrawableLoadingTask(mContext) {
            @Override
            protected void onPostExecute(Drawable result) {
                TransitionDrawable background = new TransitionDrawable(new Drawable[] {
                        mClearBg,
                        result
                });
                mPageBackgrounds.put(page, background);
                notifyPageBackgroundChanged(page.y, page.x);
                background.startTransition(TRANSITION_DURATION_MILLIS);
            }
        }.execute(resid);
    }
    return GridPagerAdapter.BACKGROUND_NONE;
}
 
Example #17
Source File: DexCrossFadeImageView.java    From DexMovingImageView with Apache License 2.0 6 votes vote down vote up
/**
 * Start a transition to the new image
 *
 * @param drawable the drawable to set
 */
public void setFadingImageDrawable(Drawable drawable) {
    Drawable currentDrawable = getDrawable();
    if ((currentDrawable != null) && (currentDrawable instanceof TransitionDrawable)) {
        currentDrawable = ((TransitionDrawable) currentDrawable).getDrawable(1);
    }
    if (currentDrawable != null) {
        Drawable[] arrayDrawable = new Drawable[2];
        arrayDrawable[0] = currentDrawable;
        arrayDrawable[1] = drawable;
        TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable);
        transitionDrawable.setCrossFadeEnabled(true);
        setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(transitionDurationMillis);
    } else {
        setImageDrawable(drawable);
    }
}
 
Example #18
Source File: DocumentsActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void changeActionBarColor() {

		int color = SettingsActivity.getPrimaryColor(this);
		Drawable colorDrawable = new ColorDrawable(color);

		if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);
		} else {
			TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
			td.startTransition(200);
		}

		oldBackground = colorDrawable;

        setUpStatusBar();
	}
 
Example #19
Source File: SettingsActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public void changeActionBarColor(int newColor) {

		int color = newColor != 0 ? newColor : SettingsActivity.getPrimaryColor(this);
		Drawable colorDrawable = new ColorDrawable(color);

		if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);

        } else {
			TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
			td.startTransition(200);
		}

		oldBackground = colorDrawable;
	}
 
Example #20
Source File: DocumentsActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void changeActionBarColor() {

		int color = SettingsActivity.getPrimaryColor(this);
		Drawable colorDrawable = new ColorDrawable(color);

		if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);
		} else {
			TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
			td.startTransition(200);
		}

		oldBackground = colorDrawable;

        setUpStatusBar();
	}
 
Example #21
Source File: SettingsActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public void changeActionBarColor(int newColor) {

		int color = newColor != 0 ? newColor : SettingsActivity.getPrimaryColor(this);
		Drawable colorDrawable = new ColorDrawable(color);

		if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);

        } else {
			TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
			td.startTransition(200);
		}

		oldBackground = colorDrawable;
	}
 
Example #22
Source File: Timber2.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(200);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
 
Example #23
Source File: FadeInNetworkImageView.java    From QuickLyric with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void setImageBitmap(Bitmap bm) {
    Context context = getContext();
    if (context != null) {
        if (bm == null) {
            if (defaultShown && defaultImageCounter > 0)
                defaultImageCounter--;
            bm = ((BitmapDrawable) getResources().getDrawable(this.defaultImageResources[defaultImageCounter++ % defaultImageResources.length])).getBitmap();
            defaultShown = true;
        } else
            defaultShown = false;
        Resources resources = context.getResources();
        TransitionDrawable td = new TransitionDrawable(new Drawable[]{
                new ColorDrawable(resources.getColor(android.R.color.transparent)),
                new BitmapDrawable(context.getResources(), bm)
        });
        setImageDrawable(td);
        td.startTransition(FADE_IN_TIME_MS);
    }
}
 
Example #24
Source File: Timber4.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(200);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
 
Example #25
Source File: BaseFadeInNetworkImageView.java    From soas with Apache License 2.0 6 votes vote down vote up
@Override
public void setImageBitmap(Bitmap bitmap) {
    // For configureBounds to be called and quick set.
    super.setImageBitmap(bitmap);

    if (bitmap != null) {
        Resources res = getResources();
        Drawable[] layers = new Drawable[2];

        // Layer 0.
        layers[0] = res.getDrawable(R.drawable.default_photo);

        // Layer 1.
        // For masking the Bitmap after scale_type is used.
        layers[1] = new BitmapDrawable(res, clipBitmap(bitmap));

        TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
        transitionDrawable.setCrossFadeEnabled(true);
        setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(400);
    }
}
 
Example #26
Source File: TwoWayAbsListView.java    From recent-images with MIT License 5 votes vote down vote up
/**
 * Sets the selector state to "pressed" and posts a CheckForKeyLongPress to see if
 * this is a long press.
 */
void keyPressed() {
	if (!isEnabled() || !isClickable()) {
		return;
	}

	Drawable selector = mSelector;
	Rect selectorRect = mSelectorRect;
	if (selector != null && (isFocused() || touchModeDrawsInPressedState())
			&& selectorRect != null && !selectorRect.isEmpty()) {

		final View v = getChildAt(mSelectedPosition - mFirstPosition);

		if (v != null) {
			if (v.hasFocusable()) return;
			v.setPressed(true);
		}
		setPressed(true);

		final boolean longClickable = isLongClickable();
		Drawable d = selector.getCurrent();
		if (d != null && d instanceof TransitionDrawable) {
			if (longClickable) {
				((TransitionDrawable) d).startTransition(
						ViewConfiguration.getLongPressTimeout());
			} else {
				((TransitionDrawable) d).resetTransition();
			}
		}
		if (longClickable && !mDataChanged) {
			if (mPendingCheckForKeyLongPress == null) {
				mPendingCheckForKeyLongPress = new CheckForKeyLongPress();
			}
			mPendingCheckForKeyLongPress.rememberWindowAttachCount();
			postDelayed(mPendingCheckForKeyLongPress, ViewConfiguration.getLongPressTimeout());
		}
	}
}
 
Example #27
Source File: PLAAbsListView.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
public void run() {
    if (mTouchMode == TOUCH_MODE_DOWN) {
        mTouchMode = TOUCH_MODE_TAP;
        final View child = getChildAt(mMotionPosition - mFirstPosition);
        if (child != null && !child.hasFocusable()) {
            mLayoutMode = LAYOUT_NORMAL;

            if (!mDataChanged) {
                layoutChildren();
                child.setPressed(true);
                positionSelector(child);
                setPressed(true);

                final int longPressTimeout = ViewConfiguration.getLongPressTimeout();
                final boolean longClickable = isLongClickable();

                if (mSelector != null) {
                    Drawable d = mSelector.getCurrent();
                    if (d != null && d instanceof TransitionDrawable) {
                        if (longClickable) {
                            ((TransitionDrawable) d).startTransition(longPressTimeout);
                        } else {
                            ((TransitionDrawable) d).resetTransition();
                        }
                    }
                }

                if (longClickable) {
                } else {
                    mTouchMode = TOUCH_MODE_DONE_WAITING;
                }
            } else {
                mTouchMode = TOUCH_MODE_DONE_WAITING;
            }
        }
    }
}
 
Example #28
Source File: DeleteDropTarget.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // Get the drawable
    mOriginalTextColor = getTextColors();

    // Get the hover color
    Resources r = getResources();
    mHoverColor = r.getColor(R.color.delete_target_hover_tint);
    mUninstallDrawable = (TransitionDrawable) 
            r.getDrawable(R.drawable.uninstall_target_selector);
    mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);

    mRemoveDrawable.setCrossFadeEnabled(true);
    mUninstallDrawable.setCrossFadeEnabled(true);

    // The current drawable is set to either the remove drawable or the uninstall drawable 
    // and is initially set to the remove drawable, as set in the layout xml.
    mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();

    // Remove the text in the Phone UI in landscape
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (!LauncherAppState.getInstance().isScreenLarge()) {
            setText("");
        }
    }
}
 
Example #29
Source File: LoadImageView.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onGetObject(@NonNull ValueHolder<ImageWrapper> holder, Conaco.Source source) {
    // Release
    mKey = null;
    mUrl = null;
    mContainer = null;

    holder.obtain(this);

    removeDrawableAndHolder();

    mHolder = holder;
    ImageWrapper imageWrapper = holder.getValue();
    Drawable drawable = new ImageDrawable(imageWrapper);
    imageWrapper.start();

    if ((source == Conaco.Source.DISK || source == Conaco.Source.NETWORK) &&
            imageWrapper.getFrameCount() <= 1) {
        Drawable[] layers = new Drawable[2];
        layers[0] = new ColorDrawable(Color.TRANSPARENT);
        layers[1] = drawable;
        TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
        setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(300);
    } else {
        setImageDrawable(drawable);
    }

    return true;
}
 
Example #30
Source File: UTilitiesActivity.java    From utexas-utilities with Apache License 2.0 5 votes vote down vote up
@Override
public void onFocusChange(View v, boolean hasFocus) {
    if (hasFocus) {
        ((TransitionDrawable) ((ImageView) v).getDrawable())
                .startTransition(BUTTON_ANIMATION_DURATION);
    } else {
        ((TransitionDrawable) ((ImageView) v).getDrawable())
                .reverseTransition(BUTTON_ANIMATION_DURATION);
    }

}