|
@ -5,6 +5,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
5
|
5
|
import androidx.recyclerview.widget.RecyclerView;
|
6
|
6
|
|
7
|
7
|
import android.content.Intent;
|
|
8
|
import android.graphics.Color;
|
8
|
9
|
import android.os.Bundle;
|
9
|
10
|
import android.util.Log;
|
10
|
11
|
import android.view.View;
|
|
@ -25,6 +26,7 @@ import com.zhy.http.okhttp.OkHttpUtils;
|
25
|
26
|
import com.zhy.http.okhttp.callback.StringCallback;
|
26
|
27
|
|
27
|
28
|
import java.net.URLEncoder;
|
|
29
|
import java.util.ArrayList;
|
28
|
30
|
import java.util.List;
|
29
|
31
|
|
30
|
32
|
import okhttp3.Call;
|
|
@ -36,7 +38,8 @@ public class CarOwnerCertificateListActivity extends AppCompatActivity {
|
36
|
38
|
private TextView add;
|
37
|
39
|
private CarOwnerCertificateListAdapter adapter;
|
38
|
40
|
private TextView no_data;
|
39
|
|
|
|
41
|
List<CarOwnerCertificateBean> mList = new ArrayList<>();
|
|
42
|
boolean canAdd = true;
|
40
|
43
|
private boolean firstTime;
|
41
|
44
|
|
42
|
45
|
@Override
|
|
@ -61,6 +64,8 @@ public class CarOwnerCertificateListActivity extends AppCompatActivity {
|
61
|
64
|
add.setOnClickListener(new View.OnClickListener() {
|
62
|
65
|
@Override
|
63
|
66
|
public void onClick(View v) {
|
|
67
|
if (canAdd == false)
|
|
68
|
return;
|
64
|
69
|
startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
|
65
|
70
|
}
|
66
|
71
|
});
|
|
@ -68,19 +73,20 @@ public class CarOwnerCertificateListActivity extends AppCompatActivity {
|
68
|
73
|
no_data = findViewById(R.id.no_data);
|
69
|
74
|
|
70
|
75
|
String data = getIntent().getStringExtra("data");
|
71
|
|
List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
|
72
|
|
if (list.size() >= 3) {
|
73
|
|
add.setVisibility(View.GONE);
|
|
76
|
mList = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
|
|
77
|
if (mList.size() >= 3) {
|
|
78
|
canAdd = false;
|
|
79
|
add.setTextColor(Color.parseColor("#CCCCCC"));
|
74
|
80
|
}
|
75
|
81
|
recycler_view = findViewById(R.id.recycler_view);
|
76
|
|
adapter = new CarOwnerCertificateListAdapter(this, list);
|
|
82
|
adapter = new CarOwnerCertificateListAdapter(this, mList);
|
77
|
83
|
recycler_view.setLayoutManager(new LinearLayoutManager(this));
|
78
|
84
|
recycler_view.setAdapter(adapter);
|
79
|
85
|
adapter.setRecyclerItemTypeClickListener(new RecyclerItemTypeClickListener() {
|
80
|
86
|
@Override
|
81
|
87
|
public void onItemClickListener(int position, int index) { // index 1:删除操作 2:编辑操作 3:设为主车型
|
82
|
88
|
|
83
|
|
CarOwnerCertificateBean bean = list.get(position);
|
|
89
|
CarOwnerCertificateBean bean = mList.get(position);
|
84
|
90
|
if (index == 1) {
|
85
|
91
|
deleteCarOwnerCertificate(bean.getId());
|
86
|
92
|
} else if (index == 2) {
|
|
@ -190,7 +196,7 @@ public class CarOwnerCertificateListActivity extends AppCompatActivity {
|
190
|
196
|
e.printStackTrace();
|
191
|
197
|
}
|
192
|
198
|
|
193
|
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&token=" + token;
|
|
199
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
|
194
|
200
|
OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
195
|
201
|
@Override
|
196
|
202
|
public void onError(Call call, Exception e) {
|
|
@ -205,14 +211,17 @@ public class CarOwnerCertificateListActivity extends AppCompatActivity {
|
205
|
211
|
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
|
206
|
212
|
if ("01".equals(rtnCode)) {
|
207
|
213
|
String data = JsonUtils.getKeyResult(response, "data");
|
208
|
|
List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
|
209
|
|
adapter.setData(list);
|
210
|
|
no_data.setVisibility(list.size() == 0 ? View.VISIBLE : View.GONE);
|
|
214
|
mList = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
|
|
215
|
adapter.setData(mList);
|
|
216
|
no_data.setVisibility(mList.size() == 0 ? View.VISIBLE : View.GONE);
|
211
|
217
|
|
212
|
|
if (list.size() >= 3) {
|
213
|
|
add.setVisibility(View.GONE);
|
|
218
|
if (mList.size() >= 3) {
|
|
219
|
canAdd = false;
|
|
220
|
add.setTextColor(Color.parseColor("#CCCCCC"));
|
214
|
221
|
} else {
|
|
222
|
canAdd = true;
|
215
|
223
|
add.setVisibility(View.VISIBLE);
|
|
224
|
add.setTextColor(Color.parseColor("#030303"));
|
216
|
225
|
}
|
217
|
226
|
} else {
|
218
|
227
|
String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
|