package net.ktnx.mobileledger.ui;
-import androidx.fragment.app.Fragment;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
-import androidx.recyclerview.widget.RecyclerView;
-
import net.ktnx.mobileledger.ui.activity.MainActivity;
import net.ktnx.mobileledger.ui.transaction_list.TransactionListAdapter;
+import net.ktnx.mobileledger.utils.Colors;
+
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class MobileLedgerListFragment extends Fragment {
protected MainActivity mActivity;
public SwipeRefreshLayout swiper;
protected RecyclerView root;
public TransactionListAdapter modelAdapter;
+ protected void themeChanged(Integer counter) {
+ swiper.setColorSchemeColors(Colors.primary);
+ }
}
}
});
swiper = mActivity.findViewById(R.id.account_swiper);
- Colors.themeWatch.addObserver((o, arg) -> swiper.setColorSchemeColors(Colors.primary));
- swiper.setColorSchemeColors(Colors.primary);
+ Colors.themeWatch.observe(this, this::themeChanged);
swiper.setOnRefreshListener(() -> {
Log.d("ui", "refreshing accounts via swipe");
mActivity.scheduleTransactionListRetrieval();
mActivity.scheduleTransactionListRetrieval();
});
- Colors.themeWatch.addObserver((o, arg) -> swiper.setColorSchemeColors(Colors.primary));
+ Colors.themeWatch.observe(this, this::themeChanged);
swiper.setColorSchemeColors(Colors.primary);
vAccountFilter = mActivity.findViewById(R.id.transaction_list_account_name_filter);
import androidx.annotation.ColorInt;
import androidx.annotation.ColorLong;
+import androidx.lifecycle.MutableLiveData;
import static java.lang.Math.abs;
@ColorInt
public static int primary, defaultTextColor;
public static int profileThemeId = -1;
- public static ObservableValue<Integer> themeWatch = new ObservableValue<>(0);
+ public static MutableLiveData<Integer> themeWatch = new MutableLiveData<>(0);
public static void refreshColors(Resources.Theme theme) {
TypedValue tv = new TypedValue();
theme.resolveAttribute(R.attr.table_row_dark_bg, tv, true);
accent = tv.data;
// trigger theme observers
- themeWatch.notifyObservers();
+ themeWatch.postValue(themeWatch.getValue()+1);
}
public static @ColorLong
long hsvaColor(float hue, float saturation, float value, float alpha) {