|
|
@@ -4,22 +4,19 @@ import android.content.Intent;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.util.Log;
|
|
|
-import android.util.TypedValue;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
|
-import android.widget.RadioButton;
|
|
|
-import android.widget.RadioGroup;
|
|
|
import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.adapter.AllSubscriptionAdapter;
|
|
|
+import com.xzjmyk.pm.activity.adapter.SubsTypeAdapter;
|
|
|
import com.xzjmyk.pm.activity.bean.SubscriptionNumber;
|
|
|
import com.xzjmyk.pm.activity.bean.message.AllSubscriptonKindMessage;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.SubscribeDetailActivity;
|
|
|
@@ -30,6 +27,7 @@ import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
import com.xzjmyk.pm.activity.util.SharedUtil;
|
|
|
+import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Style;
|
|
|
|
|
|
@@ -48,21 +46,23 @@ import java.util.Map;
|
|
|
* 所有订阅
|
|
|
* Created by RaoMeng on 2016/9/5.
|
|
|
*/
|
|
|
-public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.OnCheckedChangeListener {
|
|
|
+public class SubscriptionAllFragment extends BaseFragment{
|
|
|
private PullToRefreshListView mPullToRefreshListView;
|
|
|
private AllSubscriptionAdapter mAllSubscriptionAdapter;
|
|
|
private List<AllSubscriptonKindMessage> mAllSubscriptonKindMessages;
|
|
|
private List<SubscriptionNumber> mSubscriptionNumbers;
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
- private RadioGroup mRadioGroup;
|
|
|
private int rbPos = 0;
|
|
|
private List<String> keyStrings = new ArrayList<>();
|
|
|
private final static int SUBSCRIBE_DETAIL_REQUEST = 33;
|
|
|
private static int mClickedPos = -1;
|
|
|
- String currentMaster;
|
|
|
+ private String currentMaster;//当前账套
|
|
|
+ private String currentUser;//当前账号
|
|
|
private DBManager mDbManager;
|
|
|
private PopupWindow mDeletePopupWindow;
|
|
|
|
|
|
+ private ListView mTypeListView;
|
|
|
+ private SubsTypeAdapter mSubsTypeAdapter;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_all_subscription;
|
|
|
@@ -71,13 +71,15 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
@Override
|
|
|
protected void initViews() {
|
|
|
mDbManager = new DBManager(getActivity());
|
|
|
- mRadioGroup = (RadioGroup) root.findViewById(R.id.subscription_all_rg);
|
|
|
currentMaster = CommonUtil.getSharedPreferences(getActivity(), "erp_master");
|
|
|
+ currentUser = CommonUtil.getSharedPreferences(getActivity(), "erp_username");
|
|
|
mPullToRefreshListView = (PullToRefreshListView) root.findViewById(R.id.subscription_all_ptlv);
|
|
|
mSubscriptionNumbers = new ArrayList<>();
|
|
|
mAllSubscriptionAdapter = new AllSubscriptionAdapter(getActivity(), mSubscriptionNumbers);
|
|
|
mAllSubscriptonKindMessages = new ArrayList<>();
|
|
|
|
|
|
+ mTypeListView = (ListView) root.findViewById(R.id.subscription_all_type_lv);
|
|
|
+ mSubsTypeAdapter = new SubsTypeAdapter(getActivity(),keyStrings);
|
|
|
mEmptyLayout = new EmptyLayout(getActivity(), mPullToRefreshListView.getRefreshableView());
|
|
|
mEmptyLayout.setShowLoadingButton(false);
|
|
|
mEmptyLayout.setShowEmptyButton(false);
|
|
|
@@ -87,6 +89,7 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
+ mTypeListView.setAdapter(mSubsTypeAdapter);
|
|
|
mPullToRefreshListView.setAdapter(mAllSubscriptionAdapter);
|
|
|
mPullToRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
|
|
mPullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
@@ -108,10 +111,10 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
}, 1000);
|
|
|
}
|
|
|
});
|
|
|
- mRadioGroup.setOnCheckedChangeListener(this);
|
|
|
mPullToRefreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ ToastUtil.showToast(getActivity(), "暂不可点击!");
|
|
|
mClickedPos = position;
|
|
|
Intent intent = new Intent();
|
|
|
intent.setClass(getActivity(), SubscribeDetailActivity.class);
|
|
|
@@ -128,11 +131,10 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
|
|
View popView = View.inflate(getActivity(), R.layout.pop_subs_delete, null);
|
|
|
TextView deleteTv = (TextView) popView.findViewById(R.id.pop_subs_delete_tv);
|
|
|
- deleteTv.setText("删除订阅号");
|
|
|
+ deleteTv.setText("删除该订阅号");
|
|
|
deleteTv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- Toast.makeText(getActivity(), position + "", Toast.LENGTH_SHORT).show();
|
|
|
mDbManager.deleteFromAllSubs(mSubscriptionNumbers.get(position - 1));
|
|
|
mSubscriptionNumbers.remove(position - 1);
|
|
|
mAllSubscriptonKindMessages.get(rbPos).setSubscriptionNumbers(mSubscriptionNumbers);
|
|
|
@@ -140,12 +142,21 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
if (mSubscriptionNumbers.size() == 0) {
|
|
|
mAllSubscriptonKindMessages.remove(rbPos);
|
|
|
keyStrings.remove(rbPos);
|
|
|
+ initKeyStrings();
|
|
|
if (keyStrings.size() == 0) {
|
|
|
- mRadioGroup.setVisibility(View.GONE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mTypeListView.setVisibility(View.GONE);
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
} else {
|
|
|
rbPos = 0;
|
|
|
- mRadioGroup.removeAllViews();
|
|
|
- initRadioGroup();
|
|
|
+ mTypeListView.setVisibility(View.VISIBLE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
closeDeletePopupWindow();
|
|
|
@@ -167,35 +178,91 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
return true;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mTypeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ mSubsTypeAdapter.setSelectItem(position);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ rbPos = position;
|
|
|
+
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ if (mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers().size() != 0) {
|
|
|
+ mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTypeListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
|
|
+ View popView = View.inflate(getActivity(), R.layout.pop_subs_delete, null);
|
|
|
+ TextView deleteTv = (TextView) popView.findViewById(R.id.pop_subs_delete_tv);
|
|
|
+ deleteTv.setText("删除该订阅类");
|
|
|
+ deleteTv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mDbManager.deleteListFromAllSubs(mAllSubscriptonKindMessages.get(position).getSubscriptionNumbers());
|
|
|
+ mAllSubscriptonKindMessages.remove(position);
|
|
|
+ keyStrings.remove(position);
|
|
|
+ initKeyStrings();
|
|
|
+ if (keyStrings.size() == 0) {
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mTypeListView.setVisibility(View.GONE);
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ rbPos = 0;
|
|
|
+ mTypeListView.setVisibility(View.VISIBLE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ closeDeletePopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mDeletePopupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
+ mDeletePopupWindow.setOutsideTouchable(true);
|
|
|
+ mDeletePopupWindow.setFocusable(true);
|
|
|
+ mDeletePopupWindow.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ DisplayUtil.backgroundAlpha(getActivity(), 0.5f);
|
|
|
+ mDeletePopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeDeletePopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- private void initRadioGroup() {
|
|
|
- StringBuilder keyStringBuilder = new StringBuilder();
|
|
|
- for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
- keyStringBuilder.append("," + keyStrings.get(i));
|
|
|
- final RadioButton radioButton = new RadioButton(getActivity());
|
|
|
- radioButton.setButtonDrawable(null);
|
|
|
- radioButton.setGravity(Gravity.CENTER);
|
|
|
- radioButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
|
|
- radioButton.setBackground(getResources().getDrawable(R.drawable.selector_subscribe_bg));
|
|
|
- radioButton.setText(keyStrings.get(i));
|
|
|
- radioButton.setTextColor(getResources().getColor(R.color.selector_subscribe_tv));
|
|
|
- radioButton.setPadding(0, 30, 0, 30);
|
|
|
- radioButton.setId(i);
|
|
|
-
|
|
|
- if (i == rbPos) {
|
|
|
-// radioButton.setTextColor(getResources().getColor(R.color.red));
|
|
|
- radioButton.setChecked(true);
|
|
|
- } else {
|
|
|
-// radioButton.setTextColor(getResources().getColor(R.color.black));
|
|
|
- radioButton.setChecked(false);
|
|
|
+ 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 (i == rbPos) {
|
|
|
+ mSubsTypeAdapter.setSelectItem(i);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
}
|
|
|
- mRadioGroup.addView(radioButton, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
- }
|
|
|
- if (keyStringBuilder.length() > 2) {
|
|
|
- keyStringBuilder.delete(0, 1);
|
|
|
+ if (keyStringBuilder.length() > 2) {
|
|
|
+ keyStringBuilder.delete(0, 1);
|
|
|
+ }
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "subs", keyStringBuilder.toString());
|
|
|
+ }else {
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "subs", null);
|
|
|
}
|
|
|
- SharedUtil.putString(currentMaster + "subs", keyStringBuilder.toString());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void closeDeletePopupWindow() {
|
|
|
@@ -210,9 +277,8 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
|
|
|
@Override
|
|
|
protected void initDatas() {
|
|
|
-// mAllSubscriptonKindMessages = (List<AllSubscriptonKindMessage>) MyApplication.getDataCacheFromMap("all_subs_cache");
|
|
|
Log.d("currentMaster: ", currentMaster);
|
|
|
- String cacheKeys = SharedUtil.getString(currentMaster + "subs");
|
|
|
+ String cacheKeys = SharedUtil.getString(currentMaster + currentUser + "subs");
|
|
|
if (cacheKeys != null) {
|
|
|
String[] cacheKeysArray = cacheKeys.split(",");
|
|
|
for (int i = 0; i < cacheKeysArray.length; i++) {
|
|
|
@@ -220,43 +286,45 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
}
|
|
|
}
|
|
|
try {
|
|
|
-// List<SubscriptionNumber> dbSubscriptionNumbers = MyApplication.mDbUtils.findAll(SubscriptionNumber.class);
|
|
|
List<SubscriptionNumber> dbSubscriptionNumbers
|
|
|
- = mDbManager.queryFromAllSubs(new String[]{currentMaster}, "subs_master=?");
|
|
|
- if (dbSubscriptionNumbers == null) {
|
|
|
+ = mDbManager.queryFromAllSubs(new String[]{currentMaster,currentUser}, "subs_master=? and subs_username=? ");
|
|
|
+ if (dbSubscriptionNumbers == null || dbSubscriptionNumbers.size() == 0) {
|
|
|
sendAllSubscriptionRequest();
|
|
|
- Toast.makeText(getActivity(), "网络加载", Toast.LENGTH_SHORT).show();
|
|
|
+// Toast.makeText(getActivity(), "网络加载", Toast.LENGTH_SHORT).show();
|
|
|
} else {
|
|
|
- Toast.makeText(getActivity(), "本地加载", Toast.LENGTH_SHORT).show();
|
|
|
- for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
- AllSubscriptonKindMessage tempSubscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
- List<SubscriptionNumber> tempSubscriptionNumbers = new ArrayList<>();
|
|
|
- String currentKey = keyStrings.get(i);
|
|
|
- for (int j = 0; j < dbSubscriptionNumbers.size(); j++) {
|
|
|
- SubscriptionNumber currentSubscriptionNumber = dbSubscriptionNumbers.get(j);
|
|
|
- if (currentSubscriptionNumber.getType().equals(currentKey)) {
|
|
|
- tempSubscriptionNumbers.add(currentSubscriptionNumber);
|
|
|
- }
|
|
|
- }
|
|
|
- tempSubscriptonKindMessage.setSubscriptionKind(currentKey);
|
|
|
- tempSubscriptonKindMessage.setSubscriptionNumbers(tempSubscriptionNumbers);
|
|
|
-
|
|
|
- mAllSubscriptonKindMessages.add(tempSubscriptonKindMessage);
|
|
|
- }
|
|
|
-
|
|
|
+// Toast.makeText(getActivity(), "本地加载", Toast.LENGTH_SHORT).show();
|
|
|
+ initKeyStrings();
|
|
|
if (keyStrings.size() == 0) {
|
|
|
- mRadioGroup.setVisibility(View.GONE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mTypeListView.setVisibility(View.GONE);
|
|
|
mEmptyLayout.showEmpty();
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
} else {
|
|
|
- mRadioGroup.setVisibility(View.VISIBLE);
|
|
|
- initRadioGroup();
|
|
|
+ mTypeListView.setVisibility(View.VISIBLE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
+ AllSubscriptonKindMessage tempSubscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
+ List<SubscriptionNumber> tempSubscriptionNumbers = new ArrayList<>();
|
|
|
+ String currentKey = keyStrings.get(i);
|
|
|
+ for (int j = 0; j < dbSubscriptionNumbers.size(); j++) {
|
|
|
+ SubscriptionNumber currentSubscriptionNumber = dbSubscriptionNumbers.get(j);
|
|
|
+ if (currentSubscriptionNumber.getType().equals(currentKey)) {
|
|
|
+ tempSubscriptionNumbers.add(currentSubscriptionNumber);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tempSubscriptonKindMessage.setSubscriptionKind(currentKey);
|
|
|
+ tempSubscriptonKindMessage.setSubscriptionNumbers(tempSubscriptionNumbers);
|
|
|
+
|
|
|
+ mAllSubscriptonKindMessages.add(tempSubscriptonKindMessage);
|
|
|
+ }
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
+ Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- mSubscriptionNumbers.clear();
|
|
|
- mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
- Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
- mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -283,12 +351,7 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
switch (msg.what) {
|
|
|
case GET_ALL_SUBSCRIPTION:
|
|
|
progressDialog.dismiss();
|
|
|
-// try {
|
|
|
-// MyApplication.mDbUtils.deleteAll(SubscriptionNumber.class);
|
|
|
-// } catch (DbException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
- mDbManager.deleteMasterSubs(currentMaster);
|
|
|
+ mDbManager.deleteMasterAllSubs(currentMaster,currentUser);
|
|
|
String resultJson = msg.getData().getString("result");
|
|
|
Log.d("allsubscriptionResult: ", resultJson);
|
|
|
try {
|
|
|
@@ -303,12 +366,12 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
Crouton.makeText(getActivity(), "没有未订阅数据", 0xff99cc00, 1500).show();
|
|
|
}
|
|
|
keyStrings.clear();
|
|
|
- mRadioGroup.removeAllViews();
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mTypeListView.setVisibility(View.GONE);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
keyStrings.clear();
|
|
|
- mRadioGroup.removeAllViews();
|
|
|
while (iterator.hasNext()) {
|
|
|
String key = iterator.next().toString();
|
|
|
|
|
|
@@ -328,6 +391,7 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
subscriptionNumber.setStatus(subsObject.getInt("status"));
|
|
|
subscriptionNumber.setType(key);
|
|
|
subscriptionNumber.setMaster(currentMaster);
|
|
|
+ subscriptionNumber.setUsername(currentUser);
|
|
|
if (subsObject.getInt("status") != 1) {
|
|
|
subscriptionNumbers.add(subscriptionNumber);
|
|
|
}
|
|
|
@@ -335,11 +399,8 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
if (subscriptionNumbers.size() != 0) {
|
|
|
keyStrings.add(key);
|
|
|
subscriptonKindMessage.setSubscriptionNumbers(subscriptionNumbers);
|
|
|
- /*try {
|
|
|
- MyApplication.mDbUtils.saveAll(subscriptionNumbers);
|
|
|
- } catch (DbException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }*/
|
|
|
+
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
mDbManager.saveListToAllSubs(subscriptionNumbers);
|
|
|
mAllSubscriptonKindMessages.add(subscriptonKindMessage);
|
|
|
}
|
|
|
@@ -348,17 +409,20 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
+ initKeyStrings();
|
|
|
if (keyStrings.size() == 0) {
|
|
|
- mRadioGroup.setVisibility(View.GONE);
|
|
|
+ mTypeListView.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
} else {
|
|
|
- mRadioGroup.setVisibility(View.VISIBLE);
|
|
|
- initRadioGroup();
|
|
|
+ mTypeListView.setVisibility(View.VISIBLE);
|
|
|
+ mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mSubscriptionNumbers.clear();
|
|
|
+ mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
+ Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- mSubscriptionNumbers.clear();
|
|
|
- mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
- Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
- mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
|
|
|
if (mPullToRefreshListView.isRefreshing()) {
|
|
|
mPullToRefreshListView.onRefreshComplete();
|
|
|
@@ -373,25 +437,6 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
- rbPos = checkedId;
|
|
|
-/*
|
|
|
- for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
- RadioButton currentButton = (RadioButton) group.findViewById(i);
|
|
|
- if (i == checkedId){
|
|
|
- currentButton.setTextColor(getResources().getColor(R.color.red));
|
|
|
- }else {
|
|
|
- currentButton.setTextColor(getResources().getColor(R.color.black));
|
|
|
- }
|
|
|
- }*/
|
|
|
- mSubscriptionNumbers.clear();
|
|
|
- if (mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers().size() != 0) {
|
|
|
- mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
- mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
if (requestCode == SUBSCRIBE_DETAIL_REQUEST && resultCode == 9 && data != null) {
|