From 50aacfed3ceb60997c2c9a4cc0f9e6fe6b5ed718 Mon Sep 17 00:00:00 2001
From: 陈奇 <1650699704@qq.com>
Date: Mon, 26 Nov 2018 15:17:11 +0800
Subject: [PATCH] [*]修改主页指针跳转动画

---
 app/src/main/java/com/moral/yunfushao/activity/VoiceSetActivity.java |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/app/src/main/java/com/moral/yunfushao/activity/VoiceSetActivity.java b/app/src/main/java/com/moral/yunfushao/activity/VoiceSetActivity.java
index 3e22b48..9a8bd29 100644
--- a/app/src/main/java/com/moral/yunfushao/activity/VoiceSetActivity.java
+++ b/app/src/main/java/com/moral/yunfushao/activity/VoiceSetActivity.java
@@ -20,11 +20,14 @@
 import com.moral.yunfushao.R;
 import com.moral.yunfushao.adapter.VoiceAdapter;
 import com.moral.yunfushao.base.BaseListActivity;
-import com.moral.yunfushao.ble.BLECommon;
 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 org.greenrobot.eventbus.EventBus;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -40,10 +43,9 @@
     private ArrayList<VoiceBean> voiceList = new ArrayList<>();
     AssetManager am;
     MediaPlayer mp;
-    public static String voideUrl1 = "http://yfsapi.7drlb.com/video/music.mp3";
-    public static String voideUrl2 = "http://yfsapi.7drlb.com/video/music1.mp3";
-    public static String voideUrl3 = "http://yfsapi.7drlb.com/video/music2.mp3";
+
     private MaterialDialog resetDialog;
+    private int oldType = 0;
 
     private void showReset() {
         resetDialog = MaterialDialogUtils.showCallBaclDialog(this, "������������", "���������������������������?", new MaterialDialog.SingleButtonCallback() {
@@ -99,6 +101,11 @@
                 MainApp.theApp.sharedPreferencesUtil.saveVideoList(FastJsonTools.toJson(voiceList));
                 adapter.notifyDataSetChanged();
                 mToatUtils.showSingleLongToast("������������������");
+                oldType = MainApp.theApp.sharedPreferencesUtil.getVoiceType();
+                MainApp.theApp.sharedPreferencesUtil.saveVoiceType(3);
+                EventMessage eventMessage = new EventMessage();
+                eventMessage.setType(AppConfig.SET_VOICE);
+                EventBus.getDefault().post(eventMessage);
             }
         }
     }
@@ -179,8 +186,10 @@
                 adapter.notifyDataSetChanged();
             }
             if (voiceBean.isDefaultMusic()) {
-                mp = MediaPlayer.create(this, Uri.parse(voiceBean.getRes()));
-                mp.start();
+                if (voiceBean.getRes() != null) {
+                    mp = MediaPlayer.create(this, Uri.parse(voiceBean.getRes()));
+                    mp.start();
+                }
             } else {
                 mp = new MediaPlayer();
                 try {
@@ -247,24 +256,28 @@
         voiceList.clear();
         VoiceBean voiceBean = new VoiceBean();
         voiceBean.setId(0);
-        voiceBean.setRes(VoiceSetActivity.voideUrl1);
-        voiceBean.setName("������������");
+        voiceBean.setRes(AppConfig.voideUrl1);
+        voiceBean.setName("������������������");
         voiceBean.setVoiceName("������");
         voiceList.add(voiceBean);
         voiceBean = new VoiceBean();
         voiceBean.setId(1);
-        voiceBean.setRes(VoiceSetActivity.voideUrl2);
-        voiceBean.setName("������������");
+        voiceBean.setRes(AppConfig.voideUrl2);
+        voiceBean.setName("������������������");
         voiceBean.setVoiceName("������");
         voiceList.add(voiceBean);
         voiceBean = new VoiceBean();
         voiceBean.setId(2);
-        voiceBean.setRes(VoiceSetActivity.voideUrl3);
-        voiceBean.setName("������������");
+        voiceBean.setRes(AppConfig.voideUrl3);
+        voiceBean.setName("������������������");
         voiceBean.setVoiceName("������");
         voiceList.add(voiceBean);
         MainApp.theApp.sharedPreferencesUtil.saveVideoList(FastJsonTools.toJson(voiceList));
+        MainApp.theApp.sharedPreferencesUtil.saveVoiceType(oldType);
         adapter.notifyDataSetChanged();
+        EventMessage eventMessage = new EventMessage();
+        eventMessage.setType(AppConfig.SET_VOICE);
+        EventBus.getDefault().post(eventMessage);
     }
 
     @Override

--
Gitblit v1.8.0