蒋洪波

修改聊天界面,修改播放状态下退回到桌面出现声音的BUG

正在显示 146 个修改的文件 包含 155 行增加101 行删除
... ... @@ -20,8 +20,8 @@ public class EncryptUtilTest {
@Test
public void testMD5Encode() throws Exception {
String s = EncryptUtil.MD5Encode("123456");
// Assert.assertEquals("e10adc3949ba59abbe56e057f20f883e", s);
BigDecimal bigDecimal = new BigDecimal("4.44").setScale(1, BigDecimal.ROUND_HALF_UP);
Assert.assertEquals(bigDecimal.floatValue(), 5);
Assert.assertEquals("e10adc3949ba59abbe56e057f20f883e", s);
// BigDecimal bigDecimal = new BigDecimal("4.44").setScale(1, BigDecimal.ROUND_HALF_UP);
// Assert.assertEquals(bigDecimal.floatValue(), 5);
}
}
\ No newline at end of file
... ...
... ... @@ -14,7 +14,7 @@ public class AnnotaionEntity {
public String curPageNo;
public List<PointGroupEntity> pointGroup;
public String color;
public String thickness;
public int thickness;
public String radius;
public String fontSize;
public String fontName;
... ...
... ... @@ -4,7 +4,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.DisplayMetrics;
... ... @@ -79,6 +78,12 @@ public class DocFragment extends AppBaseFragment<LivePresenter> implements LiveC
docUrlTransformBitmap(null);
}
@Override
public void onDestroyView() {
super.onDestroyView();
handler.removeCallbacksAndMessages(null);
}
private void getWindowWith(DisplayMetrics metric) {
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metric);
winWidth = metric.widthPixels; // 屏幕宽度(像素)
... ... @@ -115,18 +120,7 @@ public class DocFragment extends AppBaseFragment<LivePresenter> implements LiveC
public final static int SEND = 0;
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
int what = msg.what;
WhiteboardUpdateEntity obj = (WhiteboardUpdateEntity) msg.obj;
switch (what) {
case SEND:
mCanvasView.drawLine(obj.annotaionItems);
break;
}
}
};
static Handler handler = new Handler();
/**
* @param entity
... ... @@ -147,7 +141,7 @@ public class DocFragment extends AppBaseFragment<LivePresenter> implements LiveC
}
private void delayDraw(final WhiteboardUpdateEntity entity) {
handler.postDelayed(new BaseRunnable<WhiteboardUpdateEntity>(entity) {
handler.postDelayed(new BaseRunnable<WhiteboardUpdateEntity>() {
@Override
protected void handle(WhiteboardUpdateEntity o) {
... ... @@ -218,20 +212,13 @@ public class DocFragment extends AppBaseFragment<LivePresenter> implements LiveC
@Override
public void call(WrapDocBitMapEntity resource) {
//用handler发送 跟drawline在一个队列里执行,否则顺序乱了导致切换图片的时候还有上一个画面的标注
handler.post(new BaseRunnable<WrapDocBitMapEntity>(resource) {
@Override
protected void handle(WrapDocBitMapEntity wrapDocBitMapEntity) {
if (wrapDocBitMapEntity.getBitmap() == null) {
showMessage("图片获取失败");
Bitmap bitmap = getNoDocBitmap();
mCanvasView.setBitmap(bitmap, false);
} else {
mCanvasView.setBitmap(wrapDocBitMapEntity.getBitmap(), !wrapDocBitMapEntity.showNoDoc());
}
}
});
if (resource.getBitmap() == null) {
showMessage("图片获取失败");
Bitmap bitmap = getNoDocBitmap();
mCanvasView.setBitmap(bitmap, false);
} else {
mCanvasView.setBitmap(resource.getBitmap(), !resource.showNoDoc());
}
}
});
}
... ...
... ... @@ -7,6 +7,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.MotionEvent;
... ... @@ -796,6 +797,25 @@ public class LiveFragment extends AppBaseFragment<LivePresenter> implements Live
}
@Override
public void showAlertDialog(@StringRes int alertStr) {
AlertDialog dialog = new AlertDialog.Builder(getContext())
.setTitle(R.string.home_pwd_mention)
.setMessage(alertStr)
.setPositiveButton(R.string.home_confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
})
.create();
dialog.show();
dialog.setCanceledOnTouchOutside(false);
}
@Override
public void showErrorDialog(String reason) {
if (mErrorDialog != null)
... ... @@ -823,6 +843,11 @@ public class LiveFragment extends AppBaseFragment<LivePresenter> implements Live
}
}
@Override
public boolean getVisible() {
return this.isSupportVisible();
}
private SeekBar.OnSeekBarChangeListener mSeekListener = new SeekBar.OnSeekBarChangeListener() {
public void onStartTrackingTouch(SeekBar bar) {
... ... @@ -891,4 +916,6 @@ public class LiveFragment extends AppBaseFragment<LivePresenter> implements Live
mShowing = false;
}
}
}
... ...
... ... @@ -110,23 +110,23 @@ public interface Constants {
/**
* 获取录制回放数据失败
*/
String GET_RECORD_ERROR = "911";
int GET_RECORD_ERROR = 911;
/**
* 初始化录制回放失败
*/
String INIT_RECORD_ERROR = "910";
int INIT_RECORD_ERROR = 910;
/**
* [加入课堂] 有相同身份的人员加入课堂,自己被踢出课堂
*/
String KICK_SELF = "208";
int KICK_SELF = 208;
/**
* [加入课堂] 已经在其它地方登陆
*/
String ALREAD_LOGIN = "207";
int ALREAD_LOGIN = 207;
/**
* [加入课堂] 密码错误
*/
String PWD_ERROR = "206";
int PWD_ERROR = 206;
/**
* [加入课堂] 人数已满
*/
... ...
... ... @@ -17,6 +17,7 @@
package com.xdy.home.vp;
import android.content.Context;
import android.support.annotation.StringRes;
import android.view.SurfaceView;
import com.xdy.commonlibrary.mvp.BaseView;
... ... @@ -123,6 +124,7 @@ public interface LiveContract {
* @param reson
*/
void showErrorDialog(int reson);
/**
* 展示错误界面
* @param reson
... ... @@ -130,9 +132,20 @@ public interface LiveContract {
void showErrorDialog(String reson);
/**
* 提示框
* @param alertStr
*/
void showAlertDialog(@StringRes int alertStr);
/**
* 重置SEEKBAR
*/
void resetSeekBar();
/**
* 获取界面状态
*/
boolean getVisible();
}
interface ChatView extends BaseView {
... ...
... ... @@ -380,11 +380,13 @@ public class LivePresenter extends BasePresenter<LiveContract.Model, LiveContrac
public void playAudio(String pa) {
currentPlayAudio = GsonUtil.json2Bean(pa, VideoEntity.class);
if (currentPlayAudio != null) {
checkPlayMode(false);
mRootView.playAudio(currentPlayAudio);
} else {
mRootView.showMessage(ResUtil.get().getString(R.string.home_parse_error));
if (mRootView.getVisible()) {
if (currentPlayAudio != null) {
checkPlayMode(false);
mRootView.playAudio(currentPlayAudio);
} else {
mRootView.showMessage(ResUtil.get().getString(R.string.home_parse_error));
}
}
}
... ... @@ -400,12 +402,14 @@ public class LivePresenter extends BasePresenter<LiveContract.Model, LiveContrac
public void playVideo(String pa) {
currentPlayVideo = GsonUtil.json2Bean(pa, VideoEntity.class);
if (currentPlayVideo != null) {
checkPlayMode(true);
if (mRootView.getVisible()) {
if (currentPlayVideo != null) {
checkPlayMode(true);
// String rtmpUrl = currentPlayVideo.getRtmpUrl();
mRootView.playVideo(currentPlayVideo);
} else {
mRootView.showMessage(ResUtil.get().getString(R.string.home_parse_error));
mRootView.playVideo(currentPlayVideo);
} else {
mRootView.showMessage(ResUtil.get().getString(R.string.home_parse_error));
}
}
}
... ... @@ -453,7 +457,10 @@ public class LivePresenter extends BasePresenter<LiveContract.Model, LiveContrac
if (errorEvent != null) {
String reason = errorEvent.getReson();
if (!TextUtils.isEmpty(reason) && !(Constants.LEAVE_CLASS_CODE == errorEvent.getCode())) {
if (Constants.PWD_ERROR == errorEvent.getCode()) {//密码错误
mRootView.showAlertDialog(R.string.home_pwd_wrong);
} else if (!TextUtils.isEmpty(reason) && !(Constants.LEAVE_CLASS_CODE == errorEvent.getCode())) {
connceted = false;
mRootView.showMessage(reason);
mRootView.quit();
... ...
... ... @@ -131,12 +131,17 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
pathLists.clear();
this.historyPointer = 0;
for (List<PointGroupEntity> pointGroupEntities : originPoint) {
// Path path = new Path();
// path.addCircle(pointGroupEntities.get(0).w / 100 * finalWidth, pointGroupEntities.get(0).h / 100 * finalWidth + currentTop, annotations.get(0).thickness, Path.Direction.CW);
// pathLists.add(path);
pathLists.add(createPath(pointGroupEntities.get(0).w / 100 * finalWidth, pointGroupEntities.get(0).h / 100 * finalWidth + currentTop));
this.historyPointer++;
for (int j = 0; j < pointGroupEntities.size(); j++) {
PointGroupEntity pointGroupEntity = pointGroupEntities.get(j);
Path path = this.getCurrentPath();
path.lineTo(pointGroupEntity.w / 100 * finalWidth, pointGroupEntity.h / 100 * finalWidth + currentTop);
Path p = this.getCurrentPath();
// p.addCircle(pointGroupEntity.w / 100 * finalWidth, pointGroupEntity.h / 100 * finalWidth + currentTop, annotations.get(0).thickness, Path.Direction.CW);
p.lineTo(pointGroupEntity.w / 100 * finalWidth, pointGroupEntity.h / 100 * finalWidth + currentTop);
}
}
}
... ... @@ -269,6 +274,9 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
float h = pointGroupEntities.get(0).h + (FLOAT_TYPE * offsetY) / (FLOAT_TYPE * finalWidth) * 100f;
pointGroupEntities.get(0).h = h;
// Path p = new Path();
// p.addCircle(w / 100f * finalWidth, h / 100f * finalWidth, annotations.get(0).thickness, Path.Direction.CW);
// pathLists.add(p);
pathLists.add(createPath(w / 100f * finalWidth, h / 100f * finalWidth));
historyPointer++;
for (int j = 1; j < pointGroupEntities.size(); j++) {
... ... @@ -278,6 +286,7 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
float h2 = pointGroupEntity.h + (FLOAT_TYPE * offsetY) / (FLOAT_TYPE * finalWidth) * 100f;
pointGroupEntity.h = h2;
path.lineTo(w2 / 100 * finalWidth, h2 / 100 * finalWidth);
// path.addCircle(w2 / 100 * finalWidth, h2 / 100 * finalWidth, annotations.get(0).thickness, Path.Direction.CW);
}
}
}
... ... @@ -358,13 +367,20 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
pathLists.clear();
historyPointer = 0;
for (List<PointGroupEntity> pointGroupEntities : operatePoints) {
// Path p = new Path();
// p.addCircle(pointGroupEntities.get(0).w / 100f * finalWidth, pointGroupEntities.get(0).h / 100f * finalWidth, annotations.get(0).thickness, Path.Direction.CW);
// pathLists.add(p);
pathLists.add(createPath(pointGroupEntities.get(0).w / 100 * finalWidth, pointGroupEntities.get(0).h / 100 * finalWidth + currentTop));
historyPointer++;
for (int i = 1; i < pointGroupEntities.size(); i++) {
PointGroupEntity pointGroupEntity = pointGroupEntities.get(i);
Path path = this.getCurrentPath();
path.lineTo(pointGroupEntity.w / 100 * finalWidth, pointGroupEntity.h / 100 * finalWidth + currentTop);
// path.addCircle(pointGroupEntity.w / 100 * finalWidth, pointGroupEntity.h / 100 * finalWidth, annotations.get(0).thickness, Path.Direction.CW);
}
}
... ... @@ -395,6 +411,7 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
/**
* 记录最原始的数据
*/
private List<AnnotaionEntity> annotations = new ArrayList<>();
private List<List<PointGroupEntity>> originPoint = new ArrayList<>();
private List<List<PointGroupEntity>> operatePoints = new ArrayList<>();
private List<Path> pathLists = new ArrayList<Path>();
... ... @@ -452,9 +469,6 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
// this.setZOrderMediaOverlay(true);
this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
// this.pathLists.add(new Path());
// this.paintLists.add(this.createPaint(paintFillColor));
// this.historyPointer++;
screenWidth = DisplayUtil.getScreenWidth(getContext());
}
... ... @@ -464,14 +478,14 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
* @param color
* @return paint This is returned as the instance of Paint
*/
private Paint createPaint(int color) {
private Paint createPaint(int color, int thickness) {
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(this.paintStyle);
paint.setStrokeWidth(this.paintStrokeWidth);///设置线宽
paint.setStrokeWidth(thickness);///设置线宽
paint.setStrokeCap(this.lineCap);
paint.setStrokeJoin(Paint.Join.MITER); // fixed
paint.setStrokeJoin(Paint.Join.ROUND); // fixed
// Otherwise
paint.setColor(color);
paint.setShadowLayer(this.blur, 0F, 0F, this.paintStrokeColor);
... ... @@ -521,23 +535,12 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
* @param annotations
*/
public void drawLine(List<AnnotaionEntity> annotations) {
this.annotations.addAll(annotations);
for (AnnotaionEntity annotation : annotations) {
List<PointGroupEntity> pointXies = annotation.pointGroup;
int color = Color.parseColor(annotation.color);
setPaintFillColor(color);
copyArr(pointXies);
// adjustPath(mRectDes.top);
// for (int j = 0; j < pointXies.size(); j++) {
// PointGroupEntity pointGroupEntity = pointXies.get(j);
// Path path = this.getCurrentPath();
// float w2 = pointGroupEntity.w;
// float h2 = pointGroupEntity.h + (FLOAT_TYPE * mRectDes.top) / (FLOAT_TYPE * finalWidth) * 100f;
// pointGroupEntity.h = h2;
// path.lineTo(w2 / 100 * finalWidth, h2 / 100 * finalWidth);
// }
for (PointGroupEntity pointXy : pointXies) {
float w = pointXy.w;
float h = pointXy.h + (FLOAT_TYPE * currentOffsetY) / (FLOAT_TYPE * finalWidth) * 100f;
... ... @@ -546,11 +549,18 @@ public class CanvasView extends SurfaceView implements SurfaceHolder.Callback, V
//操作一下這個點
operatePoints.add(pointXies);
// Path path = new Path();
// path.addCircle(pointXies.get(0).w / 100 * finalWidth, pointXies.get(0).h / 100 * finalWidth + currentTop, annotations.get(0).thickness, Path.Direction.CW);
// pathLists.add(path);
pathLists.add(createPath(pointXies.get(0).w / 100 * finalWidth, pointXies.get(0).h / 100 * finalWidth + currentTop));
paintLists.add(this.createPaint(color));
paintLists.add(this.createPaint(color, annotation.thickness * 2));
this.historyPointer++;
for (int i = 0; i < pointXies.size(); i++) {
Path path = this.getCurrentPath();
// p.addCircle(pointXies.get(i).w / 100 * finalWidth, pointXies.get(i).h / 100 * finalWidth + currentTop, annotation.thickness, Path.Direction.CW);
path.lineTo(pointXies.get(i).w / 100 * finalWidth, pointXies.get(i).h / 100 * finalWidth + currentTop);
}
}
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="6dp">
xmlns:my="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/ui_DIMEN_24.0PX"
android:paddingRight="@dimen/ui_DIMEN_24.0PX">
<TextView
... ... @@ -17,7 +18,7 @@
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/ui_DIMEN_22.0PX"
android:visibility="gone"/>
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
... ... @@ -29,7 +30,7 @@
android:id="@+id/chat_item_avatar"
style="@style/home_chat_item_avatar"
android:layout_alignParentLeft="true"/>
android:layout_alignParentLeft="true" />
<LinearLayout
android:id="@+id/ll_item_name_parent"
... ... @@ -51,7 +52,7 @@
android:text="老师"
android:textColor="@color/white"
android:textSize="@dimen/ui_DIMEN_20.0PX"
android:visibility="gone"/>
android:visibility="gone" />
<TextView
android:id="@+id/chat_item_name"
... ... @@ -59,7 +60,7 @@
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/COLOR_808080"
android:textSize="@dimen/ui_DIMEN_22.0PX"/>
android:textSize="@dimen/ui_DIMEN_22.0PX" />
</LinearLayout>
... ... @@ -77,15 +78,15 @@
android:layout_centerInParent="true"
android:background="@drawable/chat_pop_receive"
android:gravity="start|center_vertical"
android:paddingLeft="@dimen/ui_DIMEN_30.0PX"
android:paddingLeft="@dimen/ui_DIMEN_20.0PX"
android:paddingRight="@dimen/ui_DIMEN_10.0PX"
my:emojiconSize="@dimen/ui_DIMEN_40.0PX"
tools:text="fasdfasdfasdfasdfasdfasdfasdfasddfasdfasdfasdfasdffasdfasdfsadfsadfasddfasdfasfdasdfasdfsafasdfadf"/>
tools:text="" />
<ImageView
android:id="@+id/chat_item_content_image"
style="@style/home_chat_item_image_content"
android:visibility="gone"/>
android:visibility="gone" />
</RelativeLayout>
<ImageView
... ... @@ -96,7 +97,7 @@
android:layout_toRightOf="@+id/chat_item_layout_content"
android:background="@mipmap/msg_state_fail_resend"
android:focusable="false"
android:visibility="gone"/>
android:visibility="gone" />
<ProgressBar
android:id="@+id/chat_item_progress"
... ... @@ -105,7 +106,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/chat_item_layout_content"
android:visibility="gone"/>
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -76,8 +76,8 @@
android:textColor="@color/white"
android:includeFontPadding="false"
android:paddingLeft="@dimen/ui_DIMEN_10.0PX"
android:paddingRight="@dimen/ui_DIMEN_30.0PX"
tools:text="fasdfasdfasdfasdfasdfasdfasdfasddfasdfasdfasdfsadfsadfasddfasdfasfdasdfasdfsafasdfadf"
android:paddingRight="@dimen/ui_DIMEN_20.0PX"
tools:text=""
my:emojiconSize="@dimen/ui_DIMEN_40.0PX"/>
<ImageView
... ...
... ... @@ -22,6 +22,7 @@
android:id="@+id/et_password"
style="@style/home_login_edit_style"
android:hint="@string/home_password"
android:inputType="textPassword"
android:visibility="gone"/>
<Button
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_chat_fragment_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ll_chat_fragment_parent"
android:background="@color/COLOR_EBEBEB"
android:orientation="vertical">
<com.xdy.home.widget.chat.KJChatKeyboard
android:id="@+id/chat_msg_input_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<ListView
android:id="@+id/chat_listview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_above="@+id/chat_msg_input_box"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="@dimen/ui_DIMEN_24.0PX"
android:dividerHeight="@dimen/ui_DIMEN_15.0PX"
android:scrollbarStyle="outsideOverlay"
android:transcriptMode="normal"/>
android:transcriptMode="normal" />
<View
android:id="@+id/view_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#7fd8d8d8"/>
android:layout_below="@id/chat_listview"
android:background="#7fd8d8d8" />
<com.xdy.home.widget.chat.KJChatKeyboard
android:id="@+id/chat_msg_input_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
<!-- -->
</RelativeLayout>
\ No newline at end of file
... ...
... ... @@ -28,7 +28,7 @@
android:src="@mipmap/logo"/>
<!-- classId 709902904 472732494 2067973545 1895498438-->
<!-- classId 349044325 472732494 1895498438-->
<RelativeLayout
android:id="@+id/rl_classid"
style="@style/home_input_style"
... ...
... ... @@ -26,4 +26,6 @@
<string name="home_no_audio_permission">无法传输音频,请检查你的麦克风权限</string>
<string name="home_no_resouce_to_open">暂无可用音视频</string>
<string name="home_class_is_over">课堂已结束</string>
<string name="home_pwd_mention">密码错误</string>
<string name="home_pwd_wrong">请输入正确密码</string>
</resources>
... ...
... ... @@ -20,8 +20,8 @@
<style name="home_chat_item_text_content" parent="ui_wrapTvBaseStyle">
<item name="android:clickable">false</item>
<item name="android:focusable">false</item>
<item name="android:paddingTop">@dimen/ui_DIMEN_10.0PX</item>
<item name="android:paddingBottom">@dimen/ui_DIMEN_10.0PX</item>
<item name="android:paddingTop">@dimen/ui_DIMEN_15.0PX</item>
<item name="android:paddingBottom">@dimen/ui_DIMEN_15.0PX</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textColor">#323232</item>
<item name="android:textSize">@dimen/ui_DIMEN_28.0PX</item>
... ...