im
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
infoAdapter = new ServerInfoAdapter(getActivity(), infoList);
mRecyclerView.setAdapter(infoAdapter);
- infoAdapter.ServerInfoClickListener(this);
showPackageInfo();
}
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PlayVideoActivity.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PlayVideoActivity.java
new file mode 100644
index 0000000000..ee387b944e
--- /dev/null
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PlayVideoActivity.java
@@ -0,0 +1,176 @@
+/**
+ * Copyright 2021 Huawei Technologies Co., Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.mindspore.himindspore.ui.me;
+
+
+import android.content.res.Configuration;
+import android.view.View;
+
+import com.mindspore.common.base.mvp.BaseActivity;
+import com.mindspore.himindspore.R;
+import com.mindspore.himindspore.ui.lessons.LessonGSYVideoPlayer;
+
+import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
+import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
+import com.shuyu.gsyvideoplayer.listener.LockClickListener;
+import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
+import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
+
+import org.jetbrains.annotations.NotNull;
+
+public class PlayVideoActivity extends BaseActivity {
+
+ LessonGSYVideoPlayer videoPlayer;
+ String filePath;
+ String fileTitle;
+ OrientationUtils orientationUtils;
+ private GSYVideoOptionBuilder gsyVideoOption;
+ private boolean isPlay;
+ private boolean isPause;
+ private int videoPlayState = GSYVideoView.CURRENT_STATE_NORMAL;
+
+ protected void init() {
+ videoPlayer = findViewById(R.id.player);
+ filePath = getIntent().getStringExtra("filePath");
+ fileTitle = filePath.substring(filePath.lastIndexOf('/'));
+
+ initPlayer();
+ playVideo();
+ }
+
+ private void playVideo() {
+ videoPlayer.startPlayLogic();
+ }
+
+ private void initPlayer() {
+ videoPlayer.setUp(filePath, true, fileTitle);
+ // 增加title
+ videoPlayer.getTitleTextView().setVisibility(View.GONE);
+ //设置返回键
+ videoPlayer.getBackButton().setVisibility(View.VISIBLE);
+ //设置返回按键功能
+ videoPlayer.getBackButton().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onBackPressed();
+ }
+ });
+ // 外部辅助的旋转,帮助全屏
+ orientationUtils = new OrientationUtils(this, videoPlayer);
+ // 初始化不打开外部的旋转
+ orientationUtils.setEnable(false);
+ initVideo();
+ videoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //直接横屏
+ orientationUtils.resolveByClick();
+ //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusBar
+ videoPlayer.startWindowFullscreen(PlayVideoActivity.this, true, true);
+ }
+ });
+ }
+
+ private void initVideo() {
+ gsyVideoOption = new GSYVideoOptionBuilder();
+ gsyVideoOption.setThumbImageView(new View(this))
+ .setIsTouchWiget(true)
+ .setRotateViewAuto(false)
+ .setLockLand(false)
+ .setAutoFullWithSize(false)
+ .setShowFullAnimation(false)
+ .setNeedLockFull(true)
+ .setUrl(filePath)
+ .setCacheWithPlay(true)
+ .setVideoTitle(fileTitle)
+ .setVideoAllCallBack(new GSYSampleCallBack() {
+ @Override
+ public void onPrepared(String url, Object... objects) {
+ super.onPrepared(url, objects);
+ // 开始播放了才能旋转和全屏
+ orientationUtils.setEnable(videoPlayer.isRotateWithSystem());
+ isPlay = true;
+ }
+
+ @Override
+ public void onPlayError(String url, Object... objects) {
+ super.onPlayError(url, objects);
+ }
+
+ @Override
+ public void onQuitFullscreen(String url, Object... objects) {
+ super.onQuitFullscreen(url, objects);
+ if (orientationUtils != null) {
+ orientationUtils.backToProtVideo();
+ }
+ }
+ }).setLockClickListener(new LockClickListener() {
+ @Override
+ public void onClick(View view, boolean lock) {
+ if (orientationUtils != null) {
+ //配合下方的onConfigurationChanged
+ orientationUtils.setEnable(!lock);
+ }
+ }
+ }).build(videoPlayer);
+ }
+
+ @Override
+ public int getLayout() {
+ return R.layout.activity_play_video;
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ videoPlayState = videoPlayer.getCurrentState();
+ videoPlayer.getCurrentPlayer().onVideoPause();
+ isPause = true;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (videoPlayState == GSYVideoView.CURRENT_STATE_PLAYING) {
+ videoPlayer.getCurrentPlayer().onVideoResume(false);
+ isPause = false;
+ }
+ }
+
+ /**
+ * orientationUtils 和 detailPlayer.onConfigurationChanged 方法是用于触发屏幕旋转的
+ */
+ @Override
+ public void onConfigurationChanged(@NotNull Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ //如果旋转了就全屏
+ if (isPlay && !isPause) {
+ videoPlayer.onConfigurationChanged(this, newConfig, orientationUtils,
+ true, true);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (isPlay) {
+ videoPlayer.getCurrentPlayer().release();
+ }
+ if (orientationUtils != null)
+ orientationUtils.releaseListener();
+ }
+}
\ No newline at end of file
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/CacheAdapter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/CacheAdapter.java
index 788d784d73..58f9af06f4 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/CacheAdapter.java
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/CacheAdapter.java
@@ -16,6 +16,10 @@
package com.mindspore.himindspore.ui.me.adapter;
import android.content.Context;
+import android.content.Intent;
+
+import android.net.Uri;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,16 +29,23 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
+import com.bumptech.glide.request.RequestOptions;
import com.mindspore.himindspore.R;
+import com.mindspore.himindspore.ui.me.PlayVideoActivity;
+import java.io.File;
+import java.text.DecimalFormat;
import java.util.ArrayList;
public class CacheAdapter extends RecyclerView.Adapter {
+ private static final String TAG = CacheAdapter.class.getSimpleName();
private Context mContext;
- private ArrayList mList = new ArrayList();
+ private ArrayList mList;
- public CacheAdapter(Context mContext, ArrayList mList) {
+ public CacheAdapter(Context mContext, ArrayList mList) {
this.mContext = mContext;
this.mList = mList;
}
@@ -47,28 +58,51 @@ public class CacheAdapter extends RecyclerView.Adapter
@Override
public void onBindViewHolder(@NonNull CacheAdapter.ViewHolder holder, int position) {
- if (holder instanceof ViewHolder) {
+ String path = mList.get(position).getAbsolutePath();
+ Log.d(TAG, "onBindViewHolder path:" + path);
+// Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MICRO_KIND);
+// holder.thumbnailIv.setImageBitmap(bitmap);
+ Glide.with(mContext)
+ .load((Uri) null)
+ .apply(RequestOptions.bitmapTransform(new RoundedCorners(
+ (int) mContext.getResources().getDimension(R.dimen.listItemImageConner))))
+ .error(R.drawable.icon_default)
+ .placeholder(R.drawable.icon_default)
+ .into(holder.thumbnailIv);
- }
+ // holder.durationTv.setText(duration);
+ String name = mList.get(position).getName();
+ String title = name.substring(0, name.lastIndexOf('.'));
+ holder.nameTv.setText(title);
+
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
+ float fileSize = mList.get(position).length() / (1024*1024f); // 转为M为单位
+ holder.sizeTv.setText(decimalFormat.format(fileSize) + "M");
+ holder.itemView.setOnClickListener(v -> {
+ Intent intent = new Intent(mContext, PlayVideoActivity.class);
+ intent.putExtra("filePath", path);
+ mContext.startActivity(intent);
+ }
+ );
}
@Override
public int getItemCount() {
- return 6;
+ return mList.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
- ImageView imageView;
- TextView name, source, size, duration;
+ ImageView thumbnailIv;
+ TextView nameTv, sourceTv, sizeTv, durationTv;
public ViewHolder(@NonNull View itemView) {
super(itemView);
- /*imageView = itemView.findViewById(R.id.case_image);
- name = itemView.findViewById(R.id.case_name);
- source = itemView.findViewById(R.id.case_image);
- size = itemView.findViewById(R.id.case_image);
- duration = itemView.findViewById(R.id.case_image);*/
+ thumbnailIv = itemView.findViewById(R.id.cache_image);
+ nameTv = itemView.findViewById(R.id.cache_name);
+ sourceTv = itemView.findViewById(R.id.cache_source);
+ sizeTv = itemView.findViewById(R.id.cache_size);
+ durationTv = itemView.findViewById(R.id.cache_duration);
}
}
}
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/ServerInfoAdapter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/ServerInfoAdapter.java
index a26836f125..41ef404eb0 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/ServerInfoAdapter.java
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/adapter/ServerInfoAdapter.java
@@ -35,11 +35,7 @@ public class ServerInfoAdapter extends RecyclerView.Adapter {
- if (serverItemClickListener != null) {
- serverItemClickListener.onServerItemClickListener(position);
- }
- });
+ holder.itemView.setOnClickListener(infoList.get(position).getClickListener());
}
@Override
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/bean/ServerInfoBean.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/bean/ServerInfoBean.java
index e926ef516c..0dbf370458 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/bean/ServerInfoBean.java
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/bean/ServerInfoBean.java
@@ -1,14 +1,33 @@
package com.mindspore.himindspore.ui.me.bean;
import android.graphics.drawable.Drawable;
+import android.view.View;
+
+import com.mindspore.customview.ui.MyToast;
public class ServerInfoBean {
private String name;
private Drawable pic;
+ private View.OnClickListener clickListener;
+
+ public View.OnClickListener getClickListener() {
+ return clickListener;
+ }
+
+ public void setClickListener(View.OnClickListener clickListener) {
+ this.clickListener = clickListener;
+ }
public ServerInfoBean(String name, Drawable pic) {
this.name = name;
this.pic = pic;
+ clickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // 默认的点击事件是 弹出“该功能未开放”
+ MyToast.FunctionNoOpen();
+ }
+ };
}
public String getName() {
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml
index 729cff1b34..7631d7a0cf 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml
@@ -129,7 +129,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:layout_marginStart="64dp"
+ android:layout_marginStart="40dp"
android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/adapter_layout_cache.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/adapter_layout_cache.xml
index 41305397fc..74cb816fa9 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/adapter_layout_cache.xml
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/adapter_layout_cache.xml
@@ -1,6 +1,8 @@
@@ -8,69 +10,62 @@
android:id="@+id/cache_image"
android:layout_width="112dp"
android:layout_height="63dp"
- android:layout_marginStart="10dp"
- android:layout_marginTop="11dp"
+ android:layout_marginTop="@dimen/spaceVerticalNormalSize"
android:scaleType="centerCrop"
android:src="@drawable/case_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
-
+ app:layout_constraintTop_toTopOf="@id/cache_image" />
-
-
+ app:layout_constraintBottom_toBottomOf="@id/cache_image" />
-
diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml
index 2c33d6d36b..3f34963708 100644
--- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml
+++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/values/strings.xml
@@ -178,6 +178,9 @@
收藏
我的课程
离线缓存
+ 缓存
+ 缓存中
+ 已缓存
问题反馈
GITEE代码
官方网站
@@ -207,6 +210,12 @@
历史观看课程
该功能暂未开放
没有可分享的数据
+ 没有可缓存的数据
+ 视频正在缓存
+ 视频已经下载
+ 视频缓存成功
+ 视频缓存失败
+ 您还没有缓存过视频
再按一次退出
倍速
diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java
index 694f9cde84..266e73d5bf 100644
--- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java
+++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java
@@ -6,9 +6,21 @@ import java.io.File;
public class StorageUtils {
- public static final String STORAGE_PHOTO = Environment.getExternalStorageDirectory() + File.separator + "photo.jpeg";
- public static final String VIDEO_PATH = Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_DOWNLOADS + "/";
- public static final String CRASH_PATH = Environment.getExternalStorageDirectory().getPath() + "/MindSpore/CrashLog/";
+ private static final String APP_NAME = "MindSpore";
- public static final File ABSOLUTE_FILE = Environment.getExternalStorageDirectory().getAbsoluteFile();
+ public static final String STORAGE_PHOTO = Environment.getExternalStorageDirectory()
+ + File.separator + "photo.jpeg";
+
+ public static final String VIDEO_PATH = Environment.getExternalStorageDirectory().getPath()
+ + "/" + Environment.DIRECTORY_DOWNLOADS + "/";
+
+ public static final String CRASH_PATH = Environment.getExternalStorageDirectory().getPath()
+ + "/MindSpore/CrashLog/";
+
+ public static final String VIDEO_DOWNLOAD_PATH =
+ Environment.getExternalStorageDirectory().getPath() + "/"
+ + Environment.DIRECTORY_DOWNLOADS + "/" + APP_NAME + "/";
+
+ public static final File ABSOLUTE_FILE = Environment.getExternalStorageDirectory()
+ .getAbsoluteFile();
}
diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java
index 1b903b1fc9..7abd4159b3 100644
--- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java
+++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/http/HttpClient.java
@@ -20,6 +20,7 @@ import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Streaming;
+import retrofit2.http.Url;
public interface HttpClient {
@@ -63,4 +64,8 @@ public interface HttpClient {
@Headers("Content-Type: application/json")
@POST("api/requestCourseDetail")
Observable> getCourseDetailData(@Body RequestIdBean requestIdBean);
+
+ @Streaming
+ @GET()
+ Observable downloadVideo(@Url String url);
}
\ No newline at end of file
diff --git a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/MyToast.java b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/MyToast.java
index a1e04e9433..93a645ff83 100644
--- a/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/MyToast.java
+++ b/model_zoo/official/lite/MindSpore_inhand/customView/src/main/java/com/mindspore/customview/ui/MyToast.java
@@ -93,9 +93,9 @@ public class MyToast {
}
}
- public static void MakeText(String text, int duration){
+ public static void MakeText(String text, int duration) {
MyToast makeView = new MyToast(Utils.getApp(), null);
- makeView.show(text,duration);
+ makeView.show(text, duration);
}
public static void FunctionNoOpen(){
MyToast.MakeText(Utils.getApp().getResources().getString(R.string.function_not_open),800);
diff --git a/model_zoo/official/lite/MindSpore_inhand/dance/src/main/res/values/strings.xml b/model_zoo/official/lite/MindSpore_inhand/dance/src/main/res/values/strings.xml
index ea4d57e73d..309f3e5fbc 100644
--- a/model_zoo/official/lite/MindSpore_inhand/dance/src/main/res/values/strings.xml
+++ b/model_zoo/official/lite/MindSpore_inhand/dance/src/main/res/values/strings.xml
@@ -16,6 +16,7 @@
抱歉,您没有授予相机访问权限
下载
下载失败
+ 下载完毕
"舞蹈视频下载中 ...%1$d%2$s"
恭喜完成,综合得分:
--
Gitee