zengjiebin лет назад: 8
Родитель
Сommit
07f114788d

+ 2 - 1
app/src/main/java/com/kfzs/duanduan/fragment/FgtFriendExtractPage.java

@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSON;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.Friend;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.TimeUtil;
 import com.sheep.gamegroup.view.activity.AskGetMoneyAct;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
@@ -65,7 +66,7 @@ public class FgtFriendExtractPage extends BaseFragment {
                 TextView friend_item_extract = (TextView) view.getChildAt(j++);
                 friend_item_extract.setText(""+friend.getAward_amount());
                 TextView friend_item_time = (TextView) view.getChildAt(j);
-                friend_item_time.setText(FgtSmallSheep.TimeStamp2Date(friend.getCreate_time(), "yyyy/MM/dd HH:mm"));
+                friend_item_time.setText(TimeUtil.TimeStamp2Date(friend.getCreate_time(), "yyyy/MM/dd HH:mm"));
             } else {
                 view.setVisibility(View.INVISIBLE);
             }

+ 1 - 2
app/src/main/java/com/kfzs/duanduan/fragment/FgtMyMoney1.java

@@ -11,7 +11,6 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.TaskReleaseEty;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.view.adapter.ArrayAdapter;
-import com.sheep.gamegroup.view.customview.RefreshLayout;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -60,7 +59,7 @@ public class FgtMyMoney1 extends BaseFragment {
                 }
             };
             list_view.setAdapter(adapter);
-            swipe_container.setOnRefreshListener(new RefreshLayout.OnRefreshListener() {
+            swipe_container.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                 @Override
                 public void onRefresh() {
                     initData();

+ 132 - 0
app/src/main/java/com/kfzs/duanduan/fragment/FgtMyMoney2.java

@@ -0,0 +1,132 @@
+package com.kfzs.duanduan.fragment;
+
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.Friend;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.TimeUtil;
+import com.sheep.gamegroup.view.adapter.ArrayAdapter;
+import com.sheep.gamegroup.view.customview.RefreshLayout;
+import com.sheep.jiuyan.samllsheep.BuildConfig;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
+
+/**
+ * 我的资产 --> 充值记录
+ * Created by realicing on 2018/5/8.
+ * realicing@sina.com
+ */
+public class FgtMyMoney2 extends BaseFragment {
+    @BindView(R.id.list_view)
+    ListView list_view;
+    @BindView(R.id.swipe_container)
+    RefreshLayout swipe_container;
+    @BindView(R.id.empty_view)
+    View empty_view;
+    @Override
+    public int getLayoutId() {
+        return R.layout.list_has_empty2;
+    }
+
+    private List<Friend> list = ListUtil.emptyList();
+    private ArrayAdapter<Friend> adapter;
+    @Override
+    public void onViewCreated() {
+        ButterKnife.bind(this, mView);
+        if(getActivity() != null) {
+            swipe_container.setFooterView(getActivity(), list_view, R.layout.listview_footer);
+            adapter = new ArrayAdapter<Friend>(getActivity(), R.layout.x_my_money_act_layout_item, list){
+                @Override
+                public boolean convert(int position, View convertView, ViewGroup parent, Friend item) {
+                    TextView my_money_item_recharge_amount = convertView.findViewById(R.id.my_money_item_recharge_amount);
+                    TextView my_money_item_recharge_status = convertView.findViewById(R.id.my_money_item_recharge_status);
+                    TextView my_money_item_recharge_time = convertView.findViewById(R.id.my_money_item_recharge_time);
+                    my_money_item_recharge_amount.setText(String.format(Locale.CHINA, "%d", position+1));
+                    my_money_item_recharge_status.setText(item.getInvitation_code());
+                    my_money_item_recharge_time.setText(TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy/MM/dd HH:mm"));
+                    convertView.setBackgroundColor(position % 2 == 1 ? 0xffF8F8F8 : 0xffffffff);
+                    return true;
+                }
+            };
+            list_view.setAdapter(adapter);
+            swipe_container.setOnRefreshListener(new RefreshLayout.OnRefreshListener() {
+                @Override
+                public void onRefresh() {
+                    list.clear();
+                    adapter.notifyDataSetChanged();
+                    page = 1;
+                    initData();
+                }
+            });
+
+            swipe_container.setOnLoadListener(new RefreshLayout.OnLoadListener() {
+                @Override
+                public void onLoad() {
+                    swipe_container.setLoading(false);
+                    if(list.size() % per_page == 0)
+                        page++;
+                    initData();
+                }
+            });
+            initData();
+        }
+    }
+
+    public static int per_page = 10;
+    private int page = 1;
+    private void initData() {
+        empty_view.setVisibility(View.INVISIBLE);
+        SheepApp.getInstance().getNetComponent().getApiService().getUserFriendList(page, per_page)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(getContext()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        List<Friend> newList = baseMessage.getDatas(Friend.class);
+                        if(newList == null) {
+                            baseMessage.setMsg("您还没有邀请到好友");
+                            onError(baseMessage);
+                        } else {
+                            ListUtil.addAll(list, newList);
+                            notifyDataSetChanged();
+                            if (BuildConfig.DEBUG)
+                                System.out.println("baseMessage onNext " + JSON.toJSONString(baseMessage));
+                        }
+                        if(BuildConfig.DEBUG)
+                            System.out.println("baseMessage onNext "+ JSON.toJSONString(baseMessage));
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        if(BuildConfig.DEBUG)
+                            System.out.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                        notifyDataSetChanged();
+                    }
+                });
+    }
+    private void notifyDataSetChanged() {
+        empty_view.setVisibility(list.isEmpty() ? View.VISIBLE : View.INVISIBLE);
+        adapter.notifyDataSetChanged();
+        swipe_container.setRefreshing(false);
+        swipe_container.setLoading(false);
+    }
+}

+ 0 - 7
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -786,13 +786,6 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         return date;
     }
 
-    public static String TimeStamp2Date(long timestampString, String formats) {
-        Long timestamp = timestampString * 1000;
-        String date = new SimpleDateFormat(formats, Locale.CHINA).format(new Date(timestamp));
-        return date;
-    }
-
-
     @Subscribe
     public void onEventMainThread(BigEvent event) {
         switch (event.getEventTypes()) {

+ 7 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/Friend.java

@@ -1,5 +1,7 @@
 package com.sheep.gamegroup.model.entity;
 
+import android.text.TextUtils;
+
 /**
  * Created by realicing on 2018/4/24.
  * realicing@sina.com
@@ -205,4 +207,9 @@ public class Friend {
     public int getCreate_time(){
         return this.create_time;
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof Friend && TextUtils.equals(((Friend) obj).getInvitation_code(), invitation_code);
+    }
 }

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

@@ -1,6 +1,7 @@
 package com.sheep.gamegroup.util;
 
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -19,4 +20,21 @@ public class ListUtil {
     public static int getTotalPage(int count, int per_page) {
         return (count - 1) / per_page + 1;
     }
+
+    public static <T> ArrayList<T> emptyList() {
+        return new ArrayList<>();
+    }
+
+    public static <T> int addAll(List<T> list, List<T> elements) {
+        int count = 0;
+        for (T element : elements) {
+            int index = list.indexOf(element);
+            if(index != -1){
+                list.set(index, element);
+            } else if(list.add(element)){
+                count++;
+            }
+        }
+        return count;
+    }
 }

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/util/TimeUtil.java

@@ -16,6 +16,11 @@ public class TimeUtil {
         long ls = System.currentTimeMillis()/1000;
         return ls;
     }
+    public static String TimeStamp2Date(long timestampString, String formats) {
+        Long timestamp = timestampString * 1000;
+        String date = new SimpleDateFormat(formats, Locale.CHINA).format(new Date(timestamp));
+        return date;
+    }
     public static String[] getCalendarShowTime(long paramLong)
     {
         String[] localObject;

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

@@ -14,6 +14,7 @@ import android.widget.TextView;
 import com.alibaba.fastjson.JSONObject;
 import com.kfzs.duanduan.fragment.FgtCreditCardProgressQuery;
 import com.kfzs.duanduan.fragment.FgtMyMoney1;
+import com.kfzs.duanduan.fragment.FgtMyMoney2;
 import com.kfzs.duanduan.mine.GiftpackListAdapter;
 import com.kfzs.duanduan.utils.StatusBarUtils;
 import com.sheep.gamegroup.absBase.AbsChooseImageActivity;
@@ -64,7 +65,7 @@ public class ActMyMoney extends AbsChooseImageActivity {
 //        String sr = "可提现金额 <font color='#ff2d4b'><big>" + balanceAmount + "</big></font> 元";
 //        tv.setText(Html.fromHtml(sr));
         mAdapter = new GiftpackListAdapter(getSupportFragmentManager(), getApplicationContext());
-        mAdapter.add(new FgtMyMoney1(), "充值记录");
+        mAdapter.add(new FgtMyMoney2(), "充值记录");
         mAdapter.add(new FgtMyMoney1(), "提现&消费记录");
         pager.setAdapter(mAdapter);
 //        indicator.setupWithViewPager(pager);

+ 35 - 0
app/src/main/res/layout/list_has_empty2.xml

@@ -0,0 +1,35 @@
+<?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="wrap_content">
+
+    <include
+        android:id="@+id/empty_view"
+        layout="@layout/empty_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <com.sheep.gamegroup.view.customview.RefreshLayout
+        android:id="@+id/swipe_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="@dimen/content_padding_10">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+
+            <ListView
+                android:id="@+id/list_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@drawable/shape_white_solid_rectangle_small"
+                android:divider="@null"
+                android:listSelector="@color/transparent"
+                android:paddingBottom="@dimen/content_padding_8"
+                android:paddingTop="@dimen/content_padding_8"
+                android:scrollbars="none" />
+        </LinearLayout>
+    </com.sheep.gamegroup.view.customview.RefreshLayout>
+
+</RelativeLayout>