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 #47 from Longi94/development
Browse files Browse the repository at this point in the history
v2.1.5
  • Loading branch information
Longi94 committed May 13, 2016
2 parents c7f4453 + e58fe3a commit 5be431b
Show file tree
Hide file tree
Showing 127 changed files with 253 additions and 127 deletions.
26 changes: 13 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.tlongdev.bktf"
minSdkVersion 14
targetSdkVersion 23
versionCode 46
versionName "2.1.4"
versionCode 47
versionName "2.1.5"

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down Expand Up @@ -58,7 +58,7 @@ dependencies {
testCompile "org.robolectric:robolectric:3.1-SNAPSHOT"

apt 'com.jakewharton:butterknife-compiler:8.0.0'
apt 'com.google.dagger:dagger-compiler:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.2'
provided 'com.f2prateek.dart:dart-processor:2.0.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
Expand All @@ -70,20 +70,20 @@ dependencies {
compile('com.squareup.okhttp3:okhttp:3.2.0') {
exclude group: 'com.squareup.okio', module: 'okio'
}
compile 'com.android.support:support-annotations:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:customtabs:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:percent:23.3.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:customtabs:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:percent:23.4.0'
compile 'com.f2prateek.dart:dart:2.0.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.dagger:dagger:2.0.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
compile 'com.google.dagger:dagger:2.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
Expand Down
Binary file added app/src/main/assets/items/30767.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30768.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30769.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30770.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30771.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30773.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30775.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30777.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30779.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30780.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30785.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30786.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30788.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/30789.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/5848.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/5849.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9078.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9079.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9080.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9081.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9082.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9083.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9084.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9085.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9086.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/items/9087.png
Binary file added app/src/main/assets/items/9088.png
Binary file added app/src/main/assets/items/9089.png
Binary file added app/src/main/assets/items/9090.png
Binary file added app/src/main/assets/items/9091.png
Binary file added app/src/main/assets/items/9092.png
Binary file added app/src/main/assets/items/9093.png
Binary file added app/src/main/assets/items/9094.png
Binary file added app/src/main/assets/items/9095.png
Binary file added app/src/main/assets/items/9096.png
Binary file added app/src/main/assets/items/9097.png
Binary file added app/src/main/assets/items/9098.png
Binary file added app/src/main/assets/items/9099.png
Binary file added app/src/main/assets/items/9100.png
Binary file added app/src/main/assets/items/9101.png
Binary file added app/src/main/assets/items/9102.png
Binary file added app/src/main/assets/items/9103.png
Binary file added app/src/main/assets/items/9104.png
Binary file added app/src/main/assets/items/9105.png
Binary file added app/src/main/assets/items/9106.png
Binary file added app/src/main/assets/items/9107.png
Binary file added app/src/main/assets/items/9108.png
Binary file added app/src/main/assets/items/9109.png
Binary file added app/src/main/assets/items/9110.png
Binary file added app/src/main/assets/items/9111.png
Binary file added app/src/main/assets/items/9112.png
Binary file added app/src/main/assets/items/9113.png
Binary file added app/src/main/assets/items/9114.png
Binary file added app/src/main/assets/items/9115.png
Binary file added app/src/main/assets/items/9116.png
Binary file added app/src/main/assets/items/9117.png
Binary file added app/src/main/assets/items/9118.png
Binary file added app/src/main/assets/items/9119.png
Binary file added app/src/main/assets/items/9120.png
Binary file added app/src/main/assets/items/9121.png
Binary file added app/src/main/assets/items/9122.png
Binary file added app/src/main/assets/items/9123.png
Binary file added app/src/main/assets/items/9124.png
Binary file added app/src/main/assets/items/9125.png
Binary file added app/src/main/assets/items/9126.png
Binary file added app/src/main/assets/items/9127.png
Binary file added app/src/main/assets/items/9128.png
Binary file added app/src/main/assets/items/9129.png
Binary file added app/src/main/assets/items/9130.png
Binary file added app/src/main/assets/items/9131.png
Binary file added app/src/main/assets/items/9132.png
Binary file added app/src/main/assets/items/9133.png
Binary file added app/src/main/assets/items/9134.png
Binary file added app/src/main/assets/items/9135.png
Binary file added app/src/main/assets/items/9136.png
Binary file added app/src/main/assets/items/9137.png
Binary file added app/src/main/assets/items/9138.png
Binary file added app/src/main/assets/items/9139.png
Binary file added app/src/main/assets/items/9140.png
Binary file added app/src/main/assets/items/9141.png
Binary file added app/src/main/assets/items/9142.png
Binary file added app/src/main/assets/items/9143.png
Binary file added app/src/main/assets/items/9144.png
Binary file added app/src/main/assets/items/9145.png
Binary file added app/src/main/assets/items/9146.png
Binary file added app/src/main/assets/items/9147.png
Binary file added app/src/main/assets/items/9148.png
Binary file added app/src/main/assets/items/9149.png
Binary file added app/src/main/assets/items/9150.png
Binary file added app/src/main/assets/items/9151.png
Binary file added app/src/main/assets/items/9152.png
Binary file added app/src/main/assets/items/9153.png
Binary file added app/src/main/assets/items/9154.png
Binary file added app/src/main/assets/items/9155.png
Binary file added app/src/main/assets/items/9156.png
Binary file added app/src/main/assets/items/9157.png
Binary file added app/src/main/assets/items/9158.png
Binary file added app/src/main/assets/items/9159.png
Binary file added app/src/main/assets/items/9160.png
Binary file added app/src/main/assets/items/9161.png
Binary file added app/src/main/assets/items/9162.png
Binary file added app/src/main/assets/items/9163.png
Binary file added app/src/main/assets/items/9164.png
Binary file added app/src/main/assets/items/9165.png
Binary file added app/src/main/assets/items/9166.png
Binary file added app/src/main/assets/items/9167.png
Binary file added app/src/main/assets/items/9168.png
Binary file added app/src/main/assets/items/9169.png
Binary file added app/src/main/assets/items/9170.png
Binary file added app/src/main/assets/items/9171.png
Binary file added app/src/main/assets/items/9172.png
Binary file added app/src/main/assets/items/9173.png
Binary file added app/src/main/assets/items/9174.png
Binary file added app/src/main/assets/items/9175.png
Binary file added app/src/main/assets/items/9176.png
Binary file added app/src/main/assets/items/9177.png
Binary file added app/src/main/assets/items/9178.png
Binary file added app/src/main/assets/items/9179.png
Binary file added app/src/main/assets/items/9180.png
Binary file added app/src/main/assets/items/9181.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (C) 2014 [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tlongdev.bktf.adapter;

import android.content.Context;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.support.v7.widget.RecyclerView;

/**
* Created by skyfishjy on 10/31/14.
*/
public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {

private Context mContext;

private Cursor mCursor;

private boolean mDataValid;

private int mRowIdColumn;

private DataSetObserver mDataSetObserver;

public CursorRecyclerViewAdapter(Context context, Cursor cursor) {
mContext = context;
mCursor = cursor;
mDataValid = cursor != null;
mRowIdColumn = mDataValid ? mCursor.getColumnIndex("_id") : -1;
mDataSetObserver = new NotifyingDataSetObserver();
if (mCursor != null) {
mCursor.registerDataSetObserver(mDataSetObserver);
}
}

public Cursor getCursor() {
return mCursor;
}

@Override
public int getItemCount() {
if (mDataValid && mCursor != null) {
return mCursor.getCount();
}
return 0;
}

@Override
public long getItemId(int position) {
if (mDataValid && mCursor != null && mCursor.moveToPosition(position)) {
return mCursor.getLong(mRowIdColumn);
}
return 0;
}

@Override
public void setHasStableIds(boolean hasStableIds) {
super.setHasStableIds(true);
}

public abstract void onBindViewHolder(VH viewHolder, Cursor cursor);

@Override
public void onBindViewHolder(VH viewHolder, int position) {
if (!mDataValid) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException("couldn't move cursor to position " + position);
}
onBindViewHolder(viewHolder, mCursor);
}

/**
* Change the underlying cursor to a new cursor. If there is an existing cursor it will be
* closed.
*/
public void changeCursor(Cursor cursor) {
Cursor old = swapCursor(cursor);
if (old != null) {
old.close();
}
}

/**
* Swap in a new Cursor, returning the old Cursor. Unlike
* {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
* closed.
*/
public Cursor swapCursor(Cursor newCursor) {
if (newCursor == mCursor) {
return null;
}
final Cursor oldCursor = mCursor;
if (oldCursor != null && mDataSetObserver != null) {
oldCursor.unregisterDataSetObserver(mDataSetObserver);
}
mCursor = newCursor;
if (mCursor != null) {
if (mDataSetObserver != null) {
mCursor.registerDataSetObserver(mDataSetObserver);
}
mRowIdColumn = newCursor.getColumnIndexOrThrow("_id");
mDataValid = true;
notifyDataSetChanged();
} else {
mRowIdColumn = -1;
mDataValid = false;
notifyDataSetChanged();
//There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
}
return oldCursor;
}

private class NotifyingDataSetObserver extends DataSetObserver {
@Override
public void onChanged() {
super.onChanged();
mDataValid = true;
notifyDataSetChanged();
}

@Override
public void onInvalidated() {
super.onInvalidated();
mDataValid = false;
notifyDataSetChanged();
//There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
}
}
}
137 changes: 59 additions & 78 deletions app/src/main/java/com/tlongdev/bktf/adapter/RecentsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
/**
* Adapter for the recycler view in the recents fragment.
*/
public class RecentsAdapter extends RecyclerView.Adapter<RecentsAdapter.ViewHolder> {
public class RecentsAdapter extends CursorRecyclerViewAdapter<RecentsAdapter.ViewHolder> {

@Inject Context mContext;

private Cursor mDataSet;
private OnMoreListener mListener;

public RecentsAdapter(BptfApplication application) {
super(application, null);
application.getAdapterComponent().inject(this);
}

Expand All @@ -62,93 +62,74 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@SuppressWarnings("WrongConstant")
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
if (mDataSet != null && mDataSet.moveToPosition(position)) {

Price price = new Price();
price.setValue(mDataSet.getDouble(mDataSet.getColumnIndex(PriceEntry.COLUMN_PRICE)));
price.setHighValue(mDataSet.getDouble(mDataSet.getColumnIndex(PriceEntry.COLUMN_PRICE_HIGH)));
price.setDifference(mDataSet.getDouble(mDataSet.getColumnIndex(PriceEntry.COLUMN_DIFFERENCE)));
price.setCurrency(mDataSet.getString(mDataSet.getColumnIndex(PriceEntry.COLUMN_CURRENCY)));
price.setRawValue(mDataSet.getDouble(mDataSet.getColumnIndex("raw_price")));

//Get all the data from the cursor
final Item item = new Item();
item.setDefindex(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_DEFINDEX)));
item.setName(mDataSet.getString(mDataSet.getColumnIndex(ItemSchemaEntry.COLUMN_ITEM_NAME)));
item.setQuality(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_ITEM_QUALITY)));
item.setTradable(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_ITEM_TRADABLE)) == 1);
item.setCraftable(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_ITEM_CRAFTABLE)) == 1);
item.setAustralium(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_AUSTRALIUM)) == 1);
item.setPriceIndex(mDataSet.getInt(mDataSet.getColumnIndex(PriceEntry.COLUMN_PRICE_INDEX)));
item.setPrice(price);

holder.more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
mListener.onMoreClicked(v, item);
}
public void onBindViewHolder(ViewHolder holder, Cursor cursor) {
Price price = new Price();
price.setValue(cursor.getDouble(cursor.getColumnIndex(PriceEntry.COLUMN_PRICE)));
price.setHighValue(cursor.getDouble(cursor.getColumnIndex(PriceEntry.COLUMN_PRICE_HIGH)));
price.setDifference(cursor.getDouble(cursor.getColumnIndex(PriceEntry.COLUMN_DIFFERENCE)));
price.setCurrency(cursor.getString(cursor.getColumnIndex(PriceEntry.COLUMN_CURRENCY)));
price.setRawValue(cursor.getDouble(cursor.getColumnIndex("raw_price")));

//Get all the data from the cursor
final Item item = new Item();
item.setDefindex(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_DEFINDEX)));
item.setName(cursor.getString(cursor.getColumnIndex(ItemSchemaEntry.COLUMN_ITEM_NAME)));
item.setQuality(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_ITEM_QUALITY)));
item.setTradable(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_ITEM_TRADABLE)) == 1);
item.setCraftable(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_ITEM_CRAFTABLE)) == 1);
item.setAustralium(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_AUSTRALIUM)) == 1);
item.setPriceIndex(cursor.getInt(cursor.getColumnIndex(PriceEntry.COLUMN_PRICE_INDEX)));
item.setPrice(price);

holder.more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
mListener.onMoreClicked(v, item);
}
});
}
});

holder.name.setText(item.getFormattedName(mContext, false));
holder.name.setText(item.getFormattedName(mContext, false));

//Set the change indicator of the item
holder.difference.setTextColor(item.getPrice().getDifferenceColor());
holder.difference.setText(item.getPrice().getFormattedDifference(mContext));
//Set the change indicator of the item
holder.difference.setTextColor(item.getPrice().getDifferenceColor());
holder.difference.setText(item.getPrice().getFormattedDifference(mContext));

holder.icon.setImageDrawable(null);
holder.background.setBackgroundColor(item.getColor(mContext, true));
holder.icon.setImageDrawable(null);
holder.background.setBackgroundColor(item.getColor(mContext, true));

if (!item.isTradable()) {
holder.quality.setVisibility(View.VISIBLE);
if (!item.isCraftable()) {
holder.quality.setImageResource(R.drawable.uncraft_untrad);
} else {
holder.quality.setImageResource(R.drawable.untrad);
}
} else if (!item.isCraftable()) {
holder.quality.setVisibility(View.VISIBLE);
holder.quality.setImageResource(R.drawable.uncraft);
if (!item.isTradable()) {
holder.quality.setVisibility(View.VISIBLE);
if (!item.isCraftable()) {
holder.quality.setImageResource(R.drawable.uncraft_untrad);
} else {
holder.quality.setVisibility(View.GONE);
holder.quality.setImageResource(R.drawable.untrad);
}
} else if (!item.isCraftable()) {
holder.quality.setVisibility(View.VISIBLE);
holder.quality.setImageResource(R.drawable.uncraft);
} else {
holder.quality.setVisibility(View.GONE);
}

//Set the item icon
Glide.with(mContext).load(item.getIconUrl()).into(holder.icon);
//Set the item icon
Glide.with(mContext).load(item.getIconUrl()).into(holder.icon);

if (item.getPriceIndex() != 0 && item.canHaveEffects()) {
Glide.with(mContext).load(item.getEffectUrl()).into(holder.effect);
} else {
Glide.clear(holder.effect);
holder.effect.setImageDrawable(null);
}

try {
//Properly format the price
holder.price.setText(item.getPrice().getFormattedPrice(mContext));
} catch (Throwable t) {
Crashlytics.logException(t);
t.printStackTrace();
}
if (item.getPriceIndex() != 0 && item.canHaveEffects()) {
Glide.with(mContext).load(item.getEffectUrl()).into(holder.effect);
} else {
Glide.clear(holder.effect);
holder.effect.setImageDrawable(null);
}
}

@Override
public int getItemCount() {
return mDataSet == null ? 0 : mDataSet.getCount();
}

/**
* Replaces the cursor of the adapter
*
* @param data the cursor that will replace the current one
*/
public void swapCursor(Cursor data) {
if (mDataSet != null) mDataSet.close();
mDataSet = data;
notifyDataSetChanged();
try {
//Properly format the price
holder.price.setText(item.getPrice().getFormattedPrice(mContext));
} catch (Throwable t) {
Crashlytics.logException(t);
t.printStackTrace();
}
}

public void setListener(OnMoreListener listener) {
Expand Down
Loading

0 comments on commit 5be431b

Please sign in to comment.