|
@@ -1,17 +1,16 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
|
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
-import android.widget.AdapterView;
|
|
|
|
|
-import android.widget.Checkable;
|
|
|
|
|
-import android.widget.CheckedTextView;
|
|
|
|
|
-import android.widget.CompoundButton;
|
|
|
|
|
-import android.widget.GridView;
|
|
|
|
|
-import android.widget.ListView;
|
|
|
|
|
-import android.widget.RadioButton;
|
|
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.kfzs.android.view.tag.FlowLayout;
|
|
|
|
|
+import com.kfzs.android.view.tag.TagAdapter;
|
|
|
|
|
+import com.kfzs.android.view.tag.TagFlowLayout;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.UserLabel;
|
|
import com.sheep.gamegroup.model.entity.UserLabel;
|
|
@@ -20,8 +19,10 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
-import com.sheep.gamegroup.view.adapter.ArrayAdapter;
|
|
|
|
|
|
|
+import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
@@ -30,6 +31,7 @@ import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
|
|
+import butterknife.OnClick;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.schedulers.Schedulers;
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
|
@@ -45,14 +47,14 @@ public class ActUserLabelList extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.user_label_list)
|
|
@BindView(R.id.user_label_list)
|
|
|
- ListView user_label_list;
|
|
|
|
|
|
|
+ RecyclerView user_label_list;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
TitleBarUtils
|
|
TitleBarUtils
|
|
|
.getInstance()
|
|
.getInstance()
|
|
|
- .setTitle(this, "请选择用户标签")
|
|
|
|
|
- .setTitleFinish(this);
|
|
|
|
|
|
|
+ .setTitle(this, "请选择您喜欢的标签")
|
|
|
|
|
+ .setTitleListen(this, -2,null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -82,41 +84,94 @@ public class ActUserLabelList extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ private List<UserLabelList> checkLabelList;
|
|
|
private void loadData(List<UserLabelList> checkLabelList) {
|
|
private void loadData(List<UserLabelList> checkLabelList) {
|
|
|
- user_label_list.setAdapter(new ArrayAdapter<UserLabelList>(this, R.layout.user_label_item, checkLabelList) {
|
|
|
|
|
|
|
+ this.checkLabelList = checkLabelList;
|
|
|
|
|
+ user_label_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
|
|
+ user_label_list.setAdapter(new AdbCommonRecycler<UserLabelList>(SheepApp.getInstance(), checkLabelList){
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean convert(final int position, final View rootConvertView, ViewGroup parent, final UserLabelList item) {
|
|
|
|
|
- TextView user_label_tv = (TextView) rootConvertView.findViewById(R.id.user_label_tv);
|
|
|
|
|
- GridView user_label_gv = (GridView) rootConvertView.findViewById(R.id.user_label_gv);
|
|
|
|
|
- ViewUtil.setText(user_label_tv, item.getLabel_type_name());
|
|
|
|
|
- user_label_gv.setAdapter(new ArrayAdapter<UserLabel>(ActUserLabelList.this, R.layout.user_label, item.getLabels()) {
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean convert(int position, final View convertView, ViewGroup parent, final UserLabel item) {
|
|
|
|
|
- if (convertView instanceof TextView) {
|
|
|
|
|
- ViewUtil.setText((TextView) convertView, item.getLabel_name());
|
|
|
|
|
|
|
+ public int getViewIdByType(int type) {
|
|
|
|
|
+ return R.layout.user_label_item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void convert(ViewHolder holder, final UserLabelList userLabelList) {
|
|
|
|
|
+ View rootConvertView = holder.itemView;
|
|
|
|
|
+ TextView user_label_tv = rootConvertView.findViewById(R.id.user_label_tv);
|
|
|
|
|
+ ViewUtil.setText(user_label_tv, userLabelList.getLabel_type_name());
|
|
|
|
|
+
|
|
|
|
|
+ TagFlowLayout tagList = rootConvertView.findViewById(R.id.user_label_tagflow_layout);
|
|
|
|
|
+ if(tagList != null) {
|
|
|
|
|
+ TagAdapter adapter = new TagAdapter<UserLabel>(userLabelList.getLabels()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public View getView(FlowLayout parent, int position, UserLabel userLabel) {
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv = (TextView) LayoutInflater.from(ActUserLabelList.this).inflate(R.layout.user_label, parent, false);
|
|
|
|
|
+ ViewUtil.setText(tv, userLabel.getLabel_name());
|
|
|
|
|
+ return tv;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- user_label_gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
|
|
- UserLabel userLabel;
|
|
|
|
|
- if ((userLabel = ListUtil.getIndex(item.getLabels(), i)) != null) {
|
|
|
|
|
- userLabel.setChecked(!userLabel.isChecked());
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ tagList.setAdapter(adapter);
|
|
|
|
|
+ tagList.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onTagClick(View view, int position, FlowLayout parent) {
|
|
|
|
|
+ UserLabel userLabel = ListUtil.getIndex(userLabelList.getLabels(), position);
|
|
|
|
|
+ if(userLabel != null) {
|
|
|
|
|
+ userLabel.setChecked(!userLabel.isChecked());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
- if(view instanceof CheckedTextView)
|
|
|
|
|
- ((CheckedTextView) view).setChecked(userLabel != null && userLabel.isChecked());
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ @OnClick({R.id.user_label_commit_tv})
|
|
|
|
|
+ public void onViewClicked(View view) {
|
|
|
|
|
+ switch (view.getId()) {
|
|
|
|
|
+ case R.id.user_label_commit_tv:
|
|
|
|
|
+ toCommit();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void toCommit() {
|
|
|
|
|
+ List<Integer> list = ListUtil.emptyList();
|
|
|
|
|
+ for (UserLabelList userLabelList : checkLabelList) {
|
|
|
|
|
+ for (UserLabel userLabel : userLabelList.getLabels()) {
|
|
|
|
|
+ if(userLabel.isChecked()) {
|
|
|
|
|
+ list.add(userLabel.getLabel_id());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ LogUtil.println("用户标签:"+list.size());
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("label_ids", list);
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().postLabelList(jsonObject)
|
|
|
|
|
+ .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));
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void finish() {
|
|
public void finish() {
|
|
|
- Jump2View.getInstance().gotoMain(this);
|
|
|
|
|
|
|
+ Jump2View.getInstance().goHomePageView(ActUserLabelList.this, null);
|
|
|
|
|
+ super.finish();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|