Last active
November 11, 2017 12:42
Revisions
-
radityagumay revised this gist
Nov 11, 2017 . 2 changed files with 0 additions and 26 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +0,0 @@ -
radityagumay revised this gist
Nov 11, 2017 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ class FooPresenter(private val dataSource: DataSource?) : BasePresenter<FooPresenter.View> { fun push(data: Bar){ dataSource?.push("someKey", data) } fun peek() : Bar { return dataSource?.peek<Bar>("someKey") } } -
radityagumay revised this gist
Nov 11, 2017 . 1 changed file with 41 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ interface DataSourceBase class DataSource { companion object { private var sInstance: DataSource? = null private var LOCK = Any() fun getInstance(): DataSource? { synchronized(LOCK) { if (sInstance == null) { sInstance = DataSource() } } return sInstance } } private var map: WeakHashMap<Any, DataSourceBase> = WeakHashMap() fun <R : DataSourceBase> push(key: Any, data: R?) { data?.let { map.put(key, data) } } @Suppress("UNCHECKED_CAST") fun <R : DataSourceBase> peek(key: Any): R? { return map[key] as? R? } @Suppress("UNCHECKED_CAST") fun <R : DataSourceBase> pop(key: Any): R? { val data = map[key] as R map.remove(key) return data } fun remove(key: Any) { map.remove(key) } } -
radityagumay revised this gist
Nov 11, 2017 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,16 @@ class FooFragment : BaseFragment<FooPresenter.View, FooPresenter>() { companion object { fun newInstance(data: Bar): FooFragment { val fragment = FooFragment() val bundle = Bundle() bundle.putParcelable("bar", data) fragment.arguments = bundle return fragment } } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) presenter.push(arguments.getParcelable<Bar>("bar")) } } -
radityagumay renamed this gist
Nov 11, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
radityagumay created this gist
Nov 11, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ class FooFragment : BaseFragment<FooPresenter.View, FooPresenter>() { }