Code cleaning / sorting

This commit is contained in:
Tanguy Herbron 2018-08-19 02:46:53 +02:00
parent 43171cd428
commit 40210fdbf0
12 changed files with 81 additions and 61 deletions

View File

@ -69,7 +69,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
view = inflater.inflate(R.layout.fragment_watchlist_homeactivity, container, false); view = inflater.inflate(R.layout.homeactivity_fragment_watchlist, container, false);
refreshLayout = view.findViewById(R.id.swiperefreshwatchlist); refreshLayout = view.findViewById(R.id.swiperefreshwatchlist);
dragLinearLayout = view.findViewById(R.id.linearLayoutWatchlist); dragLinearLayout = view.findViewById(R.id.linearLayoutWatchlist);

View File

@ -139,7 +139,7 @@ public class BuyFragment extends CustomRecordFragment {
context = getActivity().getApplicationContext(); context = getActivity().getApplicationContext();
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK); sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy", Locale.UK);
preferenceManager = new PreferencesManager(getContext()); preferenceManager = new PreferencesManager(getContext());
@ -243,6 +243,7 @@ public class BuyFragment extends CustomRecordFragment {
, note , note
, fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom() , fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom()
, feeCurrency , feeCurrency
, ""
, fragmentExchange.getName() , fragmentExchange.getName()
, "b" , "b"
, feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f"); , feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f");
@ -261,8 +262,9 @@ public class BuyFragment extends CustomRecordFragment {
, note , note
, fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom() , fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom()
, feeCurrency , feeCurrency
, ""
, fragmentExchange.getName() , fragmentExchange.getName()
, "b" ,"b"
, feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f"); , feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f");
} }
@ -378,13 +380,9 @@ public class BuyFragment extends CustomRecordFragment {
private double getFees(String feeCurrency, double amount, double purchasedPrice) private double getFees(String feeCurrency, double amount, double purchasedPrice)
{ {
double fees; double fees = 0;
if(fees_editText.getText().toString().equals("")) if(!fees_editText.getText().toString().equals(""))
{
fees = 0;
}
else
{ {
fees = Double.parseDouble(fees_editText.getText().toString()); fees = Double.parseDouble(fees_editText.getText().toString());
@ -534,11 +532,6 @@ public class BuyFragment extends CustomRecordFragment {
} }
}); });
if(preferenceManager == null)
{
preferenceManager = new PreferencesManager(getSecureContext());
}
if(calendar == null) if(calendar == null)
{ {
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();

View File

@ -139,7 +139,7 @@ public class SellFragment extends CustomRecordFragment {
context = getActivity().getApplicationContext(); context = getActivity().getApplicationContext();
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK); sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy", Locale.UK);
preferenceManager = new PreferencesManager(getContext()); preferenceManager = new PreferencesManager(getContext());
@ -215,6 +215,7 @@ public class SellFragment extends CustomRecordFragment {
, note , note
, fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom() , fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom()
, feeCurrency , feeCurrency
, ""
, fragmentExchange.getName() , fragmentExchange.getName()
, "s" , "s"
, feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f"); , feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f");
@ -233,8 +234,9 @@ public class SellFragment extends CustomRecordFragment {
, note , note
, fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom() , fragmentPair.getFrom().equals(fragmentCurrency.getSymbol()) ? fragmentPair.getTo() : fragmentPair.getFrom()
, feeCurrency , feeCurrency
, ""
, fragmentExchange.getName() , fragmentExchange.getName()
, "s" ,"s"
, feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f"); , feesCurrencySpinner.getSelectedItemPosition() % 2 == 0 ? "p" : "f");
} }
@ -350,13 +352,9 @@ public class SellFragment extends CustomRecordFragment {
private double getFees(String feeCurrency, double amount, double purchasedPrice) private double getFees(String feeCurrency, double amount, double purchasedPrice)
{ {
double fees; double fees = 0;
if(fees_editText.getText().toString().equals("")) if(!fees_editText.getText().toString().equals(""))
{
fees = 0;
}
else
{ {
fees = Double.parseDouble(fees_editText.getText().toString()); fees = Double.parseDouble(fees_editText.getText().toString());

View File

@ -79,7 +79,7 @@ public class BalanceManager implements BinanceUpdateNotifierInterface, HitBTCUpd
balanceCounter = 0; balanceCounter = 0;
manualBalances = databaseManager.getAllCurrenciesFromManualCurrency(); manualBalances = databaseManager.getAllCurrenciesFromTransactions();
if(binanceManagers.size() > 0) if(binanceManagers.size() > 0)
{ {

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/separationColor"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7,10l5,5 5,-5z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/separationColor"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7,14l5,-5 5,5z"/>
</vector>

View File

@ -1,46 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"> <item android:state_enabled="true">
<layer-list> <layer-list>
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/hardWhite"/> <solid android:color="@color/transparent"/>
<corners android:radius="2dp"/>
<corners <stroke
android:topLeftRadius="5dp" android:color="@color/separationColor"
android:topRightRadius="5dp"/> android:width="1dp"/>
<padding
android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp"/>
</shape> </shape>
</item> </item>
<item <item
android:gravity="center_vertical|right" android:gravity="center_vertical|right"
android:drawable="@drawable/ic_arrow_drop_down_white_24dp"/> android:drawable="@drawable/ic_arrow_drop_down_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> </layer-list>
</item> </item>
</selector> </selector>

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

@ -55,7 +55,7 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="@drawable/spinner_background" android:background="@drawable/spinner_background_header"
android:gravity="center" android:gravity="center"
android:textSize="18sp" /> android:textSize="18sp" />

View File

@ -58,7 +58,7 @@
android:id="@+id/coin_autoCompleteTextView" android:id="@+id/coin_autoCompleteTextView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/spinner_background" android:background="@drawable/spinner_background_header"
android:textSize="18sp" android:textSize="18sp"
android:hint="@string/select_coin" android:hint="@string/select_coin"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
@ -87,7 +87,7 @@
android:layout_weight="1.7" android:layout_weight="1.7"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:layout_height="@dimen/spinner_toolbar_height" android:layout_height="@dimen/spinner_toolbar_height"
android:background="@drawable/spinner_background" android:background="@drawable/spinner_background_header"
android:hint="@string/select_exchange" android:hint="@string/select_exchange"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
android:gravity="center" android:gravity="center"
@ -98,7 +98,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/spinner_toolbar_height" android:layout_height="@dimen/spinner_toolbar_height"
android:layout_weight="1.2" android:layout_weight="1.2"
android:background="@drawable/spinner_background" android:background="@drawable/spinner_background_header"
android:hint="@string/select_pair" android:hint="@string/select_pair"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
android:gravity="center" android:gravity="center"