haijiang
2018-09-19 82cc6c94fdc08b1814fbf7195e88cf335eed3e8d
app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java
@@ -6,12 +6,14 @@
import android.support.v7.widget.SwitchCompat;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bigkoo.pickerview.OptionsPickerView;
import com.lzy.okgo.cache.CacheMode;
import com.moral.andbrickslib.utils.ActivityManager;
import com.moral.andbrickslib.utils.FastJsonTools;
import com.moral.yunfushao.MainActivity;
import com.moral.yunfushao.MainApp;
import com.moral.yunfushao.R;
@@ -24,6 +26,7 @@
import com.moral.yunfushao.httputils.HttpCallBack;
import com.moral.yunfushao.httputils.HttpUtils;
import com.moral.yunfushao.model.EventMessage;
import com.moral.yunfushao.model.VoiceBean;
import com.moral.yunfushao.utils.DebugUtils;
import org.greenrobot.eventbus.EventBus;
@@ -42,7 +45,7 @@
    private RelativeLayout rl_setvoice,rl_refresh;
    private Button bt_sure;
    private Button bt_look;
    private SwitchCompat sc_open;
    private SwitchCompat sc_open,sc_male;
    private int refreshIndex=0;
    @Override
    protected int getLayoutId() {
@@ -56,10 +59,19 @@
        bt_sure = findView(R.id.bt_sure);
        bt_look = findView(R.id.bt_look);
        sc_open = findView(R.id.sc_open);
        sc_male = findView(R.id.sc_male);
        tv_version = findView(R.id.tv_version);
        tv_version.setText("当前版本V"+getVersion());
        bt_look.setVisibility(DebugUtils.debug_mode ? View.VISIBLE : View.GONE);
//        bt_look.setVisibility(DebugUtils.debug_mode ? View.VISIBLE : View.GONE);
        bt_look.setVisibility(View.GONE);
        if (MainApp.theApp.sharedPreferencesUtil.getVoiceType() == 0) {
            sc_male.setChecked(false);
            sc_male.setText("男");
        }else{
            sc_male.setChecked(true);
            sc_male.setText("女");
        }
    }
    @Override
@@ -75,6 +87,25 @@
                }else{
                    update("is_open_upload","0");
                }
            }
        });
        sc_male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if(b){
                    sc_male.setText("女");
                    MainApp.theApp.sharedPreferencesUtil.saveVoiceType(1);
                    AppConfig.voideUrl1 = "http://yfsapi.7drlb.com/video/girl/music.mp3";
                    AppConfig.voideUrl2 = "http://yfsapi.7drlb.com/video/girl/music1.mp3";
                    AppConfig.voideUrl3 = "http://yfsapi.7drlb.com/video/girl/music2.mp3";
                }else{
                    sc_male.setText("男");
                    MainApp.theApp.sharedPreferencesUtil.saveVoiceType(0);
                    AppConfig.voideUrl1 = "http://yfsapi.7drlb.com/video/boy/music.mp3";
                    AppConfig.voideUrl2 = "http://yfsapi.7drlb.com/video/boy/music1.mp3";
                    AppConfig.voideUrl3 = "http://yfsapi.7drlb.com/video/boy/music2.mp3";
                }
                reset();
            }
        });
@@ -208,4 +239,31 @@
            return "1.0";
        }
    }
    private ArrayList<VoiceBean> voiceList = new ArrayList<>();
    private void reset() {
        voiceList.clear();
        VoiceBean voiceBean = new VoiceBean();
        voiceBean.setId(0);
        voiceBean.setRes(AppConfig.voideUrl1);
        voiceBean.setName("建议回避铃声");
        voiceBean.setVoiceName("默认");
        voiceList.add(voiceBean);
        voiceBean = new VoiceBean();
        voiceBean.setId(1);
        voiceBean.setRes(AppConfig.voideUrl2);
        voiceBean.setName("及时闪躲铃声");
        voiceBean.setVoiceName("默认");
        voiceList.add(voiceBean);
        voiceBean = new VoiceBean();
        voiceBean.setId(2);
        voiceBean.setRes(AppConfig.voideUrl3);
        voiceBean.setName("紧急撤离铃声");
        voiceBean.setVoiceName("默认");
        voiceList.add(voiceBean);
        MainApp.theApp.sharedPreferencesUtil.saveVideoList(FastJsonTools.toJson(voiceList));
        EventMessage eventMessage = new EventMessage();
        eventMessage.setType(AppConfig.SET_VOICE);
        EventBus.getDefault().post(eventMessage);
    }
}