Preparing layout inflater instead of dynamic generation

This commit is contained in:
Tanguy Herbron 2018-02-06 17:47:12 +01:00
parent 267cdefc9b
commit b41ce1d9c4
3 changed files with 152 additions and 8 deletions

View File

@ -77,7 +77,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
@Override @Override
public void onBackPressed() public void onBackPressed()
{ {
Log.d(this.getResources().getString(R.string.debug), "Back pressed");
Intent intent = new Intent(this, HomeActivity.class); Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("update", hasBeenModified); intent.putExtra("update", hasBeenModified);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -538,7 +537,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString())); databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
Log.d(CurrencyDetailsActivity.this.getResources().getString(R.string.debug), "Id : " + view.getTag());
drawTransactionList(); drawTransactionList();
hasBeenModified = true; hasBeenModified = true;
} }

View File

@ -43,7 +43,7 @@ public class HomeLayoutGenerator {
this.context = context; this.context = context;
} }
public CardView getInfoLayout(final Currency currency) public CardView getInfoLayout(final Currency currency, boolean isExtended)
//public CardView getInfoLayout(int index) //public CardView getInfoLayout(int index)
{ {
CardView mainCard = new CardView(context); CardView mainCard = new CardView(context);
@ -69,10 +69,8 @@ public class HomeLayoutGenerator {
mainCard.setOnClickListener(new View.OnClickListener() { mainCard.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//switchingView(view);
view.animate(); view.animate();
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class); Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
//intent.putExtra("symbol", currency.getSymbol());
intent.putExtra("currency", currency); intent.putExtra("currency", currency);
context.getApplicationContext().startActivity(intent); context.getApplicationContext().startActivity(intent);
} }
@ -116,9 +114,6 @@ public class HomeLayoutGenerator {
mainCard.setLayoutParams(paramsCard); mainCard.setLayoutParams(paramsCard);
mainCard.setRadius(8); mainCard.setRadius(8);
//infoLayout.addView(topLayoutGenerator(currencyList.get(index).getName(), currencyList.get(index).getSymbol(), currencyList.get(index).getValue(), currencyList.get(index).getIcon()));
//infoLayout.addView(bottomLayoutGenerator(currencyList.get(index).getSymbol(), currencyList.get(index).getBalance(), currencyList.get(index).getValue() * currencyList.get(index).getBalance(), currencyList.get(index).getDayFluctuationPercentage(), currencyList.get(index).getDayFluctuation()));
infoLayout.addView(topLayoutGenerator(currency.getName(), currency.getSymbol(), currency.getValue(), currency.getIcon())); infoLayout.addView(topLayoutGenerator(currency.getName(), currency.getSymbol(), currency.getValue(), currency.getIcon()));
infoLayout.addView(bottomLayoutGenerator(currency.getSymbol(), currency.getBalance(), currency.getValue() * currency.getBalance(), currency.getDayFluctuationPercentage(), currency.getDayFluctuation())); infoLayout.addView(bottomLayoutGenerator(currency.getSymbol(), currency.getBalance(), currency.getValue() * currency.getBalance(), currency.getDayFluctuationPercentage(), currency.getDayFluctuation()));

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
app:cardCornerRadius="8dp"
android:layout_margin="10dp">
<LinearLayout
android:id="@+id/mainLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:tag="mainLinear"
android:layout_margin="10dp"
android:clickable="false">
<LinearLayout
android:id="@+id/currencyInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/currencyIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"/>
<TextView
android:id="@+id/currencyNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/mainText"
android:textColor="@color/mainTextViewColor"
android:gravity="left"/>
<TextView
android:id="@+id/currencySymbolTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/secondaryText"
android:textColor="@color/secondaryTextViewColor"
android:gravity="left"/>
<TextView
android:id="@+id/currencyValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/mainText"
android:textColor="@color/secondaryTextViewColor"
android:gravity="right"/>
</LinearLayout>
<LinearLayout
android:id="@+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/currencyOwnedTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/mainText"
android:textColor="@color/mainTextViewColor"
android:gravity="left" />
<TextView
android:id="@+id/currencyValueOwnedTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/secondaryText"
android:textColor="@color/secondaryTextViewColor"
android:gravity="left"/>
<LinearLayout
android:id="@+id/secondaryLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/mainText"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/secondaryText"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/separationLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Day history"
android:textSize="@dimen/secondaryText"/>
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/separationLine"/>
</LinearLayout>
<com.db.chart.view.LineChartView
android:layout_width="match_parent"
android:layout_height="500dp"
android:visibility="gone"/>
<TextView
android:layout_width="match_parent"
android:layout_height="500dp"
android:text="Error"
android:gravity="center"
android:visibility="gone"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>