當前位置: 首頁>>代碼示例>>Java>>正文


Java TransitionDrawable.setCallback方法代碼示例

本文整理匯總了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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:GifDrawableTest.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:GifDrawableTest.java

示例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;
}
 
開發者ID:PTCE,項目名稱:popcorn-android,代碼行數:41,代碼來源:ActionBarBackground.java

示例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;

	}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:48,代碼來源:MainActivity.java

示例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;

	}
 
開發者ID:JinBoy23520,項目名稱:TingTingMusic,代碼行數:47,代碼來源:MainActivity.java

示例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());
    }

}
 
開發者ID:hsbadr,項目名稱:MultiSystem,代碼行數:48,代碼來源:MainActivity.java


注:本文中的android.graphics.drawable.TransitionDrawable.setCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。