From f3e24d2a342516a4a104aea254c78fec9d1b66e5 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 31 Jan 2018 00:50:12 +0100 Subject: [PATCH] Transaction deletion list --- app/build.gradle | 2 +- .../coinfolio/Activities/HomeActivity.java | 15 +++++ .../CurrencyData/CurrencyDataRetriver.java | 58 +++++++++++-------- .../LayoutManagers/HomeLayoutGenerator.java | 8 +++ .../res/layout/activity_currency_details.xml | 23 +++++--- 5 files changed, 74 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5c71d36..f4c6c4c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { - applicationId "com.nauk.coinfoliobeta" + applicationId "com.nauk.coinfolio" minSdkVersion 21 targetSdkVersion 26 versionCode 1 diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java index 8a440c3..b48c587 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java @@ -340,6 +340,21 @@ public class HomeActivity extends AppCompatActivity { { loadingDialog.dismiss(); } + + runOnUiThread(new Runnable() { + @Override + public void run() { + toolbarLayout.setTitle("US$0.00"); + + toolbarSubtitle.setText("US$0.00"); + + toolbarSubtitle.setTextColor(-1275068417); + } + }); + + //toolbarSubtitle.setText("US$0.00"); + + Log.d(this.getResources().getString(R.string.debug), "Colors : " + toolbarSubtitle.getTextColors()); } } diff --git a/app/src/main/java/com/nauk/coinfolio/DataManagers/CurrencyData/CurrencyDataRetriver.java b/app/src/main/java/com/nauk/coinfolio/DataManagers/CurrencyData/CurrencyDataRetriver.java index 421e240..0893f78 100644 --- a/app/src/main/java/com/nauk/coinfolio/DataManagers/CurrencyData/CurrencyDataRetriver.java +++ b/app/src/main/java/com/nauk/coinfolio/DataManagers/CurrencyData/CurrencyDataRetriver.java @@ -109,33 +109,45 @@ public class CurrencyDataRetriver { { List dataChart = new ArrayList<>(); - response = response.substring(response.indexOf("Data\":[{") + 7, response.lastIndexOf("}],\"TimeTo")); - String[] tab = response.split(Pattern.quote("},{")); - for(int i = 0; i < tab.length; i++) + Log.d("coinfolio", "Result : " + response); + + if(response.length() > 200) { - - if(i == 0) + response = response.substring(response.indexOf("Data\":[{") + 7, response.lastIndexOf("}],\"TimeTo")); + String[] tab = response.split(Pattern.quote("},{")); + for(int i = 0; i < tab.length; i++) { - tab[i] = tab[i] + "}"; + + if(i == 0) + { + tab[i] = tab[i] + "}"; + } + else + { + tab[i] = "{" + tab[i] + "}"; + } + + try { + JSONObject jsonObject = new JSONObject(tab[i]); + + long timestamp = Long.parseLong(jsonObject.getString("time")); + double close = Double.parseDouble(jsonObject.getString("close")); + double high = Double.parseDouble(jsonObject.getString("high")); + double low = Double.parseDouble(jsonObject.getString("low")); + double open = Double.parseDouble(jsonObject.getString("open")); + + dataChart.add(new CurrencyDataChart(timestamp, close, high, low, open)); + + } catch (JSONException e) { + Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i); + } } - else + } + else + { + for(int i = 1; i <= 1440; i++) { - tab[i] = "{" + tab[i] + "}"; - } - - try { - JSONObject jsonObject = new JSONObject(tab[i]); - - long timestamp = Long.parseLong(jsonObject.getString("time")); - double close = Double.parseDouble(jsonObject.getString("close")); - double high = Double.parseDouble(jsonObject.getString("high")); - double low = Double.parseDouble(jsonObject.getString("low")); - double open = Double.parseDouble(jsonObject.getString("open")); - - dataChart.add(new CurrencyDataChart(timestamp, close, high, low, open)); - - } catch (JSONException e) { - Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i); + dataChart.add(new CurrencyDataChart(i, 1, 1, 1, 1)); } } diff --git a/app/src/main/java/com/nauk/coinfolio/LayoutManagers/HomeLayoutGenerator.java b/app/src/main/java/com/nauk/coinfolio/LayoutManagers/HomeLayoutGenerator.java index 77bfaa2..48df12d 100644 --- a/app/src/main/java/com/nauk/coinfolio/LayoutManagers/HomeLayoutGenerator.java +++ b/app/src/main/java/com/nauk/coinfolio/LayoutManagers/HomeLayoutGenerator.java @@ -15,6 +15,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.db.chart.model.LineSet; +import com.db.chart.model.Point; import com.db.chart.renderer.AxisRenderer; import com.db.chart.view.LineChartView; import com.nauk.coinfolio.Activities.CurrencyDetailsActivity; @@ -28,6 +29,7 @@ import java.util.List; import java.util.Locale; import static java.lang.Math.abs; +import static java.lang.Math.floorDiv; /** * Created by Tiji on 05/01/2018. @@ -259,6 +261,12 @@ public class HomeLayoutGenerator { } } + if(valMax == valMin) + { + valMin = 0; + valMax *= 2; + } + chartView.setAxisBorderValues((float) valMin, (float) valMax); chartView.setYLabels(AxisRenderer.LabelPosition.NONE); chartView.setYAxis(false); diff --git a/app/src/main/res/layout/activity_currency_details.xml b/app/src/main/res/layout/activity_currency_details.xml index fc53091..06422cb 100644 --- a/app/src/main/res/layout/activity_currency_details.xml +++ b/app/src/main/res/layout/activity_currency_details.xml @@ -9,18 +9,25 @@ + android:layout_height="match_parent" + android:layout_marginBottom="56dp"> - + android:layout_height="wrap_content"> + + + + @@ -37,8 +44,8 @@ - @@ -50,7 +57,7 @@ - +