Skip to content
This repository has been archived by the owner on Dec 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #43 from Longi94/development
Browse files Browse the repository at this point in the history
v2.1.2
  • Loading branch information
Longi94 committed May 2, 2016
2 parents f82fc3b + c194044 commit 236c596
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> xValues = new ArrayList<>();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
public class QualityAdapter extends BaseAdapter {

private static final String[] QUALITIES = {
"Collector's", "Decorated Weapon", "Genuine", "Haunted", "Normal", "Self-Made",
Expand All @@ -43,33 +45,58 @@ public class QualityAdapter extends ArrayAdapter<String> {
private final Context mContext;

public QualityAdapter(Context context) {
super(context, R.layout.quality_spinner_item, QUALITIES);
quality = new Item();
quality.setDefindex(15059);
mContext = 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 24 additions & 23 deletions app/src/main/java/com/tlongdev/bktf/model/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -236,7 +237,9 @@ public void run() {

@Override
public void hideRefreshingAnimation() {
mSwipeRefreshLayout.setRefreshing(false);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(false);
}
}

@Override
Expand Down
Loading

0 comments on commit 236c596

Please sign in to comment.