import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
else {
viewModel.setFocusedItem(focused);
}
+
+ ProgressBar p = activity.findViewById(R.id.progressBar);
+ viewModel.observeBusyFlag(getViewLifecycleOwner(), isBusy -> {
+ if (isBusy) {
+// Handler h = new Handler();
+// h.postDelayed(() -> {
+// if (viewModel.getBusyFlag())
+// p.setVisibility(View.VISIBLE);
+//
+// }, 10);
+ p.setVisibility(View.VISIBLE);
+ }
+ else
+ p.setVisibility(View.INVISIBLE);
+ });
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.FrameLayout;
-import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
private Observer<Currency> currencyObserver;
private Observer<Boolean> showCurrencyObserver;
private Observer<String> commentObserver;
- private Observer<Boolean> busyFlagObserver;
private boolean inUpdate = false;
private boolean syncingData = false;
private View commentButton;
lAccount = itemView.findViewById(R.id.ntr_account);
lPadding = itemView.findViewById(R.id.ntr_padding);
View commentLayout = itemView.findViewById(R.id.comment_layout);
- ProgressBar p = itemView.findViewById(R.id.progressBar);
tvDescription.setNextFocusForwardId(View.NO_ID);
tvAccount.setNextFocusForwardId(View.NO_ID);
((focusedView != tvComment) && Misc.isEmptyOrNull(comment)) ? View.INVISIBLE
: View.VISIBLE);
};
-
- busyFlagObserver = isBusy -> {p.setVisibility(isBusy ? View.VISIBLE : View.INVISIBLE);};
}
private void updateCurrencyPositionAndPadding(Currency.Position position, boolean hasGap) {
ConstraintLayout.LayoutParams amountLP =
this.item.stopObservingCurrency(currencyObserver);
this.item.getModel().showCurrency.removeObserver(showCurrencyObserver);
this.item.stopObservingComment(commentObserver);
- this.item.getModel().stopObservingBusyFlag(busyFlagObserver);
this.item = null;
}
case generalData:
item.observeDate(activity, dateObserver);
item.observeDescription(activity, descriptionObserver);
- item.getModel().observeBusyFlag(activity, busyFlagObserver);
break;
case transactionRow:
item.observeAmountHint(activity, hintObserver);
profile -> showCurrency.postValue(profile.getShowCommodityByDefault());
private final AtomicInteger busyCounter = new AtomicInteger(0);
private final MutableLiveData<Boolean> busyFlag = new MutableLiveData<>(false);
- void observeBusyFlag(LifecycleOwner owner, Observer<? super Boolean> observer) {
+ void observeBusyFlag(@NonNull LifecycleOwner owner, Observer<? super Boolean> observer) {
busyFlag.observe(owner, observer);
}
void observeDataProfile(LifecycleOwner activity) {
int newValue = busyCounter.decrementAndGet();
if (newValue == 0) busyFlag.postValue(false);
}
+ public boolean getBusyFlag() {
+ return busyFlag.getValue();
+ }
enum ItemType {generalData, transactionRow, bottomFiller}
enum FocusedElement {Account, Comment, Amount}
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:animateLayoutChanges="true"
tools:context="net.ktnx.mobileledger.ui.activity.NewTransactionActivity">
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="@style/Widget.AppCompat.ProgressBar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:indeterminate="true"
+ android:indeterminateBehavior="cycle"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
<androidx.recyclerview.widget.RecyclerView
android:orientation="vertical"
android:id="@+id/new_transaction_accounts"
app:layout_constraintStart_toEndOf="@id/new_transaction_date"
app:layout_constraintTop_toTopOf="parent" />
- <ProgressBar
- android:id="@+id/progressBar"
- style="@style/Widget.AppCompat.ProgressBar.Horizontal"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:indeterminate="true"
- android:indeterminateBehavior="cycle"
- android:orientation="horizontal"
- android:visibility="invisible"
- app:layout_constraintTop_toBottomOf="@id/new_transaction_date"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent
-"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout