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


Java Animatable類代碼示例

本文整理匯總了Java中android.graphics.drawable.Animatable的典型用法代碼示例。如果您正苦於以下問題:Java Animatable類的具體用法?Java Animatable怎麽用?Java Animatable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Animatable類屬於android.graphics.drawable包,在下文中一共展示了Animatable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setTitle("Anim Items");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (menu != null) {
                for (int i = 0; i < menu.size(); i++) {
                    Drawable drawable = menu.getItem(i).getIcon();
                    if (drawable instanceof Animatable) {
                        ((Animatable) drawable).start();
                    }
                }
            }
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:MainActivity.java

示例2: onOptionsItemSelected

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Drawable drawable = item.getIcon();
    if (drawable instanceof Animatable) {
        ((Animatable) drawable).start();
    }
    switch (item.getItemId()) {
        case R.id.action_cut:
            return true;
        case R.id.action_copy:
            return true;
        case R.id.action_share:
            return true;
        case R.id.action_delete:
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:MainActivity.java

示例3: onFinish

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public int onFinish(RefreshLayout layout, boolean success) {
    if (mProgressDrawable != null) {
        mProgressDrawable.stop();
    } else {
        Drawable drawable = mProgressView.getDrawable();
        if (drawable instanceof Animatable) {
            ((Animatable) drawable).stop();
        } else {
            mProgressView.animate().rotation(0).setDuration(300);
        }
    }
    mProgressView.setVisibility(GONE);
    if (success) {
        mTitleText.setText(REFRESH_HEADER_FINISH);
        setLastUpdateTime(new Date());
    } else {
        mTitleText.setText(REFRESH_HEADER_FAILED);
    }
    return mFinishDuration;//延遲500毫秒之後再彈回
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:ClassicsHeader.java

示例4: convert

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Nullable
static Resource<Bitmap> convert(BitmapPool bitmapPool, Drawable drawable, int width, int height) {
  // Handle DrawableContainer or StateListDrawables that may contain one or more BitmapDrawables.
  drawable = drawable.getCurrent();
  Bitmap result = null;
  boolean isRecycleable = false;
  if (drawable instanceof BitmapDrawable) {
    result = ((BitmapDrawable) drawable).getBitmap();
  } else if (!(drawable instanceof Animatable)) {
    result = drawToBitmap(bitmapPool, drawable, width, height);
    // We created and drew to the Bitmap, so it's safe for us to recycle or re-use.
    isRecycleable = true;
  }

  BitmapPool toUse = isRecycleable ? bitmapPool : NO_RECYCLE_BITMAP_POOL;
  return BitmapResource.obtain(result, toUse);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:DrawableToBitmapConverter.java

示例5: setProgress

import android.graphics.drawable.Animatable; //導入依賴的package包/類
private void setProgress(float progress) {
  Drawable progressBarDrawable = mFadeDrawable.getDrawable(PROGRESS_BAR_IMAGE_INDEX);
  if (progressBarDrawable == null) {
    return;
  }

  // display progressbar when not fully loaded, hide otherwise
  if (progress >= 0.999f) {
    if (progressBarDrawable instanceof Animatable) {
      ((Animatable) progressBarDrawable).stop();
    }
    fadeOutLayer(PROGRESS_BAR_IMAGE_INDEX);
  } else {
    if (progressBarDrawable instanceof Animatable) {
      ((Animatable) progressBarDrawable).start();
    }
    fadeInLayer(PROGRESS_BAR_IMAGE_INDEX);
  }
  // set drawable level, scaled to [0, 10000] per drawable specification
  progressBarDrawable.setLevel(Math.round(progress * 10000));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:GenericDraweeHierarchy.java

示例6: drawTrack

import android.graphics.drawable.Animatable; //導入依賴的package包/類
void drawTrack(Canvas canvas) {
    final Drawable d = mIndicator;
    if (d != null) {
        // Translate canvas so a indeterminate circular progress bar with padding
        // rotates properly in its animation
        final int saveCount = canvas.save();

        canvas.translate(getPaddingLeft(), getPaddingTop());

        d.draw(canvas);
        canvas.restoreToCount(saveCount);

        if (mShouldStartAnimationDrawable && d instanceof Animatable) {
            ((Animatable) d).start();
            mShouldStartAnimationDrawable = false;
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:19,代碼來源:AVLoadingIndicatorView.java

示例7: onFinalImageSet

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public synchronized void onFinalImageSet(
    String id,
    @Nullable INFO imageInfo,
    @Nullable Animatable animatable) {
  final int numberOfListeners = mListeners.size();
  for (int i = 0; i < numberOfListeners; ++i) {
    try {
      ControllerListener<? super INFO> listener = mListeners.get(i);
      if (listener != null) {
        listener.onFinalImageSet(id, imageInfo, animatable);
      }
    } catch (Exception exception) {
      // Don't punish the other listeners if we're given a bad one.
      onException("InternalListener exception in onFinalImageSet", exception);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ForwardingControllerListener.java

示例8: init

import android.graphics.drawable.Animatable; //導入依賴的package包/類
private void init() {
  mInstrumentation = new Instrumentation(this);
  mListener = new BaseControllerListener<Object>() {
    @Override
    public void onSubmit(String id, Object callerContext) {
      mInstrumentation.onStart();
    }
    @Override
    public void onFinalImageSet(
      String id,
      @Nullable Object imageInfo,
      @Nullable Animatable animatable) {
      mInstrumentation.onSuccess();
    }
    @Override
    public void onFailure(String id, Throwable throwable) {
      mInstrumentation.onFailure();
    }
    @Override
    public void onRelease(String id) {
      mInstrumentation.onCancellation();
    }
  };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:InstrumentedDraweeView.java

示例9: onFinish

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public int onFinish(RefreshLayout layout, boolean success) {
    if (mProgressDrawable != null) {
        mProgressDrawable.stop();
    } else {
        Drawable drawable = mProgressView.getDrawable();
        if (drawable instanceof Animatable) {
            ((Animatable) drawable).stop();
        } else {
            mProgressView.animate().rotation(0).setDuration(300);
        }
    }
    mProgressView.setVisibility(GONE);
    if (success) {
        mTitleText.setText(REFRESH_HEADER_FINISH);
        if (mLastTime != null) {
            setLastUpdateTime(new Date());
        }
    } else {
        mTitleText.setText(REFRESH_HEADER_FAILED);
    }
    return mFinishDuration;//延遲500毫秒之後再彈回
}
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:24,代碼來源:ClassicsHeader.java

示例10: onCreate

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    ButterKnife.bind(this);
    Uri uri = Uri.parse("asset:///splash.webp");
    mSplashPresenter = new SplashPresenterImpl(this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setAutoPlayAnimations(true)
            .setControllerListener(new BaseControllerListener<ImageInfo>(){
                @Override
                public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
                    super.onFinalImageSet(id, imageInfo, animatable);
                    mSplashPresenter.startCountDown(1);
                }
            })
            .build();
    splashDraweee.setController(controller);
}
 
開發者ID:stdnull,項目名稱:RunMap,代碼行數:21,代碼來源:SplashActivity.java

示例11: drawTrack

import android.graphics.drawable.Animatable; //導入依賴的package包/類
void drawTrack(Canvas canvas) {
    final Drawable d = DEFAULT_ANIMATION;
    if (d != null) {
        // Translate canvas so a indeterminate circular progress bar with padding
        // rotates properly in its animation
        final int saveCount = canvas.save();

        canvas.translate(getPaddingLeft(), getPaddingTop());

        d.draw(canvas);
        canvas.restoreToCount(saveCount);

        if (mShouldStartAnimationDrawable && d instanceof Animatable) {
            ((Animatable) d).start();
            mShouldStartAnimationDrawable = false;
        }
    }
}
 
開發者ID:yedashen,項目名稱:UltimateRecyclerView,代碼行數:19,代碼來源:RecyclerViewLoadingView.java

示例12: onStart

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
protected void onStart() {
    super.onStart();

    // Animate checkmark
    mFinalCheckmarkImageView.postDelayed(new Runnable() {
        @Override
        public void run() {
            mFinalCheckmarkImageView.setVisibility(View.VISIBLE);
            Drawable drawable = mFinalCheckmarkImageView.getDrawable();
            ((Animatable) drawable).start();

            playGoodJob();
        }
    }, DEFAULT_PLAYER_DELAY);
}
 
開發者ID:elimu-ai,項目名稱:start-guide,代碼行數:17,代碼來源:FinalActivity.java

示例13: setCallback2

import android.graphics.drawable.Animatable; //導入依賴的package包/類
public void setCallback2(@Nullable Callback callback) {

        this.callback = callback;
        super.setCallback(callback);

        // if not null -> means we are attached
        if (callback != null) {
            loader.load(destination, this);
        } else {
            if (result != null) {

                result.setCallback(null);

                // let's additionally stop if it Animatable
                if (result instanceof Animatable) {
                    ((Animatable) result).stop();
                }
            }
            loader.cancel(destination);
        }
    }
 
開發者ID:noties,項目名稱:Markwon,代碼行數:22,代碼來源:AsyncDrawable.java

示例14: onOptionsItemSelected

import android.graphics.drawable.Animatable; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_list_to_grid) {
        if (!((Animatable) item.getIcon()).isRunning()) {
            if (gridLayoutManager.getSpanCount() == 1) {
                item.setIcon(AnimatedVectorDrawableCompat.create(MainActivity.this, R.drawable.avd_list_to_grid));
                gridLayoutManager.setSpanCount(3);
            } else {
                item.setIcon(AnimatedVectorDrawableCompat.create(MainActivity.this, R.drawable.avd_grid_to_list));
                gridLayoutManager.setSpanCount(1);
            }
            ((Animatable) item.getIcon()).start();
            simpleAdapter.notifyItemRangeChanged(0, simpleAdapter.getItemCount());
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
開發者ID:adonixis,項目名稱:android-list-to-grid,代碼行數:22,代碼來源:MainActivity.java

示例15: loadImage

import android.graphics.drawable.Animatable; //導入依賴的package包/類
public static void loadImage(final PhotoDraweeView mPhotoDraweeView,
                             Uri uri) {
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(uri);
    controller.setAutoPlayAnimations(true);
    controller.setOldController(mPhotoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || mPhotoDraweeView == null) {
                return;
            }
            mPhotoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    mPhotoDraweeView.setController(controller.build());
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:19,代碼來源:UdeskUtil.java


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