Skip to content

Commit

Permalink
CircleIndicator 自定义属性删除
Browse files Browse the repository at this point in the history
  • Loading branch information
maning0303 committed Jul 2, 2020
1 parent f5b6fe1 commit e5d3c82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
import android.animation.AnimatorInflater;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.os.Build;

import androidx.annotation.AnimatorRes;
import androidx.annotation.DrawableRes;
import androidx.viewpager.widget.ViewPager;

import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;

import androidx.annotation.AnimatorRes;
import androidx.annotation.DrawableRes;
import androidx.viewpager.widget.ViewPager;

import com.maning.imagebrowserlibrary.R;

/**
Expand Down Expand Up @@ -64,41 +62,9 @@ public CircleIndicator(Context context, AttributeSet attrs, int defStyleAttr, in
}

private void init(Context context, AttributeSet attrs) {
handleTypedArray(context, attrs);
checkIndicatorConfig(context);
}

private void handleTypedArray(Context context, AttributeSet attrs) {
if (attrs == null) {
return;
}

TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MNImageBrowserCircleIndicator);
mIndicatorWidth =
typedArray.getDimensionPixelSize(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_width, -1);
mIndicatorHeight =
typedArray.getDimensionPixelSize(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_height, -1);
mIndicatorMargin =
typedArray.getDimensionPixelSize(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_margin, -1);

mAnimatorResId = typedArray.getResourceId(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_animator,
R.animator.browser_scale_with_alpha);
mAnimatorReverseResId =
typedArray.getResourceId(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_animator_reverse, 0);
mIndicatorBackgroundResId =
typedArray.getResourceId(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_drawable,
R.drawable.mn_browser_white_radius);
mIndicatorUnselectedBackgroundResId =
typedArray.getResourceId(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_drawable_unselected,
mIndicatorBackgroundResId);

int orientation = typedArray.getInt(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_orientation, -1);
setOrientation(orientation == VERTICAL ? VERTICAL : HORIZONTAL);

int gravity = typedArray.getInt(R.styleable.MNImageBrowserCircleIndicator_mn_ibci_gravity, -1);
setGravity(gravity >= 0 ? gravity : Gravity.CENTER);

typedArray.recycle();
setGravity(Gravity.CENTER);
setOrientation(HORIZONTAL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
android:propertyName="scaleX"
android:valueType="floatType"
android:valueFrom="1.0"
android:valueTo="1.8"/>
android:valueTo="1.6"/>

<objectAnimator
android:propertyName="scaleY"
android:valueType="floatType"
android:valueFrom="1.0"
android:valueTo="1.8"/>
android:valueTo="1.6"/>
</set>
55 changes: 0 additions & 55 deletions imagebrowserlibrary/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,59 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="MNImageBrowserCircleIndicator">
<attr name="mn_ibci_width" format="dimension"/>
<attr name="mn_ibci_height" format="dimension"/>
<attr name="mn_ibci_margin" format="dimension"/>
<attr name="mn_ibci_animator" format="reference"/>
<attr name="mn_ibci_animator_reverse" format="reference"/>
<attr name="mn_ibci_drawable" format="reference"/>
<attr name="mn_ibci_drawable_unselected" format="reference"/>

<attr name="mn_ibci_orientation" format="enum">
<!-- Defines an horizontal widget. -->
<enum name="horizontal" value="0"/>
<!-- Defines a vertical widget. -->
<enum name="vertical" value="1"/>
</attr>

<attr name="mn_ibci_gravity">
<!-- Push object to the top of its container, not changing its size. -->
<flag name="top" value="0x30"/>
<!-- Push object to the bottom of its container, not changing its size. -->
<flag name="bottom" value="0x50"/>
<!-- Push object to the left of its container, not changing its size. -->
<flag name="left" value="0x03"/>
<!-- Push object to the right of its container, not changing its size. -->
<flag name="right" value="0x05"/>
<!-- Place object in the vertical center of its container, not changing its size. -->
<flag name="center_vertical" value="0x10"/>
<!-- Grow the vertical size of the object if needed so it completely fills its container. -->
<flag name="fill_vertical" value="0x70"/>
<!-- Place object in the horizontal center of its container, not changing its size. -->
<flag name="center_horizontal" value="0x01"/>
<!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
<flag name="fill_horizontal" value="0x07"/>
<!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
<flag name="center" value="0x11"/>
<!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
<flag name="fill" value="0x77"/>
<!-- Additional option that can be set to have the top and/or bottom edges of
the child clipped to its container's bounds.
The clip will be based on the vertical gravity: a top gravity will clip the bottom
edge, a bottom gravity will clip the top edge, and neither will clip both edges. -->
<flag name="clip_vertical" value="0x80"/>
<!-- Additional option that can be set to have the left and/or right edges of
the child clipped to its container's bounds.
The clip will be based on the horizontal gravity: a left gravity will clip the right
edge, a right gravity will clip the left edge, and neither will clip both edges. -->
<flag name="clip_horizontal" value="0x08"/>
<!-- Push object to the beginning of its container, not changing its size. -->
<flag name="start" value="0x00800003"/>
<!-- Push object to the end of its container, not changing its size. -->
<flag name="end" value="0x00800005"/>
</attr>

</declare-styleable>

</resources>

0 comments on commit e5d3c82

Please sign in to comment.