From 369f3f2caeea792d4cf653cb871c8ec1ec8ef225 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 18 Apr 2023 16:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=B1=8F=E5=9B=BE=E7=89=87=E8=BD=ACBa?= =?UTF-8?q?nner=E7=89=B9=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 4 +- .../yunbao/main/activity/MainActivity.java | 13 ++-- .../adapter/FullAdToBannerTransition.java | 63 +++++++++++++++++++ .../main/views/MainHomeLiveViewHolder.java | 10 ++- .../res/layout/item_main_home_live_head.xml | 22 +++---- 5 files changed, 87 insertions(+), 25 deletions(-) create mode 100644 main/src/main/java/com/yunbao/main/adapter/FullAdToBannerTransition.java diff --git a/config.gradle b/config.gradle index 367862767..82f2a343d 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式、 -// serverHost : "https://napi.yaoulive.com", + serverHost : "https://napi.yaoulive.com", //测试 - serverHost : "https://ceshi.yaoulive.com", +// serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 5583ca359..dc3a401c2 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -7,7 +7,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.Dialog; import android.app.NotificationChannel; import android.app.PendingIntent; @@ -18,14 +17,13 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; -import android.transition.ChangeBounds; import android.util.Log; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -75,7 +73,6 @@ import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.NoviceInstructorEvent; import com.yunbao.common.event.RongIMConnectionStatusEvent; import com.yunbao.common.event.UpdateTablePointMe; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; @@ -92,9 +89,7 @@ import com.yunbao.common.utils.LocationUtil; import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SpUtil; -import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.ToastUtils; import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.APKUpdateCustomPopup; @@ -108,6 +103,7 @@ import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.main.R; +import com.yunbao.main.adapter.FullAdToBannerTransition; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.dialog.ReturnUserDialog; import com.yunbao.main.dialog.SigninDialog; @@ -204,9 +200,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene protected void create() { super.create(); getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); - ChangeBounds bounds = new ChangeBounds(); - bounds.setDuration(1000); - getWindow().setSharedElementEnterTransition(bounds); + getWindow().setSharedElementEnterTransition(new FullAdToBannerTransition(1,0.4f,new DecelerateInterpolator())); + } @Override diff --git a/main/src/main/java/com/yunbao/main/adapter/FullAdToBannerTransition.java b/main/src/main/java/com/yunbao/main/adapter/FullAdToBannerTransition.java new file mode 100644 index 000000000..596ebf954 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/FullAdToBannerTransition.java @@ -0,0 +1,63 @@ +package com.yunbao.main.adapter; + +import android.animation.Animator; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; +import android.animation.TimeInterpolator; +import android.transition.ChangeBounds; +import android.view.View; +import android.view.ViewGroup; + +import android.transition.TransitionValues; + +public class FullAdToBannerTransition extends ChangeBounds { + + private static final String ALPHA = "android:faderay:alpha"; + + private final float startAlpha; + private final float endAlpha; + + public FullAdToBannerTransition(final float startAlpha, final float endAlpha, final TimeInterpolator timeInterpolator) { + this.startAlpha = startAlpha; + this.endAlpha = endAlpha; + setInterpolator(timeInterpolator); + setDuration(1000); + setStartDelay(500); + } + + + @Override + public void captureStartValues(final TransitionValues transitionValues) { + super.captureStartValues(transitionValues); + captureValues(transitionValues); + } + + @Override + public void captureEndValues(final TransitionValues transitionValues) { + super.captureEndValues(transitionValues); + captureValues(transitionValues); + } + + @Override + public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { + Animator animator = super.createAnimator(sceneRoot, startValues, endValues); + ObjectAnimator fade = ObjectAnimator.ofFloat(endValues.view, View.ALPHA, startAlpha, endAlpha); + return mergeAnimators(animator, fade); + } + + private void captureValues(final TransitionValues transitionValues) { + transitionValues.values.put(ALPHA, transitionValues.view.getAlpha()); + } + + private Animator mergeAnimators(Animator animator1, Animator animator2) { + if (animator1 == null) { + return animator2; + } else if (animator2 == null) { + return animator1; + } else { + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.playTogether(animator1, animator2); + return animatorSet; + } + } +} \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index 0cadee66a..05dca6923 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -1,5 +1,6 @@ package com.yunbao.main.views; +import android.animation.Animator; import android.animation.ObjectAnimator; import android.app.Activity; import android.app.Dialog; @@ -16,8 +17,13 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.ViewOutlineProvider; +import android.view.WindowInsets; +import android.view.WindowInsetsAnimation; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; import android.widget.ImageView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.ActivityCompat; import androidx.core.content.FileProvider; @@ -332,24 +338,22 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement mBanner.setClipToOutline(true); String adUrl = ((Activity) mContext).getIntent().getStringExtra("ad_url"); ImageView ad = headView.findViewById(R.id.ad_img); - ToastUtil.showDebug(adUrl); if (StringUtil.isEmpty(adUrl)) { ad.setVisibility(View.GONE); } else { //ImgLoader.display(mContext, adUrl, ad); + Glide.with(mContext) .load(adUrl) .listener(new RequestListener() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - ToastUtil.showDebug("加载失败"); ActivityCompat.startPostponedEnterTransition((Activity) mContext); return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - ToastUtil.showDebug("加载完成"); ActivityCompat.startPostponedEnterTransition((Activity) mContext); return false; } diff --git a/main/src/main/res/layout/item_main_home_live_head.xml b/main/src/main/res/layout/item_main_home_live_head.xml index 7333475f6..a504a5797 100644 --- a/main/src/main/res/layout/item_main_home_live_head.xml +++ b/main/src/main/res/layout/item_main_home_live_head.xml @@ -11,7 +11,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content" > - + - +