本文整理汇总了Java中android.graphics.drawable.TransitionDrawable.setCallback方法的典型用法代码示例。如果您正苦于以下问题:Java TransitionDrawable.setCallback方法的具体用法?Java TransitionDrawable.setCallback怎么用?Java TransitionDrawable.setCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.TransitionDrawable
的用法示例。
在下文中一共展示了TransitionDrawable.setCallback方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFrameReady_whenAttachedToDrawableCallbackButNotViewCallback_stops
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
@Test
public void onFrameReady_whenAttachedToDrawableCallbackButNotViewCallback_stops() {
TransitionDrawable topLevel = new TransitionDrawable(new Drawable[] { drawable });
drawable.setCallback(topLevel);
topLevel.setCallback(null);
drawable.start();
drawable.onFrameReady();
assertThat(drawable.isRunning()).isFalse();
}
示例2: onFrameReady_whenAttachedtoDrawableCallbackWithViewCallbackParent_doesNotStop
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
@Test
public void onFrameReady_whenAttachedtoDrawableCallbackWithViewCallbackParent_doesNotStop() {
TransitionDrawable topLevel = new TransitionDrawable(new Drawable[] { drawable });
drawable.setCallback(topLevel);
topLevel.setCallback(new View(context));
drawable.start();
drawable.onFrameReady();
assertThat(drawable.isRunning()).isTrue();
}
示例3: fadeBackground
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
/**
* Fade the ActionBar background from oldDrawable to newDrawable
*
* @param oldDrawable Drawable to be faded from
* @param newDrawable Drawable to be faded to
* @return Instance of this class
*/
private ActionBarBackground fadeBackground(Drawable oldDrawable, Drawable newDrawable) {
if (oldDrawable == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
newDrawable.setCallback(drawableCallback);
} else {
mActionBar.setBackgroundDrawable(newDrawable);
}
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[]{oldDrawable, newDrawable});
td.setCrossFadeEnabled(true);
// workaround for broken ActionBarContainer drawable handling on
// pre-API 17 builds
// https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
td.setCallback(drawableCallback);
} else {
int paddingTop = mToolbar.getPaddingTop();
mActionBar.setBackgroundDrawable(td);
mToolbar.setPadding(mToolbar.getPaddingLeft(), paddingTop, mToolbar.getPaddingRight(), mToolbar.getPaddingBottom()); // fix for fitSystemWindows
}
td.startTransition(500);
}
mOldBackground = newDrawable;
// http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
//mActionBar.setDisplayShowTitleEnabled(false);
//mActionBar.setDisplayShowTitleEnabled(true);
return this;
}
示例4: changeColor
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
private void changeColor(int newColor) {
tabs.setIndicatorColor(newColor);
// change ActionBar color just if an ActionBar is available
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Drawable colorDrawable = new ColorDrawable(newColor);
Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });
if (oldBackground == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
ld.setCallback(drawableCallback);
} else {
getActionBar().setBackgroundDrawable(ld);
}
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });
// workaround for broken ActionBarContainer drawable handling on
// pre-API 17 builds
// https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
td.setCallback(drawableCallback);
} else {
getActionBar().setBackgroundDrawable(td);
}
td.startTransition(200);
}
oldBackground = ld;
// http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
}
currentColor = newColor;
}
示例5: changeColor
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
private void changeColor(int newColor) {
tabs.setIndicatorColor(newColor);
// change ActionBar color just if an ActionBar is available
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Drawable colorDrawable = new ColorDrawable(newColor);
Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });
if (oldBackground == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
ld.setCallback(drawableCallback);
} else {
getActionBar().setBackgroundDrawable(ld);
}
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });
// workaround for broken ActionBarContainer drawable handling on
// pre-API 17 builds
// https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
td.setCallback(drawableCallback);
} else {
getActionBar().setBackgroundDrawable(td);
}
td.startTransition(200);
}
oldBackground = ld;
// http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
}
currentColor = newColor;
}
示例6: changeColor
import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
/**
* Method to set the color scheme according to the color defined in
* config.xml
*
* @param newColor : the color retrieved from config.xml
*/
public void changeColor(int newColor) {
tabs.setIndicatorColor(newColor);
Drawable colorDrawable = new ColorDrawable(newColor);
Drawable bottomDrawable = getResources().getDrawable(
R.drawable.actionbar_bottom);
LayerDrawable ld = new LayerDrawable(new Drawable[]{colorDrawable,
bottomDrawable});
if (oldBackground == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
ld.setCallback(drawableCallback);
else
getSupportActionBar().setBackgroundDrawable(ld);
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[]{
oldBackground, ld});
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
td.setCallback(drawableCallback);
else
getSupportActionBar().setBackgroundDrawable(td);
td.startTransition(200);
}
oldBackground = ld;
currentColor = newColor;
/**
* The following is a work-around to avoid NPE, see the following
* thread:
*
* @see http://stackoverflow.com/questions/11002691/actionbar-
* setbackgrounddrawable-nulling-background-from-thread-handler
*/
try {
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(true);
} catch (NullPointerException e) {
Log.e("NPE", e.getMessage());
}
}