chenbin преди 3 години
родител
ревизия
52a82c50ab

+ 2
- 0
app/src/main/java/com/tianrun/sipcall/SipEngine.java Целия файл

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

+ 4
- 1
app/src/main/java/com/tianrun/sipcall/call/CreateMeetingActivity.java Целия файл

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

+ 22
- 14
app/src/main/java/com/tianrun/sipcall/call/InCallMeetingActivity.java Целия файл

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

+ 1
- 0
app/src/main/java/com/tianrun/sipcall/db/DBUser.java Целия файл

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

+ 11
- 1
app/src/main/java/com/tianrun/sipcall/login/LoginActivity.java Целия файл

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

+ 7
- 6
app/src/main/java/com/tianrun/sipcall/login/MainActivity.java Целия файл

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

+ 13
- 9
app/src/main/java/com/tianrun/sipcall/net/Net.java Целия файл

@@ -42,18 +42,22 @@ public class Net {
42 42
             Object[] _params = (Object[]) params;
43 43
             HttpUtl.CallBack callback = (HttpUtl.CallBack) (_params[0]);
44 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 63
         @Override

+ 4
- 1
app/src/main/java/com/tianrun/sipcall/ui/ActivityMgr.java Целия файл

@@ -24,6 +24,7 @@ public class ActivityMgr {
24 24
     }
25 25
 
26 26
     public static void onHideActivity(TrBaseActivity a) {
27
+        UIUtl.onHideActivity(a);
27 28
         actives.remove(a.getClass());
28 29
         if (a == topActivity) {
29 30
             topActivity = null;
@@ -32,7 +33,9 @@ public class ActivityMgr {
32 33
 
33 34
     public static void sendMsg(int menu, Object obj) {
34 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 Целия файл

@@ -11,6 +11,7 @@ import android.widget.Toast;
11 11
 import androidx.core.content.ContextCompat;
12 12
 
13 13
 import com.qmuiteam.qmui.skin.QMUISkinManager;
14
+import com.qmuiteam.qmui.widget.dialog.QMUIBaseDialog;
14 15
 import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
15 16
 import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
16 17
 import com.tianrun.sipcall.App;
@@ -18,9 +19,46 @@ import com.tianrun.sipcall.SipEngine;
18 19
 import com.tianrun.sipcall.login.LoginActivity;
19 20
 import com.tianrun.sipcall.utils.HttpUtl;
20 21
 
22
+import java.util.ArrayList;
21 23
 import java.util.List;
24
+import java.util.Map;
25
+import java.util.concurrent.ConcurrentHashMap;
22 26
 
23 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 62
     public static void toast(String tip) {
25 63
         if (ActivityMgr.topActivity == null) return;
26 64
         try {
@@ -32,7 +70,7 @@ public class UIUtl {
32 70
                             .setTipWord(tip)
33 71
                             .create();
34 72
                     tipDialog.show();
35
-                    hideToast(tipDialog);
73
+                    hideToast(ActivityMgr.topActivity, tipDialog);
36 74
                 }
37 75
             });
38 76
         } catch (Exception e) {
@@ -51,7 +89,7 @@ public class UIUtl {
51 89
                             .setTipWord(tip)
52 90
                             .create();
53 91
                     tipDialog.show();
54
-                    hideToast(tipDialog);
92
+                    hideToast(ActivityMgr.topActivity, tipDialog);
55 93
                 }
56 94
             });
57 95
         } catch (Exception e) {
@@ -70,7 +108,7 @@ public class UIUtl {
70 108
                             .setTipWord(tip)
71 109
                             .create();
72 110
                     tipDialog.show();
73
-                    hideToast(tipDialog);
111
+                    hideToast(ActivityMgr.topActivity, tipDialog);
74 112
                 }
75 113
             });
76 114
         } catch (Exception e) {
@@ -89,7 +127,7 @@ public class UIUtl {
89 127
                             .setTipWord(tip)
90 128
                             .create();
91 129
                     tipDialog.show();
92
-                    hideToast(tipDialog);
130
+                    hideToast(ActivityMgr.topActivity, tipDialog);
93 131
                 }
94 132
             });
95 133
         } catch (Exception e) {
@@ -108,12 +146,16 @@ public class UIUtl {
108 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 152
             @Override
115 153
             public void run() {
116 154
                 try {
155
+                    ArrayList<QMUIBaseDialog> list = activesWithDialogs.get(activity.getClass());
156
+                    if(list != null && list.contains(tipDialog)) {
157
+                        list.remove(tipDialog);
158
+                    }
117 159
                     tipDialog.dismiss();
118 160
                 } catch (Exception e) {
119 161
                     System.out.println(e);

+ 1
- 4
app/src/main/java/com/tianrun/sipcall/utils/HttpUtl.java Целия файл

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

Loading…
Отказ
Запис