SettingsActivity.java
3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.lijinji.call;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lijinji.call.adapter.MenuBean;
import com.lijinji.call.adapter.RecyclerViewAdapter;
import com.lijinji.call.adapter.SettingsBean;
import com.lijinji.call.adapter.SettingsViewAdapter;
import com.lijinji.call.download.DownloadUtils;
import com.lijinji.call.util.CommonActivity;
import com.lijinji.call.util.Constant;
import com.lijinji.call.util.WMSLog;
import com.lijinji.call.util.WMSUtils;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class SettingsActivity extends CommonActivity {
@BindView(R.id.recycleSettingsView)
RecyclerView recycleSettingsView;
private Context mContext;
private SettingsViewAdapter adapter;
private ArrayList<SettingsBean> menuBeans;
private GridLayoutManager layoutManager;
private boolean isDownloading = false;
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
this.setTitle(this.getString(R.string.setting));
mContext = this;
initView();
}
private void initView() {
adapter = new SettingsViewAdapter(mContext);
layoutManager = new GridLayoutManager(mContext, 3);
recycleSettingsView.setLayoutManager(layoutManager);
recycleSettingsView.setAdapter(adapter);
menuBeans = buildMenuBeans();
if (menuBeans != null) {
adapter.setList(menuBeans);
}
adapter.setOnItemClickListener(listener);
}
private ArrayList<SettingsBean> buildMenuBeans() {
ArrayList<SettingsBean> menuBeans = new ArrayList<>();
menuBeans.add(new SettingsBean(mContext.getResources().getDrawable(R.mipmap.cangku), mContext.getString(R.string.current_warehouse), WMSUtils.getData(Constant.CURREN_WAREHOUSE)));
menuBeans.add(new SettingsBean(mContext.getResources().getDrawable(R.mipmap.station), mContext.getString(R.string.current_station), WMSUtils.getData(Constant.CURREN_LINE_NAME) + " " + WMSUtils.getData(Constant.CURREN_STATION)));
menuBeans.add(new SettingsBean(mContext.getResources().getDrawable(R.mipmap.upgrade), mContext.getString(R.string.upgrade), "当前版本:" + WMSUtils.getVersionName()));
menuBeans.add(new SettingsBean(mContext.getResources().getDrawable(R.mipmap.exit), mContext.getString(R.string.exit), ""));
return menuBeans;
}
private RecyclerViewAdapter.OnRecyclerViewItemClickListener listener = new RecyclerViewAdapter.OnRecyclerViewItemClickListener() {
@Override
public void onItemClick(int position) {
chooseItemListener(position);
}
};
private void chooseItemListener(int positino) {
SettingsBean bean = menuBeans.get(positino);
String name = bean.getName();
if (name.equals(mContext.getString(R.string.current_warehouse))) {
} else if (name.equals(mContext.getString(R.string.upgrade))) {
if(!isDownloading) {
DownloadUtils.as(mContext).startDownload();
isDownloading = true;
}
} else if (name.equals(mContext.getString(R.string.exit))) {
finish();
WMSUtils.startActivity(mContext, LoginActivity.class);
}
}
}