-
Notifications
You must be signed in to change notification settings - Fork 4
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
35 changed files
with
168 additions
and
147 deletions.
There are no files selected for viewing
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
33 changes: 23 additions & 10 deletions
33
app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/AppCompatActivityExt.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 |
---|---|---|
@@ -1,21 +1,34 @@ | ||
package com.sedsoftware.yaptalker.presentation.extensions | ||
|
||
import android.support.annotation.ColorRes | ||
import android.support.v7.app.AppCompatActivity | ||
import android.widget.Toast | ||
import es.dmoral.toasty.Toasty | ||
import android.widget.TextView | ||
import com.androidadvance.topsnackbar.TSnackbar | ||
import com.sedsoftware.yaptalker.R | ||
|
||
fun AppCompatActivity.toastError(message: String) { | ||
Toasty.error(this, message, Toast.LENGTH_SHORT, true).show() | ||
fun AppCompatActivity.snackError(message: String) { | ||
showTopSnackbar(message, R.color.snackColorError, R.color.snackColorText) | ||
} | ||
|
||
fun AppCompatActivity.toastSuccess(message: String) { | ||
Toasty.success(this, message, Toast.LENGTH_SHORT, true).show() | ||
fun AppCompatActivity.snackSuccess(message: String) { | ||
showTopSnackbar(message, R.color.snackColorSuccess, R.color.snackColorText) | ||
} | ||
|
||
fun AppCompatActivity.toastInfo(message: String) { | ||
Toasty.info(this, message, Toast.LENGTH_SHORT, true).show() | ||
fun AppCompatActivity.snackInfo(message: String) { | ||
showTopSnackbar(message, R.color.snackColorInfo, R.color.snackColorText) | ||
} | ||
|
||
fun AppCompatActivity.toastWarning(message: String) { | ||
Toasty.warning(this, message, Toast.LENGTH_SHORT, true).show() | ||
fun AppCompatActivity.snackWarning(message: String) { | ||
showTopSnackbar(message, R.color.snackColorWarning, R.color.snackColorText) | ||
} | ||
|
||
fun AppCompatActivity.showTopSnackbar(message: String, @ColorRes bgColor: Int, @ColorRes textColor: Int) { | ||
TSnackbar | ||
.make(findViewById(R.id.content_container), message, TSnackbar.LENGTH_SHORT) | ||
.also { snackbar -> snackbar.view.setBackgroundColor(color(bgColor)) } | ||
.also { snackbar -> | ||
(snackbar.view.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text) as? TextView) | ||
?.setTextColor(color(textColor)) | ||
} | ||
.show() | ||
} |
35 changes: 25 additions & 10 deletions
35
app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/FragmentExt.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 |
---|---|---|
@@ -1,21 +1,36 @@ | ||
package com.sedsoftware.yaptalker.presentation.extensions | ||
|
||
import android.support.annotation.ColorRes | ||
import android.support.v4.app.Fragment | ||
import android.widget.Toast | ||
import es.dmoral.toasty.Toasty | ||
import android.widget.TextView | ||
import com.androidadvance.topsnackbar.TSnackbar | ||
import com.sedsoftware.yaptalker.R | ||
|
||
fun Fragment.toastError(message: String) { | ||
context?.let { Toasty.error(it, message, Toast.LENGTH_SHORT, true).show() } | ||
fun Fragment.snackError(message: String) { | ||
showTopSnackbar(message, R.color.snackColorError, R.color.snackColorText) | ||
} | ||
|
||
fun Fragment.toastSuccess(message: String) { | ||
context?.let { Toasty.success(it, message, Toast.LENGTH_SHORT, true).show() } | ||
fun Fragment.snackSuccess(message: String) { | ||
showTopSnackbar(message, R.color.snackColorSuccess, R.color.snackColorText) | ||
} | ||
|
||
fun Fragment.toastInfo(message: String) { | ||
context?.let { Toasty.info(it, message, Toast.LENGTH_SHORT, true).show() } | ||
fun Fragment.snackInfo(message: String) { | ||
showTopSnackbar(message, R.color.snackColorInfo, R.color.snackColorText) | ||
} | ||
|
||
fun Fragment.toastWarning(message: String) { | ||
context?.let { Toasty.warning(it, message, Toast.LENGTH_SHORT, true).show() } | ||
fun Fragment.snackWarning(message: String) { | ||
showTopSnackbar(message, R.color.snackColorWarning, R.color.snackColorText) | ||
} | ||
|
||
fun Fragment.showTopSnackbar(message: String, @ColorRes bgColor: Int, @ColorRes textColor: Int) { | ||
activity?.let { activity -> | ||
TSnackbar | ||
.make(activity.findViewById(R.id.content_container), message, TSnackbar.LENGTH_SHORT) | ||
.also { snackbar -> snackbar.view.setBackgroundColor(activity.color(bgColor)) } | ||
.also { snackbar -> | ||
(snackbar.view.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text) as? TextView) | ||
?.setTextColor(activity.color(textColor)) | ||
} | ||
.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
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
Oops, something went wrong.