开屏图片转Banner特效
This commit is contained in:
parent
f913248fa1
commit
369f3f2cae
@ -9,9 +9,9 @@ ext {
|
|||||||
]
|
]
|
||||||
manifestPlaceholders = [
|
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",
|
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
||||||
|
@ -7,7 +7,6 @@ import android.animation.Animator;
|
|||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@ -18,14 +17,13 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.transition.ChangeBounds;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
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.NoviceInstructorEvent;
|
||||||
import com.yunbao.common.event.RongIMConnectionStatusEvent;
|
import com.yunbao.common.event.RongIMConnectionStatusEvent;
|
||||||
import com.yunbao.common.event.UpdateTablePointMe;
|
import com.yunbao.common.event.UpdateTablePointMe;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
|
||||||
import com.yunbao.common.http.CommonHttpConsts;
|
import com.yunbao.common.http.CommonHttpConsts;
|
||||||
import com.yunbao.common.http.CommonHttpUtil;
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
import com.yunbao.common.http.HttpCallback;
|
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.ProcessResultUtil;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
import com.yunbao.common.utils.SpUtil;
|
import com.yunbao.common.utils.SpUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.ToastUtils;
|
|
||||||
import com.yunbao.common.utils.VersionUtil;
|
import com.yunbao.common.utils.VersionUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.common.views.APKUpdateCustomPopup;
|
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.utils.LiveStorge;
|
||||||
import com.yunbao.live.views.ChatListViewHolder;
|
import com.yunbao.live.views.ChatListViewHolder;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
|
import com.yunbao.main.adapter.FullAdToBannerTransition;
|
||||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||||
import com.yunbao.main.dialog.ReturnUserDialog;
|
import com.yunbao.main.dialog.ReturnUserDialog;
|
||||||
import com.yunbao.main.dialog.SigninDialog;
|
import com.yunbao.main.dialog.SigninDialog;
|
||||||
@ -204,9 +200,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
protected void create() {
|
protected void create() {
|
||||||
super.create();
|
super.create();
|
||||||
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
||||||
ChangeBounds bounds = new ChangeBounds();
|
getWindow().setSharedElementEnterTransition(new FullAdToBannerTransition(1,0.4f,new DecelerateInterpolator()));
|
||||||
bounds.setDuration(1000);
|
|
||||||
getWindow().setSharedElementEnterTransition(bounds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.yunbao.main.views;
|
package com.yunbao.main.views;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -16,8 +17,13 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewOutlineProvider;
|
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 android.widget.ImageView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
@ -332,24 +338,22 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
|||||||
mBanner.setClipToOutline(true);
|
mBanner.setClipToOutline(true);
|
||||||
String adUrl = ((Activity) mContext).getIntent().getStringExtra("ad_url");
|
String adUrl = ((Activity) mContext).getIntent().getStringExtra("ad_url");
|
||||||
ImageView ad = headView.findViewById(R.id.ad_img);
|
ImageView ad = headView.findViewById(R.id.ad_img);
|
||||||
ToastUtil.showDebug(adUrl);
|
|
||||||
if (StringUtil.isEmpty(adUrl)) {
|
if (StringUtil.isEmpty(adUrl)) {
|
||||||
ad.setVisibility(View.GONE);
|
ad.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
//ImgLoader.display(mContext, adUrl, ad);
|
//ImgLoader.display(mContext, adUrl, ad);
|
||||||
|
|
||||||
Glide.with(mContext)
|
Glide.with(mContext)
|
||||||
.load(adUrl)
|
.load(adUrl)
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<Drawable>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
ToastUtil.showDebug("加载失败");
|
|
||||||
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
|
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||||
ToastUtil.showDebug("加载完成");
|
|
||||||
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
|
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ad_img"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingTop="0dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/bg_tmp_s"
|
||||||
|
android:transitionName="ad_img_0" />
|
||||||
|
|
||||||
<com.ms.banner.Banner
|
<com.ms.banner.Banner
|
||||||
android:id="@+id/banner"
|
android:id="@+id/banner"
|
||||||
@ -29,16 +38,7 @@
|
|||||||
|
|
||||||
</com.ms.banner.Banner>
|
</com.ms.banner.Banner>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ad_img"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingTop="110dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/bg_tmp_s"
|
|
||||||
android:transitionName="ad_img_0" />
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user