|
|
@@ -53,6 +53,7 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
private int rbPos = 0;
|
|
|
private List<String> keyStrings = new ArrayList<>();//当前显示的订阅类
|
|
|
+ private List<String> mAllKeyStrings = new ArrayList<>();//所有订阅类
|
|
|
private final static int SUBSCRIBE_DETAIL_REQUEST = 33;
|
|
|
private static int mClickedPos = -1;
|
|
|
private String currentMaster;//当前账套
|
|
|
@@ -73,6 +74,7 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
private List<AllSubscriptonKindMessage> mNetAllSubscriptonKindMessages;
|
|
|
private List<SubscriptionNumber> mNetSubscriptionNumbers;
|
|
|
|
|
|
+ private String mBufferKey = null;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_all_subscription;
|
|
|
@@ -112,7 +114,7 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
if (CommonUtil.isNetWorkConnected(getActivity().getApplicationContext())){
|
|
|
mAllSubscriptonKindMessages.clear();
|
|
|
- rbPos = 0;
|
|
|
+// rbPos = 0;
|
|
|
sendAllSubscriptionRequest();
|
|
|
}else {
|
|
|
if (mPullToRefreshListView.isRefreshing()){
|
|
|
@@ -169,7 +171,6 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
keyStrings.remove(rbPos);
|
|
|
if (keyStrings.size() == 0) {
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
mTypeListView.setVisibility(View.GONE);
|
|
|
mEmptyLayout.showEmpty();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
@@ -178,14 +179,12 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
rbPos = 0;
|
|
|
mTypeListView.setVisibility(View.VISIBLE);
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
-// mAllSubscriptionAdapter = new AllSubscriptionAdapter(getActivity(), mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
-// mPullToRefreshListView.getRefreshableView().setAdapter(mAllSubscriptionAdapter);
|
|
|
-
|
|
|
}
|
|
|
+ initKeyStrings();
|
|
|
+
|
|
|
}
|
|
|
closeDeletePopupWindow();
|
|
|
}
|
|
|
@@ -213,6 +212,7 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
mSubsTypeAdapter.setSelectItem(position);
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
+ mBufferKey = keyStrings.get(position);
|
|
|
rbPos = position;
|
|
|
if (mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers().size() != 0) {
|
|
|
mAllSubscriptionAdapter = new AllSubscriptionAdapter(getActivity(), mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
@@ -239,7 +239,6 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
keyStrings.remove(position);
|
|
|
if (keyStrings.size() == 0) {
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
mTypeListView.setVisibility(View.GONE);
|
|
|
mEmptyLayout.showEmpty();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
@@ -248,12 +247,12 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
rbPos = 0;
|
|
|
mTypeListView.setVisibility(View.VISIBLE);
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+ initKeyStrings();
|
|
|
closeDeletePopupWindow();
|
|
|
}
|
|
|
});
|
|
|
@@ -276,6 +275,18 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ if (CommonUtil.isNetWorkConnected(getActivity().getApplicationContext())){
|
|
|
+ //每次初始化页面都需要访问网络数据用来更新本地缓存
|
|
|
+ sendAllSubscriptionRequest();
|
|
|
+ }else {
|
|
|
+ //没有网络时,取本地数据库数据
|
|
|
+ getDbSubsData();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void initKeyStrings() {
|
|
|
StringBuilder keyStringBuilder = null;
|
|
|
if (keyStrings.size() != 0) {
|
|
|
@@ -308,18 +319,6 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void initDatas() {
|
|
|
- if (CommonUtil.isNetWorkConnected(getActivity().getApplicationContext())){
|
|
|
- //每次初始化页面都需要访问网络数据用来更新本地缓存
|
|
|
- sendAllSubscriptionRequest();
|
|
|
- }else {
|
|
|
- //没有网络时,取本地数据库数据
|
|
|
- getDbSubsData();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取本地数据库全部订阅
|
|
|
*/
|
|
|
@@ -341,7 +340,6 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
} else {
|
|
|
if (keyStrings.size() == 0) {
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
mTypeListView.setVisibility(View.GONE);
|
|
|
mEmptyLayout.showEmpty();
|
|
|
mSubscriptionNumbers.clear();
|
|
|
@@ -349,7 +347,6 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
} else {
|
|
|
mTypeListView.setVisibility(View.VISIBLE);
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
AllSubscriptonKindMessage tempSubscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
List<SubscriptionNumber> tempSubscriptionNumbers = new ArrayList<>();
|
|
|
@@ -365,12 +362,16 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
tempSubscriptonKindMessage.setSubscriptionKind(currentKey);
|
|
|
tempSubscriptonKindMessage.setSubscriptionNumbers(tempSubscriptionNumbers);
|
|
|
mAllSubscriptonKindMessages.add(tempSubscriptonKindMessage);
|
|
|
+ if (mBufferKey != null && mBufferKey.equals(keyStrings.get(i))){
|
|
|
+ rbPos = i;
|
|
|
+ }
|
|
|
}
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+ initKeyStrings();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -408,22 +409,27 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
JSONArray datasArray = resultObject.getJSONArray("datas");
|
|
|
JSONObject datasObject = datasArray.getJSONObject(0);
|
|
|
Iterator<String> iterator = datasObject.keys();
|
|
|
+ keyStrings.clear();
|
|
|
+ mAllKeyStrings.clear();
|
|
|
if (!iterator.hasNext()) {
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "subs", null);
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "allsubs", null);
|
|
|
+ mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
mEmptyLayout.showEmpty();
|
|
|
if (mPullToRefreshListView.isRefreshing()) {
|
|
|
mPullToRefreshListView.onRefreshComplete();
|
|
|
Crouton.makeText(getActivity(), "没有未订阅数据", 0xff99cc00, 1500).show();
|
|
|
}
|
|
|
- keyStrings.clear();
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
mTypeListView.setVisibility(View.GONE);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- keyStrings.clear();
|
|
|
while (iterator.hasNext()) {
|
|
|
String key = iterator.next().toString();
|
|
|
Log.d("allsubskeys: ", key);
|
|
|
+ mAllKeyStrings.add(key);
|
|
|
AllSubscriptonKindMessage subscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
subscriptonKindMessage.setSubscriptionKind(key);
|
|
|
mNetSubscriptionNumbers = new ArrayList<>();
|
|
|
@@ -484,21 +490,39 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ if (mAllKeyStrings.size() == 0){
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "allsubs", null);
|
|
|
+ }else {
|
|
|
+ StringBuilder allKeyString = new StringBuilder();
|
|
|
+ for (int i = 0; i < mAllKeyStrings.size(); i++) {
|
|
|
+ allKeyString.append("," + mAllKeyStrings.get(i));
|
|
|
+ }
|
|
|
+ if (allKeyString.length() > 2) {
|
|
|
+ allKeyString.delete(0, 1);
|
|
|
+ }
|
|
|
+ SharedUtil.putString(currentMaster + currentUser + "allsubs", allKeyString.toString());
|
|
|
+ }
|
|
|
if (keyStrings.size() == 0) {
|
|
|
mTypeListView.setVisibility(View.GONE);
|
|
|
- initKeyStrings();
|
|
|
mEmptyLayout.showEmpty();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
} else {
|
|
|
+ if (mBufferKey != null){
|
|
|
+ for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
+ if (mBufferKey.equals(keyStrings.get(i))){
|
|
|
+ rbPos = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
mTypeListView.setVisibility(View.VISIBLE);
|
|
|
mSubsTypeAdapter.notifyDataSetChanged();
|
|
|
- initKeyStrings();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().clear();
|
|
|
mAllSubscriptionAdapter.getmSubscriptionNumbers().addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
Log.d("allsubscription:", mAllSubscriptionAdapter.getmSubscriptionNumbers().toString());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+ initKeyStrings();
|
|
|
|
|
|
if (mPullToRefreshListView.isRefreshing()) {
|
|
|
mPullToRefreshListView.onRefreshComplete();
|
|
|
@@ -518,6 +542,7 @@ public class SubscriptionAllFragment extends BaseFragment {
|
|
|
|
|
|
@Override
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
if (requestCode == SUBSCRIBE_DETAIL_REQUEST && resultCode == 9 && data != null) {
|
|
|
int statu = data.getIntExtra("status", 0);
|
|
|
if (mClickedPos != -1) {
|