|
|
@@ -1,8 +1,10 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.activity.setting;
|
|
|
|
|
|
import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
@@ -21,25 +23,29 @@ import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.crm.Business;
|
|
|
+import com.xzjmyk.pm.activity.ui.MainActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
+import com.xzjmyk.pm.activity.util.DateFormatUtil;
|
|
|
import com.xzjmyk.pm.activity.view.SmoothCheckBox;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
- * @desc:切换语言
|
|
|
- * @author:Arison on 2017/5/11
|
|
|
- */
|
|
|
+ * @desc:切换语言
|
|
|
+ * @author:Arison on 2017/5/11
|
|
|
+ */
|
|
|
public class SelectLanguageActivity extends BaseActivity {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
@ViewInject(R.id.list_business)
|
|
|
private PullToRefreshListView mlist;
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
private BussinessDetailAdapter mAdapter;
|
|
|
private ArrayList<Business> mData = new ArrayList<Business>();
|
|
|
+ private String currentLanguage;
|
|
|
|
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
@@ -51,7 +57,19 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
switch (item.getItemId()) {
|
|
|
case R.id.btn_save:
|
|
|
-
|
|
|
+ LogUtil.d("MainActivity", "start:" + DateFormatUtil.getDateTimeStr());
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (!TextUtils.isEmpty(currentLanguage)) {
|
|
|
+ switchLanguage(currentLanguage);
|
|
|
+ switchLanguageAction();
|
|
|
+ } else {
|
|
|
+ switchLanguage(getString(R.string.language_rCN));
|
|
|
+ switchLanguageAction();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
break;
|
|
|
case android.R.id.home:
|
|
|
onBackPressed();
|
|
|
@@ -59,6 +77,7 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -67,8 +86,8 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
initView();
|
|
|
initData();
|
|
|
}
|
|
|
-
|
|
|
- private void initView(){
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
getSupportActionBar().setTitle(getString(R.string.set_language));
|
|
|
mEmptyLayout = new EmptyLayout(this, mlist.getRefreshableView());
|
|
|
mlist.setMode(PullToRefreshBase.Mode.DISABLED);
|
|
|
@@ -76,13 +95,15 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
BussinessDetailAdapter.ViewHolder holder = (BussinessDetailAdapter.ViewHolder) view.getTag();
|
|
|
- ToastMessage(holder.tv_business_name.getText().toString());
|
|
|
+ //ToastMessage();
|
|
|
final boolean flag = !mAdapter.getMdata().get(position - 1).isChecked;
|
|
|
Log.i(TAG, "onClick:" + position + " check:" + !flag);
|
|
|
+ currentLanguage = holder.tv_business_name.getText().toString();
|
|
|
+
|
|
|
for (Business model : mAdapter.getMdata()) {
|
|
|
model.setIsChecked(false);
|
|
|
}
|
|
|
- //把源数据清空
|
|
|
+ //把源数据清空
|
|
|
for (Business model : mData) {
|
|
|
model.setIsChecked(false);
|
|
|
}
|
|
|
@@ -97,19 +118,19 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- private void initData(){
|
|
|
- Business b=new Business();
|
|
|
- b.setName("跟随系统");
|
|
|
+
|
|
|
+ private void initData() {
|
|
|
+ Business b = new Business();
|
|
|
+ b.setName(getString(R.string.language_sys));
|
|
|
mData.add(b);
|
|
|
- b=new Business();
|
|
|
- b.setName("简体中文");
|
|
|
+ b = new Business();
|
|
|
+ b.setName(getString(R.string.language_rCN));
|
|
|
mData.add(b);
|
|
|
- b=new Business();
|
|
|
- b.setName("繁体中文");
|
|
|
+ b = new Business();
|
|
|
+ b.setName(getString(R.string.language_rTW));
|
|
|
mData.add(b);
|
|
|
- b=new Business();
|
|
|
- b.setName("英语");
|
|
|
+ b = new Business();
|
|
|
+ b.setName(getString(R.string.language_en));
|
|
|
mData.add(b);
|
|
|
mAdapter = new BussinessDetailAdapter(this, mData);
|
|
|
mlist.setAdapter(mAdapter);
|
|
|
@@ -180,19 +201,19 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
holder.cb_left.setFocusable(false);
|
|
|
holder.cb_left.setEnabled(false);
|
|
|
holder.cb_left.setClickable(false);
|
|
|
- holder.code=mdata.get(position).getCode();
|
|
|
+ holder.code = mdata.get(position).getCode();
|
|
|
holder.cb_left.setChecked(mdata.get(position).isChecked(), mdata.get(position).isChecked());
|
|
|
|
|
|
- if (!StringUtils.isEmpty(searchkeys)){
|
|
|
+ if (!StringUtils.isEmpty(searchkeys)) {
|
|
|
holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
-
|
|
|
- // holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
+
|
|
|
+ // holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
holder.tv_business_leader.setVisibility(View.GONE);
|
|
|
// CommonUtil.textSpanForStyle(holder.tv_business_name, mdata.get(position).getName(),
|
|
|
// searchkeys, ct.getResources().getColor(R.color.yellow));
|
|
|
// CommonUtil.textSpanForStyle(holder.tv_business_leader, "负责人:"+mdata.get(position).getLeader(),
|
|
|
// searchkeys, ct.getResources().getColor(R.color.yellow));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
holder.tv_business_leader.setVisibility(View.GONE);
|
|
|
holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
//holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
@@ -202,28 +223,28 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public Filter getFilter() {
|
|
|
- return new Filter() {
|
|
|
+ return new Filter() {
|
|
|
@Override
|
|
|
protected FilterResults performFiltering(CharSequence constraint) {
|
|
|
//过滤数据
|
|
|
FilterResults searchResults = new FilterResults();
|
|
|
|
|
|
- if (constraint == null || constraint.length() == 0){
|
|
|
+ if (constraint == null || constraint.length() == 0) {
|
|
|
|
|
|
- searchResults.values=mData;
|
|
|
- searchResults.count=mData.size();
|
|
|
- }else{
|
|
|
- mdata=mData;
|
|
|
- ArrayList<Business> newArry=new ArrayList<Business>();
|
|
|
- for (int i=0;i<mdata.size();i++){
|
|
|
- Business model=mdata.get(i);
|
|
|
- if (model.getName().contains(constraint)||model.getLeader().contains(constraint)){
|
|
|
+ searchResults.values = mData;
|
|
|
+ searchResults.count = mData.size();
|
|
|
+ } else {
|
|
|
+ mdata = mData;
|
|
|
+ ArrayList<Business> newArry = new ArrayList<Business>();
|
|
|
+ for (int i = 0; i < mdata.size(); i++) {
|
|
|
+ Business model = mdata.get(i);
|
|
|
+ if (model.getName().contains(constraint) || model.getLeader().contains(constraint)) {
|
|
|
newArry.add(model);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- searchResults.values=newArry;
|
|
|
- searchResults.count=newArry.size();
|
|
|
+ searchResults.values = newArry;
|
|
|
+ searchResults.count = newArry.size();
|
|
|
}
|
|
|
return searchResults;
|
|
|
}
|
|
|
@@ -231,8 +252,8 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
@Override
|
|
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
|
//装配数据
|
|
|
- mdata= (ArrayList<Business>) results.values;
|
|
|
- searchkeys=constraint.toString();
|
|
|
+ mdata = (ArrayList<Business>) results.values;
|
|
|
+ searchkeys = constraint.toString();
|
|
|
if (mAdapter.getCount() == 0) {
|
|
|
|
|
|
}
|
|
|
@@ -250,4 +271,15 @@ public class SelectLanguageActivity extends BaseActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void switchLanguageAction() {
|
|
|
+ Intent it = new Intent(SelectLanguageActivity.this,MainActivity.class);
|
|
|
+ it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
+ startActivity(it);
|
|
|
+ finish();
|
|
|
+ overridePendingTransition(0, 0);
|
|
|
+ LogUtil.d("MainActivity", "end:" + DateFormatUtil.getDateTimeStr());
|
|
|
+ System.exit(10);
|
|
|
+ android.os.Process.killProcess(android.os.Process.myPid());
|
|
|
+ }
|
|
|
+
|
|
|
}
|