diff --git a/build.gradle b/build.gradle index 9771250..914e8c1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ ext { minSdkVersion = 17 targetSdkVersion = 28 - versionCode = 10 - versionName = "0.2.5" + versionCode = 11 + versionName = "0.2.6" } buildscript { diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index e718b94..12035c1 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -24,6 +24,7 @@ android:id="@+id/breadcrumbs_view" android:layout_width="match_parent" android:layout_height="wrap_content" + app:isRtl="true" app:popupTheme="@style/AppTheme.PopupOverlay" app:textColorSelected="@color/colorSelected" app:textColorUnSelected="@color/colorUnSelected" diff --git a/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsAdapter.java b/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsAdapter.java index 75eff93..c3cb8bf 100644 --- a/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsAdapter.java +++ b/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsAdapter.java @@ -150,7 +150,7 @@ class ArrowIconHolder extends ItemHolder { ArrowIconHolder(View itemView) { super(itemView); - Drawable normalDrawable = getContext().getResources().getDrawable(R.drawable.ic_chevron_right_black_24dp); + Drawable normalDrawable = getContext().getResources().getDrawable(R.drawable.ic_fiber_manual_record_black_24dp); Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable); if (mtextColorUnSelected != -1) DrawableCompat.setTint(wrapDrawable, mtextColorUnSelected); diff --git a/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsView.java b/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsView.java index 859a852..9beb3c2 100644 --- a/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsView.java +++ b/library/src/main/java/moe/feng/common/view/breadcrumbs/BreadcrumbsView.java @@ -30,8 +30,9 @@ public class BreadcrumbsView extends FrameLayout { */ private int mPopupThemeId = -1; private int mTextColorSelected = -1; - private int mtextColorUnSelected = -1; + private int mTextColorUnSelected = -1; private int mTextSizeCustom = -1; + private boolean isRtl = false; private static final String KEY_SUPER_STATES = BuildConfig.APPLICATION_ID + ".superStates"; private static final String KEY_BREADCRUMBS = BuildConfig.APPLICATION_ID + ".breadcrumbs"; @@ -51,8 +52,9 @@ public BreadcrumbsView(Context context, AttributeSet attrs, int defStyleAttr) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BreadcrumbsView, defStyleAttr, 0); mPopupThemeId = a.getResourceId(R.styleable.BreadcrumbsView_popupTheme, -1); mTextColorSelected = a.getColor(R.styleable.BreadcrumbsView_textColorSelected, -1); - mtextColorUnSelected = a.getColor(R.styleable.BreadcrumbsView_textColorUnSelected, -1); + mTextColorUnSelected = a.getColor(R.styleable.BreadcrumbsView_textColorUnSelected, -1); mTextSizeCustom = a.getDimensionPixelSize(R.styleable.BreadcrumbsView_textSizeCustom, -1); + isRtl = a.getBoolean(R.styleable.BreadcrumbsView_isRtl, false); a.recycle(); } @@ -70,8 +72,7 @@ private void init() { mRecyclerView = new RecyclerView(getContext()); // Create Horizontal LinearLayoutManager - LinearLayoutManager layoutManager = new LinearLayoutManager( - getContext(), LinearLayoutManager.HORIZONTAL, ViewUtils.isRtlLayout(getContext())); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, isRtl); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setOverScrollMode(OVER_SCROLL_NEVER); @@ -80,7 +81,7 @@ private void init() { } // Init Adapter if (mAdapter == null) { - mAdapter = new BreadcrumbsAdapter(this, mTextColorSelected, mtextColorUnSelected, mTextSizeCustom); + mAdapter = new BreadcrumbsAdapter(this, mTextColorSelected, mTextColorUnSelected, mTextSizeCustom); if (mPopupThemeId != -1) { mAdapter.setPopupThemeId(mPopupThemeId); } diff --git a/library/src/main/java/moe/feng/common/view/breadcrumbs/ViewUtils.java b/library/src/main/java/moe/feng/common/view/breadcrumbs/ViewUtils.java index a84596a..cd956e3 100644 --- a/library/src/main/java/moe/feng/common/view/breadcrumbs/ViewUtils.java +++ b/library/src/main/java/moe/feng/common/view/breadcrumbs/ViewUtils.java @@ -13,70 +13,70 @@ class ViewUtils { - /** - * Check if the current language is RTL - * - * @param context Context - * @return Result - */ - static boolean isRtlLayout(Context context) { - return context.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; - } + /** + * Check if the current language is RTL + * + * @param context Context + * @return Result + */ + static boolean isRtlLayout(Context context) { + return context.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + } - /** - * Get color attribute from current theme - * - * @param context Themed context - * @param attr The resource id of color attribute - * @return Result - */ - @ColorInt - static int getColorFromAttr(Context context, @AttrRes int attr) { - TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr}); - int color = array.getColor(0, Color.TRANSPARENT); - array.recycle(); - return color; - } + /** + * Get color attribute from current theme + * + * @param context Themed context + * @param attr The resource id of color attribute + * @return Result + */ + @ColorInt + static int getColorFromAttr(Context context, @AttrRes int attr) { + TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr}); + int color = array.getColor(0, Color.TRANSPARENT); + array.recycle(); + return color; + } - /** - * Measure content width from ListAdapter - * - * @param context Context - * @param listAdapter The adapter that should be measured - * @return Recommend popup window width - */ - static int measureContentWidth(Context context, ListAdapter listAdapter) { - ViewGroup mMeasureParent = null; - int maxWidth = 0; - View itemView = null; - int itemType = 0; + /** + * Measure content width from ListAdapter + * + * @param context Context + * @param listAdapter The adapter that should be measured + * @return Recommend popup window width + */ + static int measureContentWidth(Context context, ListAdapter listAdapter) { + ViewGroup mMeasureParent = null; + int maxWidth = 0; + View itemView = null; + int itemType = 0; - final ListAdapter adapter = listAdapter; - final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); - final int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); - final int count = adapter.getCount(); - for (int i = 0; i < count; i++) { - final int positionType = adapter.getItemViewType(i); - if (positionType != itemType) { - itemType = positionType; - itemView = null; - } + final ListAdapter adapter = listAdapter; + final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + final int count = adapter.getCount(); + for (int i = 0; i < count; i++) { + final int positionType = adapter.getItemViewType(i); + if (positionType != itemType) { + itemType = positionType; + itemView = null; + } - if (mMeasureParent == null) { - mMeasureParent = new FrameLayout(context); - } + if (mMeasureParent == null) { + mMeasureParent = new FrameLayout(context); + } - itemView = adapter.getView(i, itemView, mMeasureParent); - itemView.measure(widthMeasureSpec, heightMeasureSpec); + itemView = adapter.getView(i, itemView, mMeasureParent); + itemView.measure(widthMeasureSpec, heightMeasureSpec); - final int itemWidth = itemView.getMeasuredWidth(); + final int itemWidth = itemView.getMeasuredWidth(); - if (itemWidth > maxWidth) { - maxWidth = itemWidth; - } - } + if (itemWidth > maxWidth) { + maxWidth = itemWidth; + } + } - return maxWidth; - } + return maxWidth; + } } diff --git a/library/src/main/res/drawable/ic_fiber_manual_record_black_24dp.xml b/library/src/main/res/drawable/ic_fiber_manual_record_black_24dp.xml new file mode 100644 index 0000000..1a83d9b --- /dev/null +++ b/library/src/main/res/drawable/ic_fiber_manual_record_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 30da8c2..b4e3edd 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -6,6 +6,7 @@ + \ No newline at end of file