Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create base classes #4

Merged
merged 3 commits into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


// coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.0'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cat.reloaded.tasks">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".base.CatApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cat.reloaded.tasks.base

import androidx.appcompat.app.AppCompatActivity

class BaseActivity : AppCompatActivity() {
}
8 changes: 8 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cat.reloaded.tasks.base

import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment

class BaseFragment(@LayoutRes layout: Int) : Fragment(layout) {

}
18 changes: 18 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/BaseViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cat.reloaded.tasks.base

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlin.coroutines.CoroutineContext

abstract class BaseViewModel<VA : ViewAction> : ViewModel(), CoroutineScope {

private val job = SupervisorJob()
override val coroutineContext: CoroutineContext = Dispatchers.IO + job
abstract fun processAction(viewAction: VA)
override fun onCleared() {
job.cancel()
super.onCleared()
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/BaseViewState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cat.reloaded.tasks.base

abstract class BaseViewState
7 changes: 7 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/CatApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cat.reloaded.tasks.base

import android.app.Application

class CatApplication : Application() {

}
3 changes: 3 additions & 0 deletions app/src/main/java/cat/reloaded/tasks/base/ViewAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cat.reloaded.tasks.base

interface ViewAction