From 82cc6c94fdc08b1814fbf7195e88cf335eed3e8d Mon Sep 17 00:00:00 2001 From: haijiang <181069201@qq.com> Date: Wed, 19 Sep 2018 14:00:15 +0800 Subject: [PATCH] 提交 --- app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 102 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java b/app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java index 9b14db3..585a957 100644 --- a/app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java +++ b/app/src/main/java/com/moral/yunfushao/fragment/FragmentSettings.java @@ -1,23 +1,35 @@ package com.moral.yunfushao.fragment; import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; 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; import com.moral.yunfushao.activity.LoginActivity; +import com.moral.yunfushao.activity.TestActivity; import com.moral.yunfushao.activity.VoiceSetActivity; import com.moral.yunfushao.base.BaseFragment; import com.moral.yunfushao.common.API; +import com.moral.yunfushao.common.AppConfig; 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; import java.util.ArrayList; import java.util.HashMap; @@ -29,9 +41,11 @@ */ public class FragmentSettings extends BaseFragment { + private TextView tv_version; private RelativeLayout rl_setvoice,rl_refresh; private Button bt_sure; - private SwitchCompat sc_open; + private Button bt_look; + private SwitchCompat sc_open,sc_male; private int refreshIndex=0; @Override protected int getLayoutId() { @@ -43,7 +57,21 @@ rl_setvoice = findView(R.id.rl_setvoice); rl_refresh = findView(R.id.rl_refresh); 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(View.GONE); + if (MainApp.theApp.sharedPreferencesUtil.getVoiceType() == 0) { + sc_male.setChecked(false); + sc_male.setText("���"); + }else{ + sc_male.setChecked(true); + sc_male.setText("���"); + } } @Override @@ -59,6 +87,33 @@ }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(); + } + }); + + bt_look.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), TestActivity.class); + startActivity(intent); } }); } @@ -145,7 +200,9 @@ }else if("is_open_upload".equals(field)){ MainApp.theApp.sharedPreferencesUtil.setUpload(Integer.parseInt(value)); } - + EventMessage event = new EventMessage(); + event.setType(AppConfig.CHANGE_SETTING); + EventBus.getDefault().post(event); if (progressDialog.isShowing()) { progressDialog.dismiss(); } @@ -166,4 +223,47 @@ } }); } + + /** + * ��������������� + * @return ������������������������ + */ + public String getVersion() { + try { + PackageManager manager = getActivity().getPackageManager(); + PackageInfo info = manager.getPackageInfo(getActivity().getPackageName(), 0); + String version = info.versionName; + return version; + } catch (Exception e) { + e.printStackTrace(); + 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); + } } -- Gitblit v1.8.0