|
|
@@ -2,14 +2,17 @@ package com.xzjmyk.pm.activity.ui.erp.activity;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.widget.ListView;
|
|
|
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.SubscriptionNumber;
|
|
|
+import com.xzjmyk.pm.activity.bean.message.AllSubscriptonKindMessage;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.adapter.AllRemovedSubsAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.db.DBManager;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.util.Constants;
|
|
|
-import com.xzjmyk.pm.activity.util.SharedUtil;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -22,9 +25,15 @@ public class ManageAllSubscriptionActivity extends BaseActivity {
|
|
|
private DBManager mDbManager;
|
|
|
private String currentMaster;//当前账套
|
|
|
private String currentUser;//当前账号
|
|
|
- private List<SubscriptionNumber> dbSubscriptionNumbers;
|
|
|
+ private List<SubscriptionNumber> dbSubscriptionNumbers;//数据库数据
|
|
|
+ private List<SubscriptionNumber> mSubscriptionNumbers;//被移除的订阅数据
|
|
|
private List<Object> keyStrings;
|
|
|
- private List<Object> allKeyStrings;
|
|
|
+ private List<Object> removedKeyStrings;
|
|
|
+
|
|
|
+ private ListView mRemovedListView;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+ private List<AllSubscriptonKindMessage> mAllSubscriptonKindMessages;
|
|
|
+ private AllRemovedSubsAdapter mAllRemovedSubsAdapter;
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -46,20 +55,58 @@ public class ManageAllSubscriptionActivity extends BaseActivity {
|
|
|
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());
|
|
|
+ if (subscriptionNumber.getRemoved() == 1 && subscriptionNumber.getStatus() != 1){
|
|
|
+ mSubscriptionNumbers.add(subscriptionNumber);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mSubscriptionNumbers == null || mSubscriptionNumbers.size() == 0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }else {
|
|
|
+ for (int i = 0; i < mSubscriptionNumbers.size(); i++) {
|
|
|
+ removedKeyStrings.add(mSubscriptionNumbers.get(i).getType());
|
|
|
+ }
|
|
|
+ keyStrings = CommonUtil.getSingleElement(removedKeyStrings);
|
|
|
+
|
|
|
+ for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
+ List<SubscriptionNumber> tempSubscriptionNumbers = null;
|
|
|
+ String key = keyStrings.get(i).toString();
|
|
|
+ AllSubscriptonKindMessage subscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
+ subscriptonKindMessage.setSubscriptionKind(key);
|
|
|
+ tempSubscriptionNumbers = new ArrayList<>();
|
|
|
+ for (int j = 0; j < mSubscriptionNumbers.size(); j++) {
|
|
|
+ SubscriptionNumber tempSubscriptionNumber = mSubscriptionNumbers.get(j);
|
|
|
+ if (tempSubscriptionNumber.getType().equals(key)){
|
|
|
+ tempSubscriptionNumbers.add(tempSubscriptionNumber);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tempSubscriptionNumbers != null && tempSubscriptionNumbers.size() != 0){
|
|
|
+ subscriptonKindMessage.setSubscriptionNumbers(tempSubscriptionNumbers);
|
|
|
+ }
|
|
|
+ mAllSubscriptonKindMessages.add(subscriptonKindMessage);
|
|
|
+ }
|
|
|
+ mAllRemovedSubsAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- mDbManager.updateListAllSubs(dbSubscriptionNumbers);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
}
|
|
|
|
|
|
- keyStrings = CommonUtil.getSingleElement(allKeyStrings);
|
|
|
- initKeyStrings();
|
|
|
-// Toast.makeText(this, "整理完成", Toast.LENGTH_SHORT).show();
|
|
|
}
|
|
|
|
|
|
private void initViews() {
|
|
|
+ mRemovedListView = (ListView) findViewById(R.id.manage_all_subs_lv);
|
|
|
+ mSubscriptionNumbers = new ArrayList<>();
|
|
|
+ mAllSubscriptonKindMessages = new ArrayList<>();
|
|
|
+
|
|
|
+ mAllRemovedSubsAdapter = new AllRemovedSubsAdapter(mAllSubscriptonKindMessages,this);
|
|
|
+ mRemovedListView.setAdapter(mAllRemovedSubsAdapter);
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mRemovedListView);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setEmptyMessage("您没有隐藏的订阅号");
|
|
|
keyStrings = new ArrayList<>();
|
|
|
- allKeyStrings = new ArrayList<>();
|
|
|
+ removedKeyStrings = new ArrayList<>();
|
|
|
mDbManager = new DBManager(this);
|
|
|
currentMaster = CommonUtil.getSharedPreferences(this, "erp_master");
|
|
|
currentUser = CommonUtil.getSharedPreferences(this, "erp_username");
|
|
|
@@ -68,23 +115,6 @@ public class ManageAllSubscriptionActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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();
|