mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Remove warning when palette cannot be found
This commit is contained in:
@@ -20,9 +20,7 @@
|
|||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.helpers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
|
|
||||||
@@ -57,16 +55,8 @@ public class ColorHelper
|
|||||||
|
|
||||||
public static int[] getPalette(Context context)
|
public static int[] getPalette(Context context)
|
||||||
{
|
{
|
||||||
int[] attr = new int[] { R.attr.palette };
|
int resourceId = UIHelper.getStyleResource(context, R.attr.palette);
|
||||||
TypedArray array = context.obtainStyledAttributes(attr);
|
if(resourceId < 0) return CSV_PALETTE;
|
||||||
int resourceId = array.getResourceId(0, -1);
|
|
||||||
array.recycle();
|
|
||||||
|
|
||||||
if(resourceId < 0)
|
|
||||||
{
|
|
||||||
Log.w("ColorHelper", "could not find palette resource. Returning CSV palette");
|
|
||||||
return CSV_PALETTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.getResources().getIntArray(resourceId);
|
return context.getResources().getIntArray(resourceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,6 +208,16 @@ public abstract class UIHelper
|
|||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getStyleResource(Context context, int attrId)
|
||||||
|
{
|
||||||
|
int[] attr = new int[] { attrId };
|
||||||
|
TypedArray array = context.obtainStyledAttributes(attr);
|
||||||
|
int resourceId = array.getResourceId(0, -1);
|
||||||
|
array.recycle();
|
||||||
|
|
||||||
|
return resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
public static void applyCurrentTheme(Activity activity)
|
public static void applyCurrentTheme(Activity activity)
|
||||||
{
|
{
|
||||||
switch(getCurrentTheme())
|
switch(getCurrentTheme())
|
||||||
|
|||||||
Reference in New Issue
Block a user