d
This commit is contained in:
@@ -39,7 +39,11 @@ import okhttp3.OkHttpClient;
|
||||
public class BaseApplication extends Application {
|
||||
|
||||
private static Context mContext;
|
||||
private static BaseApplication baseApplication;
|
||||
public static BaseApplication getInstance() {
|
||||
|
||||
return baseApplication;
|
||||
}
|
||||
|
||||
|
||||
private String str;
|
||||
@@ -52,6 +56,7 @@ public class BaseApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
baseApplication = this;
|
||||
mContext = this;
|
||||
//用户资料存储工具
|
||||
ProfileSpUtils.init(this);
|
||||
|
||||
@@ -4,32 +4,6 @@ import com.example.administrator.seven.test.BaseModel;
|
||||
|
||||
public class CommitDesignModel extends BaseModel {
|
||||
|
||||
|
||||
/**
|
||||
* result : {"msg":"提交成功","success":0}
|
||||
* status : 0
|
||||
*/
|
||||
|
||||
private ResultBean result;
|
||||
private int status;
|
||||
|
||||
public ResultBean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ResultBean result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public static class ResultBean {
|
||||
/**
|
||||
* msg : 提交成功
|
||||
* success : 0
|
||||
@@ -53,5 +27,5 @@ public class CommitDesignModel extends BaseModel {
|
||||
public void setSuccess(int success) {
|
||||
this.success = success;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class JsonBeantwo implements IPickerViewData {
|
||||
|
||||
@Override
|
||||
public String getPickerViewText() {
|
||||
return this.areaName+","+this.areaId;
|
||||
return this.areaName;
|
||||
}
|
||||
|
||||
public static class CitiesBean {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.example.administrator.seven.main.kehu.Bean;
|
||||
|
||||
import com.example.administrator.seven.test.BaseModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Time: 2020/8/20
|
||||
* Author: jianbo
|
||||
* Description:
|
||||
*/
|
||||
public class industryBean extends BaseModel {
|
||||
|
||||
/**
|
||||
* result : {"msg":"成功","data":[{"industry_id":"1","industry":"家具"}],"success":0}
|
||||
* status : 0
|
||||
*/
|
||||
|
||||
private ResultBean result;
|
||||
private int status;
|
||||
|
||||
public ResultBean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ResultBean result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public static class ResultBean {
|
||||
/**
|
||||
* msg : 成功
|
||||
* data : [{"industry_id":"1","industry":"家具"}]
|
||||
* success : 0
|
||||
*/
|
||||
|
||||
private String msg;
|
||||
private int success;
|
||||
private List<DataBean> data;
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(int success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public List<DataBean> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<DataBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static class DataBean {
|
||||
/**
|
||||
* industry_id : 1
|
||||
* industry : 家具
|
||||
*/
|
||||
|
||||
private String industry_id;
|
||||
private String industry;
|
||||
|
||||
public String getIndustry_id() {
|
||||
return industry_id;
|
||||
}
|
||||
|
||||
public void setIndustry_id(String industry_id) {
|
||||
this.industry_id = industry_id;
|
||||
}
|
||||
|
||||
public String getIndustry() {
|
||||
return industry;
|
||||
}
|
||||
|
||||
public void setIndustry(String industry) {
|
||||
this.industry = industry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,6 +151,7 @@ public class TraceFragment extends BaseFragment implements View.OnClickListener
|
||||
default:
|
||||
break;
|
||||
case R.id.bt_sousuo_ditu:
|
||||
ShowAty.SearchActivity(getActivity());
|
||||
break;
|
||||
case R.id.enter_shop_shai:
|
||||
break;
|
||||
|
||||
@@ -1,12 +1,36 @@
|
||||
package com.example.administrator.seven.main.kehu.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.example.administrator.seven.JsonUtils;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.example.administrator.seven.db.DbRecordBeanData;
|
||||
import com.example.administrator.seven.main.kehu.Bean.customerFPListBean;
|
||||
import com.example.administrator.seven.okgonet.NetApi;
|
||||
import com.example.administrator.seven.okgonet.Observer;
|
||||
import com.example.administrator.seven.utils.GlideTools;
|
||||
import com.example.administrator.seven.utils.ToastUtils;
|
||||
import com.example.administrator.seven.utils.ToolsText;
|
||||
import com.example.administrator.seven.utils.WidgetTools;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
import com.example.administrator.seven.widget.CircleImageView;
|
||||
import com.example.administrator.seven.widget.TitleBar;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 客户详情
|
||||
@@ -15,61 +39,83 @@ public class CustomerDetailActivity extends BaseActivity {
|
||||
|
||||
private TitleBar mTitleBar;
|
||||
private CircleImageView mIvDraUserHeads;
|
||||
/**
|
||||
* 姓名:--
|
||||
*/
|
||||
private TextView mTvDraUserName;
|
||||
/**
|
||||
* 电话:— —
|
||||
*/
|
||||
private TextView mTvDarUserPhone;
|
||||
/**
|
||||
* 家装阶段:
|
||||
*/
|
||||
private TextView mTvDraInfo01;
|
||||
/**
|
||||
* 毛胚
|
||||
*/
|
||||
private TextView mTvDraInfo02;
|
||||
/**
|
||||
* 风格
|
||||
*/
|
||||
private TextView mTvDraInfo03;
|
||||
/**
|
||||
* 美式
|
||||
*/
|
||||
private TextView mTvDraInfo04;
|
||||
/**
|
||||
* 预算
|
||||
*/
|
||||
private TextView mTvDraInfo05;
|
||||
/**
|
||||
* 10万
|
||||
*/
|
||||
private TextView mTvDraInfo06;
|
||||
private String namephone;
|
||||
private String customer_id;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_customer_detail);
|
||||
namephone = getIntent().getStringExtra("namephone");
|
||||
customer_id = getIntent().getStringExtra("customer_id");
|
||||
initView();
|
||||
initNormalBack();
|
||||
getData(customer_id);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mTitleBar = (TitleBar) findViewById(R.id.title_bar);
|
||||
mTitleBar.setTitle(namephone);
|
||||
mIvDraUserHeads = (CircleImageView) findViewById(R.id.iv_dra_user_heads);
|
||||
mTvDraUserName = (TextView) findViewById(R.id.tv_dra_user_name);
|
||||
mTvDarUserPhone = (TextView) findViewById(R.id.tv_dar_user_phone);
|
||||
mTvDraInfo01 = (TextView) findViewById(R.id.tv_dra_info01);
|
||||
mTvDraInfo02 = (TextView) findViewById(R.id.tv_dra_info02);
|
||||
mTvDraInfo03 = (TextView) findViewById(R.id.tv_dra_info03);
|
||||
mTvDraInfo04 = (TextView) findViewById(R.id.tv_dra_info04);
|
||||
mTvDraInfo05 = (TextView) findViewById(R.id.tv_dra_info05);
|
||||
mTvDraInfo06 = (TextView) findViewById(R.id.tv_dra_info06);
|
||||
}
|
||||
public void getData(String customer_id) {
|
||||
new NetApi().customerDetail(customer_id).subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
String body = (String) response.body();
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
String result = jsonObject.optString("result");
|
||||
Log.d("okgo的返回结果result", result);
|
||||
JSONObject result1 = jsonObject.getJSONObject("result");
|
||||
String success = result1.getString("success");
|
||||
String msg = result1.getString("msg");
|
||||
if (success.equals("0")) {
|
||||
String data1 = result1.getString("data");
|
||||
Map<String, Object> data = JSON.parseObject(data1, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
GlideTools.init(CustomerDetailActivity.this).displaypic(mIvDraUserHeads, ToolsText.getValue(data, "customer_head"), R.mipmap.icon_default_head);
|
||||
String name = ToolsText.getValue(data, "name");
|
||||
String phone = ToolsText.getValue(data, "phone");
|
||||
mTitleBar.setTitle(name+phone);
|
||||
WidgetTools.setTextfive(mTvDraUserName, "", ToolsText.getValue(data, "wechat"));
|
||||
WidgetTools.setTextfive(mTvDarUserPhone, "", ToolsText.getValue(data, "address"));
|
||||
//1:毛坯,2:精装,3:旧房改造
|
||||
switch (ToolsText.getValue(data, "decoration")){
|
||||
case "1":
|
||||
WidgetTools.setTextfive(mTvDraInfo02, "", ToolsText.getValue(data, "毛坯"));
|
||||
break;
|
||||
case "2":
|
||||
WidgetTools.setTextfive(mTvDraInfo02, "", ToolsText.getValue(data, "精装"));
|
||||
break;
|
||||
case "3":
|
||||
WidgetTools.setTextfive(mTvDraInfo02, "", ToolsText.getValue(data, "旧房改造"));
|
||||
break;
|
||||
}
|
||||
|
||||
WidgetTools.setTextfive(mTvDraInfo04, "4.户型面积:", ToolsText.getValue(data, "style_name"));
|
||||
WidgetTools.setTextfive(mTvDraInfo06, "6.备 注:", ToolsText.getValue(data, "budget"));
|
||||
|
||||
}else {
|
||||
ToastUtils.showToast(CustomerDetailActivity.this, msg);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.example.administrator.seven.main.kehu.activity;//package com.example.administrator.seven.main.kehu.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -15,18 +21,23 @@ import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.example.administrator.seven.GetJsonDataUtil;
|
||||
import com.example.administrator.seven.JsonUtils;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseTreeActivity;
|
||||
import com.example.administrator.seven.db.DbRecordBeanData;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.JsonBeantwo;
|
||||
import com.example.administrator.seven.main.kehu.Bean.PhotoeditorBean;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.contract.CommitDesignContract;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.presenter.CommitDesignPresenter;
|
||||
import com.example.administrator.seven.main.kehu.adapter.DesignAdapter;
|
||||
import com.example.administrator.seven.okgonet.NetApi;
|
||||
import com.example.administrator.seven.okgonet.Observer;
|
||||
import com.example.administrator.seven.utils.StringUtils;
|
||||
import com.example.administrator.seven.utils.ToastUtils;
|
||||
import com.example.administrator.seven.widget.TitleBar;
|
||||
import com.google.gson.Gson;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
@@ -50,16 +61,16 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
private static final int MSG_LOAD_FAILED = 0x0003;
|
||||
|
||||
private static boolean isLoaded = false;
|
||||
|
||||
private String mActivityType, userType, checkType, isEdit = "0", orderId, orderNum, userPhone, paymentpaper = "", isFocus = "0", province = "", city = "", area = "",
|
||||
orderType, visitor_id, returnnum = "", uid, checkTypetb, unique_only = "", phone, userName = "";
|
||||
|
||||
private ArrayAdapter<String> dingdanTypeAdapter;
|
||||
private ListView dingdanTypeLv;
|
||||
private PopupWindow dingdanTypePw;
|
||||
private List<DbRecordBeanData> dataBean;
|
||||
|
||||
private TextView btn_add;
|
||||
private TextView btn_add,btn_commit;
|
||||
private RecyclerView mLabelRvList;
|
||||
private DesignAdapter adapter;
|
||||
private List<PhotoeditorBean> photoeditor=new ArrayList<>();
|
||||
private List<PhotoeditorBean> photoeditor = new ArrayList<>();
|
||||
private List<industryBean.ResultBean.DataBean> industryData;
|
||||
private ArrayList<String> dingdanTypeList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -71,10 +82,28 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
mTitleBar = (TitleBar) findViewById(R.id.title_bar);
|
||||
mTitleBar.setTitle("客户分配");
|
||||
btn_add = (TextView) findViewById(R.id.btn_add);
|
||||
btn_commit = (TextView) findViewById(R.id.btn_commit);
|
||||
|
||||
//第一部分的数据
|
||||
mLabelRvList = (RecyclerView) findViewById(R.id.label_rv_list);
|
||||
//获得行业数据
|
||||
// getPresenter().getindustry();
|
||||
new NetApi().industry().subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
String body = (String) response.body();
|
||||
industryBean.ResultBean result = JsonUtils.fromJson(body, industryBean.class).getResult();
|
||||
if (result != null && String.valueOf(result.getSuccess()).equals("0")) {
|
||||
industryData = result.getData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -100,30 +129,28 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
mLabelRvList.setAdapter(adapter);
|
||||
adapter.operationListenner(new DesignAdapter.DesignItemviewOnClickListener() {
|
||||
@Override
|
||||
public void fphangye() {
|
||||
|
||||
public void fphangye(RelativeLayout rl_dingdan_type, TextView tv_dingdan_type, int position) {
|
||||
//下来选择行业
|
||||
initDingdanTypePopup(rl_dingdan_type, tv_dingdan_type, position);
|
||||
if (dingdanTypePw != null && !dingdanTypePw.isShowing()) {
|
||||
dingdanTypePw.showAsDropDown(rl_dingdan_type, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void address() {
|
||||
|
||||
public void address(TextView et_area01, TextView et_area02, int position) {
|
||||
if (isLoaded) {
|
||||
showPickerView();
|
||||
showPickerView(et_area01, et_area02, position);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onsuccress() {
|
||||
// finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initEvent() {
|
||||
btn_add.setOnClickListener(this);
|
||||
btn_commit.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,24 +160,41 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
finish();
|
||||
break;
|
||||
case R.id.btn_commit://添加图文编辑
|
||||
for (int i = 0; i < photoeditor.size(); i++) {
|
||||
if (TextUtils.isEmpty(photoeditor.get(i).getIndustry_id()) || photoeditor.get(i).getIndustry_id().equals("")) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请选择行业");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(photoeditor.get(i).getProvince()) || photoeditor.get(i).getProvince().equals("")) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请选择省");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(photoeditor.get(i).getCity()) || photoeditor.get(i).getCity().equals("")) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请选择市");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < photoeditor.size(); i++) {
|
||||
PhotoeditorBean photoeditorBean = photoeditor.get(i);
|
||||
String industry_id = photoeditorBean.getIndustry_id();
|
||||
if(StringUtils.isEmpty(industry_id)) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请完善行业信息");
|
||||
return;
|
||||
}
|
||||
String city = photoeditorBean.getCity();
|
||||
if(StringUtils.isEmpty(city)) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请完善城市选择");
|
||||
return;
|
||||
}
|
||||
String province = photoeditorBean.getProvince();
|
||||
if(StringUtils.isEmpty(province)) {
|
||||
ToastUtils.showToast(DesignActivity.this, "请完善城市选择");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<PhotoeditorBean> contents = new ArrayList<>();
|
||||
for (int i = 0; i < dataBean.size(); i++) {
|
||||
String customer_id = dataBean.get(i).getCustomer_id();
|
||||
for (int j = 0; j < photoeditor.size(); j++) {
|
||||
PhotoeditorBean photoeditorBean = photoeditor.get(j);
|
||||
photoeditorBean.setCustomer_id(customer_id);
|
||||
contents.add(photoeditorBean);
|
||||
}
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
String strtext = gson.toJson(photoeditor);
|
||||
String strtext = gson.toJson(contents);
|
||||
getPresenter().commitdesign(strtext);
|
||||
break;
|
||||
case R.id.btn_add://添加图文编辑
|
||||
@@ -168,6 +212,45 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单类型
|
||||
*/
|
||||
private void initDingdanTypePopup(RelativeLayout rl_dingdan_type, final TextView tv_dingdan_type, int position) {
|
||||
|
||||
dingdanTypeList.clear();
|
||||
for (int i = 0; i < industryData.size(); i++) {
|
||||
dingdanTypeList.add(industryData.get(i).getIndustry());
|
||||
}
|
||||
dingdanTypeLv = new ListView(this);
|
||||
// 设置适配器
|
||||
dingdanTypeAdapter = new ArrayAdapter<String>(this, R.layout.order_type_dialog_view, dingdanTypeList);
|
||||
|
||||
dingdanTypeLv.setAdapter(dingdanTypeAdapter);
|
||||
|
||||
dingdanTypeLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
String industry = industryData.get(position).getIndustry();
|
||||
String industry_id = industryData.get(position).getIndustry_id();
|
||||
tv_dingdan_type.setText(industry);
|
||||
photoeditor.get(position).setIndustry_id(industry_id);
|
||||
dingdanTypePw.dismiss();
|
||||
}
|
||||
});
|
||||
dingdanTypePw = new PopupWindow(dingdanTypeLv, rl_dingdan_type.getWidth(), ActionBar.LayoutParams.WRAP_CONTENT, true);
|
||||
dingdanTypePw.setBackgroundDrawable(getResources().getDrawable(R.drawable.window_po_bg));
|
||||
dingdanTypePw.setFocusable(true);
|
||||
dingdanTypePw.setOutsideTouchable(true);
|
||||
dingdanTypePw.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
// 关闭popup窗口
|
||||
dingdanTypePw.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return DesignActivity.this;
|
||||
@@ -178,11 +261,6 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
return DesignActivity.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commitdesign(CommitDesignModel commitDesignModel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void progress() {
|
||||
showProgressDialog("加载中...");
|
||||
@@ -238,7 +316,7 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
};
|
||||
|
||||
|
||||
private void showPickerView() {// 弹出选择器
|
||||
private void showPickerView(final TextView et_area01, final TextView et_area02, final int position) {// 弹出选择器
|
||||
|
||||
OptionsPickerView pvOptions = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
|
||||
@Override
|
||||
@@ -257,8 +335,13 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
String opt2idtx = options2Itemids.size() > 0
|
||||
&& options2Itemids.get(options1).size() > 0 ?
|
||||
options2Itemids.get(options1).get(options2) : "";
|
||||
String tx = opt1tx + opt2tx +opt1txx+","+opt2idtx ;
|
||||
Toast.makeText(DesignActivity.this, tx, Toast.LENGTH_SHORT).show();
|
||||
String tx = opt1tx + opt2tx + opt1txx + "," + opt2idtx;
|
||||
//Toast.makeText(DesignActivity.this, tx, Toast.LENGTH_SHORT).show();
|
||||
et_area01.setText(opt1tx);
|
||||
et_area02.setText(opt2tx);
|
||||
photoeditor.get(position).setProvince(opt1txx);
|
||||
photoeditor.get(position).setCity(opt2idtx);
|
||||
Log.e("选择的城市", tx);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -313,12 +396,10 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
}
|
||||
|
||||
|
||||
|
||||
mHandler.sendEmptyMessage(MSG_LOAD_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<JsonBeantwo> parseData(String result) {//Gson 解析
|
||||
ArrayList<JsonBeantwo> detail = new ArrayList<>();
|
||||
try {
|
||||
@@ -335,7 +416,6 @@ public class DesignActivity extends BaseTreeActivity<CommitDesignContract.View,
|
||||
return detail;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -124,8 +124,6 @@ public class JsonDataActivity extends AppCompatActivity implements View.OnClickL
|
||||
options2Itemids.get(options1).get(options2) : "";
|
||||
String tx = opt1tx + opt2tx +opt1txx+","+opt2idtx ;
|
||||
Toast.makeText(JsonDataActivity.this, tx, Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.example.administrator.seven.main.kehu.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.example.administrator.seven.main.kehu.adapter.SearchAdapter;
|
||||
import com.example.administrator.seven.utils.BaseAdapter;
|
||||
import com.example.administrator.seven.utils.LocatData;
|
||||
import com.example.administrator.seven.utils.ToastUtils;
|
||||
import com.example.administrator.seven.widget.ListViewForScrollView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SearchActivity extends BaseActivity implements View.OnClickListener {
|
||||
EditText etSearch;
|
||||
TextView tvCancel;
|
||||
TextView tvEmpty;
|
||||
ListViewForScrollView lvItem;
|
||||
SearchAdapter mAdapter;
|
||||
boolean isGoods = false;
|
||||
private TextView mTvCancel;
|
||||
private RelativeLayout bt_sousuo_ditu;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.ac_search);
|
||||
initView();
|
||||
initNormalBack();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
// mTitleBar = (TitleBar) findViewById(R.id.title_bar);
|
||||
etSearch = (EditText) findViewById(R.id.etSearchh);
|
||||
tvCancel = (TextView) findViewById(R.id.tvCancel);
|
||||
tvCancel.setOnClickListener(this);
|
||||
tvEmpty = (TextView) findViewById(R.id.tvEmpty);
|
||||
tvEmpty.setOnClickListener(this);
|
||||
lvItem = (ListViewForScrollView) findViewById(R.id.lvItem);
|
||||
mTvCancel = (TextView) findViewById(R.id.tvCancel);
|
||||
mTvCancel.setOnClickListener(this);
|
||||
bt_sousuo_ditu = (RelativeLayout) findViewById(R.id.bt_sousuo_ditu);
|
||||
bt_sousuo_ditu.setOnClickListener(this);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
protected void Init() {
|
||||
etSearch.setHint("请输入客户姓名、电话");
|
||||
mAdapter = new SearchAdapter(SearchActivity.this);
|
||||
mAdapter.setAdpListener(new BaseAdapter.IAdpListener() {
|
||||
@Override
|
||||
public void onItemEvent(Object data, int flag, int position) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
lvItem.setAdapter(mAdapter);
|
||||
//
|
||||
mAdapter.setList( LocatData.Init().getGoods());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.bt_sousuo_ditu: //取消
|
||||
String seachStr = etSearch.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(seachStr)) {
|
||||
//保存数据
|
||||
LocatData.Init().addGood(seachStr);
|
||||
// finish();
|
||||
} else {
|
||||
ToastUtils.showToast(SearchActivity.this,"搜索条件不能为空!");
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
case R.id.tvCancel: //取消
|
||||
etSearch.setHint("请输入客户姓名、电话");
|
||||
break;
|
||||
case R.id.tvEmpty: //清空历史搜索记录
|
||||
if (isGoods) {
|
||||
LocatData.Init().clearGood();
|
||||
} else {
|
||||
LocatData.Init().clearPost();
|
||||
}
|
||||
mAdapter.setList(new ArrayList<String>());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,14 @@ public class ShowAty {
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
public static void SearchActivity(Context ctx) {
|
||||
Intent i = new Intent(ctx, SearchActivity.class);
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 客户详情
|
||||
@@ -39,6 +47,7 @@ public class ShowAty {
|
||||
public static void CustomerDetailActivity(Context ctx, CustomerListBean.ResultBean.DataBean item) {
|
||||
Intent i = new Intent(ctx, CustomerDetailActivity.class);
|
||||
i.putExtra("namephone",item.getName()+item.getPhone());
|
||||
i.putExtra("customer_id",item.getCustomer_id());
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.PhotoeditorBean;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.BaseMenDianView;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
|
||||
@@ -12,14 +13,10 @@ import com.example.administrator.seven.network.ApiCallBack;
|
||||
public interface CommitDesignContract {
|
||||
interface Model {
|
||||
|
||||
//详细信息
|
||||
//提交信息
|
||||
void commitdesign(String content,
|
||||
final ApiCallBack<CommitDesignModel> callBack);
|
||||
|
||||
|
||||
|
||||
void worksReedit(String uid, String workid, String project_id, final ApiCallBack<PhotoeditorBean> callBack);//重新编辑
|
||||
|
||||
}
|
||||
|
||||
interface View extends BaseMenDianView {
|
||||
@@ -28,19 +25,15 @@ public interface CommitDesignContract {
|
||||
|
||||
Activity getActivity();
|
||||
|
||||
void commitdesign(CommitDesignModel commitDesignModel);
|
||||
|
||||
void progress();
|
||||
|
||||
void hideProgress();
|
||||
|
||||
void onsuccress();
|
||||
|
||||
}
|
||||
|
||||
interface Presenter {
|
||||
|
||||
void commitdesign(String uid);//提交方案设计
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.example.administrator.seven.main.kehu.activity.mvp.model;
|
||||
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.PhotoeditorBean;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.contract.CommitDesignContract;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
import com.example.administrator.seven.network.http.ApiUtils;
|
||||
@@ -35,11 +36,4 @@ public class CommitDesignModeltwo implements CommitDesignContract.Model {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void worksReedit(String uid, String workid, String project_id, final ApiCallBack<PhotoeditorBean> callBack) {
|
||||
|
||||
PhotoeditorBean worksReeditBean = new PhotoeditorBean();
|
||||
//callBack.onResponse(worksReeditBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.administrator.seven.main.kehu.activity.mvp.presenter;
|
||||
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.contract.CommitDesignContract;
|
||||
import com.example.administrator.seven.main.kehu.activity.mvp.model.CommitDesignModeltwo;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
@@ -21,8 +22,8 @@ public class CommitDesignPresenter extends MvpBasePresenter<CommitDesignContract
|
||||
mModel.commitdesign(content, new ApiCallBack<CommitDesignModel>() {
|
||||
@Override
|
||||
protected void onSuccess(CommitDesignModel responseData, String message) {
|
||||
if (responseData.getResult().getSuccess() == 0) {
|
||||
ToastUtils.showToast(getView().getContext(), responseData.getResult().getMsg());
|
||||
if (responseData.getSuccess() == 0) {
|
||||
ToastUtils.showToast(getView().getContext(), responseData.getMsg());
|
||||
getView().getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.example.administrator.seven.main.kehu.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -22,23 +23,27 @@ public class DesignAdapter extends BaseQuickAdapter<PhotoeditorBean, BaseViewHol
|
||||
Context mcontext;
|
||||
DesignItemviewOnClickListener onViewClickListener;
|
||||
public DesignAdapter(Context context, List list) {
|
||||
super(R.layout.activity_design_two, list);
|
||||
super(R.layout.item_design_two, list);
|
||||
this.mcontext = context;
|
||||
}
|
||||
@Override
|
||||
protected void convert(final BaseViewHolder helper, final PhotoeditorBean item) {
|
||||
RelativeLayout rl_dingdan_type = (RelativeLayout)helper.getView(R.id.rl_dingdan_type);
|
||||
TextView et_receive_collect = (TextView)helper.getView(R.id.et_receive_collect);
|
||||
final RelativeLayout rl_dingdan_type = (RelativeLayout)helper.getView(R.id.rl_dingdan_type);
|
||||
LinearLayout et_receive_collect = (LinearLayout)helper.getView(R.id.et_receive_collect);
|
||||
final TextView et_area01 = (TextView)helper.getView(R.id.et_area01);
|
||||
final TextView et_area02 = (TextView)helper.getView(R.id.et_area02);
|
||||
final TextView tv_dingdan_type = (TextView)helper.getView(R.id.tv_dingdan_type);
|
||||
final int position = helper.getAdapterPosition();
|
||||
rl_dingdan_type.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.fphangye();
|
||||
onViewClickListener.fphangye(rl_dingdan_type,tv_dingdan_type, position);
|
||||
}
|
||||
});
|
||||
et_receive_collect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.address();
|
||||
onViewClickListener.address(et_area01,et_area02, position);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -50,8 +55,8 @@ public class DesignAdapter extends BaseQuickAdapter<PhotoeditorBean, BaseViewHol
|
||||
|
||||
public interface DesignItemviewOnClickListener {
|
||||
|
||||
void fphangye();
|
||||
void address();
|
||||
void fphangye(RelativeLayout rl_dingdan_type,TextView tv_dingdan_type,int position);
|
||||
void address(TextView et_area01,TextView et_area02,int position);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.example.administrator.seven.main.kehu.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.main.kehu.activity.SearchActivity;
|
||||
import com.example.administrator.seven.utils.BaseAdapter;
|
||||
|
||||
/**
|
||||
* 搜索历史
|
||||
* @author lin04
|
||||
*
|
||||
*/
|
||||
public class SearchAdapter extends BaseAdapter<String> {
|
||||
|
||||
public SearchAdapter(SearchActivity context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View getConvertView(final int position, View convertView, ViewGroup parent) {
|
||||
if(convertView == null)
|
||||
convertView = mInflater.inflate(R.layout.it_search, null);
|
||||
TextView tvItem = Get(convertView, R.id.tvItem);
|
||||
setText(tvItem, mList.get(position));
|
||||
|
||||
convertView.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(null!=mListener)
|
||||
mListener.onItemEvent(mList.get(position), 0, position);
|
||||
// if("0".equals(poFrom)) { //搜索商品
|
||||
// JumpUtils.gotoActivity((Activity) mContext, MallListActivity.class, false, "mSearchStr", "开心");
|
||||
// }else { //搜索帖子
|
||||
// JumpUtils.gotoActivity((Activity) mContext, SearchResultActivity.class, false, "mSearchStr", "开心");
|
||||
// }
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,13 @@ package com.example.administrator.seven.network.http;
|
||||
|
||||
import com.example.administrator.seven.main.entity.LoginBean;
|
||||
import com.example.administrator.seven.main.entity.mine.TreeUserEntity;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
@@ -117,18 +120,18 @@ public class MyApi {
|
||||
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
* 确认分配
|
||||
*
|
||||
* @param uid 登录员工的uid
|
||||
* @param content 分配内容[{"customer_id":"客户1","industry_id":"家具id","province":"610000","city":"610100"},{"customer_id":"客户1","industry_id":"建材id","province":"610000","city":"610100"},{"customer_id":"客户2","industry_id":"家具id","province":"610000","city":"610100"},{"customer_id":"客户2","industry_id":"建材id","province":"610000","city":"610100"}]
|
||||
* @return
|
||||
*/
|
||||
@POST("AppCustomer/sureFP")
|
||||
// @POST("/device/DevLogin/accountPwd")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<LoginBean>> sureFP(@Field("uid") String uid
|
||||
Observable<ResponseBean<CommitDesignModel>> sureFP(@Field("uid") String uid
|
||||
, @Field("content") String content);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -421,6 +421,14 @@ public class HttpConstants {
|
||||
* 确认分配
|
||||
*/
|
||||
public static String URi_device_AppCustomer_sureFP = URiBase + "/device/AppCustomer/sureFP";
|
||||
|
||||
/**
|
||||
* 行业
|
||||
*/
|
||||
public static String URi_device_AppCustomer_industry = URiBase + "/device/AppCustomer/industry";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -328,4 +328,48 @@ public class NetApi {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 行业
|
||||
*/
|
||||
public Observable<Response> industry() {
|
||||
|
||||
return new Observable<Response>() {
|
||||
@Override
|
||||
public void subscribe(final Observer<Response> observer) {
|
||||
|
||||
OkGo.<String>post(HttpConstants.URi_device_AppCustomer_industry)//
|
||||
.converter(new StringConvert())//
|
||||
.cacheMode(CacheMode.NO_CACHE) //无缓存模式 CacheMode.NO_CACHE
|
||||
.adapt(new ObservableResponse<String>())//
|
||||
.subscribeOn(Schedulers.io())//
|
||||
.observeOn(AndroidSchedulers.mainThread())//
|
||||
.subscribe(new io.reactivex.Observer<Response<String>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
// addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Response<String> response) {
|
||||
observer.onNext(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseAdapter<T> extends android.widget.BaseAdapter {
|
||||
protected LayoutInflater mInflater;
|
||||
protected Context mContext;
|
||||
protected SparseArray<View> viewHolder;
|
||||
protected IAdpListener mListener;
|
||||
protected final List<T> mList = new ArrayList<T>();
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param dataList
|
||||
*/
|
||||
public BaseAdapter(Context context) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.mContext = context;
|
||||
this.mInflater = LayoutInflater.from(mContext);
|
||||
}
|
||||
|
||||
public void setAdpListener(IAdpListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return mList;
|
||||
}
|
||||
|
||||
public void setList(List<T> list) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void appendToList(List<T> list) {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void appendToTopList(List<T> list) {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
mList.addAll(0, list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mList.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mList == null ? 0 : mList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getItem(int position) {
|
||||
return mList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getConvertView(position, convertView, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* getConvertView
|
||||
*
|
||||
* @param position
|
||||
* @param convertView
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
protected abstract View getConvertView(int position, View convertView,
|
||||
ViewGroup parent);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param view
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "hiding" })
|
||||
protected <T extends View> T Get(View view, int id) {
|
||||
viewHolder = (SparseArray<View>) view.getTag();
|
||||
if (viewHolder == null) {
|
||||
viewHolder = new SparseArray<View>();
|
||||
view.setTag(viewHolder);
|
||||
}
|
||||
View childView = viewHolder.get(id);
|
||||
if (childView == null) {
|
||||
childView = view.findViewById(id);
|
||||
viewHolder.put(id, childView);
|
||||
}
|
||||
return (T) childView;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param view
|
||||
* @param id
|
||||
* @param text
|
||||
*/
|
||||
protected void setText(View v, String text) {
|
||||
if(v==null)
|
||||
return ;
|
||||
if (TextUtils.isEmpty(text))
|
||||
text = "";
|
||||
if (v instanceof TextView) {// TextView
|
||||
((TextView) v).setText(text);
|
||||
return;
|
||||
}
|
||||
if (v instanceof Button) {// Button
|
||||
((Button) v).setText(text);
|
||||
return;
|
||||
}
|
||||
if (v instanceof CheckBox) {// CheckBox
|
||||
((CheckBox) v).setText(text);
|
||||
return;
|
||||
}
|
||||
if (v instanceof RadioButton) {// RadioButton
|
||||
((RadioButton) v).setText(text);
|
||||
return;
|
||||
}
|
||||
if (v instanceof EditText) {// EditText
|
||||
((EditText) v).setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: IAdpListener
|
||||
* @Description: TODO(描述: )
|
||||
* @author Lijc
|
||||
* @Company: BlueMobi
|
||||
* @date 2015<31>?5<>?5<>? 上午10:00:15
|
||||
* @version V1.0
|
||||
*/
|
||||
public interface IAdpListener {
|
||||
/**
|
||||
* Item点击事件
|
||||
*
|
||||
* @param data
|
||||
* 数据
|
||||
* @param flag
|
||||
* 事件标志
|
||||
* @param position
|
||||
* 位置
|
||||
*/
|
||||
public void onItemEvent(Object data, int flag, int position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import com.example.administrator.seven.BaseApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LocatData {
|
||||
/** Shared */
|
||||
public static final String APP_SHARED_NAME = "svojcll.shared";
|
||||
/** */
|
||||
public static final String APP_SOSO_HISTORY_POST = "data.soso.history.post";
|
||||
/** */
|
||||
public static final String APP_SOSO_HISTORY_GOOD = "data.soso.history.good";
|
||||
/** */
|
||||
public static final String APP_LOGIN = "data.login.infor";
|
||||
/** */
|
||||
public static final String APP_USER = "data.user.infor";
|
||||
// 单例模式
|
||||
private static LocatData instance;
|
||||
|
||||
|
||||
/** */
|
||||
public static final String AD_IMG_URL = "data.ad.img.urls";
|
||||
/** */
|
||||
public static final String AD_IMG_PATH = "data.ad.img.path";
|
||||
|
||||
public void putAdPath(String path) {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(AD_IMG_PATH, path);
|
||||
}
|
||||
|
||||
public String getAdPath() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
return sharedTools.getObject(AD_IMG_PATH, String.class);
|
||||
}
|
||||
|
||||
public void putAdUrl(String path) {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(AD_IMG_URL, path);
|
||||
}
|
||||
|
||||
public String getAdUrl() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
return sharedTools.getObject(AD_IMG_URL, String.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private LocatData() {
|
||||
}
|
||||
|
||||
public static LocatData Init() {
|
||||
// mContext = ctx;
|
||||
// TODO 双重校验锁
|
||||
if (null == instance) {
|
||||
synchronized (LocatData.class) {
|
||||
if (null == instance) {
|
||||
instance = new LocatData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** 清空本地历史搜索 */
|
||||
public void clearPost() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(APP_SOSO_HISTORY_POST, "");
|
||||
}
|
||||
|
||||
/** 添加搜索KEY合集 */
|
||||
public void addPost(String sosoKey) {
|
||||
List<String> tempList = getPosts();
|
||||
|
||||
if (tempList.contains(sosoKey)) {
|
||||
tempList.remove(sosoKey);
|
||||
}
|
||||
tempList.add(0, sosoKey);
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
for (int i = 0; i < tempList.size(); i++) {
|
||||
sb.append(tempList.get(i));
|
||||
if (i < tempList.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(APP_SOSO_HISTORY_POST, sb.toString());
|
||||
|
||||
}
|
||||
|
||||
/** 获取搜索KEY合集 */
|
||||
private String getPostStr() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
String temp = sharedTools
|
||||
.getObject(APP_SOSO_HISTORY_POST, String.class);
|
||||
return (null == temp || "".equals(temp) ? "" : temp);
|
||||
}
|
||||
|
||||
/** 获取搜索KEY合集 */
|
||||
public List<String> getPosts() {
|
||||
String temp = getPostStr();
|
||||
if ("".equals(temp)) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
List<String> tempList = new ArrayList<String>();
|
||||
String[] str = temp.split(",");
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
tempList.add(str[i]);
|
||||
}
|
||||
return tempList;
|
||||
|
||||
}
|
||||
|
||||
/** 清空本地历史搜索 */
|
||||
public void clearGood() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(APP_SOSO_HISTORY_GOOD, "");
|
||||
}
|
||||
|
||||
/** 添加搜索KEY合集 */
|
||||
public void addGood(String sosoKey) {
|
||||
List<String> tempList = getGoods();
|
||||
|
||||
if (tempList.contains(sosoKey)) {
|
||||
tempList.remove(sosoKey);
|
||||
}
|
||||
tempList.add(0, sosoKey);
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
for (int i = 0; i < tempList.size(); i++) {
|
||||
sb.append(tempList.get(i));
|
||||
if (i < tempList.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
sharedTools.setObject(APP_SOSO_HISTORY_GOOD, sb.toString());
|
||||
}
|
||||
|
||||
/** 获取搜索KEY合集 */
|
||||
private String getGoodStr() {
|
||||
SharedTools sharedTools = new SharedTools(
|
||||
BaseApplication.getInstance(), APP_SHARED_NAME);
|
||||
String temp = sharedTools
|
||||
.getObject(APP_SOSO_HISTORY_GOOD, String.class);
|
||||
return (null == temp || "".equals(temp) ? "" : temp);
|
||||
}
|
||||
|
||||
/** 获取搜索KEY合集 */
|
||||
public List<String> getGoods() {
|
||||
String temp = getGoodStr();
|
||||
if ("".equals(temp)) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
List<String> tempList = new ArrayList<String>();
|
||||
String[] str = temp.split(",");
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
tempList.add(str[i]);
|
||||
}
|
||||
return tempList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: LShared
|
||||
* @Description: TODO(描述: SharedPreferences 工具类)
|
||||
* @author Lee
|
||||
* @date 2016年4月11日 上午10:00:27
|
||||
* @version V1.0
|
||||
*/
|
||||
public class SharedTools {
|
||||
|
||||
Context context;
|
||||
String name;
|
||||
public static final String SP_NAME = "tsxn";
|
||||
SharedPreferences sp;
|
||||
Editor editor;
|
||||
|
||||
public SharedTools(Context context) {
|
||||
this.context = context;
|
||||
sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
||||
editor = sp.edit();
|
||||
}
|
||||
|
||||
public SharedTools(Context context, String name) {
|
||||
this.context = context;
|
||||
this.name = name;
|
||||
sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
editor = sp.edit();
|
||||
}
|
||||
|
||||
public void setBoolean(String key, boolean bool) {
|
||||
editor.putBoolean(key, bool);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key) {
|
||||
return sp.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public void setString(String key, String val) {
|
||||
editor.putString(key, val);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
return sp.getString(key, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key和预期的value类型获取value的值
|
||||
*
|
||||
* @param key
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public <T> T getValue(String key, Class<T> clazz) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("请先调用带有context,name参数的构造!");
|
||||
}
|
||||
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name,
|
||||
Context.MODE_PRIVATE);
|
||||
return getValue(key, clazz, sp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对复杂类型存储<对象>
|
||||
*
|
||||
* @param key
|
||||
* @param val
|
||||
*/
|
||||
public void setObject(String key, Object object) {
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name,
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
|
||||
out = new ObjectOutputStream(baos);
|
||||
out.writeObject(object);
|
||||
String objectVal = new String(Base64.encode(baos.toByteArray(),
|
||||
Base64.DEFAULT));
|
||||
Editor editor = sp.edit();
|
||||
editor.putString(key, objectVal);
|
||||
editor.commit();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (baos != null) {
|
||||
baos.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getObject(String key, Class<T> clazz) {
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name,
|
||||
Context.MODE_PRIVATE);
|
||||
if (sp.contains(key)) {
|
||||
String objectVal = sp.getString(key, null);
|
||||
byte[] buffer = Base64.decode(objectVal, Base64.DEFAULT);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
ObjectInputStream ois = null;
|
||||
try {
|
||||
ois = new ObjectInputStream(bais);
|
||||
T t = (T) ois.readObject();
|
||||
return t;
|
||||
} catch (StreamCorruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bais != null) {
|
||||
bais.close();
|
||||
}
|
||||
if (ois != null) {
|
||||
ois.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对于外部不可见的过渡方法
|
||||
*
|
||||
* @param key
|
||||
* @param clazz
|
||||
* @param sp
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getValue(String key, Class<T> clazz, SharedPreferences sp) {
|
||||
T t;
|
||||
try {
|
||||
|
||||
t = clazz.newInstance();
|
||||
|
||||
if (t instanceof Integer) {
|
||||
return (T) Integer.valueOf(sp.getInt(key, 0));
|
||||
} else if (t instanceof String) {
|
||||
return (T) sp.getString(key, "");
|
||||
} else if (t instanceof Boolean) {
|
||||
return (T) Boolean.valueOf(sp.getBoolean(key, false));
|
||||
} else if (t instanceof Long) {
|
||||
return (T) Long.valueOf(sp.getLong(key, 0L));
|
||||
} else if (t instanceof Float) {
|
||||
return (T) Float.valueOf(sp.getFloat(key, 0L));
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("system", "类型输入错误或者复杂类型无法解析[" + e.getMessage() + "]");
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("system", "类型输入错误或者复杂类型无法解析[" + e.getMessage() + "]");
|
||||
}
|
||||
Log.e("system", "无法找到" + key + "对应的值");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2016 android@19code.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* 字符串工具
|
||||
* Created by Gh0st on 2016/6/2 002.
|
||||
*/
|
||||
public class StringUtils {
|
||||
/**
|
||||
* The pyvalue.
|
||||
*/
|
||||
private static int[] pyvalue = new int[]{-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032,
|
||||
-20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728,
|
||||
-19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261,
|
||||
-19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961,
|
||||
-18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490,
|
||||
-18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988,
|
||||
-17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692,
|
||||
-17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733,
|
||||
-16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419,
|
||||
-16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959,
|
||||
-15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631,
|
||||
-15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180,
|
||||
-15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941,
|
||||
-14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857,
|
||||
-14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353,
|
||||
-14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094,
|
||||
-14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831,
|
||||
-13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329,
|
||||
-13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860,
|
||||
-12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300,
|
||||
-12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358,
|
||||
-11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014,
|
||||
-10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309,
|
||||
-10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254};
|
||||
|
||||
/**
|
||||
* The pystr.
|
||||
*/
|
||||
public static String[] pystr = new String[]{"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian",
|
||||
"biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che",
|
||||
"chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan",
|
||||
"cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du",
|
||||
"duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang",
|
||||
"gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang",
|
||||
"hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian",
|
||||
"jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken",
|
||||
"keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng",
|
||||
"li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai",
|
||||
"man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai",
|
||||
"nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan",
|
||||
"nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu",
|
||||
"qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re",
|
||||
"ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha",
|
||||
"shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun",
|
||||
"shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao",
|
||||
"tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi",
|
||||
"xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi",
|
||||
"yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha",
|
||||
"zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui",
|
||||
"zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"};
|
||||
|
||||
|
||||
public static int getChsAscii(String chs) {
|
||||
int asc = 0;
|
||||
try {
|
||||
byte[] bytes = chs.getBytes("gb2312");
|
||||
/*if (bytes == null || bytes.length > 2 || bytes.length <= 0) {
|
||||
throw new RuntimeException("illegal resource string");
|
||||
}*/
|
||||
if (bytes.length == 1) {
|
||||
asc = bytes[0];
|
||||
}
|
||||
if (bytes.length == 2) {
|
||||
int hightByte = 256 + bytes[0];
|
||||
int lowByte = 256 + bytes[1];
|
||||
asc = (256 * hightByte + lowByte) - 256 * 256;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR:ChineseSpelling.class-getChsAscii(String chs)" + e);
|
||||
}
|
||||
return asc;
|
||||
}
|
||||
|
||||
public static String convert(String str) {
|
||||
String result = null;
|
||||
int ascii = getChsAscii(str);
|
||||
if (ascii > 0 && ascii < 160) {
|
||||
result = String.valueOf((char) ascii);
|
||||
} else {
|
||||
for (int i = (pyvalue.length - 1); i >= 0; i--) {
|
||||
if (pyvalue[i] <= ascii) {
|
||||
result = pystr[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getSelling(String chs) {
|
||||
String key, value;
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int i = 0; i < chs.length(); i++) {
|
||||
key = chs.substring(i, i + 1);
|
||||
if (key.getBytes().length >= 2) {
|
||||
value = convert(key);
|
||||
if (value == null) {
|
||||
value = "unknown";
|
||||
}
|
||||
} else {
|
||||
value = key;
|
||||
}
|
||||
buffer.append(value);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static String parseEmpty(String str) {
|
||||
if (str == null || "null".equals(str.trim())) {
|
||||
str = "";
|
||||
}
|
||||
return str.trim();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.trim().length() == 0;
|
||||
}
|
||||
|
||||
public static int chineseLength(String str) {
|
||||
int valueLength = 0;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
if (!isEmpty(str)) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String temp = str.substring(i, i + 1);
|
||||
if (temp.matches(chinese)) {
|
||||
valueLength += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valueLength;
|
||||
}
|
||||
|
||||
public static int strLength(String str) {
|
||||
int valueLength = 0;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
if (!isEmpty(str)) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String temp = str.substring(i, i + 1);
|
||||
if (temp.matches(chinese)) {
|
||||
valueLength += 2;
|
||||
} else {
|
||||
valueLength += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valueLength;
|
||||
}
|
||||
|
||||
public static int subStringLength(String str, int maxL) {
|
||||
int currentIndex = 0;
|
||||
int valueLength = 0;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String temp = str.substring(i, i + 1);
|
||||
if (temp.matches(chinese)) {
|
||||
valueLength += 2;
|
||||
} else {
|
||||
valueLength += 1;
|
||||
}
|
||||
if (valueLength >= maxL) {
|
||||
currentIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
public static Boolean isChinese(String str) {
|
||||
Boolean isChinese = true;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
if (!isEmpty(str)) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String temp = str.substring(i, i + 1);
|
||||
isChinese = temp.matches(chinese);
|
||||
}
|
||||
}
|
||||
return isChinese;
|
||||
}
|
||||
|
||||
public static Boolean isContainChinese(String str) {
|
||||
Boolean isChinese = false;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
if (!isEmpty(str)) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String temp = str.substring(i, i + 1);
|
||||
isChinese = temp.matches(chinese);
|
||||
}
|
||||
}
|
||||
return isChinese;
|
||||
}
|
||||
|
||||
public static String strFormat2(String str) {
|
||||
try {
|
||||
if (str.length() <= 1) {
|
||||
str = "0" + str;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static int convert2Int(Object value, int defaultValue) {
|
||||
if (value == null || "".equals(value.toString().trim())) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.valueOf(value.toString()).intValue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static String decimalFormat(float s, String format) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat(format);
|
||||
return decimalFormat.format(s);
|
||||
}
|
||||
|
||||
|
||||
public static void copy(TextView mTvWechat, Activity activity) {
|
||||
String dataa = mTvWechat.getText().toString().substring(0);
|
||||
if (!TextUtils.isEmpty(dataa)) {
|
||||
ClipboardManager cm = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
// 将文本内容放到系统剪贴板里。
|
||||
cm.setText(dataa);
|
||||
ToastUtils.showToast(activity, "复制成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
package com.example.administrator.seven.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class ListViewForScrollView extends ListView {
|
||||
public ListViewForScrollView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public ListViewForScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public ListViewForScrollView(Context context, AttributeSet attrs,
|
||||
int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
@Override
|
||||
/**
|
||||
* 重写该方法,达到使ListView适应ScrollView的效果
|
||||
*/
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
|
||||
MeasureSpec.AT_MOST);
|
||||
super.onMeasure(widthMeasureSpec, expandSpec);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.example.administrator.seven.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
* @author lin04
|
||||
*
|
||||
*/
|
||||
public class TagView extends ToggleButton {
|
||||
private boolean mCheckEnable = true;
|
||||
|
||||
public TagView(Context paramContext) {
|
||||
super (paramContext);
|
||||
init();
|
||||
}
|
||||
|
||||
public TagView(Context paramContext, AttributeSet paramAttributeSet) {
|
||||
super (paramContext, paramAttributeSet);
|
||||
init();
|
||||
}
|
||||
|
||||
public TagView(Context paramContext, AttributeSet paramAttributeSet,
|
||||
int paramInt) {
|
||||
super (paramContext, paramAttributeSet, 0);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setTextOn( null );
|
||||
setTextOff( null );
|
||||
setText( "" );
|
||||
setBackgroundResource(R.drawable.ic_launcher);
|
||||
}
|
||||
|
||||
public void setCheckEnable( boolean paramBoolean) {
|
||||
this .mCheckEnable = paramBoolean;
|
||||
if (!this .mCheckEnable ) {
|
||||
super .setChecked( false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setChecked( boolean paramBoolean) {
|
||||
if (this .mCheckEnable ) {
|
||||
super .setChecked(paramBoolean);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user