-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7f6fdb5
Showing
44 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
|
||
|
||
.DS_Store | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Intellij | ||
*.iml | ||
.idea/* | ||
|
||
# Keystore files | ||
*.jks | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
apply from: "$rootDir/dependencies.gradle" | ||
apply from: "$rootDir/configuration.gradle" | ||
|
||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-kapt' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
def versionMajor = 0 | ||
def versionMinor = 0 | ||
def versionPatch = 1 | ||
def versionBuild = 0 | ||
|
||
android { | ||
compileSdkVersion configuration.compileSdkVersion | ||
buildToolsVersion configuration.buildToolsVersion | ||
|
||
defaultConfig { | ||
applicationId "bipin.com.android.arch" | ||
|
||
minSdkVersion configuration.minSdkVersion | ||
targetSdkVersion configuration.targetSdkVersion | ||
|
||
versionCode versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild | ||
versionName "$versionMajor.$versionMinor.$versionPatch" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
dataBinding { | ||
enabled = true | ||
} | ||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation libraries.androidSupport.appCompat | ||
implementation libraries.androidSupport.constraintLayout | ||
implementation libraries.androidSupport.cardView | ||
implementation libraries.androidSupport.design | ||
implementation libraries.kotlin.stdlib | ||
implementation libraries.timber | ||
|
||
implementation libraries.rxAndroid | ||
implementation libraries.rxBinding.platform | ||
implementation libraries.rxJava | ||
implementation libraries.gson | ||
implementation libraries.okHttp | ||
implementation libraries.retrofit | ||
|
||
implementation libraries.dagger.dagger | ||
implementation libraries.dagger.support | ||
kapt libraries.dagger.processor | ||
kapt libraries.dagger.compiler | ||
|
||
implementation libraries.lifeCycle | ||
implementation libraries.materialValue | ||
|
||
implementation libraries.glide.glide | ||
kapt libraries.glide.compiler | ||
|
||
implementation libraries.epoxy.epoxy | ||
implementation libraries.epoxy.databinding | ||
kapt libraries.epoxy.processor | ||
|
||
implementation libraries.butterknife.butterknife | ||
kapt libraries.butterknife.compiler | ||
|
||
implementation libraries.rxKotlin | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/bipin/com/android/arch/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package bipin.com.android.arch | ||
|
||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.runner.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getTargetContext() | ||
assertEquals("bipin.com.android.arch", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="bipin.com.android.arch" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
android:name=".App" | ||
> | ||
<activity android:name=".ui.main.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package bipin.com.android.arch | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import bipin.com.android.arch.di.component.DaggerAppComponent | ||
import dagger.android.DispatchingAndroidInjector | ||
import dagger.android.HasActivityInjector | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Bipin Vayalu on 25/07/18. | ||
*/ | ||
|
||
class App: Application(), HasActivityInjector { | ||
|
||
@Inject | ||
lateinit var activityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity> | ||
|
||
override fun activityInjector() = activityDispatchingAndroidInjector | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) | ||
DaggerAppComponent.builder().application(this).build().inject(this) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/kotlin/bipin/com/android/arch/base/AutoClearedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package bipin.com.android.arch.base | ||
|
||
import android.support.v4.app.Fragment | ||
import android.support.v4.app.FragmentManager | ||
|
||
class AutoClearedValue<out T>(fragment: Fragment, private var value: T?) { | ||
|
||
init { | ||
val fragmentManager = fragment.fragmentManager | ||
fragmentManager!!.registerFragmentLifecycleCallbacks( | ||
object : FragmentManager.FragmentLifecycleCallbacks() { | ||
override fun onFragmentViewDestroyed(fm: FragmentManager?, f: Fragment?) { | ||
if (f === fragment) { | ||
this@AutoClearedValue.value = null | ||
fragmentManager.unregisterFragmentLifecycleCallbacks(this) | ||
} | ||
} | ||
}, false) | ||
} | ||
|
||
fun get(): T? { | ||
return value | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/kotlin/bipin/com/android/arch/base/BaseActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package bipin.com.android.arch.base | ||
|
||
import android.os.Bundle | ||
import android.support.annotation.CallSuper | ||
import android.support.v4.app.Fragment | ||
import android.support.v4.app.FragmentManager | ||
import android.support.v7.app.AppCompatActivity | ||
import bipin.com.android.arch.R | ||
import dagger.android.AndroidInjection | ||
import dagger.android.AndroidInjector | ||
import dagger.android.DispatchingAndroidInjector | ||
import dagger.android.support.HasSupportFragmentInjector | ||
import javax.inject.Inject | ||
|
||
|
||
|
||
abstract class BaseActivity : AppCompatActivity(), HasSupportFragmentInjector { | ||
|
||
override fun supportFragmentInjector(): AndroidInjector<Fragment> { | ||
return dispatchingAndroidInjector | ||
} | ||
|
||
@Inject | ||
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment> | ||
|
||
|
||
|
||
abstract fun layoutId(): Int | ||
|
||
@CallSuper | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
AndroidInjection.inject(this) | ||
setContentView(layoutId()) | ||
} | ||
|
||
fun addFragment(supportFragmentManager: FragmentManager, fragment: Fragment) { | ||
val fragmentTransaction = supportFragmentManager.beginTransaction() | ||
fragmentTransaction.add(R.id.container, fragment, fragment.javaClass.name) | ||
fragmentTransaction.commitAllowingStateLoss() | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/kotlin/bipin/com/android/arch/base/BaseBindingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package bipin.com.android.arch.base | ||
|
||
import android.databinding.DataBindingUtil | ||
import android.databinding.ViewDataBinding | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
||
abstract class BaseBindingFragment<B : ViewDataBinding> : BaseFragment() { | ||
|
||
private var _binding: AutoClearedValue<B>? = null | ||
val binding: AutoClearedValue<B> | ||
get() = _binding!! | ||
|
||
final override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
return inflateView(inflater, container, savedInstanceState) | ||
} | ||
|
||
/** | ||
* Use this if your subclass requires to have some sort of hooks into the inflation process of the view | ||
*/ | ||
open fun inflateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
val databinding: B = DataBindingUtil.inflate(inflater, layoutId(), container, false)!! | ||
_binding = AutoClearedValue(this, databinding) | ||
initializeBinding(databinding) | ||
return databinding.root | ||
} | ||
|
||
/** | ||
* Used to not forget to initialize the binding | ||
*/ | ||
abstract fun initializeBinding(binding: B) | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/kotlin/bipin/com/android/arch/base/BaseFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package bipin.com.android.arch.base | ||
|
||
import android.arch.lifecycle.ViewModelProvider | ||
import android.os.Bundle | ||
import android.support.annotation.CallSuper | ||
import android.support.v4.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import bipin.com.android.arch.base.BaseActivity | ||
import dagger.android.support.AndroidSupportInjection | ||
import javax.inject.Inject | ||
|
||
abstract class BaseFragment : Fragment() { | ||
|
||
@Inject | ||
lateinit var viewModelFactory: ViewModelProvider.Factory | ||
|
||
fun getBaseActivity(): BaseActivity { | ||
return activity as BaseActivity | ||
} | ||
|
||
@CallSuper | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
AndroidSupportInjection.inject(this) | ||
retainInstance = true | ||
setHasOptionsMenu(true) | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
return container?.inflate(layoutId()) | ||
} | ||
|
||
abstract fun layoutId(): Int | ||
} | ||
|
||
fun android.view.ViewGroup.inflate(layoutId: Int): android.view.View { | ||
return android.view.LayoutInflater.from(context).inflate(layoutId, this, false) | ||
} |
Oops, something went wrong.