-
Notifications
You must be signed in to change notification settings - Fork 1
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
Guillaume M
committed
Jun 18, 2019
1 parent
145fed1
commit fd544d5
Showing
12 changed files
with
229 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 @@ | ||
/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,24 @@ | ||
apply plugin: 'com.android.dynamic-feature' | ||
|
||
apply plugin: 'kotlin-platform-android' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-kapt' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
apply from: '../config_module.gradle' | ||
apply from: '../base_dependencies.gradle' | ||
apply from: '../test_dependencies.gradle' | ||
|
||
android { | ||
lintOptions { | ||
lintConfig file(project.rootDir.path + "/feed/lint-rules.xml") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':app') | ||
implementation project(':core') | ||
|
||
kapt "com.google.dagger:dagger-compiler:$dagger_version" | ||
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version" | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<lint> | ||
|
||
</lint> |
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,22 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:dist="http://schemas.android.com/apk/distribution" | ||
package="io.freshdroid.mymonzo.feed"> | ||
|
||
<dist:module | ||
dist:onDemand="false" | ||
dist:instant="false" | ||
dist:title="@string/feature_name_feed"> | ||
<dist:fusing dist:include="true"/> | ||
</dist:module> | ||
|
||
<application | ||
android:name="io.freshdroid.mymonzo.MyMonzoApplication" | ||
android:supportsRtl="true" | ||
tools:ignore="AllowBackup,GoogleAppIndexingWarning,MissingApplicationIcon"> | ||
|
||
|
||
</application> | ||
|
||
</manifest> | ||
|
9 changes: 9 additions & 0 deletions
9
feed/src/main/java/io/freshdroid/mymonzo/feed/FeedEnvironment.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,9 @@ | ||
package io.freshdroid.mymonzo.feed | ||
|
||
import io.freshdroid.core.user.CurrentUserType | ||
import io.reactivex.Scheduler | ||
|
||
data class FeedEnvironment( | ||
val currentUser: CurrentUserType, | ||
val scheduler: Scheduler | ||
) |
16 changes: 16 additions & 0 deletions
16
feed/src/main/java/io/freshdroid/mymonzo/feed/di/FeedComponent.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,16 @@ | ||
package io.freshdroid.mymonzo.feed.di | ||
|
||
import dagger.Component | ||
import io.freshdroid.core.di.CoreComponent | ||
import io.freshdroid.mymonzo.feed.FeedEnvironment | ||
|
||
@FeedScope | ||
@Component( | ||
dependencies = [CoreComponent::class], | ||
modules = [FeedModule::class] | ||
) | ||
interface FeedComponent { | ||
|
||
fun environment(): FeedEnvironment | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
feed/src/main/java/io/freshdroid/mymonzo/feed/di/FeedComponentManager.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,22 @@ | ||
package io.freshdroid.mymonzo.feed.di | ||
|
||
import io.freshdroid.core.di.CoreComponent | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
object FeedComponentManager { | ||
|
||
private var splashScreenComponent: FeedComponent? = null | ||
|
||
fun feedComponent(coreComponent: CoreComponent): FeedComponent { | ||
if (splashScreenComponent == null) | ||
splashScreenComponent = DaggerFeedComponent.builder().coreComponent(coreComponent).build() | ||
return splashScreenComponent as FeedComponent | ||
} | ||
|
||
fun destroyFeedComponent() { | ||
splashScreenComponent = null | ||
} | ||
|
||
|
||
} |
24 changes: 24 additions & 0 deletions
24
feed/src/main/java/io/freshdroid/mymonzo/feed/di/FeedModule.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 io.freshdroid.mymonzo.feed.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import io.freshdroid.core.user.CurrentUserType | ||
import io.freshdroid.mymonzo.feed.FeedEnvironment | ||
import io.reactivex.Scheduler | ||
|
||
@Module | ||
class FeedModule { | ||
|
||
@Provides | ||
@FeedScope | ||
fun provideFeedEnvironment( | ||
currentUser: CurrentUserType, | ||
scheduler: Scheduler | ||
): FeedEnvironment { | ||
return FeedEnvironment( | ||
currentUser, | ||
scheduler | ||
) | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
feed/src/main/java/io/freshdroid/mymonzo/feed/di/FeedScope.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,7 @@ | ||
package io.freshdroid.mymonzo.feed.di | ||
|
||
import javax.inject.Scope | ||
|
||
@Scope | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class FeedScope |
28 changes: 28 additions & 0 deletions
28
feed/src/main/java/io/freshdroid/mymonzo/feed/viewmodels/FeedFragmentViewModel.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,28 @@ | ||
package io.freshdroid.mymonzo.feed.viewmodels | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider | ||
import io.freshdroid.core.viewmodel.FragmentViewModel | ||
import io.freshdroid.mymonzo.feed.FeedEnvironment | ||
|
||
class FeedFragmentViewModel( | ||
environment: FeedEnvironment, | ||
scopeProvider: AndroidLifecycleScopeProvider | ||
) : FragmentViewModel() { | ||
|
||
init { | ||
|
||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
class Factory( | ||
private val environment: FeedEnvironment, | ||
private val scopeProvider: AndroidLifecycleScopeProvider | ||
) : ViewModelProvider.Factory { | ||
override fun <T : ViewModel?> create(modelClass: Class<T>): T { | ||
return FeedFragmentViewModel(environment, scopeProvider) as T | ||
} | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
feed/src/main/java/io/freshdroid/mymonzo/feed/views/FeedFragment.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,39 @@ | ||
package io.freshdroid.mymonzo.feed.views | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.lifecycle.ViewModelProviders | ||
import io.freshdroid.core.ui.BaseFragment | ||
import io.freshdroid.mymonzo.coreComponent | ||
import io.freshdroid.mymonzo.feed.R | ||
import io.freshdroid.mymonzo.feed.di.FeedComponentManager | ||
import io.freshdroid.mymonzo.feed.viewmodels.FeedFragmentViewModel | ||
|
||
class FeedFragment : BaseFragment() { | ||
|
||
private val component by lazy { | ||
FeedComponentManager.feedComponent(coreComponent()) | ||
} | ||
private val viewModelFactory by lazy { | ||
FeedFragmentViewModel.Factory(component.environment(), scopeProvider) | ||
} | ||
private val viewModel by lazy { | ||
ViewModelProviders.of(this, viewModelFactory).get(FeedFragmentViewModel::class.java) | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
super.onCreateView(inflater, container, savedInstanceState) | ||
return inflater.inflate(R.layout.fragment_feed, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
|
||
|
||
viewModel.arguments(arguments) | ||
} | ||
|
||
} |
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,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:layout_marginTop="@dimen/margin_regular_x2" | ||
android:layout_marginStart="@dimen/margin_regular" | ||
android:layout_marginEnd="@dimen/margin_regular" | ||
android:text="£2058.99" | ||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline4" | ||
android:textStyle="bold" | ||
android:textColor="@color/colorPrimary"/> | ||
|
||
<TextView android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/margin_tiny" | ||
android:layout_marginEnd="@dimen/margin_regular" | ||
android:layout_marginStart="@dimen/margin_regular" | ||
android:gravity="center" | ||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" | ||
android:textColor="@color/colorPrimaryLight" | ||
android:text="Balance now"/> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="@dimen/margin_regular_x2"/> | ||
|
||
</LinearLayout> |