Skip to content

Commit 59b198f

Browse files
committed
Added code syntax highlighting to Readme
1 parent abf5944 commit 59b198f

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

todoapp/README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TODO-MVP-Loaders
22

3-
It is based on the [TODO-MVP](https://github.com/googlesamples/android-architecture/tree/todo-mvp/todoapp) sample and uses Loaders to get the data from the tasks repository.
3+
It is based on the [TODO-MVP](https://github.com/googlesamples/android-architecture/tree/todo-mvp/todoapp) sample and uses Loaders to get the data from the tasks repository.
44

55
<img src="https://github.com/googlesamples/android-architecture/wiki/images/mvp-loaders.png" alt="Diagram"/>
66

@@ -17,45 +17,45 @@ configuration change.
1717

1818
### Asynchronous loading
1919

20-
The Loaders ([TaskLoader](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TaskLoader.java) and [TasksLoader](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksLoader.java)) are responsible for fetching the data and extend AsyncTaskLoader.
20+
The Loaders ([TaskLoader](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TaskLoader.java) and [TasksLoader](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksLoader.java)) are responsible for fetching the data and extend AsyncTaskLoader.
2121

2222
In [src/data/source/TasksLoader.java](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksLoader.java):
2323

2424

25-
```
26-
@Override
27-
public List<Task> loadInBackground() {
28-
return mRepository.getTasks();
29-
}
25+
```java
26+
@Override
27+
public List<Task> loadInBackground() {
28+
return mRepository.getTasks();
29+
}
3030
```
3131
The results are received in the UI Thread, handled by the presenter.
3232

3333
In [TasksPresenter.java](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksPresenter.java)
3434

3535

36-
```
37-
@Override
38-
public void onLoadFinished(Loader<List<Task>> loader, List<Task>
36+
```java
37+
@Override
38+
public void onLoadFinished(Loader<List<Task>> loader, List<Task>
3939
data) {
40-
mTasksView.setLoadingIndicator(false);
41-
42-
mCurrentTasks = data;
43-
if (mCurrentTasks == null) {
44-
mTasksView.showLoadingTasksError();
45-
} else {
46-
showFilteredTasks();
47-
}
40+
mTasksView.setLoadingIndicator(false);
41+
42+
mCurrentTasks = data;
43+
if (mCurrentTasks == null) {
44+
mTasksView.showLoadingTasksError();
45+
} else {
46+
showFilteredTasks();
4847
}
48+
}
4949
```
5050
The presenter also triggers the loading the data, like in the MVP sample but in
5151
this case it does it through the LoaderManager:
5252

5353

54-
```
55-
@Override
56-
public void start() {
57-
mLoaderManager.initLoader(TASKS_QUERY, null, this);
58-
}
54+
```java
55+
@Override
56+
public void start() {
57+
mLoaderManager.initLoader(TASKS_QUERY, null, this);
58+
}
5959
```
6060
### Content observer
6161

@@ -64,30 +64,30 @@ After every content change in the repository, <code>notifyContentObserver()</cod
6464
In [src/data/source/TasksRepository.java](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksRepository.java):
6565

6666

67-
```
68-
@Override
69-
public void deleteTask(@NonNull String taskId) {
70-
mTasksRemoteDataSource.deleteTask(checkNotNull(taskId));
71-
mTasksLocalDataSource.deleteTask(checkNotNull(taskId));
67+
```java
68+
@Override
69+
public void deleteTask(@NonNull String taskId) {
70+
mTasksRemoteDataSource.deleteTask(checkNotNull(taskId));
71+
mTasksLocalDataSource.deleteTask(checkNotNull(taskId));
7272

73-
mCachedTasks.remove(taskId);
73+
mCachedTasks.remove(taskId);
7474

75-
// Update the UI
76-
notifyContentObserver();
77-
}
75+
// Update the UI
76+
notifyContentObserver();
77+
}
7878
```
7979
This notifies the Loader which in this case simply forces a reload of data.
8080

8181
In [TasksLoader.java](https://github.com/googlesamples/android-architecture/blob/todo-mvp-loaders/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksLoader.java):
8282

8383

84-
```
85-
@Override
86-
public void onTasksChanged() {
87-
if (isStarted()) {
88-
forceLoad();
89-
}
84+
```java
85+
@Override
86+
public void onTasksChanged() {
87+
if (isStarted()) {
88+
forceLoad();
9089
}
90+
}
9191
```
9292
## Additional dependencies
9393

@@ -98,11 +98,11 @@ This project uses the Loaders framework available from Android 3.0 (API Level
9898

9999
### Complexity - understandability
100100

101-
#### Use of architectural frameworks/libraries/tools:
101+
#### Use of architectural frameworks/libraries/tools:
102102

103-
No external frameworks.
103+
No external frameworks.
104104

105-
#### Conceptual complexity
105+
#### Conceptual complexity
106106

107107
Developers need to be familiar with the Loaders framework, which is not
108108
trivial.
@@ -121,7 +121,7 @@ No difference with MVP.
121121
### Code metrics
122122

123123
Compared to MVP, the only new classes are TaskLoader and TasksLoader. Parts of
124-
the code are simpler as Loaders take care of the asynchronous work.
124+
the code are simpler as Loaders take care of the asynchronous work.
125125

126126

127127
```

0 commit comments

Comments
 (0)