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 handles when the user has said his/her speciality preference. | |
* This intent can be reached either from 'cases' intent (cases-followup context), | |
* when the speciality preference hasn't been mentioned and assistant asks for it. | |
* Or, when the user says 'Change my speciality preference'. | |
* | |
* In the first case, 'cases-followup' context has exhausted only 1 lifespan until now, | |
* i.e., in answering "Yes" for the question "Would you like us to save your preference?". | |
* So, when 'cases-followup' context exists, it means that it has come from the initial | |
* intent of "Latest 10 cases" and so, we need to proceed with fetching the cases after |
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
const rounds_map = { | |
'primary':{'id':101, 'title':'DailyRounds'}, | |
'cardio':{'id':108, 'title':'Cardiology'}, | |
'ped':{'id':103, 'title':'Pediatric'}, | |
'radio':{'id':104, 'title':'Radiology'}, | |
'anaes':{'id':106, 'title':'Anaesthesia'}, | |
'ent':{'id':112, 'title':'ENT'}, | |
'optha':{'id':120, 'title':'Ophthalmology'}, | |
'ortho':{'id':121, 'title':'Orthopedic'}, | |
'best':{'id':135, 'title':'Best cases'} |
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
class MainPresenter(val service: GithubService) { | |
var view: MainView? = null | |
fun search(searchString: String) { | |
view?.showProgress() | |
service.getRequest(searchString, 0) | |
.subscribeOn(..) | |
.observeOn(..) | |
.doOnSuccess { onSearchResultReceived(it) } |
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
class MainActivity : AppCompatActivity(), MainView { | |
val presenter: MainPresenter by currentScope.inject() | |
val adapter: ResultAdapter by currentScope.inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |
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
class DataObserver<T>() { | |
var value: T? = null | |
set(value) { | |
field = value | |
observer?.invoke(value) | |
} | |
var observer: ((T?) -> Unit)? = null |
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
class MainPresenter(val service: GithubService) { | |
. | |
. | |
val progressVisibilityObserver = DataObserver<Int>() | |
private fun onSearchResultReceived(apiResponse: ApiResponse?) { | |
. | |
. | |
progressVisibilityObserver.value = 0 | |
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
class MainActivity : AppCompatActivity() { | |
val presenter: MainPresenter by currentScope.inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
presenter.progressVisibilityObserver.observe { | |
..do something | |
} |
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
class MainActivity : AppCompatActivity(), MainView { | |
val presenter: MainPresenter by currentScope.inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
.. | |
} | |
override fun doSomething() {..} |
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
class A: AppCompatActivity() { | |
.. | |
fun startB() { | |
.. | |
startActivityForResult(intent, REQ_CODE) | |
} | |
override onActivityResult(intent, reqCode, ..) { |
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
class A: AppCompatActivity() { | |
.. | |
fun startB() { | |
.. | |
startActivityForResult(intent, REQ_CODE) | |
} | |
override onActivityResult(intent, reqCode, ..) { | |
if(reqCode == REQ_CODE) { | |
when(intent.getString("source")) { |