|
|
@@ -22,9 +22,9 @@ import com.xzjmyk.pm.activity.bean.PersonalSubscriptionBean;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
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.view.crouton.Crouton;
|
|
|
-import com.xzjmyk.pm.activity.view.crouton.Style;
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONException;
|
|
|
@@ -53,6 +53,7 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
private final static int REMOVE_MY_SUBSCRIPTION = 13;
|
|
|
|
|
|
private int mCanclePosition;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_my_subscription;
|
|
|
@@ -66,6 +67,12 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
mMySubscriptionAdapter = new MySubscriptionAdapter(getActivity(),mPersonalSubscriptionBeans);
|
|
|
mMySwipeMenuCreator = new MySwipeMenuCreator(getActivity());
|
|
|
|
|
|
+
|
|
|
+ mEmptyLayout = new EmptyLayout(getActivity(),mSwipeMenuListView);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setEmptyMessage("您没有任何订阅号");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -153,6 +160,7 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
* 获取当前用户的订阅号
|
|
|
*/
|
|
|
private void sendSubscriptionRequest() {
|
|
|
+ progressDialog.show();
|
|
|
String subsUrl = Constants.getAppBaseUrl(getActivity()) + "common/charts/getPersonalSubs.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("em_code", CommonUtil.getSharedPreferences(getActivity(),"erp_username"));
|
|
|
@@ -166,6 +174,7 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
* 取消订阅
|
|
|
*/
|
|
|
private void sendRemoveRequest(int position) {
|
|
|
+ progressDialog.show();
|
|
|
String subsUrl = Constants.getAppBaseUrl(getActivity()) + "common/charts/removeSubsMans.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("em_code", CommonUtil.getSharedPreferences(getActivity(),"erp_username"));
|
|
|
@@ -183,26 +192,40 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what){
|
|
|
case GET_MY_SUBSCRIPTION:
|
|
|
+ progressDialog.dismiss();
|
|
|
String resultJson = msg.getData().getString("result");
|
|
|
Log.d("subscriptionResult",resultJson);
|
|
|
try {
|
|
|
JSONObject resultObject = new JSONObject(resultJson);
|
|
|
JSONArray resultArray = resultObject.getJSONArray("datas");
|
|
|
- for (int i = 0; i < resultArray.length(); i++) {
|
|
|
- JSONObject currentObject = resultArray.getJSONObject(i);
|
|
|
- PersonalSubscriptionBean personalSubscriptionBean = new PersonalSubscriptionBean();
|
|
|
- personalSubscriptionBean.setNUM_ID(currentObject.getInt("NUM_ID"));
|
|
|
- personalSubscriptionBean.setTITLE(currentObject.getString("TITLE_"));
|
|
|
- personalSubscriptionBean.setKIND(currentObject.getString("KIND_"));
|
|
|
- personalSubscriptionBean.setTYPE(currentObject.getString("TYPE_"));
|
|
|
- personalSubscriptionBean.setISAPPLED(currentObject.getInt("ISAPPLIED_"));
|
|
|
-
|
|
|
- mPersonalSubscriptionBeans.add(personalSubscriptionBean);
|
|
|
+ if (resultArray != null){
|
|
|
+ if (resultArray.length() == 0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ if (mPullToRefreshScrollView.isRefreshing()){
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
+ Crouton.makeText(getActivity(),"您没有任何订阅号", 0xff99cc00, 1500).show();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (int i = 0; i < resultArray.length(); i++) {
|
|
|
+ JSONObject currentObject = resultArray.getJSONObject(i);
|
|
|
+ PersonalSubscriptionBean personalSubscriptionBean = new PersonalSubscriptionBean();
|
|
|
+ personalSubscriptionBean.setNUM_ID(currentObject.getInt("NUM_ID"));
|
|
|
+ personalSubscriptionBean.setTITLE(currentObject.getString("TITLE_"));
|
|
|
+ personalSubscriptionBean.setKIND(currentObject.getString("KIND_"));
|
|
|
+ personalSubscriptionBean.setTYPE(currentObject.getString("TYPE_"));
|
|
|
+ personalSubscriptionBean.setISAPPLED(currentObject.getInt("ISAPPLIED_"));
|
|
|
+
|
|
|
+ mPersonalSubscriptionBeans.add(personalSubscriptionBean);
|
|
|
+ }
|
|
|
+ mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
+ if (mPullToRefreshScrollView.isRefreshing()){
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
+ Crouton.makeText(getActivity(),"刷新成功", 0xff99cc00, 1500).show();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
if (mPullToRefreshScrollView.isRefreshing()){
|
|
|
mPullToRefreshScrollView.onRefreshComplete();
|
|
|
- Crouton.makeText(getActivity(),"刷新成功", Style.CONFIRM).show();
|
|
|
}
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -211,13 +234,15 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
break;
|
|
|
|
|
|
case REMOVE_MY_SUBSCRIPTION:
|
|
|
+ progressDialog.dismiss();
|
|
|
Crouton.makeText(getActivity(), "取消订阅成功", 0xff99cc00, 1500).show();
|
|
|
mPersonalSubscriptionBeans.remove(mCanclePosition);
|
|
|
mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
break;
|
|
|
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
- Crouton.makeText(getActivity(), msg.getData().getString("result"), Style.CONFIRM).show();
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Crouton.makeText(getActivity(), msg.getData().getString("result"), 0xff99cc00, 1500).show();
|
|
|
if (mPullToRefreshScrollView.isRefreshing()){
|
|
|
mPullToRefreshScrollView.onRefreshComplete();
|
|
|
}
|