|
|
@@ -6,33 +6,41 @@ 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.Html;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.kfzs.android.view.tag.FlowLayout;
|
|
|
import com.kfzs.android.view.tag.TagAdapter;
|
|
|
import com.kfzs.android.view.tag.TagFlowLayout;
|
|
|
import com.kfzs.duanduan.BaseCompatFragment;
|
|
|
-import com.kfzs.duanduan.mine.GiftpackListAdapter;
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.FindItem;
|
|
|
+import com.sheep.gamegroup.model.entity.FindTag;
|
|
|
import com.sheep.gamegroup.model.entity.UserLabel;
|
|
|
-import com.sheep.gamegroup.model.entity.UserLabelList;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.SysAppUtil;
|
|
|
import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.activity.ActUserLabelList;
|
|
|
import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
-import com.sheep.gamegroup.view.fragment.FgtTryMakeMoney;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* Created by realicing on 2018/6/27.
|
|
|
@@ -82,6 +90,67 @@ public class FgtFindChild extends BaseCompatFragment {
|
|
|
refresh.setRefreshing(false);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+ view_list.setAdapter(new AdbCommonRecycler<FindItem>(SheepApp.getInstance(), list){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getViewIdByType(int type) {
|
|
|
+ return R.layout.find_item;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void convert(ViewHolder holder, final FindItem item) {
|
|
|
+ View rootConvertView = holder.itemView;
|
|
|
+ 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);
|
|
|
+ TextView find_item_des = (TextView)rootConvertView.findViewById(R.id.find_item_des);
|
|
|
+ TextView find_item_pf_label = (TextView)rootConvertView.findViewById(R.id.find_item_pf_label);
|
|
|
+ TextView find_item_download = (TextView)rootConvertView.findViewById(R.id.find_item_download);
|
|
|
+ TagFlowLayout find_item_tags = (TagFlowLayout)rootConvertView.findViewById(R.id.find_item_tags);
|
|
|
+
|
|
|
+ if(item.isGame()){
|
|
|
+ find_item_download.setVisibility(View.VISIBLE);
|
|
|
+ find_item_pf_label.setText(Html.fromHtml(String.format(Locale.CHINA, "评分:<font color='%s'>%.1f</font>", "#29d6fd", item.getScore())));
|
|
|
+ find_item_download.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ G.showToast("您点击了下载游戏");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ find_item_download.setVisibility(View.GONE);
|
|
|
+ find_item_pf_label.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ ViewUtil.setText(find_item_name, item.getTitle());
|
|
|
+ ViewUtil.setTextTime(find_item_time, item.getCreated_at(), "yyyy-MM-dd");
|
|
|
+ ViewUtil.setImage(activity, find_item_iv, item.getPictures());
|
|
|
+ ViewUtil.setText(find_item_des, item.getContent());
|
|
|
+ if(ListUtil.isEmpty(item.getTages())){
|
|
|
+ find_item_tags.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ find_item_tags.setVisibility(View.VISIBLE);
|
|
|
+ TagAdapter adapter = new TagAdapter<FindTag>(item.getTages()) {
|
|
|
+ @Override
|
|
|
+ public View getView(FlowLayout parent, int position, FindTag item) {
|
|
|
+ TextView tv = (TextView) LayoutInflater.from(activity).inflate(R.layout.user_label, parent, false);
|
|
|
+ ViewUtil.setText(tv, item.getName());
|
|
|
+ return tv;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ find_item_tags.setAdapter(adapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ rootConvertView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ G.showToast("您点击了一个发现");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private void initData(){
|
|
|
@@ -91,37 +160,34 @@ public class FgtFindChild extends BaseCompatFragment {
|
|
|
if(result != 0){//无网络
|
|
|
if(check_net_ll != null)
|
|
|
check_net_ll.setVisibility(View.VISIBLE);
|
|
|
- testInitData();
|
|
|
- loadData();
|
|
|
} else {
|
|
|
if(check_net_ll != null)
|
|
|
check_net_ll.setVisibility(View.GONE);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+ 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) {
|
|
|
+ LogUtil.println("baseMessage onNext "+ JSON.toJSONString(baseMessage));
|
|
|
+ List<FindItem> newList = baseMessage.getDatas(FindItem.class);
|
|
|
+ if(!ListUtil.isEmpty(newList)){
|
|
|
+ list.clear();
|
|
|
+ ListUtil.addAll(list, newList);
|
|
|
+ view_list.getAdapter().notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- private void testInitData() {
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- list.add(new FindItem());
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
|
|
|
+ G.showToast(baseMessage);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
private List<FindItem> list = ListUtil.emptyList();
|
|
|
- private void loadData() {
|
|
|
- view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
- view_list.setAdapter(new AdbCommonRecycler<FindItem>(SheepApp.getInstance(), list){
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getViewIdByType(int type) {
|
|
|
- return R.layout.find_item;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void convert(ViewHolder holder, final FindItem item) {
|
|
|
- View rootConvertView = holder.itemView;
|
|
|
- TextView user_label_tv = rootConvertView.findViewById(R.id.user_label_tv);
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
}
|