Commit d8f6c0ea by 刘鹏

Merge branch 'feat/lp/lp_home_anim' into 'd/v4.0.57_xlzx'

UI还原,问题修复

See merge request app_android_lib/YDL-Component!360
parents fdb200c4 cc2481b1
...@@ -191,11 +191,7 @@ class ExpertSearchAdapter( ...@@ -191,11 +191,7 @@ class ExpertSearchAdapter(
val view = LayoutInflater.from(context) val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_tag, holder.ll_tags, false) .inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
tag.tag_name.let { name -> tag.tag_name.let { name ->
if (name.length > 4) { view.tvTag.text = name
view.tvTag.text = "${name.substring(0, 4)}…"
} else {
view.tvTag.text = name
}
} }
if (tag.is_highlight) { if (tag.is_highlight) {
view.tvTag.setBackgroundResource(R.drawable.consultant_bg_radius_line_eb892c) view.tvTag.setBackgroundResource(R.drawable.consultant_bg_radius_line_eb892c)
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
<solid android:color="@color/platform_white" /> <solid android:color="@color/platform_white" />
<stroke <stroke
android:width="0.5dp" android:width="0.5dp"
android:color="@color/color_1c1f28_20" /> android:color="@color/color_1c1f28_10" />
</shape> </shape>
\ No newline at end of file
...@@ -187,11 +187,11 @@ ...@@ -187,11 +187,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvName" android:layout_alignTop="@+id/tvName"
android:layout_marginTop="12dp"
android:text="起" android:text="起"
android:textColor="@color/color_ef8a4a" android:textColor="@color/color_ef8a4a"
android:textSize="@dimen/platform_dp_12" android:textSize="@dimen/platform_dp_12"
app:layout_constraintBaseline_toBaselineOf="@id/tvPrice" app:layout_constraintTop_toTopOf="@id/tvPrice"
app:layout_constraintBottom_toBottomOf="@id/tvPrice"
app:layout_constraintLeft_toRightOf="@id/tvPrice" /> app:layout_constraintLeft_toRightOf="@id/tvPrice" />
<TextView <TextView
...@@ -210,10 +210,8 @@ ...@@ -210,10 +210,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="24dp"
android:elevation="0dp" android:elevation="0dp"
android:minWidth="56dp" android:minWidth="60dp"
android:paddingLeft="6dp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingRight="6dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
app:cardBackgroundColor="@color/color_6ec8f9" app:cardBackgroundColor="@color/color_6ec8f9"
app:cardCornerRadius="12dp" app:cardCornerRadius="12dp"
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
android:paddingRight="4dp" android:paddingRight="4dp"
android:paddingBottom="3dp" android:paddingBottom="3dp"
android:textColor="@color/color_1c1f28_50" android:textColor="@color/color_1c1f28_50"
android:textSize="11sp" android:textSize="11dp"
tools:text="恋爱情感" /> tools:text="恋爱情感" />
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<color name="color_1c1f28_50">#801c1f28</color> <color name="color_1c1f28_50">#801c1f28</color>
<color name="color_1c1f28_40">#661c1f28</color> <color name="color_1c1f28_40">#661c1f28</color>
<color name="color_1c1f28_20">#331c1f28</color> <color name="color_1c1f28_20">#331c1f28</color>
<color name="color_1c1f28_10">#1a1c1f28</color>
<color name="color_ef8a4a">#EF8A4A</color> <color name="color_ef8a4a">#EF8A4A</color>
<color name="color_f6f6f7">#f6f6f7</color> <color name="color_f6f6f7">#f6f6f7</color>
<color name="color_6ec8f9">#6ec8f9</color> <color name="color_6ec8f9">#6ec8f9</color>
......
package com.yidianling.home.ui.transform;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
import jp.wasabeef.glide.transformations.BitmapTransformation;
public class CircleCropTransform extends BitmapTransformation {
private final Paint mBorderPaint;
private final float mBorderSize;
public CircleCropTransform() {
this(0, Color.TRANSPARENT);
}
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
/**
* @param borderSize 边框宽度(px)
* @param borderColor 边框颜色
*/
public CircleCropTransform(float borderSize, int borderColor) {
this(TypedValue.COMPLEX_UNIT_PX, borderSize, borderColor);
}
/**
* @param unit borderSize 单位
* @param borderSize 边框宽度(px)
* @param borderColor 边框颜色
*/
public CircleCropTransform(int unit, float borderSize, int borderColor) {
DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
mBorderSize = TypedValue.applyDimension(unit, borderSize, displayMetrics);
mBorderPaint = new Paint();
mBorderPaint.setDither(true);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(borderColor);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setStrokeWidth(mBorderSize);
}
private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
int size = (int) (Math.min(source.getWidth(), source.getHeight()) - (mBorderSize / 2));
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
if (mBorderPaint != null) {
float borderRadius = r - mBorderSize / 2;
canvas.drawCircle(r, r, borderRadius, mBorderPaint);
}
return result;
}
@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
}
@Override
public boolean equals(Object o) {
return false;
}
@Override
public int hashCode() {
return 0;
}
}
...@@ -43,10 +43,10 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent: ...@@ -43,10 +43,10 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
homeEvent?.reservationExpertsClick() homeEvent?.reservationExpertsClick()
} }
dataBinding?.homeModuleButtonBannerSecond?.setOnClickListener { dataBinding?.homeModuleButtonBannerSecond?.setOnClickListener {
homeEvent?.askMoreClick() homeEvent?.nowConfideClick(false)
} }
dataBinding?.homeModuleButtonBannerThird?.setOnClickListener { dataBinding?.homeModuleButtonBannerThird?.setOnClickListener {
homeEvent?.nowConfideClick(false) homeEvent?.psychologyClassClick()
} }
dataBinding?.homeModuleButtonBannerFourth?.setOnClickListener { dataBinding?.homeModuleButtonBannerFourth?.setOnClickListener {
homeEvent?.psychologyTestClick() homeEvent?.psychologyTestClick()
......
...@@ -4,6 +4,7 @@ import android.animation.Animator ...@@ -4,6 +4,7 @@ import android.animation.Animator
import android.animation.AnimatorListenerAdapter import android.animation.AnimatorListenerAdapter
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.graphics.Color
import android.os.Handler import android.os.Handler
import android.os.Message import android.os.Message
import android.util.AttributeSet import android.util.AttributeSet
...@@ -11,7 +12,9 @@ import android.util.Log ...@@ -11,7 +12,9 @@ import android.util.Log
import android.widget.ImageView import android.widget.ImageView
import android.widget.RelativeLayout import android.widget.RelativeLayout
import com.blankj.utilcode.util.SizeUtils import com.blankj.utilcode.util.SizeUtils
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.home.R import com.yidianling.home.R
import com.yidianling.home.ui.transform.CircleCropTransform
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
const val START_AVATAR_LOOP = 111 const val START_AVATAR_LOOP = 111
...@@ -26,7 +29,7 @@ class LoopScrollAvatar @JvmOverloads constructor( ...@@ -26,7 +29,7 @@ class LoopScrollAvatar @JvmOverloads constructor(
private val animDuration = 500L private val animDuration = 500L
//动画间隔播放时间 //动画间隔播放时间
private val animIntervalTime = 2000L private val animIntervalTime = 1500L
//两边头像的缩放程度 //两边头像的缩放程度
private val scaleFrom = 0.7F private val scaleFrom = 0.7F
...@@ -98,7 +101,7 @@ class LoopScrollAvatar @JvmOverloads constructor( ...@@ -98,7 +101,7 @@ class LoopScrollAvatar @JvmOverloads constructor(
* 创建圆形头像ImageView * 创建圆形头像ImageView
*/ */
private fun createImageView(): ImageView { private fun createImageView(): ImageView {
return XCRoundImageView(context) return ImageView(context)
} }
/** /**
...@@ -114,9 +117,6 @@ class LoopScrollAvatar @JvmOverloads constructor( ...@@ -114,9 +117,6 @@ class LoopScrollAvatar @JvmOverloads constructor(
//当前已在屏幕显示的控件不要复用,防止params混乱 //当前已在屏幕显示的控件不要复用,防止params混乱
ivCache.remove(iv) ivCache.remove(iv)
iv.setImageResource(res[index])
iv.scaleType = ImageView.ScaleType.FIT_XY
//图片资源全部播放完之后要从头重播 //图片资源全部播放完之后要从头重播
index = (index + 1) % res.size index = (index + 1) % res.size
...@@ -126,6 +126,9 @@ class LoopScrollAvatar @JvmOverloads constructor( ...@@ -126,6 +126,9 @@ class LoopScrollAvatar @JvmOverloads constructor(
iv.layoutParams = lp iv.layoutParams = lp
addView(iv) addView(iv)
//圆角带描边
GlideApp.with(this).load(res[index]).transform(CircleCropTransform(1f, Color.WHITE))
.into(iv)
} }
/** /**
......
package com.yidianling.home.ui.view
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.*
import android.graphics.drawable.BitmapDrawable
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
/**
* @author liupeng
*/
class XCRoundImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : AppCompatImageView(
context, attrs, defStyle
) {
private val paint: Paint = Paint()
/**
* 绘制圆形图片
* @author caizhiming
*/
@SuppressLint("DrawAllocation")
override fun onDraw(canvas: Canvas) {
val drawable = drawable
if (null != drawable) {
val bitmap = (drawable as BitmapDrawable).bitmap
val b = getCircleBitmap(bitmap, 14)
val rectSrc = Rect(0, 0, b.width, b.height)
val rectDest = Rect(0, 0, width, height)
paint.reset()
canvas.drawBitmap(b, rectSrc, rectDest, paint)
} else {
super.onDraw(canvas)
}
}
/**
* 获取圆形图片方法
* @param bitmap
* @param pixels
* @return Bitmap
* @author caizhiming
*/
private fun getCircleBitmap(bitmap: Bitmap, pixels: Int): Bitmap {
val output = Bitmap.createBitmap(
bitmap.width,
bitmap.height, Bitmap.Config.ARGB_8888
)
val canvas = Canvas(output)
val color = -0xbdbdbe
val rect = Rect(0, 0, bitmap.width, bitmap.height)
paint.isAntiAlias = true
canvas.drawARGB(0, 0, 0, 0)
paint.color = color
val x = bitmap.width
canvas.drawCircle((x / 2).toFloat(), (x / 2).toFloat(), (x / 2).toFloat(), paint)
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
canvas.drawBitmap(bitmap, rect, rect, paint)
return output
}
}
\ No newline at end of file
...@@ -62,64 +62,9 @@ ...@@ -62,64 +62,9 @@
android:src="@mipmap/home_banner_header1" android:src="@mipmap/home_banner_header1"
app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec" app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"
app:layout_constraintLeft_toLeftOf="@id/homeModuleButtonBannerFirstTitle" app:layout_constraintLeft_toLeftOf="@id/homeModuleButtonBannerFirstTitle"
android:layout_width="50dp" android:layout_width="45dp"
app:layout_constraintHorizontal_weight="1" app:layout_constraintHorizontal_weight="1"
android:layout_height="20dp" /> android:layout_height="20dp" />
<!-- <ImageView-->
<!-- android:id="@+id/header1"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:visibility="visible"-->
<!-- android:src="@mipmap/home_banner_header1"-->
<!-- app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/homeModuleButtonBannerFirstTitle"-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp"/>-->
<!-- <ImageView-->
<!-- android:id="@+id/header2"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:src="@mipmap/home_banner_header1"-->
<!-- android:layout_marginLeft="14dp"-->
<!-- android:visibility="visible"-->
<!-- app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/header1"-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp" />-->
<!-- <ImageView-->
<!-- android:id="@+id/header3"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:src="@mipmap/home_banner_header2"-->
<!-- android:layout_marginLeft="14dp"-->
<!-- android:visibility="visible"-->
<!-- app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/header2"-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp" />-->
<!-- <ImageView-->
<!-- android:id="@+id/header4"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:src="@mipmap/home_banner_header1"-->
<!-- android:layout_marginLeft="14dp"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/header3"-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp" />-->
<!-- <ImageView-->
<!-- android:id="@+id/header5"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:src="@mipmap/home_banner_header2"-->
<!-- android:layout_marginLeft="12dp"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintTop_toBottomOf="@id/homeModuleFirstDec"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/header4"-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp" />-->
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
...@@ -209,7 +154,7 @@ ...@@ -209,7 +154,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:text="心理课堂" android:text="倾诉热线"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="16dp" android:textSize="16dp"
android:textStyle="bold" android:textStyle="bold"
...@@ -222,7 +167,7 @@ ...@@ -222,7 +167,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:text="学习与成长" android:text="24小时在线"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="11dp" android:textSize="11dp"
app:layout_constraintLeft_toLeftOf="@id/homeModuleButtonBannerSecondTitle" app:layout_constraintLeft_toLeftOf="@id/homeModuleButtonBannerSecondTitle"
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:scaleType="fitXY" android:scaleType="fitCenter"
tools:layout_height="100dp" /> tools:layout_height="100dp" />
<TextView <TextView
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment