新增一处优化内存点

修复闪退回到首页后是默认在社区并且连不上IM的问题
This commit is contained in:
zlzw 2023-02-14 14:11:31 +08:00
parent 0294296ada
commit 4d9dbadea5
5 changed files with 18 additions and 4 deletions

View File

@ -75,6 +75,9 @@ public class TabButtonGroup extends LinearLayout implements View.OnClickListener
} }
} }
public int getCurPosition() {
return mCurPosition;
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -37,6 +37,10 @@ public class CustomViewHolder implements BannerViewHolder<BannerBean> {
TextView targetAssist = contextView.findViewById(R.id.target_assist_num); TextView targetAssist = contextView.findViewById(R.id.target_assist_num);
TextView currentAssist = contextView.findViewById(R.id.current_assist_num); TextView currentAssist = contextView.findViewById(R.id.current_assist_num);
TextView title = contextView.findViewById(R.id.title); TextView title = contextView.findViewById(R.id.title);
bannerBack.setImageResource(R.mipmap.start_level);
iconStart.setImageResource(R.mipmap.icon_start);
iconStartNumber.setImageResource(R.mipmap.icon_start_number);
if (data.isStart()) { if (data.isStart()) {
startContext.setVisibility(View.VISIBLE); startContext.setVisibility(View.VISIBLE);
Glide.with(context).load(R.mipmap.start_level).into(bannerBack); Glide.with(context).load(R.mipmap.start_level).into(bannerBack);

View File

@ -8,7 +8,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@mipmap/start_level" /> />
<FrameLayout <FrameLayout
android:id="@+id/start_context" android:id="@+id/start_context"
@ -51,7 +51,7 @@
android:id="@+id/icon_start" android:id="@+id/icon_start"
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="12dp" android:layout_height="12dp"
android:src="@mipmap/icon_start" /> />
<TextView <TextView
android:id="@+id/total_star_value" android:id="@+id/total_star_value"
@ -118,7 +118,7 @@
android:id="@+id/icon_start_number" android:id="@+id/icon_start_number"
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="12dp" android:layout_height="12dp"
android:src="@mipmap/icon_start_number" /> />
<TextView <TextView
android:id="@+id/number_of_people_assisted" android:id="@+id/number_of_people_assisted"

View File

@ -7,6 +7,7 @@ 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.Application;
import android.app.Dialog; import android.app.Dialog;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.PendingIntent; import android.app.PendingIntent;
@ -312,6 +313,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
if (mTabButtonGroup.getCurPosition() != position) {
System.err.println("重新初始化IM");
RongcloudIMManager.connectIM(mContext.getApplication());
position = 0;
mTabButtonGroup.setCurPosition(0);
}
if (position != 0) { if (position != 0) {
loadPageData(position, true); loadPageData(position, true);
} }

View File

@ -82,7 +82,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
for (WeakReference<Activity> reference : CommonAppContext.activityList) { for (WeakReference<Activity> reference : CommonAppContext.activityList) {
builder.append(reference.get().getClass().getSimpleName()).append("\n"); builder.append(reference.get().getClass().getSimpleName()).append("\n");
} }
builder.append("内存:").append(DeviceUtils.getMemory(mContext)); builder.append("内存:").append(DeviceUtils.getMemoryToFormat(mContext));
if (debugView != null) { if (debugView != null) {
handler.post(() -> debugView.setText(builder.toString())); handler.post(() -> debugView.setText(builder.toString()));
} }