|
|
@ -2,6 +2,8 @@ package com.kanglai.push.ui.fragment; |
|
|
|
|
|
|
|
|
|
|
|
import static com.blankj.utilcode.util.ServiceUtils.stopService; |
|
|
|
import static com.blankj.utilcode.util.ServiceUtils.stopService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.ActivityManager; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.util.Patterns; |
|
|
|
import android.util.Patterns; |
|
|
@ -17,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
|
|
|
|
import com.blankj.utilcode.util.CacheDiskUtils; |
|
|
|
import com.blankj.utilcode.util.CacheDiskUtils; |
|
|
|
import com.blankj.utilcode.util.CollectionUtils; |
|
|
|
import com.blankj.utilcode.util.CollectionUtils; |
|
|
|
|
|
|
|
import com.blankj.utilcode.util.LogUtils; |
|
|
|
import com.bumptech.glide.Glide; |
|
|
|
import com.bumptech.glide.Glide; |
|
|
|
import com.dolphin.core.BuildConfig; |
|
|
|
import com.dolphin.core.BuildConfig; |
|
|
|
import com.dolphin.core.base.BaseFragment; |
|
|
|
import com.dolphin.core.base.BaseFragment; |
|
|
@ -26,10 +29,10 @@ import com.kanglai.push.R; |
|
|
|
import com.kanglai.push.constant.CacheConstant; |
|
|
|
import com.kanglai.push.constant.CacheConstant; |
|
|
|
import com.kanglai.push.databinding.FragmentUserBinding; |
|
|
|
import com.kanglai.push.databinding.FragmentUserBinding; |
|
|
|
import com.kanglai.push.entity.User; |
|
|
|
import com.kanglai.push.entity.User; |
|
|
|
import com.kanglai.push.util.LocationService; |
|
|
|
|
|
|
|
import com.kanglai.push.ui.activity.AboutActivity; |
|
|
|
import com.kanglai.push.ui.activity.AboutActivity; |
|
|
|
import com.kanglai.push.ui.adapter.PanelRecyclerAdapter; |
|
|
|
import com.kanglai.push.ui.adapter.PanelRecyclerAdapter; |
|
|
|
import com.kanglai.push.ui.vm.UserViewModel; |
|
|
|
import com.kanglai.push.ui.vm.UserViewModel; |
|
|
|
|
|
|
|
import com.kanglai.push.util.LocationService; |
|
|
|
import com.kongzue.dialogx.DialogX; |
|
|
|
import com.kongzue.dialogx.DialogX; |
|
|
|
import com.kongzue.dialogx.dialogs.MessageDialog; |
|
|
|
import com.kongzue.dialogx.dialogs.MessageDialog; |
|
|
|
import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener; |
|
|
|
import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener; |
|
|
@ -78,9 +81,9 @@ public class UserFragment extends BaseFragment<FragmentUserBinding, UserViewMode |
|
|
|
mRecyclerView = getView().findViewById(R.id.recycler_view); |
|
|
|
mRecyclerView = getView().findViewById(R.id.recycler_view); |
|
|
|
// 设置列表
|
|
|
|
// 设置列表
|
|
|
|
List<PanelRecyclerAdapter.PanelEntity> list = CollectionUtils.newArrayList( |
|
|
|
List<PanelRecyclerAdapter.PanelEntity> list = CollectionUtils.newArrayList( |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("1").setTitle("关闭定位服务").setBadge(0).setImage(R.drawable.icon_about).setHidesLeftImage(true), |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("1").setTitle("关于我们").setBadge(0).setImage(R.drawable.icon_about).setHidesLeftImage(true), |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("2").setTitle("关于我们").setBadge(0).setImage(R.drawable.icon_about).setHidesLeftImage(true), |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("2").setTitle("退出登录").setBadge(0).setImage(R.drawable.icon_exit).setHidesLeftImage(true), |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("3").setTitle("退出登录").setBadge(0).setImage(R.drawable.icon_exit).setHidesLeftImage(true) |
|
|
|
new PanelRecyclerAdapter.PanelEntity().setCode("3").setTitle("测试按钮").setBadge(0).setImage(R.drawable.icon_about).setHidesLeftImage(true) |
|
|
|
); |
|
|
|
); |
|
|
|
final PanelRecyclerAdapter userRecyclerAdapter = new PanelRecyclerAdapter(list); |
|
|
|
final PanelRecyclerAdapter userRecyclerAdapter = new PanelRecyclerAdapter(list); |
|
|
|
userRecyclerAdapter.setEventListener(this); |
|
|
|
userRecyclerAdapter.setEventListener(this); |
|
|
@ -105,13 +108,10 @@ public class UserFragment extends BaseFragment<FragmentUserBinding, UserViewMode |
|
|
|
public void onItemViewClicked(PanelRecyclerAdapter.PanelEntity userEntity) { |
|
|
|
public void onItemViewClicked(PanelRecyclerAdapter.PanelEntity userEntity) { |
|
|
|
/** 列表点击事件 */ |
|
|
|
/** 列表点击事件 */ |
|
|
|
switch (userEntity.code) { |
|
|
|
switch (userEntity.code) { |
|
|
|
case "1": // todo: 暂未定义内容 后续可用来测试
|
|
|
|
case "1": // 关于我们
|
|
|
|
stopService(LocationService.class); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "2": // 关于我们
|
|
|
|
|
|
|
|
startActivity(AboutActivity.class); |
|
|
|
startActivity(AboutActivity.class); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "3": // 退出登录
|
|
|
|
case "2": // 退出登录
|
|
|
|
MessageDialog.build() |
|
|
|
MessageDialog.build() |
|
|
|
.setTheme(DialogX.THEME.LIGHT) |
|
|
|
.setTheme(DialogX.THEME.LIGHT) |
|
|
|
.setTitle("您确定要退出登录吗?") |
|
|
|
.setTitle("您确定要退出登录吗?") |
|
|
@ -128,6 +128,19 @@ public class UserFragment extends BaseFragment<FragmentUserBinding, UserViewMode |
|
|
|
.setCancelButton("取 消") |
|
|
|
.setCancelButton("取 消") |
|
|
|
.show(); |
|
|
|
.show(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case "3": // todo:测试按钮 上线记得清除
|
|
|
|
|
|
|
|
// stopService(LocationService.class); 暂停定位服务
|
|
|
|
|
|
|
|
// CacheDiskUtils.getInstance().remove(CacheConstant.USER_INFO); 清除用户数据
|
|
|
|
|
|
|
|
// 检测服务是否在线
|
|
|
|
|
|
|
|
ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); |
|
|
|
|
|
|
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){ |
|
|
|
|
|
|
|
LogUtils.d(service.service.getClassName()); |
|
|
|
|
|
|
|
if (LocationService.class.getName().equals(service.service.getClassName())){ |
|
|
|
|
|
|
|
LogUtils.d("在线"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|