Skip to content

Commit

Permalink
Merge pull request #33 from levibostian/api-naming
Browse files Browse the repository at this point in the history
Api naming
  • Loading branch information
levibostian authored Apr 6, 2018
2 parents 2fff75e + ca609bf commit e8ab3f4
Show file tree
Hide file tree
Showing 92 changed files with 958 additions and 378 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
15 changes: 6 additions & 9 deletions app/src/main/java/com/levibostian/wendyexample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import android.os.Handler
import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import android.widget.CompoundButton

import com.curiosityio.wendyexample.R
import com.levibostian.wendy.WendyConfig
import com.levibostian.wendy.db.PendingTaskError
import com.levibostian.wendy.listeners.TaskRunnerListener
import com.levibostian.wendy.service.PendingTask
import com.levibostian.wendy.service.PendingTasks
import com.levibostian.wendy.service.Wendy
import com.levibostian.wendy.types.ReasonPendingTaskSkipped
import com.levibostian.wendyexample.extension.closeKeyboard
import kotlinx.android.synthetic.main.activity_main.*
Expand All @@ -34,7 +31,7 @@ class MainActivity : AppCompatActivity(), TaskRunnerListener {
if (activity_main_group_id_edittext.text.isNullOrBlank()) null else activity_main_group_id_edittext.text.toString(),
activity_main_custom_data_edittext.text.toString()
)
PendingTasks.sharedInstance().addTask(pendingTask)
Wendy.sharedInstance().addTask(pendingTask)
closeKeyboard()
}
}
Expand All @@ -45,7 +42,7 @@ class MainActivity : AppCompatActivity(), TaskRunnerListener {
WendyConfig.automaticallyRunTasks = activity_main_automatically_run_tasks_checkbox.isChecked

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

activity_main_tasks_recyclerview.layoutManager = LinearLayoutManager(this)
Expand All @@ -55,13 +52,13 @@ class MainActivity : AppCompatActivity(), TaskRunnerListener {
}

private fun refreshListOfTasks() {
val recyclerViewAdapter = PendingTasksRecyclerViewAdapter(PendingTasks.sharedInstance().getAllTasks())
val recyclerViewAdapter = PendingTasksRecyclerViewAdapter(Wendy.sharedInstance().getAllTasks())
recyclerViewAdapter.listener = object : PendingTasksRecyclerViewAdapter.Listener {
override fun manuallyRunPressed(task: PendingTask) {
PendingTasks.sharedInstance().runTask(task.task_id!!)
Wendy.sharedInstance().runTask(task.taskId!!)
}
override fun resolveErrorPressed(task: PendingTask) {
PendingTasks.shared.resolveError(task.task_id!!)
Wendy.shared.resolveError(task.taskId!!)
}
}
activity_main_tasks_recyclerview.adapter = recyclerViewAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import com.curiosityio.wendyexample.BuildConfig
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import com.levibostian.wendy.service.PendingTasks
import com.levibostian.wendy.service.Wendy
import android.os.Build
import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
import com.curiosityio.wendyexample.R
import com.levibostian.wendyexample.NotificationChannelUtil.Companion.ERROR_OCCURRED_CHANNEL_DESCRIPTION
import com.levibostian.wendyexample.NotificationChannelUtil.Companion.ERROR_OCCURRED_CHANNEL_ID
import com.levibostian.wendyexample.NotificationChannelUtil.Companion.ERROR_OCCURRED_CHANNEL_NAME
Expand All @@ -21,7 +18,7 @@ class MainApplication : Application() {
override fun onCreate() {
super.onCreate()

PendingTasks.init(this, WendyExamplePendingTasksFactory())
Wendy.init(this, WendyExamplePendingTasksFactory())
.debug(BuildConfig.DEBUG)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class NotificationChannelUtil {
companion object {
const val ERROR_OCCURRED_CHANNEL_ID = "ERROR_OCCURRED_CHANNEL_ID"
const val ERROR_OCCURRED_CHANNEL_NAME = "PendingTask errors"
const val ERROR_OCCURRED_CHANNEL_DESCRIPTION = "Recorded errors for PendingTasks"
const val ERROR_OCCURRED_CHANNEL_DESCRIPTION = "Recorded errors for Wendy"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import android.widget.Button
import android.widget.TextView
import com.curiosityio.wendyexample.R
import com.levibostian.wendy.WendyConfig
import com.levibostian.wendy.listeners.PendingTaskStatusListener
import com.levibostian.wendy.service.PendingTask
import com.levibostian.wendy.service.PendingTasks
import com.levibostian.wendy.types.ReasonPendingTaskSkipped
import com.levibostian.wendy.service.Wendy
import java.text.SimpleDateFormat
import java.util.*

Expand Down Expand Up @@ -42,20 +40,20 @@ class PendingTasksRecyclerViewAdapter(val data: List<PendingTask>) : RecyclerVie
override fun onBindViewHolder(holder: PendingTasksRecyclerViewAdapter.ViewHolder, position: Int) {
val adapterItem: PendingTask = data[position]

holder.idTextView.text = String.format("task id: %d", adapterItem.task_id)
holder.dataIdTextView.text = String.format("data id: %s", adapterItem.data_id)
holder.groupIdTextView.text = String.format("group id: %s", adapterItem.group_id)
holder.manuallyRunTextView.text = String.format("manually run: %s", adapterItem.manually_run.toString())
holder.idTextView.text = String.format("task id: %d", adapterItem.taskId)
holder.dataIdTextView.text = String.format("data id: %s", adapterItem.dataId)
holder.groupIdTextView.text = String.format("group id: %s", adapterItem.groupId)
holder.manuallyRunTextView.text = String.format("manually run: %s", adapterItem.manuallyRun.toString())
holder.tagTextView.text = String.format("tag: %s", adapterItem.tag)
holder.createdAtTextView.text = String.format("Created: %s", SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z", Locale.ENGLISH).format(adapterItem.created_at))
holder.createdAtTextView.text = String.format("Created: %s", SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z", Locale.ENGLISH).format(adapterItem.createdAt))

holder.statusTextView.text = "not running"
WendyConfig.addTaskStatusListenerForTask(adapterItem.task_id!!, holder.statusTextView)
WendyConfig.addTaskStatusListenerForTask(adapterItem.taskId!!, holder.statusTextView)

holder.runTaskButton.setOnClickListener {
listener?.manuallyRunPressed(adapterItem)
}
holder.resolveErrorButton.visibility = if (PendingTasks.shared.doesErrorExist(adapterItem.task_id!!)) View.VISIBLE else View.GONE
holder.resolveErrorButton.visibility = if (Wendy.shared.doesErrorExist(adapterItem.taskId!!)) View.VISIBLE else View.GONE
holder.resolveErrorButton.setOnClickListener {
listener?.resolveErrorPressed(adapterItem)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.21'
ext.kotlin_version = '1.2.31'
ext.dokka_version = '0.9.16'
repositories {
jcenter()
Expand Down
16 changes: 8 additions & 8 deletions docs/wendy/alltypes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,9 @@ <h3>All Types</h3>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy.service/-pending-tasks/index.html">com.levibostian.wendy.service.PendingTasks</a></td>
<td>
<p>How you interact with Wendy with <a href="../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> instances you create. Add tasks to Wendy to run, get a list of all the <a href="../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a>s registered to Wendy, etc.</p>
</td>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy.service/-pending-tasks-factory/index.html">com.levibostian.wendy.service.PendingTasksFactory</a></td>
<td>
<p>Wendy requires that you create a subclass of <a href="../com.levibostian.wendy.service/-pending-tasks-factory/index.html">PendingTasksFactory</a> and provide it to Wendy in the <a href="../com.levibostian.wendy.service/-pending-tasks/init.html">PendingTasks.Companion.init</a> call. Do this in your Application's onCreate() call if you can.</p>
<p>Wendy requires that you create a subclass of <a href="../com.levibostian.wendy.service/-pending-tasks-factory/index.html">PendingTasksFactory</a> and provide it to Wendy in the <a href="../com.levibostian.wendy.service/-wendy/init.html">Wendy.Companion.init</a> call. Do this in your Application's onCreate() call if you can.</p>
</td>
</tr>
<tr>
Expand All @@ -66,6 +59,13 @@ <h3>All Types</h3>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy.service/-wendy/index.html">com.levibostian.wendy.service.Wendy</a></td>
<td>
<p>How you interact with Wendy with <a href="../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> instances you create. Add tasks to Wendy to run, get a list of all the <a href="../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a>s registered to Wendy, etc.</p>
</td>
</tr>
<tr>
<td>
<a href="../com.levibostian.wendy/-wendy-config/index.html">com.levibostian.wendy.WendyConfig</a></td>
<td>
<p>Configure Wendy and how it operates.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<br/>
<h1>&lt;init&gt;</h1>
<a name="com.levibostian.wendy.db.PendingTaskError$&lt;init&gt;(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)"></a>
<code><span class="identifier">PendingTaskError</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/id">id</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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/task_id">task_id</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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/created_at">created_at</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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/error_message">error_message</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/error_id">error_id</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span><span class="symbol">)</span></code>
<code><span class="identifier">PendingTaskError</span><span class="symbol">(</span><span class="identifier" id="com.levibostian.wendy.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/id">id</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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/createdAt">createdAt</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.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/errorMessage">errorMessage</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span><span class="symbol">, </span><span class="identifier" id="com.levibostian.wendy.db.PendingTaskError$<init>(kotlin.Long, kotlin.Long, kotlin.Long, kotlin.String, kotlin.String)/errorId">errorId</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span><span class="symbol">)</span></code>
<p>Use this class to save a <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> instance to a SQLite database. <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> is designed to be a developer facing object.</p>
<p>Wendy used to use <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> to save to a SQLite database directly but there were limitions to what I could and could not do with the class once I decided to use it as a SQLite model (example: I could not even make it abstract). So, I decided to create another class to convert a <a href="../../com.levibostian.wendy.service/-pending-task/index.html">PendingTask</a> to and save that data to a SQLite database.</p>
</BODY>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<HTML>
<HEAD>
<meta charset="UTF-8">
<title>PendingTaskError.createdAt - wendy</title>
<link rel="stylesheet" href="../../../style.css">
</HEAD>
<BODY>
<a href="../../index.html">wendy</a>&nbsp;/&nbsp;<a href="../index.html">com.levibostian.wendy.db</a>&nbsp;/&nbsp;<a href="index.html">PendingTaskError</a>&nbsp;/&nbsp;<a href="./created-at.html">createdAt</a><br/>
<br/>
<h1>createdAt</h1>
<a name="com.levibostian.wendy.db.PendingTaskError$createdAt"></a>
<code><span class="keyword">var </span><span class="identifier">createdAt</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html"><span class="identifier">Long</span></a></code>
<p>The Date your error was recorded in the Wendy database.</p>
<h3>Property</h3>
<p><a name="createdAt"></a>
<code>createdAt</code> - The Date your error was recorded in the Wendy database.</p>
</BODY>
</HTML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<HTML>
<HEAD>
<meta charset="UTF-8">
<title>PendingTaskError.errorId - wendy</title>
<link rel="stylesheet" href="../../../style.css">
</HEAD>
<BODY>
<a href="../../index.html">wendy</a>&nbsp;/&nbsp;<a href="../index.html">com.levibostian.wendy.db</a>&nbsp;/&nbsp;<a href="index.html">PendingTaskError</a>&nbsp;/&nbsp;<a href="./error-id.html">errorId</a><br/>
<br/>
<h1>errorId</h1>
<a name="com.levibostian.wendy.db.PendingTaskError$errorId"></a>
<code><span class="keyword">var </span><span class="identifier">errorId</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span></code>
<p>The identifier you, the developer, use to determine what type of error was caused and how to fix it.</p>
<h3>Property</h3>
<p><a name="errorId"></a>
<code>errorId</code> - The identifier you, the developer, use to determine what type of error was caused and how to fix it.</p>
</BODY>
</HTML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<HTML>
<HEAD>
<meta charset="UTF-8">
<title>PendingTaskError.errorMessage - wendy</title>
<link rel="stylesheet" href="../../../style.css">
</HEAD>
<BODY>
<a href="../../index.html">wendy</a>&nbsp;/&nbsp;<a href="../index.html">com.levibostian.wendy.db</a>&nbsp;/&nbsp;<a href="index.html">PendingTaskError</a>&nbsp;/&nbsp;<a href="./error-message.html">errorMessage</a><br/>
<br/>
<h1>errorMessage</h1>
<a name="com.levibostian.wendy.db.PendingTaskError$errorMessage"></a>
<code><span class="keyword">var </span><span class="identifier">errorMessage</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">?</span></code>
<p>The human readable error message you may use to show to the end user describing the error.</p>
<h3>Property</h3>
<p><a name="errorMessage"></a>
<code>errorMessage</code> - The human readable error message you may use to show to the end user describing the error.</p>
</BODY>
</HTML>
Loading

0 comments on commit e8ab3f4

Please sign in to comment.