|
@@ -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);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|