Permalink
Browse files

Inner loop - Green: Implement showing statement lines in the view

  • Loading branch information...
CarlosMChica committed May 2, 2016
1 parent b325378 commit 27bc2ac899dbdb111589573a0034683a311dc29e
@@ -49,9 +49,14 @@
@Test public void show_view_statement_lines() {
whenLaunchActivity();
List<ViewStatementLine> lines = lines();
final List<ViewStatementLine> lines = lines();
rule.getActivity().show(lines);
final ShowStatementActivity activity = rule.getActivity();
activity.runOnUiThread(new Runnable() {
@Override public void run() {
activity.show(lines);
}
});
assertThatStatementContains(lines);
}
@@ -33,5 +33,6 @@ private void initView() {
}
@Override public void show(List<ViewStatementLine> lines) {
recyclerView.setAdapter(new StatementLineAdapter(lines));
}
}
@@ -0,0 +1,26 @@
package me.panavtec.androidbankkata;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
class StatementLineAdapter extends RecyclerView.Adapter<StatementLineViewHolder> {
private final List<ViewStatementLine> lines;
public StatementLineAdapter(List<ViewStatementLine> lines) {
this.lines = lines;
}
@Override public StatementLineViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new StatementLineViewHolder(parent);
}
@Override public void onBindViewHolder(StatementLineViewHolder holder, int position) {
holder.onBind(lines.get(position));
}
@Override public int getItemCount() {
return lines.size();
}
}
@@ -0,0 +1,27 @@
package me.panavtec.androidbankkata;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
class StatementLineViewHolder extends RecyclerView.ViewHolder {
private final TextView dateTextView;
private final TextView amountTextView;
private final TextView runningBalanceTextView;
public StatementLineViewHolder(ViewGroup parent) {
super(
LayoutInflater.from(parent.getContext()).inflate(R.layout.view_transaction, parent, false));
dateTextView = (TextView) itemView.findViewById(R.id.dateTextView);
amountTextView = (TextView) itemView.findViewById(R.id.amountTextView);
runningBalanceTextView = (TextView) itemView.findViewById(R.id.runningBalanceTextView);
}
public void onBind(ViewStatementLine line) {
dateTextView.setText(line.date);
amountTextView.setText(line.amount);
runningBalanceTextView.setText(line.runningBalance);
}
}

0 comments on commit 27bc2ac

Please sign in to comment.