Java 类android.graphics.drawable.InsetDrawable 实例源码

项目:Mix    文件:ThemeUtils.java   
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
项目:FireFiles    文件:DirectoryFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
       final Resources res = context.getResources();
    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    mListView.setMultiChoiceModeListener(mMultiListener);
    mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setOnItemClickListener(mItemListener);
    mGridView.setMultiChoiceModeListener(mMultiListener);
    mGridView.setRecyclerListener(mRecycleListener);

    return view;
}
项目:simple-share-android    文件:DirectoryFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
       final Resources res = context.getResources();
    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    mListView.setMultiChoiceModeListener(mMultiListener);
    mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setOnItemClickListener(mItemListener);
    mGridView.setMultiChoiceModeListener(mMultiListener);
    mGridView.setRecyclerListener(mRecycleListener);

    return view;
}
项目:MagicaSakura    文件:ThemeUtils.java   
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't get containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
项目:SimplOS    文件:WidgetsContainerView.java   
@Override
protected void onUpdateBackgroundAndPaddings(Rect searchBarBounds, Rect padding) {
    // Apply the top-bottom padding to the content itself so that the launcher transition is
    // clipped correctly
    mContent.setPadding(0, padding.top, 0, padding.bottom);

    // TODO: Use quantum_panel_dark instead of quantum_panel_shape_dark.
    InsetDrawable background = new InsetDrawable(
            getResources().getDrawable(R.drawable.quantum_panel_shape_dark), padding.left, 0,
            padding.right, 0);
    Rect bgPadding = new Rect();
    background.getPadding(bgPadding);
    mView.setBackground(background);
    getRevealView().setBackground(background.getConstantState().newDrawable());
    mView.updateBackgroundPadding(bgPadding);
}
项目:TbRepeatPicker    文件:SUtils.java   
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = DensityUtil.dip2px(context, 8);
    int paddingV = DensityUtil.dip2px(context, 4);
    int insetH = DensityUtil.dip2px(context, 4);
    int insetV = DensityUtil.dip2px(context, 6);
    int corner_radius = DensityUtil.dip2px(context, 2);
    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, corner_radius);

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);

    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);

    return new InsetDrawable(shapeDrawable,
            insetH, insetV, insetH, insetV);
}
项目:AndroidTint    文件:EmTintManager.java   
private static boolean shouldMutateBackground(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= 16) {
        // For SDK 16+, we should be fine mutating the drawable
        return true;
    }

    if (drawable instanceof LayerDrawable) {
        return Build.VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (Drawable child : containerState.getChildren()) {
                if (!shouldMutateBackground(child)) {
                    return false;
                }
            }
        }
    }
    return true;
}
项目:CheckSmarter    文件:SUtils.java   
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
    int paddingV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_vertical_material);
    int insetH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
    int insetV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_vertical_material);

    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, CORNER_RADIUS);

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);

    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);

    return new InsetDrawable(shapeDrawable,
            insetH, insetV, insetH, insetV);
}
项目:AyoSunny    文件:D_InsetDrawable.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_d__inset_drawable);

    InsetDrawable insetDrawable=new InsetDrawable(getResources().getDrawable(R.drawable.animate_shower), 20, 30, 30, 20); 

    /*
     * xml:
     * 
     * <inset xmlns:android="http://schemas.android.com/apk/res/android"   
            android:drawable="@drawable/image4"  
            android:insetLeft="50dp"  
            android:insetRight="50dp"  
            android:insetTop="20dp"  
            android:insetBottom="20dp">  
        </inset>
     */
    findViewById(R.id.tv).setBackground(insetDrawable);
}
项目:AyoSunny    文件:D_InsetDrawable.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_d__inset_drawable);

    InsetDrawable insetDrawable=new InsetDrawable(getResources().getDrawable(R.drawable.animate_shower), 20, 30, 30, 20); 

    /*
     * xml:
     * 
     * <inset xmlns:android="http://schemas.android.com/apk/res/android"   
            android:drawable="@drawable/image4"  
            android:insetLeft="50dp"  
            android:insetRight="50dp"  
            android:insetTop="20dp"  
            android:insetBottom="20dp">  
        </inset>
     */
    findViewById(R.id.tv).setBackground(insetDrawable);
}
项目:youkes_vr    文件:SettingItem.java   
@SuppressWarnings("deprecation")
private void setSettingBackground(int resid) {
    int[] rect = new int[4];
    rect[0] = getPaddingLeft();
    rect[1] = getPaddingTop();
    rect[2] = getPaddingRight();
    rect[3] = getPaddingBottom();
    if (isInsetDrawable()) {
        setBackgroundDrawable(new InsetDrawable(getContext().getResources()
                .getDrawable(resid), mInsetDrawableRect[0],
                mInsetDrawableRect[1], mInsetDrawableRect[2],
                mInsetDrawableRect[3]));
    } else {
        setBackgroundResource(resid);
    }
    setPadding(rect[0], rect[1], rect[2], rect[3]);
}
项目:BookMySkills    文件:DrawableProvider.java   
public Drawable getRectWithCustomSize() {
    String leftText = "I";
    String rightText = "J";

    TextDrawable.IBuilder builder = TextDrawable.builder().beginConfig()
            .width(toPx(29)).withBorder(toPx(2)).endConfig().rect();

    TextDrawable left = builder.build(leftText,
            mGenerator.getColor(leftText));

    TextDrawable right = builder.build(rightText,
            mGenerator.getColor(rightText));

    Drawable[] layerList = { new InsetDrawable(left, 0, 0, toPx(31), 0),
            new InsetDrawable(right, toPx(31), 0, 0, 0) };
    return new LayerDrawable(layerList);
}
项目:incubator-wave-android    文件:DrawableProvider.java   
public Drawable getRectWithCustomSize() {
    String leftText = "I";
    String rightText = "J";

    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
                .width(toPx(29))
                .withBorder(toPx(2))
            .endConfig()
            .rect();

    TextDrawable left = builder
            .build(leftText, mGenerator.getColor(leftText));

    TextDrawable right = builder
            .build(rightText, mGenerator.getColor(rightText));

    Drawable[] layerList = {
            new InsetDrawable(left, 0, 0, toPx(31), 0),
            new InsetDrawable(right, toPx(31), 0, 0, 0)
    };
    return new LayerDrawable(layerList);
}
项目:SublimePicker    文件:SUtils.java   
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
    int paddingV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_vertical_material);
    int insetH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
    int insetV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_vertical_material);

    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, CORNER_RADIUS);

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);

    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);

    return new InsetDrawable(shapeDrawable,
            insetH, insetV, insetH, insetV);
}
项目:FLauncher    文件:BaseContainerView.java   
private void onUpdateBackgroundAndPaddings(Rect padding) {
    // Apply the top-bottom padding to itself so that the launcher transition is
    // clipped correctly
    setPadding(0, padding.top, 0, padding.bottom);

    InsetDrawable background = new InsetDrawable(mRevealDrawable,
            padding.left, 0, padding.right, 0);
    mRevealView.setBackground(background.getConstantState().newDrawable());
    mContent.setBackground(background);

    // We let the content have a intent background, but still have full width.
    // This allows the scroll bar to be used responsive outside the background bounds as well.
    mContent.setPadding(0, 0, 0, 0);

    Rect bgPadding = new Rect();
    background.getPadding(bgPadding);
    onUpdateBgPadding(padding, bgPadding);
}
项目:kaif-android    文件:VoteArticleButton.java   
private void init(Context context) {
  setBackground(new InsetDrawable(new Triangle(context.getResources()
      .getColor(R.color.vote_state_empty)),
      (int) Views.convertDpToPixel(12, context),
      (int) Views.convertDpToPixel(4, context),
      (int) Views.convertDpToPixel(12, context),
      (int) Views.convertDpToPixel(4, context)));
  voteState = Vote.VoteState.EMPTY;
  setOnClickListener(v -> {
    if (onVoteClickListener != null) {
      Vote.VoteState from = this.voteState;
      Vote.VoteState to = (this.voteState == Vote.VoteState.EMPTY
                           ? Vote.VoteState.UP
                           : Vote.VoteState.EMPTY);
      onVoteClickListener.onVoteClicked(from, to);
    }
  });
}
项目:itsnat_droid    文件:Assert.java   
public static void assertEquals(InsetDrawable a,InsetDrawable b)
{
    assertEqualsDrawableWrapper(a, b);

    assertEquals(a.isStateful(), b.isStateful());
    // android:visible
    assertEquals(a.isVisible(), b.isVisible());

    Drawable.ConstantState a_state = a.getConstantState();
    Drawable.ConstantState b_state = b.getConstantState();

    Class classInsetState = TestUtil.resolveClass(InsetDrawable.class.getName() + "$InsetState");
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetLeft"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetLeft"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetTop"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetTop"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetRight"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetRight"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetBottom"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetBottom"));

    // android:drawable
    if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // < 23 (en level 23 mDrawable está en la clase base)
    {
        assertEquals((Drawable) TestUtil.getField(a_state, classInsetState, "mDrawable"), (Drawable) TestUtil.getField(b_state, classInsetState, "mDrawable"));
    }
}
项目:weekdays-buttons-bar    文件:WeekdaysDrawableProvider.java   
public Drawable getRectWithCustomSize(Context context, String leftText, String rightText, boolean selected) {

        TextDrawable.IBuilder builder = TextDrawable.builder()
                .beginConfig()
                .width(toPx(context, 29))
                .withBorder(toPx(context, 2))
                .textColor(selected ? getTextColorSelected() : getTextColorUnselected())
                .endConfig()
                .rect();


        TextDrawable left = builder
                .build(leftText, mGenerator.getColor(leftText));


        TextDrawable right = builder
                .build(rightText, mGenerator.getColor(rightText));


        Drawable[] layerList = {
                new InsetDrawable(left, 0, 0, toPx(context, 31), 0),
                new InsetDrawable(right, toPx(context, 31), 0, 0, 0)
        };
        return new LayerDrawable(layerList);
    }
项目:GreenMatter    文件:MatButton.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static GradientDrawable getRippleShapeDrawable(Drawable background) {
    if (!(background instanceof RippleDrawable))
        return null;

    RippleDrawable ripple = (RippleDrawable)background;
    Drawable possibleInset = ripple.getDrawable(0);
    if (!(possibleInset instanceof InsetDrawable))
        return null;

    InsetDrawable inset = (InsetDrawable)possibleInset;
    Drawable possibleGradient = inset.getDrawable();
    if (!(possibleGradient instanceof GradientDrawable))
        return null;

    // Mutate the drawable, otherwise the color will be set for all instances
    possibleGradient = possibleGradient.mutate();
    return (GradientDrawable)possibleGradient;
}
项目:recycler-fast-scroll    文件:DefaultScrollerViewProvider.java   
@Override
public View provideHandleView(ViewGroup container) {
    handle = new View(getContext());

    int verticalInset = getScroller().isVertical() ? 0 : getContext().getResources().getDimensionPixelSize(R.dimen.fastscroll__handle_inset);
    int horizontalInset = !getScroller().isVertical() ? 0 : getContext().getResources().getDimensionPixelSize(R.dimen.fastscroll__handle_inset);
    InsetDrawable handleBg = new InsetDrawable(ContextCompat.getDrawable(getContext(), R.drawable.fastscroll__default_handle), horizontalInset, verticalInset, horizontalInset, verticalInset);
    Utils.setBackground(handle, handleBg);

    int handleWidth = getContext().getResources().getDimensionPixelSize(getScroller().isVertical() ? R.dimen.fastscroll__handle_clickable_width : R.dimen.fastscroll__handle_height);
    int handleHeight = getContext().getResources().getDimensionPixelSize(getScroller().isVertical() ? R.dimen.fastscroll__handle_height : R.dimen.fastscroll__handle_clickable_width);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(handleWidth, handleHeight);
    handle.setLayoutParams(params);

    return handle;
}
项目:android-wave    文件:DrawableProvider.java   
public Drawable getRectWithCustomSize() {
    String leftText = "I";
    String rightText = "J";

    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
                .width(toPx(29))
                .withBorder(toPx(2))
            .endConfig()
            .rect();

    TextDrawable left = builder
            .build(leftText, mGenerator.getColor(leftText));

    TextDrawable right = builder
            .build(rightText, mGenerator.getColor(rightText));

    Drawable[] layerList = {
            new InsetDrawable(left, 0, 0, toPx(31), 0),
            new InsetDrawable(right, toPx(31), 0, 0, 0)
    };
    return new LayerDrawable(layerList);
}
项目:LaunchEnr    文件:BaseContainerView.java   
/**
 * Update the background for the reveal view and content view based on the background padding.
 */
protected void updateBackground(int paddingLeft, int paddingTop,
        int paddingRight, int paddingBottom) {
    mRevealView.setBackground(new InsetDrawable(mBaseDrawable,
            paddingLeft, paddingTop, paddingRight, paddingBottom));
    mContent.setBackground(new InsetDrawable(mBaseDrawable,
            paddingLeft, paddingTop, paddingRight, paddingBottom));
}
项目:LaunchEnr    文件:AllAppsContainerView.java   
@Override
protected void updateBackground(
        int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
    if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
        getRevealView().setBackground(new InsetDrawable(mBaseDrawable,
                paddingLeft, paddingTop, paddingRight, paddingBottom));
        getContentView().setBackground(
                new InsetDrawable(new ColorDrawable(Color.TRANSPARENT),
                        paddingLeft, paddingTop, paddingRight, paddingBottom));
    } else {
        getRevealView().setBackground(mBaseDrawable);
    }
}
项目:android_ui    文件:DrawableWrapper.java   
/**
 */
@Override
@SuppressLint("NewApi")
public Drawable getCurrent() {
    if (mDrawable instanceof InsetDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final Drawable innerDrawable = ((InsetDrawable) mDrawable).getDrawable();
        return innerDrawable != null ? innerDrawable.getCurrent() : null;
    }
    return mDrawable.getCurrent();
}
项目:easyfilemanager    文件:DirectoryFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
       final Resources res = context.getResources();
    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    mListView.setMultiChoiceModeListener(mMultiListener);
    mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setOnItemClickListener(mItemListener);
    mGridView.setMultiChoiceModeListener(mMultiListener);
    mGridView.setRecyclerListener(mRecycleListener);

    return view;
}
项目:easyfilemanager    文件:ConnectionsFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setOnItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
    } else {
        mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
    }
}
项目:cwac-crossport    文件:DrawableUtils.java   
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse its child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } /*else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    }*/ else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
项目:cwac-crossport    文件:FloatingActionButtonLollipop.java   
@Override
void onPaddingUpdated(Rect padding) {
  if (mShadowViewDelegate.isCompatPaddingEnabled()) {
          mInsetDrawable = new InsetDrawable(mRippleDrawable,
                  padding.left, padding.top, padding.right, padding.bottom);
    mShadowViewDelegate.setBackgroundDrawable(mInsetDrawable);
  } else {
    mShadowViewDelegate.setBackgroundDrawable(mRippleDrawable);
  }
}
项目:FireFiles    文件:ConnectionsFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setOnItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
    } else {
        mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
    }
}
项目:boohee_v5.6    文件:DrawableWrapperLollipop.java   
protected boolean isCompatTintEnabled() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.mDrawable;
    if ((drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable)) {
        return true;
    }
    return false;
}
项目:boohee_v5.6    文件:FloatingActionButtonLollipop.java   
void onPaddingUpdated(Rect padding) {
    if (this.mShadowViewDelegate.isCompatPaddingEnabled()) {
        this.mInsetDrawable = new InsetDrawable(this.mRippleDrawable, padding.left, padding.top, padding.right, padding.bottom);
        this.mShadowViewDelegate.setBackgroundDrawable(this.mInsetDrawable);
        return;
    }
    this.mShadowViewDelegate.setBackgroundDrawable(this.mRippleDrawable);
}
项目:simple-share-android    文件:ConnectionsFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setOnItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
    } else {
        mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
    }
}
项目:phonk    文件:PSlider_.java   
public PSlider_(AppRunner appRunner) {
    super(appRunner.getAppContext());
    super.setMax(MAX_VALUE);
    // setProgressDrawable(getResources().getDrawable(R.drawable.ui_seekbar_progress));

    mSlider = this;
    // getStyles = new Styler(appRunner, this);

    //Custom background drawable allows you to draw how you want it to look if needed
    // SeekBarBackgroundDrawable backgroundDrawable = new SeekBarBackgroundDrawable(appRunner.getAppContext());
    ColorDrawable progressDrawable = new ColorDrawable(Color.BLUE);
    SeekBarProgressDrawable clipProgressDrawable = new SeekBarProgressDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL, appRunner.getAppContext());

    ColorDrawable progressDrawable2 = new ColorDrawable(Color.GREEN);
    //Custom seek bar slider drawable. Also allows you to modify appearance.
    InsetDrawable insetDrawable = new InsetDrawable(progressDrawable2, 0, 0, 0, 0);

    Drawable[] drawables = new Drawable[]{ insetDrawable, clipProgressDrawable };

    //Create layer drawables with android pre-defined ids
    LayerDrawable layerDrawable = new LayerDrawable(drawables);
    // layerDrawable.setId(0,android.R.id.background);
    // layerDrawable.setId(1,android.R.id.slider);

    //Set to seek bar
    setThumb(null);
    setProgressDrawable(layerDrawable);
}
项目:Android-skin-support    文件:SkinCompatDrawableUtils.java   
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
项目:FlickLauncher    文件:BaseContainerView.java   
private void updatePaddings() {
    Context context = getContext();
    Launcher launcher = Launcher.getLauncher(context);

    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP &&
            this instanceof AllAppsContainerView &&
            !launcher.getDeviceProfile().isVerticalBarLayout()) {
        mContainerPaddingLeft = mContainerPaddingRight = 0;
        mContainerPaddingTop = mContainerPaddingBottom = 0;
    } else {
        DeviceProfile grid = launcher.getDeviceProfile();
        int[] padding = grid.getContainerPadding(context);
        mContainerPaddingLeft = padding[0] + grid.edgeMarginPx;
        mContainerPaddingRight = padding[1] + grid.edgeMarginPx;
        if (!launcher.getDeviceProfile().isVerticalBarLayout()) {
            mContainerPaddingTop = mContainerPaddingBottom = grid.edgeMarginPx;
        } else {
            mContainerPaddingTop = mContainerPaddingBottom = 0;
        }
    }

    mRevealDrawable = new InsetDrawable(mBaseDrawable,
            mContainerPaddingLeft, mContainerPaddingTop, mContainerPaddingRight,
            mContainerPaddingBottom);
    mRevealView.setBackground(mRevealDrawable);
    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) {
        // Skip updating the content background
    } else {
        mContent.setBackground(mRevealDrawable);
    }
}
项目:SetupWizardLibCompat    文件:DrawableLayoutDirectionHelper.java   
/**
 * Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
 * of {@code view}.
 */
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
        int insetStart, int insetTop, int insetEnd, int insetBottom, View view) {
    boolean isRtl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
            && view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
            isRtl);
}
项目:SetupWizardLibCompat    文件:DrawableLayoutDirectionHelper.java   
/**
 * Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
 * of {@code context}.
 */
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
        int insetStart, int insetTop, int insetEnd, int insetBottom, Context context) {
    boolean isRtl = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        final int layoutDirection =
                context.getResources().getConfiguration().getLayoutDirection();
        isRtl = layoutDirection == View.LAYOUT_DIRECTION_RTL;
    }
    return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
            isRtl);
}
项目:SetupWizardLibCompat    文件:DrawableLayoutDirectionHelper.java   
/**
 * Creates an {@link android.graphics.drawable.InsetDrawable} according to
 * {@code layoutDirection}.
 */
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
        int insetStart, int insetTop, int insetEnd, int insetBottom, int layoutDirection) {
    //noinspection AndroidLintInlinedApi
    return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
            layoutDirection == View.LAYOUT_DIRECTION_RTL);
}
项目:SetupWizardLibCompat    文件:DrawableLayoutDirectionHelper.java   
private static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
        int insetStart, int insetTop, int insetEnd, int insetBottom, boolean isRtl) {
    if (isRtl) {
        return new InsetDrawable(drawable, insetEnd, insetTop, insetStart, insetBottom);
    } else {
        return new InsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom);
    }
}
项目:SimpleUILauncher    文件:BaseContainerView.java   
private void updatePaddings() {
    Context context = getContext();
    Launcher launcher = Launcher.getLauncher(context);

    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP &&
            this instanceof AllAppsContainerView &&
            !launcher.getDeviceProfile().isVerticalBarLayout()) {
        mContainerPaddingLeft = mContainerPaddingRight = 0;
        mContainerPaddingTop = mContainerPaddingBottom = 0;
    } else {
        DeviceProfile grid = launcher.getDeviceProfile();
        int[] padding = grid.getContainerPadding(context);
        mContainerPaddingLeft = padding[0] + grid.edgeMarginPx;
        mContainerPaddingRight = padding[1] + grid.edgeMarginPx;
        if (!launcher.getDeviceProfile().isVerticalBarLayout()) {
            mContainerPaddingTop = mContainerPaddingBottom = grid.edgeMarginPx;
        } else {
            mContainerPaddingTop = mContainerPaddingBottom = 0;
        }
    }

    mRevealDrawable = new InsetDrawable(mBaseDrawable,
            mContainerPaddingLeft, mContainerPaddingTop, mContainerPaddingRight,
            mContainerPaddingBottom);
    mRevealView.setBackground(mRevealDrawable);
    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) {
        // Skip updating the content background
    } else {
        mContent.setBackground(mRevealDrawable);
    }
}