|
|
@@ -0,0 +1,336 @@
|
|
|
+package com.uas.appworks.activity;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.drawable.AnimationDrawable;
|
|
|
+import android.support.v7.widget.AppCompatTextView;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuItem;
|
|
|
+import android.view.MotionEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.common.data.CalendarUtil;
|
|
|
+import com.common.data.DateFormatUtil;
|
|
|
+import com.common.data.JSONUtil;
|
|
|
+import com.core.app.MyApplication;
|
|
|
+import com.core.base.activity.BaseMVPActivity;
|
|
|
+import com.core.base.presenter.SimplePresenter;
|
|
|
+import com.core.base.view.SimpleView;
|
|
|
+import com.core.widget.arcmenu.ArcMenu;
|
|
|
+import com.me.network.app.base.HttpParams;
|
|
|
+import com.me.network.app.http.Method;
|
|
|
+import com.uas.appworks.R;
|
|
|
+import com.uas.appworks.adapter.TimeHelperAdapter;
|
|
|
+import com.uas.appworks.datainquiry.Constants;
|
|
|
+import com.uas.appworks.model.Schedule;
|
|
|
+import com.uas.appworks.model.bean.TimeHelperBean;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author RaoMeng
|
|
|
+ * @describe 时间助手页面
|
|
|
+ * @date 2018/8/21 15:02
|
|
|
+ */
|
|
|
+public class TimeHelperActivity extends BaseMVPActivity<SimplePresenter> implements SimpleView {
|
|
|
+ private static final int FLAG_GETBYDAY_SCHEDULE = 0x11;
|
|
|
+
|
|
|
+ private ArcMenu mArcMenu;
|
|
|
+ private static final int[] ITEM_DRAWABLES = {
|
|
|
+ R.drawable.ic_timehelper_metting,
|
|
|
+ R.drawable.ic_timehelper_order,
|
|
|
+ R.drawable.ic_timehelper_schedule};
|
|
|
+ private RecyclerView mRecyclerView;
|
|
|
+ private ImageView mBottomImageView;
|
|
|
+ private View mGrayView;
|
|
|
+ private List<TimeHelperBean> mTimeHelperBeans;
|
|
|
+ private TimeHelperAdapter mTimeHelperAdapter;
|
|
|
+ private AnimationDrawable mAnimationDrawable;
|
|
|
+ private View mEmptyView;
|
|
|
+ private AppCompatTextView mEmptyTextView;
|
|
|
+ private TextView mDateTextView;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.activity_time_helper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initView() {
|
|
|
+ setTitle(getString(R.string.title_time_helper));
|
|
|
+
|
|
|
+ mArcMenu = $(R.id.time_helper_arcmenu);
|
|
|
+ mDateTextView = $(R.id.time_helper_date_tv);
|
|
|
+ mRecyclerView = $(R.id.time_helper_rv);
|
|
|
+ mBottomImageView = $(R.id.time_helper_bottom_iv);
|
|
|
+ mBottomImageView.setImageResource(R.drawable.animlist_time_helper_icon);
|
|
|
+ mAnimationDrawable = (AnimationDrawable) mBottomImageView.getDrawable();
|
|
|
+
|
|
|
+ mGrayView = $(R.id.time_helper_gray_view);
|
|
|
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
|
+
|
|
|
+ mTimeHelperBeans = new ArrayList<>();
|
|
|
+ mTimeHelperAdapter = new TimeHelperAdapter(mTimeHelperBeans);
|
|
|
+ mRecyclerView.setAdapter(mTimeHelperAdapter);
|
|
|
+
|
|
|
+ mEmptyView = View.inflate(this, R.layout.common_empty_view, null);
|
|
|
+ mEmptyTextView = mEmptyView.findViewById(R.id.emptyTv);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected SimplePresenter initPresenter() {
|
|
|
+ return new SimplePresenter();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvent() {
|
|
|
+ mArcMenu.setOnMenuClickListener(new ArcMenu.OnMenuClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onMenuClick(boolean isExpanded) {
|
|
|
+ if (isExpanded) {
|
|
|
+ mGrayView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mGrayView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mGrayView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mBottomImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ onBackPressed();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTimeHelperAdapter.setOnTimeClickListener(new TimeHelperAdapter.OnTimeClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onTimeClick(int position) {
|
|
|
+ Schedule schedule = new Schedule();
|
|
|
+ TimeHelperBean timeHelperBean = mTimeHelperBeans.get(position);
|
|
|
+ schedule.setId(timeHelperBean.getScheduleId());
|
|
|
+ schedule.setType(timeHelperBean.getType());
|
|
|
+ schedule.setAllDay(timeHelperBean.getAllDay());
|
|
|
+ schedule.setRepeat(timeHelperBean.getRepeat());
|
|
|
+ schedule.setTitle(timeHelperBean.getTitle());
|
|
|
+ schedule.setTag(timeHelperBean.getTag());
|
|
|
+ schedule.setRemarks(timeHelperBean.getRemarks());
|
|
|
+ schedule.setStartTime(DateFormatUtil.str2Long(timeHelperBean.getStartTime(), DateFormatUtil.YMD_HMS));
|
|
|
+ schedule.setEndTime(DateFormatUtil.str2Long(timeHelperBean.getEndTime(), DateFormatUtil.YMD_HMS));
|
|
|
+ schedule.setWarnTime(timeHelperBean.getWarnTime());
|
|
|
+ schedule.setWarnRealTime(DateFormatUtil.str2Long(timeHelperBean.getWarnRealTime(), DateFormatUtil.YMD_HMS));
|
|
|
+ schedule.setAddress(timeHelperBean.getAddress());
|
|
|
+ schedule.setStatus(timeHelperBean.getStatus() + "");
|
|
|
+
|
|
|
+ startActivityForResult(new Intent(mContext, SchedulerCreateActivity.class)
|
|
|
+ .putExtra(Constants.Intents.ENABLE, false)
|
|
|
+ .putExtra(Constants.Intents.MODEL, schedule), 0x33);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
+ super.onWindowFocusChanged(hasFocus);
|
|
|
+ mAnimationDrawable.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initData() {
|
|
|
+ //添加弹出按钮
|
|
|
+ final int itemCount = ITEM_DRAWABLES.length;
|
|
|
+ for (int i = 0; i < itemCount; i++) {
|
|
|
+ ImageView item = new ImageView(this);
|
|
|
+ item.setImageResource(ITEM_DRAWABLES[i]);
|
|
|
+
|
|
|
+ final int position = i;
|
|
|
+ mArcMenu.addItem(item, new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mGrayView.setVisibility(View.GONE);
|
|
|
+ switch (position) {
|
|
|
+ case 0:
|
|
|
+ startActivityForResult(
|
|
|
+ new Intent("com.modular.oa.AddMeetingActivity"), 0x01);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ startActivityForResult(
|
|
|
+ new Intent("com.modular.booking.BookingListActivity")
|
|
|
+ .putExtra("whichPage", "timeHelper"), 0x02);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ startActivityForResult(new Intent(ct, SchedulerCreateActivity.class)
|
|
|
+ .putExtra(Constants.Intents.ENABLE, true), 0x03);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ String currentDate = DateFormatUtil.long2Str(System.currentTimeMillis(), "MM月dd日");
|
|
|
+ String currentWeek = CalendarUtil.getWeek(System.currentTimeMillis());
|
|
|
+ mDateTextView.setText(currentDate + "(" + currentWeek + ")");
|
|
|
+
|
|
|
+ getByDaySchedule(DateFormatUtil.long2Str(System.currentTimeMillis(), DateFormatUtil.YMD));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getByDaySchedule(String day) {
|
|
|
+ mPresenter.httpRequest(mContext, "http://192.168.253.230:8080/",
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url("schedule/schedule/getByDaySchedule")
|
|
|
+ .method(Method.GET)
|
|
|
+ .flag(FLAG_GETBYDAY_SCHEDULE)
|
|
|
+ .addParam("imid", MyApplication.getInstance().getLoginUserId())
|
|
|
+ .addParam("day", day).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void requestSuccess(int what, Object object) {
|
|
|
+ try {
|
|
|
+ String result = object.toString();
|
|
|
+ switch (what) {
|
|
|
+ case FLAG_GETBYDAY_SCHEDULE:
|
|
|
+ if (JSONUtil.validate(result)) {
|
|
|
+ mTimeHelperBeans.clear();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
+ int progress = -1;
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ TimeHelperBean timeHelperBean = new TimeHelperBean();
|
|
|
+ timeHelperBean.setScheduleId(JSONUtil.getInt(dataObject, "scheduleId"));
|
|
|
+ timeHelperBean.setImid(JSONUtil.getInt(dataObject, "imid"));
|
|
|
+ timeHelperBean.setType(JSONUtil.getText(dataObject, "type"));
|
|
|
+ timeHelperBean.setAllDay(JSONUtil.getInt(dataObject, "allDay"));
|
|
|
+ timeHelperBean.setRepeat(JSONUtil.getText(dataObject, "repeat"));
|
|
|
+ timeHelperBean.setTitle(JSONUtil.getText(dataObject, "title"));
|
|
|
+ timeHelperBean.setTag(JSONUtil.getText(dataObject, "tag"));
|
|
|
+ timeHelperBean.setRemarks(JSONUtil.getText(dataObject, "remarks"));
|
|
|
+
|
|
|
+ String startTime = JSONUtil.getText(dataObject, "startTime");
|
|
|
+ timeHelperBean.setStartTime(startTime);
|
|
|
+ long startLong = DateFormatUtil.str2Long(startTime, DateFormatUtil.YMD_HMS);
|
|
|
+ if (currentTimeMillis > startLong) {
|
|
|
+ progress++;
|
|
|
+ }
|
|
|
+
|
|
|
+ timeHelperBean.setEndTime(JSONUtil.getText(dataObject, "endTime"));
|
|
|
+ timeHelperBean.setWarnTime(JSONUtil.getInt(dataObject, "warnTime"));
|
|
|
+ timeHelperBean.setWarnRealTime(JSONUtil.getText(dataObject, "warnRealTime"));
|
|
|
+ timeHelperBean.setAddress(JSONUtil.getText(dataObject, "address"));
|
|
|
+ timeHelperBean.setStatus(JSONUtil.getInt(dataObject, "status"));
|
|
|
+ timeHelperBean.setScheduleType(JSONUtil.getInt(dataObject, "genre"));
|
|
|
+
|
|
|
+ mTimeHelperBeans.add(timeHelperBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Collections.sort(mTimeHelperBeans);
|
|
|
+
|
|
|
+ mTimeHelperAdapter.setTimeProgress(progress, 50);
|
|
|
+
|
|
|
+ mTimeHelperAdapter.notifyDataSetChanged();
|
|
|
+ if (mTimeHelperBeans.size() == 0) {
|
|
|
+ mEmptyTextView.setText("您今日的日程为空");
|
|
|
+ mTimeHelperAdapter.setEmptyView(mEmptyView);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mTimeHelperAdapter.notifyDataSetChanged();
|
|
|
+ mEmptyTextView.setText("您今日的日程为空");
|
|
|
+ mTimeHelperAdapter.setEmptyView(mEmptyView);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void requestError(int what, String errorMsg) {
|
|
|
+ try {
|
|
|
+ switch (what) {
|
|
|
+ case FLAG_GETBYDAY_SCHEDULE:
|
|
|
+ toast(errorMsg);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showLoading(String loadStr) {
|
|
|
+ progressDialog.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hideLoading() {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ getMenuInflater().inflate(R.menu.menu_time_helper, menu);
|
|
|
+ return super.onCreateOptionsMenu(menu);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ if (item.getItemId() == android.R.id.home) {
|
|
|
+ finish();
|
|
|
+ overridePendingTransition(R.anim.anim_activity_back_bottom_in, R.anim.anim_activity_back_top_out);
|
|
|
+ return true;
|
|
|
+ } else if (item.getItemId() == R.id.menu_time_helper_setting) {
|
|
|
+ startActivityForResult(TimeHelperSettingActivity.class, null, 0x11);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (requestCode == 0x01 || requestCode == 0x02 || requestCode == 0x03) {
|
|
|
+ getByDaySchedule(DateFormatUtil.long2Str(System.currentTimeMillis(), DateFormatUtil.YMD));
|
|
|
+ } else if ((requestCode == 0x33 || requestCode == 0x11) && resultCode == 0x11) {
|
|
|
+ getByDaySchedule(DateFormatUtil.long2Str(System.currentTimeMillis(), DateFormatUtil.YMD));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBackPressed() {
|
|
|
+ super.onBackPressed();
|
|
|
+ overridePendingTransition(R.anim.anim_activity_back_bottom_in, R.anim.anim_activity_back_top_out);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void finish() {
|
|
|
+ super.finish();
|
|
|
+ overridePendingTransition(R.anim.anim_activity_back_bottom_in, R.anim.anim_activity_back_top_out);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ mAnimationDrawable.stop();
|
|
|
+ }
|
|
|
+}
|