Parcourir la source

remove the animation on home page because of making onStop delay 10 sec then memory leak

hanjing il y a 7 ans
Parent
commit
6d5b7fd8f7

+ 8 - 16
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -152,22 +152,7 @@ public abstract class BaseActivity extends RxAppCompatActivity {
     }
 
     @Override
-    protected void onStop() {
-        Log.e("Destroy", "----------start Base stop----------");
-        super.onStop();
-        Log.e("Destroy", "----------end Base stop----------");
-    }
-
-    @Override
-    protected void onPause() {
-        Log.e("Destroy", "----------start Base pause----------");
-        super.onPause();
-        Log.e("Destroy", "----------end Base pause----------");
-    }
-    
-    @Override
     protected void onDestroy() {
-        Log.e("Destroy", "----------start Base destroy----------");
         fixHuaweiLeak();
         try {
             if (needButterKnife() && this.unbinder != null) {
@@ -210,7 +195,14 @@ public abstract class BaseActivity extends RxAppCompatActivity {
                 }
                 if (leakFields[i] != null) {
                     leakFields[i].setAccessible(true);
-                    leakFields[i].set(imm, null);
+                    Object obj_get = leakFields[i].get(imm);
+                    if(obj_get!=null && obj_get instanceof View){
+                        View v_get = (View) obj_get;
+                        if(v_get.getContext() == this){
+                            leakFields[i].set(imm, null);
+                        }
+                    }
+
                 }
             } catch (Throwable t) {
                 t.printStackTrace();

+ 16 - 12
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -298,7 +298,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
 
     }
 
-     /**
+    /**
      * 兑换红包弹窗
      *
      * @param mActivity 当前Activity的,
@@ -366,6 +366,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     public void toSearchActivity() {
         Jump2View.getInstance().goAppTaskSearch(activity, null);
     }
+
     @OnClick(R.id.home_search_msg_iv)
     public void toActMsg() {
         startActivity(new Intent(activity, ActMsg.class));
@@ -616,13 +617,14 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
         }
         //每次进入主页都刷新一下url配置信息
         CommonUtil.getInstance().initUrlConfigByNet(null, null);
-        if(TestUtil.isLTVersion3_4_5())//3.4.5以前版本才调用下面的方法
+        if (TestUtil.isLTVersion3_4_5())//3.4.5以前版本才调用下面的方法
             isShowRedPackage();
     }
 
 
     //banner的高度
     private int bannerHeight = G.WIDTH * 17 / 40;
+
     public void initView() {
         try {
             EventBus.getDefault().register(this);
@@ -682,7 +684,6 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
             }
         });
         CommonUtil.getInstance().reflex(tabLayout, activity);
-        setAnimation(ivDuty);
         //只显示图片并且充满的homeList
         fullHomeList.clear();
         full_home_list_rv.setHasFixedSize(true);
@@ -718,13 +719,15 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
      * @param imageView 设置动画的imageview
      */
     private void setAnimation(ImageView imageView) {
-        TranslateAnimation animation = new TranslateAnimation(0, -5, 0, 0);
-        animation.setInterpolator(new OvershootInterpolator());
-        animation.setDuration(150);
-        animation.setRepeatCount(Integer.MAX_VALUE);//根据产品要求,要一直晃动
-        animation.setRepeatMode(Animation.REVERSE);
-        if (imageView != null)
-            imageView.startAnimation(animation);
+        if (imageView.getAnimation() == null) {
+            TranslateAnimation animation = new TranslateAnimation(0, -5, 0, 0);
+            animation.setInterpolator(new OvershootInterpolator());
+            animation.setDuration(150);
+            animation.setRepeatCount(Integer.MAX_VALUE);//根据产品要求,要一直晃动
+            animation.setRepeatMode(Animation.REVERSE);
+            if (imageView != null)
+                imageView.startAnimation(animation);
+        }
     }
 
     private void loadUserInfo() {
@@ -1307,7 +1310,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     @Override
     public void failhomeList(BaseMessage baseMessage) {
         checkAndInitView();
-        if(homeListEntitys.isEmpty() && fullHomeList.isEmpty())
+        if (homeListEntitys.isEmpty() && fullHomeList.isEmpty())
             home_list_gridview_layout.setVisibility(View.GONE);
 
     }
@@ -1335,7 +1338,6 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
         if (onResumeCount > 0)
             refreshTaskList();
         onResumeCount++;
-        setAnimation(ivDuty);
     }
 
 
@@ -1720,8 +1722,10 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
 //        }
         adpHomeListGrideview.notifyDataSetChanged();
     }
+
     @BindView(R.id.home_search_msg_tv)
     TextView home_search_msg_tv;
+
     /**
      * 获取是否有未读消息并更新图标
      */

+ 0 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -442,7 +442,6 @@ public class SheepApp extends MultiDexApplication {
 
         @Override
         public void onActivityStopped(Activity activity) {
-            Log.e("Destroy", "----------start App stop----------");
             mActivityCount--;
             if (!UMConfigUtils.isNotNeedAct(activity))
                 UMConfigUtils.onPageEnd(activity);
@@ -463,7 +462,6 @@ public class SheepApp extends MultiDexApplication {
 
         @Override
         public void onActivityDestroyed(Activity activity) {
-            Log.e("Destroy", "----------start App destroy----------");
             if (YmConfig.isAvf(activity)) {
                 YmConfig.disTipDialog();
             }