Skip to content

Commit

Permalink
Merge pull request #4 from CATReloaded/m-base
Browse files Browse the repository at this point in the history
Create base classes
  • Loading branch information
IMoHaMeDHaMdYI authored May 16, 2020
2 parents 60070c3 + 3acf75b commit 13ac5aa
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 1 deletion.
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

0 comments on commit 13ac5aa

Please sign in to comment.