Browse Source

优化部分代码

Pq 1 year ago
parent
commit
620f5c0772

+ 7 - 6
musicMerge/src/main/java/com/cooleshow/musicmerge/ui/MusicHandleSettingFragment.java

@@ -17,6 +17,7 @@ import com.cooleshow.base.ui.fragment.BaseFragment;
 import com.cooleshow.base.utils.FileUtils;
 import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
+import com.cooleshow.base.utils.ThreadUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.helper.GlideEngine;
 import com.cooleshow.base.widgets.DialogUtil;
@@ -131,7 +132,7 @@ public class MusicHandleSettingFragment extends BaseFragment<FgMusicHandleSettin
 
             @Override
             public void onStopTrackingTouch(SeekBar seekBar) {
-                mViewBinding.tvRecordVolumeValue.postDelayed(mRunnable, 200);
+                ThreadUtils.runOnUiThreadDelayed(mRunnable, 200);
             }
         });
 
@@ -162,7 +163,7 @@ public class MusicHandleSettingFragment extends BaseFragment<FgMusicHandleSettin
 
             @Override
             public void onStopTrackingTouch(SeekBar seekBar) {
-                mViewBinding.tvAccompanyVolumeValue.postDelayed(mRunnable2, 200);
+                ThreadUtils.runOnUiThreadDelayed(mRunnable2, 200);
             }
         });
         mViewBinding.seekBarOffset.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@@ -484,13 +485,13 @@ public class MusicHandleSettingFragment extends BaseFragment<FgMusicHandleSettin
 
     @Override
     public void onDestroy() {
-        removeCallBack(mViewBinding.tvRecordVolumeValue, mRunnable);
-        removeCallBack(mViewBinding.tvAccompanyVolumeValue, mRunnable2);
+        removeCallBack(mRunnable);
+        removeCallBack(mRunnable2);
         super.onDestroy();
     }
 
-    private void removeCallBack(View view, Runnable runnable) {
-        Handler handler = view.getHandler();
+    private void removeCallBack(Runnable runnable) {
+        Handler handler = ThreadUtils.getMainHandler();
         if (handler != null) {
             handler.removeCallbacks(runnable);
         }