Skip to content

Commit

Permalink
Merge pull request #37 from levibostian/fix-bugs-found-from-wendy-ios
Browse files Browse the repository at this point in the history
0.1.2-alpha release
  • Loading branch information
levibostian authored Apr 18, 2018
2 parents a96c482 + 6ec1e76 commit 2bfcad9
Show file tree
Hide file tree
Showing 31 changed files with 350 additions and 90 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
17 changes: 17 additions & 0 deletions BEST_PRACTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ You know the `data_id` property in `PendingTask`? That `data_id` property is mea

Because you are supposed to query for the data of a job right before a job is run, there is no need to update a `PendingTask`. If the user edits data represented by a certain `data_id` `PendingData`, the freshest data will be the data that gets synced.

# PendingTask subclasses each having 1 specific use case

Each subclass of PendingTask that you create in your app should represent 1 task a user can perform in the app.

Example: You are building a grocery list app. Users of your app can complete the following tasks:

* Add grocery store list items.
* Edit the name of the already added grocery store list items.
* Delete grocery store list items.
* Update the profile picture of their account they created.

Because there are 4 separate, small tasks that users can do in your app, your app code needs to have 4 separate subclasses of PendingTask. One for each task. Sure, you might think you can and/or should combine the top 3 tasks into a PendingTask subclass called `GroceryStoreListItemPendingTask` and have all of the various abilities combined into 1 and have 1 subclass `ProfilePendingTask` for the last task of updating the profile picture. This is not the way Wendy is intended to work.

Wendy requires each subclass of `PendingTask` is designed to perform 1 task. There are checks in Wendy that will throw exceptions on you if you do not follow this rule. If you do, you should not have an issue. Here is a list of those checks Wendy performs:

* Every instance of a `PendingTask` subclass must **all** have a `groupId` or **all** must *not* have a `groupId`.

# How do I delete a PendingTask that I added to Wendy?

You don't delete `PendingTask`s. That is on purpose.
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [0.1.2-alpha] - 2018-04-18
### Added
- Enforce a new best practice: All subclasses of a PendingTask must all have a groupId or none of them have a groupId.

### Fixed
- While a PendingTask is running by the task runner, if a duplicate of that PendingTask gets added to Wendy, do not delete the PendingTask if it runs successfully.
- I forgot to include all of the parameters in the recursion calls to the task runner's runAllTasks() function call. That's fixed.

### Changed
- **Breaking Change** Removed the `rescheduled` parameter in the Wendy listeners when a task is complete. It is always rescheduled if it fails so no need for the paramter.
- **Breaking Change** `Wendy.runAllTasks()` now takes an object for filtering instead of a string for `groupId`.

## [0.1.1-alpha] - 2018-04-13
### Added
- Add `strict` mode to help developer during development of Wendy.
Expand Down
6 changes: 5 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
if github.branch_for_base == "master"
if !git.modified_files.include? "config/*"
if !git.modified_files.include? "docs/*"
warn 'Did you remember to generate documentation via dokku? (Hint: `./gradlew dokka`)'
end
if !git.modified_files.include? "CHANGELOG.md"
fail 'You need to edit the CHANGELOG.md file.'
end
android_version_change.assert_version_name_changed("wendy/build.gradle")
end

if git.modified_files.include? "build.gradle" or git.modified_files.include? "wendy/build.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MainActivity : AppCompatActivity(), TaskRunnerListener {
WendyConfig.automaticallyRunTasks = activity_main_automatically_run_tasks_checkbox.isChecked

activity_main_run_all_tasks_button.setOnClickListener {
Wendy.sharedInstance().runTasks()
Wendy.sharedInstance().runTasks(null)
}

activity_main_tasks_recyclerview.layoutManager = LinearLayoutManager(this)
Expand Down Expand Up @@ -71,7 +71,7 @@ class MainActivity : AppCompatActivity(), TaskRunnerListener {
}
override fun taskSkipped(reason: ReasonPendingTaskSkipped, task: PendingTask) {
}
override fun taskComplete(success: Boolean, task: PendingTask, rescheduled: Boolean) {
override fun taskComplete(success: Boolean, task: PendingTask) {
Handler().postDelayed({
refreshListOfTasks()
}, 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PendingStatusTextView : TextView, PendingTaskStatusListener {
setTextColor(ContextCompat.getColor(mContext, android.R.color.holo_blue_dark))
}

override fun complete(taskId: Long, successful: Boolean, rescheduled: Boolean) {
override fun complete(taskId: Long, successful: Boolean) {
text = if (successful) "Success!" else "Failed!"
setTextColor(ContextCompat.getColor(mContext, if (successful) android.R.color.holo_green_dark else android.R.color.holo_orange_dark))
}
Expand Down
7 changes: 7 additions & 0 deletions docs/wendy/alltypes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ <h3>All Types</h3>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy.types/-run-all-tasks-filter/index.html">com.levibostian.wendy.types.RunAllTasksFilter</a></td>
<td>
<p>Filter the Wendy task runner to only run <a href="../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a>s with the following options.</p>
</td>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy.listeners/-task-runner-listener/index.html">com.levibostian.wendy.listeners.TaskRunnerListener</a></td>
<td>
<p>Listen to status updates from the Wendy task runner. You will get notified about the status of the task runner as well as general task updates on all of the tasks that it runs.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<a href="../../index.html">wendy</a>&nbsp;/&nbsp;<a href="../index.html">com.levibostian.wendy.listeners</a>&nbsp;/&nbsp;<a href="index.html">PendingTaskStatusListener</a>&nbsp;/&nbsp;<a href="./complete.html">complete</a><br/>
<br/>
<h1>complete</h1>
<a name="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)"></a>
<code><span class="identifier">@UiThread</span> <span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">complete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/taskId">taskId</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html"><span class="identifier">Long</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/successful">successful</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/rescheduled">rescheduled</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<a name="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean)"></a>
<code><span class="identifier">@UiThread</span> <span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">complete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean)/taskId">taskId</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html"><span class="identifier">Long</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean)/successful">successful</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<p>The task runner is done running the <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a>. The task was either successful or not.</p>
<h3>Parameters</h3>
<p><a name="taskId"></a>
<code>taskId</code> - The taskId of the <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> that just ran.</p>
<p><a name="successful"></a>
<code>successful</code> - Indicates if the running of the <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> was successful or not.</p>
<p><a name="rescheduled"></a>
<code>rescheduled</code> - If the task failed but should run again, the task is rescheduled to run again in the future.</p>
</BODY>
</HTML>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h3>Functions</h3>
<p><a href="complete.html">complete</a></p>
</td>
<td>
<code><span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">complete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/taskId">taskId</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html"><span class="identifier">Long</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/successful">successful</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean, kotlin.Boolean)/rescheduled">rescheduled</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<code><span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">complete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean)/taskId">taskId</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html"><span class="identifier">Long</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.PendingTaskStatusListener$complete(kotlin.Long, kotlin.Boolean)/successful">successful</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<p>The task runner is done running the <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a>. The task was either successful or not.</p>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h3>Functions</h3>
<p><a href="task-complete.html">taskComplete</a></p>
</td>
<td>
<code><span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">taskComplete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/success">success</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/task">task</span><span class="symbol">:</span>&nbsp;<a href="../../com.levibostian.wendy.service/-pending-task/index.html"><span class="identifier">PendingTask</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/rescheduled">rescheduled</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<code><span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">taskComplete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask)/success">success</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask)/task">task</span><span class="symbol">:</span>&nbsp;<a href="../../com.levibostian.wendy.service/-pending-task/index.html"><span class="identifier">PendingTask</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<p>Task has either successfully run or failed it's run by the task runner.</p>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<a href="../../index.html">wendy</a>&nbsp;/&nbsp;<a href="../index.html">com.levibostian.wendy.listeners</a>&nbsp;/&nbsp;<a href="index.html">TaskRunnerListener</a>&nbsp;/&nbsp;<a href="./task-complete.html">taskComplete</a><br/>
<br/>
<h1>taskComplete</h1>
<a name="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)"></a>
<code><span class="identifier">@UiThread</span> <span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">taskComplete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/success">success</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/task">task</span><span class="symbol">:</span>&nbsp;<a href="../../com.levibostian.wendy.service/-pending-task/index.html"><span class="identifier">PendingTask</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask, kotlin.Boolean)/rescheduled">rescheduled</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<a name="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask)"></a>
<code><span class="identifier">@UiThread</span> <span class="keyword">abstract</span> <span class="keyword">fun </span><span class="identifier">taskComplete</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask)/success">success</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html"><span class="identifier">Boolean</span></a><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.listeners.TaskRunnerListener$taskComplete(kotlin.Boolean, com.levibostian.wendy.service.PendingTask)/task">task</span><span class="symbol">:</span>&nbsp;<a href="../../com.levibostian.wendy.service/-pending-task/index.html"><span class="identifier">PendingTask</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<p>Task has either successfully run or failed it's run by the task runner.</p>
<h3>Parameters</h3>
<p><a name="success"></a>
<code>success</code> - Indicates if the task that was run by the task runner was run successfully or not.</p>
<p><a name="task"></a>
<code>task</code> - The <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> that was run.</p>
<p><a name="rescheduled"></a>
<code>rescheduled</code> - If the task failed but should run again, the task is rescheduled to run again in the future.</p>
</BODY>
</HTML>
2 changes: 2 additions & 0 deletions docs/wendy/com.levibostian.wendy.service/-wendy/add-task.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ <h3>Parameters</h3>
<h3>Exceptions</h3>
<p><a name="RuntimeException"></a>
<code>RuntimeException</code> - Wendy will check to make sure that you have remembered to add your argument's <a href="../-pending-task/index.html">PendingTask</a> subclass to your instance of <a href="../-pending-tasks-factory/index.html">PendingTasksFactory</a> when you call this method. If your <a href="../-pending-tasks-factory/index.html">PendingTasksFactory</a> returns null (which probably means that you forgot to include a <a href="../-pending-task/index.html">PendingTask</a>) then an <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-runtime-exception/index.html">RuntimeException</a> will be thrown.</p>
<p><a name="IllegalArgumentException"></a>
<code>IllegalArgumentException</code> - If your <a href="../-pending-task/index.html">PendingTask</a> subclass does not follow the enforced best practice of: All subclasses of a <a href="../-pending-task/index.html">PendingTask</a> must <strong>all</strong> have a groupId or <strong>none</strong> of them have a groupId.</p>
</BODY>
</HTML>
Loading

0 comments on commit 2bfcad9

Please sign in to comment.