diff --git a/app/src/main/java/com/tlongdev/bktf/adapter/BackpackAdapter.java b/app/src/main/java/com/tlongdev/bktf/adapter/BackpackAdapter.java index 42e654bd..7ea54700 100644 --- a/app/src/main/java/com/tlongdev/bktf/adapter/BackpackAdapter.java +++ b/app/src/main/java/com/tlongdev/bktf/adapter/BackpackAdapter.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -18,6 +18,7 @@ import android.content.Context; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -30,7 +31,6 @@ import com.tlongdev.bktf.BptfApplication; import com.tlongdev.bktf.R; import com.tlongdev.bktf.model.BackpackItem; -import com.tlongdev.bktf.util.Utility; import java.util.List; @@ -130,7 +130,7 @@ public void onBindViewHolder(final ViewHolder holder, int position) { holder.icon.setImageDrawable(null); holder.effect.setImageDrawable(null); holder.paint.setImageDrawable(null); - holder.root.setCardBackgroundColor(Utility.getColor(mContext, R.color.card_color)); + holder.root.setCardBackgroundColor(ContextCompat.getColor(mContext, R.color.card_color)); holder.root.setOnClickListener(null); holder.quality.setVisibility(View.GONE); diff --git a/app/src/main/java/com/tlongdev/bktf/adapter/HistoryAdapter.java b/app/src/main/java/com/tlongdev/bktf/adapter/HistoryAdapter.java index 00e848b4..dd4fc55a 100644 --- a/app/src/main/java/com/tlongdev/bktf/adapter/HistoryAdapter.java +++ b/app/src/main/java/com/tlongdev/bktf/adapter/HistoryAdapter.java @@ -18,6 +18,7 @@ import android.content.Context; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -180,7 +181,7 @@ private void buildDataSet() { long days = TimeUnit.MILLISECONDS.toDays(last - first); - int textColor = Utility.getColor(mContext, R.color.text_primary); + int textColor = ContextCompat.getColor(mContext, R.color.text_primary); //Setup the X axis of the chart ArrayList xValues = new ArrayList<>(); @@ -228,7 +229,7 @@ private void buildChart(LineChart chart) { chart.getAxisRight().setEnabled(false); chart.getLegend().setEnabled(false); - int textColor = Utility.getColor(mContext, R.color.text_primary); + int textColor = ContextCompat.getColor(mContext, R.color.text_primary); XAxis xAxis = chart.getXAxis(); xAxis.setAvoidFirstLastClipping(true); diff --git a/app/src/main/java/com/tlongdev/bktf/adapter/spinner/QualityAdapter.java b/app/src/main/java/com/tlongdev/bktf/adapter/spinner/QualityAdapter.java index 2b7c43c5..62bc57f1 100644 --- a/app/src/main/java/com/tlongdev/bktf/adapter/spinner/QualityAdapter.java +++ b/app/src/main/java/com/tlongdev/bktf/adapter/spinner/QualityAdapter.java @@ -16,18 +16,20 @@ package com.tlongdev.bktf.adapter.spinner; +import android.app.Activity; import android.content.Context; import android.graphics.PorterDuff; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; import android.widget.TextView; import com.tlongdev.bktf.R; import com.tlongdev.bktf.model.Item; import com.tlongdev.bktf.model.Quality; -public class QualityAdapter extends ArrayAdapter { +public class QualityAdapter extends BaseAdapter { private static final String[] QUALITIES = { "Collector's", "Decorated Weapon", "Genuine", "Haunted", "Normal", "Self-Made", @@ -43,7 +45,6 @@ public class QualityAdapter extends ArrayAdapter { private final Context mContext; public QualityAdapter(Context context) { - super(context, R.layout.quality_spinner_item, QUALITIES); quality = new Item(); quality.setDefindex(15059); mContext = context; @@ -51,25 +52,51 @@ public QualityAdapter(Context context) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { - View rootView = super.getView(position, convertView, parent); - setView(rootView, position); - return rootView; + if (convertView == null) { + LayoutInflater lInflater = (LayoutInflater) mContext.getSystemService( + Activity.LAYOUT_INFLATER_SERVICE); + + convertView = lInflater.inflate(R.layout.quality_spinner_item, null); + } + setView(convertView, position); + return convertView; + } + + @Override + public int getCount() { + return QUALITY_IDS.length; + } + + @Override + public Object getItem(int position) { + return QUALITY_IDS[position]; + } + + @Override + public long getItemId(int position) { + return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { - View rootView = super.getDropDownView(position, convertView, parent); - setView(rootView, position); - return rootView; + if (convertView == null) { + LayoutInflater lInflater = (LayoutInflater) mContext.getSystemService( + Activity.LAYOUT_INFLATER_SERVICE); + + convertView = lInflater.inflate(R.layout.quality_spinner_item, null); + } + setView(convertView, position); + return convertView; } private void setView(View view, int position) { TextView text = (TextView) view.findViewById(R.id.text1); - text.setText(getItem(position)); + text.setText(QUALITIES[position]); quality.setQuality(QUALITY_IDS[position]); - text.getCompoundDrawables()[0].setColorFilter(quality.getColor(mContext, false), PorterDuff.Mode.MULTIPLY); + int color = quality.getColor(mContext, false); + text.getCompoundDrawables()[0].setColorFilter(color, PorterDuff.Mode.MULTIPLY); } public int getQualityId(int selectedItemPosition) { diff --git a/app/src/main/java/com/tlongdev/bktf/component/AdapterComponent.java b/app/src/main/java/com/tlongdev/bktf/component/AdapterComponent.java index b4b72774..94fa14c8 100644 --- a/app/src/main/java/com/tlongdev/bktf/component/AdapterComponent.java +++ b/app/src/main/java/com/tlongdev/bktf/component/AdapterComponent.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/com/tlongdev/bktf/customtabs/CustomTabActivityHelper.java b/app/src/main/java/com/tlongdev/bktf/customtabs/CustomTabActivityHelper.java index 29248d78..a8620707 100644 --- a/app/src/main/java/com/tlongdev/bktf/customtabs/CustomTabActivityHelper.java +++ b/app/src/main/java/com/tlongdev/bktf/customtabs/CustomTabActivityHelper.java @@ -8,6 +8,7 @@ import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsServiceConnection; import android.support.customtabs.CustomTabsSession; +import android.support.v4.content.ContextCompat; import com.tlongdev.bktf.R; @@ -47,7 +48,7 @@ public static void openCustomTab(Activity activity, } else { customTabsIntent.intent.setPackage(packageName); customTabsIntent.intent.putExtra(EXTRA_CUSTOM_TABS_TOOLBAR_COLOR, - activity.getResources().getColor(R.color.primary)); + ContextCompat.getColor(activity, R.color.primary)); customTabsIntent.launchUrl(activity, uri); } } diff --git a/app/src/main/java/com/tlongdev/bktf/gcm/GcmMessageHandler.java b/app/src/main/java/com/tlongdev/bktf/gcm/GcmMessageHandler.java index 8868e80c..8822f07b 100644 --- a/app/src/main/java/com/tlongdev/bktf/gcm/GcmMessageHandler.java +++ b/app/src/main/java/com/tlongdev/bktf/gcm/GcmMessageHandler.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/com/tlongdev/bktf/model/Item.java b/app/src/main/java/com/tlongdev/bktf/model/Item.java index 952cede1..7e141a6c 100644 --- a/app/src/main/java/com/tlongdev/bktf/model/Item.java +++ b/app/src/main/java/com/tlongdev/bktf/model/Item.java @@ -21,6 +21,7 @@ import android.database.Cursor; import android.os.Parcel; import android.os.Parcelable; +import android.support.v4.content.ContextCompat; import com.tlongdev.bktf.R; import com.tlongdev.bktf.data.DatabaseContract; @@ -338,40 +339,40 @@ public boolean canHaveEffects() { public int getColor(Context context, boolean isDark) { switch (quality) { case Quality.GENUINE: - return isDark ? Utility.getColor(context, R.color.tf2_genuine_color_dark) - : Utility.getColor(context, R.color.tf2_genuine_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_genuine_color_dark) + : ContextCompat.getColor(context, R.color.tf2_genuine_color); case Quality.VINTAGE: - return isDark ? Utility.getColor(context, R.color.tf2_vintage_color_dark) - : Utility.getColor(context, R.color.tf2_vintage_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_vintage_color_dark) + : ContextCompat.getColor(context, R.color.tf2_vintage_color); case Quality.UNUSUAL: - return isDark ? Utility.getColor(context, R.color.tf2_unusual_color_dark) - : Utility.getColor(context, R.color.tf2_unusual_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_unusual_color_dark) + : ContextCompat.getColor(context, R.color.tf2_unusual_color); case Quality.UNIQUE: - return isDark ? Utility.getColor(context, R.color.tf2_unique_color_dark) - : Utility.getColor(context, R.color.tf2_unique_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_unique_color_dark) + : ContextCompat.getColor(context, R.color.tf2_unique_color); case Quality.COMMUNITY: - return isDark ? Utility.getColor(context, R.color.tf2_community_color_dark) - : Utility.getColor(context, R.color.tf2_community_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_community_color_dark) + : ContextCompat.getColor(context, R.color.tf2_community_color); case Quality.VALVE: - return isDark ? Utility.getColor(context, R.color.tf2_valve_color_dark) - : Utility.getColor(context, R.color.tf2_valve_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_valve_color_dark) + : ContextCompat.getColor(context, R.color.tf2_valve_color); case Quality.SELF_MADE: - return isDark ? Utility.getColor(context, R.color.tf2_community_color_dark) - : Utility.getColor(context, R.color.tf2_community_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_community_color_dark) + : ContextCompat.getColor(context, R.color.tf2_community_color); case Quality.STRANGE: - return isDark ? Utility.getColor(context, R.color.tf2_strange_color_dark) - : Utility.getColor(context, R.color.tf2_strange_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_strange_color_dark) + : ContextCompat.getColor(context, R.color.tf2_strange_color); case Quality.HAUNTED: - return isDark ? Utility.getColor(context, R.color.tf2_haunted_color_dark) - : Utility.getColor(context, R.color.tf2_haunted_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_haunted_color_dark) + : ContextCompat.getColor(context, R.color.tf2_haunted_color); case Quality.COLLECTORS: - return isDark ? Utility.getColor(context, R.color.tf2_collectors_color_dark) - : Utility.getColor(context, R.color.tf2_collectors_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_collectors_color_dark) + : ContextCompat.getColor(context, R.color.tf2_collectors_color); case Quality.PAINTKITWEAPON: return getDecoratedWeaponColor(context, isDark); default: - return isDark ? Utility.getColor(context, R.color.tf2_normal_color_dark) - : Utility.getColor(context, R.color.tf2_normal_color); + return isDark ? ContextCompat.getColor(context, R.color.tf2_normal_color_dark) + : ContextCompat.getColor(context, R.color.tf2_normal_color); } } @@ -418,7 +419,7 @@ private int getDecoratedWeaponColor(Context context, boolean isDark) { } cursor.close(); } - return colorResource == 0 ? Utility.getColor(context, R.color.tf2_normal_color) : Utility.getColor(context, colorResource); + return colorResource == 0 ? ContextCompat.getColor(context, R.color.tf2_normal_color) : ContextCompat.getColor(context, colorResource); } /** diff --git a/app/src/main/java/com/tlongdev/bktf/presenter/fragment/RecentsPresenter.java b/app/src/main/java/com/tlongdev/bktf/presenter/fragment/RecentsPresenter.java index d70025ba..728dd348 100644 --- a/app/src/main/java/com/tlongdev/bktf/presenter/fragment/RecentsPresenter.java +++ b/app/src/main/java/com/tlongdev/bktf/presenter/fragment/RecentsPresenter.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/com/tlongdev/bktf/presenter/fragment/UserPresenter.java b/app/src/main/java/com/tlongdev/bktf/presenter/fragment/UserPresenter.java index a60d4a36..ad23405b 100644 --- a/app/src/main/java/com/tlongdev/bktf/presenter/fragment/UserPresenter.java +++ b/app/src/main/java/com/tlongdev/bktf/presenter/fragment/UserPresenter.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/com/tlongdev/bktf/ui/activity/AppCompatPreferenceActivity.java b/app/src/main/java/com/tlongdev/bktf/ui/activity/AppCompatPreferenceActivity.java index 717de62c..5916db36 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/activity/AppCompatPreferenceActivity.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/activity/AppCompatPreferenceActivity.java @@ -23,6 +23,7 @@ import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; @@ -33,7 +34,6 @@ import com.google.android.gms.analytics.Tracker; import com.tlongdev.bktf.BptfApplication; import com.tlongdev.bktf.R; -import com.tlongdev.bktf.util.Utility; import javax.inject.Inject; @@ -58,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) { //Set the color of the status bar if (Build.VERSION.SDK_INT >= 21) { - getWindow().setStatusBarColor(Utility.getColor(this, R.color.primary_dark)); + getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.primary_dark)); } } diff --git a/app/src/main/java/com/tlongdev/bktf/ui/activity/BptfActivity.java b/app/src/main/java/com/tlongdev/bktf/ui/activity/BptfActivity.java index 4ca28452..1020e3c6 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/activity/BptfActivity.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/activity/BptfActivity.java @@ -19,6 +19,7 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; @@ -27,7 +28,6 @@ import com.tlongdev.bktf.R; import com.tlongdev.bktf.ads.AdManager; import com.tlongdev.bktf.ui.view.BaseView; -import com.tlongdev.bktf.util.Utility; import javax.inject.Inject; @@ -50,7 +50,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { //Set the color of the status bar if (Build.VERSION.SDK_INT >= 21) { - getWindow().setStatusBarColor(Utility.getColor(this, R.color.primary_dark)); + getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.primary_dark)); } } diff --git a/app/src/main/java/com/tlongdev/bktf/ui/activity/ItemChooserActivity.java b/app/src/main/java/com/tlongdev/bktf/ui/activity/ItemChooserActivity.java index a2ff6631..6f1f0f3b 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/activity/ItemChooserActivity.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/activity/ItemChooserActivity.java @@ -108,7 +108,7 @@ protected void onCreate(Bundle savedInstanceState) { effectAdapter = new EffectAdapter(this); effectSpinner.setAdapter(effectAdapter); - qualityAdapter = new QualityAdapter(this); + qualityAdapter = new QualityAdapter(mApplication); qualitySpinner.setAdapter(qualityAdapter); qualitySpinner.setSelection(7); qualitySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/app/src/main/java/com/tlongdev/bktf/ui/activity/MainActivity.java b/app/src/main/java/com/tlongdev/bktf/ui/activity/MainActivity.java index 70e1deea..8d01c555 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/activity/MainActivity.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/activity/MainActivity.java @@ -24,6 +24,7 @@ import android.support.design.widget.NavigationView; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.ContextCompat; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; @@ -138,7 +139,7 @@ protected void onCreate(Bundle savedInstanceState) { PreferenceManager.setDefaultValues(this, R.xml.pref_general, false); //Setup the drawer - mDrawerLayout.setStatusBarBackgroundColor(Utility.getColor(this, R.color.primary_dark)); + mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, R.color.primary_dark)); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); diff --git a/app/src/main/java/com/tlongdev/bktf/ui/fragment/RecentsFragment.java b/app/src/main/java/com/tlongdev/bktf/ui/fragment/RecentsFragment.java index 03bee1d7..afa29136 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/fragment/RecentsFragment.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/fragment/RecentsFragment.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -28,6 +28,7 @@ import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.GridLayoutManager; @@ -150,7 +151,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mRecyclerView.setVisibility(View.GONE); //Set up the swipe refresh layout (color and listener) - mSwipeRefreshLayout.setColorSchemeColors(Utility.getColor(mContext, R.color.accent)); + mSwipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(mContext, R.color.accent)); mSwipeRefreshLayout.setOnRefreshListener(this); mAdManager.addAdView(mAdView); @@ -236,7 +237,9 @@ public void run() { @Override public void hideRefreshingAnimation() { - mSwipeRefreshLayout.setRefreshing(false); + if (mSwipeRefreshLayout != null) { + mSwipeRefreshLayout.setRefreshing(false); + } } @Override diff --git a/app/src/main/java/com/tlongdev/bktf/ui/fragment/UserFragment.java b/app/src/main/java/com/tlongdev/bktf/ui/fragment/UserFragment.java index 902dd60c..df06699c 100644 --- a/app/src/main/java/com/tlongdev/bktf/ui/fragment/UserFragment.java +++ b/app/src/main/java/com/tlongdev/bktf/ui/fragment/UserFragment.java @@ -27,6 +27,7 @@ import android.support.design.widget.AppBarLayout; import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CoordinatorLayout; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -157,7 +158,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, //Set the color of the refreshing animation if (!searchedUser) { - mSwipeRefreshLayout.setColorSchemeColors(Utility.getColor(mContext, R.color.accent)); + mSwipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(mContext, R.color.accent)); mSwipeRefreshLayout.setOnRefreshListener(mPresenter); mUser = mProfileManager.getUser(); @@ -217,7 +218,7 @@ public void onClick(View v) { //Get the steam id, do nothing if there is no steam id String steamId = mUser.getResolvedSteamId(); - if (steamId.equals("")) { + if (steamId == null || steamId.equals("")) { showToast("bptf: " + getString(R.string.error_no_steam_id), Toast.LENGTH_SHORT); return; } @@ -300,41 +301,41 @@ public void updateUserPage(User user) { lastOnlineText.setText(String.format("%s %s", getString(R.string.user_page_last_online), Utility.formatLastOnlineTime(mContext, System.currentTimeMillis() - lastOnline * 1000L))); } - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.text_primary)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.text_primary)); break; case 1: lastOnlineText.setText(getString(R.string.user_page_status_online)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 2: lastOnlineText.setText(getString(R.string.user_page_status_busy)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 3: lastOnlineText.setText(getString(R.string.user_page_status_away)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 4: lastOnlineText.setText(getString(R.string.user_page_status_snooze)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 5: lastOnlineText.setText(getString(R.string.user_page_status_trade)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 6: lastOnlineText.setText(getString(R.string.user_page_status_play)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_online)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_online)); break; case 7: lastOnlineText.setText(getString(R.string.user_page_status_in_game)); - lastOnlineText.setTextColor(Utility.getColor(mContext, R.color.player_in_game)); + lastOnlineText.setTextColor(ContextCompat.getColor(mContext, R.color.player_in_game)); break; } //Load drawables for player statuses - Drawable statusOk = getResources().getDrawable(R.drawable.ic_done_white_48dp); - Drawable statusBad = getResources().getDrawable(R.drawable.ic_close_white_48dp); + Drawable statusOk = ContextCompat.getDrawable(getActivity(), R.drawable.ic_done_white_48dp); + Drawable statusBad = ContextCompat.getDrawable(getActivity(), R.drawable.ic_close_white_48dp); if (statusOk != null) statusOk.setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY); if (statusBad != null) statusBad.setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY); @@ -425,7 +426,9 @@ public void run() { @Override public void hideRefreshingAnimation() { - mSwipeRefreshLayout.setRefreshing(false); + if (mSwipeRefreshLayout != null) { + mSwipeRefreshLayout.setRefreshing(false); + } } @Override diff --git a/app/src/main/java/com/tlongdev/bktf/util/ProfileManager.java b/app/src/main/java/com/tlongdev/bktf/util/ProfileManager.java index ea5a76f5..6fb786ca 100644 --- a/app/src/main/java/com/tlongdev/bktf/util/ProfileManager.java +++ b/app/src/main/java/com/tlongdev/bktf/util/ProfileManager.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/java/com/tlongdev/bktf/util/Utility.java b/app/src/main/java/com/tlongdev/bktf/util/Utility.java index b0c15c6e..225613f1 100644 --- a/app/src/main/java/com/tlongdev/bktf/util/Utility.java +++ b/app/src/main/java/com/tlongdev/bktf/util/Utility.java @@ -25,14 +25,13 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.ColorStateList; import android.database.Cursor; import android.media.RingtoneManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.os.Build; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; +import android.support.v4.content.ContextCompat; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; @@ -66,26 +65,6 @@ public class Utility { public static final double EPSILON = 0.0001; - /** - * Returns a color integer associated with a particular resource ID. If the - * resource holds a complex {@link ColorStateList}, then the default color - * from the set is returned. - * - * @param id The desired resource identifier, as generated by the aapt - * tool. This integer encodes the package, type, and resource - * entry. The value 0 is an invalid identifier. - * @param context the context - * @return A single color value in the form 0xAARRGGBB. - */ - public static int getColor(Context context, int id) { - if (Build.VERSION.SDK_INT >= 23) { - return context.getResources().getColor(id, null); - } else { - //noinspection deprecation - return context.getResources().getColor(id); - } - } - /** * Get the name of the unusual effect. * @@ -398,7 +377,7 @@ public static void createSimpleNotification(Context context, int id, String titl .setContentText(message) .setAutoCancel(true) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) - .setColor(getColor(context, R.color.primary)) + .setColor(ContextCompat.getColor(context, R.color.primary)) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); // Creates an explicit intent for an Activity in your app diff --git a/app/src/main/java/com/tlongdev/bktf/widget/FavoritesWidgetService.java b/app/src/main/java/com/tlongdev/bktf/widget/FavoritesWidgetService.java index 4fa58ba1..d49d5768 100644 --- a/app/src/main/java/com/tlongdev/bktf/widget/FavoritesWidgetService.java +++ b/app/src/main/java/com/tlongdev/bktf/widget/FavoritesWidgetService.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/app/src/main/res/layout/activity_item_chooser.xml b/app/src/main/res/layout/activity_item_chooser.xml index 1abeba2c..18d75995 100644 --- a/app/src/main/res/layout/activity_item_chooser.xml +++ b/app/src/main/res/layout/activity_item_chooser.xml @@ -117,7 +117,8 @@ + android:layout_height="wrap_content" + android:padding="16dp"/> + android:layout_height="wrap_content" + android:padding="16dp"/>