public void bind(int index) { Weight w = weights.get(index); date.setText(EnvUtil.getFormattedDate(w.getDate())); value.setText(EnvUtil.formatWeight(EnvUtil.getProperValue(w, ctx))); unit.setText(EnvUtil.getLocalUnitString(ctx)); delete.setOnClickListener( view -> { Log.d(TAG, String.format("delete = %d", index)); remove(w); }); }
public void remove(Weight w) { notifyItemRemoved(weights.indexOf(w)); w.delete(); weights.remove(w); }