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);
}
});
(view) -> b.templateIsFallbackSwitch.toggle();
b.templateIsFallbackLabel.setOnClickListener(fallbackLabelClickListener);
b.templateIsFallbackText.setOnClickListener(fallbackLabelClickListener);
- b.templateDetailsTemplateParamsHelpButton.setOnClickListener(v -> HelpDialog.show(
- b.getRoot()
- .getContext(), R.string.template_details_template_params_label,
- R.array.template_params_help));
+ b.templateParamsHelpButton.setOnClickListener(v -> HelpDialog.show(b.getRoot()
+ .getContext(),
+ R.string.template_details_template_params_label, R.array.template_params_help));
}
@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");
b.testText.setText(header.getTestText());
if (header.hasLiteralDateYear()) {
- b.templateDetailsYearSource.setText(R.string.template_details_source_literal);
+ b.yearSource.setText(R.string.template_details_source_literal);
final Integer dateYear = header.getDateYear();
b.templateDetailsDateYear.setText(
(dateYear == null) ? null : String.valueOf(dateYear));
- b.templateDetailsDateYearLayout.setVisibility(View.VISIBLE);
+ b.yearLayout.setVisibility(View.VISIBLE);
}
else {
- b.templateDetailsDateYearLayout.setVisibility(View.GONE);
- b.templateDetailsYearSource.setText(
+ b.yearLayout.setVisibility(View.GONE);
+ b.yearSource.setText(
String.format(Locale.US, groupNoText, header.getDateYearMatchGroup(),
getMatchGroupText(header.getDateYearMatchGroup())));
}
- b.templateDetailsYearSourceLabel.setOnClickListener(
+ b.yearSourceLabel.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
- b.templateDetailsYearSource.setOnClickListener(
+ b.yearSource.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
if (header.hasLiteralDateMonth()) {
- b.templateDetailsMonthSource.setText(R.string.template_details_source_literal);
+ b.monthSource.setText(R.string.template_details_source_literal);
final Integer dateMonth = header.getDateMonth();
b.templateDetailsDateMonth.setText(
(dateMonth == null) ? null : String.valueOf(dateMonth));
- b.templateDetailsDateMonthLayout.setVisibility(View.VISIBLE);
+ b.monthLayout.setVisibility(View.VISIBLE);
}
else {
- b.templateDetailsDateMonthLayout.setVisibility(View.GONE);
- b.templateDetailsMonthSource.setText(
+ b.monthLayout.setVisibility(View.GONE);
+ b.monthSource.setText(
String.format(Locale.US, groupNoText, header.getDateMonthMatchGroup(),
getMatchGroupText(header.getDateMonthMatchGroup())));
}
- b.templateDetailsMonthSourceLabel.setOnClickListener(
+ b.monthSourceLabel.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_MONTH));
- b.templateDetailsMonthSource.setOnClickListener(
+ b.monthSource.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_MONTH));
if (header.hasLiteralDateDay()) {
- b.templateDetailsDaySource.setText(R.string.template_details_source_literal);
+ b.daySource.setText(R.string.template_details_source_literal);
final Integer dateDay = header.getDateDay();
b.templateDetailsDateDay.setText(
(dateDay == null) ? null : String.valueOf(dateDay));
- b.templateDetailsDateDayLayout.setVisibility(View.VISIBLE);
+ b.dayLayout.setVisibility(View.VISIBLE);
}
else {
- b.templateDetailsDateDayLayout.setVisibility(View.GONE);
- b.templateDetailsDaySource.setText(
+ b.dayLayout.setVisibility(View.GONE);
+ b.daySource.setText(
String.format(Locale.US, groupNoText, header.getDateDayMatchGroup(),
getMatchGroupText(header.getDateDayMatchGroup())));
}
- b.templateDetailsDaySourceLabel.setOnClickListener(
+ b.daySourceLabel.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_DAY));
- b.templateDetailsDaySource.setOnClickListener(
+ b.daySource.setOnClickListener(
v -> selectHeaderDetailSource(v, HeaderDetail.DATE_DAY));
if (header.hasLiteralTransactionDescription()) {
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");