Commit ce77cb3f authored by wangxuewei's avatar wangxuewei

[提交人]:王雪伟

[提交简述] :多多菜园1.0.2
[实现方案] :加入通知开关
parent bc0f82c8
......@@ -30,8 +30,6 @@ import com.ym.library.net.ApiClient
import com.ym.library.net.BaseObserver
import com.ym.library.net.RxSchedulers
import com.ym.library.net.UserInfoEntity
import com.ym.library.router.RounterApi
import com.ym.library.router.RounterBus
import com.ym.library.utils.*
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
......@@ -46,7 +44,7 @@ import java.lang.reflect.Method
class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
private var mOrderString = "";
private val mContext = AppliContext.get()
private var mRefreshLoginObservable: Observable<Boolean>? = null
private var mRefreshLoginObservable: Observable<String>? = null
@SuppressLint("CheckResult")
override fun onCreate(savedInstanceState: Bundle?) {
......@@ -55,21 +53,28 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
if (SettingPreference.getIsShowGuide()) {
SettingPreference.setIsShowGuide(false)
}
mRefreshLoginObservable = RxBus.get().register("refresh_login", Boolean::class.java)
mRefreshLoginObservable = RxBus.get().register("refresh_login", String::class.java)
TurntableDialog.initTurntableAnim()
getUserInfo()
checkUpdateApp()
mRefreshLoginObservable?.observeOn(AndroidSchedulers.mainThread())?.subscribe({
SettingPreference.setToken("")
try {
val intent = Intent(this@GameActivity, WxLoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
} catch (e: java.lang.Exception) {
when (it) {
"not_login" -> {
SettingPreference.setToken("")
try {
val intent = Intent(this, WxLoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
} catch (e: java.lang.Exception) {
}
}
"open_notif" -> {
openNotif()
}
"close_notif" -> {
scc?.let { unbindService(it) }
}
}
// if (mRefreshLoginObservable!=null){
// RxBus.get().unregister("refresh_login", mRefreshLoginObservable!!)//页面销毁的时候要执行 反注册
// }
}, {
})
......@@ -1068,16 +1073,20 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
//打开通知栏
private fun openNotif() {
val intent = Intent(this, NotificationService::class.java)
scc = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
val myBinder: NotificationService.MyBinder = service as NotificationService.MyBinder
myNotifService = myBinder.getService()
}
if (SettingPreference.getNotice()) {
val intent = Intent(this, NotificationService::class.java)
scc = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
val myBinder: NotificationService.MyBinder =
service as NotificationService.MyBinder
myNotifService = myBinder.getService()
}
override fun onServiceDisconnected(name: ComponentName) {}
override fun onServiceDisconnected(name: ComponentName) {}
}
bindService(intent, scc as ServiceConnection, BIND_AUTO_CREATE)
}
bindService(intent, scc as ServiceConnection, BIND_AUTO_CREATE)
}
}
\ No newline at end of file
PACKAGE_NAME=com.ym.ddcy
VERSION_CODE=3
VERSION_CODE=3
VERSION_NAME=1.0.2
\ No newline at end of file
......@@ -27,7 +27,7 @@ public abstract class BaseObserver<T> implements Observer<Response<T>> {
onSuccess(null);
}
} else if (TextUtils.equals(result.status, "101")) {//重试设备登录和获取用户信息
RxBus.get().post("refresh_login", true);
RxBus.get().post("refresh_login", "not_login");
} else if (TextUtils.equals(result.status, "160")) {
onFailure(null, "160", "请重试");//该异常可以汇报服务端
} else {
......
......@@ -129,6 +129,7 @@ public class SettingPreference {
private static final String SHOW_PRIVACY_PROTOCOL = "show_privacy_protocol";//是否同意隐私协议
private static final String SHOW_FIVE_WITHDRAW = "show_five_withdraw";//5首提现
private static final String SHOW_NOTIFICATION = "show_notification";//通知栏
/**
* 是否第一次进入APP
*
......@@ -236,6 +237,23 @@ public class SettingPreference {
return ad;
}
/**
* SHOW_NOTIFICATION
* 设置通知栏
*/
public static void setNotice(Boolean value) {
SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(SHOW_NOTIFICATION, value);
editor.commit();
}
public static Boolean getNotice() {
SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
Boolean ad = settings.getBoolean(SHOW_NOTIFICATION, true);
return ad;
}
/**
* 是否开发设备
......
......@@ -4,6 +4,7 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.util.Log
import android.widget.CompoundButton
import com.bytedance.sdk.openadsdk.TTNativeExpressAd
import com.umeng.analytics.MobclickAgent
import com.ym.library.Constant
......@@ -39,6 +40,18 @@ class SettingActivity : BaseActivity() {
id_iv_copy.setOnClickListener {
copy()
}
id_notif_check.isChecked = SettingPreference.getNotice()
//复选框
id_notif_check.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { compoundButton, b ->
SettingPreference.setNotice(b)
if (b) {
RxBus.get().post("refresh_login", "open_notif")
} else {
RxBus.get().post("refresh_login", "close_notif")
}
})
rl_back.setOnClickListener { finish() }
// id_iv_back.setOnClickListener { finish() }
// tv_user_toolbar_title.text = "设置"
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dc_notif_open" android:state_checked="true" />
<item android:drawable="@drawable/dc_notif_close" android:state_checked="false" />
<item android:drawable="@drawable/dc_notif_close" />
</selector>
\ No newline at end of file
......@@ -93,7 +93,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="8dp"
android:background="@drawable/icon_ll_bg"
......@@ -148,6 +148,43 @@
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="通知栏"
android:textColor="#642D2D"
android:textSize="15sp" />
<CheckBox
android:id="@+id/id_notif_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox_style"
android:checked="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/id_setting_update_version"
android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment