Parcourir la source

Merge branch 'sheep_develop' of 10.8.230.114:xmy_android/small_sheep_android into sheep_develop

hanjing il y a 7 ans
Parent
commit
ffa83e4104

+ 0 - 4
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -1,14 +1,10 @@
 package com.sheep.gamegroup.absBase;
 
-import android.app.Activity;
-import android.content.Context;
 import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
-import android.support.v4.app.FragmentActivity;
 import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
 import android.view.View;
 import android.view.Window;

+ 21 - 4
app/src/main/java/com/sheep/gamegroup/view/activity/ActVideoDetail.java

@@ -20,13 +20,13 @@ import android.widget.TextView;
 import android.widget.VideoView;
 
 import com.kfzs.duanduan.utils.StatusBarUtils;
-import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.absBase.BaseUMActivity;
 import com.sheep.gamegroup.absBase.IRefresh;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DiscoveryVideo;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ActionUtil;
+import com.sheep.gamegroup.util.ApiJSONUtil;
 import com.sheep.gamegroup.util.ApiUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.Jump2View;
@@ -42,7 +42,6 @@ import com.sheep.jiuyan.samllsheep.utils.G;
 import com.umeng.socialize.bean.SHARE_MEDIA;
 
 import java.util.ArrayList;
-import java.util.List;
 
 import butterknife.BindView;
 import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -126,7 +125,6 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
     private void loadVideoData(DiscoveryVideo discoveryVideo) {
         if (discoveryVideo == null) {
             ViewUtil.setText(video_like_tv, ViewUtil.BLOCK);
-            ViewUtil.setText(video_comment_tv, ViewUtil.BLOCK);
             ViewUtil.setText(video_title_tv, ViewUtil.BLOCK);
             ViewUtil.setText(video_share_tv, ViewUtil.BLOCK);
             ViewUtil.setVisibility2(video_focus_iv, false);
@@ -134,7 +132,6 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
         }
         ViewUtil.setAvatar(video_avatar_iv, discoveryVideo.getAvatar());
         ViewUtil.setText(video_like_tv, discoveryVideo.getLike());
-        ViewUtil.setText(video_comment_tv, discoveryVideo.getComment());
         ViewUtil.setText(video_title_tv, discoveryVideo.getTitle());
         ViewUtil.setText(video_share_tv, discoveryVideo.getShare());
         ViewUtil.setChecked(video_like_tv, discoveryVideo.getIs_like());
@@ -288,6 +285,26 @@ public class ActVideoDetail extends BaseUMActivity implements MediaPlayer.OnInfo
                 });
     }
 
+    @Override
+    protected void onResume() {
+        super.onResume();
+        //更新评论数量
+        SheepApp.getInstance().getNetComponent().getApiService().getGameUserAppCommentList(1,1, video_id, ApiJSONUtil.COMMENT_TYPE_VIDEO)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        ViewUtil.setText(video_comment_tv, baseMessage.getTotal());
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        ViewUtil.setText(video_comment_tv, baseMessage.getTotal());
+                    }
+                });
+    }
+
     private GestureDetector mGestureDetector;
 
     //播放或者暂停

+ 4 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActWeb.java

@@ -10,6 +10,7 @@ import android.os.Build;
 import android.os.Environment;
 import android.provider.MediaStore;
 import android.support.annotation.RequiresApi;
+import android.support.v7.app.ActionBar;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.View;
@@ -51,8 +52,6 @@ public class ActWeb extends BaseActWeb {
 
     @BindView(R.id.webview)
     WebView mWebView;
-    @BindView(R.id.layout_navigationBar)
-    View layout_navigationBar;
 
     private String title;//title为空时,不显示整个标题栏
     private boolean needJsInteract;//是否需要js交互,有js交互的会对url进行操作:拼接token到后面
@@ -468,6 +467,8 @@ public class ActWeb extends BaseActWeb {
 
     @Override
     public void showTitleBar(boolean isShow) {
-        ViewUtil.setVisibility(layout_navigationBar, isShow);
+        ActionBar actionBar = getSupportActionBar();
+        if(actionBar != null)
+            actionBar.hide();
     }
 }

+ 4 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -10,6 +10,7 @@ import android.os.Build;
 import android.os.Environment;
 import android.provider.MediaStore;
 import android.support.annotation.RequiresApi;
+import android.support.v7.app.ActionBar;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.View;
@@ -51,8 +52,6 @@ public class ActWebX5 extends BaseActWeb {
 
     @BindView(R.id.webview)
     WebView mWebView;
-    @BindView(R.id.layout_navigationBar)
-    View layout_navigationBar;
 
     private String title;//title为空时,不显示整个标题栏
     private boolean needJsInteract;//是否需要js交互,有js交互的会对url进行操作:拼接token到后面
@@ -469,7 +468,9 @@ public class ActWebX5 extends BaseActWeb {
 
     @Override
     public void showTitleBar(boolean isShow) {
-        ViewUtil.setVisibility(layout_navigationBar, isShow);
+        ActionBar actionBar = getSupportActionBar();
+        if(actionBar != null)
+            actionBar.hide();
     }
 
 }

+ 3 - 6
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtArticleComment.java

@@ -83,12 +83,9 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> implements
     //输入框
     private EditText input_comment_input;
 
-    //是否显示无数据占位图
-    protected void updateEmptyView() {
-        boolean isEmpty = list.isEmpty() && (article_id <= 0 || article == null);
-        if (useSelfEmpty())
-            CommonUtil.getInstance().updateEmptyView(empty_view, isEmpty);
-        ViewUtil.setVisibility(find_article_comment_title_rl, !list.isEmpty());
+    @Override
+    public boolean useSelfEmpty() {
+        return true;
     }
 
     @Override

+ 3 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -40,6 +40,7 @@ import com.sheep.gamegroup.util.MyFileNameGenerator;
 import com.sheep.gamegroup.util.RefreshUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.GameCertificationActivity;
 import com.sheep.jiuyan.samllsheep.service.AutoCheckService;
 import com.sheep.jiuyan.samllsheep.service.DownloadService;
@@ -397,10 +398,11 @@ public class SheepApp extends MultiDexApplication {
                 SysAppUtil.showVersionInfo(activity, SpUtils.getIgnoreMd5());
             } else if (YmConfig.isAvf(activity)) {
                 YmConfig.showTipDialog(activity, YmConfig.TYPE_ADD_VIEW);
+            } else if(activity instanceof ActMain){//进入主页时检查插件更新
+                PluginUtil.initPlugin();
             }
 
             if (mActivityCount == 0) {
-                PluginUtil.initPlugin();
                 if (ConfigUtil.getInstance().isUpgrade()) {
                     Beta.autoDownloadOnWifi = !BuildConfig.DEBUG;
                     Bugly.init(getApplicationContext(), Config.BUGLY_APPID, BuildConfig.DEBUG);

+ 17 - 16
app/src/main/java/com/sheep/jiuyan/samllsheep/service/ListenerShotNewService.java

@@ -63,22 +63,6 @@ public class ListenerShotNewService extends Service {
         if (intent != null) {
             userId = intent.getStringExtra(EXTRA_KEY_USER_ID);
         }
-        if(runningTaskUtil == null) {
-            //初始化获取当前应用的工具类
-            runningTaskUtil = new RunningTaskUtil(getApplicationContext());
-        }
-        if(manager == null) {
-            //开启监听
-            manager = ScreenShotListenManager.newInstance(getApplicationContext());
-            manager.setListener(
-                    new ScreenShotListenManager.OnScreenShotListener() {
-                        public void onShot(String imagePath) {
-                            addPng(imagePath);
-                        }
-                    }
-            );
-            manager.startListen();
-        }
 
 
         int msgId = 113922;
@@ -110,7 +94,24 @@ public class ListenerShotNewService extends Service {
                 .build();
         notification.flags |= Notification.FLAG_NO_CLEAR;
         //这里的id不能是0
+        // android 8.0 Context.startForegroundService() 函数将启动一个前台服务。现在,即使应用在后台运行,系统也允许其调用 Context.startForegroundService()。不过,应用必须在创建服务后的五秒内调用该服务的 startForeground() 函数
         startForeground(msgId, notification);
+        if(runningTaskUtil == null) {
+            //初始化获取当前应用的工具类
+            runningTaskUtil = new RunningTaskUtil(getApplicationContext());
+        }
+        if(manager == null) {
+            //开启监听
+            manager = ScreenShotListenManager.newInstance(getApplicationContext());
+            manager.setListener(
+                    new ScreenShotListenManager.OnScreenShotListener() {
+                        public void onShot(String imagePath) {
+                            addPng(imagePath);
+                        }
+                    }
+            );
+            manager.startListen();
+        }
         return super.onStartCommand(intent, flags, startId);
     }
     private ScreenShotListenManager manager;

+ 16 - 16
app/src/main/java/com/sheep/jiuyan/samllsheep/service/ListenerShotService.java

@@ -60,22 +60,6 @@ public class ListenerShotService extends Service {
         if (intent != null) {
             userId = intent.getStringExtra(EXTRA_KEY_USER_ID);
         }
-        if(runningTaskUtil == null) {
-            //初始化获取当前应用的工具类
-            runningTaskUtil = new RunningTaskUtil(getApplicationContext());
-        }
-        if(manager == null) {
-            //开启监听
-            manager = ScreenShotListenManager.newInstance(getApplicationContext());
-            manager.setListener(
-                    new ScreenShotListenManager.OnScreenShotListener() {
-                        public void onShot(String imagePath) {
-                            addPng(imagePath);
-                        }
-                    }
-            );
-            manager.startListen();
-        }
 
         Notification.Builder notificationBuilder = new Notification.Builder(getApplicationContext());
         //点击通知栏跳转到相应的应用里面
@@ -98,6 +82,22 @@ public class ListenerShotService extends Service {
         notification.flags |= Notification.FLAG_NO_CLEAR;
         //这里的id不能是0
         startForeground(113922, notification);
+        if(runningTaskUtil == null) {
+            //初始化获取当前应用的工具类
+            runningTaskUtil = new RunningTaskUtil(getApplicationContext());
+        }
+        if(manager == null) {
+            //开启监听
+            manager = ScreenShotListenManager.newInstance(getApplicationContext());
+            manager.setListener(
+                    new ScreenShotListenManager.OnScreenShotListener() {
+                        public void onShot(String imagePath) {
+                            addPng(imagePath);
+                        }
+                    }
+            );
+            manager.startListen();
+        }
         return super.onStartCommand(intent, flags, startId);
     }
     private ScreenShotListenManager manager;

+ 12 - 8
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/view/EggView.java

@@ -109,16 +109,20 @@ public class EggView extends View {
 
     //退出时销毁
     public void onDestroy() {
-        for (int i = 0; i < eggs.length; i++) {
-            if (eggs[i] != null) {
-                eggs[i].destroy();
+        if(eggs != null) {
+            for (int i = 0; i < eggs.length; i++) {
+                if (eggs[i] != null) {
+                    eggs[i].destroy();
+                }
             }
         }
-        for (Bitmap item : bitmaps) {
-            try {
-                item.recycle();
-            } catch (Exception e) {
-                e.printStackTrace();
+        if(bitmaps != null) {
+            for (Bitmap item : bitmaps) {
+                try {
+                    item.recycle();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
         }
     }

+ 4 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/TitleBarUtils.java

@@ -58,8 +58,10 @@ public class TitleBarUtils {
      */
     public TitleBarUtils setTitle(Activity activity, String title) {
         TextView titleView = activity.getWindow().getDecorView().findViewById(R.id.txt_baseactivity_title);
-        titleView.setVisibility(View.VISIBLE);
-        titleView.setText(title == null ? "" : title);
+        if(titleView != null) {
+            titleView.setVisibility(View.VISIBLE);
+            titleView.setText(title == null ? "" : title);
+        }
         return mTitleBarUtils;
     }