例外workaround

This commit is contained in:
ろむねこ 2024-07-23 11:47:15 +09:00
parent 86093a1e13
commit f4b116cd27
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -1,5 +1,6 @@
package one.nem.kidshift.wallet; package one.nem.kidshift.wallet;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -172,9 +173,14 @@ public class HistoryItemListAdapter extends RecyclerView.Adapter<HistoryItemList
private int getMonthTotal(HistoryModel historyModel) { private int getMonthTotal(HistoryModel historyModel) {
int total = historyModel.getReward(); int total = historyModel.getReward();
int index = historyDataList.getList().indexOf(historyModel) + 1; int index = historyDataList.getList().indexOf(historyModel) + 1;
while (!isFirstOfMonth(this.historyDataList.getList().get(index))) { try {
total += historyModel.getReward(); while (!isFirstOfMonth(this.historyDataList.getList().get(index))) {
index++; total += historyModel.getReward();
index++;
}
} catch (IndexOutOfBoundsException e) {
// 1個しかない場合 Workaround
// TODO: 例外をひねり潰すのではなくそもそも発生しないようにするべき
} }
return total; return total;
} }