Add loading indicator for trades
This commit is contained in:
parent
680840b262
commit
009dc09eca
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@ -3,7 +3,6 @@
|
|||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/Moodl.iml" filepath="$PROJECT_DIR$/Moodl.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Moodl.iml" filepath="$PROJECT_DIR$/Moodl.iml" />
|
||||||
<module fileurl="file://E:\Github\Moodl\Moodl.iml" filepath="E:\Github\Moodl\Moodl.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package com.nauk.moodl.Activities;
|
package com.nauk.moodl.Activities;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
@ -21,6 +24,7 @@ import android.support.v7.app.AppCompatActivity;
|
|||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -101,6 +105,9 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
private Button lineChartButton;
|
private Button lineChartButton;
|
||||||
private Button candleStickChartButton;
|
private Button candleStickChartButton;
|
||||||
|
|
||||||
|
|
||||||
|
private View loadingFooter;
|
||||||
|
|
||||||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||||
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
|
|
||||||
@ -218,6 +225,11 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
hasBeenModified = false;
|
hasBeenModified = false;
|
||||||
|
|
||||||
|
Drawable tradeDrawable = ((ProgressBar) findViewById(R.id.loadingIndicator)).getIndeterminateDrawable();
|
||||||
|
tradeDrawable.mutate();
|
||||||
|
tradeDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
tradeDrawable.invalidateSelf();
|
||||||
|
|
||||||
TradeUpdater updater = new TradeUpdater();
|
TradeUpdater updater = new TradeUpdater();
|
||||||
updater.execute();
|
updater.execute();
|
||||||
}
|
}
|
||||||
@ -906,8 +918,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void drawTradeList(ArrayList<com.nauk.moodl.DataManagers.CurrencyData.Trade> trades)
|
private void drawTradeList(ArrayList<com.nauk.moodl.DataManagers.CurrencyData.Trade> trades)
|
||||||
{
|
{
|
||||||
findViewById(R.id.tradeProgressBar).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
tradeLayout.setOnScrollListener(new AbsListView.OnScrollListener() {
|
tradeLayout.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
@ -922,7 +932,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
{
|
{
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
|
|
||||||
expand(findViewById(R.id.tradeProgressBar));
|
|
||||||
TradeAdder tradeAdder = new TradeAdder();
|
TradeAdder tradeAdder = new TradeAdder();
|
||||||
tradeAdder.execute();
|
tradeAdder.execute();
|
||||||
}
|
}
|
||||||
@ -934,6 +943,8 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
tradeLayout.setAdapter(tradeListAdapter);
|
tradeLayout.setAdapter(tradeListAdapter);
|
||||||
tradeLayout.setTextFilterEnabled(false);
|
tradeLayout.setTextFilterEnabled(false);
|
||||||
|
|
||||||
|
findViewById(R.id.tradeLoaderIndicator).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void expand(final View v) {
|
private static void expand(final View v) {
|
||||||
@ -983,8 +994,28 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadingIndicatorGenerator()
|
||||||
|
{
|
||||||
|
loadingFooter = LayoutInflater.from(CurrencyDetailsActivity.this).inflate(R.layout.listview_loading_indicator, null, false);
|
||||||
|
|
||||||
|
Drawable drawable = ((ProgressBar) loadingFooter.findViewById(R.id.progressIndicator)).getIndeterminateDrawable();
|
||||||
|
drawable.mutate();
|
||||||
|
drawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
drawable.invalidateSelf();
|
||||||
|
|
||||||
|
tradeLayout.addFooterView(loadingFooter);
|
||||||
|
}
|
||||||
|
|
||||||
private class TradeAdder extends AsyncTask<Void, Integer, Void>
|
private class TradeAdder extends AsyncTask<Void, Integer, Void>
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
|
super.onPreExecute();
|
||||||
|
|
||||||
|
loadingIndicatorGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
|
|
||||||
@ -1006,7 +1037,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
tradeListAdapter.notifyDataSetChanged();
|
tradeListAdapter.notifyDataSetChanged();
|
||||||
flag_loading = false;
|
flag_loading = false;
|
||||||
|
|
||||||
findViewById(R.id.tradeProgressBar).setVisibility(View.GONE);
|
tradeLayout.removeFooterView(loadingFooter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1027,8 +1058,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
protected void onPreExecute()
|
protected void onPreExecute()
|
||||||
{
|
{
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
|
||||||
findViewById(R.id.tradeProgressBar).setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -625,18 +625,31 @@
|
|||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/tradeLoaderIndicator"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loadingIndicator"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Looking for trades..."/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/listTrades"
|
android:id="@+id/listTrades"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"/>
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/tradeProgressBar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/mainLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:id="@+id/mainLayout">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
|
19
app/src/main/res/layout/listview_loading_indicator.xml
Normal file
19
app/src/main/res/layout/listview_loading_indicator.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressIndicator"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Looking for more trades..."/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user