From 0ab4cb15a1a235fe3a5853d134452973b75704d0 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Sun, 13 May 2018 17:47:08 +0200 Subject: [PATCH] Fix card generation | Preparing Details fragments Have to reinstall Windows, non usable commit as is --- .../Activities/CurrencyDetailsActivity.java | 34 +- .../DetailsActivityFragments/Home.java | 34 ++ .../Informations.java | 10 + .../Transactions.java | 10 + .../nauk/moodl/Activities/HomeActivity.java | 5 +- .../HomeActivityFragments/Summary.java | 2 + .../CurrencyData/CurrencyCardview.java | 16 +- .../moodl/DetailsActivityPagerAdapter.java | 48 +++ ...ter.java => HomeActivityPagerAdapter.java} | 13 +- .../res/layout/activity_currency_details.xml | 4 +- app/src/main/res/layout/cardview_currency.xml | 328 ++++++++-------- .../main/res/layout/cardview_watchlist.xml | 334 ++++++++-------- .../layout/fragment_home_detailsactivity.xml | 358 ++++++++++++++++++ .../fragment_watchlist_homeactivity.xml | 6 +- 14 files changed, 827 insertions(+), 375 deletions(-) create mode 100644 app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Home.java create mode 100644 app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Informations.java create mode 100644 app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Transactions.java create mode 100644 app/src/main/java/com/nauk/moodl/DetailsActivityPagerAdapter.java rename app/src/main/java/com/nauk/moodl/{PagerAdapter.java => HomeActivityPagerAdapter.java} (65%) create mode 100644 app/src/main/res/layout/fragment_home_detailsactivity.xml diff --git a/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java b/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java index a307d54..7e16ae8 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java +++ b/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java @@ -15,12 +15,12 @@ import android.os.Looper; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.CardView; import android.text.Html; import android.text.method.LinkMovementMethod; -import android.util.Log; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.MotionEvent; @@ -56,6 +56,7 @@ import com.nauk.moodl.DataManagers.CurrencyData.Transaction; import com.nauk.moodl.DataManagers.DatabaseManager; import com.nauk.moodl.DataManagers.ExchangeManager.BinanceManager; import com.nauk.moodl.DataManagers.PreferencesManager; +import com.nauk.moodl.DetailsActivityPagerAdapter; import com.nauk.moodl.LayoutManagers.TradeListAdapter; import com.nauk.moodl.LayoutManagers.TransactionListAdapter; import com.nauk.moodl.PlaceholderManager; @@ -72,7 +73,7 @@ import static java.lang.Math.abs; public class CurrencyDetailsActivity extends AppCompatActivity { - private ViewFlipper viewFlipper; + private ViewPager viewPager; private ListView transactionLayout; private ListView tradeLayout; private DatabaseManager databaseManager; @@ -113,13 +114,13 @@ public class CurrencyDetailsActivity extends AppCompatActivity { public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: - viewFlipper.setDisplayedChild(0); + viewPager.setCurrentItem(0); return true; case R.id.navigation_dashboard: - viewFlipper.setDisplayedChild(1); + viewPager.setCurrentItem(1); return true; case R.id.navigation_notifications: - viewFlipper.setDisplayedChild(2); + viewPager.setCurrentItem(2); return true; } return false; @@ -141,7 +142,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { switch (item.getItemId()) { case android.R.id.home: - if(viewFlipper.getDisplayedChild() == 0) + if(viewPager.getCurrentItem() == 0) { finishAfterTransition(); } @@ -160,10 +161,21 @@ public class CurrencyDetailsActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_currency_details); - Intent intent = getIntent(); + viewPager = findViewById(R.id.vfCurrencyDetails); + final DetailsActivityPagerAdapter adapter = new DetailsActivityPagerAdapter(getSupportFragmentManager(), 3); + + viewPager.setAdapter(adapter); + viewPager.setOffscreenPageLimit(2); + + BottomNavigationView navigation = findViewById(R.id.navigation_details); + navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + + /*Intent intent = getIntent(); currency = intent.getParcelableExtra("currency"); + + databaseManager = new DatabaseManager(this); preferencesManager = new PreferencesManager(this); @@ -173,7 +185,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { displayLineChart = true; flag_loading = false; - viewFlipper = findViewById(R.id.vfCurrencyDetails); + viewPager = findViewById(R.id.vfCurrencyDetails); transactionLayout = findViewById(R.id.listTransactions); tradeLayout = findViewById(R.id.listTrades); lineChart = findViewById(R.id.chartPriceView); @@ -227,8 +239,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { updateChartTab(DAY, 1); - BottomNavigationView navigation = findViewById(R.id.navigation_details); - navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + hasBeenModified = false; @@ -238,7 +249,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { tradeDrawable.invalidateSelf(); TradeUpdater updater = new TradeUpdater(); - updater.execute(); + updater.execute();*/ } private void refreshInfoTab() @@ -609,6 +620,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { initializeBarChart(barChart); barChart.setData(generateVolumeChartSet()); + barChart.animateY(1000); barChart.invalidate(); findViewById(R.id.chartVolumeView).setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Home.java b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Home.java new file mode 100644 index 0000000..914ece7 --- /dev/null +++ b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Home.java @@ -0,0 +1,34 @@ +package com.nauk.moodl.Activities.DetailsActivityFragments; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.nauk.moodl.DataManagers.CurrencyData.Currency; +import com.nauk.moodl.R; + +/** + * Created by Tiji on 13/05/2018. + */ + +public class Home extends Fragment { + + private View view; + private Currency currency; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) + { + view = inflater.inflate(R.layout.fragment_home_detailsactivity, container, false); + + currency = getActivity().getIntent().getParcelableExtra("currency"); + + return view; + } +} diff --git a/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Informations.java b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Informations.java new file mode 100644 index 0000000..28ed0c1 --- /dev/null +++ b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Informations.java @@ -0,0 +1,10 @@ +package com.nauk.moodl.Activities.DetailsActivityFragments; + +import android.support.v4.app.Fragment; + +/** + * Created by Tiji on 13/05/2018. + */ + +public class Informations extends Fragment { +} diff --git a/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Transactions.java b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Transactions.java new file mode 100644 index 0000000..b98b8ed --- /dev/null +++ b/app/src/main/java/com/nauk/moodl/Activities/DetailsActivityFragments/Transactions.java @@ -0,0 +1,10 @@ +package com.nauk.moodl.Activities.DetailsActivityFragments; + +import android.support.v4.app.Fragment; + +/** + * Created by Tiji on 13/05/2018. + */ + +public class Transactions extends Fragment { +} diff --git a/app/src/main/java/com/nauk/moodl/Activities/HomeActivity.java b/app/src/main/java/com/nauk/moodl/Activities/HomeActivity.java index 26fe9ff..9156442 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/HomeActivity.java +++ b/app/src/main/java/com/nauk/moodl/Activities/HomeActivity.java @@ -1,7 +1,6 @@ package com.nauk.moodl.Activities; import android.graphics.Bitmap; -import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.AppBarLayout; @@ -13,7 +12,7 @@ import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; -import com.nauk.moodl.PagerAdapter; +import com.nauk.moodl.HomeActivityPagerAdapter; import com.nauk.moodl.R; //Use WilliamChart for charts https://github.com/diogobernardino/WilliamChart @@ -64,7 +63,7 @@ public class HomeActivity extends AppCompatActivity { setContentView(R.layout.activity_currency_summary); viewPager = findViewById(R.id.viewPager); - final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), 3); + final HomeActivityPagerAdapter adapter = new HomeActivityPagerAdapter(getSupportFragmentManager(), 3); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(2); diff --git a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Summary.java b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Summary.java index d136952..365f5c8 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Summary.java +++ b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Summary.java @@ -128,6 +128,8 @@ public class Summary extends Fragment { updateRunnable = new Runnable() { @Override public void run() { + lastTimestamp = 0; + if (refreshLayout.isRefreshing()) { refreshLayout.setRefreshing(false); diff --git a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java index 37b361d..201b8dd 100644 --- a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java +++ b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java @@ -13,6 +13,7 @@ import android.support.v7.widget.CardView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -54,7 +55,9 @@ public class CurrencyCardview extends CardView { ((LineChart) findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor()); - findViewById(R.id.masterLayout).setOnClickListener(new View.OnClickListener() { + setupCardView(context); + + setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { PreferencesManager preferencesManager = new PreferencesManager(context); @@ -119,7 +122,9 @@ public class CurrencyCardview extends CardView { ((LineChart) findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor()); - findViewById(R.id.masterLayout).setOnClickListener(new View.OnClickListener() { + setupCardView(context); + + setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { PreferencesManager preferencesManager = new PreferencesManager(context); @@ -174,6 +179,13 @@ public class CurrencyCardview extends CardView { updateColor(currency); } + private void setupCardView(Context context) + { + setClickable(false); + setFocusable(false); + setBackgroundColor(context.getColor(R.color.summary_background)); + } + private void setupLineChart(View view, final Currency currency) { LineChart lineChart = findViewById(R.id.LineChartView); diff --git a/app/src/main/java/com/nauk/moodl/DetailsActivityPagerAdapter.java b/app/src/main/java/com/nauk/moodl/DetailsActivityPagerAdapter.java new file mode 100644 index 0000000..410a022 --- /dev/null +++ b/app/src/main/java/com/nauk/moodl/DetailsActivityPagerAdapter.java @@ -0,0 +1,48 @@ +package com.nauk.moodl; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; + +import com.nauk.moodl.Activities.DetailsActivityFragments.Home; +import com.nauk.moodl.Activities.DetailsActivityFragments.Informations; +import com.nauk.moodl.Activities.DetailsActivityFragments.Transactions; +import com.nauk.moodl.Activities.HomeActivityFragments.MarketCapitalization; +import com.nauk.moodl.Activities.HomeActivityFragments.Summary; +import com.nauk.moodl.Activities.HomeActivityFragments.Watchlist; +import com.nauk.moodl.DataManagers.CurrencyData.Currency; + +/** + * Created by Tiji on 13/05/2018. + */ + +public class DetailsActivityPagerAdapter extends FragmentStatePagerAdapter { + + private int numOfTabs; + + public DetailsActivityPagerAdapter(FragmentManager fm, int numOfTabs) + { + super(fm); + this.numOfTabs = numOfTabs; + } + + @Override + public Fragment getItem(int position) { + switch (position) + { + case 0: + return new Home(); + case 1: + return new Informations(); + case 2: + return new Transactions(); + default: + return null; + } + } + + @Override + public int getCount() { + return numOfTabs; + } +} diff --git a/app/src/main/java/com/nauk/moodl/PagerAdapter.java b/app/src/main/java/com/nauk/moodl/HomeActivityPagerAdapter.java similarity index 65% rename from app/src/main/java/com/nauk/moodl/PagerAdapter.java rename to app/src/main/java/com/nauk/moodl/HomeActivityPagerAdapter.java index 1e9e34e..305bc80 100644 --- a/app/src/main/java/com/nauk/moodl/PagerAdapter.java +++ b/app/src/main/java/com/nauk/moodl/HomeActivityPagerAdapter.java @@ -12,11 +12,11 @@ import com.nauk.moodl.Activities.HomeActivityFragments.Watchlist; * Created by Tiji on 13/04/2018. */ -public class PagerAdapter extends FragmentStatePagerAdapter { +public class HomeActivityPagerAdapter extends FragmentStatePagerAdapter { private int numOfTabs; - public PagerAdapter(FragmentManager fm, int numOfTabs) + public HomeActivityPagerAdapter(FragmentManager fm, int numOfTabs) { super(fm); this.numOfTabs = numOfTabs; @@ -27,14 +27,11 @@ public class PagerAdapter extends FragmentStatePagerAdapter { switch (position) { case 0: - Watchlist watchlist = new Watchlist(); - return watchlist; + return new Watchlist(); case 1: - Summary summary = new Summary(); - return summary; + return new Summary(); case 2: - MarketCapitalization marketCapitalization = new MarketCapitalization(); - return marketCapitalization; + return new MarketCapitalization(); default: return null; } diff --git a/app/src/main/res/layout/activity_currency_details.xml b/app/src/main/res/layout/activity_currency_details.xml index 3ffb3ab..d21c3ff 100644 --- a/app/src/main/res/layout/activity_currency_details.xml +++ b/app/src/main/res/layout/activity_currency_details.xml @@ -6,7 +6,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="com.nauk.moodl.Activities.CurrencyDetailsActivity"> - - + - + android:clickable="false" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="10dp" + app:cardCornerRadius="2dp" + android:orientation="vertical" + android:tag="mainLinear"> - + android:orientation="vertical"> + + - - + android:layout_margin="5dp" + android:orientation="vertical"> + android:orientation="horizontal"> + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:textSize="@dimen/cardViewMainText" /> - - - - - - - - - - - - - - - - - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cardview_watchlist.xml b/app/src/main/res/layout/cardview_watchlist.xml index 94890cb..0e875d3 100644 --- a/app/src/main/res/layout/cardview_watchlist.xml +++ b/app/src/main/res/layout/cardview_watchlist.xml @@ -1,216 +1,204 @@ - + android:clickable="false" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="10dp" + app:cardCornerRadius="2dp" + android:orientation="vertical" + android:tag="mainLinear"> - + android:orientation="vertical"> + android:orientation="horizontal" + android:baselineAligned="false"> + android:layout_margin="5dp" + android:orientation="vertical" + android:layout_weight="0.92"> + android:orientation="horizontal" + android:gravity="center"> - + android:layout_margin="1dp" /> - - - - - - - - - + android:layout_gravity="center_vertical" + android:gravity="start" + android:textColor="@color/mainTextViewColor" + android:textSize="@dimen/cardViewMainText" /> - - - - - - - - - - - + + android:id="@+id/bottomLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> - + android:gravity="start" + android:textColor="@color/secondaryTextViewColor" + android:textSize="@dimen/cardViewMainText" + android:layout_weight="0.5"/> + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + android:background="@drawable/ic_delete_white_24dp" + android:clickable="false" + android:focusable="false"/> - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_detailsactivity.xml b/app/src/main/res/layout/fragment_home_detailsactivity.xml new file mode 100644 index 0000000..74c912b --- /dev/null +++ b/app/src/main/res/layout/fragment_home_detailsactivity.xml @@ -0,0 +1,358 @@ + + + + + +