fix: 定时推送(未完成)

This commit is contained in:
md 2021-09-03 10:50:33 +08:00
parent 94526a9054
commit fd1be59439
3 changed files with 33 additions and 22 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion '29.0.2' buildToolsVersion '29.0.2'
// ndkVersion '23.0.7123448' ndkVersion '23.0.7123448'
defaultConfig { defaultConfig {
applicationId "com.navinfo.outdoor" applicationId "com.navinfo.outdoor"

View File

@ -55,7 +55,7 @@ import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.bean.GetPhoneBean; import com.navinfo.outdoor.bean.GetPhoneBean;
import com.navinfo.outdoor.bean.JobSearchBean; import com.navinfo.outdoor.bean.JobSearchBean;
import com.navinfo.outdoor.bean.TaskPrefectureBean; import com.navinfo.outdoor.bean.MessageNoticeBean;
import com.navinfo.outdoor.bean.UserBean; import com.navinfo.outdoor.bean.UserBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
@ -136,7 +136,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
if (msg.what == 0x100) { if (msg.what == 0x100) {
isBack = false; isBack = false;
} }
if (msg.what == 0x101){ if (msg.what == 0x101) {
initMessageNotice(); initMessageNotice();
} }
return false; return false;
@ -144,7 +144,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
}); });
/** /**
* bitmapDescriptor1 * bitmapDescriptor1
*/ */
@ -161,7 +160,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
private ArrayList<LatLng> latList; private ArrayList<LatLng> latList;
private ArrayList<PoiEntity> poiEntityArrayList; private ArrayList<PoiEntity> poiEntityArrayList;
private ImageView ivMassNotification; private ImageView ivMassNotification;
private int messageType=0; private int messageType = 0;
public static TreasureFragment newInstance(Bundle bundle) { public static TreasureFragment newInstance(Bundle bundle) {
@ -185,40 +184,45 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
dismissLoadingDialog(); dismissLoadingDialog();
removableHashMap.clear(); removableHashMap.clear();
initThread(); // 刷新筛选的本地数据 initThread(); // 刷新筛选的本地数据
if (Constant.currentLocation!=null){ if (Constant.currentLocation != null) {
initList(Constant.currentLocation); // 刷新筛选的网络数据 initList(Constant.currentLocation); // 刷新筛选的网络数据
}else { } else {
Toast.makeText(getActivity(), "未开启定位服务", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "未开启定位服务", Toast.LENGTH_SHORT).show();
} }
} }
private void initMessageNotice() {
private void initMessageNotice() {
OkGoBuilder.getInstance() OkGoBuilder.getInstance()
.Builder(getActivity()) .Builder(getActivity())
.url(HttpInterface.MESSAGE_INFO_PUSH) .url(HttpInterface.MESSAGE_INFO_PUSH)
.params( new HttpParams("type",messageType+"")) .params(new HttpParams("type", messageType + ""))
.cls(TaskPrefectureBean.class) .cls(MessageNoticeBean.class)
.token(Constant.ACCESS_TOKEN) .token(Constant.ACCESS_TOKEN)
.getRequest(new Callback<GetPhoneBean>() { .getRequest(new Callback<MessageNoticeBean>() {
@Override @Override
public void onSuccess(GetPhoneBean getPhoneBean, int id) { public void onSuccess(MessageNoticeBean messageNoticeBean, int id) {
if (getPhoneBean.getCode() == 200) { dismissLoadingDialog();
String code = getPhoneBean.getBody().getCode(); if (messageNoticeBean.getCode() == 200) {
Integer telLength = getPhoneBean.getBody().getTelLength(); if (messageType == 0) {
Constant.CODE = code; ivMassNotification.setVisibility(View.GONE);
Constant.TelLength = telLength; } else if (messageType == 1) {
ivMassNotification.setVisibility(View.VISIBLE);
}
} else { } else {
Toast.makeText(getActivity(), getPhoneBean.getMessage() + "", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), messageNoticeBean.getMessage() + "", Toast.LENGTH_SHORT).show();
} }
} }
@Override @Override
public void onError(Throwable e, int id) { public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
} }
}); });
} }
@Override @Override
protected void initView() { protected void initView() {
super.initView(); super.initView();
@ -329,7 +333,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
treasureMap.getLayoutParams().height = widthHeight[1]; treasureMap.getLayoutParams().height = widthHeight[1];
//消息通知 //消息通知
handler.sendEmptyMessageDelayed(0x101,10000);
} }

View File

@ -5,11 +5,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<!-- android:lines="1"--> <!-- android:lines="1"-->
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cb_filter"
app:layout_constraintTop_toTopOf="@+id/tv_form"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
android:layout_width="260dp" android:layout_width="260dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="20dp" android:layout_marginTop="20dp"
android:layout_marginLeft="35dp"
android:text="测试彼此" android:text="测试彼此"
android:textColor="#333" android:textColor="#333"
android:textSize="15sp" android:textSize="15sp"
@ -20,7 +27,7 @@
android:id="@+id/tv_form" android:id="@+id/tv_form"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="20dp" android:layout_marginLeft="35dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:background="@drawable/underline" android:background="@drawable/underline"
android:padding="5dp" android:padding="5dp"
@ -51,7 +58,7 @@
android:text="任务id:11315" android:text="任务id:11315"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/tv_name" app:layout_constraintStart_toStartOf="@+id/tv_name"
app:layout_constraintTop_toBottomOf="@+id/tv_name" /> app:layout_constraintTop_toBottomOf="@+id/tv_name"/>
<TextView <TextView
android:id="@+id/tv_money" android:id="@+id/tv_money"