diff --git a/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/utils/ToastCharterUtils.kt b/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/utils/ToastCharterUtils.kt new file mode 100644 index 0000000000..d60f472a45 --- /dev/null +++ b/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/utils/ToastCharterUtils.kt @@ -0,0 +1,21 @@ +package com.mogo.och.bus.passenger.utils + +import android.view.View +import com.mogo.eagle.core.utilcode.util.ActivityUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.bus.passenger.view.ToastCharterView +import me.jessyan.autosize.utils.AutoSizeUtils + +object ToastCharterUtils { + fun showTaost(toastText:String){ + val context = ActivityUtils.getTopActivity() + val marker = ToastCharterView(context) + marker.setText(toastText) + marker.measure( + View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(context, 145f), View.MeasureSpec.UNSPECIFIED), + View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(context, 34f), View.MeasureSpec.EXACTLY) + ) + marker.layout(0, 0, marker.measuredWidth, marker.measuredHeight) + ToastUtils.showShort(marker) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/view/ToastCharterView.kt b/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/view/ToastCharterView.kt new file mode 100644 index 0000000000..314280bcf7 --- /dev/null +++ b/OCH/mogo-och-charter-passenger/src/main/java/com/mogo/och/bus/passenger/view/ToastCharterView.kt @@ -0,0 +1,27 @@ +package com.mogo.och.bus.passenger.view + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.och.bus.passenger.R +import kotlinx.android.synthetic.main.charter_p_view_toast.view.* + +class ToastCharterView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout ( + context, + attrs, + defStyleAttr +) { + + init { + LayoutInflater.from(context).inflate(R.layout.charter_p_view_toast, this, true) + } + + fun setText(siteName: String) { + tv_taost_texit.text = siteName + } +} \ No newline at end of file diff --git a/OCH/mogo-och-charter-passenger/src/main/res/drawable/charter_p_toast_shape.xml b/OCH/mogo-och-charter-passenger/src/main/res/drawable/charter_p_toast_shape.xml new file mode 100644 index 0000000000..7a2823a326 --- /dev/null +++ b/OCH/mogo-och-charter-passenger/src/main/res/drawable/charter_p_toast_shape.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-charter-passenger/src/main/res/layout/charter_p_view_toast.xml b/OCH/mogo-och-charter-passenger/src/main/res/layout/charter_p_view_toast.xml new file mode 100644 index 0000000000..eeefa3536d --- /dev/null +++ b/OCH/mogo-och-charter-passenger/src/main/res/layout/charter_p_view_toast.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/OCH/mogo-och-charter-passenger/src/main/res/values/color.xml b/OCH/mogo-och-charter-passenger/src/main/res/values/color.xml index 397230136c..ca22013238 100644 --- a/OCH/mogo-och-charter-passenger/src/main/res/values/color.xml +++ b/OCH/mogo-och-charter-passenger/src/main/res/values/color.xml @@ -46,6 +46,7 @@ #3060ABFE #0060ABFE #00EFF6FF + #B3EFF6FF #91EFF6FF #CCFFFFFF #80FFFFFF diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/ToastUtils.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/ToastUtils.java index dfa9844026..400f3e021d 100644 --- a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/ToastUtils.java +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/ToastUtils.java @@ -453,6 +453,26 @@ public final class ToastUtils { show(UtilsBridge.format(format, args), Toast.LENGTH_LONG, DEFAULT_MAKER); } + /** + * Show the toast for a short period of time. + * + */ + public static void showShort(@Nullable final View view) { + if(view!=null){ + show(view, Toast.LENGTH_SHORT, DEFAULT_MAKER); + }else { + + } + } + /** + * Show the toast for a short period of time. + * + */ + public static void showLong(@Nullable final View view) { + show(view, Toast.LENGTH_LONG, DEFAULT_MAKER); + } + + /** * Cancel the toast. */