Browse Source

upgrade

master
chenbin 3 years ago
parent
commit
52a82c50ab

+ 2
- 0
app/src/main/java/com/tianrun/sipcall/SipEngine.java View File

249
      */
249
      */
250
     public void GoToInCall(Context context, String callnumber, String callstate, int calltype, int callid) {
250
     public void GoToInCall(Context context, String callnumber, String callstate, int calltype, int callid) {
251
         Intent intent = null;
251
         Intent intent = null;
252
+
253
+        logmy.e("GoToInCall==============" + isMeetingCall(callnumber) +"==="+ System.currentTimeMillis());
252
         if (isMeetingCall(callnumber)) {
254
         if (isMeetingCall(callnumber)) {
253
             intent = new Intent(context, InCallMeetingActivity.class);
255
             intent = new Intent(context, InCallMeetingActivity.class);
254
         } else {
256
         } else {

+ 4
- 1
app/src/main/java/com/tianrun/sipcall/call/CreateMeetingActivity.java View File

32
 import com.tianrun.sipcall.ui.TrBaseActivity;
32
 import com.tianrun.sipcall.ui.TrBaseActivity;
33
 import com.tianrun.sipcall.ui.UIUtl;
33
 import com.tianrun.sipcall.ui.UIUtl;
34
 import com.tianrun.sipcall.utils.HttpUtl;
34
 import com.tianrun.sipcall.utils.HttpUtl;
35
+import com.tianrun.sipcall.utils.logmy;
35
 
36
 
36
 import java.util.ArrayList;
37
 import java.util.ArrayList;
37
 import java.util.HashMap;
38
 import java.util.HashMap;
257
             UIUtl.toastI("请添加要加入会议的分机号");
258
             UIUtl.toastI("请添加要加入会议的分机号");
258
             return;
259
             return;
259
         }
260
         }
261
+
262
+        logmy.e("createMeeting==============" + System.currentTimeMillis());
260
         QMUITipDialog dialog = UIUtl.toastLoading("");
263
         QMUITipDialog dialog = UIUtl.toastLoading("");
261
         Net.createMeeting(meetingTopic.getText().toString(), meetingDesc.getText().toString(), userStr, new HttpUtl.CallBack() {
264
         Net.createMeeting(meetingTopic.getText().toString(), meetingDesc.getText().toString(), userStr, new HttpUtl.CallBack() {
262
             @Override
265
             @Override
271
 //                    }
274
 //                    }
272
 //                    SipEngine.getInstance().CallNumber(code, isVideo);
275
 //                    SipEngine.getInstance().CallNumber(code, isVideo);
273
 //                }
276
 //                }
274
-                UIUtl.toastS("临时会议创建成功");
277
+//                UIUtl.toastS("临时会议创建成功");
275
                 dialog.dismiss();
278
                 dialog.dismiss();
276
                 finish();
279
                 finish();
277
             }
280
             }

+ 22
- 14
app/src/main/java/com/tianrun/sipcall/call/InCallMeetingActivity.java View File

12
 import android.os.Message;
12
 import android.os.Message;
13
 import android.os.PowerManager;
13
 import android.os.PowerManager;
14
 import android.os.PowerManager.WakeLock;
14
 import android.os.PowerManager.WakeLock;
15
+import android.util.Log;
15
 import android.view.View;
16
 import android.view.View;
16
 import android.view.View.OnClickListener;
17
 import android.view.View.OnClickListener;
17
 import android.view.ViewGroup;
18
 import android.view.ViewGroup;
84
     private boolean VIDEOSTATE = false;
85
     private boolean VIDEOSTATE = false;
85
     public static Intent incallIntent;
86
     public static Intent incallIntent;
86
 
87
 
88
+    private  boolean isinited = false;
89
+
87
     TrAdapter adapterUser;
90
     TrAdapter adapterUser;
88
 
91
 
89
     List<DBUser> allUsers = new ArrayList<>();
92
     List<DBUser> allUsers = new ArrayList<>();
141
         KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");
144
         KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");
142
         kl.disableKeyguard();
145
         kl.disableKeyguard();
143
         initview();
146
         initview();
147
+
148
+        if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
149
+            imageButtonAddUser.setVisibility(View.VISIBLE);
150
+        } else {
151
+            imageButtonAddUser.setVisibility(View.INVISIBLE);
152
+        }
144
         incallIntent = getIntent();
153
         incallIntent = getIntent();
145
         setDate(this.getIntent());
154
         setDate(this.getIntent());
146
 
155
 
147
         allUsers.clear();
156
         allUsers.clear();
148
         setUsers();
157
         setUsers();
149
-        getMembers();
150
-        getMemberTimer();
151
         initTabAndPager();
158
         initTabAndPager();
152
         mTabSegment.setVisibility(View.INVISIBLE);
159
         mTabSegment.setVisibility(View.INVISIBLE);
160
+//        getMembers();
161
+        getMemberTimer();
153
     }
162
     }
154
 
163
 
155
     static void getMemberTimer() {
164
     static void getMemberTimer() {
156
         if(handler_CallActivity != null) {
165
         if(handler_CallActivity != null) {
157
-            CONS.SENDMESSAGETO(handler_CallActivity, -1, null);
158
             handler_CallActivity.postDelayed(getMemberRunner, 2000);
166
             handler_CallActivity.postDelayed(getMemberRunner, 2000);
159
         }
167
         }
160
     }
168
     }
161
     static Runnable getMemberRunner = new Runnable() {
169
     static Runnable getMemberRunner = new Runnable() {
162
         @Override
170
         @Override
163
         public void run() {
171
         public void run() {
172
+            CONS.SENDMESSAGETO(handler_CallActivity, -1, null);
164
             getMemberTimer();
173
             getMemberTimer();
165
         }
174
         }
166
     };
175
     };
167
 
176
 
168
     private void initview() {
177
     private void initview() {
178
+        if(isinited) return;
179
+        isinited = true;
169
         View view = findViewById(R.id.IncallMeetingRoot);
180
         View view = findViewById(R.id.IncallMeetingRoot);
170
         gridUser = view.findViewById(R.id.GridUser);
181
         gridUser = view.findViewById(R.id.GridUser);
171
         show = (TextView) findViewById(R.id.show);
182
         show = (TextView) findViewById(R.id.show);
178
         remoteRender = (SMSurfaceViewRenderer) findViewById(R.id.remote_video_view);
189
         remoteRender = (SMSurfaceViewRenderer) findViewById(R.id.remote_video_view);
179
         localRenderLayout = (SMPercentFrameLayout) findViewById(R.id.local_video_layout);
190
         localRenderLayout = (SMPercentFrameLayout) findViewById(R.id.local_video_layout);
180
         remoteRenderLayout = (SMPercentFrameLayout) findViewById(R.id.remote_video_layout);
191
         remoteRenderLayout = (SMPercentFrameLayout) findViewById(R.id.remote_video_layout);
192
+        logmy.e("new EngineServer============================" + System.currentTimeMillis());
181
         engineServer = new EngineServer(localRender, remoteRender, localRenderLayout, remoteRenderLayout, true);
193
         engineServer = new EngineServer(localRender, remoteRender, localRenderLayout, remoteRenderLayout, true);
182
 
194
 
183
         incall_mute = findViewById(R.id.incall_mute);
195
         incall_mute = findViewById(R.id.incall_mute);
190
         mTabSegment = findViewById(R.id.ScreenType);
202
         mTabSegment = findViewById(R.id.ScreenType);
191
         mContentViewPager = findViewById(R.id.contentViewPager);
203
         mContentViewPager = findViewById(R.id.contentViewPager);
192
         imageButtonAddUser = findViewById(R.id.imageButtonAddUser);
204
         imageButtonAddUser = findViewById(R.id.imageButtonAddUser);
193
-        if (DBUser.mySelf.isManager) {
194
-            imageButtonAddUser.setVisibility(View.VISIBLE);
195
-        } else {
196
-            imageButtonAddUser.setVisibility(View.INVISIBLE);
197
-        }
198
     }
205
     }
199
 
206
 
200
     private void initTabAndPager() {
207
     private void initTabAndPager() {
315
 
322
 
316
                 @Override
323
                 @Override
317
                 public void clickCallback(Object data, AdapterView<?> parent, View view, int position, long id) {
324
                 public void clickCallback(Object data, AdapterView<?> parent, View view, int position, long id) {
318
-                    if (!DBUser.mySelf.isManager) {
325
+                    if (DBUser.mySelf == null || !DBUser.mySelf.isManager) {
319
                         return;
326
                         return;
320
                     }
327
                     }
321
                     DBUser d = (DBUser) data;
328
                     DBUser d = (DBUser) data;
329
                             .dimAmount(0.5f)
336
                             .dimAmount(0.5f)
330
                             .skinManager(QMUISkinManager.defaultInstance(InCallMeetingActivity.this))
337
                             .skinManager(QMUISkinManager.defaultInstance(InCallMeetingActivity.this))
331
                             .edgeProtection(QMUIDisplayHelper.dp2px(InCallMeetingActivity.this, 20));
338
                             .edgeProtection(QMUIDisplayHelper.dp2px(InCallMeetingActivity.this, 20));
332
-                    if (DBUser.mySelf.isManager) {
339
+                    if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
333
                         if(d.isBusy()) {
340
                         if(d.isBusy()) {
334
                             if (d.isMute) {
341
                             if (d.isMute) {
335
                                 qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unmute).text("取消禁言").onClick(
342
                                 qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unmute).text("取消禁言").onClick(
506
             incall_muteVideo.setVisibility(View.GONE);
513
             incall_muteVideo.setVisibility(View.GONE);
507
         } else {
514
         } else {
508
             incall_answer.setVisibility(View.GONE);
515
             incall_answer.setVisibility(View.GONE);
509
-            if (DBUser.mySelf.isManager) {
516
+            if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
510
                 incall_mute.setVisibility(View.VISIBLE);
517
                 incall_mute.setVisibility(View.VISIBLE);
511
                 if (VIDEOSTATE) {
518
                 if (VIDEOSTATE) {
512
                     incall_muteVideo.setVisibility(View.VISIBLE);
519
                     incall_muteVideo.setVisibility(View.VISIBLE);
562
      */
569
      */
563
     public synchronized void stopVideoStream(boolean isExit) {
570
     public synchronized void stopVideoStream(boolean isExit) {
564
         if (VIDEOSTATE && engineServer != null) {
571
         if (VIDEOSTATE && engineServer != null) {
572
+            logmy.e("stopVideoStream============================" + System.currentTimeMillis());
565
             engineServer.stopVideoStream(isExit);
573
             engineServer.stopVideoStream(isExit);
566
             VIDEOSTATE = false;
574
             VIDEOSTATE = false;
567
         }
575
         }
631
                 break;
639
                 break;
632
         }
640
         }
633
         c = 0;
641
         c = 0;
634
-        logmy.e("startVideoStream=============="+ callnumber + "--" + server + "--" + rport + "--" + lport);
642
+        logmy.e("startVideoStream=============="+ callnumber + "--" + server + "--" + rport + "--" + lport +"====" + System.currentTimeMillis());
635
         if (engineServer != null) {
643
         if (engineServer != null) {
636
             ShowVideoView(true);
644
             ShowVideoView(true);
637
             /*
645
             /*
654
             engineServer.startVideoStream(this, server, rport, lport, payload, BitRate, FrameRate, w, h, c, true);
662
             engineServer.startVideoStream(this, server, rport, lport, payload, BitRate, FrameRate, w, h, c, true);
655
             VIDEOSTATE = true;
663
             VIDEOSTATE = true;
656
 
664
 
657
-            if (DBUser.mySelf.isManager) {
665
+            if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
658
                 incall_mute.setVisibility(View.VISIBLE);
666
                 incall_mute.setVisibility(View.VISIBLE);
659
                 incall_muteVideo.setVisibility(View.VISIBLE);
667
                 incall_muteVideo.setVisibility(View.VISIBLE);
660
             }
668
             }
673
                 break;
681
                 break;
674
             case R.id.incall_answer:
682
             case R.id.incall_answer:
675
                 incall_answer.setVisibility(View.GONE);
683
                 incall_answer.setVisibility(View.GONE);
676
-                if (DBUser.mySelf.isManager) {
684
+                if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
677
                     incall_mute.setVisibility(View.VISIBLE);
685
                     incall_mute.setVisibility(View.VISIBLE);
678
                 }
686
                 }
679
                 SipEngine.getInstance().answer(callid);
687
                 SipEngine.getInstance().answer(callid);

+ 1
- 0
app/src/main/java/com/tianrun/sipcall/db/DBUser.java View File

35
         this.name = d.getString("name");
35
         this.name = d.getString("name");
36
         this.phone = d.getString("extn");
36
         this.phone = d.getString("extn");
37
         this.status = d.getString("sip_state");
37
         this.status = d.getString("sip_state");
38
+        status = status == null ? "" : status;
38
         String weight = d.getString("weight");
39
         String weight = d.getString("weight");
39
         if (weight != null) {
40
         if (weight != null) {
40
             this.isManager = weight.equals("1") ? true : false;
41
             this.isManager = weight.equals("1") ? true : false;

+ 11
- 1
app/src/main/java/com/tianrun/sipcall/login/LoginActivity.java View File

108
     @Override
108
     @Override
109
     protected void onResume() {
109
     protected void onResume() {
110
         super.onResume();
110
         super.onResume();
111
+        if(dialogLoading != null) {
112
+            dialogLoading.dismiss();
113
+            dialogLoading = null;
114
+        }
111
         if (InCallActivity.handler_CallActivity != null) {
115
         if (InCallActivity.handler_CallActivity != null) {
112
             startActivity(InCallActivity.incallIntent);
116
             startActivity(InCallActivity.incallIntent);
113
             return;
117
             return;
206
 
210
 
207
     @Override
211
     @Override
208
     protected void onDestroy() {
212
     protected void onDestroy() {
213
+        if(dialogLoading != null) {
214
+            dialogLoading.dismiss();
215
+            dialogLoading = null;
216
+        }
209
         super.onDestroy();
217
         super.onDestroy();
210
     }
218
     }
211
 
219
 
219
             case CONS.LOGINFAILED:
227
             case CONS.LOGINFAILED:
220
                 if(dialogLoading != null) {
228
                 if(dialogLoading != null) {
221
                     dialogLoading.dismiss();
229
                     dialogLoading.dismiss();
230
+                    dialogLoading = null;
222
                 }
231
                 }
223
                 break;
232
                 break;
224
             case CONS.LOGIN:
233
             case CONS.LOGIN:
225
                 if(dialogLoading != null) {
234
                 if(dialogLoading != null) {
226
                     dialogLoading.dismiss();
235
                     dialogLoading.dismiss();
236
+                    dialogLoading = null;
227
                 }
237
                 }
228
                 if (isEnable()) {
238
                 if (isEnable()) {
229
                     saveUserInfor(this.name, this.pw, this.ip, this.port);
239
                     saveUserInfor(this.name, this.pw, this.ip, this.port);
230
                 }
240
                 }
231
-                startActivity(new Intent(this, MainActivity.class));
232
                 DBUser.mySelf = new DBUser("", this.name, "true");
241
                 DBUser.mySelf = new DBUser("", this.name, "true");
242
+                startActivity(new Intent(this, MainActivity.class));
233
                 finish();
243
                 finish();
234
                 break;
244
                 break;
235
         }
245
         }

+ 7
- 6
app/src/main/java/com/tianrun/sipcall/login/MainActivity.java View File

171
 
171
 
172
     // 处理当前分机号可能有需要加入的会议
172
     // 处理当前分机号可能有需要加入的会议
173
     private void checkBeforeMeetingState() {
173
     private void checkBeforeMeetingState() {
174
+        if(DBUser.mySelf == null) return;
174
         Net.getUserInfor(DBUser.mySelf.phone, new HttpUtl.CallBack() {
175
         Net.getUserInfor(DBUser.mySelf.phone, new HttpUtl.CallBack() {
175
             @Override
176
             @Override
176
             public void onRequestComplete(int cmd, String result, Object orgs) {
177
             public void onRequestComplete(int cmd, String result, Object orgs) {
242
                 } else {
243
                 } else {
243
                     StartMeetingVoice.setVisibility(View.VISIBLE);
244
                     StartMeetingVoice.setVisibility(View.VISIBLE);
244
                     StartMeetingVideo.setVisibility(View.VISIBLE);
245
                     StartMeetingVideo.setVisibility(View.VISIBLE);
245
-                    if (DBUser.mySelf.isManager) {
246
+                    if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
246
                         ButtonDelGroup.setVisibility(View.VISIBLE);
247
                         ButtonDelGroup.setVisibility(View.VISIBLE);
247
                     } else {
248
                     } else {
248
                         ButtonDelGroup.setVisibility(View.INVISIBLE);
249
                         ButtonDelGroup.setVisibility(View.INVISIBLE);
261
                         allUsers.addAll(group.users);
262
                         allUsers.addAll(group.users);
262
                     }
263
                     }
263
                     //根据权限来处理
264
                     //根据权限来处理
264
-                    if (DBUser.mySelf.isManager) {
265
+                    if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
265
                         DBUser u = new DBUser("", "添加分机", "false");
266
                         DBUser u = new DBUser("", "添加分机", "false");
266
                         u.isAddFlag = true;
267
                         u.isAddFlag = true;
267
                         allUsers.add(u);
268
                         allUsers.add(u);
303
             imageViewAddGroupIcon.setVisibility(View.INVISIBLE);
304
             imageViewAddGroupIcon.setVisibility(View.INVISIBLE);
304
         }
305
         }
305
 
306
 
306
-        if (DBUser.mySelf.isBusy()) {
307
+        if (DBUser.mySelf != null && DBUser.mySelf.isBusy()) {
307
             imageViewSelfStatus.setColorFilter(Color.RED);
308
             imageViewSelfStatus.setColorFilter(Color.RED);
308
             textViewSelfStatus.setText("通话中");
309
             textViewSelfStatus.setText("通话中");
309
-        } else if (DBUser.mySelf.isOnline()) {
310
+        } else if (DBUser.mySelf != null && DBUser.mySelf.isOnline()) {
310
             imageViewSelfStatus.setColorFilter(Color.GREEN);
311
             imageViewSelfStatus.setColorFilter(Color.GREEN);
311
             textViewSelfStatus.setText("在线");
312
             textViewSelfStatus.setText("在线");
312
         } else {
313
         } else {
425
                                         }
426
                                         }
426
                                     }
427
                                     }
427
                             ));
428
                             ));
428
-                    if (DBUser.mySelf.isManager && currSelectData != null && (!currSelectData.isAll())) {
429
+                    if (DBUser.mySelf != null && DBUser.mySelf.isManager && currSelectData != null && (!currSelectData.isAll())) {
429
                         qa.addAction(new QMUIQuickAction.Action().icon(android.R.drawable.ic_delete).text("移除").onClick(
430
                         qa.addAction(new QMUIQuickAction.Action().icon(android.R.drawable.ic_delete).text("移除").onClick(
430
                                 new QMUIQuickAction.OnClickListener() {
431
                                 new QMUIQuickAction.OnClickListener() {
431
                                     @Override
432
                                     @Override
582
                     allUsers.clear();
583
                     allUsers.clear();
583
                     allUsers.addAll(group.users);
584
                     allUsers.addAll(group.users);
584
                     //根据权限来处理
585
                     //根据权限来处理
585
-                    if (DBUser.mySelf.isManager) {
586
+                    if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
586
                         DBUser u = new DBUser("", "添加分机", "false");
587
                         DBUser u = new DBUser("", "添加分机", "false");
587
                         u.isAddFlag = true;
588
                         u.isAddFlag = true;
588
                         allUsers.add(u);
589
                         allUsers.add(u);

+ 13
- 9
app/src/main/java/com/tianrun/sipcall/net/Net.java View File

42
             Object[] _params = (Object[]) params;
42
             Object[] _params = (Object[]) params;
43
             HttpUtl.CallBack callback = (HttpUtl.CallBack) (_params[0]);
43
             HttpUtl.CallBack callback = (HttpUtl.CallBack) (_params[0]);
44
             Object orgs = _params[1];
44
             Object orgs = _params[1];
45
-            if (ActivityMgr.topActivity != null && callback != null) {
46
-                ActivityMgr.topActivity.handler.post(new Runnable() {
47
-                    @Override
48
-                    public void run() {
49
-                        if (callback != null) {
50
-                            callback.onRequestComplete(cmd, result, orgs);
45
+            try {
46
+                if (ActivityMgr.topActivity != null && callback != null) {
47
+                    ActivityMgr.topActivity.handler.post(new Runnable() {
48
+                        @Override
49
+                        public void run() {
50
+                            if (callback != null) {
51
+                                callback.onRequestComplete(cmd, result, orgs);
52
+                            }
51
                         }
53
                         }
52
-                    }
53
-                });
54
+                    });
55
+                }
56
+                ActivityMgr.sendMsg(cmd, new NetPkg(result, orgs));
57
+            } catch (Exception e) {
58
+                Log.e(TAG, e.getMessage());
54
             }
59
             }
55
 
60
 
56
-            ActivityMgr.sendMsg(cmd, new NetPkg(result, orgs));
57
         }
61
         }
58
 
62
 
59
         @Override
63
         @Override

+ 4
- 1
app/src/main/java/com/tianrun/sipcall/ui/ActivityMgr.java View File

24
     }
24
     }
25
 
25
 
26
     public static void onHideActivity(TrBaseActivity a) {
26
     public static void onHideActivity(TrBaseActivity a) {
27
+        UIUtl.onHideActivity(a);
27
         actives.remove(a.getClass());
28
         actives.remove(a.getClass());
28
         if (a == topActivity) {
29
         if (a == topActivity) {
29
             topActivity = null;
30
             topActivity = null;
32
 
33
 
33
     public static void sendMsg(int menu, Object obj) {
34
     public static void sendMsg(int menu, Object obj) {
34
         for (TrBaseActivity a : actives.values()) {
35
         for (TrBaseActivity a : actives.values()) {
35
-            CONS.SENDMESSAGETO(a.handler, menu, obj);
36
+            if(a != null && a.handler != null) {
37
+                CONS.SENDMESSAGETO(a.handler, menu, obj);
38
+            }
36
         }
39
         }
37
     }
40
     }
38
 
41
 

+ 49
- 7
app/src/main/java/com/tianrun/sipcall/ui/UIUtl.java View File

11
 import androidx.core.content.ContextCompat;
11
 import androidx.core.content.ContextCompat;
12
 
12
 
13
 import com.qmuiteam.qmui.skin.QMUISkinManager;
13
 import com.qmuiteam.qmui.skin.QMUISkinManager;
14
+import com.qmuiteam.qmui.widget.dialog.QMUIBaseDialog;
14
 import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
15
 import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
15
 import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
16
 import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
16
 import com.tianrun.sipcall.App;
17
 import com.tianrun.sipcall.App;
18
 import com.tianrun.sipcall.login.LoginActivity;
19
 import com.tianrun.sipcall.login.LoginActivity;
19
 import com.tianrun.sipcall.utils.HttpUtl;
20
 import com.tianrun.sipcall.utils.HttpUtl;
20
 
21
 
22
+import java.util.ArrayList;
21
 import java.util.List;
23
 import java.util.List;
24
+import java.util.Map;
25
+import java.util.concurrent.ConcurrentHashMap;
22
 
26
 
23
 public class UIUtl {
27
 public class UIUtl {
28
+    public static Map<Class, ArrayList<QMUIBaseDialog>> activesWithDialogs = new ConcurrentHashMap<>();
29
+
30
+    private  static  void  onShowDialog(TrBaseActivity activity, QMUIBaseDialog dialog){
31
+        try {
32
+            ArrayList<QMUIBaseDialog> list = activesWithDialogs.get(activity.getClass());
33
+            if (list == null) {
34
+                list = new ArrayList<QMUIBaseDialog>();
35
+            }
36
+            list.add(dialog);
37
+            activesWithDialogs.put(activity.getClass(), list);
38
+        } catch (Exception e){
39
+            System.out.println(e);
40
+        }
41
+    }
42
+
43
+    public static void onHideActivity(TrBaseActivity activity){
44
+        try {
45
+            if(activity == null) return;
46
+            ArrayList<QMUIBaseDialog> list = activesWithDialogs.get(activity.getClass());
47
+            if(list != null) {
48
+                for (int i = 0; i < list.size(); i++) {
49
+                    QMUIBaseDialog dialog =list.get(i);
50
+                    if(dialog != null) {
51
+                        dialog.dismiss();
52
+                    }
53
+                }
54
+                list.clear();
55
+            }
56
+            activesWithDialogs.remove(activity.getClass());
57
+        } catch (Exception e){
58
+            System.out.println(e);
59
+        }
60
+    }
61
+
24
     public static void toast(String tip) {
62
     public static void toast(String tip) {
25
         if (ActivityMgr.topActivity == null) return;
63
         if (ActivityMgr.topActivity == null) return;
26
         try {
64
         try {
32
                             .setTipWord(tip)
70
                             .setTipWord(tip)
33
                             .create();
71
                             .create();
34
                     tipDialog.show();
72
                     tipDialog.show();
35
-                    hideToast(tipDialog);
73
+                    hideToast(ActivityMgr.topActivity, tipDialog);
36
                 }
74
                 }
37
             });
75
             });
38
         } catch (Exception e) {
76
         } catch (Exception e) {
51
                             .setTipWord(tip)
89
                             .setTipWord(tip)
52
                             .create();
90
                             .create();
53
                     tipDialog.show();
91
                     tipDialog.show();
54
-                    hideToast(tipDialog);
92
+                    hideToast(ActivityMgr.topActivity, tipDialog);
55
                 }
93
                 }
56
             });
94
             });
57
         } catch (Exception e) {
95
         } catch (Exception e) {
70
                             .setTipWord(tip)
108
                             .setTipWord(tip)
71
                             .create();
109
                             .create();
72
                     tipDialog.show();
110
                     tipDialog.show();
73
-                    hideToast(tipDialog);
111
+                    hideToast(ActivityMgr.topActivity, tipDialog);
74
                 }
112
                 }
75
             });
113
             });
76
         } catch (Exception e) {
114
         } catch (Exception e) {
89
                             .setTipWord(tip)
127
                             .setTipWord(tip)
90
                             .create();
128
                             .create();
91
                     tipDialog.show();
129
                     tipDialog.show();
92
-                    hideToast(tipDialog);
130
+                    hideToast(ActivityMgr.topActivity, tipDialog);
93
                 }
131
                 }
94
             });
132
             });
95
         } catch (Exception e) {
133
         } catch (Exception e) {
108
         return tipDialog;
146
         return tipDialog;
109
     }
147
     }
110
 
148
 
111
-    private static void hideToast(QMUITipDialog tipDialog) {
112
-        if (ActivityMgr.topActivity == null) return;
113
-        ActivityMgr.topActivity.handler.postDelayed(new Runnable() {
149
+    private static void hideToast(TrBaseActivity activity, QMUITipDialog tipDialog) {
150
+        if (activity == null) return;
151
+        activity.handler.postDelayed(new Runnable() {
114
             @Override
152
             @Override
115
             public void run() {
153
             public void run() {
116
                 try {
154
                 try {
155
+                    ArrayList<QMUIBaseDialog> list = activesWithDialogs.get(activity.getClass());
156
+                    if(list != null && list.contains(tipDialog)) {
157
+                        list.remove(tipDialog);
158
+                    }
117
                     tipDialog.dismiss();
159
                     tipDialog.dismiss();
118
                 } catch (Exception e) {
160
                 } catch (Exception e) {
119
                     System.out.println(e);
161
                     System.out.println(e);

+ 1
- 4
app/src/main/java/com/tianrun/sipcall/utils/HttpUtl.java View File

68
                 }
68
                 }
69
 
69
 
70
             }
70
             }
71
-
72
-            ;
73
         }.start();
71
         }.start();
74
     }
72
     }
75
 
73
 
96
                     }
94
                     }
97
                 }
95
                 }
98
             }
96
             }
99
-
100
-            ;
101
         }.start();
97
         }.start();
102
 
98
 
103
     }
99
     }
161
                 return "";
157
                 return "";
162
             } else {
158
             } else {
163
                 UIUtl.toastI("内部错误");
159
                 UIUtl.toastI("内部错误");
160
+                Log.e("http", urlStr);
164
                 throw new RuntimeException(" responseCode :" + retCode);
161
                 throw new RuntimeException(" responseCode :" + retCode);
165
             }
162
             }
166
 
163
 

Loading…
Cancel
Save