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
This commit is contained in:
Tanguy Herbron 2018-08-21 02:00:09 +02:00
parent ac7fb545ec
commit 518df666f4
11 changed files with 334 additions and 261 deletions

View File

@ -161,6 +161,8 @@ public class TransactionsFragment extends Fragment {
} }
}); });
if(getActivity() != null)
{
TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getActivity(), transactions); TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getActivity(), transactions);
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@ -172,6 +174,7 @@ public class TransactionsFragment extends Fragment {
}); });
} }
} }
}
/*public class TransactionUpdater extends AsyncTask<Void, Integer, Void> /*public class TransactionUpdater extends AsyncTask<Void, Integer, Void>
{ {

View File

@ -9,6 +9,7 @@ import android.support.v4.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.graphics.Palette; import android.support.v7.graphics.Palette;
import android.text.SpannableString; import android.text.SpannableString;
@ -54,6 +55,7 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
private PreferencesManager preferencesManager; private PreferencesManager preferencesManager;
private CoinmarketCapAPIManager coinmarketCapAPIManager; private CoinmarketCapAPIManager coinmarketCapAPIManager;
private SwipeRefreshLayout refreshLayout; private SwipeRefreshLayout refreshLayout;
private NestedScrollView nestedScrollView;
private long lastTimestamp; private long lastTimestamp;
private String defaultCurrency; private String defaultCurrency;
private CryptocompareApiManager cryptocompareApiManager; private CryptocompareApiManager cryptocompareApiManager;
@ -89,6 +91,8 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
defaultCurrency = preferencesManager.getDefaultCurrency(); defaultCurrency = preferencesManager.getDefaultCurrency();
lastTimestamp = 0; lastTimestamp = 0;
nestedScrollView = view.findViewById(R.id.nestedMarketCap);
setupRefreshLayout(); setupRefreshLayout();
setupDrawerButton(); setupDrawerButton();
@ -304,12 +308,12 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
switch (motionEvent.getAction()) switch (motionEvent.getAction())
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
refreshLayout.setEnabled(false); nestedScrollView.setEnabled(false);
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
break; break;
default: default:
refreshLayout.setEnabled(true); nestedScrollView.setEnabled(true);
break; break;
} }

View File

@ -296,8 +296,8 @@ public class BuyFragment extends CustomRecordFragment {
}); });
feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_buy); feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_buy);
currencyFeeAdapter = new ArrayAdapter<String>(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); currencyFeeAdapter = new ArrayAdapter<String>(getActivity(), 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); feesCurrencySpinner.setAdapter(currencyFeeAdapter);
deductHoldingsSwitch = view.findViewById(R.id.deductHoldingsBuy); deductHoldingsSwitch = view.findViewById(R.id.deductHoldingsBuy);

View File

@ -268,7 +268,7 @@ public class SellFragment extends CustomRecordFragment {
feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_sell); feesCurrencySpinner = view.findViewById(R.id.feesCurrency_editText_sell);
currencyFeeAdapter = new ArrayAdapter<String>(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); currencyFeeAdapter = new ArrayAdapter<String>(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); feesCurrencySpinner.setAdapter(currencyFeeAdapter);
if(fragmentPair != null) if(fragmentPair != null)
@ -522,6 +522,8 @@ public class SellFragment extends CustomRecordFragment {
public void updatePair(Pair pair) public void updatePair(Pair pair)
{ {
fragmentPair = pair;
currencyFeeAdapter = new ArrayAdapter<String>(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); currencyFeeAdapter = new ArrayAdapter<String>(getSecureContext(), android.R.layout.simple_spinner_item, new ArrayList<>());
currencyFeeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); currencyFeeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
feesCurrencySpinner.setAdapter(currencyFeeAdapter); feesCurrencySpinner.setAdapter(currencyFeeAdapter);

View File

@ -262,15 +262,15 @@ public class TransferFragment extends CustomRecordFragment {
private void setupSpinnesr() private void setupSpinnesr()
{ {
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.from_transfer_options_string_array)); ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(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); fromSpinner.setAdapter(fromAdapter);
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.to_transfer_options_string_array)); ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(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); toSpinner.setAdapter(toAdapter);
ArrayAdapter<String> feeAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.fees_options)); ArrayAdapter<String> feeAdapter = new ArrayAdapter<String>(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); feeSpinner.setAdapter(feeAdapter);
fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<layer-list>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/hardWhite"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<padding
android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp"/>
</shape>
</item>
<item
android:gravity="center_vertical|right"
android:drawable="@drawable/ic_arrow_drop_down_white_24dp"/>
</layer-list>
</item>
<item android:state_enabled="false">
<layer-list>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/softWhite"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<padding
android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp"/>
</shape>
</item>
<item
android:gravity="center_vertical|right"
android:drawable="@drawable/ic_arrow_drop_down_white_24dp"/>
</layer-list>
</item>
</selector>

View File

@ -16,9 +16,6 @@
android:bottom="3dp"/> android:bottom="3dp"/>
</shape> </shape>
</item> </item>
<item
android:gravity="center_vertical|right"
android:drawable="@drawable/ic_arrow_drop_down_white_24dp"/>
</layer-list> </layer-list>
</item> </item>
@ -38,9 +35,6 @@
android:bottom="3dp"/> android:bottom="3dp"/>
</shape> </shape>
</item> </item>
<item
android:gravity="center_vertical|right"
android:drawable="@drawable/ic_arrow_drop_down_white_24dp"/>
</layer-list> </layer-list>
</item> </item>
</selector> </selector>

View File

@ -50,6 +50,12 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@drawable/gradient_background"> android:background="@drawable/gradient_background">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedMarketCap"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/list_background">
<LinearLayout android:id="@+id/layoutMarketCap" <LinearLayout android:id="@+id/layoutMarketCap"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -229,5 +235,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -51,12 +51,17 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@drawable/gradient_background"> android:background="@drawable/gradient_background">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedMarketCap"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/list_background">
<LinearLayout android:id="@+id/layoutMarketCap" <LinearLayout android:id="@+id/layoutMarketCap"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="20dp" android:paddingTop="20dp">
android:background="@drawable/list_background">
<ProgressBar <ProgressBar
android:id="@+id/progressBarMarketCap" android:id="@+id/progressBarMarketCap"
@ -230,5 +235,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?attr/dropdownListPreferredItemHeight"
android:ellipsize="marquee"
android:textColor="#000000"/>