Skip to content

Commit 5ca3f05

Browse files
committed
Merge pull request android#11 from DmitriyZaitsev/dz/todo-databinding-1
Use binded fields instead of finding them by id again
2 parents 1b128d2 + f59d4fd commit 5ca3f05

File tree

1 file changed

+4
-5
lines changed
  • todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks

1 file changed

+4
-5
lines changed

todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksFragment.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
9393

9494
tasksFragBinding.setActionHandler(mPresenter);
9595

96-
View root = tasksFragBinding.getRoot();
97-
9896
// Set up tasks view
99-
ListView listView = (ListView) root.findViewById(R.id.tasks_list);
97+
ListView listView = tasksFragBinding.tasksList;
10098

10199
mListAdapter = new TasksAdapter(new ArrayList<Task>(0), mPresenter);
102100
listView.setAdapter(mListAdapter);
@@ -114,8 +112,7 @@ public void onClick(View v) {
114112
});
115113

116114
// Set up progress indicator
117-
final ScrollChildSwipeRefreshLayout swipeRefreshLayout =
118-
(ScrollChildSwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
115+
final ScrollChildSwipeRefreshLayout swipeRefreshLayout = tasksFragBinding.refreshLayout;
119116
swipeRefreshLayout.setColorSchemeColors(
120117
ContextCompat.getColor(getActivity(), R.color.colorPrimary),
121118
ContextCompat.getColor(getActivity(), R.color.colorAccent),
@@ -126,6 +123,8 @@ public void onClick(View v) {
126123

127124
setHasOptionsMenu(true);
128125

126+
View root = tasksFragBinding.getRoot();
127+
129128
return root;
130129
}
131130

0 commit comments

Comments
 (0)