progress bar around the save transaction floating action button
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Dec 2018 20:39:22 +0000 (20:39 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 Dec 2018 20:39:22 +0000 (20:39 +0000)
app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
app/src/main/res/layout/activity_new_transaction.xml

index 7fc8bcc817eb43272d8819b0d4d04fe74706bc41..7648a65fa495facee6010cbcfef030a7d5624788 100644 (file)
@@ -23,6 +23,7 @@ import android.view.View;
 import android.widget.AutoCompleteTextView;
 import android.widget.EditText;
 import android.widget.FilterQueryProvider;
+import android.widget.ProgressBar;
 import android.widget.SimpleCursorAdapter;
 import android.widget.TableLayout;
 import android.widget.TableRow;
@@ -50,6 +51,7 @@ import java.util.Objects;
 public class NewTransactionActivity extends AppCompatActivity implements TaskCallback {
     private TableLayout table;
     private FloatingActionButton fab;
+    private ProgressBar progress;
     private TextView text_date;
     private TextView text_descr;
     private static SaveTransactionTask saver;
@@ -75,6 +77,8 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
                 new_transaction_save_clicked(view);
             }
         });
+        progress = findViewById(R.id.save_transaction_progress);
+
         Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
         table = findViewById(R.id.new_transaction_accounts_table);
         for (int i = 0; i < table.getChildCount(); i++) {
@@ -86,6 +90,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
 
     public void new_transaction_save_clicked(View view) {
         fab.setEnabled(false);
+        progress.setVisibility(View.VISIBLE);
 
         saver = new SaveTransactionTask(this);
 
@@ -218,6 +223,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
     @Override
     public void done() {
         fab.setEnabled(true);
+        progress.setVisibility(View.INVISIBLE);
         reset_form();
     }
 
index 4b16686756f9fa1c7d667eaf247f07214992ff23..75876a4320b1174c2a21fa4178eeefbdbfa9bff5 100644 (file)
 
     <include layout="@layout/content_new_transaction" />
 
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/fab"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="bottom|end"
-        android:layout_margin="@dimen/fab_margin"
-        android:foregroundTint="@android:color/white"
-        android:tint="@android:color/white"
-        app:backgroundTint="@color/colorPrimary"
-        app:srcCompat="@android:drawable/ic_menu_save" />
+    <android.support.constraint.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        >
+
+        <ProgressBar
+            android:id="@+id/save_transaction_progress"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
+            android:layout_margin="4dp"
+            android:visibility="invisible"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent" />
+
+        <android.support.design.widget.FloatingActionButton
+            android:id="@+id/fab"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:foregroundTint="@android:color/white"
+            android:padding="@dimen/fab_margin"
+            android:tint="@android:color/white"
+            app:backgroundTint="@color/colorPrimary"
+            app:layout_constraintBottom_toBottomOf="@id/save_transaction_progress"
+            app:layout_constraintEnd_toEndOf="@id/save_transaction_progress"
+            app:layout_constraintStart_toStartOf="@id/save_transaction_progress"
+            app:layout_constraintTop_toTopOf="@id/save_transaction_progress"
+            app:srcCompat="@android:drawable/ic_menu_save" />
+
+    </android.support.constraint.ConstraintLayout>
 
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file