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

View File

@ -445,7 +445,12 @@ public class Summary extends Fragment {
}
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++;
if(counter == 3)

View File

@ -664,7 +664,12 @@ public class Watchlist extends Fragment {
}
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++;
if(counter == 3)

View File

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

View File

@ -234,8 +234,18 @@ public class CurrencyDataRetriever {
currency.setProofType(jsonObject.getString("ProofType"));
currency.setAlgorithm(jsonObject.getString("Algorithm"));
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) {
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.exception.BinanceApiException;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.R;
import java.util.ArrayList;
import java.util.HashMap;

View File

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