Switching summary card generation to xml inflater
This commit is contained in:
parent
b41ce1d9c4
commit
88d426b0b8
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -24,7 +24,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -247,17 +247,20 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
|
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
|
||||||
{
|
{
|
||||||
currencyLayout.addView(layoutGenerator.getInfoLayout(currency));
|
//currencyLayout.addView(layoutGenerator.getInfoLayout(currency));
|
||||||
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//currencyLayout.addView(layoutGenerator.getInfoLayout(balanceManager.getTotalBalance().get(0), true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int i = 0; i < currencyLayout.getChildCount(); i++)
|
/*for(int i = 0; i < currencyLayout.getChildCount(); i++)
|
||||||
{
|
{
|
||||||
currencyLayout.getChildAt(i).findViewWithTag("chart_layout").setVisibility(View.GONE);
|
currencyLayout.getChildAt(i).findViewWithTag("chart_layout").setVisibility(View.GONE);
|
||||||
currencyLayout.getChildAt(i).findViewWithTag("separator_layout").setVisibility(View.GONE);
|
currencyLayout.getChildAt(i).findViewWithTag("separator_layout").setVisibility(View.GONE);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
updateViewButtonIcon();
|
updateViewButtonIcon();
|
||||||
@ -494,7 +497,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params)
|
protected Void doInBackground(Void... params)
|
||||||
{
|
{
|
||||||
final List<CardView> cardList = new ArrayList<>();
|
final List<View> cardList = new ArrayList<>();
|
||||||
|
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
|
|
||||||
@ -522,12 +525,12 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
totalValue += localCurrency.getValue() * localCurrency.getBalance();
|
totalValue += localCurrency.getValue() * localCurrency.getBalance();
|
||||||
totalFluctuation += (localCurrency.getValue() * localCurrency.getBalance()) * (localCurrency.getDayFluctuationPercentage() / 100);
|
totalFluctuation += (localCurrency.getValue() * localCurrency.getBalance()) * (localCurrency.getDayFluctuationPercentage() / 100);
|
||||||
|
|
||||||
cardList.add(layoutGenerator.getInfoLayout(localCurrency));
|
cardList.add(layoutGenerator.getInfoLayout(localCurrency, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!localCurrency.getSymbol().equals("USD") && localCurrency.getHistoryMinutes() == null)
|
if(!localCurrency.getSymbol().equals("USD") && localCurrency.getHistoryMinutes() == null)
|
||||||
{
|
{
|
||||||
cardList.add(layoutGenerator.getInfoLayout(localCurrency));
|
cardList.add(layoutGenerator.getInfoLayout(localCurrency, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceManager.getTotalBalance().set(i, localCurrency);
|
balanceManager.getTotalBalance().set(i, localCurrency);
|
||||||
|
@ -8,6 +8,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -43,7 +44,65 @@ public class HomeLayoutGenerator {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardView getInfoLayout(final Currency currency, boolean isExtended)
|
public View getInfoLayout(final Currency currency, boolean isExtended)
|
||||||
|
{
|
||||||
|
|
||||||
|
View view = LayoutInflater.from(context).inflate(R.layout.cardview_currency, null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
view.animate();
|
||||||
|
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
||||||
|
intent.putExtra("currency", currency);
|
||||||
|
context.getApplicationContext().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
((ImageView) view.findViewById(R.id.currencyIcon))
|
||||||
|
.setImageBitmap(currency.getIcon());
|
||||||
|
((TextView) view.findViewById(R.id.currencyNameTextView))
|
||||||
|
.setText(currency.getName());
|
||||||
|
((TextView) view.findViewById(R.id.currencySymbolTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencySymbolPlaceholder, currency.getSymbol()));
|
||||||
|
((TextView) view.findViewById(R.id.currencyOwnedTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyBalancePlaceholder, numberConformer(currency.getBalance()), currency.getSymbol()));
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueOwnedTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getValue() * currency.getBalance())));
|
||||||
|
|
||||||
|
((TextView) view.findViewById(R.id.currencyValueTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyPercentagePlaceholder, numberConformer(currency.getDayFluctuationPercentage())));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setText(context.getResources().getString(R.string.currencyDollarParenthesisPlaceholder, numberConformer(currency.getDayFluctuation())));
|
||||||
|
|
||||||
|
updateColor(view, currency);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateColor(View view, Currency currency)
|
||||||
|
{
|
||||||
|
if(currency.getDayFluctuationPercentage() > 0)
|
||||||
|
{
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
|
.setTextColor(context.getResources().getColor(R.color.increase));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setTextColor(context.getResources().getColor(R.color.increase));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
|
.setTextColor(context.getResources().getColor(R.color.decrease));
|
||||||
|
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||||
|
.setTextColor(context.getResources().getColor(R.color.decrease));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardView getInfoLayout(final Currency currency)
|
||||||
//public CardView getInfoLayout(int index)
|
//public CardView getInfoLayout(int index)
|
||||||
{
|
{
|
||||||
CardView mainCard = new CardView(context);
|
CardView mainCard = new CardView(context);
|
||||||
|
@ -56,7 +56,8 @@
|
|||||||
android:id="@+id/switch_button"
|
android:id="@+id/switch_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/quick_button"/>
|
android:text="@string/quick_button"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,24 +1,30 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clickable="true"
|
android:layout_margin="10dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:padding="10dp"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="8dp"
|
||||||
android:layout_margin="10dp">
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/mainLinear"
|
android:id="@+id/mainLinear"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:clickable="false"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:tag="mainLinear"
|
android:tag="mainLinear">
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:clickable="false">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/currencyInfoLayout"
|
android:id="@+id/currencyInfoLayout"
|
||||||
@ -36,31 +42,33 @@
|
|||||||
android:id="@+id/currencyIcon"
|
android:id="@+id/currencyIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"/>
|
android:layout_margin="1dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencyNameTextView"
|
android:id="@+id/currencyNameTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/mainText"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="start"
|
||||||
android:textColor="@color/mainTextViewColor"
|
android:textColor="@color/mainTextViewColor"
|
||||||
android:gravity="left"/>
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencySymbolTextView"
|
android:id="@+id/currencySymbolTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/secondaryText"
|
android:layout_marginStart="2dp"
|
||||||
|
android:gravity="left"
|
||||||
android:textColor="@color/secondaryTextViewColor"
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
android:gravity="left"/>
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencyValueTextView"
|
android:id="@+id/currencyValueTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/mainText"
|
android:gravity="right"
|
||||||
android:textColor="@color/secondaryTextViewColor"
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
android:gravity="right"/>
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -74,34 +82,37 @@
|
|||||||
android:id="@+id/currencyOwnedTextView"
|
android:id="@+id/currencyOwnedTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/mainText"
|
android:gravity="left"
|
||||||
android:textColor="@color/mainTextViewColor"
|
android:textColor="@color/mainTextViewColor"
|
||||||
android:gravity="left" />
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencyValueOwnedTextView"
|
android:id="@+id/currencyValueOwnedTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/secondaryText"
|
android:layout_marginStart="2dp"
|
||||||
|
android:gravity="left"
|
||||||
android:textColor="@color/secondaryTextViewColor"
|
android:textColor="@color/secondaryTextViewColor"
|
||||||
android:gravity="left"/>
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/secondaryLayout"
|
android:id="@+id/secondaryLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:gravity="right"
|
||||||
android:gravity="right">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/currencyFluctuationPercentageTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/mainText"/>
|
android:textSize="@dimen/cardViewMainText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/currencyFluctuationTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/secondaryText"/>
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -114,35 +125,36 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp">
|
android:layout_marginRight="10dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Day history"
|
android:text="Day history"
|
||||||
android:textSize="@dimen/secondaryText"/>
|
android:textSize="@dimen/cardViewSecondaryText" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="3dp"
|
android:layout_height="1dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@color/separationLine"/>
|
android:background="@color/separationLine" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.db.chart.view.LineChartView
|
<com.db.chart.view.LineChartView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="500dp"
|
android:layout_height="500dp"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="500dp"
|
android:layout_height="500dp"
|
||||||
android:text="Error"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:visibility="gone"/>
|
android:text="Error"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<dimen name="cardViewMainText">15sp</dimen>
|
||||||
|
<dimen name="cardViewSecondaryText">12sp</dimen>
|
||||||
|
|
||||||
<dimen name="app_bar_height">180dp</dimen>
|
<dimen name="app_bar_height">180dp</dimen>
|
||||||
<dimen name="fab_margin">16dp</dimen>
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
<dimen name="text_margin">16dp</dimen>
|
<dimen name="text_margin">16dp</dimen>
|
||||||
|
@ -131,4 +131,12 @@
|
|||||||
<string name="button3m">3M</string>
|
<string name="button3m">3M</string>
|
||||||
<string name="button6m">6M</string>
|
<string name="button6m">6M</string>
|
||||||
<string name="button1y">1y</string>
|
<string name="button1y">1y</string>
|
||||||
|
|
||||||
|
<!--Cardview placeholders-->
|
||||||
|
<string name="currencySymbolPlaceholder">(%1$s)</string>
|
||||||
|
<string name="currencyBalancePlaceholder">%1$s%2$s</string>
|
||||||
|
<string name="currencyDollarParenthesisPlaceholder">(US$%1$s)</string>
|
||||||
|
<string name="currencyDollarPlaceholder">US$%1$s</string>
|
||||||
|
<string name="currencyPercentagePlaceholder">%1$s%%</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user