def room_version = '2.2.6'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
- def nav_version = '2.3.4'
+ def nav_version = '2.3.5'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
- implementation 'androidx.recyclerview:recyclerview:1.1.0'
+ implementation 'androidx.recyclerview:recyclerview:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0-alpha05'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha05'
@NotNull
private LedgerAccount getAccount() {
return listDiffer.getCurrentList()
- .get(getAdapterPosition())
+ .get(getBindingAdapterPosition())
.getAccount();
}
private void toggleAmountsExpanded() {
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.recyclerview.widget.RecyclerView;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.databinding.NewTransactionAccountRowBinding;
boolean wasSyncing = syncingData;
syncingData = true;
try {
- final int pos = getAdapterPosition();
+ final int pos = getBindingAdapterPosition();
if (id == R.id.account_row_acc_name) {
adapter.noteFocusIsOnAccount(pos);
}
CurrencySelectorFragment cpf = new CurrencySelectorFragment();
cpf.showPositionAndPadding();
cpf.setOnCurrencySelectedListener(
- c -> adapter.setItemCurrency(getAdapterPosition(), c));
+ c -> adapter.setItemCurrency(getBindingAdapterPosition(), c));
cpf.show(activity.getSupportFragmentManager(), "currency-selector");
});
ignoreFocusChanges = true;
try {
if (((focusInfo == null) || (focusInfo.element == null) ||
- focusInfo.position != getAdapterPosition()))
+ focusInfo.position != getBindingAdapterPosition()))
return;
NewTransactionModel.TransactionAccount acc = getItem().toTransactionAccount();
return false;
}
- if (getAdapterPosition() < 0) {
+ if (getBindingAdapterPosition() == RecyclerView.NO_POSITION) {
// probably the row was swiped out
Logger.debug("new-trans", "Ignoring request to suncData(): adapter position negative");
return false;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.databinding.NewTransactionHeaderRowBinding;
boolean wasSyncing = syncingData;
syncingData = true;
try {
- final int pos = getAdapterPosition();
+ final int pos = getBindingAdapterPosition();
if (id == R.id.transaction_comment) {
adapter.noteFocusIsOnTransactionComment(pos);
}
ignoreFocusChanges = true;
try {
if (((focusInfo == null) || (focusInfo.element == null) ||
- focusInfo.position != getAdapterPosition()))
+ focusInfo.position != getBindingAdapterPosition()))
return;
NewTransactionModel.Item head = getItem().toTransactionHead();
return false;
}
- if (getAdapterPosition() < 0) {
+ if (getBindingAdapterPosition() == RecyclerView.NO_POSITION) {
// probably the row was swiped out
Logger.debug("new-trans", "Ignoring request to suncData(): adapter position negative");
return false;
mProfile = Data.getProfile();
}
NewTransactionModel.Item getItem() {
- return mAdapter.getItem(getAdapterPosition());
+ return mAdapter.getItem(getBindingAdapterPosition());
// return Objects.requireNonNull(mAdapter.model.getItems()
// .getValue())
-// .get(getAdapterPosition());
+// .get(getBindingAdapterPosition());
}
abstract public void bind(NewTransactionModel.Item item);
}
public boolean canDropOver(@NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder current,
@NonNull RecyclerView.ViewHolder target) {
- final int adapterPosition = target.getAdapterPosition();
+ final int adapterPosition = target.getBindingAdapterPosition();
// first item is immovable
if (adapterPosition == 0)
@NonNull RecyclerView.ViewHolder viewHolder) {
int flags = makeFlag(ItemTouchHelper.ACTION_STATE_IDLE, ItemTouchHelper.END);
// the top (date and description) and the bottom (padding) items are always there
- final int adapterPosition = viewHolder.getAdapterPosition();
+ final int adapterPosition = viewHolder.getBindingAdapterPosition();
if (adapterPosition > 0) {
flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG,
ItemTouchHelper.UP | ItemTouchHelper.DOWN) |
@NonNull RecyclerView.ViewHolder viewHolder,
@NonNull RecyclerView.ViewHolder target) {
- model.moveItem(viewHolder.getAdapterPosition(), target.getAdapterPosition());
+ model.moveItem(viewHolder.getBindingAdapterPosition(),
+ target.getBindingAdapterPosition());
return true;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
- int pos = viewHolder.getAdapterPosition();
+ int pos = viewHolder.getBindingAdapterPosition();
viewModel.removeItem(pos);
}
});
@NonNull RecyclerView.ViewHolder viewHolder,
@NonNull RecyclerView.ViewHolder target) {
final List<Profile> profiles = new ArrayList<>(listDiffer.getCurrentList());
- Collections.swap(profiles, viewHolder.getAdapterPosition(),
- target.getAdapterPosition());
+ Collections.swap(profiles, viewHolder.getBindingAdapterPosition(),
+ target.getBindingAdapterPosition());
DB.get()
.getProfileDAO()
.updateOrder(profiles, null);
-// notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
+// notifyItemMoved(viewHolder.getBindingAdapterPosition(), target
+// .getBindingAdapterPosition());
return true;
}
@Override
holder.mEditButton.setOnClickListener(view -> {
Profile p = listDiffer.getCurrentList()
- .get(holder.getAdapterPosition());
+ .get(holder.getBindingAdapterPosition());
ProfileDetailActivity.start(view.getContext(), p);
});
if (editingProfiles())
return;
Profile profile = listDiffer.getCurrentList()
- .get(getAdapterPosition());
+ .get(getBindingAdapterPosition());
if (Data.getProfile() != profile) {
debug("profiles", "Setting profile to " + profile.getName());
Data.drawerOpen.setValue(false);
public boolean canDropOver(@NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder current,
@NonNull RecyclerView.ViewHolder target) {
- final int adapterPosition = target.getAdapterPosition();
+ final int adapterPosition = target.getBindingAdapterPosition();
// first item is immovable
if (adapterPosition == 0)
@NonNull RecyclerView.ViewHolder viewHolder) {
int flags = 0;
// the top item (transaction params) is always there
- final int adapterPosition = viewHolder.getAdapterPosition();
+ final int adapterPosition = viewHolder.getBindingAdapterPosition();
if (adapterPosition > 0)
flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG,
ItemTouchHelper.UP | ItemTouchHelper.DOWN) |
@NonNull RecyclerView.ViewHolder viewHolder,
@NonNull RecyclerView.ViewHolder target) {
- final int fromPosition = viewHolder.getAdapterPosition();
- final int toPosition = target.getAdapterPosition();
+ final int fromPosition = viewHolder.getBindingAdapterPosition();
+ final int toPosition = target.getBindingAdapterPosition();
if (fromPosition == toPosition) {
Logger.debug("drag", String.format(Locale.US,
"Ignoring request to move an account from position %d to %d",
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
- int pos = viewHolder.getAdapterPosition();
+ int pos = viewHolder.getBindingAdapterPosition();
mModel.removeItem(pos);
}
});
}
@NotNull
private TemplateDetailsItem.Header getItem() {
- int pos = getAdapterPosition();
+ int pos = getBindingAdapterPosition();
return differ.getCurrentList()
.get(pos)
.asHeaderItem();
}
}
- notifyItemChanged(getAdapterPosition());
+ notifyItemChanged(getBindingAdapterPosition());
});
final AppCompatActivity activity = (AppCompatActivity) v.getContext();
sel.show(activity.getSupportFragmentManager(), "template-details-source-selector");
String groupNoText = resources.getString(R.string.template_item_match_group_source);
Logger.debug("drag", String.format(Locale.US, "Binding account id %d, pos %d at %d",
- item.getId(), item.getPosition(), getAdapterPosition()));
+ item.getId(), item.getPosition(), getBindingAdapterPosition()));
TemplateDetailsItem.AccountRow accRow = item.asAccountRowItem();
b.patternAccountLabel.setText(String.format(Locale.US,
resources.getString(R.string.template_details_account_row_label),
}
private @NotNull TemplateDetailsItem.AccountRow getItem() {
return differ.getCurrentList()
- .get(getAdapterPosition())
+ .get(getBindingAdapterPosition())
.asAccountRowItem();
}
private void selectAccountRowDetailSource(View v, AccDetail detail) {
}
}
- notifyItemChanged(getAdapterPosition());
+ notifyItemChanged(getBindingAdapterPosition());
});
final AppCompatActivity activity = (AppCompatActivity) v.getContext();
sel.show(activity.getSupportFragmentManager(), "template-details-source-selector");