package com.yidianling.user.mine

import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.yidianling.user.R
import kotlinx.android.synthetic.main.user_mine_activity_persionalize_setting.*

/**
 * 个性化开关，隐私政策需要
 */
@Route(path = "/user/persionalizesetting")
class PersionalizeSettingActivity : BaseActivity() {
    private val PERSIONNALIZE_KEY = "persionalize"

    override fun layoutResId(): Int {
        return R.layout.user_mine_activity_persionalize_setting
    }

    override fun getStatusViewOptions(): StatusBarOptions {
        return StatusBarOptions(true, true)
    }

    override fun initDataAndEvent() {
        val key = SharedPreferencesEditor.getString(PERSIONNALIZE_KEY)
        tb_check.isChecked = !(key != null && key == "1")

        tb_check.setOnClickListener {
            if (tb_check.isChecked) {
                SharedPreferencesEditor.putString(PERSIONNALIZE_KEY, "0")
            } else {
                SharedPreferencesEditor.putString(PERSIONNALIZE_KEY, "1")
            }
        }
    }


}