From 518df666f400d77afb7b46588566f56ab46c639d Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 21 Aug 2018 02:00:09 +0200 Subject: [PATCH] Multiple fixs [DetailsActivity] - Fix crash when finishing the activity before all transactions and trades are updated [MarketCapitalizationActivity] - Fix some views not visible for little screens [RecordTransactionActivity] - Fix crash when editing a sell transaction --- .../TransactionsFragment.java | 19 +- .../MarketCapitalization.java | 8 +- .../BuyFragment.java | 4 +- .../SellFragment.java | 4 +- .../TransferFragment.java | 6 +- .../spinner_background_header.xml | 46 ++++ .../drawable/spinner_background_header.xml | 6 - .../homeactivity_fragment_marketcap.xml | 246 +++++++++--------- .../homeactivity_fragment_marketcap.xml | 245 ++++++++--------- .../record_transaction_fragment_buy.xml | 2 +- .../res/layout/spinner_dropdown_black.xml | 9 + 11 files changed, 334 insertions(+), 261 deletions(-) create mode 100644 app/src/main/res/drawable-v21/spinner_background_header.xml create mode 100644 app/src/main/res/layout/spinner_dropdown_black.xml diff --git a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/TransactionsFragment.java b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/TransactionsFragment.java index 2641b70..61fba84 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/TransactionsFragment.java +++ b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/TransactionsFragment.java @@ -161,15 +161,18 @@ public class TransactionsFragment extends Fragment { } }); - TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getActivity(), transactions); + if(getActivity() != null) + { + TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getActivity(), transactions); - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - transactionLayout.setAdapter(transactionListAdapter); - transactionLayout.setTextFilterEnabled(false); - } - }); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + transactionLayout.setAdapter(transactionListAdapter); + transactionLayout.setTextFilterEnabled(false); + } + }); + } } } diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/MarketCapitalization.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/MarketCapitalization.java index 4305c16..5cd2023 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/MarketCapitalization.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/MarketCapitalization.java @@ -9,6 +9,7 @@ import android.support.v4.app.Fragment; import android.os.Bundle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; +import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.graphics.Palette; import android.text.SpannableString; @@ -54,6 +55,7 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif private PreferencesManager preferencesManager; private CoinmarketCapAPIManager coinmarketCapAPIManager; private SwipeRefreshLayout refreshLayout; + private NestedScrollView nestedScrollView; private long lastTimestamp; private String defaultCurrency; private CryptocompareApiManager cryptocompareApiManager; @@ -89,6 +91,8 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif defaultCurrency = preferencesManager.getDefaultCurrency(); lastTimestamp = 0; + nestedScrollView = view.findViewById(R.id.nestedMarketCap); + setupRefreshLayout(); setupDrawerButton(); @@ -304,12 +308,12 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: - refreshLayout.setEnabled(false); + nestedScrollView.setEnabled(false); break; case MotionEvent.ACTION_MOVE: break; default: - refreshLayout.setEnabled(true); + nestedScrollView.setEnabled(true); break; } diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java index 767d472..6d7a1c2 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java @@ -296,8 +296,8 @@ public class BuyFragment extends CustomRecordFragment { }); feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_buy); - currencyFeeAdapter = new ArrayAdapter(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); - currencyFeeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + currencyFeeAdapter = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_item, new ArrayList<>()); + currencyFeeAdapter.setDropDownViewResource(R.layout.spinner_dropdown_black); feesCurrencySpinner.setAdapter(currencyFeeAdapter); deductHoldingsSwitch = view.findViewById(R.id.deductHoldingsBuy); diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java index 4976a63..f91ce8b 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/SellFragment.java @@ -268,7 +268,7 @@ public class SellFragment extends CustomRecordFragment { feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_sell); currencyFeeAdapter = new ArrayAdapter(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); - currencyFeeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + currencyFeeAdapter.setDropDownViewResource(R.layout.spinner_dropdown_black); feesCurrencySpinner.setAdapter(currencyFeeAdapter); if(fragmentPair != null) @@ -522,6 +522,8 @@ public class SellFragment extends CustomRecordFragment { public void updatePair(Pair pair) { + fragmentPair = pair; + currencyFeeAdapter = new ArrayAdapter(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); currencyFeeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); feesCurrencySpinner.setAdapter(currencyFeeAdapter); diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java index d057a5b..b36deb2 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/TransferFragment.java @@ -262,15 +262,15 @@ public class TransferFragment extends CustomRecordFragment { private void setupSpinnesr() { ArrayAdapter fromAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.from_transfer_options_string_array)); - fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + fromAdapter.setDropDownViewResource(R.layout.spinner_dropdown_black); fromSpinner.setAdapter(fromAdapter); ArrayAdapter toAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.to_transfer_options_string_array)); - toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + toAdapter.setDropDownViewResource(R.layout.spinner_dropdown_black); toSpinner.setAdapter(toAdapter); ArrayAdapter feeAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.fees_options)); - feeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + feeAdapter.setDropDownViewResource(R.layout.spinner_dropdown_black); feeSpinner.setAdapter(feeAdapter); fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/app/src/main/res/drawable-v21/spinner_background_header.xml b/app/src/main/res/drawable-v21/spinner_background_header.xml new file mode 100644 index 0000000..7246389 --- /dev/null +++ b/app/src/main/res/drawable-v21/spinner_background_header.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/spinner_background_header.xml b/app/src/main/res/drawable/spinner_background_header.xml index 7246389..b6e1358 100644 --- a/app/src/main/res/drawable/spinner_background_header.xml +++ b/app/src/main/res/drawable/spinner_background_header.xml @@ -16,9 +16,6 @@ android:bottom="3dp"/> - @@ -38,9 +35,6 @@ android:bottom="3dp"/> - diff --git a/app/src/main/res/layout-v21/homeactivity_fragment_marketcap.xml b/app/src/main/res/layout-v21/homeactivity_fragment_marketcap.xml index 9d3726a..31351d3 100644 --- a/app/src/main/res/layout-v21/homeactivity_fragment_marketcap.xml +++ b/app/src/main/res/layout-v21/homeactivity_fragment_marketcap.xml @@ -50,173 +50,181 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" android:background="@drawable/gradient_background"> - - - - + android:orientation="vertical" + android:paddingTop="20dp" + android:background="@drawable/list_background"> - - - - - - - - - + style="?android:attr/progressBarStyleLarge" + android:layout_gravity="center" + android:background="@drawable/circular_progress_bar" /> - + - + android:layout_height="350dp" + android:layout_marginTop="5dp"> + + + + + + + android:orientation="vertical" + android:layout_margin="10dp"> + + + + - - - - + android:orientation="horizontal" + android:baselineAligned="false"> + android:layout_weight="0.5" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + android:layout_weight="0.5" + android:orientation="vertical"> - - - - - - - - - - - - - + android:orientation="vertical" + android:layout_marginTop="5dp"> - + + + + + @@ -228,6 +236,6 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/homeactivity_fragment_marketcap.xml b/app/src/main/res/layout/homeactivity_fragment_marketcap.xml index 6fa469b..2628a9a 100644 --- a/app/src/main/res/layout/homeactivity_fragment_marketcap.xml +++ b/app/src/main/res/layout/homeactivity_fragment_marketcap.xml @@ -51,173 +51,180 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" android:background="@drawable/gradient_background"> - - - - + android:orientation="vertical" + android:paddingTop="20dp"> - - - - - - - - - + style="?android:attr/progressBarStyleLarge" + android:layout_gravity="center" + android:background="@drawable/circular_progress_bar" /> - + - + android:layout_height="350dp" + android:layout_marginTop="5dp"> + + + + + + + android:orientation="vertical" + android:layout_margin="10dp"> + + + + - - - - + android:orientation="horizontal" + android:baselineAligned="false"> + android:layout_weight="0.5" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + android:layout_weight="0.5" + android:orientation="vertical"> - - - - - - - - - - - - - + android:orientation="vertical" + android:layout_marginTop="5dp"> - + + + + + @@ -229,6 +236,6 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/record_transaction_fragment_buy.xml b/app/src/main/res/layout/record_transaction_fragment_buy.xml index d883f0b..c13495f 100644 --- a/app/src/main/res/layout/record_transaction_fragment_buy.xml +++ b/app/src/main/res/layout/record_transaction_fragment_buy.xml @@ -100,7 +100,7 @@ android:id="@+id/feesCurrency_editText_buy" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="1"/> + android:layout_weight="1" /> diff --git a/app/src/main/res/layout/spinner_dropdown_black.xml b/app/src/main/res/layout/spinner_dropdown_black.xml new file mode 100644 index 0000000..bf21419 --- /dev/null +++ b/app/src/main/res/layout/spinner_dropdown_black.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file