Parcourir la source

tune up find list page

billyyoyo il y a 5 ans
Parent
commit
feea254e62

+ 13 - 14
app/src/main/java/com/sheep/gamegroup/module/find/activity/ActFind.java

@@ -4,7 +4,6 @@ import android.support.v4.app.Fragment;
 
 import com.sheep.gamegroup.absBase.BaseContainerActivity;
 import com.sheep.gamegroup.model.entity.ArticleTag;
-import com.sheep.gamegroup.module.find.fragment.FgtFind2;
 import com.sheep.gamegroup.view.fragment.BaseListFragment5;
 import com.sheep.gamegroup.view.fragment.FgtFindChild;
 import com.sheep.jiuyan.samllsheep.R;
@@ -33,18 +32,18 @@ public class ActFind extends BaseContainerActivity {
     @Override
     protected Fragment initFragment() {
         int forWhat = getIntent().getIntExtra("for_what", 0);
-        if (forWhat == FOR_GAME) {
-            int forType = getIntent().getIntExtra("for_type", 0);
-            int forSubtype = getIntent().getIntExtra("for_subtype", 0);
-            TitleBarUtils.getInstance()
-                    .setShowOrHide(this, true)
-                    .setTitle(this, forSubtype == 1 ? "游戏资讯" : "活动中心")
-                    .setTitleFinish(this);
-            FgtFindChild fgt = FgtFindChild.newInstance(new ArticleTag(-forType, forSubtype));
-            fgt.setRefreshOnType(BaseListFragment5.REFRESH_ON_CREATE);
-            return fgt;
-        } else {
-            return new FgtFind2();
-        }
+//        if (forWhat == FOR_GAME) {
+        int forType = getIntent().getIntExtra("for_type", 0);
+        int forSubtype = getIntent().getIntExtra("for_subtype", 0);
+        TitleBarUtils.getInstance()
+                .setShowOrHide(this, true)
+                .setTitle(this, forSubtype == 1 ? "游戏资讯" : "活动中心")
+                .setTitleFinish(this);
+        FgtFindChild fgt = FgtFindChild.newInstance(new ArticleTag(-forType, forSubtype));
+        fgt.setRefreshOnType(BaseListFragment5.REFRESH_ON_CREATE);
+        return fgt;
+//        } else {
+//            return new FgtFind2();
+//        }
     }
 }

+ 0 - 219
app/src/main/java/com/sheep/gamegroup/module/find/fragment/FgtFind2.java

@@ -1,219 +0,0 @@
-package com.sheep.gamegroup.module.find.fragment;
-
-import android.app.Activity;
-import android.provider.MediaStore;
-import android.support.design.widget.TabLayout;
-import android.support.v4.view.ViewPager;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.ImageView;
-
-import com.kfzs.duanduan.utils.NumberFormatUtils;
-import com.sheep.gamegroup.model.entity.ArticleTag;
-import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.util.SheepSubscriber;
-import com.sheep.gamegroup.util.CommonUtil;
-import com.sheep.gamegroup.util.DataUtil;
-import com.sheep.gamegroup.util.Jump2View;
-import com.sheep.gamegroup.util.KeyEventUtil;
-import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.ViewUtil;
-import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
-import com.sheep.gamegroup.view.fragment.FgtArticleVideo;
-import com.sheep.gamegroup.view.fragment.FgtFindChild;
-import com.sheep.gamegroup.view.fragment.FgtWatchFocus;
-import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.base.BaseFragment;
-import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
-
-import org.afinal.simplecache.ApiKey;
-
-import java.util.List;
-
-import butterknife.BindView;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.schedulers.Schedulers;
-import rx.functions.Action1;
-
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_TAG;
-
-/**
- * Created by realicing on 2018/6/27.
- * realicing@sina.com
- * 主页--发现模块
- */
-public class FgtFind2 extends BaseFragment {
-    private Activity activity;
-
-    @BindView(R.id.indicator)
-    TabLayout indicator;
-    @BindView(R.id.pager)
-    ViewPager pager;
-    @BindView(R.id.add_article)
-    View add_article;
-    @BindView(R.id.add_article_expand)
-    ImageView add_article_expand;
-    @BindView(R.id.add_article_iv)
-    ImageView add_article_iv;
-    @BindView(R.id.add_article_camera)
-    ImageView add_article_camera;
-    @BindView(R.id.add_article_pic)
-    ImageView add_article_pic;
-    @BindView(R.id.img_baseactivity_title)
-    ImageView img_baseactivity_title;
-
-    private TitleFragmentListAdapter mAdapter;
-
-    private void initView() {
-        mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
-        ArticleTag articleTagAll = new ArticleTag();
-        articleTagAll.setId(0);
-        articleTagAll.setName("全部");
-        mAdapter.add(FgtFindChild.newInstance(articleTagAll), articleTagAll.getName());
-        //悬浮
-        ViewUtil.setImage(add_article_expand, ViewUtil.getNetImgByName("add_article_expand"));
-        if (!onlyChooseVideo) {
-            ViewUtil.setImage(add_article_iv, ViewUtil.getNetImgByName("add_article"));
-            ViewUtil.setImage(add_article_camera, ViewUtil.getNetImgByName("add_article_camera"));
-            ViewUtil.setImage(add_article_pic, ViewUtil.getNetImgByName("add_article_pic"));
-        }
-        ViewUtil.setVisibility(add_article, false);
-        ViewUtil.setVisibility(add_article_iv, false);
-        ViewUtil.setVisibility(add_article_camera, false);
-        ViewUtil.setVisibility(add_article_pic, false);
-        add_article.setOnClickListener(view -> {
-            if (onlyChooseVideo) {
-                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
-            } else {
-                changeAddArticle(add_article_iv.getVisibility() == View.VISIBLE);
-            }
-        });
-        if (!onlyChooseVideo) {
-            add_article_camera.setOnClickListener(view -> {
-//                changeAddArticle(true);
-//                G.showToast("添加视频");
-                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
-            });
-            add_article_pic.setOnClickListener(view -> {
-//                changeAddArticle(true);
-//                G.showToast("添加图片");
-                Jump2View.getInstance().gotoActPublishArticle(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE);
-            });
-        }
-        img_baseactivity_title.setOnClickListener(this::onClickBackImg);
-    }
-
-    private boolean onlyChooseVideo = true;//只选择视频
-
-    private void changeAddArticle(boolean isExpand) {
-        ViewUtil.setVisibility(add_article_iv, !isExpand);
-        ViewUtil.setVisibility(add_article_camera, !isExpand);
-        ViewUtil.setVisibility(add_article_pic, !isExpand);
-        add_article_expand.setAlpha(isExpand ? 1.0f : 0.0f);
-    }
-
-    @Override
-    public int getLayoutId() {
-        return R.layout.fgt_find2;
-    }
-
-    @Override
-    public void onViewCreated() {
-        activity = getActivity();
-        initView();
-        initData();
-    }
-
-    private void initData() {
-        //尝试获取缓存数据
-        List<ArticleTag> newList = DataUtil.getInstance().getCacheList(ApiKey.articles_tags, ArticleTag.class);
-        if (ListUtil.isEmpty(newList)) {//这里有个bug,如果一开始有数据,等到服务器数据发生变化时,就会始终使用老的数据,除非有缓存时长限制,但是这样又导致数据不是最新的,所以在SysAppUtil中的checkNet方法直接更新该列表。
-            initNetData(true);
-        } else {
-            list.addAll(newList);
-            loadList();
-        }
-    }
-
-    @Override
-    public void initDataOnVisibleToUser() {
-
-    }
-
-    private void initNetData(final boolean loadPager) {
-        SheepApp.getInstance().getNetComponent().getApiService().getFindTagList()
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        List<ArticleTag> newList = baseMessage.getDatas(ArticleTag.class);
-                        list.clear();
-                        list.addAll(newList);
-                        if (loadPager && !ListUtil.isEmpty(list)) {
-                            loadList();
-                        }
-                    }
-
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                    }
-                });
-    }
-
-    //没有添加数据返回true
-    private void loadList() {
-        CommonUtil.getInstance().initUrlConfigByNet("awaken_on", new Action1<String>() {
-            @Override
-            public void call(String url) {
-                int awaken_on = NumberFormatUtils.parseInteger(url);
-                int count = 1;
-                for (ArticleTag findLabel : list) {
-                    switch (findLabel.getName()) {
-                        case "视频":
-                            mAdapter.add(FgtArticleVideo.newInstance(findLabel.getId()), findLabel.getName());
-                            break;
-                        default:
-                            mAdapter.add(FgtFindChild.newInstance(findLabel), findLabel.getName());
-                            break;
-                    }
-                    count++;
-                }
-                if (awaken_on == 1) {
-                    count++;
-                    mAdapter.add(new FgtWatchFocus(), "看点", 2);
-                }
-                pager.setAdapter(mAdapter);
-                indicator.setupWithViewPager(pager);
-                pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
-                    @Override
-                    public void onPageScrolled(int i, float v, int i1) {
-
-                    }
-
-                    @Override
-                    public void onPageSelected(int i) {
-                        ViewUtil.setVisibility(add_article, mAdapter.getItem(i) instanceof FgtArticleVideo);
-                        FIND_TAG.onEvent("find_tag_name", ListUtil.hasIndex(list, i - 1) ? list.get(i - 1).getName() : "全部");
-                    }
-
-                    @Override
-                    public void onPageScrollStateChanged(int i) {
-
-                    }
-                });
-                CommonUtil.getInstance().reflex(indicator, activity);
-                pager.setOffscreenPageLimit(count);
-
-            }
-        });
-    }
-
-    private List<ArticleTag> list = ListUtil.emptyList();
-
-    //点击返回
-    public void onClickBackImg(View view) {
-        KeyEventUtil.sendKeyDownUp(KeyEvent.KEYCODE_BACK);
-    }
-}

+ 0 - 6
app/src/main/java/com/sheep/gamegroup/util/MainTab.java

@@ -6,12 +6,6 @@ import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.module.game.fragment.FgtGameCenter;
 import com.sheep.gamegroup.module.home.fragment.FgtHome;
 import com.sheep.gamegroup.module.home.fragment.FgtWrapper;
-import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
-import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
-import com.sheep.gamegroup.view.fragment.FgtFind;
-import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
-import com.sheep.gamegroup.view.fragment.FgtSmallSheep;
-import com.sheep.jiuyan.samllsheep.Config;
 import com.sheep.jiuyan.samllsheep.R;
 import com.snail.antifake.jni.EmulatorDetectUtil;
 

+ 0 - 2
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -31,8 +31,6 @@ import com.sheep.gamegroup.model.entity.Release_task;
 import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
-import com.sheep.gamegroup.module.find.activity.ActFind;
-import com.sheep.gamegroup.module.login.fragments.AbsLoginFgt;
 import com.sheep.gamegroup.module.pay.activity.ActPayPassword;
 import com.sheep.gamegroup.module.qrcode.ScanQRCodeActivity;
 import com.sheep.gamegroup.module.user.activity.ActVip;

+ 1 - 169
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtFindChild.java

@@ -120,133 +120,6 @@ public class FgtFindChild extends BaseListFragment5<Article> {
         }
     }
 
-
-    private Map<String, Applications> findAppMap = new HashMap<>();
-
-    //获取任务对应的findApp
-    private Applications getFindAppByKey(String key) {
-        if (findAppMap.containsKey(key))
-            return findAppMap.get(key);
-        return null;
-    }
-
-    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(Applications findApp, TextView textView) {
-        if (findApp.isCanDownload()) {//可下载
-            downLoadTextViewMap.put(findApp.getDownload_link(), textView);
-            downLoadTextViewMap.put(findApp.getPackage_name(), textView);
-            findAppMap.put(findApp.getDownload_link(), findApp);
-            findAppMap.put(findApp.getPackage_name(), findApp);
-            findApp.getFindAppHelper().updateDownloadTaskView(true, findApp, textView);
-        } else {//预约下载
-            findApp.getFindAppHelper().updateReservationView(true, 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%%", Math.abs(task.getMPercent())));
-        }
-    }
-
-    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);
-        }
-        Applications findApp = getFindAppByKey(task.getMDownloadUrl());
-        if (findApp != null) {
-            findApp.updateState(DownloadUtil.STATUS_FINISH);
-        }
-    }
-
-    /**
-     * 主要的事件广播接收更新处理
-     *
-     * @param event
-     */
-    @Subscribe
-    public void onEventMainThread(BigEvent event) {
-        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;
-            }
-        }
-    }
-
     @Override
     public void pluginLoadData(Action1 action) {
         CommonUtil.getInstance().refreshAds(SheepAd.FORM_NEWS, (ret, list) -> {
@@ -290,40 +163,6 @@ public class FgtFindChild extends BaseListFragment5<Article> {
         EventBus.getDefault().unregister(this);
     }
 
-    @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:", "");
-
-            Applications findApp = getFindAppByKey(packageName);
-            TextView textView = getTextViewByKey(packageName);
-            if (findApp != null) {
-                switch (intent.getAction()) {
-                    case ACTION_PACKAGE_ADDED:
-                        if (textView != null) {
-                            textView.setText(CommonUtil.GAME_OPEN);
-                        }
-                        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);
-                            if (textView != null) {
-                                textView.setText(CommonUtil.START_DOWNLOAD);
-                            }
-                        } else {
-                            findApp.updateState(DownloadUtil.STATUS_FINISH);
-                            if (textView != null) {
-                                textView.setText(CommonUtil.START_INSTALL);
-                            }
-                        }
-                        break;
-                }
-            }
-        }
-    }
-
     protected void combineList() {
         //combine ads and list
         if (ads == null || ads.size() == 0) return;
@@ -413,13 +252,7 @@ public class FgtFindChild extends BaseListFragment5<Article> {
             ViewUtil.setVisibility(find_item_placement, item.getIs_placement() == 1);
 
             if (find_item_download != null) {
-                if (item.isGame()) {
-                    ViewUtil.setVisibility(find_item_download, View.VISIBLE);
-                    Applications findApp = item.getApplication();
-                    updateView(findApp, find_item_download);
-                } else {
-                    ViewUtil.setVisibility(find_item_download, View.GONE);
-                }
+                ViewUtil.setVisibility(find_item_download, item.isGame());
             }
             ViewUtil.setText(find_item_name, item.getTitle());
             ViewUtil.setTextTime(find_item_time, item.getCreated_at(), "yyyy-MM-dd");
@@ -443,7 +276,6 @@ public class FgtFindChild extends BaseListFragment5<Article> {
                 }
             }
             rootConvertView.setOnClickListener(view -> onClickItem(item));
-            LogUtil.logI("commonflag:  " + item.getTitle() + "  " + item.getType());
         }
     }
 

+ 0 - 101
app/src/main/res/layout/fgt_find2.xml

@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@color/white">
-
-    <android.support.constraint.ConstraintLayout
-        android:id="@+id/layout_navigationBar"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="@color/bg_home_color"
-        android:paddingTop="@dimen/status_bar_height">
-
-        <ImageView
-            android:id="@+id/img_baseactivity_title"
-            android:layout_width="wrap_content"
-            android:layout_height="?attr/actionBarSize"
-            android:gravity="center_vertical"
-            android:paddingStart="@dimen/content_padding_20"
-            android:paddingEnd="@dimen/content_padding_20"
-            android:scaleType="centerInside"
-            android:src="@drawable/narrow_back_white"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent" />
-
-        <TextView
-            android:id="@+id/txt_baseactivity_title"
-            android:layout_width="wrap_content"
-            android:layout_height="?attr/actionBarSize"
-            android:layout_centerInParent="true"
-            android:gravity="center"
-            android:text="发现"
-            android:textColor="@color/white"
-            android:textSize="@dimen/text_size_4"
-            app:layout_constraintBottom_toBottomOf="@+id/img_baseactivity_title"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="@+id/img_baseactivity_title" />
-    </android.support.constraint.ConstraintLayout>
-
-    <ImageView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:adjustViewBounds="true"
-        android:scaleType="fitXY"
-        android:layout_below="@id/layout_navigationBar"
-        android:src="@drawable/skin_drawable_selector_bg_home_search" />
-
-    <android.support.design.widget.TabLayout
-        android:id="@+id/indicator"
-        style="@style/style_tab_2"
-        android:layout_below="@id/layout_navigationBar"
-        android:layout_marginTop="20dp" />
-
-    <android.support.v4.view.ViewPager
-        android:id="@+id/pager"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_below="@id/indicator" />
-
-    <com.kfzs.duanduan.view.DragRelativeLayout
-        android:id="@+id/add_article"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentEnd="true"
-        android:layout_centerVertical="true">
-
-        <ImageView
-            android:id="@+id/add_article_iv"
-            android:layout_width="120dp"
-            android:layout_height="120dp"
-            android:src="@drawable/icon" />
-
-        <ImageView
-            android:id="@+id/add_article_expand"
-            android:layout_width="72dp"
-            android:layout_height="72dp"
-            android:layout_alignTop="@id/add_article_iv"
-            android:layout_alignEnd="@id/add_article_iv"
-            android:src="@drawable/icon" />
-
-        <ImageView
-            android:id="@+id/add_article_camera"
-            android:layout_width="25dp"
-            android:layout_height="22dp"
-            android:layout_marginStart="15dp"
-            android:layout_marginTop="18dp"
-            android:src="@drawable/icon" />
-
-        <ImageView
-            android:id="@+id/add_article_pic"
-            android:layout_width="26dp"
-            android:layout_height="25dp"
-            android:layout_alignEnd="@id/add_article_iv"
-            android:layout_alignBottom="@id/add_article_iv"
-            android:layout_marginEnd="22dp"
-            android:layout_marginBottom="19dp"
-            android:src="@drawable/icon" />
-    </com.kfzs.duanduan.view.DragRelativeLayout>
-</RelativeLayout>