-
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.
Merge branch 'feature/50-wtf' into develop
- Loading branch information
Showing
48 changed files
with
908 additions
and
11 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
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
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
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
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
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
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
17 changes: 17 additions & 0 deletions
17
...rtsScorecard/app/src/main/java/nl/entreco/dartsscorecard/di/viewmodel/api/FaqApiModule.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,17 @@ | ||
package nl.entreco.dartsscorecard.di.viewmodel.api | ||
|
||
import com.google.firebase.firestore.FirebaseFirestore | ||
import dagger.Module | ||
import dagger.Provides | ||
import nl.entreco.data.wtf.RemoteWtfRepository | ||
import nl.entreco.domain.common.log.Logger | ||
import nl.entreco.domain.repository.WtfRepository | ||
|
||
@Module | ||
class FaqApiModule { | ||
|
||
@Provides | ||
fun provideRemoteFaqRepository(db: FirebaseFirestore, logger: Logger): WtfRepository { | ||
return RemoteWtfRepository(db, logger) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/di/wtf/WtfComponent.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,12 @@ | ||
package nl.entreco.dartsscorecard.di.wtf | ||
|
||
import dagger.Subcomponent | ||
import nl.entreco.dartsscorecard.wtf.WtfAdapter | ||
import nl.entreco.dartsscorecard.wtf.WtfViewModel | ||
|
||
@WtfScope | ||
@Subcomponent(modules = [(WtfModule::class)]) | ||
interface WtfComponent { | ||
fun viewModel(): WtfViewModel | ||
fun adapter(): WtfAdapter | ||
} |
6 changes: 6 additions & 0 deletions
6
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/di/wtf/WtfModule.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,6 @@ | ||
package nl.entreco.dartsscorecard.di.wtf | ||
|
||
import dagger.Module | ||
|
||
@Module | ||
class WtfModule |
7 changes: 7 additions & 0 deletions
7
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/di/wtf/WtfScope.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 nl.entreco.dartsscorecard.di.wtf | ||
|
||
import javax.inject.Scope | ||
|
||
@Scope | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class WtfScope |
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
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
107 changes: 107 additions & 0 deletions
107
android/DartsScorecard/app/src/main/java/nl/entreco/dartsscorecard/wtf/WtfActivity.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,107 @@ | ||
package nl.entreco.dartsscorecard.wtf | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.databinding.DataBindingUtil | ||
import android.os.Bundle | ||
import android.support.v7.widget.DefaultItemAnimator | ||
import android.support.v7.widget.GridLayoutManager | ||
import android.support.v7.widget.Toolbar | ||
import android.view.LayoutInflater | ||
import android.view.MenuItem | ||
import com.yalantis.jellytoolbar.listener.JellyListener | ||
import nl.entreco.dartsscorecard.R | ||
import nl.entreco.dartsscorecard.base.ViewModelActivity | ||
import nl.entreco.dartsscorecard.databinding.ActivityWtfBinding | ||
import nl.entreco.dartsscorecard.databinding.SearchbarBinding | ||
import nl.entreco.dartsscorecard.di.wtf.WtfComponent | ||
import nl.entreco.dartsscorecard.di.wtf.WtfModule | ||
import android.support.v4.content.ContextCompat | ||
import android.view.WindowManager | ||
import android.view.inputmethod.InputMethodManager | ||
|
||
|
||
class WtfActivity : ViewModelActivity() { | ||
|
||
private lateinit var binding: ActivityWtfBinding | ||
private lateinit var searchBinding: SearchbarBinding | ||
private val component: WtfComponent by componentProvider { it.plus(WtfModule()) } | ||
private val viewModel: WtfViewModel by viewModelProvider { component.viewModel() } | ||
private val adapter: WtfAdapter by lazy { component.adapter() } | ||
|
||
private val jellyListener by lazy { | ||
object : JellyListener() { | ||
override fun onCancelIconClicked() { | ||
val searchField = searchBinding.searchField | ||
if (searchField.text.isEmpty()) { | ||
binding.includeToolbar.toolbar.collapse() | ||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
imm.hideSoftInputFromWindow(searchField.windowToken, 0) | ||
} else { | ||
searchField.text.clear() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
binding = DataBindingUtil.setContentView(this, R.layout.activity_wtf) | ||
binding.viewModel = viewModel | ||
|
||
initJellyBar() | ||
initToolbar(toolbar(binding), R.string.title_wtf) | ||
initRecyclerView(binding) | ||
} | ||
|
||
private fun initJellyBar() { | ||
binding.includeToolbar.toolbar.jellyListener = jellyListener | ||
searchBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.searchbar, null, false) | ||
searchBinding.listener = adapter | ||
binding.includeToolbar.toolbar.contentView = searchBinding.root | ||
} | ||
|
||
private fun initRecyclerView(binding: ActivityWtfBinding) { | ||
val recyclerView = binding.wtfRecyclerView | ||
recyclerView.setHasFixedSize(true) | ||
recyclerView.setItemViewCacheSize(20) | ||
recyclerView.layoutManager = GridLayoutManager(binding.root.context, 1) | ||
recyclerView.itemAnimator = DefaultItemAnimator() | ||
recyclerView.isDrawingCacheEnabled = true | ||
recyclerView.adapter = adapter | ||
} | ||
|
||
private fun toolbar(binding: ActivityWtfBinding): Toolbar { | ||
return binding.includeToolbar.toolbar.toolbar!! | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
viewModel.subscribe(this, adapter) | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
viewModel.unsubscribe(this) | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem?): Boolean { | ||
return when (item?.itemId) { | ||
android.R.id.home -> { | ||
onBackPressed() | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
fun launch(context: Context) { | ||
val intent = Intent(context, WtfActivity::class.java) | ||
context.startActivity(intent) | ||
} | ||
} | ||
} |
Oops, something went wrong.