import android.content.Context;
import android.database.MatrixCursor;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.AutoCompleteTextView;
import android.widget.Toast;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.ui.MobileLedgerListFragment;
import androidx.recyclerview.widget.RecyclerView;
import static android.content.Context.INPUT_METHOD_SERVICE;
+import static net.ktnx.mobileledger.utils.Logger.debug;
public class TransactionListFragment extends MobileLedgerListFragment {
private MenuItem menuTransactionListFilter;
@Override
public void onResume() {
super.onResume();
- Log.d("flow", "TransactionListFragment.onResume()");
+ debug("flow", "TransactionListFragment.onResume()");
}
@Override
public void onStop() {
super.onStop();
- Log.d("flow", "TransactionListFragment.onStop()");
+ debug("flow", "TransactionListFragment.onStop()");
}
@Override
public void onPause() {
super.onPause();
- Log.d("flow", "TransactionListFragment.onPause()");
+ debug("flow", "TransactionListFragment.onPause()");
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
- Log.d("flow", "TransactionListFragment.onActivityCreated called");
+ debug("flow", "TransactionListFragment.onActivityCreated called");
super.onActivityCreated(savedInstanceState);
swiper = mActivity.findViewById(R.id.transaction_swipe);
modelAdapter = new TransactionListAdapter();
root.setAdapter(modelAdapter);
- FloatingActionButton fab = mActivity.findViewById(R.id.btn_add_transaction);
-
mActivity.fabShouldShow();
- root.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
- if (dy < 0) mActivity.fabShouldShow();
- if (dy > 0) fab.hide();
- }
- });
+
+ manageFabOnScroll();
LinearLayoutManager llm = new LinearLayoutManager(mActivity);
- llm.setOrientation(LinearLayoutManager.VERTICAL);
+ llm.setOrientation(RecyclerView.VERTICAL);
root.setLayoutManager(llm);
swiper.setOnRefreshListener(() -> {
- Log.d("ui", "refreshing transactions via swipe");
- mActivity.scheduleTransactionListRetrieval();
+ debug("ui", "refreshing transactions via swipe");
+ Data.scheduleTransactionListRetrieval(mActivity);
});
Colors.themeWatch.observe(this, this::themeChanged);
- swiper.setColorSchemeColors(Colors.primary);
vAccountFilter = mActivity.findViewById(R.id.transaction_list_account_name_filter);
accNameFilter = mActivity.findViewById(R.id.transaction_filter_account_name);
MLDB.hookAutocompletionAdapter(mActivity, accNameFilter, "accounts", "name", true);
accNameFilter.setOnItemClickListener((parent, view, position, id) -> {
-// Log.d("tmp", "direct onItemClick");
+// debug("tmp", "direct onItemClick");
MatrixCursor mc = (MatrixCursor) parent.getItemAtPosition(position);
Data.accountFilter.setValue(mc.getString(1));
Globals.hideSoftKeyboard(mActivity);
});
}
private void onAccountNameFilterChanged(String accName) {
+ final String fieldText = accNameFilter.getText().toString();
+ if ((accName == null) && (fieldText.equals(""))) return;
+
if (accNameFilter != null) {
accNameFilter.setText(accName, false);
}