|
|
@@ -5,30 +5,43 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.provider.Settings;
|
|
|
+import android.support.constraint.ConstraintLayout;
|
|
|
+import android.support.v7.widget.AppCompatTextView;
|
|
|
import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.ContextMenu;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuInflater;
|
|
|
+import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.BaseAdapter;
|
|
|
+import android.widget.ImageButton;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.ScrollView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
|
+import com.common.data.TextUtil;
|
|
|
import com.common.preferences.PreferenceUtils;
|
|
|
import com.common.system.DisplayUtil;
|
|
|
import com.core.api.wxapi.ApiPlatform;
|
|
|
import com.core.api.wxapi.ApiUtils;
|
|
|
import com.core.app.Constants;
|
|
|
+import com.core.base.BaseActivity;
|
|
|
import com.core.base.EasyFragment;
|
|
|
import com.core.model.Friend;
|
|
|
+import com.core.model.WorkModel;
|
|
|
+import com.core.utils.ToastUtil;
|
|
|
import com.core.utils.sortlist.BaseSortModel;
|
|
|
import com.core.widget.DrawableCenterTextView;
|
|
|
import com.core.widget.MyListView;
|
|
|
@@ -47,6 +60,7 @@ import com.modular.appmessages.adapter.MessageAdapter;
|
|
|
import com.modular.appmessages.model.MessageHeader;
|
|
|
import com.modular.appmessages.presenter.MessagePresenter;
|
|
|
import com.modular.appmessages.presenter.imp.IMessageView;
|
|
|
+import com.modular.appmessages.widget.SignRefreshLayout;
|
|
|
import com.uas.appme.pedometer.view.UURanking;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.platform.task.TaskActivity;
|
|
|
@@ -67,14 +81,19 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
|
|
|
@ViewInject(R.id.message_net_set)
|
|
|
private DrawableCenterTextView message_net_set;
|
|
|
- @ViewInject(R.id.pullScrollView)
|
|
|
- private PullToRefreshScrollView pullScrollView;
|
|
|
+ @ViewInject(R.id.mSignRefreshLayout)
|
|
|
+ private SignRefreshLayout mSignRefreshLayout;
|
|
|
@ViewInject(R.id.headerLV)
|
|
|
private MyListView headerLV;
|
|
|
@ViewInject(R.id.contentLV)
|
|
|
private MyListView contentLV;
|
|
|
|
|
|
- private Activity mContext;
|
|
|
+ private View signView;
|
|
|
+ private ImageButton itemSignImage;
|
|
|
+ private AppCompatTextView itemWorkTv;
|
|
|
+ private AppCompatTextView itemOffkTv;
|
|
|
+
|
|
|
+ private BaseActivity mContext;
|
|
|
private MessagePresenter presenter;
|
|
|
private MessageAdapter mAdapter;
|
|
|
private PopupWindow setWindow;
|
|
|
@@ -89,8 +108,8 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
@Override
|
|
|
public void onAttach(Context context) {
|
|
|
super.onAttach(context);
|
|
|
- if (context instanceof Activity) {
|
|
|
- mContext = (Activity) context;
|
|
|
+ if (context instanceof BaseActivity) {
|
|
|
+ mContext = (BaseActivity) context;
|
|
|
}
|
|
|
if (context instanceof MessagePresenter.UnReaderListener) {
|
|
|
unReaderListener = (MessagePresenter.UnReaderListener) context;
|
|
|
@@ -104,6 +123,20 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
+ inflater.inflate(R.menu.add_new, menu);
|
|
|
+ super.onCreateOptionsMenu(menu, inflater);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ if (item.getItemId() == R.id.add) {
|
|
|
+ setSignViewData();
|
|
|
+ }
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected int inflateLayoutId() {
|
|
|
return R.layout.fragment_new_message;
|
|
|
@@ -111,12 +144,12 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
|
|
|
@Override
|
|
|
protected void onCreateView(Bundle savedInstanceState, boolean createView) {
|
|
|
- LogUtil.d("onCreateView:" + DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS));
|
|
|
if (createView) {
|
|
|
ViewUtils.inject(getmRootView());
|
|
|
platform = ApiUtils.getApiModel() instanceof ApiPlatform;
|
|
|
initView();
|
|
|
initEvent();
|
|
|
+ setHasOptionsMenu(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -124,6 +157,9 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
presenter.loadData();
|
|
|
+ if (!mSignRefreshLayout.isEnablePullDown()) {
|
|
|
+ mSignRefreshLayout.setSignShow();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -135,13 +171,13 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
presenter.search(s.toString());
|
|
|
}
|
|
|
});
|
|
|
- pullScrollView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ScrollView>() {
|
|
|
+ mSignRefreshLayout.setOnRefreshListener(new SignRefreshLayout.onRefreshListener() {
|
|
|
@Override
|
|
|
- public void onRefresh(PullToRefreshBase<ScrollView> refreshView) {
|
|
|
-// initHeaderView();
|
|
|
+ public void onRefresh() {
|
|
|
presenter.loadData();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
contentLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
@@ -169,12 +205,56 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
|
|
|
|
|
|
private void initView() {
|
|
|
- pullScrollView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
|
|
mAdapter = new MessageAdapter(null, mContext);
|
|
|
contentLV.setAdapter(mAdapter);
|
|
|
presenter = new MessagePresenter(mContext, this, unReaderListener);
|
|
|
+ signView = mSignRefreshLayout.getSignView();
|
|
|
+
|
|
|
+
|
|
|
+ if (signView != null) {
|
|
|
+ itemSignImage = signView.findViewById(R.id.itemSignImage);
|
|
|
+ itemWorkTv = signView.findViewById(R.id.itemWorkTv);
|
|
|
+ itemOffkTv = signView.findViewById(R.id.itemOffkTv);
|
|
|
+ itemSignImage.setOnClickListener(this);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ public void showProgress() {
|
|
|
+ if (mContext != null && mContext.progressDialog != null) {
|
|
|
+ mContext.progressDialog.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setSignViewData() {
|
|
|
+ if (mContext != null && mContext.progressDialog != null) {
|
|
|
+ mContext.progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ WorkModel work = presenter.getCurrentWork();
|
|
|
+ if (work != null) {
|
|
|
+ if (itemWorkTv != null) {
|
|
|
+ if (TextUtils.isEmpty(work.getWorkSignin())) {
|
|
|
+ itemWorkTv.setTextColor(getResources().getColor(R.color.message_not_sign_time));
|
|
|
+ itemWorkTv.setText("未打卡(" + work.getWorkTime() + ")");
|
|
|
+ } else {
|
|
|
+ itemWorkTv.setText(work.getWorkSignin() + ":00");
|
|
|
+ itemWorkTv.setTextColor(getResources().getColor(R.color.white));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (itemOffkTv != null) {
|
|
|
+ if (TextUtils.isEmpty(work.getOffSignin())) {
|
|
|
+ itemOffkTv.setTextColor(getResources().getColor(R.color.message_not_sign_time));
|
|
|
+ itemOffkTv.setText("未打卡(" + work.getOffTime() + ")");
|
|
|
+ } else {
|
|
|
+ itemOffkTv.setText(work.getOffSignin() + ":00");
|
|
|
+ itemOffkTv.setTextColor(getResources().getColor(R.color.white));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mSignRefreshLayout.setTag(work);
|
|
|
+ mSignRefreshLayout.setSignShow();
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast(ct, "未找到班次!!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void showPopupWindow() {
|
|
|
if (setWindow == null) initPopupWindow();
|
|
|
@@ -250,11 +330,20 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
break;
|
|
|
|
|
|
case R.id.uustep_rl:
|
|
|
-// startActivity(new Intent(mContext, UUSportActivity.class));
|
|
|
startActivity(new Intent(mContext, UURanking.class));
|
|
|
-// uustepRedtv.setVisibility(View.GONE);
|
|
|
PreferenceUtils.putBoolean(Constants.UU_STEP_RED, true);
|
|
|
break;
|
|
|
+
|
|
|
+ case R.id.itemSignImage:
|
|
|
+ WorkModel work = null;
|
|
|
+ if (mSignRefreshLayout != null && mSignRefreshLayout.getTag() != null) {
|
|
|
+ Object tag = mSignRefreshLayout.getTag();
|
|
|
+ if (tag instanceof WorkModel) {
|
|
|
+ work = (WorkModel) tag;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ presenter.signWork(work);
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -263,8 +352,8 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
@Override
|
|
|
public void showModel(List<BaseSortModel<Friend>> models) {
|
|
|
sortModels(models);
|
|
|
- if (pullScrollView.isRefreshing()) {
|
|
|
- pullScrollView.onRefreshComplete();
|
|
|
+ if (mSignRefreshLayout.isRefreshing()) {
|
|
|
+ mSignRefreshLayout.stopRefresh();
|
|
|
}
|
|
|
if (mAdapter == null) {
|
|
|
mAdapter = new MessageAdapter(models, mContext);
|
|
|
@@ -321,7 +410,7 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- pullScrollView.onRefreshComplete();
|
|
|
+ mSignRefreshLayout.stopRefresh();
|
|
|
}
|
|
|
|
|
|
private boolean updateHideOrDisplay(int num, boolean isUpdated, int type) {
|
|
|
@@ -395,6 +484,11 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateSign() {
|
|
|
+ setSignViewData();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private class HeadAdapter extends BaseAdapter {
|
|
|
List<MessageHeader> models;
|