From f913248fa1ae62a60f21974e2522dcbc62ea83f2 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 18 Apr 2023 11:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E6=96=B9=E6=A1=881?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../phonelive/activity/LauncherActivity.java | 25 +++++++- .../yunbao/common/activity/AbsActivity.java | 4 ++ .../yunbao/common/http/CommonHttpUtil.java | 1 + .../com/yunbao/common/http/HttpCallback.java | 1 + config.gradle | 4 +- .../yunbao/main/activity/MainActivity.java | 27 +++++++-- .../main/views/MainHomeLiveViewHolder.java | 58 +++++++++++++++++++ .../yunbao/main/views/MainHomeViewHolder.java | 6 -- main/src/main/res/layout/activity_main.xml | 24 +++++++- .../res/layout/item_main_home_live_head.xml | 19 +++++- 10 files changed, 149 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index 371732ef7..da53b3d72 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -1,6 +1,7 @@ package com.shayu.phonelive.activity; +import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Build; @@ -19,6 +20,8 @@ import android.widget.ImageView; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.app.ActivityOptionsCompat; import androidx.core.app.NotificationManagerCompat; import com.alibaba.android.arouter.facade.annotation.Route; @@ -45,6 +48,7 @@ import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; import com.yunbao.common.utils.DownloadUtil; +import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; import com.yunbao.common.utils.LogUtil; import com.yunbao.common.utils.MD5Util; @@ -100,6 +104,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); super.onCreate(savedInstanceState); EventBus.getDefault().register(this); setStatusBar(); @@ -184,6 +189,8 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL String adInfo = bean.getAdInfo(); if (!TextUtils.isEmpty(adInfo)) { JSONObject obj = JSON.parseObject(adInfo); + Log.i(TAG, "callback: " + adInfo); + obj.put("switch", 1); if (obj.getIntValue("switch") == 1) { List list = JSON.parseArray(obj.getString("list"), AdBean.class); if (list != null && list.size() > 0) { @@ -268,8 +275,15 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL if (getIntent().getStringExtra("activityUrl") != null) { intent.putExtra("activityUrl", getIntent().getStringExtra("activityUrl")); } - - LauncherActivity.this.startActivity(intent); + if (mImageViewList != null && mImageViewList.size() > 0) { + Log.i(TAG, "forwardMainActivity: " + mImageViewList.size()); + intent.putExtra("ad_url", mAdList.get(0).getUrl()); + Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(LauncherActivity.this, mImageViewList.get(0), "ad_img_0").toBundle(); + //Bundle bundle = ActivityOptionsCompat.makeScaleUpAnimation(mImageViewList.get(0),100,100, DpUtil.dp2px(400),DpUtil.dp2px(200)).toBundle(); + LauncherActivity.this.startActivity(intent, bundle); + } else { + LauncherActivity.this.startActivity(intent); + } finish(); } @@ -369,7 +383,13 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL if (mContainer == null) { return; } + isImage = true; if (isImage) { + mAdList = new ArrayList<>(); + AdBean adBean = new AdBean(); + adBean.setUrl("https://downs.yaoulive.com/20230411/af6596ffcc35349adbae44dfb9c23a96.jpg"); + adBean.setLink("https://downs.yaoulive.com/20230411/af6596ffcc35349adbae44dfb9c23a96.jpg"); + mAdList.add(adBean); int imgSize = mAdList.size(); if (imgSize > 0) { mImageViewList = new ArrayList<>(); @@ -378,6 +398,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setBackgroundColor(0xffffffff); + imageView.setTransitionName("ad_img_" + i); mImageViewList.add(imageView); ImgLoader.display(mContext, mAdList.get(i).getUrl(), imageView); } diff --git a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java index e75bf5ae6..ec2cce55c 100644 --- a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java @@ -55,6 +55,7 @@ public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + create(); Intent intent = getIntent(); if (intent != null) { isFullWindow = getIntent().getBooleanExtra("isFull", false); @@ -86,6 +87,9 @@ public abstract class AbsActivity extends AppCompatActivity { protected void main() { + } + protected void create(){ + } protected boolean isStatusBarWhite() { diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index 82d94a308..116f95228 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -223,6 +223,7 @@ public class CommonHttpUtil { IMLoginManager.get(context).setDefaultBubbleUrl(obj.getString("defaultBubbleUrl")); } } catch (Exception e) { + e.printStackTrace(); String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage(); ErrorActivity.forward("GetConfig接口返回数据异常", error); } diff --git a/common/src/main/java/com/yunbao/common/http/HttpCallback.java b/common/src/main/java/com/yunbao/common/http/HttpCallback.java index 11637be1a..31cc2e101 100644 --- a/common/src/main/java/com/yunbao/common/http/HttpCallback.java +++ b/common/src/main/java/com/yunbao/common/http/HttpCallback.java @@ -62,6 +62,7 @@ public abstract class HttpCallback extends AbsCallback { @Override public void onError(Response response) { Throwable t = response.getException(); + t.printStackTrace(); L.e("网络请求错误---->" + t.getClass() + " : " + t.getMessage()); if (t instanceof SocketTimeoutException || t instanceof ConnectException || t instanceof UnknownHostException || t instanceof UnknownServiceException || t instanceof SocketException) { ToastUtil.show(R.string.load_failure); diff --git a/config.gradle b/config.gradle index 95a3f25a3..367862767 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 aa188c6ac..5583ca359 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -7,6 +7,7 @@ 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; @@ -17,11 +18,14 @@ 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.widget.FrameLayout; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -29,6 +33,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; +import androidx.core.app.ActivityCompat; import androidx.viewpager.widget.ViewPager; import com.alibaba.android.arouter.facade.annotation.Route; @@ -70,6 +75,7 @@ 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; @@ -86,6 +92,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; @@ -193,9 +200,18 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene return R.layout.activity_main; } + @Override + protected void create() { + super.create(); + getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); + ChangeBounds bounds = new ChangeBounds(); + bounds.setDuration(1000); + getWindow().setSharedElementEnterTransition(bounds); + } @Override protected void main() { + ActivityCompat.postponeEnterTransition(this); ConversationIMListManager.get(this); //在请求一下这个接口给我后台版本号 CommonHttpUtil.getConfig(mContext, new CommonCallback() { @@ -312,9 +328,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Override public void onPageSelected(int position) { - if(mTabButtonGroup.getCurPosition()!=position){ - System.err.println("重连IM:"+IMLoginManager.isLogin(mContext)); - if(!IMLoginManager.isLogin(mContext)){ + if (mTabButtonGroup.getCurPosition() != position) { + System.err.println("重连IM:" + IMLoginManager.isLogin(mContext)); + if (!IMLoginManager.isLogin(mContext)) { //IMLoginManager.get(mContext).setupLoginUser(); RouteUtil.forwardLoginInvalid("登錄失效"); return; @@ -828,7 +844,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene Log.e("--->", list.get(j).getGiftname() + list.get(j).getSwf()); - GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback() { + GiftCacheUtil.getFile(MainActivity.this, Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback() { @Override public void callback(File bean) { @@ -869,7 +885,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene Log.e("tx", id); - GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { + GiftCacheUtil.getFile(MainActivity.this, Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @Override public void callback(File bean) { // Log.e("111",bean.getPath()+"是"); @@ -990,6 +1006,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private void loadPageData(int position, boolean needlLoadData) { if (mViewHolders == null) { + ToastUtil.showDebug("Holders为空"); return; } 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 da5733aac..0cadee66a 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -1,12 +1,16 @@ package com.yunbao.main.views; import android.animation.ObjectAnimator; +import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.graphics.Outline; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Environment; +import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -14,6 +18,8 @@ import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.widget.ImageView; +import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; import androidx.core.content.FileProvider; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; @@ -21,6 +27,13 @@ import androidx.recyclerview.widget.RecyclerView; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.bumptech.glide.Glide; +import com.bumptech.glide.RequestBuilder; +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.DrawableImageViewTarget; +import com.bumptech.glide.request.target.Target; import com.ms.banner.Banner; import com.ms.banner.listener.OnBannerClickListener; import com.yunbao.common.CommonAppConfig; @@ -35,12 +48,14 @@ import com.yunbao.common.bean.LiveClassBean; import com.yunbao.common.bean.WeekListBean; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ShareUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.CustomViewHolder; import com.yunbao.live.event.LiveRoomChangeEvent; @@ -315,7 +330,47 @@ 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; + } + }) + /* .addListener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { + ActivityCompat.startPostponedEnterTransition((Activity) mContext); + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { + ActivityCompat.startPostponedEnterTransition((Activity) mContext); + return false; + } + })*/ + .error(R.mipmap.ic_launcher) + .into(new DrawableImageViewTarget(ad)); + + } } @@ -361,6 +416,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement return; } mBannerShowed = true; + BannerBean tmp = mBannerList.get(0); + mBannerList.set(0, mBannerList.get(2)); + mBannerList.set(2, tmp); mBanner.setAutoPlay(true) .setPages(mBannerList, new CustomViewHolder()) .setDelayTime(3000) diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index 7025820a8..83c5d32b9 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,19 +1,13 @@ package com.yunbao.main.views; import android.content.Context; -import android.content.Intent; -import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.WordUtil; -import com.yunbao.live.dialog.LiveAnchorSayPopDialog; -import com.yunbao.live.dialog.LiveRobotSettingDialogFragment; import com.yunbao.main.R; -import com.yunbao.main.activity.MainActivity; -import com.yunbao.main.activity.TestActivity; /** * Created by cxf on 2018/9/22. diff --git a/main/src/main/res/layout/activity_main.xml b/main/src/main/res/layout/activity_main.xml index 6327e294d..d3150e18d 100644 --- a/main/src/main/res/layout/activity_main.xml +++ b/main/src/main/res/layout/activity_main.xml @@ -1,6 +1,7 @@ - - + - \ No newline at end of file + + + \ No newline at end of file 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 c1c032c7f..7333475f6 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 @@ -1,6 +1,7 @@ + > + + app:indicator_width="8dp"> + + +