<commit_before># mobi.tjorn.content.loaders

### What is this?
Almost a drop-in replacement for [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html).

### Introduction
Many online guides, like [Authorizing with Google for REST APIs](https://developers.google.com/android/guides/http-auth#extend_asynctask_to_get_the_auth_token), use [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html) 
to perform background operations.
But the problem with [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html) is that they are not
integrated with [Activity Lifecycle](http://developer.android.com/guide/components/activities.html#Lifecycle).  
Developers have to write error-prone code to handle Activity pausing, stopping, destruction, configuration changes, etc.

[Loaders](http://developer.android.com/guide/components/loaders.html) are integrated with 
[Activity Lifecycle](http://developer.android.com/guide/components/activities.html#Lifecycle), 
but they are not as widely popular as [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html),
except [CursorLoader](http://developer.android.com/reference/android/content/CursorLoader.html).
[Loaders](http://developer.android.com/guide/components/loaders.html) are not as easy to create and use as [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html).
This library attempts to make [Loaders](http://developer.android.com/guide/components/loaders.html) easy to use.

### How to use
1. Subclass one of the Loaders in this library and, optionally, one of the Resutls.
2. In your existing code, move code
  - from [AsyncTask.onPreExecute](http://developer.android.com/reference/android/os/AsyncTask.html#onPreExecute()) to 
    [LoaderCallbacks.onCreateLoader](http://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html#onCreateLoader(int, android.os.Bundle))
  - from [AsyncTask.doInBackground](http://developer.android.com/reference/android/os/AsyncTask.html#doInBackground(Params...)) to<commit_msg>Included Using in Android Studio section.<commit_after># mobi.tjorn.content.loaders

### What is this?
Almost a drop-in replacement for [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html).

### Introduction
Many online guides, like [Authorizing with Google for REST APIs](https://developers.google.com/android/guides/http-auth#extend_asynctask_to_get_the_auth_token), use [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html) 
to perform background operations.
But the problem with [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html) is that they are not
integrated with [Activity Lifecycle](http://developer.android.com/guide/components/activities.html#Lifecycle).  
Developers have to write error-prone code to handle Activity pausing, stopping, destruction, configuration changes, etc.

[Loaders](http://developer.android.com/guide/components/loaders.html) are integrated with 
[Activity Lifecycle](http://developer.android.com/guide/components/activities.html#Lifecycle), 
but they are not as widely popular as [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html),
except [CursorLoader](http://developer.android.com/reference/android/content/CursorLoader.html).
[Loaders](http://developer.android.com/guide/components/loaders.html) are not as easy to create and use as [AsyncTasks](http://developer.android.com/reference/android/os/AsyncTask.html).
This library attempts to make [Loaders](http://developer.android.com/guide/components/loaders.html) easy to use.

### Using in Android Studio / Gradle

```
buildscript {
    repositories {
        jcenter()
    }
}
```

```
dependencies {
    compile 'mobi.tjorn.content:loaders:1.0.0'
}
```

### Migrating from [AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html)s
1. Subclass one of the Loaders in this library and, optionally, one of the Resutls.
2. In your existing code, move code
  - from [AsyncTask.onPreExecute](http://developer.android.com/reference/android/os/AsyncTask.html#onPreExecute()) to 
    [LoaderCallbacks.onCreateLoader](http://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html#onCreateLoader(int, android.os.Bundle))
  - from [AsyncTask.doInBackground](http://developer.android.com/reference/android/os/AsyncTask.html#doInBackground(Params...)) to
{'fraction_non_alphanumeric': 0.13042505592841164, 'fraction_numerical': 0.0015659955257270694, 'mean_word_length': 5.623703703703704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1102910', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1273, 'n_words': 269}