Skip to content

Instantly share code, notes, and snippets.

@waqasakram117
Created February 3, 2020 08:48
Show Gist options
  • Select an option

  • Save waqasakram117/a084cd6a96edc5fd0e95b0e3b87a3a81 to your computer and use it in GitHub Desktop.

Select an option

Save waqasakram117/a084cd6a96edc5fd0e95b0e3b87a3a81 to your computer and use it in GitHub Desktop.
package com.lightbeem.securemessages.common
import android.content.Context
import android.util.Log
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import com.lightbeem.securemessages.BuildConfig
fun Any.showLog(msg: String){
if (BuildConfig.DEBUG){
val trace = Thread.currentThread().stackTrace[6]
Log.i(trace.className,"${trace.methodName}: $msg")
}
}
fun Any.showError(msg: String){
if (BuildConfig.DEBUG){
val trace = Thread.currentThread().stackTrace[3]
Log.e(trace.className,"${trace.methodName}: $msg")
}
}
fun FragmentActivity.hideKeyboard(){
val view = this.currentFocus
view?.let { v ->
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.hideSoftInputFromWindow(v.windowToken, 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment