Add start date to details activity | Fix coin number related crash

This commit is contained in:
Tanguy Herbron 2018-04-23 14:41:17 +02:00
parent 9976109472
commit 9a06e9f256
7 changed files with 94 additions and 23 deletions

View File

@ -227,10 +227,24 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
((ProgressBar) findViewById(R.id.percentageCoinEmited)) ((ProgressBar) findViewById(R.id.percentageCoinEmited))
.setProgress((int) Math.round(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100)); .setProgress((int) Math.round(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100));
((TextView) findViewById(R.id.txtViewAlgorithm)) if(currency.getAlgorithm() != null && !currency.getAlgorithm().equals(""))
.setText(currency.getAlgorithm()); {
((TextView) findViewById(R.id.txtViewProofType)) ((TextView) findViewById(R.id.txtViewAlgorithm))
.setText(currency.getProofType()); .setText(currency.getAlgorithm());
}
if(currency.getProofType() != null && !currency.getProofType().equals(""))
{
((TextView) findViewById(R.id.txtViewProofType))
.setText(currency.getProofType());
}
if(currency.getStartDate() != null && !currency.getStartDate().equals(""))
{
((TextView) findViewById(R.id.txtViewStartDate))
.setText(currency.getStartDate());
}
((TextView) findViewById(R.id.txtViewDescription)) ((TextView) findViewById(R.id.txtViewDescription))
.setText(Html.fromHtml(currency.getDescription())); .setText(Html.fromHtml(currency.getDescription()));
((TextView) findViewById(R.id.txtViewDescription)) ((TextView) findViewById(R.id.txtViewDescription))
@ -303,7 +317,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
} }
else else
{ {
setTitle(" " + currency.getName() + " | " + currency.getBalance()); setTitle(" " + currency.getName() + " | " + numberConformer(currency.getBalance()));
} }
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
@ -727,12 +741,12 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
if(!str.equals("Infinity")) if(!str.equals("Infinity"))
{ {
int counter = 0; int counter = 0;
int i = str.indexOf(".") - 1; int i = str.indexOf(".");
if(i <= 0) if(i <= 0)
{ {
i = str.length() - 1; i = str.length();
} }
for(; i > 0; i--) for(i -= 1; i > 0; i--)
{ {
counter++; counter++;
if(counter == 3) if(counter == 3)

View File

@ -445,7 +445,12 @@ public class Summary extends Fragment {
} }
int counter = 0; int counter = 0;
for(int i = str.indexOf(".") - 1; i > 0; i--) int i = str.indexOf(".");
if(i <= 0)
{
i = str.length();
}
for(i -= 1; i > 0; i--)
{ {
counter++; counter++;
if(counter == 3) if(counter == 3)

View File

@ -664,7 +664,12 @@ public class Watchlist extends Fragment {
} }
int counter = 0; int counter = 0;
for(int i = str.indexOf(".") - 1; i > 0; i--) int i = str.indexOf(".");
if(i <= 0)
{
i = str.length();
}
for(i -= 1; i > 0; i--)
{ {
counter++; counter++;
if(counter == 3) if(counter == 3)

View File

@ -40,6 +40,7 @@ public class Currency implements Parcelable {
private int totalSupply; private int totalSupply;
private double marketCapitalization; private double marketCapitalization;
private int rank; private int rank;
private String startDate;
private List<String> socialMediaLinks; private List<String> socialMediaLinks;
//private String proofType //private String proofType
@ -161,6 +162,7 @@ public class Currency implements Parcelable {
Currency.this.description = currencyInfo.description; Currency.this.description = currencyInfo.description;
Currency.this.maxCoinSupply = currencyInfo.maxCoinSupply; Currency.this.maxCoinSupply = currencyInfo.maxCoinSupply;
Currency.this.minedCoinSupply = currencyInfo.minedCoinSupply; Currency.this.minedCoinSupply = currencyInfo.minedCoinSupply;
Currency.this.startDate = currencyInfo.startDate;
callBack.onSuccess(Currency.this); callBack.onSuccess(Currency.this);
} }
@ -403,6 +405,14 @@ public class Currency implements Parcelable {
this.tickerId = tickerId; this.tickerId = tickerId;
} }
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
private void updateDayFluctuation() private void updateDayFluctuation()
{ {
if(historyMinutes != null) if(historyMinutes != null)

View File

@ -234,8 +234,18 @@ public class CurrencyDataRetriever {
currency.setProofType(jsonObject.getString("ProofType")); currency.setProofType(jsonObject.getString("ProofType"));
currency.setAlgorithm(jsonObject.getString("Algorithm")); currency.setAlgorithm(jsonObject.getString("Algorithm"));
currency.setDescription(jsonObject.getString("Description")); currency.setDescription(jsonObject.getString("Description"));
currency.setMaxCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinSupply")));
currency.setMinedCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinsMined"))); if(!jsonObject.getString("TotalCoinSupply").equals(""))
{
currency.setMaxCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinSupply")));
}
if(!jsonObject.getString("TotalCoinsMined").equals(""))
{
currency.setMinedCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinsMined")));
}
currency.setStartDate(jsonObject.getString("StartDate"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -11,6 +11,7 @@ import com.binance.api.client.domain.account.Trade;
import com.binance.api.client.domain.account.request.OrderRequest; import com.binance.api.client.domain.account.request.OrderRequest;
import com.binance.api.client.exception.BinanceApiException; import com.binance.api.client.exception.BinanceApiException;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency; import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.R;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -376,7 +376,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_margin="6dp"> android:layout_margin="6dp">
@ -443,7 +443,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:orientation="horizontal"> android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -491,7 +492,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -508,7 +510,8 @@
<TextView <TextView
android:id="@+id/txtViewAlgorithm" android:id="@+id/txtViewAlgorithm"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:text="--"/>
</LinearLayout> </LinearLayout>
@ -527,7 +530,36 @@
<TextView <TextView
android:id="@+id/txtViewProofType" android:id="@+id/txtViewProofType"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:text="--"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.5">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start date"
android:textStyle="bold"/>
<TextView
android:id="@+id/txtViewStartDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="--"/>
</LinearLayout> </LinearLayout>
@ -611,12 +643,6 @@
</LinearLayout> </LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
</ViewFlipper> </ViewFlipper>
<android.support.design.widget.BottomNavigationView <android.support.design.widget.BottomNavigationView