-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
53 additions
and
28 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
presentation/src/main/java/com/whyranoid/presentation/reusable/SingleToast.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,28 @@ | ||
package com.whyranoid.presentation.reusable | ||
|
||
import android.content.Context | ||
import android.widget.Toast | ||
|
||
object SingleToast { | ||
|
||
private const val DEFAULT_DURATION = 2_000L | ||
private var lastToastInfo: Pair<String, Long>? = null | ||
|
||
fun show( | ||
context: Context, | ||
message: String, | ||
duration: Int = Toast.LENGTH_SHORT | ||
) { | ||
if (lastToastInfo?.first != message) { | ||
lastToastInfo = message to System.currentTimeMillis() | ||
Toast.makeText(context, message, duration).show() | ||
} else { | ||
lastToastInfo?.second?.let {lastToastTime -> | ||
if (System.currentTimeMillis() - lastToastTime > DEFAULT_DURATION) { | ||
lastToastInfo = message to System.currentTimeMillis() | ||
Toast.makeText(context, message, duration).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
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 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 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 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