|
|
@@ -1,19 +1,19 @@
|
|
|
package com.kfzs.duanduan.fragment;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
-import android.app.Fragment;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.LinearLayout;
|
|
|
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.entity.TaskReleaseEty;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.view.activity.AskGetMoneyAct;
|
|
|
-import com.sheep.gamegroup.view.adapter.CreditCardTaskAdp;
|
|
|
import com.sheep.gamegroup.view.adapter.FriendExtractAdp;
|
|
|
-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;
|
|
|
@@ -33,42 +33,67 @@ import rx.schedulers.Schedulers;
|
|
|
* realicing@sina.com
|
|
|
*/
|
|
|
public class FgtFriendExtractPage extends BaseFragment {
|
|
|
- @BindView(R.id.list_view)
|
|
|
- ListView list_view;
|
|
|
+ @BindView(R.id.friend_list_ll)
|
|
|
+ LinearLayout friend_list_ll;
|
|
|
@Override
|
|
|
public int getLayoutId() {
|
|
|
- return R.layout.list_view;
|
|
|
+ return R.layout.friend_list;
|
|
|
}
|
|
|
|
|
|
private List<Friend> list = new ArrayList<>();
|
|
|
- private FriendExtractAdp adapter;
|
|
|
@Override
|
|
|
public void onViewCreated() {
|
|
|
ButterKnife.bind(this, mView);
|
|
|
- adapter = new FriendExtractAdp(getActivity(), list);
|
|
|
- list_view.setAdapter(adapter);
|
|
|
initData();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private int per_page = 5;
|
|
|
+ public static int per_page = 5;
|
|
|
private int page = 1;
|
|
|
+ private void notifyDataSetChanged(){
|
|
|
+ int size = list.size();
|
|
|
+ for (int i = 0; i < friend_list_ll.getChildCount(); i++) {
|
|
|
+ ViewGroup view = (ViewGroup) friend_list_ll.getChildAt(i);
|
|
|
+ if(i < size){
|
|
|
+ view.setVisibility(View.VISIBLE);
|
|
|
+ int j = 0;
|
|
|
+ Friend friend = list.get(i);
|
|
|
+ TextView friend_item_id = (TextView) view.getChildAt(j++);
|
|
|
+ friend_item_id.setText(friend.getInvitation_code());
|
|
|
+ TextView friend_item_name = (TextView) view.getChildAt(j++);
|
|
|
+ friend_item_name.setText(friend.getNickname());
|
|
|
+ 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"));
|
|
|
+ } else {
|
|
|
+ view.setVisibility(View.INVISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private boolean isLoadding = false;
|
|
|
private void initData(){
|
|
|
+ if(list.size() >= per_page || isLoadding){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isLoadding = true;
|
|
|
+ list.clear();
|
|
|
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> friendList = baseMessage.getDatas(Friend.class);
|
|
|
Activity activity = getActivity();
|
|
|
if(activity instanceof AskGetMoneyAct){
|
|
|
- ((AskGetMoneyAct) activity).setFriendExtractCount(baseMessage.getTotal());
|
|
|
+ ((AskGetMoneyAct) activity).setFriendExtractCount(baseMessage.getTotal(), page, friendList.size());
|
|
|
}
|
|
|
- List<Friend> friendList = baseMessage.getDatas(Friend.class);
|
|
|
list.addAll(friendList);
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
+ notifyDataSetChanged();
|
|
|
if(BuildConfig.DEBUG)
|
|
|
System.out.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
|
|
|
+ isLoadding = false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -76,6 +101,7 @@ public class FgtFriendExtractPage extends BaseFragment {
|
|
|
if(BuildConfig.DEBUG)
|
|
|
System.out.println("baseMessage onError "+JSON.toJSONString(baseMessage));
|
|
|
G.showToast(TextUtils.isEmpty(baseMessage.getMsg()) ? "服务器错误,请稍候再试" : baseMessage.getMsg());
|
|
|
+ isLoadding = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -84,4 +110,8 @@ public class FgtFriendExtractPage extends BaseFragment {
|
|
|
friendExtractPage.page = page;
|
|
|
return friendExtractPage;
|
|
|
}
|
|
|
+
|
|
|
+ public List<Friend> getList() {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|