|  | @@ -17,6 +17,7 @@ import android.media.SoundPool;
 | 
	
		
			
				|  |  |  import android.os.Build;
 | 
	
		
			
				|  |  |  import android.os.Bundle;
 | 
	
		
			
				|  |  |  import android.os.Handler;
 | 
	
		
			
				|  |  | +import android.os.Looper;
 | 
	
		
			
				|  |  |  import android.os.Message;
 | 
	
		
			
				|  |  |  import android.os.SystemClock;
 | 
	
		
			
				|  |  |  import android.text.TextUtils;
 | 
	
	
		
			
				|  | @@ -131,6 +132,10 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
	
		
			
				|  |  |      private static final int SDK_PAY_FLAG = 1;
 | 
	
		
			
				|  |  |      private static final int SDK_AUTH_FLAG = 2;
 | 
	
		
			
				|  |  |      public static final int SHARE_CHAT_REQUEST_CODE = 501;
 | 
	
		
			
				|  |  | +    public static final int MESSAGE_TYPE_UPDATE_LOADING_START = 5010;//开始更新加载loading
 | 
	
		
			
				|  |  | +    public static final int MESSAGE_TYPE_UPDATE_LOADING = 5011;//更新加载loading
 | 
	
		
			
				|  |  | +    public static final int MESSAGE_TYPE_UPDATE_LOADING_COMPLETE = 5012;//完成加载loading
 | 
	
		
			
				|  |  | +    public static final int MESSAGE_TYPE_HIDE_LOADING = 5013;//隐藏加载loading
 | 
	
		
			
				|  |  |      FrameLayout viewParent;
 | 
	
		
			
				|  |  |      WebView webView;
 | 
	
		
			
				|  |  |      private UMShareListener mShareListener;
 | 
	
	
		
			
				|  | @@ -141,6 +146,41 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
	
		
			
				|  |  |      private URI webSocketUri = URI.create("BuildConfig.BASE_STU_SOCKET_URL");
 | 
	
		
			
				|  |  |      private String mImageBase64;
 | 
	
		
			
				|  |  |      private MusicTunerHelper mMusicTunerHelper;
 | 
	
		
			
				|  |  | +    private int currentProgressCount = 0;
 | 
	
		
			
				|  |  | +    private Handler mLoadHandler = new Handler(Looper.getMainLooper()) {
 | 
	
		
			
				|  |  | +        @Override
 | 
	
		
			
				|  |  | +        public void handleMessage(@androidx.annotation.NonNull Message msg) {
 | 
	
		
			
				|  |  | +            if (msg.what == MESSAGE_TYPE_UPDATE_LOADING) {
 | 
	
		
			
				|  |  | +                currentProgressCount++;
 | 
	
		
			
				|  |  | +                if (currentProgressCount <= 10) {
 | 
	
		
			
				|  |  | +                    updateProgress(4);
 | 
	
		
			
				|  |  | +                } else if (currentProgressCount <= 30) {
 | 
	
		
			
				|  |  | +                    updateProgress(2);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    updateProgress(1);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                sendProgressMessage(MESSAGE_TYPE_UPDATE_LOADING, 1000);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (msg.what == MESSAGE_TYPE_UPDATE_LOADING_START) {
 | 
	
		
			
				|  |  | +                showLoadingAnim();
 | 
	
		
			
				|  |  | +                sendProgressMessage(MESSAGE_TYPE_UPDATE_LOADING, 1000);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (msg.what == MESSAGE_TYPE_UPDATE_LOADING_COMPLETE) {
 | 
	
		
			
				|  |  | +                mViewBinding.progress.setProgress(100);
 | 
	
		
			
				|  |  | +                sendProgressMessage(MESSAGE_TYPE_HIDE_LOADING, 300);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (msg.what == MESSAGE_TYPE_HIDE_LOADING) {
 | 
	
		
			
				|  |  | +                hideLoadingAnim();
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static AccompanyFragment newInstance(String url) {
 | 
	
		
			
				|  |  |          AccompanyFragment fragment = new AccompanyFragment();
 | 
	
	
		
			
				|  | @@ -265,6 +305,15 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void updateProgress(int progress) {
 | 
	
		
			
				|  |  | +        int currentProgress = mViewBinding.progress.getProgress();
 | 
	
		
			
				|  |  | +        int totalProgress = currentProgress + progress;
 | 
	
		
			
				|  |  | +        if (totalProgress > 99) {
 | 
	
		
			
				|  |  | +            totalProgress = 99;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        mViewBinding.progress.setProgress(totalProgress);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void onSendMessage(String message) {
 | 
	
		
			
				|  |  |          Log.i("accom", "message:" + message);
 | 
	
	
		
			
				|  | @@ -377,32 +426,38 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              JSONObject content = jsonObject.getJSONObject("content");
 | 
	
		
			
				|  |  |              boolean show = content.optBoolean("show", false);
 | 
	
		
			
				|  |  | -            if (getActivity() != null) {
 | 
	
		
			
				|  |  | -                getActivity().runOnUiThread(new Runnable() {
 | 
	
		
			
				|  |  | -                    @Override
 | 
	
		
			
				|  |  | -                    public void run() {
 | 
	
		
			
				|  |  | -                        if (show) {
 | 
	
		
			
				|  |  | -                            showLoadingAnim();
 | 
	
		
			
				|  |  | -                        } else {
 | 
	
		
			
				|  |  | -                            hideLoadingAnim();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (mLoadHandler != null) {
 | 
	
		
			
				|  |  | +                mLoadHandler.removeCallbacksAndMessages(null);
 | 
	
		
			
				|  |  | +                if (show) {
 | 
	
		
			
				|  |  | +                    sendProgressMessage(MESSAGE_TYPE_UPDATE_LOADING_START, 0);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    sendProgressMessage(MESSAGE_TYPE_UPDATE_LOADING_COMPLETE, 0);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              onSendMessage(jsonObject.toString());
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  | -            hideLoadingAnim();
 | 
	
		
			
				|  |  | +            sendProgressMessage(MESSAGE_TYPE_HIDE_LOADING,0);
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void showLoadingAnim() {
 | 
	
		
			
				|  |  | +        currentProgressCount = 0;
 | 
	
		
			
				|  |  |          mViewBinding.ivLoadingBack.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  |          mViewBinding.llLoading.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  |          mViewBinding.viewLoadingAnim.playAnimation();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void sendProgressMessage(int type, int delayedTime) {
 | 
	
		
			
				|  |  | +        Message message = Message.obtain();
 | 
	
		
			
				|  |  | +        message.what = type;
 | 
	
		
			
				|  |  | +        mLoadHandler.sendMessageDelayed(message, delayedTime);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void hideLoadingAnim() {
 | 
	
		
			
				|  |  | +        currentProgressCount = 0;
 | 
	
		
			
				|  |  |          mViewBinding.ivLoadingBack.setVisibility(View.GONE);
 | 
	
		
			
				|  |  |          mViewBinding.viewLoadingAnim.clearAnimation();
 | 
	
		
			
				|  |  |          mViewBinding.llLoading.setVisibility(View.GONE);
 | 
	
	
		
			
				|  | @@ -1312,6 +1367,15 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void onDestroy() {
 | 
	
		
			
				|  |  | +        if (mHandler != null) {
 | 
	
		
			
				|  |  | +            mHandler.removeCallbacksAndMessages(null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (loopHandler != null) {
 | 
	
		
			
				|  |  | +            loopHandler.removeCallbacksAndMessages(null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (mLoadHandler != null) {
 | 
	
		
			
				|  |  | +            mLoadHandler.removeCallbacksAndMessages(null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          super.onDestroy();
 | 
	
		
			
				|  |  |          if (null != webView) {
 | 
	
		
			
				|  |  |              webView.destroy();
 |