Skip to content

Commit

Permalink
Merge pull request konifar#26 from DroidKaigi/create-empty-activity-a…
Browse files Browse the repository at this point in the history
…nd-fragments

Create empty activities and fragments
  • Loading branch information
takahirom authored Dec 29, 2017
2 parents 1669729 + 65949f1 commit 5ce8401
Show file tree
Hide file tree
Showing 58 changed files with 1,220 additions and 153 deletions.
44 changes: 44 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,50 @@
</intent-filter>
</activity>
<activity android:name=".presentation.detail.SessionDetailActivity" />
<activity
android:name=".presentation.map.MapActivity"
android:label="@string/title_activity_map"
android:parentActivityName=".presentation.MainActivity"
android:theme="@style/AppTheme"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="io.github.droidkaigi.confsched2018.presentation.MainActivity"
/>
</activity>
<activity
android:name=".presentation.sponsors.SponsorsActivity"
android:label="@string/title_activity_sponsors"
android:parentActivityName=".presentation.MainActivity"
android:theme="@style/AppTheme"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="io.github.droidkaigi.confsched2018.presentation.MainActivity"
/>
</activity>
<activity
android:name=".presentation.about.AboutThisAppActivity"
android:label="@string/title_activity_about_this_app"
android:parentActivityName=".presentation.MainActivity"
android:theme="@style/AppTheme"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="io.github.droidkaigi.confsched2018.presentation.MainActivity"
/>
</activity>
<activity
android:name=".presentation.settings.SettingsActivity"
android:label="@string/title_activity_settings"
android:parentActivityName=".presentation.MainActivity"
android:theme="@style/AppTheme"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="io.github.droidkaigi.confsched2018.presentation.MainActivity"
/>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Single
import io.reactivex.rxkotlin.Flowables
import io.reactivex.rxkotlin.Singles
import timber.log.Timber
import javax.inject.Inject

Expand Down Expand Up @@ -47,8 +48,8 @@ class SessionDataRepository @Inject constructor(
override val speakers: Flowable<List<Speaker>> =
sessionDatabase.getAllSpeaker()
.map { speakers ->
speakers.map { speaker -> speaker.toSpeaker() }
}
speakers.map { speaker -> speaker.toSpeaker() }
}

override val roomSessions: Flowable<Map<Room, List<Session>>>
= sessions.map { sessionList -> sessionList.groupBy { it.room } }
Expand All @@ -70,6 +71,15 @@ class SessionDataRepository @Inject constructor(
.toCompletable()
}

override fun search(query: String): Single<SearchResult> = Singles.zip(
sessions.map {
it.filter { it.title.contains(query) || it.desc.contains(query) }
}.firstOrError(),
speakers.map {
it.filter { it.name.contains(query) }
}.firstOrError(),
{ sessions: List<Session>, speakers: List<Speaker> -> SearchResult(sessions, speakers) })

companion object {
const val DEBUG = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ interface SessionRepository {

@CheckResult fun refreshSessions(): Completable
@CheckResult fun favorite(session: Session): Single<Boolean>
@CheckResult fun search(query: String): Single<SearchResult>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.droidkaigi.confsched2018.di

import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.github.droidkaigi.confsched2018.presentation.about.AboutThisAppActivity
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity

@Module abstract class AboutThisAppActivityBuilder {
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class, AboutThisAppActivityModule::class])
abstract fun contributeAboutThisAppActivity(): AboutThisAppActivity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.droidkaigi.confsched2018.di

import android.support.v7.app.AppCompatActivity
import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.about.AboutThisAppActivity
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity

@Module interface AboutThisAppActivityModule {
@Binds fun providesAppCompatActivity(activity: AboutThisAppActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import javax.inject.Singleton
NetworkModule::class,
DatabaseModule::class,
MainActivityBuilder::class,
MapActivityBuilder::class,
AboutThisAppActivityBuilder::class,
SettingsActivityBuilder::class,
SponsorsActivityBuilder::class,
SessionDetailActivityBuilder::class
])
interface AppComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ package io.github.droidkaigi.confsched2018.di

import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.github.droidkaigi.confsched2018.presentation.detail.DetailFragment
import io.github.droidkaigi.confsched2018.presentation.about.AboutThisAppFragment
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailFragment
import io.github.droidkaigi.confsched2018.presentation.favorite.FavoriteSessionsFragment
import io.github.droidkaigi.confsched2018.presentation.feed.FeedFragment
import io.github.droidkaigi.confsched2018.presentation.map.MapFragment
import io.github.droidkaigi.confsched2018.presentation.search.SearchFragment
import io.github.droidkaigi.confsched2018.presentation.search.SearchSessionFragment
import io.github.droidkaigi.confsched2018.presentation.search.SearchSessionsFragment
import io.github.droidkaigi.confsched2018.presentation.search.SearchSpeakersFragment
import io.github.droidkaigi.confsched2018.presentation.search.SearchTopicsFragment
import io.github.droidkaigi.confsched2018.presentation.sessions.AllSessionsFragment
import io.github.droidkaigi.confsched2018.presentation.sessions.RoomSessionsFragment
import io.github.droidkaigi.confsched2018.presentation.sessions.SessionsFragment
import io.github.droidkaigi.confsched2018.presentation.settings.SettingsFragment
import io.github.droidkaigi.confsched2018.presentation.sponsors.SponsorsFragment

@Module abstract class FragmentBuildersModule {
@ContributesAndroidInjector abstract fun contributeSessionsFragment(): SessionsFragment
Expand All @@ -20,11 +26,23 @@ import io.github.droidkaigi.confsched2018.presentation.sessions.SessionsFragment

@ContributesAndroidInjector abstract fun contributeSearchFragment(): SearchFragment

@ContributesAndroidInjector abstract fun contributeSearchSessionFragment(): SearchSessionFragment
@ContributesAndroidInjector abstract fun contributeSearchSessionsFragment(): SearchSessionsFragment

@ContributesAndroidInjector abstract fun contributeSearchTopicsFragment(): SearchTopicsFragment

@ContributesAndroidInjector abstract fun contributeSearchSpeakersFragment(): SearchSpeakersFragment

@ContributesAndroidInjector abstract fun contributeFavoriteSessionsFragment(): FavoriteSessionsFragment

@ContributesAndroidInjector abstract fun contributeFeedFragment(): FeedFragment

@ContributesAndroidInjector abstract fun contributeDetailFragment(): DetailFragment
@ContributesAndroidInjector abstract fun contributeDetailFragment(): SessionDetailFragment

@ContributesAndroidInjector abstract fun contributeMapFragment(): MapFragment

@ContributesAndroidInjector abstract fun contributeAboutThisAppFragment(): AboutThisAppFragment

@ContributesAndroidInjector abstract fun contributeSponsorsFragment(): SponsorsFragment

@ContributesAndroidInjector abstract fun contributeSettingsFragment(): SettingsFragment
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.MainActivity

@Module
interface MainActivityModule {
@Module interface MainActivityModule {
@Binds fun providesAppCompatActivity(mainActivity: MainActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.droidkaigi.confsched2018.di

import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.map.MapActivity

@Module abstract class MapActivityBuilder {
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class, MapActivityModule::class])
abstract fun contributeMapActivity(): MapActivity

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.droidkaigi.confsched2018.di

import android.support.v7.app.AppCompatActivity
import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.map.MapActivity

@Module interface MapActivityModule {
@Binds fun providesAppCompatActivity(activity: MapActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity

@Module
interface SessionDetailActivityModule {
@Binds
fun providesAppCompatActivity(sessionDetailActivity: SessionDetailActivity): AppCompatActivity
@Module interface SessionDetailActivityModule {
@Binds fun providesAppCompatActivity(activity: SessionDetailActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.droidkaigi.confsched2018.di

import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.settings.SettingsActivity

@Module abstract class SettingsActivityBuilder {
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class, SettingsActivityModule::class])
abstract fun contributeSettingsActivity(): SettingsActivity

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.droidkaigi.confsched2018.di

import android.support.v7.app.AppCompatActivity
import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.settings.SettingsActivity

@Module interface SettingsActivityModule {
@Binds fun providesAppCompatActivity(activity: SettingsActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.droidkaigi.confsched2018.di

import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.sponsors.SponsorsActivity

@Module abstract class SponsorsActivityBuilder {
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class, SponsorsActivityModule::class])
abstract fun contributeSponsorsActivity(): SponsorsActivity

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.droidkaigi.confsched2018.di

import android.support.v7.app.AppCompatActivity
import dagger.Binds
import dagger.Module
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailActivity
import io.github.droidkaigi.confsched2018.presentation.sponsors.SponsorsActivity

@Module interface SponsorsActivityModule {
@Binds fun providesAppCompatActivity(activity: SponsorsActivity): AppCompatActivity
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import dagger.multibindings.IntoMap
import io.github.droidkaigi.confsched2018.presentation.detail.SessionDetailViewModel
import io.github.droidkaigi.confsched2018.presentation.favorite.FavoriteSessionsViewModel
import io.github.droidkaigi.confsched2018.presentation.feed.FeedViewModel
import io.github.droidkaigi.confsched2018.presentation.search.SearchSessionViewModel
import io.github.droidkaigi.confsched2018.presentation.search.SearchSessionsViewModel
import io.github.droidkaigi.confsched2018.presentation.search.SearchSpeakersViewModel
import io.github.droidkaigi.confsched2018.presentation.search.SearchTopicsViewModel
import io.github.droidkaigi.confsched2018.presentation.search.SearchViewModel
import io.github.droidkaigi.confsched2018.presentation.sessions.AllSessionsViewModel
import io.github.droidkaigi.confsched2018.presentation.sessions.RoomSessionsViewModel
Expand All @@ -32,8 +34,8 @@ import io.github.droidkaigi.confsched2018.presentation.sessions.SessionsViewMode
abstract fun bindRoomSessionsViewModel(roomSessionsViewModel: RoomSessionsViewModel): ViewModel

@Binds @IntoMap
@ViewModelKey(SearchSessionViewModel::class)
abstract fun bindSearchSessionViewModel(searchSessionViewModel: SearchSessionViewModel): ViewModel
@ViewModelKey(SearchSessionsViewModel::class)
abstract fun bindSearchSessionViewModel(searchSessionsViewModel: SearchSessionsViewModel): ViewModel


@Binds @IntoMap
Expand All @@ -48,5 +50,14 @@ import io.github.droidkaigi.confsched2018.presentation.sessions.SessionsViewMode
@ViewModelKey(SessionDetailViewModel::class)
abstract fun bindSessionDetailViewModel(sessionDetailViewModel: SessionDetailViewModel): ViewModel

@Binds @IntoMap
@ViewModelKey(SearchTopicsViewModel::class)
abstract fun bindSearchTopicsViewModel(sessionDetailViewModel: SearchTopicsViewModel): ViewModel

@Binds @IntoMap
@ViewModelKey(SearchSpeakersViewModel::class)
abstract fun bindSearchSpeakersViewModel(sessionDetailViewModel: SearchSpeakersViewModel): ViewModel


@Binds abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class MainActivity : AppCompatActivity(), HasSupportFragmentInjector {
actionBarDrawerToggle.syncState()
binding.drawer.setNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.nav_item_info -> {
}
else -> {
}
R.id.nav_item_map -> navigationController.navigateToMapActivity()
R.id.nav_item_setting -> navigationController.navigateToSettingsActivity()
R.id.nav_item_sponsor -> navigationController.navigateToSponsorsActivity()
R.id.nav_item_info -> navigationController.navigateToAboutThisAppActivity()
}
true
}
Expand Down
Loading

0 comments on commit 5ce8401

Please sign in to comment.