huangxinbao

fix whitebroad

正在显示 24 个修改的文件 包含 2158 行增加563 行删除
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 <ConfirmationsSetting value="0" id="Add" /> 37 <ConfirmationsSetting value="0" id="Add" />
38 <ConfirmationsSetting value="0" id="Remove" /> 38 <ConfirmationsSetting value="0" id="Remove" />
39 </component> 39 </component>
40 - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> 40 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
41 <output url="file://$PROJECT_DIR$/build/classes" /> 41 <output url="file://$PROJECT_DIR$/build/classes" />
42 </component> 42 </component>
43 <component name="ProjectType"> 43 <component name="ProjectType">
@@ -71,6 +71,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -71,6 +71,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
71 SurfaceView surfaceviewPlayVideo; 71 SurfaceView surfaceviewPlayVideo;
72 private String initClass = ""; 72 private String initClass = "";
73 private String publisherSuccess=""; 73 private String publisherSuccess="";
  74 + private XdySdk xdySdk;
74 private Handler handler = new Handler() { 75 private Handler handler = new Handler() {
75 @Override 76 @Override
76 public void handleMessage(Message msg) { 77 public void handleMessage(Message msg) {
@@ -82,7 +83,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -82,7 +83,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
82 break; 83 break;
83 case -1: 84 case -1:
84 //退出 85 //退出
85 - XdySdk.api("leaveClass", ""); 86 + xdySdk.api("leaveClass", "");
86 break; 87 break;
87 case 0: 88 case 0:
88 parseJoinClass((String) msg.obj,true); 89 parseJoinClass((String) msg.obj,true);
@@ -113,7 +114,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -113,7 +114,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
113 break; 114 break;
114 case 7: 115 case 7:
115 //停止播放 116 //停止播放
116 - XdySdk.onPlayStop(); 117 + xdySdk.onPlayStop();
117 // img_playVideo_novideo.setVisibility(View.GONE); 118 // img_playVideo_novideo.setVisibility(View.GONE);
118 // surfaceviewPlayVideo.refreshDrawableState();; 119 // surfaceviewPlayVideo.refreshDrawableState();;
119 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this); 120 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this);
@@ -133,11 +134,12 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -133,11 +134,12 @@ public class AudioPublisherActivity extends AppCompatActivity {
133 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮 134 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //屏幕常亮
134 setContentView(R.layout.activity_video_publisher); 135 setContentView(R.layout.activity_video_publisher);
135 ButterKnife.bind(this); 136 ButterKnife.bind(this);
  137 + xdySdk=XdySdk.getXdyInstance();
136 btnVideoPlayPubsherVideo.setVisibility(View.GONE); 138 btnVideoPlayPubsherVideo.setVisibility(View.GONE);
137 // setTablayout(); 139 // setTablayout();
138 init(); 140 init();
139 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+""); 141 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+"");
140 - XdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() { 142 + xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
141 @Override 143 @Override
142 public void onXdyAsyncMessageReceiver(String type, String response) { 144 public void onXdyAsyncMessageReceiver(String type, String response) {
143 145
@@ -176,7 +178,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -176,7 +178,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
176 178
177 public void init() { 179 public void init() {
178 initClass = getIntent().getStringExtra("init"); 180 initClass = getIntent().getStringExtra("init");
179 - XdySdk.api("init", initClass); 181 + xdySdk.api("init", initClass);
180 182
181 } 183 }
182 //判断解析是否有密码 184 //判断解析是否有密码
@@ -211,26 +213,26 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -211,26 +213,26 @@ public class AudioPublisherActivity extends AppCompatActivity {
211 String temp=new Gson().toJson(joinClass); 213 String temp=new Gson().toJson(joinClass);
212 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 214 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
213 XdyLogUtil.e("加入课堂", jsonParmp); 215 XdyLogUtil.e("加入课堂", jsonParmp);
214 - XdySdk.api("joinClass", jsonParmp); 216 + xdySdk.api("joinClass", jsonParmp);
215 } 217 }
216 218
217 public void playVideo(String response) { 219 public void playVideo(String response) {
218 - VideoPlayBean videoPlayBean = JsonUtil.parseJsonToBean(response, VideoPlayBean.class);  
219 - if (videoPlayBean != null && videoPlayBean.getRtmpUrl() != null)  
220 - XdyLogUtil.e(TAG, "执行了ss" + videoPlayBean.getRtmpUrl());  
221 - XdySdk.api("playVideo", videoPlayBean.getRtmpUrl(), surfaceviewPlayVideo, AudioPublisherActivity.this, new EventHande_Video());  
222 -// img_playVideo_novideo.setVisibility(View.GONE);  
223 - ToastUtil.showToastshort("视频播放初始化",AudioPublisherActivity.this); 220 +// VideoPlayBean videoPlayBean = JsonUtil.parseJsonToBean(response, VideoPlayBean.class);
  221 +// if (videoPlayBean != null && videoPlayBean.getRtmpUrl() != null)
  222 +// XdyLogUtil.e(TAG, "执行了ss" + videoPlayBean.getRtmpUrl());
  223 +// xdySdk.api("playVideo", videoPlayBean.getRtmpUrl(), surfaceviewPlayVideo, AudioPublisherActivity.this, new EventHande_Video());
  224 +//// img_playVideo_novideo.setVisibility(View.GONE);
  225 +// ToastUtil.showToastshort("视频播放初始化",AudioPublisherActivity.this);
224 } 226 }
225 227
226 public void playAudio(String response) { 228 public void playAudio(String response) {
227 - AudioPlayBean audioPlayBean = JsonUtil.parseJsonToBean(response, AudioPlayBean.class);  
228 - if (audioPlayBean != null && audioPlayBean.getRtmpUrl() != null) {  
229 - XdyLogUtil.e(TAG, "执行了" + audioPlayBean.getRtmpUrl());  
230 - XdySdk.api("playAudio", audioPlayBean.getRtmpUrl(), null, AudioPublisherActivity.this, new EventHande_Video());  
231 -// img_playVideo_novideo.setVisibility(View.GONE);  
232 - ToastUtil.showToastshort("音频播放初始化",AudioPublisherActivity.this);  
233 - } 229 +// AudioPlayBean audioPlayBean = JsonUtil.parseJsonToBean(response, AudioPlayBean.class);
  230 +// if (audioPlayBean != null && audioPlayBean.getRtmpUrl() != null) {
  231 +// XdyLogUtil.e(TAG, "执行了" + audioPlayBean.getRtmpUrl());
  232 +// xdySdk.api("playAudio", audioPlayBean.getRtmpUrl(), null, AudioPublisherActivity.this, new EventHande_Video());
  233 +//// img_playVideo_novideo.setVisibility(View.GONE);
  234 +// ToastUtil.showToastshort("音频播放初始化",AudioPublisherActivity.this);
  235 +// }
234 } 236 }
235 237
236 public void getDoc(String response) { 238 public void getDoc(String response) {
@@ -252,7 +254,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -252,7 +254,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
252 254
253 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 255 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
254 XdyLogUtil.e(TAG, "文档" + jsonParmp); 256 XdyLogUtil.e(TAG, "文档" + jsonParmp);
255 - XdySdk.api("getDocImageFullPath", jsonParmp); 257 + xdySdk.api("getDocImageFullPath", jsonParmp);
256 } 258 }
257 } 259 }
258 260
@@ -263,7 +265,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -263,7 +265,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
263 "}"; 265 "}";
264 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 266 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
265 XdyLogUtil.e(TAG, "聊天" + jsonParmp); 267 XdyLogUtil.e(TAG, "聊天" + jsonParmp);
266 - XdySdk.api("sendChatMsg", jsonParmp); 268 + xdySdk.api("sendChatMsg", jsonParmp);
267 269
268 } 270 }
269 271
@@ -281,55 +283,55 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -281,55 +283,55 @@ public class AudioPublisherActivity extends AppCompatActivity {
281 String ids_new = "getVideoPublishPath"; 283 String ids_new = "getVideoPublishPath";
282 String tem = "{ \"type\": \"live\"}"; 284 String tem = "{ \"type\": \"live\"}";
283 String s = XdyStringUtils.stringToJson(tem, true); 285 String s = XdyStringUtils.stringToJson(tem, true);
284 - XdySdk.api(ids_new, s); 286 + xdySdk.api(ids_new, s);
285 } 287 }
286 288
287 public void publisherVideo(String response) { 289 public void publisherVideo(String response) {
288 - String url = XdyStringUtils.stringToJson(response);  
289 - XdyLogUtil.e("调用任务了播url:", "" + url);  
290 - String us = response.substring(1, response.length() - 1);  
291 - try {  
292 - LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);  
293 - if (liveBean != null&&liveBean.getCode()==0&&liveBean.getPublishUrl()!=null) {  
294 -// String url_text="rtmp://player.daniulive.com:1935/hls/stream";  
295 -// String url_text="rtmp://123.56.205.116:6000/live/h5dev_1999957388_980_983041_1491813919";  
296 - publisherSuccess=liveBean.getPublishUrl();  
297 - if(isPusherAudio){  
298 - XdySdk.api("publishAudio", liveBean.getPublishUrl(), surfaceview_pubisherVideo, AudioPublisherActivity.this,new EventHande());  
299 - ToastUtil.showToastshort("推送纯音频初始化中",AudioPublisherActivity.this);  
300 - }else{  
301 - XdySdk.api("publishVideo", liveBean.getPublishUrl(), surfaceview_pubisherVideo, AudioPublisherActivity.this,new EventHande());  
302 - ToastUtil.showToastshort("推送视频初始化中",AudioPublisherActivity.this);  
303 - }  
304 -  
305 - XdyLogUtil.e(TAG,liveBean.getPublishUrl());  
306 - PublisherEntity publisherEntity=new PublisherEntity();  
307 - if(!TextUtils.isEmpty(publisherSuccess)) {  
308 - publisherEntity.setPublishUrl(publisherSuccess);  
309 - String pamp= new Gson().toJson(publisherEntity);  
310 - XdyLogUtil.e("推流成功",""+pamp);  
311 - XdySdk.api("publishVideo",pamp);  
312 - }  
313 -  
314 - }  
315 - } catch (Exception e) {  
316 - XdyLogUtil.e("调用任务了播视频了e", "" + e.getMessage());  
317 -  
318 - } 290 +// String url = XdyStringUtils.stringToJson(response);
  291 +// XdyLogUtil.e("调用任务了播url:", "" + url);
  292 +// String us = response.substring(1, response.length() - 1);
  293 +// try {
  294 +// LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);
  295 +// if (liveBean != null&&liveBean.getCode()==0&&liveBean.getPublishUrl()!=null) {
  296 +//// String url_text="rtmp://player.daniulive.com:1935/hls/stream";
  297 +//// String url_text="rtmp://123.56.205.116:6000/live/h5dev_1999957388_980_983041_1491813919";
  298 +// publisherSuccess=liveBean.getPublishUrl();
  299 +// if(isPusherAudio){
  300 +// xdySdk.api("publishAudio", liveBean.getPublishUrl(), surfaceview_pubisherVideo, AudioPublisherActivity.this,new EventHande());
  301 +// ToastUtil.showToastshort("推送纯音频初始化中",AudioPublisherActivity.this);
  302 +// }else{
  303 +// xdySdk.api("publishVideo", liveBean.getPublishUrl(), surfaceview_pubisherVideo, AudioPublisherActivity.this,new EventHande());
  304 +// ToastUtil.showToastshort("推送视频初始化中",AudioPublisherActivity.this);
  305 +// }
  306 +//
  307 +// XdyLogUtil.e(TAG,liveBean.getPublishUrl());
  308 +// PublisherEntity publisherEntity=new PublisherEntity();
  309 +// if(!TextUtils.isEmpty(publisherSuccess)) {
  310 +// publisherEntity.setPublishUrl(publisherSuccess);
  311 +// String pamp= new Gson().toJson(publisherEntity);
  312 +// XdyLogUtil.e("推流成功",""+pamp);
  313 +// xdySdk.api("publishVideo",pamp);
  314 +// }
  315 +//
  316 +// }
  317 +// } catch (Exception e) {
  318 +// XdyLogUtil.e("调用任务了播视频了e", "" + e.getMessage());
  319 +//
  320 +// }
319 321
320 } 322 }
321 /** 323 /**
322 * 测试Audio 324 * 测试Audio
323 */ 325 */
324 public void publisherAudioText(){ 326 public void publisherAudioText(){
325 - XdySdk.api(Constants.PUBLISH_AUDIO, "", surfaceview_pubisherVideo, AudioPublisherActivity.this,""); 327 + xdySdk.api(Constants.PUBLISH_AUDIO, "", surfaceview_pubisherVideo, AudioPublisherActivity.this);
326 328
327 } 329 }
328 330
329 @Override 331 @Override
330 public void onBackPressed() { 332 public void onBackPressed() {
331 333
332 - XdySdk.api("unPublishVideo",""); 334 + xdySdk.api("unPublishVideo","");
333 super.onBackPressed(); 335 super.onBackPressed();
334 } 336 }
335 337
@@ -337,7 +339,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -337,7 +339,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
337 339
338 @Override 340 @Override
339 protected void onDestroy() { 341 protected void onDestroy() {
340 - XdySdk.onPublisherStop(); 342 + xdySdk.onPublisherStop();
341 super.onDestroy(); 343 super.onDestroy();
342 344
343 } 345 }
@@ -364,7 +366,7 @@ public class AudioPublisherActivity extends AppCompatActivity { @@ -364,7 +366,7 @@ public class AudioPublisherActivity extends AppCompatActivity {
364 break; 366 break;
365 case R.id.btn_videoPlay_stop: 367 case R.id.btn_videoPlay_stop:
366 ToastUtil.showToastshort("正在退出,请稍等",this); 368 ToastUtil.showToastshort("正在退出,请稍等",this);
367 - XdySdk.api("unPublishVideo",""); 369 + xdySdk.api("unPublishVideo","");
368 finish(); 370 finish();
369 break; 371 break;
370 } 372 }
1 package com.mang.xdy.demo.activity; 1 package com.mang.xdy.demo.activity;
2 -  
3 -import android.app.AlertDialog; 2 +;
4 import android.app.Dialog; 3 import android.app.Dialog;
5 import android.content.Context; 4 import android.content.Context;
6 -import android.content.DialogInterface;  
7 -import android.graphics.Bitmap;  
8 -import android.graphics.BitmapFactory;  
9 -import android.media.Image;  
10 import android.os.Bundle; 5 import android.os.Bundle;
11 import android.os.Handler; 6 import android.os.Handler;
12 import android.os.Message; 7 import android.os.Message;
@@ -14,7 +9,6 @@ import android.support.design.widget.TabLayout; @@ -14,7 +9,6 @@ import android.support.design.widget.TabLayout;
14 import android.support.v4.view.ViewPager; 9 import android.support.v4.view.ViewPager;
15 import android.support.v7.app.AppCompatActivity; 10 import android.support.v7.app.AppCompatActivity;
16 import android.text.TextUtils; 11 import android.text.TextUtils;
17 -import android.util.Log;  
18 import android.view.Gravity; 12 import android.view.Gravity;
19 import android.view.SurfaceView; 13 import android.view.SurfaceView;
20 import android.view.View; 14 import android.view.View;
@@ -23,74 +17,41 @@ import android.view.WindowManager; @@ -23,74 +17,41 @@ import android.view.WindowManager;
23 import android.widget.Button; 17 import android.widget.Button;
24 import android.widget.EditText; 18 import android.widget.EditText;
25 import android.widget.ImageView; 19 import android.widget.ImageView;
26 -import android.widget.TextView;  
27 -import android.widget.Toast;  
28 -  
29 -import com.bumptech.glide.Glide;  
30 -import com.eventhandle.SmartEventCallback;  
31 import com.google.gson.Gson; 20 import com.google.gson.Gson;
  21 +import com.mang.xdy.common.Constants;
  22 +import com.mang.xdy.core.SPUtil;
32 import com.mang.xdy.core.XdySdk; 23 import com.mang.xdy.core.XdySdk;
33 import com.mang.xdy.demo.R; 24 import com.mang.xdy.demo.R;
34 import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter; 25 import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter;
35 -import com.mang.xdy.demo.bean.AudioPlayBean;  
36 -import com.mang.xdy.demo.bean.ChatBean;  
37 import com.mang.xdy.demo.bean.DocEntity; 26 import com.mang.xdy.demo.bean.DocEntity;
38 import com.mang.xdy.demo.bean.GetDocImageEntity; 27 import com.mang.xdy.demo.bean.GetDocImageEntity;
39 import com.mang.xdy.demo.bean.InitClassSuccessEntity; 28 import com.mang.xdy.demo.bean.InitClassSuccessEntity;
40 import com.mang.xdy.demo.bean.JoinClass; 29 import com.mang.xdy.demo.bean.JoinClass;
41 -import com.mang.xdy.demo.bean.LiveBean;  
42 import com.mang.xdy.demo.bean.VideoPlayBean; 30 import com.mang.xdy.demo.bean.VideoPlayBean;
43 -import com.mang.xdy.demo.bean.WhiteboardUpdateEntity;  
44 import com.mang.xdy.demo.utils.JsonUtil; 31 import com.mang.xdy.demo.utils.JsonUtil;
45 import com.mang.xdy.demo.utils.ToastUtil; 32 import com.mang.xdy.demo.utils.ToastUtil;
46 -import com.mang.xdy.demo.widget.CanvasView;  
47 import com.mang.xdy.utils.XdyLogUtil; 33 import com.mang.xdy.utils.XdyLogUtil;
48 import com.mang.xdy.utils.XdyStringUtils; 34 import com.mang.xdy.utils.XdyStringUtils;
49 -import com.squareup.picasso.Picasso;  
50 35
51 -import java.io.IOException;  
52 -import java.util.concurrent.ExecutionException;  
53 36
54 import butterknife.BindView; 37 import butterknife.BindView;
55 import butterknife.ButterKnife; 38 import butterknife.ButterKnife;
56 -import butterknife.OnClick;  
57 39
58 public class VideoPlayActivity extends AppCompatActivity { 40 public class VideoPlayActivity extends AppCompatActivity {
59 private final static String TAG = "VideoPlayActivity"; 41 private final static String TAG = "VideoPlayActivity";
60 - @BindView(R.id.btn_videoPlay_pubsherVideo)  
61 - Button btnVideoPlayPubsherVideo;  
62 - @BindView(R.id.btn_videoPlay_chat)  
63 - Button btnVideoPlayChat;  
64 - @BindView(R.id.tv_videoPlay_url)  
65 - TextView tv_videoPlay_url;  
66 - @BindView(R.id.surfaceview_pubisherVideo)  
67 - SurfaceView surfaceview_pubisherVideo;  
68 @BindView(R.id.img_playVideo_novideo) 42 @BindView(R.id.img_playVideo_novideo)
69 ImageView img_playVideo_novideo; 43 ImageView img_playVideo_novideo;
70 - @BindView(R.id.bt_stop)  
71 - Button bt_stop;  
72 - @BindView(R.id.img_playVideo_docShow)  
73 - ImageView mDocImage;  
74 private String username=""; 44 private String username="";
75 private String userpwd=""; 45 private String userpwd="";
76 private PersonDialog personDialog; 46 private PersonDialog personDialog;
77 private SimpleFragmentPagerAdapter pagerAdapter; 47 private SimpleFragmentPagerAdapter pagerAdapter;
78 48
79 private ViewPager viewPager; 49 private ViewPager viewPager;
80 -  
81 private TabLayout tabLayout; 50 private TabLayout tabLayout;
82 @BindView(R.id.surfaceview_playVideo) 51 @BindView(R.id.surfaceview_playVideo)
83 SurfaceView surfaceviewPlayVideo; 52 SurfaceView surfaceviewPlayVideo;
84 - @BindView(R.id.canvas_playVideo_showWhiteBroad)  
85 - CanvasView mCanvasView;  
86 private String initClass = ""; 53 private String initClass = "";
87 - public OnAcceptFromCoreToFragmentListener mOnAcceptFromCoreToFragmentListener;  
88 - public interface OnAcceptFromCoreToFragmentListener{  
89 - void onAcceptInfo(String type,String response);  
90 - }  
91 - public void setmOnAcceptFromCoreToFragmentListener(OnAcceptFromCoreToFragmentListener mOnAcceptFromCoreToFragmentListener){  
92 - this.mOnAcceptFromCoreToFragmentListener=mOnAcceptFromCoreToFragmentListener;  
93 - } 54 + private XdySdk xdySdk;
94 private Handler handler = new Handler() { 55 private Handler handler = new Handler() {
95 @Override 56 @Override
96 public void handleMessage(Message msg) { 57 public void handleMessage(Message msg) {
@@ -102,7 +63,7 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -102,7 +63,7 @@ public class VideoPlayActivity extends AppCompatActivity {
102 break; 63 break;
103 case -1: 64 case -1:
104 //退出 65 //退出
105 - XdySdk.api("leaveClass", ""); 66 + xdySdk.api("leaveClass", "");
106 break; 67 break;
107 case 0: 68 case 0:
108 parseJoinClass((String) msg.obj,true); 69 parseJoinClass((String) msg.obj,true);
@@ -123,20 +84,15 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -123,20 +84,15 @@ public class VideoPlayActivity extends AppCompatActivity {
123 getDoc((String) msg.obj); 84 getDoc((String) msg.obj);
124 break; 85 break;
125 case 4: 86 case 4:
126 - //发送消息  
127 - sendMeg();  
128 break; 87 break;
129 case 5: 88 case 5:
130 - //接受消息  
131 - getMsg((String) msg.obj);  
132 break; 89 break;
133 case 6: 90 case 6:
134 //图片 91 //图片
135 - setDocImage((String) msg.obj);  
136 break; 92 break;
137 case 7: 93 case 7:
138 //停止播放 94 //停止播放
139 - XdySdk.onPlayStop(); 95 + xdySdk.onPlayStop();
140 img_playVideo_novideo.setVisibility(View.VISIBLE); 96 img_playVideo_novideo.setVisibility(View.VISIBLE);
141 // surfaceviewPlayVideo.refreshDrawableState();; 97 // surfaceviewPlayVideo.refreshDrawableState();;
142 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this); 98 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this);
@@ -151,11 +107,11 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -151,11 +107,11 @@ public class VideoPlayActivity extends AppCompatActivity {
151 super.onCreate(savedInstanceState); 107 super.onCreate(savedInstanceState);
152 setContentView(R.layout.activity_video_play); 108 setContentView(R.layout.activity_video_play);
153 ButterKnife.bind(this); 109 ButterKnife.bind(this);
154 - 110 + xdySdk=XdySdk.getXdyInstance();
155 init(); 111 init();
156 - setTablayout(); 112 + setTablayout();
157 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+""); 113 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+"");
158 - XdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() { 114 + xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
159 @Override 115 @Override
160 public void onXdyAsyncMessageReceiver(String type, String response) { 116 public void onXdyAsyncMessageReceiver(String type, String response) {
161 Message message = Message.obtain(); 117 Message message = Message.obtain();
@@ -188,6 +144,8 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -188,6 +144,8 @@ public class VideoPlayActivity extends AppCompatActivity {
188 case "class_join_success": 144 case "class_join_success":
189 //加入课堂成功 145 //加入课堂成功
190 ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this); 146 ToastUtil.showToastshort("加入课堂成功", VideoPlayActivity.this);
  147 + String userJson=response;
  148 + SPUtil.putString(VideoPlayActivity.this, Constants.CLASS_JOIN_SUCCESS,userJson);
191 break; 149 break;
192 case "class_delete_roster": 150 case "class_delete_roster":
193 // ToastUtil.showToastshort("离开课堂", VideoPlayActivity.this); 151 // ToastUtil.showToastshort("离开课堂", VideoPlayActivity.this);
@@ -209,7 +167,6 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -209,7 +167,6 @@ public class VideoPlayActivity extends AppCompatActivity {
209 break; 167 break;
210 case "whiteboard_annotation_update": 168 case "whiteboard_annotation_update":
211 ToastUtil.showToastshort("白板信息更新" + response, VideoPlayActivity.this); 169 ToastUtil.showToastshort("白板信息更新" + response, VideoPlayActivity.this);
212 - showDoc(type,response);  
213 break; 170 break;
214 case "getDocImageFullPath": 171 case "getDocImageFullPath":
215 // String urls= "rtmp://player.daniulive.com:1935/hls/stream";; 172 // String urls= "rtmp://player.daniulive.com:1935/hls/stream";;
@@ -230,16 +187,13 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -230,16 +187,13 @@ public class VideoPlayActivity extends AppCompatActivity {
230 XdyLogUtil.e("xuedianyunlog",response); 187 XdyLogUtil.e("xuedianyunlog",response);
231 } 188 }
232 } 189 }
233 - if(mOnAcceptFromCoreToFragmentListener!=null){  
234 - mOnAcceptFromCoreToFragmentListener.onAcceptInfo(type,response);  
235 - }  
236 } 190 }
237 }); 191 });
238 } 192 }
239 193
240 public void init() { 194 public void init() {
241 initClass = getIntent().getStringExtra("init"); 195 initClass = getIntent().getStringExtra("init");
242 - XdySdk.api("init", initClass); 196 + xdySdk.api("init", initClass);
243 197
244 } 198 }
245 199
@@ -265,12 +219,6 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -265,12 +219,6 @@ public class VideoPlayActivity extends AppCompatActivity {
265 } 219 }
266 //加入课堂 220 //加入课堂
267 public void joinClass(String rsponse,boolean isShowPwd) { 221 public void joinClass(String rsponse,boolean isShowPwd) {
268 -  
269 -// String temp = "{\n" +  
270 -// " \"userName\":\"base\",\n" +  
271 -// " \"password\":\"123321\",\n" +  
272 -// " \"hasCamera\":false,\n" +  
273 -// " \"hasMicrophone\":false}";  
274 JoinClass joinClass=new JoinClass(); 222 JoinClass joinClass=new JoinClass();
275 joinClass.setHasCamera(false); 223 joinClass.setHasCamera(false);
276 joinClass.setHasMicrophone(false); 224 joinClass.setHasMicrophone(false);
@@ -283,112 +231,60 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -283,112 +231,60 @@ public class VideoPlayActivity extends AppCompatActivity {
283 String temp=new Gson().toJson(joinClass); 231 String temp=new Gson().toJson(joinClass);
284 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 232 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
285 XdyLogUtil.e("加入课堂", jsonParmp); 233 XdyLogUtil.e("加入课堂", jsonParmp);
286 - XdySdk.api("joinClass", jsonParmp); 234 + xdySdk.api("joinClass", jsonParmp);
287 } 235 }
288 - VideoPlayBean videoPlayBean; 236 +
  237 + /**
  238 + * 播放视频
  239 + * @param response
  240 + */
289 public void playVideo(String response) { 241 public void playVideo(String response) {
290 -// videoPlayBean = JsonUtil.parseJsonToBean(response, VideoPlayBean.class);  
291 -// if (videoPlayBean != null && videoPlayBean.getRtmpUrl() != null) {  
292 -// XdyLogUtil.e(TAG, "执行了ss" + videoPlayBean.getRtmpUrl());  
293 - bt_stop.setEnabled(true);  
294 -// XdySdk.setAsyncApi("playVideo", videoPlayBean.getRtmpUrl(), surfaceviewPlayVideo, VideoPlayActivity.this, new EventHande_Video());  
295 - XdySdk.api("playVideo", response+"", surfaceviewPlayVideo, VideoPlayActivity.this,"");  
296 - img_playVideo_novideo.setVisibility(View.GONE);  
297 -// }else{  
298 -// bt_stop.setEnabled(false);  
299 -// } 242 + xdySdk.api("playVideo", response+"", surfaceviewPlayVideo, VideoPlayActivity.this);
  243 + img_playVideo_novideo.setVisibility(View.GONE);
300 ToastUtil.showToastshort("视频播放初始化",VideoPlayActivity.this); 244 ToastUtil.showToastshort("视频播放初始化",VideoPlayActivity.this);
301 } 245 }
302 246
  247 + /**
  248 + * 播放音频
  249 + * @param response
  250 + */
303 public void playAudio(String response) { 251 public void playAudio(String response) {
304 -// AudioPlayBean audioPlayBean = JsonUtil.parseJsonToBean(response, AudioPlayBean.class);  
305 -// if (audioPlayBean != null && audioPlayBean.getRtmpUrl() != null) {  
306 -// XdyLogUtil.e(TAG, "执行了" + audioPlayBean.getRtmpUrl());  
307 -// XdySdk.setAsyncApi("playAudio", audioPlayBean.getRtmpUrl(), null, VideoPlayActivity.this, new EventHande_Video());  
308 - XdySdk.api("playAudio", response, null, VideoPlayActivity.this, "");  
309 - img_playVideo_novideo.setVisibility(View.GONE);  
310 - ToastUtil.showToastshort("音频播放初始化",VideoPlayActivity.this);  
311 -// } 252 + xdySdk.api("playAudio", response, null, VideoPlayActivity.this);
  253 + img_playVideo_novideo.setVisibility(View.GONE);
  254 + ToastUtil.showToastshort("音频播放初始化",VideoPlayActivity.this);
312 } 255 }
313 256
314 public void getDoc(String response) { 257 public void getDoc(String response) {
315 DocEntity docEntity = JsonUtil.parseJsonToBean(response, DocEntity.class); 258 DocEntity docEntity = JsonUtil.parseJsonToBean(response, DocEntity.class);
316 if (docEntity != null && docEntity.getRelativeUrl() != null) { 259 if (docEntity != null && docEntity.getRelativeUrl() != null) {
317 -  
318 String url = docEntity.getRelativeUrl(); 260 String url = docEntity.getRelativeUrl();
319 -// String temp = "{\n" +  
320 -// " \"type\": \"jpg\",\n" +  
321 -// " \"pageNum\": 1,\n" +  
322 -// " \"relativeUrl\": \" '" + url + "'\"\n" +  
323 -// "}";  
324 -// String temp = "{\n" +  
325 -// " \"type\": \"jpg\",\n" +  
326 -// " \"pageNum\": 1,\n" +  
327 -// " \"relativeUrl\": \"/DocSharing/data/1087553281/20170409-204600041/d32594763768243bddc64934be5088a0.jpg\"\n" +  
328 -// "}";  
329 -  
330 GetDocImageEntity getDocImageEntity=new GetDocImageEntity(); 261 GetDocImageEntity getDocImageEntity=new GetDocImageEntity();
331 getDocImageEntity.setPageNum(1); 262 getDocImageEntity.setPageNum(1);
332 -// getDocImageEntity.setRelativeUrl("/DocSharing/data/1087553281/20170409-204600041/d32594763768243bddc64934be5088a0.swf");  
333 getDocImageEntity.setRelativeUrl(url); 263 getDocImageEntity.setRelativeUrl(url);
334 getDocImageEntity.setType("jpg"); 264 getDocImageEntity.setType("jpg");
335 String jsonParmp = new Gson().toJson(getDocImageEntity); 265 String jsonParmp = new Gson().toJson(getDocImageEntity);
336 XdyLogUtil.e(TAG, "文档" + jsonParmp); 266 XdyLogUtil.e(TAG, "文档" + jsonParmp);
337 - XdySdk.api("getDocImageFullPath", jsonParmp); 267 + xdySdk.api("getDocImageFullPath", jsonParmp);
338 } 268 }
339 } 269 }
340 270
341 - public void sendMeg() {  
342 - String temp = "{\n" +  
343 - " \"message\": \"固定发送测试 hello\",\n" +  
344 - " \"to\": 0\n" +  
345 - "}";  
346 - String jsonParmp = XdyStringUtils.stringToJson(temp, true);  
347 - XdyLogUtil.e(TAG, "聊天" + jsonParmp);  
348 - XdySdk.api("sendChatMsg", jsonParmp);  
349 -  
350 - }  
351 -  
352 - //获取聊天信息  
353 - public void getMsg(String msg) {  
354 - ChatBean chatBean = JsonUtil.parseJsonToBean(msg, ChatBean.class);  
355 - if (chatBean != null) {  
356 - btnVideoPlayChat.setText(chatBean.getMessage());  
357 - }  
358 -  
359 - }  
360 -  
361 - //获取推流地址  
362 - public void getPublish() {  
363 - }  
364 -  
365 - public void publisherVideo(String response) {  
366 - }  
367 271
368 @Override 272 @Override
369 public void onBackPressed() { 273 public void onBackPressed() {
370 -  
371 super.onBackPressed(); 274 super.onBackPressed();
372 - XdySdk.onPlayStop(); 275 + xdySdk.onPlayStop();
373 } 276 }
374 277
375 278
376 279
377 - @OnClick({R.id.btn_videoPlay_chat, R.id.btn_videoPlay_pubsherVideo,R.id.bt_stop})  
378 public void onViewClicked(View view) { 280 public void onViewClicked(View view) {
379 switch (view.getId()) { 281 switch (view.getId()) {
380 - case R.id.btn_videoPlay_chat:  
381 - handler.sendEmptyMessage(4);  
382 - break;  
383 - case R.id.btn_videoPlay_pubsherVideo:  
384 - getPublish();  
385 - break;  
386 - case R.id.bt_stop:  
387 - //停止视频  
388 - if(videoPlayBean!=null) {  
389 - XdySdk.api("stopVideo", videoPlayBean.getMediaId() + "");  
390 - }  
391 - break; 282 +// case R.id.bt_stop:
  283 +// //停止视频
  284 +// if(videoPlayBean!=null) {
  285 +// xdySdk.api("stopVideo", videoPlayBean.getMediaId() + "");
  286 +// }
  287 +// break;
392 } 288 }
393 } 289 }
394 class PersonDialog extends Dialog { 290 class PersonDialog extends Dialog {
@@ -453,58 +349,6 @@ public class VideoPlayActivity extends AppCompatActivity { @@ -453,58 +349,6 @@ public class VideoPlayActivity extends AppCompatActivity {
453 }); 349 });
454 } 350 }
455 } 351 }
456 - public void setDocImage(String resonse){  
457 - if(resonse.length()>10){  
458 - String temp=XdyStringUtils.stringToJson(resonse);  
459 - String url=temp.substring(2,temp.length()-2);  
460 - urlsss=url;  
461 - XdyLogUtil.e(TAG,"截取后的"+url);  
462 - Picasso.with(this).load(url).placeholder(R.mipmap.novideo).into(mDocImage);  
463 - getBitmap(url);  
464 - }  
465 - }  
466 - String urlsss="";  
467 - Bitmap bitmap;  
468 - public void showDoc(String type,String response){  
469 - mCanvasView.setZOrderMediaOverlay(true);  
470 - mCanvasView.setBitmap(bitmap,false);  
471 -  
472 - WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class);  
473 - if(whiteboardUpdateEntity!=null){  
474 - drawline(whiteboardUpdateEntity);  
475 - }  
476 -  
477 - }  
478 - private void drawline(WhiteboardUpdateEntity o) {  
479 - if (o != null) {  
480 - if (o.isFresh) {  
481 - if (mCanvasView != null) {  
482 - mCanvasView.clear();  
483 - }  
484 - }  
485 352
486 - if (o.annotaionItems != null) {  
487 - if (mCanvasView != null) {  
488 - mCanvasView.drawLine(o.annotaionItems);  
489 - }  
490 - }  
491 -  
492 - }  
493 - }  
494 353
495 - public void getBitmap(final String url){  
496 - new Thread(){  
497 - @Override  
498 - public void run() {  
499 - super.run();  
500 - try {  
501 - bitmap= Glide.with(VideoPlayActivity.this).load(url).asBitmap().into(480,480).get();  
502 - } catch (InterruptedException e) {  
503 - e.printStackTrace();  
504 - } catch (ExecutionException e) {  
505 - e.printStackTrace();  
506 - }  
507 - }  
508 - }.start();  
509 - }  
510 } 354 }
@@ -67,7 +67,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -67,7 +67,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
67 private String userpwd=""; 67 private String userpwd="";
68 private PersonDialog personDialog; 68 private PersonDialog personDialog;
69 private SimpleFragmentPagerAdapter pagerAdapter; 69 private SimpleFragmentPagerAdapter pagerAdapter;
70 - 70 + private XdySdk xdySdk;
71 private ViewPager viewPager; 71 private ViewPager viewPager;
72 //默认推送视频 72 //默认推送视频
73 private boolean isPusherAudio=false; 73 private boolean isPusherAudio=false;
@@ -93,7 +93,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -93,7 +93,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
93 break; 93 break;
94 case -1: 94 case -1:
95 //退出 95 //退出
96 - XdySdk.api("leaveClass", ""); 96 + xdySdk.api("leaveClass", "");
97 break; 97 break;
98 case 0: 98 case 0:
99 parseJoinClass((String) msg.obj,true); 99 parseJoinClass((String) msg.obj,true);
@@ -126,7 +126,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -126,7 +126,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
126 break; 126 break;
127 case 7: 127 case 7:
128 //停止播放 128 //停止播放
129 - XdySdk.onPlayStop(); 129 + xdySdk.onPlayStop();
130 // img_playVideo_novideo.setVisibility(View.GONE); 130 // img_playVideo_novideo.setVisibility(View.GONE);
131 // surfaceviewPlayVideo.refreshDrawableState();; 131 // surfaceviewPlayVideo.refreshDrawableState();;
132 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this); 132 // ToastUtil.showToastshort("播放音视/视频停止",VideoPlayActivity.this);
@@ -148,9 +148,10 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -148,9 +148,10 @@ public class VideoPublisherActivity extends AppCompatActivity {
148 ButterKnife.bind(this); 148 ButterKnife.bind(this);
149 btn_videoPlay_publisherAudio.setVisibility(View.GONE); 149 btn_videoPlay_publisherAudio.setVisibility(View.GONE);
150 // setTablayout(); 150 // setTablayout();
  151 + xdySdk=XdySdk.getXdyInstance();
151 init(); 152 init();
152 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+""); 153 XdyLogUtil.e(TAG,"当前线程 main:"+android.os.Process.myPid()+"线程:"+Thread.currentThread().getId()+"");
153 - XdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() { 154 + xdySdk.setOnXdyAsyncMessageLitener(new XdySdk.OnXdyAsyncMessageLitener() {
154 @Override 155 @Override
155 public void onXdyAsyncMessageReceiver(String type, String response) { 156 public void onXdyAsyncMessageReceiver(String type, String response) {
156 157
@@ -191,7 +192,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -191,7 +192,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
191 192
192 public void init() { 193 public void init() {
193 initClass = getIntent().getStringExtra("init"); 194 initClass = getIntent().getStringExtra("init");
194 - XdySdk.api("init", initClass); 195 + xdySdk.api("init", initClass);
195 196
196 } 197 }
197 //判断解析是否有密码 198 //判断解析是否有密码
@@ -226,26 +227,26 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -226,26 +227,26 @@ public class VideoPublisherActivity extends AppCompatActivity {
226 String temp=new Gson().toJson(joinClass); 227 String temp=new Gson().toJson(joinClass);
227 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 228 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
228 XdyLogUtil.e("加入课堂", jsonParmp); 229 XdyLogUtil.e("加入课堂", jsonParmp);
229 - XdySdk.api("joinClass", jsonParmp); 230 + xdySdk.api("joinClass", jsonParmp);
230 } 231 }
231 232
232 public void playVideo(String response) { 233 public void playVideo(String response) {
233 - VideoPlayBean videoPlayBean = JsonUtil.parseJsonToBean(response, VideoPlayBean.class);  
234 - if (videoPlayBean != null && videoPlayBean.getRtmpUrl() != null)  
235 - XdyLogUtil.e(TAG, "执行了ss" + videoPlayBean.getRtmpUrl());  
236 - XdySdk.api("playVideo", videoPlayBean.getRtmpUrl(), surfaceviewPlayVideo, VideoPublisherActivity.this, new EventHande_Video());  
237 -// img_playVideo_novideo.setVisibility(View.GONE);  
238 - ToastUtil.showToastshort("视频播放初始化",VideoPublisherActivity.this); 234 +// VideoPlayBean videoPlayBean = JsonUtil.parseJsonToBean(response, VideoPlayBean.class);
  235 +// if (videoPlayBean != null && videoPlayBean.getRtmpUrl() != null)
  236 +// XdyLogUtil.e(TAG, "执行了ss" + videoPlayBean.getRtmpUrl());
  237 +// xdySdk.api("playVideo", videoPlayBean.getRtmpUrl(), surfaceviewPlayVideo, VideoPublisherActivity.this, new EventHande_Video());
  238 +//// img_playVideo_novideo.setVisibility(View.GONE);
  239 +// ToastUtil.showToastshort("视频播放初始化",VideoPublisherActivity.this);
239 } 240 }
240 241
241 public void playAudio(String response) { 242 public void playAudio(String response) {
242 - AudioPlayBean audioPlayBean = JsonUtil.parseJsonToBean(response, AudioPlayBean.class);  
243 - if (audioPlayBean != null && audioPlayBean.getRtmpUrl() != null) {  
244 - XdyLogUtil.e(TAG, "执行了" + audioPlayBean.getRtmpUrl());  
245 - XdySdk.api("playAudio", audioPlayBean.getRtmpUrl(), null, VideoPublisherActivity.this, new EventHande_Video());  
246 -// img_playVideo_novideo.setVisibility(View.GONE);  
247 - ToastUtil.showToastshort("音频播放初始化",VideoPublisherActivity.this);  
248 - } 243 +// AudioPlayBean audioPlayBean = JsonUtil.parseJsonToBean(response, AudioPlayBean.class);
  244 +// if (audioPlayBean != null && audioPlayBean.getRtmpUrl() != null) {
  245 +// XdyLogUtil.e(TAG, "执行了" + audioPlayBean.getRtmpUrl());
  246 +// xdySdk.api("playAudio", audioPlayBean.getRtmpUrl(), null, VideoPublisherActivity.this, new EventHande_Video());
  247 +//// img_playVideo_novideo.setVisibility(View.GONE);
  248 +// ToastUtil.showToastshort("音频播放初始化",VideoPublisherActivity.this);
  249 +// }
249 } 250 }
250 251
251 public void getDoc(String response) { 252 public void getDoc(String response) {
@@ -267,7 +268,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -267,7 +268,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
267 268
268 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 269 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
269 XdyLogUtil.e(TAG, "文档" + jsonParmp); 270 XdyLogUtil.e(TAG, "文档" + jsonParmp);
270 - XdySdk.api("getDocImageFullPath", jsonParmp); 271 + xdySdk.api("getDocImageFullPath", jsonParmp);
271 } 272 }
272 } 273 }
273 274
@@ -278,7 +279,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -278,7 +279,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
278 "}"; 279 "}";
279 String jsonParmp = XdyStringUtils.stringToJson(temp, true); 280 String jsonParmp = XdyStringUtils.stringToJson(temp, true);
280 XdyLogUtil.e(TAG, "聊天" + jsonParmp); 281 XdyLogUtil.e(TAG, "聊天" + jsonParmp);
281 - XdySdk.api("sendChatMsg", jsonParmp); 282 + xdySdk.api("sendChatMsg", jsonParmp);
282 283
283 } 284 }
284 285
@@ -296,14 +297,14 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -296,14 +297,14 @@ public class VideoPublisherActivity extends AppCompatActivity {
296 String ids_new = "getVideoPublishPath"; 297 String ids_new = "getVideoPublishPath";
297 String tem = "{ \"type\": \"live\"}"; 298 String tem = "{ \"type\": \"live\"}";
298 String s = XdyStringUtils.stringToJson(tem, true); 299 String s = XdyStringUtils.stringToJson(tem, true);
299 - XdySdk.api(ids_new, s); 300 + xdySdk.api(ids_new, s);
300 } 301 }
301 302
302 /** 303 /**
303 * 获取封装的推流地址 304 * 获取封装的推流地址
304 */ 305 */
305 public void publisherVideoText(){ 306 public void publisherVideoText(){
306 - XdySdk.api("publishVideo", "", surfaceview_pubisherVideo, VideoPublisherActivity.this,""); 307 + xdySdk.api("publishVideo", "", surfaceview_pubisherVideo, VideoPublisherActivity.this);
307 308
308 } 309 }
309 310
@@ -315,44 +316,44 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -315,44 +316,44 @@ public class VideoPublisherActivity extends AppCompatActivity {
315 316
316 } 317 }
317 public void publisherVideo(String response) { 318 public void publisherVideo(String response) {
318 - String url = XdyStringUtils.stringToJson(response);  
319 - XdyLogUtil.e("调用任务了播url:", "" + url);  
320 - String us = response.substring(1, response.length() - 1);  
321 - try {  
322 - LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);  
323 - if (liveBean != null&&liveBean.getCode()==0&&liveBean.getPublishUrl()!=null) {  
324 -// String url_text="rtmp://player.daniulive.com:1935/hls/stream";  
325 -// String url_text="rtmp://123.56.205.116:6000/live/h5dev_1999957388_980_983041_1491813919";  
326 - publisherSuccess=liveBean.getPublishUrl();  
327 - if(isPusherAudio){  
328 - XdySdk.api("publishAudio", liveBean.getPublishUrl(), surfaceview_pubisherVideo, VideoPublisherActivity.this,new EventHande());  
329 - ToastUtil.showToastshort("推送纯音频初始化中",VideoPublisherActivity.this);  
330 - }else{  
331 - XdySdk.api("publishVideo", liveBean.getPublishUrl(), surfaceview_pubisherVideo, VideoPublisherActivity.this,new EventHande());  
332 - ToastUtil.showToastshort("推送视频初始化中",VideoPublisherActivity.this);  
333 - }  
334 - isAbleback=true;  
335 - XdyLogUtil.e(TAG,liveBean.getPublishUrl());  
336 - PublisherEntity publisherEntity=new PublisherEntity();  
337 - if(!TextUtils.isEmpty(publisherSuccess)) {  
338 - publisherEntity.setPublishUrl(publisherSuccess);  
339 - String pamp= new Gson().toJson(publisherEntity);  
340 - XdyLogUtil.e("推流成功",""+pamp);  
341 - XdySdk.api("publishVideo",pamp);  
342 - }  
343 -  
344 - }  
345 - } catch (Exception e) {  
346 - XdyLogUtil.e("调用任务了播视频了e", "" + e.getMessage());  
347 -// publisherVideoReturnBean=JsonUtil.parseJsonToBean(response,PublisherVideoReturnBean.class);  
348 - } 319 +// String url = XdyStringUtils.stringToJson(response);
  320 +// XdyLogUtil.e("调用任务了播url:", "" + url);
  321 +// String us = response.substring(1, response.length() - 1);
  322 +// try {
  323 +// LiveBean liveBean = new Gson().fromJson(url, LiveBean.class);
  324 +// if (liveBean != null&&liveBean.getCode()==0&&liveBean.getPublishUrl()!=null) {
  325 +//// String url_text="rtmp://player.daniulive.com:1935/hls/stream";
  326 +//// String url_text="rtmp://123.56.205.116:6000/live/h5dev_1999957388_980_983041_1491813919";
  327 +// publisherSuccess=liveBean.getPublishUrl();
  328 +// if(isPusherAudio){
  329 +// xdySdk.api("publishAudio", liveBean.getPublishUrl(), surfaceview_pubisherVideo, VideoPublisherActivity.this,new EventHande());
  330 +// ToastUtil.showToastshort("推送纯音频初始化中",VideoPublisherActivity.this);
  331 +// }else{
  332 +// xdySdk.api("publishVideo", liveBean.getPublishUrl(), surfaceview_pubisherVideo, VideoPublisherActivity.this,new EventHande());
  333 +// ToastUtil.showToastshort("推送视频初始化中",VideoPublisherActivity.this);
  334 +// }
  335 +// isAbleback=true;
  336 +// XdyLogUtil.e(TAG,liveBean.getPublishUrl());
  337 +// PublisherEntity publisherEntity=new PublisherEntity();
  338 +// if(!TextUtils.isEmpty(publisherSuccess)) {
  339 +// publisherEntity.setPublishUrl(publisherSuccess);
  340 +// String pamp= new Gson().toJson(publisherEntity);
  341 +// XdyLogUtil.e("推流成功",""+pamp);
  342 +// xdySdk.api("publishVideo",pamp);
  343 +// }
  344 +//
  345 +// }
  346 +// } catch (Exception e) {
  347 +// XdyLogUtil.e("调用任务了播视频了e", "" + e.getMessage());
  348 +//// publisherVideoReturnBean=JsonUtil.parseJsonToBean(response,PublisherVideoReturnBean.class);
  349 +// }
349 350
350 } 351 }
351 352
352 @Override 353 @Override
353 public void onBackPressed() { 354 public void onBackPressed() {
354 //退出课堂 355 //退出课堂
355 - XdySdk.api("unPublishVideo",""); 356 + xdySdk.api("unPublishVideo","");
356 super.onBackPressed(); 357 super.onBackPressed();
357 358
358 359
@@ -362,7 +363,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -362,7 +363,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
362 363
363 @Override 364 @Override
364 protected void onDestroy() { 365 protected void onDestroy() {
365 - XdySdk.onPublisherStop(); 366 + xdySdk.onPublisherStop();
366 super.onDestroy(); 367 super.onDestroy();
367 } 368 }
368 369
@@ -382,7 +383,7 @@ public class VideoPublisherActivity extends AppCompatActivity { @@ -382,7 +383,7 @@ public class VideoPublisherActivity extends AppCompatActivity {
382 break; 383 break;
383 case R.id.btn_videoPlay_stop: 384 case R.id.btn_videoPlay_stop:
384 ToastUtil.showToastshort("正在退出,请稍等",this); 385 ToastUtil.showToastshort("正在退出,请稍等",this);
385 - XdySdk.api("unPublishVideo",""); 386 + xdySdk.api("unPublishVideo","");
386 finish(); 387 finish();
387 break; 388 break;
388 } 389 }
  1 +/*
  2 + * Copyright (c) 2015, 张涛.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package com.mang.xdy.demo.adapter;
  17 +
  18 +import android.content.Context;
  19 +import android.text.TextUtils;
  20 +import android.view.View;
  21 +import android.view.ViewGroup;
  22 +import android.widget.BaseAdapter;
  23 +import android.widget.ImageView;
  24 +import android.widget.ProgressBar;
  25 +import android.widget.RelativeLayout;
  26 +import android.widget.TextView;
  27 +
  28 +
  29 +import com.mang.xdy.demo.R;
  30 +import com.mang.xdy.demo.bean.Message;
  31 +import com.mang.xdy.demo.fragment.ChatFragment;
  32 +import com.mang.xdy.demo.widget.chat.UrlUtils;
  33 +import com.mang.xdy.utils.XdyLogUtil;
  34 +
  35 +import org.kymjs.kjframe.KJBitmap;
  36 +
  37 +import java.util.ArrayList;
  38 +import java.util.List;
  39 +
  40 +/**
  41 + * @author kymjs (http://www.kymjs.com/) on 6/8/15.
  42 + */
  43 +public class ChatAdapter extends BaseAdapter {
  44 +
  45 + private final Context cxt;
  46 + private List<Message> datas = null;
  47 + private KJBitmap kjb;
  48 + private ChatFragment.OnChatItemClickListener listener;
  49 + String oldTime;
  50 +
  51 + public ChatAdapter(Context cxt, List<Message> datas, ChatFragment.OnChatItemClickListener listener) {
  52 + this.cxt = cxt;
  53 + if (datas == null) {
  54 + datas = new ArrayList<Message>(0);
  55 + }
  56 + this.datas = datas;
  57 + kjb = new KJBitmap();
  58 + this.listener = listener;
  59 + }
  60 +
  61 + public void refresh(List<Message> datas) {
  62 + if (datas == null) {
  63 + datas = new ArrayList<>(0);
  64 + }
  65 + this.datas = datas;
  66 + notifyDataSetChanged();
  67 + }
  68 +
  69 + @Override
  70 + public int getCount() {
  71 + return datas.size();
  72 + }
  73 +
  74 + @Override
  75 + public Object getItem(int position) {
  76 + return datas.get(position);
  77 + }
  78 +
  79 + @Override
  80 + public long getItemId(int position) {
  81 + return position;
  82 + }
  83 +
  84 + @Override
  85 + public int getItemViewType(int position) {
  86 + return datas.get(position).getIsSend() ? 1 : 0;
  87 + }
  88 +
  89 + @Override
  90 + public int getViewTypeCount() {
  91 + return 2;
  92 + }
  93 +
  94 + @Override
  95 + public View getView(final int position, View v, ViewGroup parent) {
  96 + final ViewHolder holder;
  97 + final Message data = datas.get(position);
  98 + if (v == null) {
  99 + holder = new ViewHolder();
  100 + if (data.getIsSend()) {
  101 + v = View.inflate(cxt, R.layout.home_chat_item_list_right, null);
  102 + } else {
  103 + v = View.inflate(cxt, R.layout.home_chat_item_list_left, null);
  104 + }
  105 + holder.layout_content = (RelativeLayout) v.findViewById(R.id.chat_item_layout_content);
  106 + holder.img_avatar = (ImageView) v.findViewById(R.id.chat_item_avatar);
  107 + holder.img_chatimage = (ImageView) v.findViewById(R.id.chat_item_content_image);
  108 + holder.img_sendfail = (ImageView) v.findViewById(R.id.chat_item_fail);
  109 + holder.progress = (ProgressBar) v.findViewById(R.id.chat_item_progress);
  110 + holder.tv_chatcontent = (TextView) v.findViewById(R.id.chat_item_content_text);
  111 + holder.tv_date = (TextView) v.findViewById(R.id.chat_item_date);
  112 + holder.tv_name = (TextView) v.findViewById(R.id.chat_item_name);
  113 + holder.tv_teacher_bg = (TextView) v.findViewById(R.id.chat_item_taacher_bg);
  114 + v.setTag(holder);
  115 + } else {
  116 + holder = (ViewHolder) v.getTag();
  117 + }
  118 +
  119 + if (data.getTime() != null) {
  120 + String dataTime = data.getTime();
  121 + holder.tv_date.setText(dataTime);
  122 + holder.tv_date.setVisibility(View.VISIBLE);
  123 + }else {
  124 + holder.tv_date.setVisibility(View.GONE);
  125 + }
  126 +
  127 + //如果是文本类型,则隐藏图片,如果是图片则隐藏文本
  128 + if (data.getType() == Message.MSG_TYPE_TEXT) {
  129 + holder.img_chatimage.setVisibility(View.GONE);
  130 + holder.tv_chatcontent.setVisibility(View.VISIBLE);
  131 + if (data.getContent().contains("href")) {
  132 + holder.tv_chatcontent = UrlUtils.handleHtmlText(holder.tv_chatcontent, data
  133 + .getContent());
  134 + } else {
  135 + holder.tv_chatcontent = UrlUtils.handleText(holder.tv_chatcontent, data
  136 + .getContent());
  137 + }
  138 + } else {
  139 + holder.tv_chatcontent.setVisibility(View.GONE);
  140 + holder.img_chatimage.setVisibility(View.VISIBLE);
  141 + }
  142 +
  143 + //如果是表情或图片,则不显示气泡,如果是图片则显示气泡
  144 + if (data.getType() != Message.MSG_TYPE_TEXT) {
  145 + holder.layout_content.setBackgroundResource(android.R.color.transparent);
  146 + } else {
  147 + if (data.getIsSend()) {
  148 + holder.layout_content.setBackgroundResource(R.drawable.chat_pop_send);
  149 + } else {
  150 + holder.layout_content.setBackgroundResource(R.drawable.chat_pop_receive);
  151 + }
  152 + }
  153 +
  154 + //显示头像
  155 + /*if (data.getIsSend()) {
  156 + kjb.display(holder.img_avatar, data.getFromUserAvatar());
  157 + } else {
  158 + kjb.display(holder.img_avatar, data.getToUserAvatar());
  159 + }*/
  160 + if (data.getIsSend()) {
  161 + XdyLogUtil.e("chatadapter getIsSend","hahhaahahhaahhhahaahahha");
  162 +// switch (AccountUtils.getUser().getUserRole()) {
  163 +// case "normal"://普通角色/学生
  164 +// if (!TextUtils.isEmpty(data.getFromUserName())) {
  165 +// holder.tv_name.setText(data.getFromUserName());
  166 +// } else {
  167 +// holder.tv_name.setText("学生");
  168 +// }
  169 +// holder.tv_teacher_bg.setVisibility(View.GONE);
  170 +// holder.img_avatar.setImageResource(R.mipmap.student);
  171 +// break;
  172 +// case "host"://主持人/老师
  173 +// if (TextUtils.isEmpty(data.getFromUserName())) {
  174 +// data.setFromUserName("老师");
  175 +// }
  176 +// holder.img_avatar.setImageResource(R.mipmap.teacher);
  177 +// holder.tv_name.setText(data.getFromUserName());
  178 +// holder.tv_teacher_bg.setVisibility(View.VISIBLE);
  179 +// break;
  180 +// case "presenter"://主讲人
  181 +// if (!TextUtils.isEmpty(data.getFromUserName())) {
  182 +// holder.tv_name.setText(data.getFromUserName());
  183 +// } else {
  184 +// holder.tv_name.setText("主讲人");
  185 +// }
  186 +// holder.tv_teacher_bg.setVisibility(View.GONE);
  187 +// holder.img_avatar.setImageResource(R.mipmap.student);
  188 +// break;
  189 +// case "assistant"://助教
  190 +// if (!TextUtils.isEmpty(data.getFromUserName())) {
  191 +// holder.tv_name.setText(data.getFromUserName());
  192 +// } else {
  193 +// holder.tv_name.setText("助教");
  194 +// }
  195 +// holder.tv_teacher_bg.setVisibility(View.GONE);
  196 +// holder.img_avatar.setImageResource(R.mipmap.student);
  197 +// break;
  198 +// case "record":// 暂时没用
  199 +// if (!TextUtils.isEmpty(data.getFromUserName())) {
  200 +// holder.tv_name.setText(data.getFromUserName());
  201 +// } else {
  202 +// holder.tv_name.setText("学生");
  203 +// }
  204 +// holder.tv_teacher_bg.setVisibility(View.GONE);
  205 +// holder.img_avatar.setImageResource(R.mipmap.student);
  206 +// break;
  207 +// }
  208 + }
  209 + else {
  210 + switch (data.getUserRole()) {
  211 + case "normal"://普通角色/学生
  212 + if (!TextUtils.isEmpty(data.getToUserName())) {
  213 + holder.tv_name.setText(data.getToUserName());
  214 + } else {
  215 + holder.tv_name.setText("学生");
  216 + }
  217 + holder.tv_teacher_bg.setVisibility(View.GONE);
  218 + holder.img_avatar.setImageResource(R.mipmap.student);
  219 + break;
  220 + case "host"://主持人/老师
  221 + if (TextUtils.isEmpty(data.getToUserName())) {
  222 + data.setToUserName("老师");
  223 + }
  224 + holder.tv_teacher_bg.setVisibility(View.VISIBLE);
  225 + holder.img_avatar.setImageResource(R.mipmap.teacher);
  226 + holder.tv_name.setText(data.getToUserName());
  227 + break;
  228 + case "presenter"://主讲人
  229 + if (!TextUtils.isEmpty(data.getToUserName())) {
  230 + holder.tv_name.setText(data.getToUserName());
  231 + } else {
  232 + holder.tv_name.setText("主讲人");
  233 + }
  234 + holder.tv_teacher_bg.setVisibility(View.GONE);
  235 + holder.img_avatar.setImageResource(R.mipmap.student);
  236 + break;
  237 + case "assistant"://助教
  238 + if (!TextUtils.isEmpty(data.getToUserName())) {
  239 + holder.tv_name.setText(data.getToUserName());
  240 + } else {
  241 + holder.tv_name.setText("助教");
  242 + }
  243 + holder.tv_teacher_bg.setVisibility(View.GONE);
  244 + holder.img_avatar.setImageResource(R.mipmap.student);
  245 + break;
  246 + case "record":// 暂时没用
  247 + if (!TextUtils.isEmpty(data.getToUserName())) {
  248 + holder.tv_name.setText(data.getToUserName());
  249 + } else {
  250 + holder.tv_name.setText("学生");
  251 + }
  252 + holder.tv_teacher_bg.setVisibility(View.GONE);
  253 + holder.img_avatar.setImageResource(R.mipmap.student);
  254 + break;
  255 + }
  256 + }
  257 +
  258 + if (listener != null) {
  259 + holder.tv_chatcontent.setOnClickListener(new View.OnClickListener() {
  260 + @Override
  261 + public void onClick(View v) {
  262 + listener.onTextClick(position);
  263 + }
  264 + });
  265 + holder.img_chatimage.setOnClickListener(new View.OnClickListener() {
  266 + @Override
  267 + public void onClick(View v) {
  268 + switch (data.getType()) {
  269 + case Message.MSG_TYPE_PHOTO:
  270 + listener.onPhotoClick(position);
  271 + break;
  272 + case Message.MSG_TYPE_FACE:
  273 + listener.onFaceClick(position);
  274 + break;
  275 + }
  276 + }
  277 + });
  278 + }
  279 +
  280 + //消息发送的状态
  281 + switch (data.getState()) {
  282 + case Message.MSG_STATE_FAIL:
  283 + holder.progress.setVisibility(View.GONE);
  284 + holder.img_sendfail.setVisibility(View.VISIBLE);
  285 + break;
  286 + case Message.MSG_STATE_SUCCESS:
  287 + holder.progress.setVisibility(View.GONE);
  288 + holder.img_sendfail.setVisibility(View.GONE);
  289 + break;
  290 + case Message.MSG_STATE_SENDING:
  291 + holder.progress.setVisibility(View.VISIBLE);
  292 + holder.img_sendfail.setVisibility(View.GONE);
  293 + break;
  294 + }
  295 + return v;
  296 + }
  297 +
  298 + static class ViewHolder {
  299 + TextView tv_date;
  300 + TextView tv_name;
  301 + TextView tv_teacher_bg;
  302 + ImageView img_avatar;
  303 + TextView tv_chatcontent;
  304 + ImageView img_chatimage;
  305 + ImageView img_sendfail;
  306 + ProgressBar progress;
  307 + RelativeLayout layout_content;
  308 + }
  309 +
  310 + private float sp2px(float spValue) {
  311 + final float scale = cxt.getResources().getDisplayMetrics().scaledDensity;
  312 + return spValue * scale;
  313 + }
  314 +}
@@ -18,8 +18,7 @@ import java.util.List; @@ -18,8 +18,7 @@ import java.util.List;
18 18
19 public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { 19 public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
20 20
21 - final int PAGE_COUNT = 1;  
22 - private String tabTitles[] = new String[]{"tab1","tab2"}; 21 + private String tabTitles[] = new String[]{"文档","聊天"};
23 private Context context; 22 private Context context;
24 private DocFragment docFragment=new DocFragment(); 23 private DocFragment docFragment=new DocFragment();
25 private ChatFragment chatFragment=new ChatFragment(); 24 private ChatFragment chatFragment=new ChatFragment();
@@ -33,7 +32,6 @@ public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { @@ -33,7 +32,6 @@ public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
33 32
34 @Override 33 @Override
35 public Fragment getItem(int position) { 34 public Fragment getItem(int position) {
36 -// return PageFragment.newInstance(position + 1);  
37 return fragmentList.get(position); 35 return fragmentList.get(position);
38 } 36 }
39 37
  1 +package com.mang.xdy.demo.base;
  2 +
  3 +import java.lang.ref.WeakReference;
  4 +
  5 +public abstract class BaseRunnable<T> implements Runnable {
  6 +
  7 + WeakReference<T> weakReference;
  8 +
  9 + public BaseRunnable() {
  10 +
  11 + }
  12 +
  13 + public BaseRunnable(T t) {
  14 + weakReference = new WeakReference<>(t);
  15 + }
  16 +
  17 + @Override
  18 + public void run() {
  19 + T t = null;
  20 + if (weakReference != null && (t = weakReference.get()) != null) {
  21 + handle(t);
  22 + } else {
  23 + handle(null);
  24 + }
  25 + }
  26 +
  27 + protected abstract void handle(T t);
  28 +}
  1 +package com.mang.xdy.demo.bean;
  2 +
  3 +/**
  4 + * Created by Admin on 2017/3/25.
  5 + */
  6 +
  7 +public class ChatMsgEntity {
  8 +
  9 + public String fromNodeId;
  10 + public String toNodeId;
  11 + public String message;
  12 + public String fromName;
  13 + public String fromRole;
  14 +}
1 package com.mang.xdy.demo.bean; 1 package com.mang.xdy.demo.bean;
2 2
  3 +import java.util.List;
  4 +
3 /** 5 /**
4 * Created by huang on 2017/4/9. 6 * Created by huang on 2017/4/9.
5 */ 7 */
6 8
7 public class DocEntity { 9 public class DocEntity {
8 10
  11 +
9 /** 12 /**
10 - * itemIdx : 749428394  
11 - * owner : 747132023  
12 - * from : 747132023 13 + * visible : true
  14 + * itemIdx : 48941765
  15 + * owner : 51346831
  16 + * from : 51346831
13 * curPageNo : 1 17 * curPageNo : 1
14 - * pageNum : 1  
15 - * fileType : jpg  
16 - * creatUserId : 0  
17 - * relativeUrl : /DocSharing/data/1087553281/20170409-204600041/d32594763768243bddc64934be5088a0.jpg  
18 - * url : 18 + * pageNum : 3
  19 + * fileType : pdf
  20 + * creatUserId : 968228008
  21 + * relativeUrl : /DocSharing/data/1299232248/example.swf
  22 + * url : http://127.0.0.1/DocSharing/data/1299232248/example.swf
19 * curV : 0 23 * curV : 0
20 * curH : 0 24 * curH : 0
21 * scale : 100 25 * scale : 100
22 - * visible : true  
23 - * action : 1  
24 - * docId : 8ab3b0ed5b4fb08d015b52bf009e0b7e  
25 - * fileName : 19462408_171130083000_2.jpg 26 + * action : 0
  27 + * docId : 8ab3b0ed5b5f23bc015b603b965d0552
  28 + * fileName : example.jpg
26 * dynamicTS : 0 29 * dynamicTS : 0
27 * md5 : 30 * md5 :
28 * showType : 0 31 * showType : 0
  32 + * images : ["http://127.0.0.1/DocSharing/data/1299232248/1.jpg","http://127.0.0.1/DocSharing/data/1299232248/2.jpg","http://127.0.0.1/DocSharing/data/1299232248/3.jpg"]
  33 + * pdf : http://127.0.0.1/DocSharing/data/1299232248/example.pdf
  34 + * html :
29 */ 35 */
30 36
  37 + private boolean visible;
31 private int itemIdx; 38 private int itemIdx;
32 private int owner; 39 private int owner;
33 private int from; 40 private int from;
@@ -40,13 +47,23 @@ public class DocEntity { @@ -40,13 +47,23 @@ public class DocEntity {
40 private int curV; 47 private int curV;
41 private int curH; 48 private int curH;
42 private int scale; 49 private int scale;
43 - private boolean visible;  
44 private int action; 50 private int action;
45 private String docId; 51 private String docId;
46 private String fileName; 52 private String fileName;
47 private String dynamicTS; 53 private String dynamicTS;
48 private String md5; 54 private String md5;
49 private int showType; 55 private int showType;
  56 + private String pdf;
  57 + private String html;
  58 + private List<String> images;
  59 +
  60 + public boolean isVisible() {
  61 + return visible;
  62 + }
  63 +
  64 + public void setVisible(boolean visible) {
  65 + this.visible = visible;
  66 + }
50 67
51 public int getItemIdx() { 68 public int getItemIdx() {
52 return itemIdx; 69 return itemIdx;
@@ -144,14 +161,6 @@ public class DocEntity { @@ -144,14 +161,6 @@ public class DocEntity {
144 this.scale = scale; 161 this.scale = scale;
145 } 162 }
146 163
147 - public boolean isVisible() {  
148 - return visible;  
149 - }  
150 -  
151 - public void setVisible(boolean visible) {  
152 - this.visible = visible;  
153 - }  
154 -  
155 public int getAction() { 164 public int getAction() {
156 return action; 165 return action;
157 } 166 }
@@ -199,4 +208,28 @@ public class DocEntity { @@ -199,4 +208,28 @@ public class DocEntity {
199 public void setShowType(int showType) { 208 public void setShowType(int showType) {
200 this.showType = showType; 209 this.showType = showType;
201 } 210 }
  211 +
  212 + public String getPdf() {
  213 + return pdf;
  214 + }
  215 +
  216 + public void setPdf(String pdf) {
  217 + this.pdf = pdf;
  218 + }
  219 +
  220 + public String getHtml() {
  221 + return html;
  222 + }
  223 +
  224 + public void setHtml(String html) {
  225 + this.html = html;
  226 + }
  227 +
  228 + public List<String> getImages() {
  229 + return images;
  230 + }
  231 +
  232 + public void setImages(List<String> images) {
  233 + this.images = images;
  234 + }
202 } 235 }
@@ -3,7 +3,7 @@ package com.mang.xdy.demo.bean; @@ -3,7 +3,7 @@ package com.mang.xdy.demo.bean;
3 /** 3 /**
4 * Created by abao on 2017/4/11. 4 * Created by abao on 2017/4/11.
5 */ 5 */
6 - 6 +@Deprecated
7 public class GetDocImageEntity { 7 public class GetDocImageEntity {
8 8
9 /** 9 /**
  1 +/*
  2 + * Copyright (c) 2015, 张涛.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package com.mang.xdy.demo.bean;
  17 +
  18 +/**
  19 + * 聊天消息javabean
  20 + *
  21 + * @author kymjs (http://www.kymjs.com/)
  22 + */
  23 +public class Message {
  24 + public final static int MSG_TYPE_TEXT = 3;
  25 + public final static int MSG_TYPE_PHOTO = 1;
  26 + public final static int MSG_TYPE_FACE = 2;
  27 +
  28 + public final static int MSG_STATE_SENDING = 3;
  29 + public final static int MSG_STATE_SUCCESS = 1;
  30 + public final static int MSG_STATE_FAIL = 2;
  31 +
  32 + private Long id;
  33 +
  34 +
  35 + private String userRole;
  36 + private int type; // 0-text | 1-photo | 2-face | more type ...
  37 + private int state; // 0-sending | 1-success | 2-fail
  38 + private String fromUserName;
  39 + private String fromUserAvatar;
  40 + private String toUserName;
  41 + private String toUserAvatar;
  42 + private String content;
  43 +
  44 + private Boolean isSend;
  45 + private Boolean sendSucces;
  46 + private String time;
  47 +
  48 + public Message(int type, int state, String userRole, String fromUserName,
  49 + String fromUserAvatar, String toUserName, String toUserAvatar,
  50 + String content, Boolean isSend, Boolean sendSucces, String time) {
  51 + super();
  52 + this.type = type;
  53 + this.state = state;
  54 + this.userRole=userRole;
  55 + this.fromUserName = fromUserName;
  56 + this.fromUserAvatar = fromUserAvatar;
  57 + this.toUserName = toUserName;
  58 + this.toUserAvatar = toUserAvatar;
  59 + this.content = content;
  60 + this.isSend = isSend;
  61 + this.sendSucces = sendSucces;
  62 + this.time = time;
  63 +
  64 + }
  65 +
  66 + public Long getId() {
  67 + return id;
  68 + }
  69 +
  70 + public void setId(Long id) {
  71 + this.id = id;
  72 + }
  73 +
  74 + public int getType() {
  75 + return type;
  76 + }
  77 +
  78 + public void setType(int type) {
  79 + this.type = type;
  80 + }
  81 +
  82 + public int getState() {
  83 + return state;
  84 + }
  85 +
  86 + public void setState(int state) {
  87 + this.state = state;
  88 + }
  89 +
  90 + public String getFromUserName() {
  91 + return fromUserName;
  92 + }
  93 +
  94 + public void setFromUserName(String fromUserName) {
  95 + this.fromUserName = fromUserName;
  96 + }
  97 +
  98 + public String getFromUserAvatar() {
  99 + return fromUserAvatar;
  100 + }
  101 +
  102 + public void setFromUserAvatar(String fromUserAvatar) {
  103 + this.fromUserAvatar = fromUserAvatar;
  104 + }
  105 +
  106 + public String getToUserName() {
  107 + return toUserName;
  108 + }
  109 +
  110 + public void setToUserName(String toUserName) {
  111 + this.toUserName = toUserName;
  112 + }
  113 +
  114 + public String getToUserAvatar() {
  115 + return toUserAvatar;
  116 + }
  117 +
  118 + public void setToUserAvatar(String toUserAvatar) {
  119 + this.toUserAvatar = toUserAvatar;
  120 + }
  121 +
  122 + public String getContent() {
  123 + return content;
  124 + }
  125 +
  126 + public void setContent(String content) {
  127 + this.content = content;
  128 + }
  129 +
  130 + public Boolean getIsSend() {
  131 + return isSend;
  132 + }
  133 +
  134 + public void setIsSend(Boolean isSend) {
  135 + this.isSend = isSend;
  136 + }
  137 +
  138 + public Boolean getSendSucces() {
  139 + return sendSucces;
  140 + }
  141 +
  142 + public void setSendSucces(Boolean sendSucces) {
  143 + this.sendSucces = sendSucces;
  144 + }
  145 +
  146 + public String getTime() {
  147 + return time;
  148 + }
  149 +
  150 + public void setTime(String time) {
  151 + this.time = time;
  152 + }
  153 +
  154 + public String getUserRole() {
  155 + return userRole;
  156 + }
  157 +
  158 + public void setUserRole(String userRole) {
  159 + this.userRole = userRole;
  160 + }
  161 +
  162 +
  163 +
  164 +
  165 +}
  1 +package com.mang.xdy.demo.bean;
  2 +
  3 +/**
  4 + * Created by abao on 2017/4/18.
  5 + */
  6 +
  7 +public class SendChatMsgEntity {
  8 +
  9 + /**
  10 + * message : Hello world!
  11 + * to : 0
  12 + */
  13 +
  14 + private String message;
  15 + private int to;
  16 +
  17 + public String getMessage() {
  18 + return message;
  19 + }
  20 +
  21 + public void setMessage(String message) {
  22 + this.message = message;
  23 + }
  24 +
  25 + public int getTo() {
  26 + return to;
  27 + }
  28 +
  29 + public void setTo(int to) {
  30 + this.to = to;
  31 + }
  32 +}
@@ -11,11 +11,32 @@ import android.view.LayoutInflater; @@ -11,11 +11,32 @@ import android.view.LayoutInflater;
11 import android.view.MotionEvent; 11 import android.view.MotionEvent;
12 import android.view.View; 12 import android.view.View;
13 import android.view.ViewGroup; 13 import android.view.ViewGroup;
  14 +import android.widget.ListView;
14 15
  16 +import com.google.gson.Gson;
  17 +import com.mang.xdy.common.Constants;
  18 +import com.mang.xdy.core.SPUtil;
  19 +import com.mang.xdy.core.XdySdk;
15 import com.mang.xdy.demo.R; 20 import com.mang.xdy.demo.R;
  21 +import com.mang.xdy.demo.activity.VideoPlayActivity;
  22 +import com.mang.xdy.demo.adapter.ChatAdapter;
  23 +import com.mang.xdy.demo.bean.ChatMsgEntity;
16 import com.mang.xdy.demo.bean.Faceicon; 24 import com.mang.xdy.demo.bean.Faceicon;
  25 +import com.mang.xdy.demo.bean.JoinClassBean;
  26 +import com.mang.xdy.demo.bean.JoinClassSuccessEntity;
  27 +import com.mang.xdy.demo.bean.Message;
  28 +import com.mang.xdy.demo.bean.SendChatMsgEntity;
  29 +import com.mang.xdy.demo.utils.JsonUtil;
17 import com.mang.xdy.demo.widget.chat.KJChatKeyboard; 30 import com.mang.xdy.demo.widget.chat.KJChatKeyboard;
18 import com.mang.xdy.demo.widget.chat.OnOperationListener; 31 import com.mang.xdy.demo.widget.chat.OnOperationListener;
  32 +import com.mang.xdy.demo.widget.emoji.DisplayRules;
  33 +import com.mang.xdy.listener.ObserverListener;
  34 +import com.mang.xdy.utils.XdyLogUtil;
  35 +import com.mang.xdy.utils.XdyStringUtils;
  36 +
  37 +import org.kymjs.kjframe.ui.ViewInject;
  38 +import org.kymjs.kjframe.utils.KJLoger;
  39 +import org.kymjs.kjframe.utils.StringUtils;
19 40
20 import java.io.File; 41 import java.io.File;
21 import java.math.MathContext; 42 import java.math.MathContext;
@@ -29,10 +50,17 @@ import butterknife.ButterKnife; @@ -29,10 +50,17 @@ import butterknife.ButterKnife;
29 * Created by abao on 2017/4/17. 50 * Created by abao on 2017/4/17.
30 */ 51 */
31 52
32 -public class ChatFragment extends Fragment { 53 +public class ChatFragment extends Fragment implements ObserverListener{
33 @BindView(R.id.chat_msg_input_box) 54 @BindView(R.id.chat_msg_input_box)
34 KJChatKeyboard box; 55 KJChatKeyboard box;
  56 + @BindView(R.id.chat_listview)
  57 + ListView mListView;
35 private Context mContext; 58 private Context mContext;
  59 + private String TAG=this.getClass().getSimpleName();
  60 + private boolean replay=false;
  61 + private ChatAdapter adapter;
  62 + List<Message> datas = new ArrayList<Message>();
  63 + private XdySdk xdySdk;
36 @Nullable 64 @Nullable
37 @Override 65 @Override
38 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 66 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -45,7 +73,10 @@ public class ChatFragment extends Fragment { @@ -45,7 +73,10 @@ public class ChatFragment extends Fragment {
45 public void onActivityCreated(@Nullable Bundle savedInstanceState) { 73 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
46 super.onActivityCreated(savedInstanceState); 74 super.onActivityCreated(savedInstanceState);
47 mContext=this.getContext(); 75 mContext=this.getContext();
  76 + xdySdk=XdySdk.getXdyInstance();
  77 + xdySdk.add(this);
48 init(); 78 init();
  79 + initData();
49 } 80 }
50 81
51 public void init(){ 82 public void init(){
@@ -56,6 +87,7 @@ public class ChatFragment extends Fragment { @@ -56,6 +87,7 @@ public class ChatFragment extends Fragment {
56 if (!TextUtils.isEmpty(content)) { 87 if (!TextUtils.isEmpty(content)) {
57 // LogUtil.i("聊天内容===" + content); 88 // LogUtil.i("聊天内容===" + content);
58 // mPresenter.sendChatMsg(content, 0); 89 // mPresenter.sendChatMsg(content, 0);
  90 + sendMeg(content);
59 } 91 }
60 92
61 } 93 }
@@ -88,7 +120,7 @@ public class ChatFragment extends Fragment { @@ -88,7 +120,7 @@ public class ChatFragment extends Fragment {
88 120
89 @Override 121 @Override
90 public void selectedBackSpace(String back) { 122 public void selectedBackSpace(String back) {
91 -// DisplayRules.backspace(box.getEditTextBox()); 123 + DisplayRules.backspace(box.getEditTextBox());
92 } 124 }
93 125
94 @Override 126 @Override
@@ -116,11 +148,96 @@ public class ChatFragment extends Fragment { @@ -116,11 +148,96 @@ public class ChatFragment extends Fragment {
116 } 148 }
117 149
118 box.setFaceData(faceCagegory); 150 box.setFaceData(faceCagegory);
119 -// mRealListView.setOnTouchListener(getOnTouchListener()); 151 + mListView.setOnTouchListener(getOnTouchListener());
120 } 152 }
121 153
  154 + protected void initData() {
  155 + adapter = new ChatAdapter(mContext, datas, getOnChatItemClickListener());
  156 + mListView.setAdapter(adapter);
  157 + }
  158 + /**
  159 + * @return 聊天列表内存点击事件监听器
  160 + */
  161 + private OnChatItemClickListener getOnChatItemClickListener() {
  162 + return new OnChatItemClickListener() {
  163 + @Override
  164 + public void onPhotoClick(int position) {
  165 + KJLoger.debug(datas.get(position).getContent() + "点击图片的");
  166 + ViewInject.toast(mContext, datas.get(position).getContent() + "点击图片的");
  167 + }
  168 +
  169 + @Override
  170 + public void onTextClick(int position) {
  171 + }
  172 +
  173 + @Override
  174 + public void onFaceClick(int position) {
  175 + }
  176 + };
  177 + }
  178 +
  179 + private String oldTime;
  180 + private String time;
  181 + public void renderChatMsg(String response) {
  182 + ChatMsgEntity entity= JsonUtil.parseJsonToBean(response,ChatMsgEntity.class);
  183 + JoinClassSuccessEntity joinClassSuccessEntity=JsonUtil.parseJsonToBean(SPUtil.getString(mContext,Constants.CLASS_JOIN_SUCCESS,""),JoinClassSuccessEntity.class);
  184 + String nodeId="";
  185 + if(joinClassSuccessEntity!=null) {
  186 + nodeId = joinClassSuccessEntity.getNodeId() + "";
  187 + }
  188 + if (entity != null && adapter != null) {
  189 + Message message;
  190 + String dataTime = StringUtils.getDataTime("HH:mm");
  191 +
  192 + if (entity.fromNodeId.equals(nodeId)) {
  193 + if (TextUtils.isEmpty(oldTime)) {
  194 + time = oldTime = dataTime;
  195 + } else if (dataTime.equals(oldTime)) {
  196 + time = null;
  197 + } else {
  198 + time = oldTime = dataTime;
  199 + }
  200 + message = new Message(Message.MSG_TYPE_TEXT, Message.MSG_STATE_SUCCESS, entity.fromRole,
  201 + entity.fromName, "", "",
  202 + "", entity.message, true, true, replay ? null : time);
  203 + datas.add(message);
  204 + adapter.refresh(datas);
  205 + mListView.setSelection(adapter.getCount() - 1);
  206 + } else {
  207 + XdyLogUtil.e("返回的聊天内容===" + entity.message);
  208 + if (TextUtils.isEmpty(oldTime)) {
  209 + time = oldTime = dataTime;
  210 + } else if (dataTime.equals(oldTime)) {
  211 + time = null;
  212 + } else {
  213 + time = oldTime = dataTime;
  214 + }
  215 + message = new Message(Message.MSG_TYPE_TEXT, Message.MSG_STATE_SUCCESS, entity.fromRole, "",
  216 + "", entity.fromName, "", entity.message, false,
  217 + true, replay ? null : time);
  218 + datas.add(message);
  219 + adapter.refresh(datas);
  220 + mListView.setSelection(adapter.getCount() - 1);
  221 +
  222 + }
  223 + }
  224 +
  225 + }
122 226
123 /** 227 /**
  228 + * 发送聊天消息
  229 + * @param chatmsg
  230 + */
  231 + public void sendMeg(String chatmsg) {
  232 + SendChatMsgEntity sendChatMsgEntity=new SendChatMsgEntity();
  233 + sendChatMsgEntity.setMessage(chatmsg);
  234 + sendChatMsgEntity.setTo(0);
  235 + String jsonParmp=new Gson().toJson(sendChatMsgEntity);
  236 + XdyLogUtil.e(TAG, "聊天" + jsonParmp);
  237 + xdySdk.api("sendChatMsg", jsonParmp);
  238 +
  239 + }
  240 + /**
124 * 若软键盘或表情键盘弹起,点击上端空白处应该隐藏输入法键盘 241 * 若软键盘或表情键盘弹起,点击上端空白处应该隐藏输入法键盘
125 * 242 *
126 * @return 会隐藏输入法键盘的触摸事件监听器 243 * @return 会隐藏输入法键盘的触摸事件监听器
@@ -135,4 +252,25 @@ public class ChatFragment extends Fragment { @@ -135,4 +252,25 @@ public class ChatFragment extends Fragment {
135 } 252 }
136 }; 253 };
137 } 254 }
  255 +
  256 +
  257 + @Override
  258 + public void observerUpData(String type, String parameter) {
  259 + switch (type) {
  260 + case Constants.CHAT_RECEIVE_MESSAGE:
  261 + renderChatMsg(parameter);
  262 + break;
  263 + }
  264 + }
  265 +
  266 + /**
  267 + * 聊天列表中对内容的点击事件监听
  268 + */
  269 + public interface OnChatItemClickListener {
  270 + void onPhotoClick(int position);
  271 +
  272 + void onTextClick(int position);
  273 +
  274 + void onFaceClick(int position);
  275 + }
138 } 276 }
@@ -8,6 +8,7 @@ import android.os.Handler; @@ -8,6 +8,7 @@ import android.os.Handler;
8 import android.os.Message; 8 import android.os.Message;
9 import android.support.annotation.Nullable; 9 import android.support.annotation.Nullable;
10 import android.support.v4.app.Fragment; 10 import android.support.v4.app.Fragment;
  11 +import android.util.DisplayMetrics;
11 import android.view.LayoutInflater; 12 import android.view.LayoutInflater;
12 import android.view.View; 13 import android.view.View;
13 import android.view.ViewGroup; 14 import android.view.ViewGroup;
@@ -18,11 +19,14 @@ import com.mang.xdy.common.Constants; @@ -18,11 +19,14 @@ import com.mang.xdy.common.Constants;
18 import com.mang.xdy.core.XdySdk; 19 import com.mang.xdy.core.XdySdk;
19 import com.mang.xdy.demo.R; 20 import com.mang.xdy.demo.R;
20 import com.mang.xdy.demo.activity.VideoPlayActivity; 21 import com.mang.xdy.demo.activity.VideoPlayActivity;
  22 +import com.mang.xdy.demo.base.BaseRunnable;
21 import com.mang.xdy.demo.bean.DocEntity; 23 import com.mang.xdy.demo.bean.DocEntity;
22 import com.mang.xdy.demo.bean.GetDocImageEntity; 24 import com.mang.xdy.demo.bean.GetDocImageEntity;
23 import com.mang.xdy.demo.bean.WhiteboardUpdateEntity; 25 import com.mang.xdy.demo.bean.WhiteboardUpdateEntity;
24 import com.mang.xdy.demo.utils.JsonUtil; 26 import com.mang.xdy.demo.utils.JsonUtil;
  27 +import com.mang.xdy.demo.utils.ToastUtil;
25 import com.mang.xdy.demo.widget.CanvasView; 28 import com.mang.xdy.demo.widget.CanvasView;
  29 +import com.mang.xdy.listener.ObserverListener;
26 import com.mang.xdy.utils.XdyLogUtil; 30 import com.mang.xdy.utils.XdyLogUtil;
27 import com.mang.xdy.utils.XdyStringUtils; 31 import com.mang.xdy.utils.XdyStringUtils;
28 import com.squareup.picasso.Picasso; 32 import com.squareup.picasso.Picasso;
@@ -36,26 +40,32 @@ import butterknife.ButterKnife; @@ -36,26 +40,32 @@ import butterknife.ButterKnife;
36 * Created by abao on 2017/4/14. 40 * Created by abao on 2017/4/14.
37 */ 41 */
38 42
39 -public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptFromCoreToFragmentListener{ 43 +public class DocFragment extends Fragment implements ObserverListener{
40 private static String TAG="DocFragment"; 44 private static String TAG="DocFragment";
41 @BindView(R.id.canvas_doc_show) 45 @BindView(R.id.canvas_doc_show)
42 CanvasView mCanvasView; 46 CanvasView mCanvasView;
43 private Bitmap bitmap; 47 private Bitmap bitmap;
44 private Context mContext; 48 private Context mContext;
45 private String whritebroad=""; 49 private String whritebroad="";
  50 + private XdySdk xdySdk;
  51 + int winWidth;
  52 + int winHeight;
  53 + private long intervalTime;
46 54
47 @Override 55 @Override
48 public void onActivityCreated(@Nullable Bundle savedInstanceState) { 56 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
49 super.onActivityCreated(savedInstanceState); 57 super.onActivityCreated(savedInstanceState);
  58 + xdySdk=XdySdk.getXdyInstance();
  59 + xdySdk.add(this);
50 init(); 60 init();
51 mContext=this.getContext(); 61 mContext=this.getContext();
52 } 62 }
53 63
54 - private static Handler mHandler=new Handler(){ 64 + private Handler mHandler=new Handler(){
55 @Override 65 @Override
56 public void handleMessage(Message msg) { 66 public void handleMessage(Message msg) {
57 super.handleMessage(msg); 67 super.handleMessage(msg);
58 - 68 + ToastUtil.showToastshort("图片加载失败",mContext);
59 } 69 }
60 }; 70 };
61 71
@@ -67,36 +77,40 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF @@ -67,36 +77,40 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF
67 return view; 77 return view;
68 } 78 }
69 79
  80 +
70 public void init(){ 81 public void init(){
71 - VideoPlayActivity videoPlayActivity= (VideoPlayActivity) this.getActivity(); 82 + DisplayMetrics metric = new DisplayMetrics();
  83 + getWindowWith(metric);
72 mCanvasView.setBitmap(getEmptyBitmap(),false); 84 mCanvasView.setBitmap(getEmptyBitmap(),false);
73 - videoPlayActivity.setmOnAcceptFromCoreToFragmentListener(this);  
74 -  
75 } 85 }
76 86
  87 + private void getWindowWith(DisplayMetrics metric) {
  88 + this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metric);
  89 + winWidth = metric.widthPixels; // 屏幕宽度(像素)
  90 + winHeight = metric.heightPixels; // 屏幕高度(像素)
  91 + XdyLogUtil.e(TAG,"获取屏幕的宽:"+winWidth+":"+mCanvasView.getWidth()+" 获取屏幕的高:"+winHeight);
  92 + }
77 93
  94 + /**
  95 + * 获取文档
  96 + * @param response
  97 + */
78 public void getDoc(String response) { 98 public void getDoc(String response) {
79 DocEntity docEntity = JsonUtil.parseJsonToBean(response, DocEntity.class); 99 DocEntity docEntity = JsonUtil.parseJsonToBean(response, DocEntity.class);
80 - if (docEntity != null && docEntity.getRelativeUrl() != null) {  
81 - String url = docEntity.getRelativeUrl();  
82 - GetDocImageEntity getDocImageEntity=new GetDocImageEntity();  
83 - getDocImageEntity.setPageNum(1);  
84 -// getDocImageEntity.setRelativeUrl("/DocSharing/data/1087553281/20170409-204600041/d32594763768243bddc64934be5088a0.swf");  
85 - getDocImageEntity.setRelativeUrl(url);  
86 - getDocImageEntity.setType("jpg");  
87 - String jsonParmp = new Gson().toJson(getDocImageEntity);  
88 - XdyLogUtil.e(TAG, "文档" + jsonParmp);  
89 - XdySdk.api("getDocImageFullPath", jsonParmp); 100 + if (docEntity != null && docEntity.getImages()!= null&&docEntity.getImages().size()>=1) {
  101 + //默认显示第一张
  102 + setDocImage(docEntity.getImages().get(0));
  103 + }else{
  104 + mHandler.sendEmptyMessage(0);
90 } 105 }
91 } 106 }
92 107
93 - public void setDocImage(String resonse){  
94 - if(resonse.length()>10){  
95 - String temp= XdyStringUtils.stringToJson(resonse);  
96 - String url=temp.substring(2,temp.length()-2);  
97 - XdyLogUtil.e(TAG,"截取后的"+url); 108 + /**
  109 + * 设置图片
  110 + * @param url
  111 + */
  112 + public void setDocImage(String url){
98 getBitmap(url); 113 getBitmap(url);
99 - }  
100 } 114 }
101 115
102 public void getBitmap(final String url){ 116 public void getBitmap(final String url){
@@ -105,12 +119,13 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF @@ -105,12 +119,13 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF
105 public void run() { 119 public void run() {
106 super.run(); 120 super.run();
107 try { 121 try {
108 - bitmap= Glide.with(mContext).load(url).asBitmap().into(480,480).get(); 122 + bitmap= Glide.with(mContext).load(url).asBitmap().centerCrop() .into(winWidth,winWidth).get();
109 if(bitmap!=null) { 123 if(bitmap!=null) {
110 mHandler.post(new Runnable() { 124 mHandler.post(new Runnable() {
111 @Override 125 @Override
112 public void run() { 126 public void run() {
113 - mCanvasView.setBitmap(bitmap,false); 127 + mCanvasView.setZOrderMediaOverlay(true);
  128 + mCanvasView.setBitmap(bitmap,true);
114 } 129 }
115 }); 130 });
116 131
@@ -129,30 +144,41 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF @@ -129,30 +144,41 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF
129 * @param response 144 * @param response
130 */ 145 */
131 public void showDoc(String type,String response){ 146 public void showDoc(String type,String response){
132 - mCanvasView.setZOrderMediaOverlay(true);  
133 147
134 - if(bitmap!=null) {  
135 - mCanvasView.setBitmap(bitmap,false);  
136 - }  
137 -// else{  
138 -// mCanvasView.setBitmap(getEmptyBitmap(),false);  
139 -// }  
140 WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class); 148 WhiteboardUpdateEntity whiteboardUpdateEntity= JsonUtil.parseJsonToBean(response,WhiteboardUpdateEntity.class);
141 if(whiteboardUpdateEntity!=null){ 149 if(whiteboardUpdateEntity!=null){
142 - drawline(whiteboardUpdateEntity);  
143 - 150 + mCanvasView.setZOrderMediaOverlay(true);
  151 +
  152 +// if(bitmap!=null) {
  153 +// mCanvasView.setBitmap(bitmap,!whiteboardUpdateEntity.isFresh);
  154 +// }
  155 + if (intervalTime != 0) {
  156 + intervalTime = System.currentTimeMillis() - intervalTime;
  157 + if (intervalTime < 150) {//小于100毫秒 不执行?
  158 + mHandler.removeCallbacksAndMessages(null);
  159 + }
  160 + delayDraw(whiteboardUpdateEntity);
  161 + } else {
  162 + delayDraw(whiteboardUpdateEntity);
  163 + }
  164 + intervalTime = System.currentTimeMillis();
144 } 165 }
145 166
146 } 167 }
  168 + private void delayDraw(final WhiteboardUpdateEntity entity) {
  169 + mHandler.postDelayed(new BaseRunnable<WhiteboardUpdateEntity>() {
  170 +
  171 + @Override
  172 + protected void handle(WhiteboardUpdateEntity o) {
  173 + drawline(entity);
  174 + }
  175 + }, 200);
  176 + }
147 public Bitmap getEmptyBitmap(){ 177 public Bitmap getEmptyBitmap(){
148 Bitmap bitmap_empty= BitmapFactory.decodeResource(getResources(),R.mipmap.no_doc); 178 Bitmap bitmap_empty= BitmapFactory.decodeResource(getResources(),R.mipmap.no_doc);
149 -  
150 return bitmap_empty; 179 return bitmap_empty;
151 } 180 }
152 181
153 -  
154 -  
155 -  
156 private void drawline(WhiteboardUpdateEntity o) { 182 private void drawline(WhiteboardUpdateEntity o) {
157 if (o != null) { 183 if (o != null) {
158 if (o.isFresh) { 184 if (o.isFresh) {
@@ -169,19 +195,18 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF @@ -169,19 +195,18 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF
169 } 195 }
170 } 196 }
171 197
172 -  
173 @Override 198 @Override
174 - public void onAcceptInfo(String type, String response) {  
175 - XdyLogUtil.e(TAG,"type:"+type+" response:"+response); 199 + public void observerUpData(String type, String parameter) {
  200 + XdyLogUtil.e(TAG,"type:"+type+" response:"+parameter);
176 switch (type){ 201 switch (type){
177 case Constants.DOCUMENT_UPDATE: 202 case Constants.DOCUMENT_UPDATE:
178 - getDoc(response);  
179 - break;  
180 - case "getDocImageFullPath":  
181 - setDocImage(response); 203 + getDoc(parameter);
182 break; 204 break;
  205 +// case "getDocImageFullPath":
  206 +// setDocImage(parameter);
  207 +// break;
183 case Constants.WHITEBOARD_ANNOTATION_UPDATE: 208 case Constants.WHITEBOARD_ANNOTATION_UPDATE:
184 - showDoc(type,response); 209 + showDoc(type,parameter);
185 break; 210 break;
186 case Constants.DOCUMENT_DELETE: 211 case Constants.DOCUMENT_DELETE:
187 bitmap=null; 212 bitmap=null;
@@ -190,4 +215,9 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF @@ -190,4 +215,9 @@ public class DocFragment extends Fragment implements VideoPlayActivity.OnAcceptF
190 215
191 } 216 }
192 } 217 }
  218 + @Override
  219 + public void onDestroyView() {
  220 + super.onDestroyView();
  221 + mHandler.removeCallbacksAndMessages(null);
  222 + }
193 } 223 }
  1 +/**
  2 + * Licensed under the Apache License, Version 2.0 (the "License");
  3 + * you may not use this file except in compliance with the License.
  4 + * You may obtain a copy of the License at
  5 + * <p/>
  6 + * http://www.apache.org/licenses/LICENSE-2.0
  7 + * <p/>
  8 + * Unless required by applicable law or agreed to in writing, software
  9 + * distributed under the License is distributed on an "AS IS" BASIS,
  10 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11 + * See the License for the specific language governing permissions and
  12 + * limitations under the License.
  13 + */
  14 +package com.mang.xdy.demo.utils.cache;
  15 +
  16 +import android.content.Context;
  17 +import android.graphics.Bitmap;
  18 +import android.graphics.BitmapFactory;
  19 +import android.graphics.Canvas;
  20 +import android.graphics.PixelFormat;
  21 +import android.graphics.drawable.BitmapDrawable;
  22 +import android.graphics.drawable.Drawable;
  23 +import android.text.TextUtils;
  24 +
  25 +import org.json.JSONArray;
  26 +import org.json.JSONObject;
  27 +
  28 +import java.io.BufferedReader;
  29 +import java.io.BufferedWriter;
  30 +import java.io.ByteArrayInputStream;
  31 +import java.io.ByteArrayOutputStream;
  32 +import java.io.File;
  33 +import java.io.FileInputStream;
  34 +import java.io.FileNotFoundException;
  35 +import java.io.FileOutputStream;
  36 +import java.io.FileReader;
  37 +import java.io.FileWriter;
  38 +import java.io.IOException;
  39 +import java.io.InputStream;
  40 +import java.io.ObjectInputStream;
  41 +import java.io.ObjectOutputStream;
  42 +import java.io.OutputStream;
  43 +import java.io.RandomAccessFile;
  44 +import java.io.Serializable;
  45 +import java.util.Collections;
  46 +import java.util.HashMap;
  47 +import java.util.Map;
  48 +import java.util.Map.Entry;
  49 +import java.util.Set;
  50 +import java.util.concurrent.atomic.AtomicInteger;
  51 +import java.util.concurrent.atomic.AtomicLong;
  52 +
  53 +public class ACache implements ICache {
  54 + public static final int TIME_HOUR = 60 * 60;
  55 + public static final int TIME_DAY = TIME_HOUR * 24;
  56 + private static final int MAX_SIZE = 1000 * 1000 * 50; // 50 mb
  57 + private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量
  58 + private static Map<String, ICache> mInstanceMap = new HashMap<String, ICache>();
  59 + private ACacheManager mCache;
  60 +
  61 + public static ICache get(Context ctx) {
  62 + return get(ctx, "ACache");
  63 + }
  64 +
  65 + public static ICache get(Context ctx, String cacheName) {
  66 + File f = new File(ctx.getCacheDir(), cacheName);
  67 + return get(f, MAX_SIZE, MAX_COUNT);
  68 + }
  69 +
  70 + public static ICache get(File cacheDir) {
  71 + return get(cacheDir, MAX_SIZE, MAX_COUNT);
  72 + }
  73 +
  74 + public static ICache get(Context ctx, long max_zise, int max_count) {
  75 + File f = new File(ctx.getCacheDir(), "ACache");
  76 + return get(f, max_zise, max_count);
  77 + }
  78 +
  79 + public static ICache get(File cacheDir, long max_zise, int max_count) {
  80 + ICache manager = mInstanceMap.get(cacheDir.getAbsoluteFile() + myPid());
  81 + if (manager == null) {
  82 + manager = new ACache(cacheDir, max_zise, max_count);
  83 + mInstanceMap.put(cacheDir.getAbsolutePath() + myPid(), manager);
  84 + }
  85 + return manager;
  86 + }
  87 +
  88 + private static String myPid() {
  89 + return "_" + android.os.Process.myPid();
  90 + }
  91 +
  92 + private ACache(File cacheDir, long max_size, int max_count) {
  93 + if (!cacheDir.exists() && !cacheDir.mkdirs()) {
  94 + throw new RuntimeException("can't make dirs in "
  95 + + cacheDir.getAbsolutePath());
  96 + }
  97 + mCache = new ACacheManager(cacheDir, max_size, max_count);
  98 + }
  99 +
  100 + /**
  101 + * Provides a means to save a cached file before the data are available.
  102 + * Since writing about the file is complete, and its close method is called,
  103 + * its contents will be registered in the cache. Example of use:
  104 + * <p/>
  105 + * ACache cache = new ACache(this) try { OutputStream stream =
  106 + * cache.put("myFileName") stream.write("some bytes".getBytes()); // now
  107 + * update cache! stream.close(); } catch(FileNotFoundException e){
  108 + * e.printStackTrace() }
  109 + */
  110 + class xFileOutputStream extends FileOutputStream {
  111 + File file;
  112 +
  113 + public xFileOutputStream(File file) throws FileNotFoundException {
  114 + super(file);
  115 + this.file = file;
  116 + }
  117 +
  118 + public void close() throws IOException {
  119 + super.close();
  120 + mCache.put(file);
  121 + }
  122 + }
  123 +
  124 + // =======================================
  125 + // ============ String数据 读写 ==============
  126 + // =======================================
  127 +
  128 + /**
  129 + * 保存 String数据 到 缓存中
  130 + *
  131 + * @param key 保存的key
  132 + * @param value 保存的String数据
  133 + */
  134 + @Override
  135 + public void put(String key, String value) {
  136 + if (TextUtils.isEmpty(value))//不允许有空值出现
  137 + return;
  138 +
  139 + File file = mCache.newFile(key);
  140 +
  141 + BufferedWriter out = null;
  142 + try {
  143 + if(!file.exists()){
  144 + file.createNewFile();
  145 + }
  146 + out = new BufferedWriter(new FileWriter(file), 1024);
  147 + out.write(value);
  148 + } catch (IOException e) {
  149 + e.printStackTrace();
  150 + } finally {
  151 + if (out != null) {
  152 + try {
  153 + out.flush();
  154 + out.close();
  155 + } catch (IOException e) {
  156 + e.printStackTrace();
  157 + }
  158 + }
  159 + mCache.put(file);
  160 + }
  161 + }
  162 +
  163 + /**
  164 + * 保存 String数据 到 缓存中
  165 + *
  166 + * @param key 保存的key
  167 + * @param value 保存的String数据
  168 + * @param saveTime 保存的时间,单位:秒
  169 + */
  170 + @Override
  171 + public void put(String key, String value, int saveTime) {
  172 + put(key, Utils.newStringWithDateInfo(saveTime, value));
  173 + }
  174 +
  175 + /**
  176 + * 读取 String数据
  177 + *
  178 + * @param key
  179 + * @return String 数据
  180 + */
  181 + @Override
  182 + public String getAsString(String key) {
  183 + File file = mCache.get(key);
  184 + if (!file.exists())
  185 + return null;
  186 + boolean removeFile = false;
  187 + BufferedReader in = null;
  188 + try {
  189 + in = new BufferedReader(new FileReader(file));
  190 + String readString = "";
  191 + String currentLine;
  192 + while ((currentLine = in.readLine()) != null) {
  193 + readString += currentLine;
  194 + }
  195 + if (!Utils.isDue(readString)) {
  196 + return Utils.clearDateInfo(readString);
  197 + } else {
  198 + removeFile = true;
  199 + return null;
  200 + }
  201 + } catch (IOException e) {
  202 + e.printStackTrace();
  203 + return null;
  204 + } finally {
  205 + if (in != null) {
  206 + try {
  207 + in.close();
  208 + } catch (IOException e) {
  209 + e.printStackTrace();
  210 + }
  211 + }
  212 + if (removeFile)
  213 + remove(key);
  214 + }
  215 + }
  216 +
  217 + // =======================================
  218 + // ============= JSONObject 数据 读写 ==============
  219 + // =======================================
  220 +
  221 + /**
  222 + * 保存 JSONObject数据 到 缓存中
  223 + *
  224 + * @param key 保存的key
  225 + * @param value 保存的JSON数据
  226 + */
  227 + @Override
  228 + public void put(String key, JSONObject value) {
  229 + put(key, value.toString());
  230 + }
  231 +
  232 + /**
  233 + * 保存 JSONObject数据 到 缓存中
  234 + *
  235 + * @param key 保存的key
  236 + * @param value 保存的JSONObject数据
  237 + * @param saveTime 保存的时间,单位:秒
  238 + */
  239 + @Override
  240 + public void put(String key, JSONObject value, int saveTime) {
  241 + put(key, value.toString(), saveTime);
  242 + }
  243 +
  244 + /**
  245 + * 读取JSONObject数据
  246 + *
  247 + * @param key
  248 + * @return JSONObject数据
  249 + */
  250 + @Override
  251 + public JSONObject getAsJSONObject(String key) {
  252 + String JSONString = getAsString(key);
  253 + try {
  254 + JSONObject obj = new JSONObject(JSONString);
  255 + return obj;
  256 + } catch (Exception e) {
  257 + e.printStackTrace();
  258 + return null;
  259 + }
  260 + }
  261 +
  262 + // =======================================
  263 + // ============ JSONArray 数据 读写 =============
  264 + // =======================================
  265 +
  266 + /**
  267 + * 保存 JSONArray数据 到 缓存中
  268 + *
  269 + * @param key 保存的key
  270 + * @param value 保存的JSONArray数据
  271 + */
  272 + @Override
  273 + public void put(String key, JSONArray value) {
  274 + put(key, value.toString());
  275 + }
  276 +
  277 + /**
  278 + * 保存 JSONArray数据 到 缓存中
  279 + *
  280 + * @param key 保存的key
  281 + * @param value 保存的JSONArray数据
  282 + * @param saveTime 保存的时间,单位:秒
  283 + */
  284 + @Override
  285 + public void put(String key, JSONArray value, int saveTime) {
  286 + put(key, value.toString(), saveTime);
  287 + }
  288 +
  289 + /**
  290 + * 读取JSONArray数据
  291 + *
  292 + * @param key
  293 + * @return JSONArray数据
  294 + */
  295 + @Override
  296 + public JSONArray getAsJSONArray(String key) {
  297 + String JSONString = getAsString(key);
  298 + try {
  299 + JSONArray obj = new JSONArray(JSONString);
  300 + return obj;
  301 + } catch (Exception e) {
  302 + e.printStackTrace();
  303 + return null;
  304 + }
  305 + }
  306 +
  307 + // =======================================
  308 + // ============== byte 数据 读写 =============
  309 + // =======================================
  310 +
  311 + /**
  312 + * 保存 byte数据 到 缓存中
  313 + *
  314 + * @param key 保存的key
  315 + * @param value 保存的数据
  316 + */
  317 + @Override
  318 + public void put(String key, byte[] value) {
  319 + File file = mCache.newFile(key);
  320 + FileOutputStream out = null;
  321 + try {
  322 + out = new FileOutputStream(file);
  323 + out.write(value);
  324 + } catch (Exception e) {
  325 + e.printStackTrace();
  326 + } finally {
  327 + if (out != null) {
  328 + try {
  329 + out.flush();
  330 + out.close();
  331 + } catch (IOException e) {
  332 + e.printStackTrace();
  333 + }
  334 + }
  335 + mCache.put(file);
  336 + }
  337 + }
  338 +
  339 + /**
  340 + * Cache for a stream
  341 + *
  342 + * @param key the file name.
  343 + * @return OutputStream stream for writing data.
  344 + * @throws FileNotFoundException if the file can not be created.
  345 + */
  346 + @Override
  347 + public OutputStream put(String key) throws FileNotFoundException {
  348 + return new xFileOutputStream(mCache.newFile(key));
  349 + }
  350 +
  351 + /**
  352 + * @param key the file name.
  353 + * @return (InputStream or null) stream previously saved in cache.
  354 + * @throws FileNotFoundException if the file can not be opened
  355 + */
  356 + @Override
  357 + public InputStream get(String key) throws FileNotFoundException {
  358 + File file = mCache.get(key);
  359 + if (!file.exists())
  360 + return null;
  361 + return new FileInputStream(file);
  362 + }
  363 +
  364 + /**
  365 + * 保存 byte数据 到 缓存中
  366 + *
  367 + * @param key 保存的key
  368 + * @param value 保存的数据
  369 + * @param saveTime 保存的时间,单位:秒
  370 + */
  371 + @Override
  372 + public void put(String key, byte[] value, int saveTime) {
  373 + put(key, Utils.newByteArrayWithDateInfo(saveTime, value));
  374 + }
  375 +
  376 + /**
  377 + * 获取 byte 数据
  378 + *
  379 + * @param key
  380 + * @return byte 数据
  381 + */
  382 + @Override
  383 + public byte[] getAsBinary(String key) {
  384 + RandomAccessFile RAFile = null;
  385 + boolean removeFile = false;
  386 + try {
  387 + File file = mCache.get(key);
  388 + if (!file.exists())
  389 + return null;
  390 + RAFile = new RandomAccessFile(file, "r");
  391 + byte[] byteArray = new byte[(int) RAFile.length()];
  392 + RAFile.read(byteArray);
  393 + if (!Utils.isDue(byteArray)) {
  394 + return Utils.clearDateInfo(byteArray);
  395 + } else {
  396 + removeFile = true;
  397 + return null;
  398 + }
  399 + } catch (Exception e) {
  400 + e.printStackTrace();
  401 + return null;
  402 + } finally {
  403 + if (RAFile != null) {
  404 + try {
  405 + RAFile.close();
  406 + } catch (IOException e) {
  407 + e.printStackTrace();
  408 + }
  409 + }
  410 + if (removeFile)
  411 + remove(key);
  412 + }
  413 + }
  414 +
  415 + // =======================================
  416 + // ============= 序列化 数据 读写 ===============
  417 + // =======================================
  418 +
  419 + /**
  420 + * 保存 Serializable数据 到 缓存中
  421 + *
  422 + * @param key 保存的key
  423 + * @param value 保存的value
  424 + */
  425 + @Override
  426 + public void put(String key, Serializable value) {
  427 + put(key, value, -1);
  428 + }
  429 +
  430 + /**
  431 + * 保存 Serializable数据到 缓存中
  432 + *
  433 + * @param key 保存的key
  434 + * @param value 保存的value
  435 + * @param saveTime 保存的时间,单位:秒
  436 + */
  437 + @Override
  438 + public void put(String key, Serializable value, int saveTime) {
  439 + ByteArrayOutputStream baos = null;
  440 + ObjectOutputStream oos = null;
  441 + try {
  442 + baos = new ByteArrayOutputStream();
  443 + oos = new ObjectOutputStream(baos);
  444 + oos.writeObject(value);
  445 + byte[] data = baos.toByteArray();
  446 + if (saveTime != -1) {
  447 + put(key, data, saveTime);
  448 + } else {
  449 + put(key, data);
  450 + }
  451 + } catch (Exception e) {
  452 + e.printStackTrace();
  453 + } finally {
  454 + try {
  455 + oos.close();
  456 + } catch (IOException e) {
  457 + }
  458 + }
  459 + }
  460 +
  461 + /**
  462 + * 读取 Serializable数据
  463 + *
  464 + * @param key
  465 + * @return Serializable 数据
  466 + */
  467 + @Override
  468 + public Object getAsObject(String key) {
  469 + byte[] data = getAsBinary(key);
  470 + if (data != null) {
  471 + ByteArrayInputStream bais = null;
  472 + ObjectInputStream ois = null;
  473 + try {
  474 + bais = new ByteArrayInputStream(data);
  475 + ois = new ObjectInputStream(bais);
  476 + Object reObject = ois.readObject();
  477 + return reObject;
  478 + } catch (Exception e) {
  479 + e.printStackTrace();
  480 + return null;
  481 + } finally {
  482 + try {
  483 + if (bais != null)
  484 + bais.close();
  485 + } catch (IOException e) {
  486 + e.printStackTrace();
  487 + }
  488 + try {
  489 + if (ois != null)
  490 + ois.close();
  491 + } catch (IOException e) {
  492 + e.printStackTrace();
  493 + }
  494 + }
  495 + }
  496 + return null;
  497 +
  498 + }
  499 +
  500 + // =======================================
  501 + // ============== bitmap 数据 读写 =============
  502 + // =======================================
  503 +
  504 + /**
  505 + * 保存 bitmap 到 缓存中
  506 + *
  507 + * @param key 保存的key
  508 + * @param value 保存的bitmap数据
  509 + */
  510 + @Override
  511 + public void put(String key, Bitmap value) {
  512 + put(key, Utils.Bitmap2Bytes(value));
  513 + }
  514 +
  515 + /**
  516 + * 保存 bitmap 到 缓存中
  517 + *
  518 + * @param key 保存的key
  519 + * @param value 保存的 bitmap 数据
  520 + * @param saveTime 保存的时间,单位:秒
  521 + */
  522 + @Override
  523 + public void put(String key, Bitmap value, int saveTime) {
  524 + put(key, Utils.Bitmap2Bytes(value), saveTime);
  525 + }
  526 +
  527 + /**
  528 + * 读取 bitmap 数据
  529 + *
  530 + * @param key
  531 + * @return bitmap 数据
  532 + */
  533 + @Override
  534 + public Bitmap getAsBitmap(String key) {
  535 + if (getAsBinary(key) == null) {
  536 + return null;
  537 + }
  538 + return Utils.Bytes2Bimap(getAsBinary(key));
  539 + }
  540 +
  541 + // =======================================
  542 + // ============= drawable 数据 读写 =============
  543 + // =======================================
  544 +
  545 + /**
  546 + * 保存 drawable 到 缓存中
  547 + *
  548 + * @param key 保存的key
  549 + * @param value 保存的drawable数据
  550 + */
  551 + @Override
  552 + public void put(String key, Drawable value) {
  553 + put(key, Utils.drawable2Bitmap(value));
  554 + }
  555 +
  556 + /**
  557 + * 保存 drawable 到 缓存中
  558 + *
  559 + * @param key 保存的key
  560 + * @param value 保存的 drawable 数据
  561 + * @param saveTime 保存的时间,单位:秒
  562 + */
  563 + @Override
  564 + public void put(String key, Drawable value, int saveTime) {
  565 + put(key, Utils.drawable2Bitmap(value), saveTime);
  566 + }
  567 +
  568 + /**
  569 + * 读取 Drawable 数据
  570 + *
  571 + * @param key
  572 + * @return Drawable 数据
  573 + */
  574 + @Override
  575 + public Drawable getAsDrawable(String key) {
  576 + if (getAsBinary(key) == null) {
  577 + return null;
  578 + }
  579 + return Utils.bitmap2Drawable(Utils.Bytes2Bimap(getAsBinary(key)));
  580 + }
  581 +
  582 + /**
  583 + * 获取缓存文件
  584 + *
  585 + * @param key
  586 + * @return value 缓存的文件
  587 + */
  588 + @Override
  589 + public File file(String key) {
  590 + File f = mCache.newFile(key);
  591 + if (f.exists())
  592 + return f;
  593 + return null;
  594 + }
  595 +
  596 + /**
  597 + * 移除某个key
  598 + *
  599 + * @param key
  600 + * @return 是否移除成功
  601 + */
  602 + @Override
  603 + public boolean remove(String key) {
  604 + return mCache.remove(key);
  605 + }
  606 +
  607 + /**
  608 + * 清除所有数据
  609 + */
  610 + @Override
  611 + public void clear() {
  612 + mCache.clear();
  613 + }
  614 +
  615 + /**
  616 + * @author 杨福海(michael) www.yangfuhai.com
  617 + * @version 1.0
  618 + * @title 缓存管理器
  619 + */
  620 + public class ACacheManager {
  621 + private final AtomicLong cacheSize;
  622 + private final AtomicInteger cacheCount;
  623 + private final long sizeLimit;
  624 + private final int countLimit;
  625 + private final Map<File, Long> lastUsageDates = Collections
  626 + .synchronizedMap(new HashMap<File, Long>());
  627 + protected File cacheDir;
  628 +
  629 + private ACacheManager(File cacheDir, long sizeLimit, int countLimit) {
  630 + this.cacheDir = cacheDir;
  631 + this.sizeLimit = sizeLimit;
  632 + this.countLimit = countLimit;
  633 + cacheSize = new AtomicLong();
  634 + cacheCount = new AtomicInteger();
  635 + calculateCacheSizeAndCacheCount();
  636 + }
  637 +
  638 + /**
  639 + * 计算 cacheSize和cacheCount
  640 + */
  641 + private void calculateCacheSizeAndCacheCount() {
  642 + new Thread(new Runnable() {
  643 + @Override
  644 + public void run() {
  645 + int size = 0;
  646 + int count = 0;
  647 + File[] cachedFiles = cacheDir.listFiles();
  648 + if (cachedFiles != null) {
  649 + for (File cachedFile : cachedFiles) {
  650 + size += calculateSize(cachedFile);
  651 + count += 1;
  652 + lastUsageDates.put(cachedFile,
  653 + cachedFile.lastModified());
  654 + }
  655 + cacheSize.set(size);
  656 + cacheCount.set(count);
  657 + }
  658 + }
  659 + }).start();
  660 + }
  661 +
  662 + private void put(File file) {
  663 + int curCacheCount = cacheCount.get();
  664 + while (curCacheCount + 1 > countLimit) {
  665 + long freedSize = removeNext();
  666 + cacheSize.addAndGet(-freedSize);
  667 +
  668 + curCacheCount = cacheCount.addAndGet(-1);
  669 + }
  670 + cacheCount.addAndGet(1);
  671 +
  672 + long valueSize = calculateSize(file);
  673 + long curCacheSize = cacheSize.get();
  674 + while (curCacheSize + valueSize > sizeLimit) {
  675 + long freedSize = removeNext();
  676 + curCacheSize = cacheSize.addAndGet(-freedSize);
  677 + }
  678 + cacheSize.addAndGet(valueSize);
  679 +
  680 + Long currentTime = System.currentTimeMillis();
  681 + file.setLastModified(currentTime);
  682 + lastUsageDates.put(file, currentTime);
  683 + }
  684 +
  685 + private File get(String key) {
  686 + File file = newFile(key);
  687 + Long currentTime = System.currentTimeMillis();
  688 + file.setLastModified(currentTime);
  689 + lastUsageDates.put(file, currentTime);
  690 +
  691 + return file;
  692 + }
  693 +
  694 + private File newFile(String key) {
  695 + if(!cacheDir.exists())cacheDir.mkdirs();
  696 + return new File(cacheDir, key.hashCode() + "");
  697 + }
  698 +
  699 + private boolean remove(String key) {
  700 + File image = get(key);
  701 + return image.delete();
  702 + }
  703 +
  704 + private void clear() {
  705 + lastUsageDates.clear();
  706 + cacheSize.set(0);
  707 + File[] files = cacheDir.listFiles();
  708 + if (files != null) {
  709 + for (File f : files) {
  710 + f.delete();
  711 + }
  712 + }
  713 + }
  714 +
  715 + /**
  716 + * 移除旧的文件
  717 + *
  718 + * @return
  719 + */
  720 + private long removeNext() {
  721 + if (lastUsageDates.isEmpty()) {
  722 + return 0;
  723 + }
  724 +
  725 + Long oldestUsage = null;
  726 + File mostLongUsedFile = null;
  727 + Set<Entry<File, Long>> entries = lastUsageDates.entrySet();
  728 + synchronized (lastUsageDates) {
  729 + for (Entry<File, Long> entry : entries) {
  730 + if (mostLongUsedFile == null) {
  731 + mostLongUsedFile = entry.getKey();
  732 + oldestUsage = entry.getValue();
  733 + } else {
  734 + Long lastValueUsage = entry.getValue();
  735 + if (lastValueUsage < oldestUsage) {
  736 + oldestUsage = lastValueUsage;
  737 + mostLongUsedFile = entry.getKey();
  738 + }
  739 + }
  740 + }
  741 + }
  742 +
  743 + long fileSize = calculateSize(mostLongUsedFile);
  744 + if (mostLongUsedFile.delete()) {
  745 + lastUsageDates.remove(mostLongUsedFile);
  746 + }
  747 + return fileSize;
  748 + }
  749 +
  750 + private long calculateSize(File file) {
  751 + return file.length();
  752 + }
  753 + }
  754 +
  755 + /**
  756 + * @author 杨福海(michael) www.yangfuhai.com
  757 + * @version 1.0
  758 + * @title 时间计算工具类
  759 + */
  760 + private static class Utils {
  761 +
  762 + /**
  763 + * 判断缓存的String数据是否到期
  764 + *
  765 + * @param str
  766 + * @return true:到期了 false:还没有到期
  767 + */
  768 + private static boolean isDue(String str) {
  769 + return isDue(str.getBytes());
  770 + }
  771 +
  772 + /**
  773 + * 判断缓存的byte数据是否到期
  774 + *
  775 + * @param data
  776 + * @return true:到期了 false:还没有到期
  777 + */
  778 + private static boolean isDue(byte[] data) {
  779 + String[] strs = getDateInfoFromDate(data);
  780 + if (strs != null && strs.length == 2) {
  781 + String saveTimeStr = strs[0];
  782 + while (saveTimeStr.startsWith("0")) {
  783 + saveTimeStr = saveTimeStr
  784 + .substring(1, saveTimeStr.length());
  785 + }
  786 + long saveTime = Long.valueOf(saveTimeStr);
  787 + long deleteAfter = Long.valueOf(strs[1]);
  788 + if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) {
  789 + return true;
  790 + }
  791 + }
  792 + return false;
  793 + }
  794 +
  795 + private static String newStringWithDateInfo(int second, String strInfo) {
  796 + return createDateInfo(second) + strInfo;
  797 + }
  798 +
  799 + private static byte[] newByteArrayWithDateInfo(int second, byte[] data2) {
  800 + byte[] data1 = createDateInfo(second).getBytes();
  801 + byte[] retdata = new byte[data1.length + data2.length];
  802 + System.arraycopy(data1, 0, retdata, 0, data1.length);
  803 + System.arraycopy(data2, 0, retdata, data1.length, data2.length);
  804 + return retdata;
  805 + }
  806 +
  807 + private static String clearDateInfo(String strInfo) {
  808 + if (strInfo != null && hasDateInfo(strInfo.getBytes())) {
  809 + strInfo = strInfo.substring(strInfo.indexOf(mSeparator) + 1,
  810 + strInfo.length());
  811 + }
  812 + return strInfo;
  813 + }
  814 +
  815 + private static byte[] clearDateInfo(byte[] data) {
  816 + if (hasDateInfo(data)) {
  817 + return copyOfRange(data, indexOf(data, mSeparator) + 1,
  818 + data.length);
  819 + }
  820 + return data;
  821 + }
  822 +
  823 + private static boolean hasDateInfo(byte[] data) {
  824 + return data != null && data.length > 15 && data[13] == '-'
  825 + && indexOf(data, mSeparator) > 14;
  826 + }
  827 +
  828 + private static String[] getDateInfoFromDate(byte[] data) {
  829 + if (hasDateInfo(data)) {
  830 + String saveDate = new String(copyOfRange(data, 0, 13));
  831 + String deleteAfter = new String(copyOfRange(data, 14,
  832 + indexOf(data, mSeparator)));
  833 + return new String[]{saveDate, deleteAfter};
  834 + }
  835 + return null;
  836 + }
  837 +
  838 + private static int indexOf(byte[] data, char c) {
  839 + for (int i = 0; i < data.length; i++) {
  840 + if (data[i] == c) {
  841 + return i;
  842 + }
  843 + }
  844 + return -1;
  845 + }
  846 +
  847 + private static byte[] copyOfRange(byte[] original, int from, int to) {
  848 + int newLength = to - from;
  849 + if (newLength < 0)
  850 + throw new IllegalArgumentException(from + " > " + to);
  851 + byte[] copy = new byte[newLength];
  852 + System.arraycopy(original, from, copy, 0,
  853 + Math.min(original.length - from, newLength));
  854 + return copy;
  855 + }
  856 +
  857 + private static final char mSeparator = ' ';
  858 +
  859 + private static String createDateInfo(int second) {
  860 + String currentTime = System.currentTimeMillis() + "";
  861 + while (currentTime.length() < 13) {
  862 + currentTime = "0" + currentTime;
  863 + }
  864 + return currentTime + "-" + second + mSeparator;
  865 + }
  866 +
  867 + /*
  868 + * Bitmap → byte[]
  869 + */
  870 + private static byte[] Bitmap2Bytes(Bitmap bm) {
  871 + if (bm == null) {
  872 + return null;
  873 + }
  874 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
  875 + bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
  876 + return baos.toByteArray();
  877 + }
  878 +
  879 + /*
  880 + * byte[] → Bitmap
  881 + */
  882 + private static Bitmap Bytes2Bimap(byte[] b) {
  883 + if (b.length == 0) {
  884 + return null;
  885 + }
  886 + return BitmapFactory.decodeByteArray(b, 0, b.length);
  887 + }
  888 +
  889 + /*
  890 + * Drawable → Bitmap
  891 + */
  892 + private static Bitmap drawable2Bitmap(Drawable drawable) {
  893 + if (drawable == null) {
  894 + return null;
  895 + }
  896 + // 取 drawable 的长宽
  897 + int w = drawable.getIntrinsicWidth();
  898 + int h = drawable.getIntrinsicHeight();
  899 + // 取 drawable 的颜色格式
  900 + Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
  901 + : Bitmap.Config.RGB_565;
  902 + // 建立对应 bitmap
  903 + Bitmap bitmap = Bitmap.createBitmap(w, h, config);
  904 + // 建立对应 bitmap 的画布
  905 + Canvas canvas = new Canvas(bitmap);
  906 + drawable.setBounds(0, 0, w, h);
  907 + // 把 drawable 内容画到画布中
  908 + drawable.draw(canvas);
  909 + return bitmap;
  910 + }
  911 +
  912 + /*
  913 + * Bitmap → Drawable
  914 + */
  915 + @SuppressWarnings("deprecation")
  916 + private static Drawable bitmap2Drawable(Bitmap bm) {
  917 + if (bm == null) {
  918 + return null;
  919 + }
  920 + BitmapDrawable bd = new BitmapDrawable(bm);
  921 + bd.setTargetDensity(bm.getDensity());
  922 + return new BitmapDrawable(bm);
  923 + }
  924 + }
  925 +
  926 +
  927 +}
  1 +package com.mang.xdy.demo.utils.cache;
  2 +
  3 +import android.graphics.Bitmap;
  4 +import android.graphics.drawable.Drawable;
  5 +
  6 +import org.json.JSONArray;
  7 +import org.json.JSONObject;
  8 +
  9 +import java.io.File;
  10 +import java.io.FileNotFoundException;
  11 +import java.io.InputStream;
  12 +import java.io.OutputStream;
  13 +import java.io.Serializable;
  14 +
  15 +public interface ICache {
  16 +
  17 + void put(String key, String value);
  18 +
  19 + void put(String key, String value, int saveTime);
  20 +
  21 + String getAsString(String key);
  22 +
  23 + void put(String key, JSONObject value);
  24 +
  25 + void put(String key, JSONObject value, int saveTime);
  26 +
  27 + JSONObject getAsJSONObject(String key);
  28 +
  29 + void put(String key, JSONArray value);
  30 +
  31 + void put(String key, JSONArray value, int saveTime);
  32 +
  33 + JSONArray getAsJSONArray(String key);
  34 +
  35 + void put(String key, byte[] value);
  36 +
  37 + OutputStream put(String key) throws FileNotFoundException;
  38 +
  39 + InputStream get(String key) throws FileNotFoundException;
  40 +
  41 + void put(String key, byte[] value, int saveTime);
  42 +
  43 + byte[] getAsBinary(String key);
  44 +
  45 + void put(String key, Serializable value);
  46 +
  47 + void put(String key, Serializable value, int saveTime);
  48 +
  49 + Object getAsObject(String key);
  50 +
  51 + void put(String key, Bitmap value);
  52 +
  53 + void put(String key, Bitmap value, int saveTime);
  54 +
  55 + Bitmap getAsBitmap(String key);
  56 +
  57 + void put(String key, Drawable value);
  58 +
  59 + void put(String key, Drawable value, int saveTime);
  60 +
  61 + Drawable getAsDrawable(String key);
  62 +
  63 + File file(String key);
  64 +
  65 + boolean remove(String key);
  66 +
  67 + void clear();
  68 +}
@@ -8,26 +8,18 @@ @@ -8,26 +8,18 @@
8 tools:context="com.mang.xdy.demo.activity.VideoPlayActivity"> 8 tools:context="com.mang.xdy.demo.activity.VideoPlayActivity">
9 <RelativeLayout 9 <RelativeLayout
10 android:layout_width="match_parent" 10 android:layout_width="match_parent"
11 - android:layout_height="300dp"> 11 + android:layout_height="220dp">
12 <SurfaceView 12 <SurfaceView
13 android:id="@+id/surfaceview_playVideo" 13 android:id="@+id/surfaceview_playVideo"
14 android:layout_width="match_parent" 14 android:layout_width="match_parent"
15 - android:layout_height="10dp" /> 15 + android:layout_height="match_parent" />
16 <ImageView 16 <ImageView
17 android:id="@+id/img_playVideo_novideo" 17 android:id="@+id/img_playVideo_novideo"
18 android:layout_width="match_parent" 18 android:layout_width="match_parent"
19 - android:layout_height="10dp" 19 + android:layout_height="match_parent"
20 android:background="@mipmap/novideo" 20 android:background="@mipmap/novideo"
21 /> 21 />
22 -  
23 -  
24 </RelativeLayout> 22 </RelativeLayout>
25 - <SurfaceView  
26 - android:id="@+id/surfaceview_pubisherVideo"  
27 - android:layout_width="120dp"  
28 - android:layout_height="120dp"  
29 - android:visibility="gone"  
30 - />  
31 <android.support.design.widget.TabLayout 23 <android.support.design.widget.TabLayout
32 android:id="@+id/sliding_tabs" 24 android:id="@+id/sliding_tabs"
33 android:layout_width="match_parent" 25 android:layout_width="match_parent"
@@ -40,47 +32,4 @@ @@ -40,47 +32,4 @@
40 android:layout_height="0px" 32 android:layout_height="0px"
41 android:layout_weight="1" 33 android:layout_weight="1"
42 android:background="@android:color/white" /> 34 android:background="@android:color/white" />
43 - <ImageView  
44 - android:id="@+id/img_playVideo_docShow"  
45 - android:layout_width="match_parent"  
46 - android:visibility="gone"  
47 - android:layout_height="100dp" />  
48 - <com.mang.xdy.demo.widget.CanvasView  
49 - android:id="@+id/canvas_playVideo_showWhiteBroad"  
50 - android:layout_width="match_parent"  
51 - android:visibility="gone"  
52 - android:layout_height="10dp" />  
53 -  
54 - <TextView  
55 - android:id="@+id/tv_videoPlay_url"  
56 - android:layout_width="wrap_content"  
57 - android:layout_height="wrap_content"  
58 - />  
59 - <LinearLayout  
60 - android:layout_width="match_parent"  
61 - android:layout_height="wrap_content"  
62 - android:orientation="horizontal">  
63 - <Button  
64 - android:id="@+id/btn_videoPlay_chat"  
65 - android:layout_width="wrap_content"  
66 - android:layout_height="wrap_content"  
67 - android:text="发送hello"  
68 - android:visibility="gone"  
69 - />  
70 - <Button  
71 - android:id="@+id/btn_videoPlay_pubsherVideo"  
72 - android:layout_width="wrap_content"  
73 - android:layout_height="wrap_content"  
74 - android:visibility="gone"  
75 - android:text="获取推流地址"  
76 - />  
77 - </LinearLayout>  
78 - <Button  
79 - android:id="@+id/bt_stop"  
80 - android:layout_width="wrap_content"  
81 - android:layout_height="wrap_content"  
82 - android:text="停止视频"  
83 - android:visibility="gone"  
84 - android:clickable="false"  
85 - />  
86 </LinearLayout> 35 </LinearLayout>
@@ -6,9 +6,11 @@ package com.mang.xdy.bean; @@ -6,9 +6,11 @@ package com.mang.xdy.bean;
6 6
7 public class AudioPlayBean { 7 public class AudioPlayBean {
8 8
  9 +
9 /** 10 /**
10 * mediaId : 983041 11 * mediaId : 983041
11 * fromNodeId : 253252 12 * fromNodeId : 253252
  13 + * userRole : host
12 * seek : 0 14 * seek : 0
13 * rtmpUrl : rtmp://127.0.0.1:6000/live/h5dev_403074980_0_983041_1488258462 15 * rtmpUrl : rtmp://127.0.0.1:6000/live/h5dev_403074980_0_983041_1488258462
14 * m3u8Url : http://127.0.0.1:6001/live/h5dev_403074980_0_983041_1488258462/index.m3u8 16 * m3u8Url : http://127.0.0.1:6001/live/h5dev_403074980_0_983041_1488258462/index.m3u8
@@ -17,6 +19,7 @@ public class AudioPlayBean { @@ -17,6 +19,7 @@ public class AudioPlayBean {
17 19
18 private int mediaId; 20 private int mediaId;
19 private int fromNodeId; 21 private int fromNodeId;
  22 + private String userRole;
20 private int seek; 23 private int seek;
21 private String rtmpUrl; 24 private String rtmpUrl;
22 private String m3u8Url; 25 private String m3u8Url;
@@ -38,6 +41,14 @@ public class AudioPlayBean { @@ -38,6 +41,14 @@ public class AudioPlayBean {
38 this.fromNodeId = fromNodeId; 41 this.fromNodeId = fromNodeId;
39 } 42 }
40 43
  44 + public String getUserRole() {
  45 + return userRole;
  46 + }
  47 +
  48 + public void setUserRole(String userRole) {
  49 + this.userRole = userRole;
  50 + }
  51 +
41 public int getSeek() { 52 public int getSeek() {
42 return seek; 53 return seek;
43 } 54 }
@@ -96,6 +96,8 @@ public class XdyJsCore { @@ -96,6 +96,8 @@ public class XdyJsCore {
96 if(mOnXdyAsyncMessageListener !=null){ 96 if(mOnXdyAsyncMessageListener !=null){
97 mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp); 97 mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp);
98 } 98 }
  99 + //TODo 使用观察者传递数
  100 + XdySdk.getXdyInstance().notifyObserver(id,parmp);
99 } 101 }
100 } 102 }
101 103
@@ -17,9 +17,7 @@ import com.mang.xdy.utils.XdyLogUtil; @@ -17,9 +17,7 @@ import com.mang.xdy.utils.XdyLogUtil;
17 */ 17 */
18 public class XdyPlayerCore { 18 public class XdyPlayerCore {
19 19
20 - private SurfaceView mSurfaceView = null;  
21 private long playerHandle = 0; 20 private long playerHandle = 0;
22 -  
23 private static final int PORTRAIT = 1; //竖屏 21 private static final int PORTRAIT = 1; //竖屏
24 private static final int LANDSCAPE = 2; //横屏 22 private static final int LANDSCAPE = 2; //横屏
25 private static final String TAG = "XdyPlayer"; 23 private static final String TAG = "XdyPlayer";
@@ -32,15 +30,14 @@ public class XdyPlayerCore { @@ -32,15 +30,14 @@ public class XdyPlayerCore {
32 static { 30 static {
33 System.loadLibrary("SmartPlayer"); 31 System.loadLibrary("SmartPlayer");
34 } 32 }
35 - protected XdyPlayerCore(String rtmpUrl,SurfaceView mSurfaceView, Context mContext) {  
36 - this.mSurfaceView = mSurfaceView; 33 + protected XdyPlayerCore(String rtmpUrl, Context mContext) {
37 this.mContext=mContext; 34 this.mContext=mContext;
38 } 35 }
39 - protected static XdyPlayerCore getXdyPlayerCore(String rtmpUrl,SurfaceView mSurfaceView, Context mContext){ 36 + protected static XdyPlayerCore getXdyPlayerCore(String rtmpUrl, Context mContext){
40 if(mXdyPlayerCore==null){ 37 if(mXdyPlayerCore==null){
41 synchronized (XdyPlayerCore.class){ 38 synchronized (XdyPlayerCore.class){
42 if(mXdyPlayerCore==null){ 39 if(mXdyPlayerCore==null){
43 - mXdyPlayerCore=new XdyPlayerCore(rtmpUrl, mSurfaceView, mContext); 40 + mXdyPlayerCore=new XdyPlayerCore(rtmpUrl, mContext);
44 } 41 }
45 } 42 }
46 } 43 }
@@ -61,9 +58,9 @@ public class XdyPlayerCore { @@ -61,9 +58,9 @@ public class XdyPlayerCore {
61 libPlayer = new SmartPlayerJni(); 58 libPlayer = new SmartPlayerJni();
62 } 59 }
63 //TODO 60 //TODO
64 -// if(playerHandle==0) { 61 + if(playerHandle==0) {
65 playerHandle = libPlayer.SmartPlayerInit(mContext); 62 playerHandle = libPlayer.SmartPlayerInit(mContext);
66 -// } 63 + }
67 XdyLogUtil.e(TAG, "playVideoId" + playerHandle); 64 XdyLogUtil.e(TAG, "playVideoId" + playerHandle);
68 if (playerHandle == 0) { 65 if (playerHandle == 0) {
69 XdyLogUtil.e(TAG, "视频初始化失败 "); 66 XdyLogUtil.e(TAG, "视频初始化失败 ");
@@ -15,12 +15,17 @@ import com.mang.xdy.bean.PublisherVideoReturnBean; @@ -15,12 +15,17 @@ import com.mang.xdy.bean.PublisherVideoReturnBean;
15 import com.mang.xdy.bean.VideoPlayBean; 15 import com.mang.xdy.bean.VideoPlayBean;
16 import com.mang.xdy.cache.ACache; 16 import com.mang.xdy.cache.ACache;
17 import com.mang.xdy.common.Constants; 17 import com.mang.xdy.common.Constants;
  18 +import com.mang.xdy.listener.ObserverListener;
  19 +import com.mang.xdy.listener.SubjectListener;
18 import com.mang.xdy.message.MsgManage; 20 import com.mang.xdy.message.MsgManage;
19 import com.mang.xdy.utils.JsonUtil; 21 import com.mang.xdy.utils.JsonUtil;
20 import com.mang.xdy.utils.PlayerUtils; 22 import com.mang.xdy.utils.PlayerUtils;
21 import com.mang.xdy.utils.XdyLogUtil; 23 import com.mang.xdy.utils.XdyLogUtil;
22 import com.mang.xdy.utils.XdyStringUtils; 24 import com.mang.xdy.utils.XdyStringUtils;
23 25
  26 +import java.util.ArrayList;
  27 +import java.util.List;
  28 +
24 import static com.mang.xdy.utils.PlayerUtils.getPublishPathAudio; 29 import static com.mang.xdy.utils.PlayerUtils.getPublishPathAudio;
25 import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo; 30 import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo;
26 31
@@ -30,15 +35,15 @@ import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo; @@ -30,15 +35,15 @@ import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo;
30 * 受原先的文档设计的规则,所有方法的都是静态的方法,影响性能 35 * 受原先的文档设计的规则,所有方法的都是静态的方法,影响性能
31 * 考虑跟换文档,提升性能 36 * 考虑跟换文档,提升性能
32 */ 37 */
33 -public class XdySdk { 38 +public class XdySdk implements SubjectListener{
34 /** 39 /**
35 * 用户初始化,还是调用各种方法,都需要统一的对外给出监听事件 40 * 用户初始化,还是调用各种方法,都需要统一的对外给出监听事件
36 */ 41 */
37 - private static XdyJsCore mXdyJsCore; 42 + private static XdyJsCore mXdyJsCore;
38 private static XdySdk mXdySdk; 43 private static XdySdk mXdySdk;
39 - private static Context mContext;  
40 - private static XdyPlayerCore mXdyPlayerCore;  
41 - private static XdyPublisherCore mXdyPublisherCore; 44 + private static Context mContext;
  45 + private XdyPlayerCore mXdyPlayerCore;
  46 + private XdyPublisherCore mXdyPublisherCore;
42 /*消息管理*/ 47 /*消息管理*/
43 private static MsgManage mMsgManage; 48 private static MsgManage mMsgManage;
44 49
@@ -46,8 +51,29 @@ public class XdySdk { @@ -46,8 +51,29 @@ public class XdySdk {
46 /*缓存管理*/ 51 /*缓存管理*/
47 private static ACache aCache; 52 private static ACache aCache;
48 //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏) 53 //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏)
49 - private static SurfaceView mSurfaceView;  
50 - private static Activity mActivity; 54 + private SurfaceView mSurfaceView;
  55 + private Activity mActivity;
  56 + private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>();
  57 +
  58 + @Override
  59 + public void add(ObserverListener observerListener) {
  60 + observerListenerList.add(observerListener);
  61 + }
  62 +
  63 + @Override
  64 + public void notifyObserver(String type, String parameter) {
  65 + handleData(type,parameter);
  66 +
  67 +
  68 +
  69 + }
  70 +
  71 + @Override
  72 + public void remove(ObserverListener observerListener) {
  73 + if(observerListenerList.contains(observerListener)){
  74 + observerListenerList.remove(observerListener);
  75 + }
  76 + }
51 77
52 /** 78 /**
53 * 对外提供的异步消息接收接口) 79 * 对外提供的异步消息接收接口)
@@ -60,12 +86,12 @@ public class XdySdk { @@ -60,12 +86,12 @@ public class XdySdk {
60 */ 86 */
61 void onXdyAsyncMessageReceiver(String type, String response); 87 void onXdyAsyncMessageReceiver(String type, String response);
62 } 88 }
63 - private static OnXdyAsyncMessageLitener mOnXdyAsyncMessageLitener; 89 + private OnXdyAsyncMessageLitener mOnXdyAsyncMessageLitener;
64 90
65 /** 91 /**
66 * 设置监听 92 * 设置监听
67 */ 93 */
68 - public static void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){ 94 + public void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){
69 judgeCore();; 95 judgeCore();;
70 mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener; 96 mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener;
71 } 97 }
@@ -85,35 +111,36 @@ public class XdySdk { @@ -85,35 +111,36 @@ public class XdySdk {
85 if(context==null){ 111 if(context==null){
86 throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL); 112 throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL);
87 } 113 }
88 - mContext=context; 114 + aCache=ACache.get(context);
  115 + mContext=context;
89 mXdyJsCore = XdyJsCore.getInstance(context); 116 mXdyJsCore = XdyJsCore.getInstance(context);
90 mMsgManage=MsgManage.getErrorMsgInstance(); 117 mMsgManage=MsgManage.getErrorMsgInstance();
91 - mMsgManage.setXdyMsgManageListener(new MsgManage.OnXdyMsgManageListener() {  
92 - @Override  
93 - public void onXdyMsgResponse(final String type, final String response) {  
94 - //处理数据异常,传递给最外层  
95 - handler.post(new Runnable() {  
96 - @Override  
97 - public void run() {  
98 - handleListener(type,response);  
99 - }  
100 - });  
101 -  
102 - }  
103 - });  
104 - mXdyJsCore.setXdyAsyncMessageListener(new XdyJsCore.OnXdyAsyncMessageListener() {  
105 - @Override  
106 - public void getSdyAsyncMessageListener(final String id, final String parameter) {  
107 - handler.post(new Runnable() {  
108 - @Override  
109 - public void run() {  
110 - handleData(id,parameter);  
111 - }  
112 - });  
113 -  
114 - }  
115 - });  
116 - aCache=ACache.get(mContext); 118 +// mMsgManage.setXdyMsgManageListener(new MsgManage.OnXdyMsgManageListener() {
  119 +// @Override
  120 +// public void onXdyMsgResponse(final String type, final String response) {
  121 +// //处理数据异常,传递给最外层
  122 +// handler.post(new Runnable() {
  123 +// @Override
  124 +// public void run() {
  125 +// handleListener(type,response);
  126 +// }
  127 +// });
  128 +//
  129 +// }
  130 +// });
  131 +// mXdyJsCore.setXdyAsyncMessageListener(new XdyJsCore.OnXdyAsyncMessageListener() {
  132 +// @Override
  133 +// public void getSdyAsyncMessageListener(final String id, final String parameter) {
  134 +// handler.post(new Runnable() {
  135 +// @Override
  136 +// public void run() {
  137 +// handleData(id,parameter);
  138 +// }
  139 +// });
  140 +//
  141 +// }
  142 +// });
  143 +// aCache=ACache.get(mContext);
117 } 144 }
118 145
119 /** 146 /**
@@ -121,8 +148,8 @@ public class XdySdk { @@ -121,8 +148,8 @@ public class XdySdk {
121 * @param type 类型 148 * @param type 类型
122 * @param argument 参数 149 * @param argument 参数
123 */ 150 */
124 - public static void api(String type,String argument){  
125 - judgeCore(); 151 + public void api(String type,String argument){
  152 + judgeCore();
126 //再次停止播放器 153 //再次停止播放器
127 switch (type){ 154 switch (type){
128 case "unPublishAudio": 155 case "unPublishAudio":
@@ -140,60 +167,44 @@ public class XdySdk { @@ -140,60 +167,44 @@ public class XdySdk {
140 } 167 }
141 mXdyJsCore.native2js(type, argument); 168 mXdyJsCore.native2js(type, argument);
142 } 169 }
143 - /**  
144 - * 接收视频播放的方法  
145 - * @param type  
146 - * @param rtmpUrl  
147 - * @param surfaceView  
148 - * @param context  
149 - * @deprecated  
150 - */  
151 - public static void setAsyncApi(String type, String rtmpUrl, SurfaceView surfaceView,Context context) {  
152 - switch (type) {  
153 -// case "playVideo": 170 +
  171 +// /**
  172 +// * 重载推流
  173 +// * @param type
  174 +// * @param rtmpUrl
  175 +// * @param surfaceView
  176 +// * @param activity
  177 +// */
  178 +// public void api(String type, String rtmpUrl, SurfaceView surfaceView, Activity activity, SmartEventCallback smartEventCallback) {
  179 +// judgeString(type);
  180 +// judgeUrl(rtmpUrl);
  181 +// switch (type) {
  182 +// case Constants.PLAY_AUDIO:
  183 +// //播放音频
  184 +// mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(rtmpUrl,null, activity);
  185 +// mXdyPlayerCore.playAudio(rtmpUrl,smartEventCallback);
  186 +// break;
  187 +// case Constants.PLAY_VIDEO:
154 // //播放视频 188 // //播放视频
155 -// mXdyPlayerCore = new XdyPlayerCore(rtmpUrl,surfaceView, context); 189 +// mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(rtmpUrl,surfaceView, activity);
  190 +// mXdyPlayerCore.playVideo(rtmpUrl, surfaceView,smartEventCallback);
156 // break; 191 // break;
157 - }  
158 - }  
159 -  
160 - /**  
161 - * 重载推流  
162 - * @param type  
163 - * @param rtmpUrl  
164 - * @param surfaceView  
165 - * @param activity  
166 - */  
167 - public static void api(String type, String rtmpUrl, SurfaceView surfaceView, Activity activity, SmartEventCallback smartEventCallback) {  
168 - judgeString(type);  
169 - judgeUrl(rtmpUrl);  
170 - switch (type) {  
171 - case Constants.PLAY_AUDIO:  
172 - //播放音频  
173 - mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(rtmpUrl,null, activity);  
174 - mXdyPlayerCore.playAudio(rtmpUrl,smartEventCallback);  
175 - break;  
176 - case Constants.PLAY_VIDEO:  
177 - //播放视频  
178 - mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(rtmpUrl,surfaceView, activity);  
179 - mXdyPlayerCore.playVideo(rtmpUrl, surfaceView,smartEventCallback);  
180 - break;  
181 - case Constants.PUBLISH_VIDEO:  
182 - //打开推流视频  
183 - //用户打开推流的时候应该主动去获取推流地址  
184 - if(mXdyPublisherCore==null)  
185 - mXdyPublisherCore=new XdyPublisherCore(1,1,activity);  
186 - mXdyPublisherCore.publisher(rtmpUrl,surfaceView,smartEventCallback);  
187 - break;  
188 - case Constants.PUBLISH_AUDIO:  
189 - //只推送音频  
190 - if(mXdyPublisherCore==null)  
191 - mXdyPublisherCore=new XdyPublisherCore(1,0,activity);  
192 - mXdyPublisherCore.publisherAudio(rtmpUrl,smartEventCallback);  
193 - break;  
194 -  
195 - }  
196 - } 192 +// case Constants.PUBLISH_VIDEO:
  193 +// //打开推流视频
  194 +// //用户打开推流的时候应该主动去获取推流地址
  195 +// if(mXdyPublisherCore==null)
  196 +// mXdyPublisherCore=new XdyPublisherCore(1,1,activity);
  197 +// mXdyPublisherCore.publisher(rtmpUrl,surfaceView,smartEventCallback);
  198 +// break;
  199 +// case Constants.PUBLISH_AUDIO:
  200 +// //只推送音频
  201 +// if(mXdyPublisherCore==null)
  202 +// mXdyPublisherCore=new XdyPublisherCore(1,0,activity);
  203 +// mXdyPublisherCore.publisherAudio(rtmpUrl,smartEventCallback);
  204 +// break;
  205 +//
  206 +// }
  207 +// }
197 208
198 /** 209 /**
199 * 测试封装 用过时标识区分 210 * 测试封装 用过时标识区分
@@ -204,10 +215,8 @@ public class XdySdk { @@ -204,10 +215,8 @@ public class XdySdk {
204 * @param 215 * @param
205 * @deprecated 216 * @deprecated
206 */ 217 */
207 - public static void api(String type,String mediaId, SurfaceView surfaceView, Activity activity,String ss) { 218 + public void api(String type,String mediaId, SurfaceView surfaceView, Activity activity) {
208 judgeString(type); 219 judgeString(type);
209 - //  
210 - Object o;  
211 switch (type) { 220 switch (type) {
212 case Constants.PLAY_AUDIO: 221 case Constants.PLAY_AUDIO:
213 //播放音频 222 //播放音频
@@ -215,18 +224,20 @@ public class XdySdk { @@ -215,18 +224,20 @@ public class XdySdk {
215 * 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误 224 * 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误
216 * 225 *
217 */ 226 */
218 - String json= aCache.getAsString(mediaId);  
219 - if(TextUtils.isEmpty(json)){ 227 + String json_audio= aCache.getAsString(mediaId);
  228 + if(TextUtils.isEmpty(json_audio)){
220 //TODO/给出相应的提示表示没有 这个id 229 //TODO/给出相应的提示表示没有 这个id
  230 + XdyLogUtil.e(TAG,"Play Audio Can not find this AudioId");
221 return; 231 return;
222 } 232 }
223 - AudioPlayBean audioPlayBean=JsonUtil.parseJsonToBean(json,AudioPlayBean.class); 233 + AudioPlayBean audioPlayBean=JsonUtil.parseJsonToBean(json_audio,AudioPlayBean.class);
224 if(audioPlayBean!=null) { 234 if(audioPlayBean!=null) {
225 - if(mXdyPlayerCore==null)  
226 - mXdyPlayerCore = XdyPlayerCore.getXdyPlayerCore(audioPlayBean.getRtmpUrl(), null, activity); 235 + if(mXdyPlayerCore==null) {
  236 + mXdyPlayerCore = XdyPlayerCore.getXdyPlayerCore(audioPlayBean.getRtmpUrl(), activity);
  237 + }
227 mXdyPlayerCore.playAudio(audioPlayBean.getRtmpUrl(), new EventHande()); 238 mXdyPlayerCore.playAudio(audioPlayBean.getRtmpUrl(), new EventHande());
228 }else{ 239 }else{
229 - 240 + XdyLogUtil.e(TAG,"Can not get play Audio response");
230 } 241 }
231 break; 242 break;
232 case Constants.PLAY_VIDEO: 243 case Constants.PLAY_VIDEO:
@@ -238,15 +249,18 @@ public class XdySdk { @@ -238,15 +249,18 @@ public class XdySdk {
238 String json_video= aCache.getAsString(mediaId); 249 String json_video= aCache.getAsString(mediaId);
239 if(TextUtils.isEmpty(json_video)){ 250 if(TextUtils.isEmpty(json_video)){
240 ///给出相应的提示表示没有 这个id 251 ///给出相应的提示表示没有 这个id
  252 + XdyLogUtil.e(TAG,"Play Video Can not find this VideoId");
241 return; 253 return;
242 } 254 }
243 VideoPlayBean videoPlayBean=JsonUtil.parseJsonToBean(json_video,VideoPlayBean.class); 255 VideoPlayBean videoPlayBean=JsonUtil.parseJsonToBean(json_video,VideoPlayBean.class);
244 if(videoPlayBean!=null){ 256 if(videoPlayBean!=null){
245 - if(mXdyPlayerCore==null)  
246 - mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(videoPlayBean.getRtmpUrl(),surfaceView, activity); 257 + if(mXdyPlayerCore==null) {
  258 + mXdyPlayerCore = XdyPlayerCore.getXdyPlayerCore(videoPlayBean.getRtmpUrl(), activity);
  259 + }
247 mXdyPlayerCore.playVideo(videoPlayBean.getRtmpUrl(), surfaceView,new EventHande()); 260 mXdyPlayerCore.playVideo(videoPlayBean.getRtmpUrl(), surfaceView,new EventHande());
248 }else{ 261 }else{
249 //统一提示推流错误 262 //统一提示推流错误
  263 + XdyLogUtil.e(TAG,"Can not get play Video response");
250 } 264 }
251 break; 265 break;
252 case Constants.PUBLISH_VIDEO: 266 case Constants.PUBLISH_VIDEO:
@@ -275,19 +289,19 @@ public class XdySdk { @@ -275,19 +289,19 @@ public class XdySdk {
275 } 289 }
276 } 290 }
277 /*判断是否被初始化*/ 291 /*判断是否被初始化*/
278 - private static void judgeCore(){ 292 + private void judgeCore(){
279 if(mXdyJsCore==null){ 293 if(mXdyJsCore==null){
280 throw new IllegalArgumentException(Constants.ERROR_XDYCORE_INIT); 294 throw new IllegalArgumentException(Constants.ERROR_XDYCORE_INIT);
281 } 295 }
282 } 296 }
283 /*判断type是否为空*/ 297 /*判断type是否为空*/
284 - private static void judgeString(String type){ 298 + private void judgeString(String type){
285 if(TextUtils.isEmpty(type)){ 299 if(TextUtils.isEmpty(type)){
286 XdyLogUtil.e(TAG,Constants.ERROR_TYPE_NULL); 300 XdyLogUtil.e(TAG,Constants.ERROR_TYPE_NULL);
287 } 301 }
288 } 302 }
289 /*判断是否是合法的url*/ 303 /*判断是否是合法的url*/
290 - protected static void judgeUrl(String url){ 304 + protected void judgeUrl(String url){
291 if (url == null) 305 if (url == null)
292 return; 306 return;
293 307
@@ -303,20 +317,20 @@ public class XdySdk { @@ -303,20 +317,20 @@ public class XdySdk {
303 } 317 }
304 } 318 }
305 319
306 -// public static XdySdk getXdyInstance(){  
307 -// if(mXdySdk ==null){  
308 -// synchronized (XdySdk.class){  
309 -// mXdySdk =new XdySdk();  
310 -// }  
311 -// }  
312 -// return mXdySdk;  
313 -// } 320 + public static XdySdk getXdyInstance(){
  321 + if(mXdySdk ==null){
  322 + synchronized (XdySdk.class){
  323 + mXdySdk =new XdySdk();
  324 + }
  325 + }
  326 + return mXdySdk;
  327 + }
314 /** 328 /**
315 *core获取到的数据处理 329 *core获取到的数据处理
316 * @param type 330 * @param type
317 * @param response 331 * @param response
318 */ 332 */
319 - private static void handleData(String type,String response){ 333 + private void handleData(String type,String response){
320 //开始处理推流信息,用户只需要传递surfaceview activity, 内部处理url 334 //开始处理推流信息,用户只需要传递surfaceview activity, 内部处理url
321 /*需要处理的信息有playVideo 返回的url地址, 遇到video_play ,和 335 /*需要处理的信息有playVideo 返回的url地址, 遇到video_play ,和
322 audio 336 audio
@@ -449,17 +463,20 @@ public class XdySdk { @@ -449,17 +463,20 @@ public class XdySdk {
449 /** 463 /**
450 * 处理所有向外发送的接口数据 464 * 处理所有向外发送的接口数据
451 * @param type 465 * @param type
452 - * @param response 466 + * @param parameter
453 */ 467 */
454 - private static void handleListener(String type,String response){ 468 + private void handleListener(String type,String parameter){
455 if(mOnXdyAsyncMessageLitener!=null){ 469 if(mOnXdyAsyncMessageLitener!=null){
456 - mOnXdyAsyncMessageLitener.onXdyAsyncMessageReceiver(type,response); 470 + mOnXdyAsyncMessageLitener.onXdyAsyncMessageReceiver(type,parameter);
  471 + }
  472 + for(ObserverListener o:observerListenerList){
  473 + o.observerUpData(type,parameter);
457 } 474 }
458 } 475 }
459 /** 476 /**
460 * 播放视频音频销毁方法 477 * 播放视频音频销毁方法
461 */ 478 */
462 - public static void onPlayStop(){ 479 + public void onPlayStop(){
463 if(mXdyPlayerCore!=null) { 480 if(mXdyPlayerCore!=null) {
464 mXdyPlayerCore.onStopPlay(); 481 mXdyPlayerCore.onStopPlay();
465 mXdyPlayerCore=null; 482 mXdyPlayerCore=null;
@@ -469,7 +486,7 @@ public class XdySdk { @@ -469,7 +486,7 @@ public class XdySdk {
469 /** 486 /**
470 * 推送视频音频停止方法 487 * 推送视频音频停止方法
471 */ 488 */
472 - public static void onPublisherStop(){ 489 + public void onPublisherStop(){
473 if(mXdyPublisherCore!=null){ 490 if(mXdyPublisherCore!=null){
474 mXdyPublisherCore.onStopPublisher(); 491 mXdyPublisherCore.onStopPublisher();
475 mXdyPublisherCore=null; 492 mXdyPublisherCore=null;
@@ -482,7 +499,7 @@ public class XdySdk { @@ -482,7 +499,7 @@ public class XdySdk {
482 } 499 }
483 } 500 }
484 501
485 - static class EventHande implements SmartEventCallback { 502 + class EventHande implements SmartEventCallback {
486 @Override 503 @Override
487 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { 504 public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) {
488 switch (code) { 505 switch (code) {
  1 +package com.mang.xdy.listener;
  2 +
  3 +/**
  4 + * Created by abao on 2017/4/18.
  5 + */
  6 +
  7 +public interface ObserverListener {
  8 + /**
  9 + *
  10 + * @param type 类型
  11 + * @param parameter 参数
  12 + */
  13 + void observerUpData(String type,String parameter);
  14 +}
  1 +package com.mang.xdy.listener;
  2 +
  3 +/**
  4 + * Created by abao on 2017/4/18.
  5 + */
  6 +
  7 +public interface SubjectListener {
  8 + void add(ObserverListener observerListener);
  9 + void notifyObserver(String type,String parameter);
  10 + void remove(ObserverListener observerListener);
  11 +}
@@ -19,7 +19,7 @@ public class PlayerUtils { @@ -19,7 +19,7 @@ public class PlayerUtils {
19 public static void getPublishPathVideo() { 19 public static void getPublishPathVideo() {
20 String tem = "{ \"type\": \"live\"}"; 20 String tem = "{ \"type\": \"live\"}";
21 String s = XdyStringUtils.stringToJson(tem, true); 21 String s = XdyStringUtils.stringToJson(tem, true);
22 - XdySdk.api(Constants.GET_VIDEO_PUBLISH_PATH, s); 22 + XdySdk.getXdyInstance().api(Constants.GET_VIDEO_PUBLISH_PATH, s);
23 } 23 }
24 24
25 /** 25 /**
@@ -28,7 +28,7 @@ public class PlayerUtils { @@ -28,7 +28,7 @@ public class PlayerUtils {
28 public static void getPublishPathAudio() { 28 public static void getPublishPathAudio() {
29 String tem = "{ \"type\": \"live\"}"; 29 String tem = "{ \"type\": \"live\"}";
30 String s = XdyStringUtils.stringToJson(tem, true); 30 String s = XdyStringUtils.stringToJson(tem, true);
31 - XdySdk.api(Constants.GET_AUDIO_PUBLISH_PATH, s); 31 + XdySdk.getXdyInstance().api(Constants.GET_AUDIO_PUBLISH_PATH, s);
32 } 32 }
33 33
34 /** 34 /**
@@ -41,7 +41,7 @@ public class PlayerUtils { @@ -41,7 +41,7 @@ public class PlayerUtils {
41 publisherEntity.setPublishUrl(url); 41 publisherEntity.setPublishUrl(url);
42 String pamp = new Gson().toJson(publisherEntity); 42 String pamp = new Gson().toJson(publisherEntity);
43 XdyLogUtil.e("推流成功", "" + pamp); 43 XdyLogUtil.e("推流成功", "" + pamp);
44 - XdySdk.api(Constants.PUBLISH_VIDEO, pamp); 44 + XdySdk.getXdyInstance().api(Constants.PUBLISH_VIDEO, pamp);
45 } 45 }
46 } 46 }
47 47
@@ -55,7 +55,7 @@ public class PlayerUtils { @@ -55,7 +55,7 @@ public class PlayerUtils {
55 publisherEntity.setPublishUrl(url); 55 publisherEntity.setPublishUrl(url);
56 String pamp = new Gson().toJson(publisherEntity); 56 String pamp = new Gson().toJson(publisherEntity);
57 XdyLogUtil.e("推流成功", "" + pamp); 57 XdyLogUtil.e("推流成功", "" + pamp);
58 - XdySdk.api(Constants.PUBLISH_AUDIO, pamp); 58 + XdySdk.getXdyInstance().api(Constants.PUBLISH_AUDIO, pamp);
59 } 59 }
60 } 60 }
61 } 61 }