This file contains hidden or 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
| fun hideTop() { | |
| window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN | |
| window.setFlags( | |
| WindowManager.LayoutParams.FLAG_FULLSCREEN, | |
| WindowManager.LayoutParams.FLAG_FULLSCREEN) | |
| supportActionBar?.hide() | |
| } |
This file contains hidden or 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
| infix fun Disposable.addTo(autoDisposable: AutoDisposable) = autoDisposable.add(this) |
This file contains hidden or 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
| class AutoDisposable @Inject constructor() : LifecycleObserver { | |
| private lateinit var compositeDisposable: CompositeDisposable | |
| fun bindTo(lifecycle: Lifecycle) { | |
| lifecycle.addObserver(this) | |
| compositeDisposable = CompositeDisposable() | |
| } | |
| fun add(disposable: Disposable) { | |
| if (::compositeDisposable.isInitialized) { |
This file contains hidden or 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
| fun <T> lazyUnsychronized(initializer: () -> T): Lazy<T> = | |
| lazy(LazyThreadSafetyMode.NONE, initializer) |
This file contains hidden or 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
| fun <T : View> AppCompatActivity.bindView(@IdRes idRes: Int): Lazy<T> = | |
| lazyUnsychronized { | |
| findViewById<T>(idRes) | |
| } |
This file contains hidden or 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
| class PopularMoviesActivity : BaseActivity(), PopularMoviesContract.View { | |
| private val tvMainText: TextView by bindView(R.id.mainText) | |
| private val btnMainButton: Button by bindView(R.id.mainButton) | |
| @Inject lateinit var presenter: PopularMoviesPresenter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) |
This file contains hidden or 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
| class PopularMoviesActivity : BaseActivity(), PopularMoviesContract.View { | |
| private val tvMainText: TextView by bindView(R.id.mainText) | |
| private val btnMainButton: Button by bindView(R.id.mainButton) | |
| lateinit var presenter: PopularMoviesPresenter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) |
This file contains hidden or 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
| abstract class BaseActivity: DaggerAppCompatActivity() { | |
| @Inject lateinit var autoDisposable: AutoDisposable | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| autoDisposable.bindTo(this.lifecycle) | |
| } | |
| } |
This file contains hidden or 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
| abstract class BaseActivity : AppCompatActivity() { | |
| // This can be injected with Dagger2 | |
| var autoDisposable = AutoDisposable() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| autoDisposable.bindTo(this.lifecycle) | |
| } | |
| } |
This file contains hidden or 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
| class PopularMoviesPresenter @Inject constructor( | |
| private val model: PopularMoviesModel | |
| ) : PopularMoviesContract.Presenter { | |
| private lateinit var view: PopularMoviesContract.View | |
| override fun attach(view: PopularMoviesContract.View) { | |
| this.view = view | |
| } |