Skip to content

Commit

Permalink
Updated loading dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Mar 6, 2018
1 parent 712a65b commit 7d44f45
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
Expand Up @@ -35,7 +35,7 @@
*/

public class DataLoaderScreen extends AppCompatActivity {
public static MaterialDialog progressDialog = null;
//public static MaterialDialog progressDialog = null;
public static AppCompatActivity dataLoaderScreenActivity;

private float mpu;
Expand All @@ -51,13 +51,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Log.d(Constants.LOG.MATAG, Constants.LOG.CREATING_MAINVIEW);
setContentView(R.layout.activity_loading);
//mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
progressDialog = new MaterialDialog.Builder(this)
/*progressDialog = new MaterialDialog.Builder(this)
.cancelable(false)
.title(R.string.loadingData)
.content(R.string.please_wait)
.progress(false, 100)
.build();
progressDialog.show();
progressDialog.show();*/
new DataLoader().execute();
//new MainActivity.DataLoader().execute();
} else {
Expand Down Expand Up @@ -107,9 +107,9 @@ protected void onPostExecute(Boolean result) {
//DataLoaderScreen.this.finish();
} else {
Log.i("DLS", "Data non-loaded...");
if (progressDialog != null) {
/*if (progressDialog != null) {
progressDialog.dismiss();
}
}*/
new MaterialDialog.Builder(DataLoaderScreen.this)
.positiveText(R.string.accept)
.cancelable(false)
Expand Down Expand Up @@ -174,7 +174,7 @@ public void run() {
}*/
try {
mpu = round((float) getHTTPSRequest(Constants.STATS_URL).getDouble(Constants.MARKET_NAME), 2);
progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
//progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
} catch (Exception e) {
Log.e(Constants.LOG.MATAG, Constants.LOG.MARKET_PRICE_ERROR + e.getMessage());
mpu = -1;
Expand Down Expand Up @@ -202,7 +202,7 @@ public void run() {
}*/
try {
retrievedData = JSONTools.convert2HashMap(getHTTPSRequest(url));
progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
//progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
} catch (Exception e) {
retrievedData = null;
Log.e(Constants.LOG.MATAG, Constants.LOG.DATA_ERROR + e.getMessage());
Expand All @@ -229,7 +229,7 @@ public void run() {
}*/
try {
cardsData = JSONTools.convert2HashMap(getHTTPSRequest(Constants.STATS_URL));
progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
//progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
} catch (Exception e) {
cardsData = null;
Log.e(Constants.LOG.MATAG, Constants.LOG.DATA_ERROR + e.getMessage());
Expand All @@ -254,7 +254,7 @@ public void run() {
}*/
try {
btcPrice = JSONTools.convert2DateHashMap(getHTTPSRequest(Constants.API_URL).getJSONObject("bpi"));
progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
//progressDialog.setProgress(progressDialog.getCurrentProgress() + 20);
} catch (Exception e) {
btcPrice = null;
Log.e(Constants.LOG.MATAG, Constants.LOG.DATA_ERROR + e.getMessage());
Expand Down
Expand Up @@ -34,7 +34,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.donations_activity);

if (isGooglePlayServicesAvaiable(this)) {
if (isGooglePlayServicesAvailable(this)) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
DonationsFragment donationsFragment;

Expand Down Expand Up @@ -68,7 +68,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}

public boolean isGooglePlayServicesAvaiable(Activity activity) {
public boolean isGooglePlayServicesAvailable(Activity activity) {
GoogleApiAvailability googleApiAvailabilityForPlayServices = GoogleApiAvailability.getInstance();
int status = googleApiAvailabilityForPlayServices.isGooglePlayServicesAvailable(activity);
if (status != ConnectionResult.SUCCESS) {
Expand Down
Expand Up @@ -99,7 +99,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
createTable(tableLayout, createdView);
try {
tableThread.join();
DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 10);
//DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 10);
return createdView;
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down
Expand Up @@ -161,9 +161,9 @@ public void onClick(View v) {
longPressInfo = getString(R.string.longclick);
((TextView) createdView.findViewById(R.id.longPressInfo)).setText(longPressInfo);
return createdView;
} finally {
DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 10);
}
}/* finally {
//DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 10);
}*/
}

private void setupValues() {
Expand Down
Expand Up @@ -187,7 +187,7 @@ protected void onResume() {
//DataLoaderScreen.progressDialog.setProgress(DataLoaderScreen.progressDialog.getCurrentProgress() + 5);
//Toast.makeText(this, "Hi, the activity is fully loaded", Toast.LENGTH_LONG).show();
DataLoaderScreen.dataLoaderScreenActivity.finish();
DataLoaderScreen.progressDialog.dismiss();
//DataLoaderScreen.progressDialog.dismiss();
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/launch_screen.xml
Expand Up @@ -6,6 +6,6 @@
<item>
<bitmap
android:src="@drawable/ic_launcher_foreground"
android:gravity="center"/>
android:gravity="center" />
</item>
</layer-list>
31 changes: 28 additions & 3 deletions app/src/main/res/layout/activity_loading.xml
@@ -1,6 +1,31 @@
<?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">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<ProgressBar
android:id="@+id/progressBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.342"
app:layout_constraintStart_toStartOf="parent" />

<TextView
android:id="@+id/textView"
style="@android:style/Widget.DeviceDefault.Light.TextView.SpinnerItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="44dp"
android:layout_marginStart="20dp"
android:text="@string/loadingData"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/progressBar2" />
</android.support.constraint.ConstraintLayout>

0 comments on commit 7d44f45

Please sign in to comment.