Explorar o código

Merge remote-tracking branch 'origin/sheep_develop' into sheep_develop

yuanshenglan %!s(int64=7) %!d(string=hai) anos
pai
achega
f8e45ed057

+ 71 - 44
app/src/main/java/com/kfzs/duanduan/fragment/FgtFindChild.java

@@ -4,9 +4,7 @@ import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
-import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -16,6 +14,7 @@ import android.widget.TextView;
 import com.arialyy.annotations.Download;
 import com.arialyy.aria.core.Aria;
 import com.arialyy.aria.core.download.DownloadTask;
+import com.jcodecraeer.xrecyclerview.XRecyclerView;
 import com.kfzs.android.view.tag.FlowLayout;
 import com.kfzs.android.view.tag.TagAdapter;
 import com.kfzs.android.view.tag.TagFlowLayout;
@@ -65,6 +64,8 @@ import static com.sheep.gamegroup.util.UMConfigUtils.Event.FIND_ITEM;
  */
 public class FgtFindChild extends BaseCompatFragment {
 
+    private int page = 1;//页数
+    private int per_page = 10;
     private int type;
     public static FgtFindChild newInstance(int type){
         FgtFindChild fgt = new FgtFindChild();
@@ -88,7 +89,7 @@ public class FgtFindChild extends BaseCompatFragment {
     private Activity activity;
     @Override
     protected void initView(Bundle savedInstanceState) {
-        setContentView(R.layout.net_empty_fresh_list);
+        setContentView(R.layout.net_empty_xrecycler);
         activity = getActivity();
         ButterKnife.bind(this, mContentView);
         initView();
@@ -97,24 +98,39 @@ public class FgtFindChild extends BaseCompatFragment {
 
     @BindView(R.id.title)
     View title;
-    @BindView(R.id.refresh)
-    SwipeRefreshLayout refresh;
+//    @BindView(R.id.refresh)
+//    SwipeRefreshLayout refresh;
     @BindView(R.id.empty_view)
     View empty_view;
     @BindView(R.id.check_net_ll)
     View check_net_ll;
     @BindView(R.id.view_list)
-    RecyclerView view_list;
+    XRecyclerView view_list;
     private void initView(){
         title.setVisibility(View.GONE);
-        refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+//        refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+//            @Override
+//            public void onRefresh() {
+//                refreshData();
+//                refresh.setRefreshing(false);
+//            }
+//        });
+        view_list.setLoadingListener(new XRecyclerView.LoadingListener() {
             @Override
             public void onRefresh() {
                 refreshData();
-                refresh.setRefreshing(false);
             }
-        });
 
+            @Override
+            public void onLoadMore() {
+                if(ListUtil.size(list) >= per_page*page){
+                    page += 1;
+                    initData();
+                }else {
+                    view_list.loadMoreComplete();
+                }
+            }
+        });
         view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
         view_list.setAdapter(new AdbCommonRecycler<FindItem>(SheepApp.getInstance(), list){
 
@@ -124,20 +140,20 @@ public class FgtFindChild extends BaseCompatFragment {
             }
             @Override
             public int getViewIdByType(int type) {//type来源于 getItemViewType 返回的值
-                if(type == -1 + list.size()){
-                   return R.layout.find_item_bottom;
-                }
                 return R.layout.find_item;
             }
 
             @Override
-            public void convert(ViewHolder holder, final FindItem item) {
+            public void convert(final ViewHolder holder, final FindItem item) {
                 if(item == null){
                     return;
                 }
                 View rootConvertView = holder.itemView;
                 View padding = rootConvertView.findViewById(R.id.padding);
-                padding.setVisibility(holder.getAdapterPosition() == 0 ? View.GONE : View.VISIBLE);
+                if(padding == null){
+                    return;
+                }
+                padding.setVisibility(holder.getAdapterPosition() == 1 ? View.GONE : View.VISIBLE);
                 TextView find_item_name = (TextView)rootConvertView.findViewById(R.id.find_item_name);
                 TextView find_item_time = (TextView)rootConvertView.findViewById(R.id.find_item_time);
                 ImageView find_item_iv = (ImageView)rootConvertView.findViewById(R.id.find_item_iv);
@@ -175,7 +191,15 @@ public class FgtFindChild extends BaseCompatFragment {
                     };
                     find_item_tags.setAdapter(adapter);
                 }
-
+//                if(BuildConfig.DEBUG){
+//                    rootConvertView.setOnLongClickListener(new View.OnLongClickListener() {
+//                        @Override
+//                        public boolean onLongClick(View view) {
+//                            G.showToast(""+holder.getAdapterPosition());
+//                            return true;
+//                        }
+//                    });
+//                }
                 rootConvertView.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
@@ -272,12 +296,8 @@ public class FgtFindChild extends BaseCompatFragment {
 
     public void initData(){
         //先尝试获取缓存数据
-        List<FindItem> newList = DataUtil.getInstance().getCacheList(ApiKey.articles(type), FindItem.class);
+        List<FindItem> newList = DataUtil.getInstance().getCacheList(ApiKey.articles(page, per_page, type), FindItem.class);
         loadList(newList);
-        refreshData();
-    }
-
-    public void refreshData(){
         empty_view.setVisibility(View.INVISIBLE);
         SysAppUtil.checkNet(new Action1<Integer>() {
             @Override
@@ -291,38 +311,45 @@ public class FgtFindChild extends BaseCompatFragment {
                 }
             }
         });
-        SheepApp.getInstance().getNetComponent().getApiService().getFindList(1, 100, type)
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.articles(type));
-                                if(isNewData) {
-                                    List<FindItem> newList = baseMessage.getDatas(FindItem.class);
-                                    loadList(newList);
-                                }
-                            }
+        SheepApp.getInstance().getNetComponent().getApiService().getFindList(page, per_page, type)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.articles(page, per_page, type));
+                        if(isNewData) {
+                            List<FindItem> newList = baseMessage.getDatas(FindItem.class);
+                            loadList(newList);
+                        }
+                    }
 
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                notifyDataSetChanged();
-                            }
-                        });
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        notifyDataSetChanged();
+                    }
+                });
+    }
+
+    public void refreshData(){
+        list.clear();
+        view_list.getAdapter().notifyDataSetChanged();
+        page = 1;
+        initData();
     }
     private void loadList(List<FindItem> newList){
-        if(!ListUtil.isEmpty(newList)){
-            list.clear();
-            ListUtil.addAll(list, newList);
-            if(!list.isEmpty())
-                list.add(null);//底部部分----我是有底线的
-        }
+        ListUtil.addAll(list, newList);
         notifyDataSetChanged();
     }
 
     private void notifyDataSetChanged(){
         CommonUtil.getInstance().updateEmptyView(empty_view, list.isEmpty());
-        refresh.setRefreshing(false);
+//        refresh.setRefreshing(false);
+        if(page == 1){
+            view_list.refreshComplete();
+        } else {
+            view_list.loadMoreComplete();
+        }
         view_list.getAdapter().notifyDataSetChanged();
     }
     private List<FindItem> list = ListUtil.emptyList();

+ 6 - 0
app/src/main/java/com/kfzs/duanduan/fragment/FgtMiDong.java

@@ -60,6 +60,7 @@ public class FgtMiDong extends BaseCompatFragment {
     private int pageNo = 1;
     private int pageSize = 30;
     private List<AdDataSon> listData = ListUtil.emptyList();
+    private int refresh_init_false = 1;
 
     public static FgtMiDong newInstance(int type) {
         FgtMiDong fgtMiDong = new FgtMiDong();
@@ -186,6 +187,11 @@ public class FgtMiDong extends BaseCompatFragment {
 
                 @Override
                 public void onLoadAdFailure() {
+                    if(refresh_init_false == 1){
+                        initData(isRefresh);
+                    }
+                    refresh_init_false++;
+
                     refresh.setRefreshing(false);
                     if (isRefresh)
                         G.showToast(activity, "网络异常,请稍后再试", Toast.LENGTH_SHORT);

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/helper/TaskHelper.java

@@ -453,13 +453,13 @@ public class TaskHelper {
         for (TaskChild taskChild : taskChildList) {
             switch (taskChild.getStatus()) {
                 case 2:
+                case 4:
                 case 3:
-                case 6://找到可领取或者进行中或者审核失败则直接退出循环
+                case 6://找到可领取或者进行中或者审核失败或者审核中则直接退出循环
                     selectTaskChild = taskChild;
                     break outFor;
                 case 0:
                 case 1:
-                case 4:
                 case 5:
                     if (selectTaskChild == null)
                         selectTaskChild = taskChild;

+ 4 - 5
app/src/main/java/com/sheep/gamegroup/model/entity/FindItem.java

@@ -7,8 +7,6 @@ import com.sheep.gamegroup.util.ListUtil;
 
 import java.util.List;
 
-import rx.functions.Action1;
-
 /**
  * Created by realicing on 2018/6/27.
  * realicing@sina.com
@@ -180,9 +178,10 @@ public class FindItem {
     }
 
 
-
-
-
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof FindItem && ((FindItem) obj).getId() == id;
+    }
 
     //是否是游戏,游戏要显示下载游戏与评分
     public boolean isGame() {

+ 20 - 5
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -6,6 +6,7 @@ import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Handler;
 import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.View;
@@ -1452,17 +1453,31 @@ public class Jump2View {
     /**
      * 幂动科技
      */
-    public void goMiDong(Activity activity, Object o){
+    public void goMiDong(final Activity activity, Object o){
         if(!SheepApp.getInstance().isShowMidong()){
             G.showToast("敬请期待");
             return;
         }
         CommonUtil.getInstance().initMiDong(activity, DataUtil.getInstance().getUserId());
-        if(SheepApp.getInstance().isInitMidong()){
-            Intent intent = new Intent(activity, ActMiDong.class);
-            activity.startActivity(intent);
-            MI_DONG_VIEW.onEvent();
+        long l ;
+        if(SheepApp.getInstance().getMidongTimeCount() == 1){
+            l = 1000;
+        }else {
+            l = 0;
         }
+        SheepApp.getInstance().setMidongTimeCount(SheepApp.getInstance().getMidongTimeCount()+1);
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if(SheepApp.getInstance().isInitMidong()){
+                    Intent intent = new Intent(activity, ActMiDong.class);
+                    activity.startActivity(intent);
+                    MI_DONG_VIEW.onEvent();
+                }
+
+            }
+        }, l);
+
     }
     /**
      * 小米游戏列表

+ 13 - 0
app/src/main/java/com/sheep/gamegroup/util/ListUtil.java

@@ -114,6 +114,19 @@ public class ListUtil {
             list.set(position, t);
     }
 
+    /**
+     * 清除末尾的空数据
+     * @param list
+     */
+    public static <T> void removeNull(List<T> list) {
+        removeItem(list, new CallBack<T, Boolean>() {
+            @Override
+            public Boolean call(T t) {
+                return t == null;
+            }
+        });
+    }
+
     public static interface CallBack<I, R>{
         public R call(I i);
     }

+ 9 - 6
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtAudit.java

@@ -11,6 +11,7 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.view.adapter.TaskListItemAdp;
 import com.sheep.gamegroup.view.customview.RefreshLayout;
 import com.sheep.jiuyan.samllsheep.R;
@@ -114,14 +115,16 @@ public class FgtAudit extends BaseFragment {
             CommonUtil.getInstance().getAudit(new Action1<BaseMessage>() {
                 @Override
                 public void call(BaseMessage baseMessage) {
-                    int count = 0;
                     if(baseMessage != null){
                         List<TaskAcceptedEty> releaseEtyList = baseMessage.getDataList(TaskAcceptedEty.class);
-                        count = ListUtil.addAll(etyList, releaseEtyList);
-                    }
-                    if(count < per_page){//添加最后一条底线
-                        if(!etyList.isEmpty())
-                            etyList.add(null);
+                        ListUtil.removeNull(etyList);
+                        ListUtil.addAll(etyList, releaseEtyList);
+//                        int count = ListUtil.addAll(etyList, releaseEtyList);
+//                        LogUtil.println("FgtAuditAddLine", count, ListUtil.size(releaseEtyList));
+                        if(ListUtil.size(releaseEtyList) < per_page){//添加最后一条底线
+                            if(!etyList.isEmpty())
+                                etyList.add(null);
+                        }
                     }
                     notifyDataSetChanged();
                 }

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

@@ -51,6 +51,15 @@ public class SheepApp extends BaseApplication {
     private String packgeName;
     private boolean isInitMidong = false;
     private boolean isShowMidong = false;
+    private int midongTimeCount = 1;
+
+    public int getMidongTimeCount() {
+        return midongTimeCount;
+    }
+
+    public void setMidongTimeCount(int midongTimeCount) {
+        this.midongTimeCount = midongTimeCount;
+    }
 
     public boolean isShowMidong() {
         return isShowMidong;

+ 2 - 2
app/src/main/java/org/afinal/simplecache/ApiKey.java

@@ -53,8 +53,8 @@ public class ApiKey {
     //发现模块标签列表
     public static final String articles_tags = "app/find/articles_tags/list";
     //发现模块发现列表
-    public static String articles(int tag_id){
-        return "app/find/articles/list?page=1&per_page=100&tag_id="+tag_id;
+    public static String articles(int page, int per_page, int tag_id){
+        return String.format(Locale.CHINA, "app/find/articles/list?page=%d&per_page=%d&tag_id=%d", page, per_page, tag_id);
     }
     //发现模块资讯
     public static String articlesItem(int id){

+ 0 - 1
app/src/main/res/layout/common_tab_vp.xml

@@ -15,7 +15,6 @@
     <android.support.design.widget.TabLayout
         android:id="@+id/indicator"
         style="@style/style_tab"
-        android:layout_marginBottom="7dp"
         android:layout_marginTop="7dp" />
 
     <android.support.v4.view.ViewPager

+ 30 - 0
app/src/main/res/layout/net_empty_xrecycler.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/bg_gray">
+
+    <include
+        android:id="@+id/title"
+        layout="@layout/title" />
+
+    <include
+        android:id="@+id/check_net_ll"
+        layout="@layout/check_net_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/title" />
+
+    <include
+        android:id="@+id/empty_view"
+        layout="@layout/empty_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/check_net_ll" />
+
+    <com.jcodecraeer.xrecyclerview.XRecyclerView
+        android:id="@+id/view_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/check_net_ll"/>
+</RelativeLayout>