Android Open Source - MediaCodecVideoPlayer Slide Drawable






From Project

Back to project page MediaCodecVideoPlayer.

License

The source code is released under:

Apache License

If you think the Android project MediaCodecVideoPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.simonvt.menudrawer;
//w  w  w  .  j a v  a 2 s  .  c  o m
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;

public class SlideDrawable extends Drawable implements Drawable.Callback {

    private Drawable mWrapped;
    private float mOffset;

    private final Rect mTmpRect = new Rect();

    private boolean mIsRtl;

    public SlideDrawable(Drawable wrapped) {
        mWrapped = wrapped;
    }

    public void setOffset(float offset) {
        mOffset = offset;
        invalidateSelf();
    }

    public float getOffset() {
        return mOffset;
    }

    void setIsRtl(boolean isRtl) {
        mIsRtl = isRtl;
        invalidateSelf();
    }

    @Override
    public void draw(Canvas canvas) {
        mWrapped.copyBounds(mTmpRect);
        canvas.save();
        if (mIsRtl) {
            canvas.translate(1.f / 3 * mTmpRect.width() * mOffset, 0);
        } else {
            canvas.translate(1.f / 3 * mTmpRect.width() * -mOffset, 0);
        }
        mWrapped.draw(canvas);
        canvas.restore();
    }

    @Override
    public void setChangingConfigurations(int configs) {
        mWrapped.setChangingConfigurations(configs);
    }

    @Override
    public int getChangingConfigurations() {
        return mWrapped.getChangingConfigurations();
    }

    @Override
    public void setDither(boolean dither) {
        mWrapped.setDither(dither);
    }

    @Override
    public void setFilterBitmap(boolean filter) {
        mWrapped.setFilterBitmap(filter);
    }

    @Override
    public void setAlpha(int alpha) {
        mWrapped.setAlpha(alpha);
    }

    @Override
    public void setColorFilter(ColorFilter cf) {
        mWrapped.setColorFilter(cf);
    }

    @Override
    public void setColorFilter(int color, PorterDuff.Mode mode) {
        mWrapped.setColorFilter(color, mode);
    }

    @Override
    public void clearColorFilter() {
        mWrapped.clearColorFilter();
    }

    @Override
    public boolean isStateful() {
        return mWrapped.isStateful();
    }

    @Override
    public boolean setState(int[] stateSet) {
        return mWrapped.setState(stateSet);
    }

    @Override
    public int[] getState() {
        return mWrapped.getState();
    }

    @Override
    public Drawable getCurrent() {
        return mWrapped.getCurrent();
    }

    @Override
    public boolean setVisible(boolean visible, boolean restart) {
        return super.setVisible(visible, restart);
    }

    @Override
    public int getOpacity() {
        return mWrapped.getOpacity();
    }

    @Override
    public Region getTransparentRegion() {
        return mWrapped.getTransparentRegion();
    }

    @Override
    protected boolean onStateChange(int[] state) {
        mWrapped.setState(state);
        return super.onStateChange(state);
    }

    @Override
    protected void onBoundsChange(Rect bounds) {
        super.onBoundsChange(bounds);
        mWrapped.setBounds(bounds);
    }

    @Override
    public int getIntrinsicWidth() {
        return mWrapped.getIntrinsicWidth();
    }

    @Override
    public int getIntrinsicHeight() {
        return mWrapped.getIntrinsicHeight();
    }

    @Override
    public int getMinimumWidth() {
        return mWrapped.getMinimumWidth();
    }

    @Override
    public int getMinimumHeight() {
        return mWrapped.getMinimumHeight();
    }

    @Override
    public boolean getPadding(Rect padding) {
        return mWrapped.getPadding(padding);
    }

    @Override
    public ConstantState getConstantState() {
        return super.getConstantState();
    }

    @Override
    public void invalidateDrawable(Drawable who) {
        if (who == mWrapped) {
            invalidateSelf();
        }
    }

    @Override
    public void scheduleDrawable(Drawable who, Runnable what, long when) {
        if (who == mWrapped) {
            scheduleSelf(what, when);
        }
    }

    @Override
    public void unscheduleDrawable(Drawable who, Runnable what) {
        if (who == mWrapped) {
            unscheduleSelf(what);
        }
    }
}




Java Source Code List

com.example.hellojni.HelloJni.java
com.jasonsoft.mediacodecvideoplayer.LoadThumbnailTask.java
com.jasonsoft.mediacodecvideoplayer.MediaCodecVideoPlayerActivity.java
com.jasonsoft.mediacodecvideoplayer.MenuDrawerBaseActivity.java
com.jasonsoft.mediacodecvideoplayer.RoundedCornerImageView.java
com.jasonsoft.mediacodecvideoplayer.Utils.java
com.jasonsoft.mediacodecvideoplayer.VideoSurfaceView.java
com.jasonsoft.mediacodecvideoplayer.adapter.MenuAdapter.java
com.jasonsoft.mediacodecvideoplayer.cache.CacheManager.java
com.jasonsoft.mediacodecvideoplayer.data.AsyncDrawable.java
com.jasonsoft.mediacodecvideoplayer.data.LoadThumbnailParams.java
com.jasonsoft.mediacodecvideoplayer.data.LoadThumbnailResult.java
com.jasonsoft.mediacodecvideoplayer.data.MenuDrawerCategory.java
com.jasonsoft.mediacodecvideoplayer.data.MenuDrawerItem.java
net.simonvt.menudrawer.BuildLayerFrameLayout.java
net.simonvt.menudrawer.ColorDrawable.java
net.simonvt.menudrawer.DraggableDrawer.java
net.simonvt.menudrawer.FloatScroller.java
net.simonvt.menudrawer.MenuDrawer.java
net.simonvt.menudrawer.NoClickThroughFrameLayout.java
net.simonvt.menudrawer.OverlayDrawer.java
net.simonvt.menudrawer.PeekInterpolator.java
net.simonvt.menudrawer.Position.java
net.simonvt.menudrawer.Scroller.java
net.simonvt.menudrawer.SinusoidalInterpolator.java
net.simonvt.menudrawer.SlideDrawable.java
net.simonvt.menudrawer.SlidingDrawer.java
net.simonvt.menudrawer.SmoothInterpolator.java
net.simonvt.menudrawer.StaticDrawer.java
net.simonvt.menudrawer.ViewHelper.java
net.simonvt.menudrawer.compat.ActionBarHelperCompat.java
net.simonvt.menudrawer.compat.ActionBarHelperNative.java
net.simonvt.menudrawer.compat.ActionBarHelper.java