|
@@ -16,14 +16,22 @@ import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.common.LogUtil;
|
|
import com.common.LogUtil;
|
|
|
import com.common.config.BaseConfig;
|
|
import com.common.config.BaseConfig;
|
|
|
|
|
+import com.common.data.DateFormatUtil;
|
|
|
|
|
+import com.common.data.JSONUtil;
|
|
|
|
|
+import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
import com.common.data.StringUtil;
|
|
|
import com.common.system.DisplayUtil;
|
|
import com.common.system.DisplayUtil;
|
|
|
import com.core.app.Constants;
|
|
import com.core.app.Constants;
|
|
|
import com.core.base.BaseActivity;
|
|
import com.core.base.BaseActivity;
|
|
|
import com.core.base.EasyFragment;
|
|
import com.core.base.EasyFragment;
|
|
|
import com.core.utils.IntentUtils;
|
|
import com.core.utils.IntentUtils;
|
|
|
|
|
+import com.core.utils.ToastUtil;
|
|
|
|
|
+import com.core.widget.EmptyLayout;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
import com.me.network.app.http.HttpClient;
|
|
@@ -34,9 +42,13 @@ import com.modular.apputils.adapter.PopListAdapter;
|
|
|
import com.modular.apputils.widget.CustomerBanner;
|
|
import com.modular.apputils.widget.CustomerBanner;
|
|
|
import com.uas.appworks.OA.platform.activity.CharitSearchActivity;
|
|
import com.uas.appworks.OA.platform.activity.CharitSearchActivity;
|
|
|
import com.uas.appworks.OA.platform.adapter.ActivityAdapter;
|
|
import com.uas.appworks.OA.platform.adapter.ActivityAdapter;
|
|
|
|
|
+import com.uas.appworks.OA.platform.model.CharitActModel;
|
|
|
import com.uas.appworks.OA.platform.model.TestString;
|
|
import com.uas.appworks.OA.platform.model.TestString;
|
|
|
import com.uas.appworks.R;
|
|
import com.uas.appworks.R;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Created by Bitlike on 2017/11/8.
|
|
* Created by Bitlike on 2017/11/8.
|
|
|
*/
|
|
*/
|
|
@@ -79,7 +91,7 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
if (item.getItemId() == R.id.search) {
|
|
if (item.getItemId() == R.id.search) {
|
|
|
startActivity(new Intent(ct, CharitSearchActivity.class).
|
|
startActivity(new Intent(ct, CharitSearchActivity.class).
|
|
|
putExtra("type", 2)
|
|
putExtra("type", 2)
|
|
|
- .putExtra("title","活动搜索"));
|
|
|
|
|
|
|
+ .putExtra("title", "活动搜索"));
|
|
|
}
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
}
|
|
@@ -91,7 +103,10 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
refreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
refreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- IntentUtils.linkCommonWeb(ct, Constants.BASE_CHARIT_ACTIVITY_URL);
|
|
|
|
|
|
|
+ if (mAdapter != null && ListUtils.getSize(mAdapter.getModels()) > i) {
|
|
|
|
|
+ CharitActModel model = mAdapter.getModels().get(i);
|
|
|
|
|
+ IntentUtils.linkCommonWeb(ct, Constants.BASE_CHARIT_ACTIVITY_URL + "/" + model.getId(), model.getName());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
initData();
|
|
initData();
|
|
@@ -110,7 +125,7 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
loadData("", "全部");
|
|
loadData("", "全部");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void loadData(String keyWork, String status) {
|
|
|
|
|
|
|
+ private void loadData(String keyWork, final String status) {
|
|
|
LogUtil.i("loadProjects=");
|
|
LogUtil.i("loadProjects=");
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("activities")
|
|
.url("activities")
|
|
@@ -121,10 +136,10 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
@Override
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
public void onResponse(Object o) {
|
|
|
try {
|
|
try {
|
|
|
- if (o != null && !BaseConfig.isDebug()) {
|
|
|
|
|
- handlerData(o.toString());
|
|
|
|
|
|
|
+ if (o != null) {
|
|
|
|
|
+ handlerData(o.toString(), status);
|
|
|
} else {
|
|
} else {
|
|
|
- handlerData(TestString.PROJECTS_DATA);
|
|
|
|
|
|
|
+ handlerData(TestString.PROJECTS_DATA, status);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
if (e != null) {
|
|
if (e != null) {
|
|
@@ -138,9 +153,52 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
}));
|
|
}));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void handlerData(String message) throws Exception {
|
|
|
|
|
|
|
+ private ActivityAdapter mAdapter;
|
|
|
|
|
+ private List<CharitActModel> allModels;
|
|
|
|
|
+
|
|
|
|
|
+ private void handlerData(String message, String status) throws Exception {
|
|
|
LogUtil.i("handlerData");
|
|
LogUtil.i("handlerData");
|
|
|
- refreshListView.setAdapter(new ActivityAdapter(ct, null));
|
|
|
|
|
|
|
+ if (JSONUtil.validateJSONObject(message)) {
|
|
|
|
|
+ JSONObject object = JSON.parseObject(message);
|
|
|
|
|
+ JSONArray array = JSONUtil.getJSONArray(object, "activityList");
|
|
|
|
|
+ allModels = JSON.parseArray(array.toString(), CharitActModel.class);
|
|
|
|
|
+ setAdapter(status, allModels);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setAdapter(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void setAdapter(String status, List<CharitActModel> models) {
|
|
|
|
|
+ String newtime = DateFormatUtil.long2Str("yyyy.MM.dd HH:mm");
|
|
|
|
|
+ List<CharitActModel> showModels = new ArrayList<>();
|
|
|
|
|
+ if (!"全部".equals(status)) {
|
|
|
|
|
+ for (CharitActModel model : models) {
|
|
|
|
|
+ if (newtime.compareTo(model.getStartTime()) < 0) {
|
|
|
|
|
+ if (status.equals("未开始")) {
|
|
|
|
|
+ showModels.add(model);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (newtime.compareTo(model.getEndTime()) > 0) {
|
|
|
|
|
+ if (status.equals("已结束")) {
|
|
|
|
|
+ showModels.add(model);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (status.equals("进行中")) {
|
|
|
|
|
+ showModels.add(model);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showModels = allModels;
|
|
|
|
|
+ }
|
|
|
|
|
+ setAdapter(showModels);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void setAdapter(List<CharitActModel> models) {
|
|
|
|
|
+ if (mAdapter == null) {
|
|
|
|
|
+ mAdapter = new ActivityAdapter(ct, models);
|
|
|
|
|
+ refreshListView.setAdapter(mAdapter);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mAdapter.setModels(models);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -159,13 +217,13 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
View windowView = LayoutInflater.from(ct).inflate(R.layout.item_list_pop, null);
|
|
View windowView = LayoutInflater.from(ct).inflate(R.layout.item_list_pop, null);
|
|
|
window.setContentView(windowView);
|
|
window.setContentView(windowView);
|
|
|
ListView contentLV = (ListView) windowView.findViewById(R.id.contentLV);
|
|
ListView contentLV = (ListView) windowView.findViewById(R.id.contentLV);
|
|
|
- final String[] messages = {"赞", "OK", "加油", "好的", "请及时完成"};
|
|
|
|
|
|
|
+ final String[] messages = {"全部", "未开始", "进行中", "已结束"};
|
|
|
contentLV.setAdapter(new PopListAdapter(ct, messages));
|
|
contentLV.setAdapter(new PopListAdapter(ct, messages));
|
|
|
window.setTouchable(true);
|
|
window.setTouchable(true);
|
|
|
window.setBackgroundDrawable(ct.getResources().getDrawable(R.drawable.pop_round_bg));
|
|
window.setBackgroundDrawable(ct.getResources().getDrawable(R.drawable.pop_round_bg));
|
|
|
window.getContentView().measure(0, 0);
|
|
window.getContentView().measure(0, 0);
|
|
|
- window.setHeight(DisplayUtil.dip2px(ct, 230));
|
|
|
|
|
- window.setWidth(DisplayUtil.dip2px(ct, 100));
|
|
|
|
|
|
|
+ window.setHeight(DisplayUtil.dip2px(ct, 180));
|
|
|
|
|
+ window.setWidth(DisplayUtil.dip2px(ct, 80));
|
|
|
// window.setAnimationStyle(R.style.MenuAnimationFade);
|
|
// window.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
window.setOutsideTouchable(false);
|
|
window.setOutsideTouchable(false);
|
|
|
window.setFocusable(true);
|
|
window.setFocusable(true);
|
|
@@ -180,10 +238,10 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
String message = messages[position];
|
|
String message = messages[position];
|
|
|
window.dismiss();
|
|
window.dismiss();
|
|
|
- LogUtil.i("message+" + message);
|
|
|
|
|
|
|
+ selectStatus(message);
|
|
|
|
|
+ statusTv.setText(message);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
window.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
window.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onDismiss() {
|
|
public void onDismiss() {
|
|
@@ -191,4 +249,15 @@ public class ActivityFragment extends EasyFragment implements View.OnClickListen
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void selectStatus(String message) {
|
|
|
|
|
+ if (message == null || message.length() <= 0) {
|
|
|
|
|
+ ToastUtil.showToast(ct, "选择错误");
|
|
|
|
|
+ } else if (ListUtils.isEmpty(allModels)) {
|
|
|
|
|
+ loadData("", message);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setAdapter(message, allModels);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|