From 684cb8197435eb08d3a30191be37a9dfa3d93d1c Mon Sep 17 00:00:00 2001 From: kapodamy Date: Sat, 19 Jan 2019 16:22:24 -0300 Subject: [PATCH] Update MissionsFragment.java work-around for reading the current theme icons --- .../giga/ui/fragment/MissionsFragment.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 33e7b0a8a..25960a419 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -16,6 +16,7 @@ import android.support.annotation.DrawableRes; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -198,12 +199,20 @@ public class MissionsFragment extends Fragment { } @DrawableRes - private int getDrawableFromAttribute(@AttrRes int ic) { - TypedArray styledAttributes = mContext.obtainStyledAttributes(new int[]{ic}); - int resId = styledAttributes.getResourceId(0, -1); + private int getDrawableFromAttribute(@AttrRes int attr) { + TypedArray styledAttributes = mContext.getTheme().obtainStyledAttributes(new int[]{attr}); + int resId = styledAttributes.getResourceId(0, 0); styledAttributes.recycle(); - return resId; + if (resId != 0) { + return resId; + } else { + // work-around + styledAttributes = mContext.obtainStyledAttributes(new int[]{attr}); + resId = styledAttributes.getResourceId(0, 0); + styledAttributes.recycle(); + return resId; + } } @Override