|
|
@@ -2,23 +2,93 @@ package com.xzjmyk.pm.activity.ui.erp.activity;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
+import com.xzjmyk.pm.activity.bean.SubscriptionNumber;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.db.DBManager;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.util.SharedUtil;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
+ * 未订阅号整理页面
|
|
|
* Created by RaoMeng on 2016/10/28.
|
|
|
*/
|
|
|
public class ManageAllSubscriptionActivity extends BaseActivity {
|
|
|
-
|
|
|
+ private DBManager mDbManager;
|
|
|
+ private String currentMaster;//当前账套
|
|
|
+ private String currentUser;//当前账号
|
|
|
+ private List<SubscriptionNumber> dbSubscriptionNumbers;
|
|
|
+ private List<Object> keyStrings;
|
|
|
+ private List<Object> allKeyStrings;
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
getSupportActionBar().setTitle("未订阅管理");
|
|
|
setContentView(R.layout.activity_manage_all_subs);
|
|
|
|
|
|
+ initViews();
|
|
|
+ initEvents();
|
|
|
+ initDatas();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initDatas() {
|
|
|
Intent intent = new Intent();
|
|
|
- setResult(Constants.RESULT_MANAGE_ALL_SUBSCRIPTION,intent);
|
|
|
+ setResult(Constants.RESULT_MANAGE_ALL_SUBSCRIPTION, intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initEvents() {
|
|
|
+ if (dbSubscriptionNumbers != null && dbSubscriptionNumbers.size() != 0) {
|
|
|
+ for (int i = 0; i < dbSubscriptionNumbers.size(); i++) {
|
|
|
+ SubscriptionNumber subscriptionNumber = dbSubscriptionNumbers.get(i);
|
|
|
+ subscriptionNumber.setRemoved(0);
|
|
|
+ allKeyStrings.add(subscriptionNumber.getType());
|
|
|
+ }
|
|
|
+ mDbManager.updateListAllSubs(dbSubscriptionNumbers);
|
|
|
+ }
|
|
|
+
|
|
|
+ keyStrings = CommonUtil.getSingleElement(allKeyStrings);
|
|
|
+ initKeyStrings();
|
|
|
+ Toast.makeText(this, "整理完成", Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initViews() {
|
|
|
+ keyStrings = new ArrayList<>();
|
|
|
+ allKeyStrings = new ArrayList<>();
|
|
|
+ mDbManager = new DBManager(this);
|
|
|
+ currentMaster = CommonUtil.getSharedPreferences(this, "erp_master");
|
|
|
+ currentUser = CommonUtil.getSharedPreferences(this, "erp_username");
|
|
|
+ dbSubscriptionNumbers =
|
|
|
+ mDbManager.queryFromAllSubs(new String[]{currentMaster, currentUser}, "subs_master=? and subs_username=? ");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initKeyStrings() {
|
|
|
+ StringBuilder keyStringBuilder = null;
|
|
|
+ if (keyStrings.size() != 0) {
|
|
|
+ keyStringBuilder = new StringBuilder();
|
|
|
+ for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
+ keyStringBuilder.append("," + keyStrings.get(i));
|
|
|
+ }
|
|
|
+ if (keyStringBuilder.length() > 2) {
|
|
|
+ keyStringBuilder.delete(0, 1);
|
|
|
+ }
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "subs", keyStringBuilder.toString());
|
|
|
+ } else {
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "subs", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ mDbManager.closeDB();
|
|
|
}
|
|
|
}
|