Просмотр исходного кода

合并资讯详情与资讯详情的评论列表

zengjiebin лет назад: 7
Родитель
Сommit
4bb112eb84

+ 3 - 7
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -1616,11 +1616,7 @@ public class Jump2View {
      * @param item
      */
     public void goFindInformation(Activity activity, Article item) {
-        Intent intent = new Intent(activity, ActArticle.class);
-        intent.putExtra("id", item.getId());
-        intent.putExtra("title", item.getTitle());
-        activity.startActivity(intent);
-        USER_FIND_APP_ORDER.onEvent();
+        goFindInformation(activity, item.getTitle(), item.getId());
     }
 
     /**
@@ -1631,8 +1627,8 @@ public class Jump2View {
      * @param id
      */
     public void goFindInformation(Activity activity, String title, int id) {
-        Intent intent = new Intent(activity, ActArticle.class);
-        intent.putExtra("id", id);
+        Intent intent = new Intent(activity, ActArticleComment.class);
+        DataUtil.putObject(intent, id);
         intent.putExtra("title", title);
         activity.startActivity(intent);
         USER_FIND_APP_ORDER.onEvent();

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActArticle.java

@@ -91,7 +91,7 @@ public class ActArticle extends BaseActivity implements Action1<Integer> {
     private WebViewVideoHelper webViewVideoHelper = new WebViewVideoHelper();
     @Override
     public void initView() {
-        id = getIntent().getIntExtra("id", 0);
+        id = DataUtil.getObject(getIntent(), Integer.class);
 
         TitleBarUtils.getInstance()
                 .setTitle(this, "详情")
@@ -334,7 +334,7 @@ public class ActArticle extends BaseActivity implements Action1<Integer> {
         }
         CommonUtil.getInstance().updateEmptyView(empty_view, list.isEmpty());
         refresh.setRefreshing(false);
-        view_list.getAdapter().notifyDataSetChanged();
+        ViewUtil.notifyDataSetChanged(view_list);
     }
 
 

+ 35 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActArticleComment.java

@@ -1,6 +1,9 @@
 package com.sheep.gamegroup.view.activity;
 
+import android.content.res.Configuration;
 import android.support.v4.app.Fragment;
+import android.view.KeyEvent;
+import android.view.WindowManager;
 
 import com.sheep.gamegroup.absBase.BaseContainerActivity;
 import com.sheep.gamegroup.util.DataUtil;
@@ -19,4 +22,36 @@ public class ActArticleComment extends BaseContainerActivity {
         fragment.setArticle_id(article_id);
         return fragment;
     }
+    @Override
+    public boolean onKeyUp(int keyCode, KeyEvent event) {
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_BACK:
+                if(fragment instanceof FgtArticleComment)
+                    ((FgtArticleComment) fragment).onBackUp();
+                return true;
+            default:
+                return super.onKeyUp(keyCode, event);
+        }
+    }
+    @Override
+    public void onBackPressed() {
+        if(fragment instanceof FgtArticleComment && ((FgtArticleComment) fragment).onBackPressed()){
+            return;
+        }
+        super.onBackPressed();
+    }
+    @Override
+    public void onConfigurationChanged(Configuration config) {
+        super.onConfigurationChanged(config);
+        switch (config.orientation) {
+            case Configuration.ORIENTATION_LANDSCAPE:
+                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+                break;
+            case Configuration.ORIENTATION_PORTRAIT:
+                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+                break;
+        }
+    }
 }

+ 53 - 51
app/src/main/java/com/sheep/gamegroup/view/activity/ActInvitation.java

@@ -306,59 +306,61 @@ public class ActInvitation extends BaseActivity {
         final ImageView image_bottom = itemView.findViewById(R.id.image_bottom);
         final ImageView image_logo = itemView.findViewById(R.id.image_logo);
         final TextView image_tip = itemView.findViewById(R.id.image_tip);
-        viewPager.postDelayed(new Runnable() {
-            @Override
-            public void run() {
-                if (image_container == null || viewPager == null || image_bottom == null || image_logo == null || image_bottom_top == null || image_tip == null) {
-                    return;
-                }
-                image_container.setVisibility(View.VISIBLE);
-                int vWidth = viewPager.getWidth();
-                int vHeight = viewPager.getHeight();
-                float imgWidth = vWidth;
-                float imgHeight = vHeight;
-                int imgHeightPadding = 0;
-                if (vHeight * 1.0F / vWidth > h * 1.0F / w) {//图片上下有padding
-                    imgHeight = imgWidth * h / w;
-                    imgHeightPadding = (int) ((vHeight - imgHeight) / 2);
-                } else {//图片左右有padding
-                    imgWidth = imgHeight * w / h;
-                }
+        if(viewPager != null) {
+            viewPager.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    if (image_container == null || viewPager == null || image_bottom == null || image_logo == null || image_bottom_top == null || image_tip == null) {
+                        return;
+                    }
+                    image_container.setVisibility(View.VISIBLE);
+                    int vWidth = viewPager.getWidth();
+                    int vHeight = viewPager.getHeight();
+                    float imgWidth = vWidth;
+                    float imgHeight = vHeight;
+                    int imgHeightPadding = 0;
+                    if (vHeight * 1.0F / vWidth > h * 1.0F / w) {//图片上下有padding
+                        imgHeight = imgWidth * h / w;
+                        imgHeightPadding = (int) ((vHeight - imgHeight) / 2);
+                    } else {//图片左右有padding
+                        imgWidth = imgHeight * w / h;
+                    }
 
-                float containerWidthRadius = 60 / 216F;
-                float containerHeightRadius = 70 / 216F;
-                float rqRadius = 53 / 216F;
-                float tipRadius = 5 / 216F;
-                float radius = 4 / 216F;
-                float topRadius = 2 / 216F;
-                float logoRadius = rqRadius * 16 / 68;
-                GlideImageLoader.saveAndSetRqImageDisHardConfig(image_bottom, item.getLink(), (int) (imgWidth * rqRadius));
-                //重新设置logo的宽高
-                ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
-                layoutParams.width = (int) (imgWidth * logoRadius);
-                layoutParams.height = (int) (imgWidth * logoRadius);
-                image_logo.setLayoutParams(layoutParams);
-                //重新设置二维码上部的距离
-                ViewGroup.LayoutParams layoutParamsTop = image_bottom_top.getLayoutParams();
-                layoutParamsTop.height = (int) (imgWidth * topRadius);
-                image_bottom_top.setLayoutParams(layoutParamsTop);
-                //重新设置《扫我开始赚钱》的高度
-                ViewGroup.LayoutParams layoutParamsTip = image_tip.getLayoutParams();
-                layoutParamsTip.height = (int) (imgWidth * (tipRadius + topRadius * 3 / 2));
-                image_tip.setLayoutParams(layoutParamsTip);
-                image_tip.setTextSize(imgWidth * tipRadius / G.DENSITY);
-                //重新设置整个二维码外容器的高度
-                RelativeLayout.LayoutParams layoutParamsContainer = (RelativeLayout.LayoutParams) image_container.getLayoutParams();
-                layoutParamsContainer.width = (int) (imgWidth * containerWidthRadius);
-                layoutParamsContainer.height = (int) (imgWidth * containerHeightRadius);
-                layoutParamsContainer.bottomMargin = imgHeightPadding;
-                image_container.setLayoutParams(layoutParamsContainer);
-                Drawable bg = image_container.getBackground();
-                if (bg instanceof GradientDrawable) {
-                    ((GradientDrawable) bg).setCornerRadius(imgWidth * radius);
+                    float containerWidthRadius = 60 / 216F;
+                    float containerHeightRadius = 70 / 216F;
+                    float rqRadius = 53 / 216F;
+                    float tipRadius = 5 / 216F;
+                    float radius = 4 / 216F;
+                    float topRadius = 2 / 216F;
+                    float logoRadius = rqRadius * 16 / 68;
+                    GlideImageLoader.saveAndSetRqImageDisHardConfig(image_bottom, item.getLink(), (int) (imgWidth * rqRadius));
+                    //重新设置logo的宽高
+                    ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
+                    layoutParams.width = (int) (imgWidth * logoRadius);
+                    layoutParams.height = (int) (imgWidth * logoRadius);
+                    image_logo.setLayoutParams(layoutParams);
+                    //重新设置二维码上部的距离
+                    ViewGroup.LayoutParams layoutParamsTop = image_bottom_top.getLayoutParams();
+                    layoutParamsTop.height = (int) (imgWidth * topRadius);
+                    image_bottom_top.setLayoutParams(layoutParamsTop);
+                    //重新设置《扫我开始赚钱》的高度
+                    ViewGroup.LayoutParams layoutParamsTip = image_tip.getLayoutParams();
+                    layoutParamsTip.height = (int) (imgWidth * (tipRadius + topRadius * 3 / 2));
+                    image_tip.setLayoutParams(layoutParamsTip);
+                    image_tip.setTextSize(imgWidth * tipRadius / G.DENSITY);
+                    //重新设置整个二维码外容器的高度
+                    RelativeLayout.LayoutParams layoutParamsContainer = (RelativeLayout.LayoutParams) image_container.getLayoutParams();
+                    layoutParamsContainer.width = (int) (imgWidth * containerWidthRadius);
+                    layoutParamsContainer.height = (int) (imgWidth * containerHeightRadius);
+                    layoutParamsContainer.bottomMargin = imgHeightPadding;
+                    image_container.setLayoutParams(layoutParamsContainer);
+                    Drawable bg = image_container.getBackground();
+                    if (bg instanceof GradientDrawable) {
+                        ((GradientDrawable) bg).setCornerRadius(imgWidth * radius);
+                    }
                 }
-            }
-        }, time);
+            }, time);
+        }
     }
 
     private int curPosition = 0;

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

@@ -17,6 +17,7 @@ import com.sheep.gamegroup.util.Conversion;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
+import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
@@ -202,8 +203,7 @@ public abstract class BaseListFragment3<T> extends BaseRefreshLoadMoreFragment{
     //通过刷新来重新加载数据
     public void refreshData() {
         clear();
-        if (view_list != null)
-            view_list.getAdapter().notifyDataSetChanged();
+        ViewUtil.notifyDataSetChanged(view_list);
         initData();
     }
 
@@ -221,7 +221,7 @@ public abstract class BaseListFragment3<T> extends BaseRefreshLoadMoreFragment{
             return;
         }
         updateEmptyView();
-        view_list.getAdapter().notifyDataSetChanged();
+        ViewUtil.notifyDataSetChanged(view_list);
         refreshOrLoadMoreComplete();
     }
 

+ 386 - 4
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtArticleComment.java

@@ -1,41 +1,75 @@
 package com.sheep.gamegroup.view.fragment;
 
+import android.app.Activity;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
 import android.widget.EditText;
+import android.widget.ImageView;
 import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import com.scwang.smartrefresh.layout.SmartRefreshLayout;
 import com.scwang.smartrefresh.layout.api.RefreshLayout;
 import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
+import com.sheep.gamegroup.event.BigEvent;
+import com.sheep.gamegroup.greendao.download.DownLoadInfo;
+import com.sheep.gamegroup.helper.TaskHelper;
 import com.sheep.gamegroup.model.api.ApiService;
+import com.sheep.gamegroup.model.entity.Applications;
+import com.sheep.gamegroup.model.entity.Article;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.UserComment;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ApiJSONUtil;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.DownloadUtil;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.RefreshUtil;
 import com.sheep.gamegroup.util.TestUtil;
+import com.sheep.gamegroup.util.TimeUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.viewHelper.WebViewVideoHelper;
 import com.sheep.gamegroup.view.adapter.AdpArticleComment;
 import com.sheep.gamegroup.view.dialog.DialogSuccessUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import org.afinal.simplecache.ApiKey;
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 import butterknife.BindView;
 import io.reactivex.Observable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
+
+import static android.content.Intent.ACTION_PACKAGE_ADDED;
+import static android.content.Intent.ACTION_PACKAGE_REMOVED;
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_SHARE;
 
 /**
  * Created by realicing on 2018/11/2.
  * realicing@sina.com
  * 用户评论详情界面
  */
-public class FgtArticleComment extends BaseListFragment3<UserComment> {
+public class FgtArticleComment extends BaseListFragment3<UserComment> implements Action1<Integer> {
 
     @Override
     public int getLayoutId() {
@@ -51,8 +85,19 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> {
 
     @Override
     public void initView() {
-        TitleBarUtils.getInstance().setTitle(mView, "评论")
-                .setTitleFinish(mView, activity);
+        TitleBarUtils.getInstance().setTitle(getView(), "详情")
+                .setTitleFinish(getView(), activity)
+                .setRightImgBotton(getView(), R.mipmap.share, new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        FIND_SHARE.onEvent("find_id", article_id);
+                        if(article == null){
+                            Jump2View.getInstance().tryShare(activity, "find_share_url", "find_id", article_id);
+                        } else {
+                            Jump2View.getInstance().tryShare(activity, "find_share_url", "find_id", article_id, article.getDes());
+                        }
+                    }
+                });
         smartRefreshLayout = refresh;
         refresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
             @Override
@@ -79,9 +124,19 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> {
                 commitContent(content);
             }
         });
+        EventBus.getDefault().register(this);
+
+    }
 
+    @Override
+    public void refreshData() {
+        initArticle();
+        super.refreshData();
     }
 
+    private Article article;
+
+
     //用户评论一个用户对游戏的评论
     private void commitContent(String content) {
         if (TestUtil.isDev()) G.showToast("评论内容:" + content);
@@ -112,10 +167,19 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> {
 
     //    ------------------------------start header------------------------------------
     private View headerView;
+    private View find_information_bottom_item;
+    private View find_information_bottom_item_line;
+    private View find_information_bottom_item_game;
 
     //初始化headerView
     private void initHeaderView() {
-        headerView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.include_line_title_more, null);
+        headerView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.header_act_article, null);
+        find_information_bottom_item = headerView.findViewById(R.id.find_information_bottom_item);
+        find_information_bottom_item_line = headerView.findViewById(R.id.find_information_bottom_item_line);
+        find_information_bottom_item_game = headerView.findViewById(R.id.find_information_bottom_item_game);
+        ViewUtil.setVisibility(find_information_bottom_item, false);
+        ViewUtil.setVisibility(find_information_bottom_item_line, false);
+        ViewUtil.setVisibility(find_information_bottom_item_game, false);
     }
 
     //    ------------------------------end header------------------------------------
@@ -145,10 +209,328 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> {
     }
 
 
+    private WebViewVideoHelper webViewVideoHelper = new WebViewVideoHelper();
+    private void loadTop(View itemView) {
+        TextView find_information_name = (TextView) itemView.findViewById(R.id.find_information_name);
+        TextView find_information_time = (TextView) itemView.findViewById(R.id.find_information_time);
+        TextView find_information_look = (TextView) itemView.findViewById(R.id.find_information_look);
+        ViewUtil.setText(find_information_name, article.getTitle());
+        ViewUtil.setText(find_information_time, String.format(Locale.CHINA, "发布时间:%s", TimeUtil.TimeStamp2Date(article.getCreated_at(), "yyyy-MM-dd HH:mm")));
+        ViewUtil.setText(find_information_look, article.getClicks());
+
+        WebView webView = itemView.findViewById(R.id.find_information_content_wb);
+        webViewVideoHelper.init(activity, webView);
+        ViewUtil.loadDataWithBaseURL(webView, article.getContent());
+
+
+    }
+    private TaskHelper taskHelper = new TaskHelper(this);
+
+    private void loadBottom() {
+        if (taskHelper.hasTask()) {
+            taskHelper.loadTask(find_information_bottom_item);
+        } else {
+            find_information_bottom_item.setVisibility(View.GONE);
+        }
+        find_information_bottom_item_line.setVisibility(taskHelper.hasTask() && findApp != null ? View.VISIBLE : View.GONE);
+        if (findApp != null) {
+            loadGame(find_information_bottom_item_game);
+        } else {
+            find_information_bottom_item_game.setVisibility(View.GONE);
+        }
+    }
+    private void loadGame(View itemView) {
+        itemView.setVisibility(View.VISIBLE);
+        ImageView find_information_game_icon = (ImageView) itemView.findViewById(R.id.find_information_game_icon);
+        TextView find_information_game_name = (TextView) itemView.findViewById(R.id.find_information_game_name);
+        TextView find_information_game_surplus = (TextView) itemView.findViewById(R.id.find_information_game_surplus);
+        TextView find_information_game_time = (TextView) itemView.findViewById(R.id.find_information_game_time);
+        TextView find_information_game_task_center = (TextView) itemView.findViewById(R.id.find_information_game_task_center);
+        GlideImageLoader.setGameImage(find_information_game_icon, findApp.getIcon());
+        ViewUtil.setText(find_information_game_name, findApp.getName());
+        final boolean isNeedReservation = !findApp.isCanDownload();//这里认为只有两种状态:可下载与预约下载
+        ViewUtil.setText(find_information_game_surplus);
+        if (isNeedReservation)
+            ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "开放时间:%s", TimeUtil.TimeStamp2Date(findApp.getDownload_at(), "yyyy-MM-dd\u0020HH:mm")));
+        else
+            ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "厂商:%s\u0020包体大小:%sM", findApp.getManufacturer(), findApp.getPackage_size()));
+        find_information_game_task_center.setVisibility(View.VISIBLE);
+
+        updateView(activity, findApp, find_information_game_task_center);
+
+        itemView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Jump2View.getInstance().goFindGame(activity, article);
+            }
+        });
+    }
+
+    public void initArticle() {
+        if(article == null) {//第一次才调用该方法,之后都是刷新操作
+            Article data = DataUtil.getInstance().getCacheResult(ApiKey.articlesItem(article_id), Article.class);
+            if (data != null) {
+                loadFindItem(data);
+            }
+        }
+        SheepApp.getInstance().getNetComponent().getApiService().getFindDetail(article_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.articlesItem(article_id));
+                        if (isNewData) {
+                            Article data = baseMessage.getData(Article.class);
+                            loadFindItem(data);
+                        }
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        taskHelper.clear();
+                    }
+                });
+    }
+    private void loadFindItem(Article data) {
+        if (data != null) {
+            taskHelper.clear();
+            article = data;
+            if (article.getRelease_task_id() != 0) {//包含任务
+                taskHelper.initAcceptedTask(activity, article.getRelease_task_id());
+            }
+            if (article.getApplication_id() != 0) {//包含游戏
+                initFindApp(article.getApplication_id());
+            }
+            loadTop(headerView);
+        }
+    }
+
+    private Applications findApp;
+
+    private void initFindApp(final int application_id) {
+        if(findApp == null) {
+            Applications cacheResult = DataUtil.getInstance().getCacheResult(ApiKey.applications(application_id), Applications.class);
+            if (cacheResult != null) {
+                findApp = cacheResult;
+                loadGame(find_information_bottom_item_game);
+            }
+        }
+        SheepApp.getInstance().getNetComponent().getApiService().getAppDetail(application_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.applications(application_id));
+                        if (isNewData) {
+                            findApp = baseMessage.getData(Applications.class);
+                            loadGame(find_information_bottom_item_game);
+                        }
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+                });
+    }
     @Override
     protected Class<UserComment> getTClass() {
         return UserComment.class;
     }
 
+    private Map<String, TextView> downLoadTextViewMap = new HashMap<>();
+
+    //获取任务对应的TextView来更新进度
+    private TextView getTextViewByTask(DownLoadInfo task) {
+        return getTextViewByKey(task.getMDownloadUrl());
+    }
 
+    private TextView getTextViewByKey(String key) {
+        if (downLoadTextViewMap.containsKey(key))
+            return downLoadTextViewMap.get(key);
+        return null;
+    }
+
+    //更新按钮状态与添加点击事件
+    private void updateView(Activity activity, Applications findApp, TextView textView) {
+        if (findApp.isCanDownload()) {//可下载
+            downLoadTextViewMap.put(findApp.getDownload_link(), textView);
+            downLoadTextViewMap.put(findApp.getPackage_name(), textView);
+            findApp.getFindAppHelper().updateDownloadTaskView(activity, findApp, textView);
+        } else {//预约下载
+            findApp.getFindAppHelper().updateReservationView(activity, findApp, textView);
+        }
+    }
+
+    //下载状态监听
+
+    void onPre(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText("准备下载中");
+        }
+    }
+
+    void taskStart(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText("开始下载中");
+        }
+    }
+
+    void taskResume(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText("恢复下载中");
+        }
+    }
+
+    //在这里处理任务执行中的状态,如进度进度条的刷新
+    protected void running(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText(String.format(Locale.CHINA, "%d%%(%s)", Math.abs(task.getMPercent()), task.getAverageSpeed()));//添加下载速度
+        }
+    }
+
+    void taskStop(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText(CommonUtil.CONTINUE_DOWNLOAD);
+        }
+    }
+
+    void taskCancel(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText("已经取消");
+        }
+    }
+
+    void taskFail(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText(CommonUtil.FAIL_DOWNLOAD);
+        }
+    }
+
+    void taskComplete(DownLoadInfo task) {
+        TextView textView = getTextViewByTask(task);
+        if (textView != null) {
+            textView.setText(CommonUtil.START_INSTALL);
+        }
+        if (findApp != null && TextUtils.equals(task.getMDownloadUrl(), findApp.getDownload_link()))
+            findApp.updateState(DownloadUtil.STATUS_FINISH);
+    }
+
+    @Subscribe
+    public void onEventMainThread(BigEvent event) {
+        switch (event.getEventTypes()) {
+            case ONFRESH_TRYMAKEMANY_PAGE:
+                taskHelper.refreshTask();
+                break;
+        }
+        if (event.getData() instanceof DownLoadInfo) {
+            DownLoadInfo task = (DownLoadInfo) event.getData();
+            switch (event.getEventTypes()) {
+                case DOWNLOAD_RUNNING:
+                    running(task);
+                    break;
+                case DOWNLOAD_STOP:
+                    taskStop(task);
+                    break;
+                case DOWNLOAD_COMPLETE:
+                    taskComplete(task);
+                    break;
+                case DOWNLOAD_CANCEL:
+                    taskCancel(task);
+                    break;
+                case DOWNLOAD_FAIL:
+                    taskFail(task);
+                    break;
+            }
+        }
+    }
+
+    @Subscribe
+    public void onEventMainThread(Intent intent) {
+        if (intent != null && intent.getAction() != null && intent.getDataString() != null && intent.getDataString().contains("package:")) {
+            String packageName = intent.getDataString().replace("package:", "");
+
+            TextView textView = getTextViewByKey(packageName);
+            if (textView != null && findApp != null) {
+                switch (intent.getAction()) {
+                    case ACTION_PACKAGE_ADDED:
+                        textView.setText(CommonUtil.GAME_OPEN);
+                        break;
+                    case ACTION_PACKAGE_REMOVED:
+                        String path = PackageUtil.isExistsFile(packageName, findApp.getDownload_url());
+                        if (TextUtils.isEmpty(path)) {
+                            textView.setText(CommonUtil.START_DOWNLOAD);
+                        } else {
+                            textView.setText(CommonUtil.START_INSTALL);
+                        }
+                        break;
+                }
+            }
+
+            if (findApp != null && TextUtils.equals(packageName, findApp.getPackage_names())) {
+                switch (intent.getAction()) {
+                    case ACTION_PACKAGE_ADDED:
+                        findApp.updateState(DownloadUtil.STATUS_INSTALLED);
+                        break;
+                    case ACTION_PACKAGE_REMOVED:
+                        String path = PackageUtil.isExistsFile(packageName, findApp.getDownload_url());
+                        if (TextUtils.isEmpty(path)) {
+                            findApp.updateState(DownloadUtil.STATUS_INIT);
+                        } else {
+                            findApp.updateState(DownloadUtil.STATUS_FINISH);
+                        }
+                        break;
+                }
+            }
+        }
+    }
+
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        taskHelper.onResume();
+        webViewVideoHelper.onResume();
+    }
+    @Override
+    public void onPause() {
+        super.onPause();
+        webViewVideoHelper.onPause();
+    }
+    @Override
+    public void onDestroy() {
+//        LogUtil.logI("释放资源");
+        EventBus.getDefault().unregister(this);
+        taskHelper.destroy();
+        webViewVideoHelper.onDestroy();
+        super.onDestroy();
+    }
+
+    @Override
+    public void call(Integer integer) {
+        switch (integer) {
+            case 1://刷新底部
+                loadBottom();
+                break;
+        }
+    }
+
+
+
+    public boolean onBackUp() {
+        webViewVideoHelper.onBackUp();
+        return true;
+    }
+    public boolean onBackPressed() {
+        return webViewVideoHelper.onBackPressed();
+    }
 }

+ 107 - 0
app/src/main/res/layout/header_act_article.xml

@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@color/white"
+    android:padding="@dimen/content_padding">
+
+    <TextView
+        android:id="@+id/find_information_name"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/app_name"
+        android:textColor="#020202"
+        android:textSize="15sp"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/find_information_time"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/dp_10"
+        android:text="@string/app_name"
+        android:textColor="#989898"
+        android:textSize="13sp"
+        app:layout_constraintTop_toBottomOf="@+id/find_information_name" />
+
+    <ImageView
+        android:id="@+id/find_information_eye"
+        android:layout_width="20dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/content_padding_20"
+        android:adjustViewBounds="true"
+        android:scaleType="fitXY"
+        android:src="@mipmap/watch"
+        app:layout_constraintBottom_toBottomOf="@+id/find_information_time"
+        app:layout_constraintStart_toEndOf="@+id/find_information_time"
+        app:layout_constraintTop_toTopOf="@+id/find_information_time" />
+
+    <TextView
+        android:id="@+id/find_information_look"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="@dimen/dp_10"
+        android:text="@string/app_name"
+        android:textColor="#989898"
+        android:textSize="13sp"
+        app:layout_constraintBaseline_toBaselineOf="@+id/find_information_time"
+        app:layout_constraintStart_toEndOf="@+id/find_information_eye" />
+
+    <View
+        android:id="@+id/find_information_line"
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:layout_marginTop="@dimen/content_padding_10"
+        android:background="@color/theme_app_divider_color"
+        app:layout_constraintTop_toBottomOf="@+id/find_information_time" />
+
+    <WebView
+        android:id="@+id/find_information_content_wb"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/content_padding_10"
+        app:layout_constraintTop_toBottomOf="@+id/find_information_line"
+        tools:ignore="WebViewLayout" />
+
+    <include
+        android:id="@+id/find_information_bottom_item"
+        layout="@layout/find_information_bottom_item"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="12dp"
+        app:layout_constraintTop_toBottomOf="@id/find_information_content_wb" />
+
+    <View
+        android:id="@+id/find_information_bottom_item_line"
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:layout_marginTop="@dimen/content_padding"
+        android:background="@color/theme_app_divider_color"
+        app:layout_constraintTop_toBottomOf="@id/find_information_bottom_item" />
+
+    <include
+        android:id="@+id/find_information_bottom_item_game"
+        layout="@layout/find_information_bottom_item_game"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="12dp"
+        android:background="@color/white"
+        app:layout_constraintTop_toBottomOf="@id/find_information_bottom_item_line" />
+
+    <RelativeLayout
+        style="@style/style_wc_rl"
+        app:layout_constraintTop_toBottomOf="@id/find_information_bottom_item_game">
+
+        <TextView
+            style="@style/style_wc_line_title"
+            android:text="用户评价" />
+
+        <TextView
+            style="@style/style_wc_more"
+            android:text="更多"
+            android:visibility="invisible" />
+    </RelativeLayout>
+</android.support.constraint.ConstraintLayout>