generated from GO-SOPT-ANDROID/android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24a8556
commit be5017b
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/android/go/sopt/util/ContextExtension.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.android.go.sopt.util | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
import android.widget.Toast | ||
import com.google.android.material.snackbar.Snackbar | ||
|
||
fun Context.showShortToast(message: String){ | ||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
fun Context.hideKeyboard(view: View){ | ||
val inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
// hideSoftInputFromWindow는 첫번째 인자로 windowToken을 받아야함. windowToken은 View에서 사용? | ||
inputManager.hideSoftInputFromWindow(view.windowToken, 0) | ||
} | ||
|
||
fun Context.showShortSnackbar(view: View, message: String){ | ||
// Snackbar.make는 첫번째 인자로 View를 받아야한다. 그래서 this(context)를 쓰면 에러남 | ||
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.android.go.sopt.util | ||
|
||
import android.view.View | ||
import com.google.android.material.snackbar.Snackbar | ||
|
||
// View 객체를 상속받는 곳에서만 사용 가능~ | ||
//fun View.showShortSnackBar(message: String){ | ||
// Snackbar.make(this, message, Snackbar.LENGTH_SHORT).show() | ||
//} |