[评价功能]
This commit is contained in:
yangyakun
2024-03-08 10:47:14 +08:00
parent 2edf7052d2
commit 62425f5278
8 changed files with 240 additions and 10 deletions

View File

@@ -1,10 +1,13 @@
package com.mogo.och.common.module.utils;
import android.annotation.SuppressLint;
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
/**
@@ -24,8 +27,7 @@ public class DateTimeUtil {
public static String formatCalendarToString(Calendar calendar, String format){
if (calendar == null) return "";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(calendar.getTime());
return getSafeDateFormat(format).format(calendar.getTime());
}catch (Exception e){
e.printStackTrace();
}
@@ -50,8 +52,7 @@ public class DateTimeUtil {
}
public static String formatLongToString(long time, String format){
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(time);
return getSafeDateFormat(format).format(time);
}catch (Exception e){
e.printStackTrace();
}
@@ -108,11 +109,6 @@ public class DateTimeUtil {
return calendar.getTimeInMillis();
}
public static String getAfterSecondTime(int timeInSecond,String formate){
Calendar beforeTime = Calendar.getInstance();
beforeTime.add(Calendar.SECOND, timeInSecond);
return formatCalendarToString(beforeTime, formate);
}
public static String getAfterSecondTime(int timeInSecond){
Calendar beforeTime = Calendar.getInstance();
beforeTime.add(Calendar.SECOND, timeInSecond);
@@ -163,4 +159,31 @@ public class DateTimeUtil {
return stringBuffer.toString();
}
private static final ThreadLocal<Map<String, SimpleDateFormat>> SDF_THREAD_LOCAL
= new ThreadLocal<Map<String, SimpleDateFormat>>() {
@Override
protected Map<String, SimpleDateFormat> initialValue() {
return new HashMap<>();
}
@Override
public void remove() {
super.remove();
}
};
@SuppressLint("SimpleDateFormat")
public static SimpleDateFormat getSafeDateFormat(String pattern) {
Map<String, SimpleDateFormat> sdfMap = SDF_THREAD_LOCAL.get();
//noinspection ConstantConditions
SimpleDateFormat simpleDateFormat = sdfMap.get(pattern);
if (simpleDateFormat == null) {
simpleDateFormat = new SimpleDateFormat(pattern);
sdfMap.put(pattern, simpleDateFormat);
}
return simpleDateFormat;
}
}

View File

@@ -0,0 +1,107 @@
package com.mogo.och.taxi.passenger.ui.evaluate
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.common.module.voice.VoiceNotice
import com.mogo.och.taxi.passenger.R
import kotlinx.android.synthetic.main.taxi_p_evaluate.view.iv_close
import kotlinx.android.synthetic.main.taxi_p_evaluate.view.iv_evaluate_great
import kotlinx.android.synthetic.main.taxi_p_evaluate.view.iv_evaluate_low
import kotlinx.android.synthetic.main.taxi_p_evaluate.view.iv_taxt_p_greate_text
class EvaluateView : ConstraintLayout {
private val TAG = "EvaluateView"
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes)
private var isFirat = true
private fun initView() {
LayoutInflater.from(context).inflate(R.layout.taxi_p_evaluate, this, true)
iv_evaluate_great.onClick {
if(isFirat){
iv_evaluate_great.pivotX = (iv_evaluate_great.width / 2).toFloat()
iv_evaluate_great.pivotY = iv_evaluate_great.height.toFloat()
iv_evaluate_great.animate().scaleY(1.7f).scaleX(1.7f).setListener(object
:AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
VoiceNotice.showNotice("感谢您的认可,我们会再接再厉", AIAssist.LEVEL2)
iv_taxt_p_greate_text.animate().alpha(1f).duration = 1000
// 小智爱心动作
RxUtils.createSubscribe(3_000) {
visibility = GONE
iv_taxt_p_greate_text.visibility = GONE
// 小智回归默认动作
}
}
}).duration = 1000
isFirat = false
}
}
iv_evaluate_low.onClick {
if(isFirat){
iv_evaluate_low.pivotX = (iv_evaluate_low.width / 2).toFloat()
iv_evaluate_low.pivotY = iv_evaluate_low.height.toFloat()
iv_evaluate_low.animate().scaleY(1.7f).scaleX(1.7f).setListener(object :
AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
VoiceNotice.showNotice("感谢您的反馈,我们会继续努力!", AIAssist.LEVEL2)
// 小智爱心动作
RxUtils.createSubscribe(3_000) {
visibility = GONE
// 小智回归默认动作
}
}
}).duration = 1000
isFirat = false
}
}
iv_close.onClick {
visibility = GONE
}
}
override fun onVisibilityAggregated(isVisible: Boolean) {
super.onVisibilityAggregated(isVisible)
if(isVisible){
isFirat = true
VoiceNotice.showNotice("行程即将结束咯~小智很想知道您的体验如何呢", AIAssist.LEVEL2)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
}
init {
try {
initView()
} catch (e: Exception) {
e.printStackTrace()
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_621"
android:layout_height="wrap_content"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<com.mogo.eagle.core.widget.RoundCanClickConstraintLayout
android:layout_width="@dimen/dp_600"
android:layout_height="@dimen/dp_349"
android:layout_marginStart="@dimen/dp_21"
android:layout_marginTop="@dimen/dp_33"
android:background="#8CF5FAFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:roundLayoutRadius="24dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_51"
android:layout_marginEnd="@dimen/dp_51"
android:text="行程即将结束,小智很想知道你的体验如何呢?"
android:textColor="@color/taxi_p_131415"
android:textSize="@dimen/dp_32"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_great_evaluate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_105"
android:layout_marginBottom="@dimen/dp_40"
android:text="新奇有趣"
android:textColor="@color/taxi_p_303C52"
android:textSize="@dimen/dp_26"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_low_evaluate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_99"
android:layout_marginBottom="@dimen/dp_40"
android:text="有待提升"
android:textColor="@color/taxi_p_303C52"
android:textSize="@dimen/dp_26"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/iv_evaluate_great"
android:layout_width="@dimen/dp_120"
android:layout_height="@dimen/dp_120"
android:layout_marginBottom="@dimen/dp_10"
android:src="@drawable/taxi_p_evaluate_great"
app:layout_constraintBottom_toTopOf="@+id/tv_great_evaluate"
app:layout_constraintEnd_toEndOf="@+id/tv_great_evaluate"
app:layout_constraintStart_toStartOf="@+id/tv_great_evaluate" />
<ImageView
android:id="@+id/iv_evaluate_low"
android:layout_width="@dimen/dp_120"
android:layout_height="@dimen/dp_120"
android:layout_marginBottom="@dimen/dp_1"
android:src="@drawable/taxi_p_evaluate_low"
app:layout_constraintBottom_toTopOf="@+id/tv_low_evaluate"
app:layout_constraintEnd_toEndOf="@+id/tv_low_evaluate"
app:layout_constraintStart_toStartOf="@+id/tv_low_evaluate" />
</com.mogo.eagle.core.widget.RoundCanClickConstraintLayout>
<ImageView
android:id="@+id/iv_taxt_p_greate_text"
android:layout_width="@dimen/dp_314"
android:layout_height="@dimen/dp_140"
android:src="@drawable/taxt_p_greate_text"
android:visibility="gone"
android:layout_marginStart="@dimen/dp_81"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_close"
android:layout_width="@dimen/dp_81"
android:layout_height="@dimen/dp_81"
android:layout_marginTop="@dimen/dp_10"
android:src="@drawable/taxi_p_evaluate_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</merge>

View File

@@ -47,6 +47,7 @@
<color name="taxi_p_598CFF">#598CFF</color>
<color name="taxi_p_253A5A">#253A5A</color>
<color name="taxi_p_4DFFFFFF">#4DFFFFFF</color>
<color name="taxi_p_131415">#131415</color>
<color name="taxi_p_464646">#464646</color>