Skip to content

Commit

Permalink
updated onVMMessage, removed reset to portraitOrientation
Browse files Browse the repository at this point in the history
  • Loading branch information
Luteoos committed Mar 13, 2019
1 parent 139a3df commit ccb59f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ abstract class BaseActivityMVVM<T: BaseViewModel> : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
hideKeyboard()
setPortraitOrientation(true)
setContentView(getLayoutID())
}

Expand All @@ -35,7 +34,9 @@ abstract class BaseActivityMVVM<T: BaseViewModel> : AppCompatActivity() {
/**
* override it to handle message from ViewModel
*/
abstract fun onVMMessage(msg: String?)
open fun onVMMessage(msg: String?){

}

override fun onBackPressed() {
hideKeyboard()
Expand All @@ -51,14 +52,15 @@ abstract class BaseActivityMVVM<T: BaseViewModel> : AppCompatActivity() {
viewModel.detachDisposable()
super.onDestroy()
}
protected fun setPortraitOrientation(isPortrait: Boolean) {

fun setPortraitOrientation(isPortrait: Boolean) {
when(isPortrait){
true -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
false -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
}
}

protected fun hideKeyboard(){
fun hideKeyboard(){
if(this.currentFocus != null){
val inputMng = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMng.hideSoftInputFromWindow(this.currentFocus!!.windowToken, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ abstract class BaseFragmentMVVM<T: BaseViewModel> : Fragment(){
/**
* override it to handle message from ViewModel
*/
abstract fun onVMMessage(msg: String?)
open fun onVMMessage(msg: String?){

}

override fun onStop() {
super.onStop()
Expand All @@ -45,7 +47,7 @@ abstract class BaseFragmentMVVM<T: BaseViewModel> : Fragment(){
viewModel.detachDisposable()
}

protected fun hideKeyboard(){
fun hideKeyboard(){
if(activity!!.currentFocus != null){
val inputMng = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMng.hideSoftInputFromWindow(activity!!.currentFocus!!.windowToken, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class BaseFragmentMVVMWithoutVM : Fragment() {
return inflater.inflate(getLayoutID(), container, false)
}

protected fun hideKeyboard(){
fun hideKeyboard(){
if(activity!!.currentFocus != null){
val inputMng = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMng.hideSoftInputFromWindow(activity!!.currentFocus!!.windowToken, 0)
Expand Down

0 comments on commit ccb59f9

Please sign in to comment.