From 0c98e4d0090851e3265dfe379592658b7ac498b1 Mon Sep 17 00:00:00 2001 From: Felix Prahl-Kamps Date: Sun, 19 Aug 2018 13:54:15 +0200 Subject: [PATCH] fix read sync info, modified upload state adapter --- app/src/main/AndroidManifest.xml | 6 +- .../wg/its/mispbump/QrSyncActivity.java | 14 +-- .../wg/its/mispbump/SyncUploadActivity.java | 41 ++++++- .../mispbump/adapter/UploadStateAdapter.java | 17 ++- .../wg/its/mispbump/cam/CameraFragment.java | 1 - .../wg/its/mispbump/model/UploadState.java | 12 +- app/src/main/res/layout/row_upload_state.xml | 105 ++++++++---------- 7 files changed, 115 insertions(+), 81 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dcfc2af..3280d17 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -28,8 +28,10 @@ android:screenOrientation="portrait" android:theme="@style/AppTheme.Fullscreen"> - - + + + uploadStates.length) { @@ -180,6 +187,11 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic } private void setApplicationError(boolean canRetry) { + + setErrorOnRemainingTasks(); + + uploadStateAdapter.notifyDataSetChanged(); + fabFinish.setVisibility(View.VISIBLE); if (canRetry) { @@ -187,6 +199,23 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic } } + private void setErrorOnRemainingTasks() { + + boolean errorFound = false; + + for (int i = 0; i < uploadStates.length; i++) { + + if (!errorFound && uploadStates[i].getCurrentState() == UploadState.State.ERROR) { + errorFound = true; + continue; + } + + if (errorFound) { + uploadStates[i].setFollowError(); + } + } + } + // Upload States private void checkBundle(UploadState state) { diff --git a/app/src/main/java/de/overview/wg/its/mispbump/adapter/UploadStateAdapter.java b/app/src/main/java/de/overview/wg/its/mispbump/adapter/UploadStateAdapter.java index edc05ea..9400d77 100644 --- a/app/src/main/java/de/overview/wg/its/mispbump/adapter/UploadStateAdapter.java +++ b/app/src/main/java/de/overview/wg/its/mispbump/adapter/UploadStateAdapter.java @@ -6,6 +6,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.ProgressBar; import android.widget.TextView; import de.overview.wg.its.mispbump.R; import de.overview.wg.its.mispbump.model.UploadState; @@ -20,7 +21,8 @@ public class UploadStateAdapter extends RecyclerView.Adapter barcodes = barcodeDetector.detect(frame); if (barcodes.size() > 0) { - Log.d(TAG, "onImageAvailable: " + barcodes.valueAt(0).rawValue); parentActivity.onReadQrCode(barcodes.valueAt(0).rawValue); } } diff --git a/app/src/main/java/de/overview/wg/its/mispbump/model/UploadState.java b/app/src/main/java/de/overview/wg/its/mispbump/model/UploadState.java index a88a798..3538e27 100644 --- a/app/src/main/java/de/overview/wg/its/mispbump/model/UploadState.java +++ b/app/src/main/java/de/overview/wg/its/mispbump/model/UploadState.java @@ -6,7 +6,8 @@ public class UploadState { PENDING, IN_PROGRESS, DONE, - ERROR + ERROR, + FOLLOW_ERROR } private State currentState = State.PENDING; private String title, error; @@ -19,6 +20,7 @@ public class UploadState { public String getTitle() { return title; } + public void setTitle(String title) { this.title = title; } @@ -26,20 +28,28 @@ public class UploadState { public String getErrorMessage() { return error; } + public void setError(String error) { this.error = error; this.currentState = State.ERROR; } + public void setDone() { this.currentState = State.DONE; } + public void setInProgress() { this.currentState = State.IN_PROGRESS; } + public void setPending() { this.currentState = State.PENDING; } + public void setFollowError () { + this.currentState = State.FOLLOW_ERROR; + } + public State getCurrentState() { return currentState; } diff --git a/app/src/main/res/layout/row_upload_state.xml b/app/src/main/res/layout/row_upload_state.xml index 9055202..1c30e64 100644 --- a/app/src/main/res/layout/row_upload_state.xml +++ b/app/src/main/res/layout/row_upload_state.xml @@ -12,68 +12,55 @@ app:cardPreventCornerOverlap="true" app:contentPadding="16dp"> - + + + + + + + + + + + + + + - - + android:text="This will be a meaningful error, somewhen in the future!" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:textColor="#f44336"/> - - - - - - - - - +