diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/res/drawable/ic_image_cover.xml b/app/src/main/res/drawable/ic_image_cover.xml new file mode 100644 index 0000000..04444da --- /dev/null +++ b/app/src/main/res/drawable/ic_image_cover.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/res/drawable/ic_image_cover.xml b/app/src/main/res/drawable/ic_image_cover.xml new file mode 100644 index 0000000..04444da --- /dev/null +++ b/app/src/main/res/drawable/ic_image_cover.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_video_cover.xml b/app/src/main/res/drawable/ic_video_cover.xml new file mode 100644 index 0000000..5ac1ab3 --- /dev/null +++ b/app/src/main/res/drawable/ic_video_cover.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/res/drawable/ic_image_cover.xml b/app/src/main/res/drawable/ic_image_cover.xml new file mode 100644 index 0000000..04444da --- /dev/null +++ b/app/src/main/res/drawable/ic_image_cover.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_video_cover.xml b/app/src/main/res/drawable/ic_video_cover.xml new file mode 100644 index 0000000..5ac1ab3 --- /dev/null +++ b/app/src/main/res/drawable/ic_video_cover.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_full_screen_video.xml b/app/src/main/res/layout/activity_full_screen_video.xml new file mode 100644 index 0000000..ed2fb95 --- /dev/null +++ b/app/src/main/res/layout/activity_full_screen_video.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/res/drawable/ic_image_cover.xml b/app/src/main/res/drawable/ic_image_cover.xml new file mode 100644 index 0000000..04444da --- /dev/null +++ b/app/src/main/res/drawable/ic_image_cover.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_video_cover.xml b/app/src/main/res/drawable/ic_video_cover.xml new file mode 100644 index 0000000..5ac1ab3 --- /dev/null +++ b/app/src/main/res/drawable/ic_video_cover.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_full_screen_video.xml b/app/src/main/res/layout/activity_full_screen_video.xml new file mode 100644 index 0000000..ed2fb95 --- /dev/null +++ b/app/src/main/res/layout/activity_full_screen_video.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_standard_file.xml b/app/src/main/res/layout/activity_standard_file.xml index cd6b399..3f72f91 100644 --- a/app/src/main/res/layout/activity_standard_file.xml +++ b/app/src/main/res/layout/activity_standard_file.xml @@ -22,5 +22,5 @@ android:layout_height="match_parent" android:scrollbars="none" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" - app:spanCount="5" /> + app:spanCount="6" /> \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bc5072..f968fe0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,9 +86,12 @@ - + diff --git a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java index 5a1b423..12b1400 100644 --- a/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java +++ b/app/src/main/java/com/casic/br/ar/app/model/VideoGuideModel.java @@ -1,4 +1,184 @@ package com.casic.br.ar.app.model; +import java.util.List; + public class VideoGuideModel { + + private int code; + private DataModel data; + private String message; + private boolean success; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String attachment; + private String attachmentName; + private String classId; + private String className; + private String createTime; + private String createUserId; + private String createUserName; + private String id; + private String tag; + private String title; + private String updateTime; + private String updateUserId; + private String updateUserName; + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUserName() { + return createUserName; + } + + public void setCreateUserName(String createUserName) { + this.createUserName = createUserName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(String updateUserId) { + this.updateUserId = updateUserId; + } + + public String getUpdateUserName() { + return updateUserName; + } + + public void setUpdateUserName(String updateUserName) { + this.updateUserName = updateUserName; + } + } + } } diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt index c8f646e..cf6a4b1 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitService.kt @@ -88,12 +88,13 @@ /** * 获取指导视频 */ - @POST("/meter/file/listPage") + @GET("/knowledge-base/listPage") suspend fun getGuideVideoByPage( @Header("token") token: String, - @Body requestBody: RequestBody, - @QueryMap limit: Map, - @QueryMap offset: Map + @Query("keywords") keywords: String, + @Query("classId") classId: String, + @Query("offset") offset: Int, + @Query("limit") limit: Int ): String /** diff --git a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt index 67a17ea..cabd011 100644 --- a/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ar/app/retrofit/RetrofitServiceManager.kt @@ -131,20 +131,9 @@ /** * 获取指导视频 */ - suspend fun getGuideVideoByPage(keywords: String, offset: Int): String { - val param = JsonObject() - param.addProperty("keywords", keywords) - val requestBody = param.toString().toRequestBody( - "application/json;charset=UTF-8".toMediaType() - ) - - val limitMap = HashMap() - limitMap["limit"] = LocaleConstant.PAGE_LIMIT - - val offsetMap = HashMap() - offsetMap["offset"] = offset + suspend fun getGuideVideoByPage(keywords: String, classId: String, offset: Int): String { return api.getGuideVideoByPage( - AuthenticationHelper.token, requestBody, limitMap, offsetMap + AuthenticationHelper.token, keywords, classId, offset, LocaleConstant.PAGE_LIMIT ) } diff --git a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt index 885f6c3..0018d51 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/BigImageActivity.kt @@ -74,7 +74,7 @@ val view = LayoutInflater.from(context).inflate( R.layout.item_big_picture, container, false ) - val photoView: PhotoView = view.findViewById(R.id.photoView) + val photoView = view.findViewById(R.id.photoView) Glide.with(context).load(data[position]).into(photoView) photoView.scaleType = ImageView.ScaleType.CENTER container.addView(view) diff --git a/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt new file mode 100644 index 0000000..8801faa --- /dev/null +++ b/app/src/main/java/com/casic/br/ar/app/view/FullScreenVideoActivity.kt @@ -0,0 +1,71 @@ +package com.casic.br.ar.app.view + +import android.os.Bundle +import android.view.View +import com.casic.br.ar.app.databinding.ActivityFullScreenVideoBinding +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.utils.Constant +import com.shuyu.gsyvideoplayer.GSYVideoManager +import com.shuyu.gsyvideoplayer.utils.OrientationUtils + +class FullScreenVideoActivity : KotlinBaseActivity() { + private var orientationUtils: OrientationUtils? = null + + override fun initEvent() { + + } + + override fun initOnCreate(savedInstanceState: Bundle?) { + val videoPath = intent.getStringExtra(Constant.INTENT_PARAM) + binding.videoPlayer.setUp(videoPath, true, "") + + binding.videoPlayer.titleTextView.visibility = View.GONE + binding.videoPlayer.fullscreenButton.visibility = View.GONE + //设置旋转 + orientationUtils = OrientationUtils(this, binding.videoPlayer) + //是否可以滑动调整 + binding.videoPlayer.setIsTouchWiget(true) + + //不需要屏幕旋转 + binding.videoPlayer.isNeedOrientationUtils = false + binding.videoPlayer.startPlayLogic() + + binding.videoPlayer.backButton.setOnClickListener { onBackPressed() } + } + + override fun initViewBinding(): ActivityFullScreenVideoBinding { + return ActivityFullScreenVideoBinding.inflate(layoutInflater) + } + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN) + window.decorView.systemUiVisibility = uiOptions + } + + override fun onPause() { + super.onPause() + binding.videoPlayer.onVideoPause() + } + + override fun onResume() { + super.onResume() + binding.videoPlayer.onVideoResume() + } + + override fun onDestroy() { + super.onDestroy() + GSYVideoManager.releaseAllVideos() + orientationUtils?.releaseListener() + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + //释放所有 + binding.videoPlayer.setVideoAllCallBack(null) + super.onBackPressed() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt index 344ff49..ea0e5c9 100644 --- a/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt +++ b/app/src/main/java/com/casic/br/ar/app/view/VideoGuideActivity.kt @@ -7,103 +7,90 @@ import androidx.lifecycle.ViewModelProvider import com.casic.br.ar.app.R import com.casic.br.ar.app.databinding.ActivityVideoGuideBinding +import com.casic.br.ar.app.extensions.combineFilePath import com.casic.br.ar.app.model.VideoGuideModel import com.casic.br.ar.app.vm.VideoGuideViewModel import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter import com.pengxh.kt.lite.adapter.ViewHolder import com.pengxh.kt.lite.base.KotlinBaseActivity import com.pengxh.kt.lite.divider.RecyclerViewItemOffsets +import com.pengxh.kt.lite.extensions.dp2px +import com.pengxh.kt.lite.extensions.navigatePageTo import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.Constant import com.pengxh.kt.lite.utils.LoadState import com.pengxh.kt.lite.utils.LoadingDialogHub import com.pengxh.kt.lite.utils.WeakReferenceHandler class VideoGuideActivity : KotlinBaseActivity(), Handler.Callback { - private lateinit var weakReferenceHandler: WeakReferenceHandler + private val marginOffset by lazy { 5.dp2px(this) } + private val weakReferenceHandler by lazy { WeakReferenceHandler(this) } private lateinit var videoGuideViewModel: VideoGuideViewModel - private lateinit var videoGuideAdapter: NormalRecyclerAdapter - private var dataBeans: MutableList = ArrayList() - private var keywords = "" + private lateinit var videoGuideAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var classId = "" private var page = 1 - private var isRefresh = false - private var isLoadMore = false override fun initEvent() { - binding.searchButton.setOnClickListener { - keywords = binding.searchView.text.toString().trim() - } - binding.refreshLayout.setOnRefreshListener { - isRefresh = true - page = 1 - getGuideVideoByPage() - } - - binding.refreshLayout.setOnLoadMoreListener { - isLoadMore = true - page++ - getGuideVideoByPage() - } } override fun initOnCreate(savedInstanceState: Bundle?) { - weakReferenceHandler = WeakReferenceHandler(this) + classId = intent.getStringExtra(Constant.INTENT_PARAM) as String + videoGuideViewModel = ViewModelProvider(this)[VideoGuideViewModel::class.java] + getGuideVideoByPage() videoGuideViewModel.videosResult.observe(this) { -// if (it.code == 200) { -// val dataRows = it.data?.rows!! -// when { -// isRefresh -> { -// videoGuideAdapter.setRefreshData(dataRows) -// binding.refreshLayout.finishRefresh() -// isRefresh = false -// } -// -// isLoadMore -> { -// if (dataRows.size == 0) { -// "到底了,别拉了".show(this) -// } -// videoGuideAdapter.setLoadMoreData(dataRows) -// binding.refreshLayout.finishLoadMore() -// isLoadMore = false -// } -// -// else -> { -// dataBeans = dataRows -// weakReferenceHandler.sendEmptyMessage(2024030502) -// } -// } -// } + if (it.code == 200) { + it.data?.rows?.apply { + dataBeans = this + weakReferenceHandler.sendEmptyMessage(2024052401) + } + } } } private fun getGuideVideoByPage() { - videoGuideViewModel.getGuideVideoByPage(this, keywords, page) + videoGuideViewModel.getGuideVideoByPage(this, "", classId, page) } override fun handleMessage(msg: Message): Boolean { when (msg.what) { - 2024030502 -> { + 2024052401 -> { videoGuideAdapter = object : - NormalRecyclerAdapter( - R.layout.item_guide_video, dataBeans + NormalRecyclerAdapter( + R.layout.item_guide_video_g, dataBeans ) { override fun convertView( viewHolder: ViewHolder, position: Int, - item: VideoGuideModel + item: VideoGuideModel.DataModel.RowsModel ) { - + val imageSource = if (item.attachment.endsWith(".mp4")) { + R.drawable.ic_video_cover + } else { + R.drawable.ic_image_cover + } + viewHolder.setImageResource(R.id.imageView, imageSource) + .setText(R.id.fileTitleView, item.title) } } binding.recyclerView.adapter = videoGuideAdapter - binding.recyclerView.addItemDecoration(RecyclerViewItemOffsets(0, 7, 0, 7)) + binding.recyclerView.addItemDecoration( + RecyclerViewItemOffsets(marginOffset, marginOffset, marginOffset, marginOffset) + ) videoGuideAdapter.setOnItemClickedListener(object : - NormalRecyclerAdapter.OnItemClickedListener { + NormalRecyclerAdapter.OnItemClickedListener { override fun onItemClicked( - position: Int, t: VideoGuideModel + position: Int, t: VideoGuideModel.DataModel.RowsModel ) { - //TODO 查看指导视频详情 + if (t.attachment.endsWith(".mp4")) { + navigatePageTo(t.attachment.combineFilePath()) + } else { + navigatePageTo( + 0, arrayListOf(t.attachment.combineFilePath()) + ) + } } }) } diff --git a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt index 4b5218e..8b15d75 100644 --- a/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt +++ b/app/src/main/java/com/casic/br/ar/app/vm/VideoGuideViewModel.kt @@ -18,9 +18,11 @@ private val gson by lazy { Gson() } val videosResult = MutableLiveData() - fun getGuideVideoByPage(context: Context, keywords: String, offset: Int) = launch({ + fun getGuideVideoByPage( + context: Context, keywords: String, classId: String, offset: Int + ) = launch({ loadState.value = LoadState.Loading - val response = RetrofitServiceManager.getGuideVideoByPage(keywords, offset) + val response = RetrofitServiceManager.getGuideVideoByPage(keywords, classId, offset) when (response.getResponseCode()) { 200 -> { loadState.value = LoadState.Success diff --git a/app/src/main/res/drawable/ic_image_cover.xml b/app/src/main/res/drawable/ic_image_cover.xml new file mode 100644 index 0000000..04444da --- /dev/null +++ b/app/src/main/res/drawable/ic_image_cover.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_video_cover.xml b/app/src/main/res/drawable/ic_video_cover.xml new file mode 100644 index 0000000..5ac1ab3 --- /dev/null +++ b/app/src/main/res/drawable/ic_video_cover.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_full_screen_video.xml b/app/src/main/res/layout/activity_full_screen_video.xml new file mode 100644 index 0000000..ed2fb95 --- /dev/null +++ b/app/src/main/res/layout/activity_full_screen_video.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_standard_file.xml b/app/src/main/res/layout/activity_standard_file.xml index cd6b399..3f72f91 100644 --- a/app/src/main/res/layout/activity_standard_file.xml +++ b/app/src/main/res/layout/activity_standard_file.xml @@ -22,5 +22,5 @@ android:layout_height="match_parent" android:scrollbars="none" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" - app:spanCount="5" /> + app:spanCount="6" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_video_guide.xml b/app/src/main/res/layout/activity_video_guide.xml index 5a9e62f..b473864 100644 --- a/app/src/main/res/layout/activity_video_guide.xml +++ b/app/src/main/res/layout/activity_video_guide.xml @@ -4,74 +4,23 @@ android:id="@+id/rootView" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/themeColor" + android:background="@color/black" android:orientation="vertical"> - + android:fontFamily="sans-serif-black" + android:padding="@dimen/dp_10" + android:text="指导视频" + android:textColor="@color/white" + android:textSize="@dimen/sp_18" /> - - - - -