version:1.1.3
update:分包,增加空间信息,更换图标 bugfixes:
@@ -16,8 +16,8 @@ android {
|
||||
applicationId "com.uiui.videoplayer"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 28
|
||||
versionCode 109
|
||||
versionName "1.0.8"
|
||||
versionCode 114
|
||||
versionName "1.1.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -42,11 +42,39 @@ android {
|
||||
//签名
|
||||
signingConfigs {
|
||||
tuixin {// 签名文件
|
||||
storeFile file("src/doc/tuixin.jks")
|
||||
storeFile file("keystore/tuixin.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "universal"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
//多版本
|
||||
productFlavors {
|
||||
uiui {
|
||||
flavorDimensions "default"
|
||||
}
|
||||
|
||||
uiuios {
|
||||
flavorDimensions "default"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
uiui {
|
||||
java {
|
||||
srcDirs += ['uiui/java'] // 5 添加
|
||||
}
|
||||
aidl.srcDirs 'src/uiui/aidl'
|
||||
}
|
||||
|
||||
uiuios {
|
||||
java {
|
||||
srcDirs += ['uiuios/java'] // 5 添加
|
||||
}
|
||||
aidl.srcDirs 'src/uiuios/aidl'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +131,7 @@ dependencies {
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.video.VideoActivity"
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.uiui.videoplayer.activity.main;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -17,25 +16,21 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.othershe.combinebitmap.CombineBitmap;
|
||||
import com.othershe.combinebitmap.layout.DingLayoutManager;
|
||||
import com.othershe.combinebitmap.layout.WechatLayoutManager;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiui.videoplayer.BuildConfig;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.activity.pic.GalleryActivity;
|
||||
import com.uiui.videoplayer.activity.video.VideoActivity;
|
||||
import com.uiui.videoplayer.adapter.VideoAdapter;
|
||||
import com.uiui.videoplayer.base.BaseActivity;
|
||||
import com.uiui.videoplayer.base.BaseLightActivity;
|
||||
import com.uiui.videoplayer.bean.BaseResponse;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.fragment.doc.DocFragment;
|
||||
import com.uiui.videoplayer.fragment.pic.PictureFragment;
|
||||
import com.uiui.videoplayer.fragment.video.VideoFragment;
|
||||
import com.uiui.videoplayer.network.NetInterfaceManager;
|
||||
import com.uiui.videoplayer.utils.JGYUtils;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
import com.uiui.videoplayer.utils.Utils;
|
||||
@@ -45,36 +40,44 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import wseemann.media.FFmpegMediaMetadataRetriever;
|
||||
|
||||
public class MainActivity extends BaseLightActivity {
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
private static final int REQUEST_PERMISSION_CODE = 200;
|
||||
|
||||
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
@BindView(R.id.cl_pic)
|
||||
ConstraintLayout cl_pic;
|
||||
@BindView(R.id.vl_video)
|
||||
ConstraintLayout vl_video;
|
||||
@BindView(R.id.nv_pic)
|
||||
NiceImageView nv_pic;
|
||||
@BindView(R.id.nv_video)
|
||||
NiceImageView nv_video;
|
||||
@BindView(R.id.cl_video)
|
||||
ConstraintLayout cl_video;
|
||||
@BindView(R.id.cl_doc)
|
||||
ConstraintLayout cl_doc;
|
||||
@BindView(R.id.iv_pic)
|
||||
ImageView iv_pic;
|
||||
@BindView(R.id.iv_video)
|
||||
ImageView iv_video;
|
||||
@BindView(R.id.iv_doc)
|
||||
ImageView iv_doc;
|
||||
@BindView(R.id.tv_space)
|
||||
TextView tv_space;
|
||||
@BindView(R.id.tv_rank)
|
||||
TextView tv_rank;
|
||||
|
||||
@BindView(R.id.tv_version)
|
||||
TextView tv_version;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private Fragment[] mFragments;
|
||||
|
||||
String[] permissions = new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
@@ -93,29 +96,39 @@ public class MainActivity extends BaseLightActivity {
|
||||
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
ButterKnife.bind(this);
|
||||
cl_pic.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(MainActivity.this, GalleryActivity.class));
|
||||
}
|
||||
});
|
||||
vl_video.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(MainActivity.this, VideoActivity.class));
|
||||
}
|
||||
});
|
||||
tv_version.setText("版本号:V" + BuildConfig.VERSION_NAME);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
cl_pic.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchContent(0);
|
||||
}
|
||||
});
|
||||
cl_video.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchContent(1);
|
||||
}
|
||||
});
|
||||
cl_doc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchContent(2);
|
||||
}
|
||||
});
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragments = new Fragment[3];
|
||||
switchContent(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
getHomeSpaceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +155,6 @@ public class MainActivity extends BaseLightActivity {
|
||||
intent.setData(Uri.parse("package:" + this.getPackageName()));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,6 +177,125 @@ public class MainActivity extends BaseLightActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void getHomeSpaceInfo() {
|
||||
NetInterfaceManager.getInstance().getHomeSpaceInfoControl()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<SpaceInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getHomeSpaceInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SpaceInfo> spaceInfoBaseResponse) {
|
||||
Log.e("getHomeSpaceInfo", "onNext: " + spaceInfoBaseResponse);
|
||||
if (spaceInfoBaseResponse.code == 200) {
|
||||
SpaceInfo spaceInfo = spaceInfoBaseResponse.data;
|
||||
String home_video_grade = spaceInfo.getHome_video_grade();
|
||||
long quota = spaceInfo.getQuota();
|
||||
long use_quota = spaceInfo.getUse_quota();
|
||||
tv_rank.setText(home_video_grade);
|
||||
tv_space.setText(Utils.formatFileSize(use_quota) + "/" + Utils.formatFileSize(quota));
|
||||
} else {
|
||||
tv_rank.setText("普通");
|
||||
tv_space.setText("0GB/0GB");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getHomeSpaceInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getHomeSpaceInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 切换显示内容
|
||||
public void switchContent(int index) {
|
||||
switchPic(index);
|
||||
FragmentTransaction transaction = mFragmentManager.beginTransaction();
|
||||
hideFragments(transaction);
|
||||
try {
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (mFragments[0] == null) {
|
||||
mFragments[0] = new PictureFragment();
|
||||
transaction.add(R.id.content, mFragments[0], 0 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[0]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (mFragments[1] == null) {
|
||||
mFragments[1] = new VideoFragment();
|
||||
transaction.add(R.id.content, mFragments[1], 1 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[1]);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (mFragments[2] == null) {
|
||||
mFragments[2] = new DocFragment();
|
||||
transaction.add(R.id.content, mFragments[2], 2 + "");
|
||||
} else {
|
||||
transaction.show(mFragments[2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
transaction.commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void switchPic(int index) {
|
||||
// iv_pic.setImageDrawable(getDrawable(R.drawable.home_icon_picture_normal));
|
||||
// iv_video.setImageDrawable(getDrawable(R.drawable.home_icon_video_normal));
|
||||
// iv_doc.setImageDrawable(getDrawable(R.drawable.home_icon_doc_normal));
|
||||
// Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim_small);
|
||||
cl_pic.setBackground(null);
|
||||
cl_video.setBackground(null);
|
||||
cl_doc.setBackground(null);
|
||||
switch (index) {
|
||||
case 0:
|
||||
// iv_pic.startAnimation(animation);
|
||||
iv_pic.setImageDrawable(getDrawable(R.drawable.home_icon_picture_pressed));
|
||||
iv_video.setImageDrawable(getDrawable(R.drawable.home_icon_video_normal));
|
||||
cl_pic.setBackground(getDrawable(R.drawable.alarm_pressed_background));
|
||||
break;
|
||||
case 1:
|
||||
// iv_video.startAnimation(animation);
|
||||
iv_pic.setImageDrawable(getDrawable(R.drawable.home_icon_picture_normal));
|
||||
iv_video.setImageDrawable(getDrawable(R.drawable.home_icon_video_pressed));
|
||||
cl_video.setBackground(getDrawable(R.drawable.alarm_pressed_background));
|
||||
break;
|
||||
case 2:
|
||||
// iv_doc.startAnimation(animation);
|
||||
// iv_doc.setImageDrawable(getDrawable(R.drawable.home_icon_doc_checked));
|
||||
cl_doc.setBackground(getDrawable(R.drawable.alarm_pressed_background));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// 将所有的Fragment都置为隐藏状态。
|
||||
private void hideFragments(FragmentTransaction transaction) {
|
||||
if (mFragments != null) {
|
||||
for (Fragment fragment : mFragments) {
|
||||
if (fragment != null) {
|
||||
transaction.hide(fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getThumbnail() {
|
||||
long s1 = System.currentTimeMillis();
|
||||
List<String> picFileList = new ArrayList<>();
|
||||
@@ -215,49 +346,49 @@ public class MainActivity extends BaseLightActivity {
|
||||
Log.e("getThumbnail", "videoFileList: " + videoFileList);
|
||||
Log.e("getThumbnail", "picFileList size = " + picFileList.size());
|
||||
Log.e("getThumbnail", "videoFileList size = " + videoFileList.size());
|
||||
if (picFileList.size() == 0) {
|
||||
nv_pic.setImageDrawable(getDrawable(R.drawable.icon_pic));
|
||||
} else {
|
||||
nv_pic.setImageDrawable(path2Drawable(picFileList.get(0)));
|
||||
}
|
||||
if (videoFileList.size() == 0) {
|
||||
nv_video.setImageDrawable(getDrawable(R.drawable.icon_video));
|
||||
} else {
|
||||
Observable.create(new ObservableOnSubscribe<Bitmap>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
|
||||
FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
|
||||
mmr.setDataSource(videoFileList.get(0));
|
||||
Bitmap bitmap = mmr.getFrameAtTime();//获得视频第一帧的Bitmap对象.
|
||||
mmr.release();
|
||||
emitter.onNext(bitmap);
|
||||
}
|
||||
}).subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Bitmap>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("VideoResult", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Bitmap result) {
|
||||
Log.e("VideoResult", "onNext: " + result);
|
||||
nv_video.setImageBitmap(result);
|
||||
// Glide.with(nv_video).load(result).error(R.drawable.icon_video).into(nv_video);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("VideoResult", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("VideoResult", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
// if (picFileList.size() == 0) {
|
||||
// nv_pic.setImageDrawable(getDrawable(R.drawable.icon_pic));
|
||||
// } else {
|
||||
// nv_pic.setImageDrawable(path2Drawable(picFileList.get(0)));
|
||||
// }
|
||||
// if (videoFileList.size() == 0) {
|
||||
// nv_video.setImageDrawable(getDrawable(R.drawable.icon_video));
|
||||
// } else {
|
||||
// Observable.create(new ObservableOnSubscribe<Bitmap>() {
|
||||
// @Override
|
||||
// public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
|
||||
// FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
|
||||
// mmr.setDataSource(videoFileList.get(0));
|
||||
// Bitmap bitmap = mmr.getFrameAtTime();//获得视频第一帧的Bitmap对象.
|
||||
// mmr.release();
|
||||
// emitter.onNext(bitmap);
|
||||
// }
|
||||
// }).subscribeOn(Schedulers.newThread())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Observer<Bitmap>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.e("VideoResult", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(Bitmap result) {
|
||||
// Log.e("VideoResult", "onNext: " + result);
|
||||
// nv_video.setImageBitmap(result);
|
||||
//// Glide.with(nv_video).load(result).error(R.drawable.icon_video).into(nv_video);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e("VideoResult", "onError: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("VideoResult", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
Log.e("getThumbnail", "videoFileList size = " + videoFileList.size());
|
||||
// CombineBitmap.init(this)
|
||||
// .setLayoutManager(new DingLayoutManager()) // 必选, 设置图片的组合形式,支持WechatLayoutManager、DingLayoutManager
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.uiui.videoplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,20 +14,25 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
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.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.activity.preview.PreviewActivity;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.uiui.videoplayer.gson.GsonUtils;
|
||||
import com.uiui.videoplayer.utils.JGYUtils;
|
||||
import com.uiui.videoplayer.utils.ScreenUtils;
|
||||
import com.uiui.videoplayer.utils.VideoUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PicAdapter extends RecyclerView.Adapter<PicAdapter.Holder> {
|
||||
|
||||
@@ -44,10 +52,10 @@ public class PicAdapter extends RecyclerView.Adapter<PicAdapter.Holder> {
|
||||
ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) holder.iv_pic.getLayoutParams();
|
||||
//动态计算,设置item的宽高一致,总宽度-左右margin-左右padding /总列数-item左右margin-item左右padding
|
||||
params.height =
|
||||
(mGridLayoutManager.getWidth() - layoutParams.leftMargin
|
||||
- layoutParams.rightMargin - holder.iv_pic.getPaddingStart() - holder.iv_pic.getPaddingEnd()) / mGridLayoutManager.getSpanCount()
|
||||
- 2 * holder.itemView.getPaddingLeft() - 2 * ((ViewGroup.MarginLayoutParams) params).leftMargin;
|
||||
// params.height =
|
||||
// (mGridLayoutManager.getWidth() - layoutParams.leftMargin
|
||||
// - layoutParams.rightMargin - holder.iv_pic.getPaddingStart() - holder.iv_pic.getPaddingEnd()) / mGridLayoutManager.getSpanCount()
|
||||
// - 2 * holder.itemView.getPaddingLeft() - 2 * ((ViewGroup.MarginLayoutParams) params).leftMargin;
|
||||
return holder;
|
||||
}
|
||||
|
||||
@@ -61,10 +69,13 @@ public class PicAdapter extends RecyclerView.Adapter<PicAdapter.Holder> {
|
||||
} else {
|
||||
holder.tv_name.setText(fileName);
|
||||
}
|
||||
RequestOptions options = RequestOptions.bitmapTransform(new RoundedCorners(ScreenUtils.dip2px(mContext, 4F)));
|
||||
if (!JGYUtils.getInstance().fileExists(photoInfo.getFile())) {
|
||||
Glide.with(mContext).load(fileUrl).into(holder.iv_pic);
|
||||
// Glide.with(mContext).load(fileUrl).into(holder.iv_pic);
|
||||
loadImg(fileUrl, holder.iv_pic);
|
||||
} else {
|
||||
Glide.with(mContext).load(JGYUtils.getInstance().getUrlLocalPath(photoInfo.getFile())).into(holder.iv_pic);
|
||||
// Glide.with(mContext).load(JGYUtils.getInstance().getUrlLocalPath(photoInfo.getFile())).into(holder.iv_pic);
|
||||
loadImg(JGYUtils.getInstance().getUrlLocalPath(photoInfo.getFile()), holder.iv_pic);
|
||||
}
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -79,6 +90,27 @@ public class PicAdapter extends RecyclerView.Adapter<PicAdapter.Holder> {
|
||||
});
|
||||
}
|
||||
|
||||
private void loadImg(String path, ImageView imageView) {
|
||||
Glide.with(imageView).asBitmap().load(path).into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
int imgWidth = resource.getWidth();
|
||||
int imgHeight = resource.getHeight();
|
||||
imageView.setImageBitmap(resource);
|
||||
// Log.e("into", "onResourceReady: width = " + imgWidth + "height = " + imgHeight);
|
||||
// ViewGroup.LayoutParams layoutParams = iv_img.getLayoutParams();
|
||||
// int width = iv_img.getWidth();
|
||||
// layoutParams.height = (int) (imgHeight * (1.0f * width /imgWidth ));
|
||||
// iv_img.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mPhotoInfos == null ? 0 : mPhotoInfos.size();
|
||||
@@ -91,7 +123,7 @@ public class PicAdapter extends RecyclerView.Adapter<PicAdapter.Holder> {
|
||||
|
||||
class Holder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
ImageView iv_pic;
|
||||
NiceImageView iv_pic;
|
||||
TextView tv_name;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.uiui.videoplayer.adapter;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RecyclerViewSpacesItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final HashMap<String, Integer> mSpaceValueMap;
|
||||
|
||||
public static final String TOP_DECORATION = "top_decoration";
|
||||
public static final String BOTTOM_DECORATION = "bottom_decoration";
|
||||
public static final String LEFT_DECORATION = "left_decoration";
|
||||
public static final String RIGHT_DECORATION = "right_decoration";
|
||||
|
||||
public RecyclerViewSpacesItemDecoration(final HashMap<String, Integer> mSpaceValueMap) {
|
||||
this.mSpaceValueMap = mSpaceValueMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(final Rect outRect, final View view, final RecyclerView parent,
|
||||
final RecyclerView.State state) {
|
||||
if (mSpaceValueMap.get(TOP_DECORATION) != null) {
|
||||
outRect.top = mSpaceValueMap.get(TOP_DECORATION);
|
||||
}
|
||||
if (mSpaceValueMap.get(LEFT_DECORATION) != null) {
|
||||
outRect.left = mSpaceValueMap.get(LEFT_DECORATION);
|
||||
}
|
||||
if (mSpaceValueMap.get(RIGHT_DECORATION) != null) {
|
||||
outRect.right = mSpaceValueMap.get(RIGHT_DECORATION);
|
||||
}
|
||||
if (mSpaceValueMap.get(BOTTOM_DECORATION) != null) {
|
||||
outRect.bottom = mSpaceValueMap.get(BOTTOM_DECORATION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import android.util.Log;
|
||||
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.sn.manager.RemoteManager;
|
||||
import com.uiui.videoplayer.manager.ConnectManager;
|
||||
import com.uiui.videoplayer.manager.RemoteManager;
|
||||
import com.uiui.videoplayer.network.NetInterfaceManager;
|
||||
import com.uiui.videoplayer.utils.JGYUtils;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
155
app/src/main/java/com/uiui/videoplayer/base/BaseFragment.java
Normal file
@@ -0,0 +1,155 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public abstract class BaseFragment extends Fragment implements LifecycleProvider<FragmentEvent> {
|
||||
public final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
protected boolean isViewInitiated;
|
||||
protected boolean isVisibleToUser;
|
||||
protected boolean isDataInitiated;
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final Observable<FragmentEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindFragment(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onAttach(android.app.Activity activity) {
|
||||
super.onAttach(activity);
|
||||
lifecycleSubject.onNext(FragmentEvent.ATTACH);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
lifecycleSubject.onNext(FragmentEvent.CREATE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
isViewInitiated = true;
|
||||
prepareFetchData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
this.isVisibleToUser = isVisibleToUser;
|
||||
prepareFetchData();
|
||||
}
|
||||
|
||||
public abstract void fetchData();
|
||||
|
||||
public boolean prepareFetchData() {
|
||||
return prepareFetchData(false);
|
||||
}
|
||||
|
||||
public boolean prepareFetchData(boolean forceUpdate) {
|
||||
if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
|
||||
fetchData();
|
||||
isDataInitiated = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
lifecycleSubject.onNext(FragmentEvent.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
lifecycleSubject.onNext(FragmentEvent.RESUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onPause() {
|
||||
lifecycleSubject.onNext(FragmentEvent.PAUSE);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onStop() {
|
||||
lifecycleSubject.onNext(FragmentEvent.STOP);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onDestroyView() {
|
||||
lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onDestroy() {
|
||||
lifecycleSubject.onNext(FragmentEvent.DESTROY);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onDetach() {
|
||||
lifecycleSubject.onNext(FragmentEvent.DETACH);
|
||||
super.onDetach();
|
||||
}
|
||||
}
|
||||
35
app/src/main/java/com/uiui/videoplayer/bean/SpaceInfo.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.uiui.videoplayer.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SpaceInfo implements Serializable {
|
||||
private static final long serialVersionUID = -1299818908870523156L;
|
||||
|
||||
String home_video_grade;
|
||||
long quota;
|
||||
long use_quota;
|
||||
|
||||
public String getHome_video_grade() {
|
||||
return home_video_grade;
|
||||
}
|
||||
|
||||
public void setHome_video_grade(String home_video_grade) {
|
||||
this.home_video_grade = home_video_grade;
|
||||
}
|
||||
|
||||
public long getQuota() {
|
||||
return quota;
|
||||
}
|
||||
|
||||
public void setQuota(long quota) {
|
||||
this.quota = quota;
|
||||
}
|
||||
|
||||
public long getUse_quota() {
|
||||
return use_quota;
|
||||
}
|
||||
|
||||
public void setUse_quota(long use_quota) {
|
||||
this.use_quota = use_quota;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.uiui.videoplayer.fragment.doc;
|
||||
|
||||
import com.uiui.videoplayer.base.BasePresenter;
|
||||
import com.uiui.videoplayer.base.BaseView;
|
||||
|
||||
public class DocContact {
|
||||
public interface Presenter extends BasePresenter<DocView> {
|
||||
|
||||
}
|
||||
|
||||
public interface DocView extends BaseView {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.uiui.videoplayer.fragment.doc;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.base.BaseFragment;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link DocFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class DocFragment extends BaseFragment implements DocContact.DocView {
|
||||
private static final String TAG = DocFragment.class.getSimpleName();
|
||||
|
||||
private View rootView;// 设置为全局的
|
||||
private Activity mContext;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public DocFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment PictureFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static DocFragment newInstance(String param1, String param2) {
|
||||
DocFragment fragment = new DocFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.e(TAG, "onCreateView: ");
|
||||
if (null != rootView) {
|
||||
ViewGroup parent = (ViewGroup) rootView.getParent();
|
||||
if (null != parent) {
|
||||
parent.removeView(rootView);
|
||||
}
|
||||
} else { // 如ongoing果rootView为空 ,就实例化该视图
|
||||
rootView = inflater.inflate(R.layout.fragment_doc, container, false);
|
||||
mContext = (Activity) rootView.getContext();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
}
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.uiui.videoplayer.fragment.doc;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.videoplayer.disklrucache.CacheHelper;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class DocPresenter implements DocContact.Presenter {
|
||||
private static final String TAG = DocPresenter.class.getSimpleName();
|
||||
private DocContact.DocView mView;
|
||||
private Context mContext;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
public DocPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
private BehaviorSubject<FragmentEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull DocContact.DocView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.uiui.videoplayer.fragment.pic;
|
||||
|
||||
import com.uiui.videoplayer.base.BasePresenter;
|
||||
import com.uiui.videoplayer.base.BaseView;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PictureContact {
|
||||
public interface Presenter extends BasePresenter<PictureView> {
|
||||
void getHomePhoto();
|
||||
}
|
||||
|
||||
public interface PictureView extends BaseView {
|
||||
void setHomePhoto(ArrayList<PhotoInfo> photoInfos);
|
||||
void getHomePhotoFinish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.uiui.videoplayer.fragment.pic;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.activity.pic.GalleryPresenter;
|
||||
import com.uiui.videoplayer.adapter.PicAdapter;
|
||||
import com.uiui.videoplayer.adapter.RecyclerViewSpacesItemDecoration;
|
||||
import com.uiui.videoplayer.base.BGAGridDivider;
|
||||
import com.uiui.videoplayer.base.BaseFragment;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link PictureFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class PictureFragment extends BaseFragment implements PictureContact.PictureView {
|
||||
private static final String TAG = PictureFragment.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.swipeRefreshLayout)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.cl_nodata)
|
||||
ConstraintLayout cl_nodata;
|
||||
|
||||
private View rootView;// 设置为全局的
|
||||
private Activity mContext;
|
||||
|
||||
private PicturePresenter mPresenter;
|
||||
private PicAdapter mPicAdapter;
|
||||
private static final int SPAN_COUNT = 3;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public PictureFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment PictureFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static PictureFragment newInstance(String param1, String param2) {
|
||||
PictureFragment fragment = new PictureFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.e(TAG, "onCreateView: ");
|
||||
if (null != rootView) {
|
||||
ViewGroup parent = (ViewGroup) rootView.getParent();
|
||||
if (null != parent) {
|
||||
parent.removeView(rootView);
|
||||
}
|
||||
} else { // 如ongoing果rootView为空 ,就实例化该视图
|
||||
rootView = inflater.inflate(R.layout.fragment_picture, container, false);
|
||||
mContext = (Activity) rootView.getContext();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
}
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
Log.e(TAG, "fetchData: ");
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mPresenter = new PicturePresenter(mContext);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(mContext, SPAN_COUNT, LinearLayoutManager.VERTICAL, false);
|
||||
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
|
||||
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 1));//top间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 1));//底部间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.LEFT_DECORATION, (int) (density * 20));//左间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, (int) (density * 20));//右间距
|
||||
recyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));
|
||||
|
||||
mPicAdapter = new PicAdapter(layoutManager);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.addItemDecoration(BGAGridDivider.newInstanceWithSpaceRes(R.dimen.dp_2));
|
||||
recyclerView.setAdapter(mPicAdapter);
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mPresenter.getHomePhoto();
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
}
|
||||
});
|
||||
mPresenter.getHomePhoto();
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHomePhoto(ArrayList<PhotoInfo> photoInfos) {
|
||||
mPicAdapter.setPhotoInfos(photoInfos);
|
||||
if (photoInfos == null || photoInfos.size() == 0) {
|
||||
cl_nodata.setVisibility(View.VISIBLE);
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
ToastUtil.show("没有数据");
|
||||
} else {
|
||||
cl_nodata.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHomePhotoFinish() {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.uiui.videoplayer.fragment.pic;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.uiui.videoplayer.disklrucache.CacheHelper;
|
||||
import com.uiui.videoplayer.network.NetInterfaceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class PicturePresenter implements PictureContact.Presenter {
|
||||
private static final String TAG = PicturePresenter.class.getSimpleName();
|
||||
private PictureContact.PictureView mView;
|
||||
private Context mContext;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
public PicturePresenter(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
private BehaviorSubject<FragmentEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull PictureContact.PictureView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHomePhoto() {
|
||||
NetInterfaceManager.getInstance().getHomePhotoFragment( getLifecycle(), new NetInterfaceManager.onPhotoCallback() {
|
||||
@Override
|
||||
public void setPhotoList(ArrayList<PhotoInfo> photoList) {
|
||||
mView.setHomePhoto(photoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.getHomePhotoFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.uiui.videoplayer.fragment.video;
|
||||
|
||||
import com.uiui.videoplayer.base.BasePresenter;
|
||||
import com.uiui.videoplayer.base.BaseView;
|
||||
import com.uiui.videoplayer.bean.LocalVideoInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class VideoContact {
|
||||
public interface Presenter extends BasePresenter<VideoView> {
|
||||
void getHomeVideo();
|
||||
}
|
||||
|
||||
public interface VideoView extends BaseView {
|
||||
void setHomeVideo(ArrayList<LocalVideoInfo> video);
|
||||
void getHomeVideoFinish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package com.uiui.videoplayer.fragment.video;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.activity.video.VideoActivity;
|
||||
import com.uiui.videoplayer.adapter.RecyclerViewSpacesItemDecoration;
|
||||
import com.uiui.videoplayer.adapter.VideoAdapter;
|
||||
import com.uiui.videoplayer.base.BaseFragment;
|
||||
import com.uiui.videoplayer.base.CustomDialog;
|
||||
import com.uiui.videoplayer.base.RecycleGridLayoutManager;
|
||||
import com.uiui.videoplayer.base.SpacesItemDecoration;
|
||||
import com.uiui.videoplayer.bean.LocalVideoInfo;
|
||||
import com.uiui.videoplayer.gson.GsonUtils;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
import com.uiui.videoplayer.utils.VideoUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link VideoFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class VideoFragment extends BaseFragment implements VideoContact.VideoView {
|
||||
private static final String TAG = VideoFragment.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.cl_nodata)
|
||||
ConstraintLayout cl_nodata;
|
||||
@BindView(R.id.swipeRefreshLayout)
|
||||
SwipeRefreshLayout refreshLayout;
|
||||
|
||||
private View rootView;// 设置为全局的
|
||||
private Activity mContext;
|
||||
|
||||
private VideoPresenter mPresenter;
|
||||
private RecycleGridLayoutManager mManager;
|
||||
private VideoAdapter adapter;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public VideoFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment PictureFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static VideoFragment newInstance(String param1, String param2) {
|
||||
VideoFragment fragment = new VideoFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.e(TAG, "onCreateView: ");
|
||||
if (null != rootView) {
|
||||
ViewGroup parent = (ViewGroup) rootView.getParent();
|
||||
if (null != parent) {
|
||||
parent.removeView(rootView);
|
||||
}
|
||||
} else { // 如ongoing果rootView为空 ,就实例化该视图
|
||||
rootView = inflater.inflate(R.layout.fragment_video, container, false);
|
||||
mContext = (Activity) rootView.getContext();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
}
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mPresenter = new VideoPresenter(mContext);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
|
||||
Aria.download(this).register();
|
||||
|
||||
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mPresenter.getHomeVideo();
|
||||
refreshLayout.setRefreshing(true);
|
||||
}
|
||||
});
|
||||
// ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
// int orientation = getResources().getConfiguration().orientation;
|
||||
// if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// mManager = new RecycleGridLayoutManager(mContext, 4);
|
||||
// } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mManager = new RecycleGridLayoutManager(mContext, 3);
|
||||
// }
|
||||
|
||||
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
|
||||
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 1));//top间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 1));//底部间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.LEFT_DECORATION, (int) (density * 20));//左间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, (int) (density * 20));//右间距
|
||||
recyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));
|
||||
|
||||
recyclerView.setLayoutManager(mManager);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX1x), getResources().getDimensionPixelSize(R.dimen.PX1x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX1x), getResources().getDimensionPixelSize(R.dimen.PX1x)));
|
||||
((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
adapter = new VideoAdapter(mContext);
|
||||
adapter.setOnLongClickListener(new VideoAdapter.onItemLongClickListener() {
|
||||
@Override
|
||||
public void onItemLongClick(String path, int position) {
|
||||
showDialog(path, position);
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
mPresenter.getHomeVideo();
|
||||
refreshLayout.setRefreshing(true);
|
||||
}
|
||||
|
||||
private void showDialog(String path, int position) {
|
||||
CustomDialog dialog = new CustomDialog(mContext);
|
||||
dialog.setTitle("删除文件")
|
||||
.setMessage("确定要删除文件 " + VideoUtils.getFileNameWithoutExtension(path) + "吗")
|
||||
.setPositive("确定")
|
||||
.setNegtive("取消")
|
||||
.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
dialog.dismiss();
|
||||
File file = new File(path);
|
||||
if (file.delete()) {
|
||||
adapter.removeItem(position);
|
||||
ToastUtil.show("删除成功");
|
||||
} else {
|
||||
ToastUtil.show("删除失败,检查权限是否开启");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setHomeVideo(ArrayList<LocalVideoInfo> video) {
|
||||
if (video == null || video.size() == 0) {
|
||||
cl_nodata.setVisibility(View.VISIBLE);
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
ToastUtil.show("没有数据");
|
||||
} else {
|
||||
cl_nodata.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
adapter.setData(video);
|
||||
}
|
||||
refreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHomeVideoFinish() {
|
||||
refreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
void running(DownloadTask task) {
|
||||
Log.e("aria running", "正在下载:" + task.getState() + "-" + task.getPercent() + "--" + task.getExtendField());
|
||||
try {
|
||||
String jsonString = task.getExtendField();
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
|
||||
} catch (Exception e) {
|
||||
Log.e("running", "running: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
void taskComplete(DownloadTask task) {
|
||||
//在这里处理任务完成的状态
|
||||
Log.e("taskComplete", task.getExtendField());
|
||||
// Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||
mPresenter.getHomeVideo();
|
||||
}
|
||||
|
||||
@Download.onTaskFail
|
||||
void taskFail(DownloadTask task, Exception e) {
|
||||
Aria.download(this).resumeAllTask();
|
||||
final String filepath = task.getFilePath();
|
||||
final String packageName = task.getExtendField();
|
||||
try {
|
||||
Aria.download(this).load(task.getDownloadEntity().getId()).cancel(true);
|
||||
Log.e(TAG, "taskFail: " + "Exception: " + e.getLocalizedMessage());
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
Log.e(TAG, "taskFail: " + packageName + "filepath: " + filepath);
|
||||
mPresenter.getHomeVideo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.uiui.videoplayer.fragment.video;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.videoplayer.bean.LocalVideoInfo;
|
||||
import com.uiui.videoplayer.disklrucache.CacheHelper;
|
||||
import com.uiui.videoplayer.network.NetInterfaceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class VideoPresenter implements VideoContact.Presenter {
|
||||
private static final String TAG = VideoPresenter.class.getSimpleName();
|
||||
private VideoContact.VideoView mView;
|
||||
private Context mContext;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
public VideoPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
private BehaviorSubject<FragmentEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull VideoContact.VideoView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getHomeVideo() {
|
||||
NetInterfaceManager.getInstance().getHomeVideoFragment( lifecycle, new NetInterfaceManager.onVideoPathCallback() {
|
||||
@Override
|
||||
public void setVideoList(ArrayList<LocalVideoInfo> videoList) {
|
||||
mView.setHomeVideo(videoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.getHomeVideoFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.uiui.videoplayer.network;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -12,8 +11,11 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.sn.manager.RemoteManager;
|
||||
import com.uiui.videoplayer.bean.BaseResponse;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.bean.VideoInfo;
|
||||
import com.uiui.videoplayer.bean.LocalVideoInfo;
|
||||
import com.uiui.videoplayer.config.CommonConfig;
|
||||
@@ -21,8 +23,8 @@ import com.uiui.videoplayer.disklrucache.CacheHelper;
|
||||
import com.uiui.videoplayer.gson.GsonUtils;
|
||||
import com.uiui.videoplayer.manager.ConnectManager;
|
||||
import com.uiui.videoplayer.manager.ConnectMode;
|
||||
import com.uiui.videoplayer.manager.RemoteManager;
|
||||
import com.uiui.videoplayer.network.api.HomePhotoApi;
|
||||
import com.uiui.videoplayer.network.api.HomeSpaceInfoApi;
|
||||
import com.uiui.videoplayer.network.api.HomeVideoApi;
|
||||
import com.uiui.videoplayer.network.interceptor.RepeatRequestInterceptor;
|
||||
import com.uiui.videoplayer.utils.JGYUtils;
|
||||
@@ -52,7 +54,6 @@ import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import wseemann.media.FFmpegMediaMetadataRetriever;
|
||||
|
||||
public class NetInterfaceManager {
|
||||
private static final String TAG = NetInterfaceManager.class.getSimpleName();
|
||||
@@ -165,6 +166,13 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SpaceInfo>> getHomeSpaceInfoControl() {
|
||||
return mRetrofit.create(HomeSpaceInfoApi.class)
|
||||
.getHomeSpaceInfo(RemoteManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public interface onVideoPathCallback {
|
||||
void setVideoList(ArrayList<LocalVideoInfo> videoList);
|
||||
|
||||
@@ -221,6 +229,12 @@ public class NetInterfaceManager {
|
||||
.subscribe(getHomeVideoObserver(callback));
|
||||
}
|
||||
|
||||
public void getHomeVideoFragment(BehaviorSubject<FragmentEvent> lifecycle, onVideoPathCallback callback) {
|
||||
getHomeVideoControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getHomeVideoObserver(callback));
|
||||
}
|
||||
|
||||
public void getHomeVideo(onVideoPathCallback callback) {
|
||||
getHomeVideoControl()
|
||||
.subscribe(getHomeVideoObserver(callback));
|
||||
@@ -446,6 +460,12 @@ public class NetInterfaceManager {
|
||||
.subscribe(getHomePhotoObserver(callback));
|
||||
}
|
||||
|
||||
public void getHomePhotoFragment(BehaviorSubject<FragmentEvent> lifecycle, onPhotoCallback callback) {
|
||||
getHomePhotoControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getHomePhotoObserver(callback));
|
||||
}
|
||||
|
||||
public void getHomePhoto(onPhotoCallback callback) {
|
||||
getHomePhotoControl()
|
||||
.subscribe(getHomePhotoObserver(callback));
|
||||
|
||||
@@ -8,4 +8,8 @@ public class UrlAddress {
|
||||
public static final String HOME_VIDEO ="File/getHomeVideo";
|
||||
/*获取家庭照片*/
|
||||
public static final String HOME_PHOTO ="File/getHomePhoto";
|
||||
/*获取家庭空间信息*/
|
||||
public static final String GET_HOME_SPACE_INFO ="File/getHomeSpaceInfo";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.uiui.videoplayer.network.api;
|
||||
|
||||
import com.uiui.videoplayer.bean.BaseResponse;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface HomeSpaceInfoApi {
|
||||
@GET(UrlAddress.GET_HOME_SPACE_INFO)
|
||||
Observable<BaseResponse<SpaceInfo>> getHomeSpaceInfo(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.uiui.videoplayer.utils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class Utils {
|
||||
public static String TimeFormat(long millisecond) {
|
||||
int ss = 1000;
|
||||
@@ -19,4 +21,23 @@ public class Utils {
|
||||
return strMinute + ":" + strSecond;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换文件大小 MB
|
||||
*/
|
||||
public static String formatFileSize(long fileS) {
|
||||
DecimalFormat df = new DecimalFormat("#");
|
||||
String fileSizeString;
|
||||
String wrongSize = "0GB";
|
||||
if (fileS == 0) {
|
||||
return wrongSize;
|
||||
}
|
||||
if (fileS < 1048576) {
|
||||
fileSizeString = df.format((double) fileS / 1024) + "GB";
|
||||
} else {
|
||||
fileSizeString = df.format((double) fileS / 1048576) + "TB";
|
||||
}
|
||||
return fileSizeString;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/drawable-hdpi/home_icon_doc_normal.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
app/src/main/res/drawable-hdpi/home_icon_picture_normal.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/drawable-hdpi/home_icon_picture_pressed.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/drawable-hdpi/home_icon_video_normal.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
app/src/main/res/drawable-hdpi/home_icon_video_pressed.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_dropdown.png
Normal file
|
After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
15
app/src/main/res/drawable/alarm_pressed_background.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 内部颜色 -->
|
||||
<solid android:color="@color/home_background_color" />
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners android:topLeftRadius="@dimen/dp_8"
|
||||
android:bottomLeftRadius="@dimen/dp_8"
|
||||
/>
|
||||
|
||||
<!-- <padding-->
|
||||
<!-- android:bottom="0dp"-->
|
||||
<!-- android:left="8dp"-->
|
||||
<!-- android:right="8dp"-->
|
||||
<!-- android:top="0dp" />-->
|
||||
</shape>
|
||||
17
app/src/main/res/drawable/space_background.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 内部颜色 -->
|
||||
<solid android:color="@color/space_color" />
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners
|
||||
android:bottomLeftRadius="@dimen/dp_8"
|
||||
android:bottomRightRadius="@dimen/dp_8"
|
||||
android:topLeftRadius="@dimen/dp_8"
|
||||
android:topRightRadius="@dimen/dp_8" />
|
||||
|
||||
<padding
|
||||
android:bottom="@dimen/dp_4"
|
||||
android:left="@dimen/dp_4"
|
||||
android:right="@dimen/dp_4"
|
||||
android:top="@dimen/dp_4" />
|
||||
</shape>
|
||||
@@ -7,129 +7,261 @@
|
||||
tools:context=".activity.main.MainActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:background="@color/colorAccent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="家庭空间"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_15"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:id="@+id/constraintLayout3"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_pic"
|
||||
android:layout_width="@dimen/dp_128"
|
||||
android:layout_height="@dimen/dp_128"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:background="@drawable/bg_dialog"
|
||||
android:id="@+id/constraintLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="家庭空间"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout2">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_pic"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:background="@drawable/alarm_pressed_background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_pic"
|
||||
android:layout_width="@dimen/dp_44"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/home_icon_picture_normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="图片"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_video"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_pic"
|
||||
app:layout_constraintTop_toTopOf="@+id/cl_pic">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_video"
|
||||
android:layout_width="@dimen/dp_44"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/home_icon_video_normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:maxLines="1"
|
||||
android:text="视频"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_doc"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:layout_gravity="end"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_pic"
|
||||
app:layout_constraintTop_toTopOf="@+id/cl_pic">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_doc"
|
||||
android:layout_width="@dimen/dp_44"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/home_icon_doc_normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView3"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:maxLines="1"
|
||||
android:text="文档"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dp_8"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_7"
|
||||
app:layout_constraintBottom_toTopOf="@+id/constraintLayout5"
|
||||
app:layout_constraintEnd_toEndOf="@+id/constraintLayout5"
|
||||
app:layout_constraintStart_toStartOf="@+id/constraintLayout5" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout5"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="@dimen/dp_48"
|
||||
android:layout_marginBottom="@dimen/dp_24"
|
||||
android:background="@drawable/space_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_space"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_13"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="0.5GB/1GB" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_space"
|
||||
tools:text="普通版本" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/home_background_color"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/constraintLayout3"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:text="相册"
|
||||
android:layout_marginEnd="@dimen/dp_4"
|
||||
android:text="按时间顺序排序"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nv_pic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/nv_pic"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_pic"
|
||||
app:corner_radius="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/vl_video"
|
||||
android:layout_width="@dimen/dp_128"
|
||||
android:layout_height="@dimen/dp_128"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:background="@drawable/bg_dialog"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_pic"
|
||||
app:layout_constraintTop_toTopOf="@+id/cl_pic">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:text="视频"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nv_video"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/nv_video"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_video"
|
||||
app:corner_radius="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_32"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="@dimen/dp_10"
|
||||
android:layout_height="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/play"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/nv_video"
|
||||
app:layout_constraintEnd_toEndOf="@+id/nv_video"
|
||||
app:layout_constraintStart_toStartOf="@+id/nv_video"
|
||||
app:layout_constraintTop_toTopOf="@+id/nv_video" />
|
||||
|
||||
android:src="@drawable/icon_dropdown"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout4" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
14
app/src/main/res/layout/fragment_doc.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragment.pic.PictureFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
69
app/src/main/res/layout/fragment_picture.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".fragment.pic.PictureFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_nodata"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.369">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/no_data"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
android:text="没有数据"
|
||||
android:textColor="@color/defaultColor"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
66
app/src/main/res/layout/fragment_video.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".fragment.pic.PictureFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_nodata"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.369">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/no_data"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
android:text="没有数据"
|
||||
android:textColor="@color/defaultColor"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -6,13 +6,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/iv_pic"
|
||||
android:layout_width="@dimen/dp_128"
|
||||
android:layout_height="@dimen/dp_128"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="@color/white"
|
||||
android:scaleType="centerCrop"
|
||||
app:corner_radius="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -26,6 +26,7 @@
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/lightGray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="@dimen/dp_176"
|
||||
android:layout_height="@dimen/dp_99"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -26,8 +26,8 @@
|
||||
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/iv_status"
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_48"
|
||||
android:layout_width="@dimen/dp_32"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:src="@drawable/status_download"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -57,6 +57,7 @@
|
||||
android:maxLines="2"
|
||||
android:text=""
|
||||
android:textColor="@color/black"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="@+id/constraintLayout"
|
||||
app:layout_constraintStart_toStartOf="@+id/constraintLayout"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout" />
|
||||
|
||||
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 35 KiB |
@@ -13,6 +13,9 @@
|
||||
<color name="btn_cancel">#d0d0d0</color>
|
||||
<color name="btn_cancel_pressed">#9F9F9F</color>
|
||||
|
||||
<color name="home_background_color">#efefef</color>
|
||||
<color name="space_color">#3D54D9</color>
|
||||
|
||||
<!--https://www.jianshu.com/p/8dc258dfd189-->
|
||||
<color name="transparent">#00000000</color><!--透明色-->
|
||||
<color name="colorYang">#FFE2C59B</color><!--羊皮纸色-->
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">家庭空间</string>
|
||||
<string name="download_now">正在下载%s</string>
|
||||
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.videoplayer.manager;
|
||||
package com.uiui.sn.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
@@ -49,6 +49,7 @@ public class RemoteManager {
|
||||
String sn = mIGetInfoInterface.getSerial();
|
||||
if (!TextUtils.isEmpty(sn)) {
|
||||
mMMKV.encode(serialKey, sn);
|
||||
Log.e(TAG, "onServiceConnected: sn = " + sn);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
30
app/src/uiuios/aidl/com/uiuios/sn/IGetInfoInterface.aidl
Normal file
@@ -0,0 +1,30 @@
|
||||
// IGetInfoInterface.aidl
|
||||
package com.uiuios.sn;
|
||||
|
||||
// Declare any non-default types here with import statements
|
||||
|
||||
interface IGetInfoInterface {
|
||||
/**
|
||||
* Demonstrates some basic types that you can use as parameters
|
||||
* and return values in AIDL.
|
||||
*/
|
||||
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
||||
double aDouble, String aString);
|
||||
|
||||
/*获取sn*/
|
||||
String getSerial();
|
||||
/*获取定位结果*/
|
||||
String getMapResult();
|
||||
/*获取WiFi名*/
|
||||
String getWifiSsid();
|
||||
/*获取蓝牙名*/
|
||||
String getBluetoothSsid();
|
||||
/*写入系统数据库*/
|
||||
boolean SystemPutInt(String name, int value);
|
||||
/*结束进程*/
|
||||
void killBackgroundProcesses(String pkg);
|
||||
/*设置launcher3为默认*/
|
||||
void openLauncher3();
|
||||
/*设置默认桌面*/
|
||||
void setDefaultDesktop(String pkgName, String className);
|
||||
}
|
||||
139
app/src/uiuios/java/com/uiui/sn/manager/RemoteManager.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.uiui.sn.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.videoplayer.config.CommonConfig;
|
||||
import com.uiuios.sn.IGetInfoInterface;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class RemoteManager {
|
||||
private static final String TAG = RemoteManager.class.getSimpleName();
|
||||
|
||||
public static final String serialKey = "SERIAL_KEY";
|
||||
public static final String hidePackageKey = "HIDE_PACKAGE_NAME";
|
||||
public static final String disablePackageKey = "DISABLE_PACKAGE_NAME";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static RemoteManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
private IGetInfoInterface mIGetInfoInterface;
|
||||
private ServiceConnection mServiceConnection;
|
||||
|
||||
private RemoteManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.mServiceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: " + name);
|
||||
mIGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||
try {
|
||||
for (ConnectedListener listener : mListeners) {
|
||||
listener.onConnected();
|
||||
}
|
||||
String sn = mIGetInfoInterface.getSerial();
|
||||
if (!TextUtils.isEmpty(sn)) {
|
||||
mMMKV.encode(serialKey, sn);
|
||||
Log.e(TAG, "onServiceConnected: sn = " + sn);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "onServiceConnected: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.e(TAG, "onServiceDisconnected: " + name);
|
||||
mIGetInfoInterface = null;
|
||||
bindinfoService();
|
||||
}
|
||||
};
|
||||
if (mIGetInfoInterface == null) {
|
||||
bindinfoService();
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
Log.e(TAG, "init: ");
|
||||
sInstance = new RemoteManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static RemoteManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init RemoteManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
private static final String AOLEYUNINFO_PACKAGE_NAME = "com.uiuios.sn";
|
||||
private static final String AOLEYUNINFO_CLASS_NAME = "com.uiuios.sn.service.RemoteService";
|
||||
private static final String AOLEYUNINFO_ACTION = "com.uiuios.sn.IGetInfoInterface";
|
||||
|
||||
public void checkAvailable() {
|
||||
if (mIGetInfoInterface == null) {
|
||||
bindinfoService();
|
||||
}
|
||||
}
|
||||
|
||||
public interface ConnectedListener {
|
||||
void onConnected();
|
||||
}
|
||||
|
||||
private Set<ConnectedListener> mListeners = new HashSet<>();
|
||||
|
||||
public void setListener(ConnectedListener listener) {
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(ConnectedListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
private void bindinfoService() {
|
||||
//这是连接aidl服务的代码
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(AOLEYUNINFO_ACTION);
|
||||
intent.setPackage(AOLEYUNINFO_PACKAGE_NAME);
|
||||
intent.setComponent(new ComponentName(AOLEYUNINFO_PACKAGE_NAME, AOLEYUNINFO_CLASS_NAME));
|
||||
mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
public String getSerial() {
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// return "ah01201058819872";
|
||||
// }
|
||||
String sn = mMMKV.decodeString(serialKey, "");
|
||||
Log.e(TAG, "sn: " + sn);
|
||||
if (mIGetInfoInterface == null) {
|
||||
bindinfoService();
|
||||
return sn;
|
||||
}
|
||||
try {
|
||||
String serial = mIGetInfoInterface.getSerial();
|
||||
Log.e(TAG, "getSerial: " + serial);
|
||||
return serial;
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
return sn;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
rootProject.name='UIUI播放器'
|
||||
rootProject.name='UIUI家庭空间'
|
||||
include ':app', ':JZVideo', ':niceimageview'
|
||||
|
||||