导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - SettingSwitchActivity.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 SettingSwitchActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.activity;

import android.view.View;
import android.widget.ImageView;
import butterknife.BindView;
import butterknife.OnClick;
import com.luanxingyuan.app.base.AppManager;
import com.luanxingyuan.app.base.BaseActivity;
import com.luanxingyuan.app.base.BaseResponse;
import com.luanxingyuan.app.bean.UserCenterBean;
import com.luanxingyuan.app.util.ParamUtil;
import com.luanxingyuan.app.util.ToastUtil;
import java.util.HashMap;
import o6.n;

public class SettingSwitchActivity extends BaseActivity {

    @BindView
    ImageView mSoundIv;

    @BindView
    ImageView mVibrateIv;
    private UserCenterBean userCenterBean;

    class a extends r6.a<BaseResponse<UserCenterBean>> {
        a() {
        }

        public void onResponse(BaseResponse<UserCenterBean> baseResponse, int i8) {
            UserCenterBean userCenterBean;
            if (SettingSwitchActivity.this.isFinishing() || baseResponse == null || baseResponse.m_istatus != 1 || (userCenterBean = baseResponse.m_object) == null) {
                return;
            }
            SettingSwitchActivity.this.userCenterBean = userCenterBean;
            SettingSwitchActivity.this.refreshSwitch();
        }
    }

    class b implements View.OnClickListener {

        class a extends r6.a<BaseResponse> {

            final View f7040a;

            final boolean f7041b;

            final int f7042c;

            a(View view, boolean z7, int i8) {
                this.f7040a = view;
                this.f7041b = z7;
                this.f7042c = i8;
            }

            @Override
            public void onError(x8.e eVar, Exception exc, int i8) {
                super.onError(eVar, exc, i8);
                if (SettingSwitchActivity.this.isFinishing()) {
                    return;
                }
                ((BaseActivity) SettingSwitchActivity.this).mContext.dismissLoadingDialog();
            }

            public void onResponse(BaseResponse baseResponse, int i8) {
                if (SettingSwitchActivity.this.isFinishing()) {
                    return;
                }
                ((BaseActivity) SettingSwitchActivity.this).mContext.dismissLoadingDialog();
                if (baseResponse == null || baseResponse.m_istatus != 1) {
                    ToastUtil.showToast(((BaseActivity) SettingSwitchActivity.this).mContext, 2131821363);
                    return;
                }
                this.f7040a.setSelected(this.f7041b);
                if (this.f7041b) {
                    return;
                }
                ToastUtil.showToast(((BaseActivity) SettingSwitchActivity.this).mContext, new int[]{2131821362, 2131821360, 2131821361}[this.f7042c - 1]);
            }
        }

        b() {
        }

        @Override
        public void onClick(View view) {
            if (SettingSwitchActivity.this.userCenterBean == null) {
                ToastUtil.showToast("获取数据中");
                SettingSwitchActivity.this.getInfo();
                return;
            }
            ((BaseActivity) SettingSwitchActivity.this).mContext.showLoadingDialog();
            int parseInt = Integer.parseInt(view.getTag().toString());
            boolean z7 = !view.isSelected();
            HashMap hashMap = new HashMap();
            hashMap.put("userId", ((BaseActivity) SettingSwitchActivity.this).mContext.getUserId());
            hashMap.put("chatType", Integer.valueOf(parseInt));
            hashMap.put("switchType", Integer.valueOf(z7 ? 1 : 0));
            x7.a.h().c(m6.a.v2()).e("param", ParamUtil.getParam(hashMap)).f().c(new a(view, z7, parseInt));
        }
    }

    public void getInfo() {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", Integer.valueOf(AppManager.f().k().t_id));
        x7.a.h().c(m6.a.M0()).e("param", ParamUtil.getParam(hashMap)).f().c(new a());
    }

    private void initView() {
        this.mSoundIv.setSelected(n.n(getApplicationContext()));
        this.mVibrateIv.setSelected(n.p(getApplicationContext()));
    }

    public void refreshSwitch() {
        View findViewById = findViewById(2131297422);
        View findViewById2 = findViewById(2131296374);
        View findViewById3 = findViewById(2131297086);
        UserCenterBean userCenterBean = this.userCenterBean;
        if (userCenterBean != null) {
            findViewById2.setSelected(userCenterBean.t_voice_switch == 1);
            findViewById3.setSelected(this.userCenterBean.t_text_switch == 1);
            findViewById.setSelected(this.userCenterBean.t_is_not_disturb == 1);
        } else {
            getInfo();
        }
        findViewById.setTag(1);
        findViewById2.setTag(2);
        findViewById3.setTag(3);
        b bVar = new b();
        findViewById.setOnClickListener(bVar);
        findViewById2.setOnClickListener(bVar);
        findViewById3.setOnClickListener(bVar);
    }

    @Override
    protected View getContentView() {
        return inflate(2131492964);
    }

    @OnClick
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131297248) {
            if (this.mSoundIv.isSelected()) {
                this.mSoundIv.setSelected(false);
                n.G(getApplicationContext(), false);
                return;
            } else {
                this.mSoundIv.setSelected(true);
                n.G(getApplicationContext(), true);
                return;
            }
        }
        if (id != 2131297416) {
            return;
        }
        if (this.mVibrateIv.isSelected()) {
            this.mVibrateIv.setSelected(false);
            n.I(getApplicationContext(), false);
        } else {
            this.mVibrateIv.setSelected(true);
            n.I(getApplicationContext(), true);
        }
    }

    @Override
    protected void onContentAdded() {
        setTitle("消息设置");
        initView();
        refreshSwitch();
    }
}