|
@@ -62,6 +62,7 @@ import com.cooleshow.base.widgets.CommonDialog;
|
|
|
import com.cooleshow.base.widgets.DialogUtil;
|
|
|
import com.cooleshow.base.widgets.ViewConvertListener;
|
|
|
import com.cooleshow.base.widgets.ViewHolder;
|
|
|
+import com.cooleshow.musictuner.utils.MusicTunerHelper;
|
|
|
import com.cooleshow.student.BuildConfig;
|
|
|
import com.cooleshow.student.api.APIService;
|
|
|
import com.cooleshow.student.bean.alipay.AuthResult;
|
|
@@ -137,6 +138,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
private ShareAction mShareAction;
|
|
|
private URI webSocketUri = URI.create("BuildConfig.BASE_STU_SOCKET_URL");
|
|
|
private String mImageBase64;
|
|
|
+ private MusicTunerHelper mMusicTunerHelper;
|
|
|
|
|
|
public static AccompanyFragment newInstance(String url) {
|
|
|
AccompanyFragment fragment = new AccompanyFragment();
|
|
@@ -263,6 +265,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
|
|
|
@Override
|
|
|
public void onSendMessage(String message) {
|
|
|
+ Log.i("accom", "message:" + message);
|
|
|
if (webView != null) {
|
|
|
webView.evaluateJavascript("postMessage('" + message + "')", new ValueCallback<String>() {
|
|
|
@Override
|
|
@@ -1320,7 +1323,9 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
MidiPlayerUtils.getInstance().stopPlay();
|
|
|
UMShareAPI.get(mContext).release();
|
|
|
-
|
|
|
+ if (mMusicTunerHelper != null) {
|
|
|
+ mMusicTunerHelper.release();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1945,6 +1950,38 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void cloudToggleFollow(String mode) {
|
|
|
+ new RxPermissions(this)
|
|
|
+ .request(Manifest.permission.RECORD_AUDIO)
|
|
|
+ .subscribe(permission -> {
|
|
|
+ if (permission) {
|
|
|
+ handleCloudFollow(mode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleCloudFollow(String mode) {
|
|
|
+ if (mMusicTunerHelper == null) {
|
|
|
+ mMusicTunerHelper = new MusicTunerHelper(new MusicTunerHelper.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onResult(float pitchInHz) {
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ sendCloudToggleFollowResult(pitchInHz);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (TextUtils.equals(mode, "start")) {
|
|
|
+ mMusicTunerHelper.start();
|
|
|
+ } else {
|
|
|
+ mMusicTunerHelper.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sendSavePicCallBack(String api, String result, String uuid) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
JSONObject contentJson = new JSONObject();
|
|
@@ -2265,6 +2302,18 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
ShareHelper.parseShareContactData(mImageBase64, data);
|
|
|
}
|
|
|
|
|
|
+ private void sendCloudToggleFollowResult(float result) {
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONObject contentJson = new JSONObject();
|
|
|
+ jsonObject.put("api", "cloudFollowTime");
|
|
|
+ contentJson.put("frequency", result);
|
|
|
+ jsonObject.put("content", contentJson);
|
|
|
+ onSendMessage(jsonObject.toString());
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 发送支付结果
|