version:1.1.4
update:更换为竖屏 bugfixes:
@@ -16,8 +16,8 @@ android {
|
||||
applicationId "com.uiui.videoplayer"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 28
|
||||
versionCode 114
|
||||
versionName "1.1.3"
|
||||
versionCode 115
|
||||
versionName "1.1.4"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -32,6 +32,14 @@ android {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
viewBinding{
|
||||
enabled = true
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -123,6 +131,7 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation project(path: ':FlycoTabLayoutZ_Lib')
|
||||
implementation project(path: ':JZVideo')
|
||||
implementation project(path: ':niceimageview')
|
||||
|
||||
@@ -130,6 +139,7 @@ dependencies {
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
||||
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:screenOrientation="portrait"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.video.VideoActivity"
|
||||
@@ -29,7 +29,7 @@
|
||||
android:name=".activity.preview.PreviewActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="userPortrait" />
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.PlayActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
@@ -39,6 +39,13 @@
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:screenOrientation="sensor"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name=".activity.vip.VipActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/activity_styles"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,12 +1,5 @@
|
||||
package com.uiui.videoplayer.activity.main;
|
||||
|
||||
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.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -17,23 +10,24 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.uiui.videoplayer.BuildConfig;
|
||||
import com.uiui.videoplayer.R;
|
||||
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.activity.vip.VipActivity;
|
||||
import com.uiui.videoplayer.base.BaseFragmentPagerAdapter;
|
||||
import com.uiui.videoplayer.base.mvvm.BaseMvvmActivity;
|
||||
import com.uiui.videoplayer.databinding.ActivityMainBinding;
|
||||
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;
|
||||
import com.uiui.videoplayer.utils.VideoUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,41 +37,18 @@ import java.util.ArrayList;
|
||||
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.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> {
|
||||
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.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 String[] title = new String[]{"视频", "照片"};
|
||||
|
||||
private BaseFragmentPagerAdapter mPagerAdapter;
|
||||
private FragmentManager mFragmentManager;
|
||||
private Fragment[] mFragments;
|
||||
private List<Fragment> mFragments;
|
||||
private PictureFragment mPictureFragment;
|
||||
private VideoFragment mVideoFragment;
|
||||
|
||||
String[] permissions = new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
@@ -89,46 +60,41 @@ public class MainActivity extends BaseActivity {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new Click());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
// //注意要清除 FLAG_TRANSLUCENT_STATUS flag
|
||||
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
ButterKnife.bind(this);
|
||||
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);
|
||||
}
|
||||
});
|
||||
mViewDataBinding.tvVersion.setText("V" + BuildConfig.VERSION_NAME);
|
||||
mFragments = new ArrayList<>();
|
||||
if (mVideoFragment == null) {
|
||||
mVideoFragment = new VideoFragment();
|
||||
}
|
||||
if (mPictureFragment == null) {
|
||||
mPictureFragment = new PictureFragment();
|
||||
}
|
||||
mFragments.add(mVideoFragment);
|
||||
mFragments.add(mPictureFragment);
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragments = new Fragment[3];
|
||||
switchContent(0);
|
||||
mPagerAdapter = new BaseFragmentPagerAdapter(mFragmentManager, mFragments);
|
||||
mViewDataBinding.viewPager.setAdapter(mPagerAdapter);
|
||||
mViewDataBinding.mainSlidingTabLayout.setViewPager(mViewDataBinding.viewPager, title);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
getHomeSpaceInfo();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,124 +143,6 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -346,92 +194,8 @@ public class MainActivity extends BaseActivity {
|
||||
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: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
Log.e("getThumbnail", "videoFileList size = " + videoFileList.size());
|
||||
// CombineBitmap.init(this)
|
||||
// .setLayoutManager(new DingLayoutManager()) // 必选, 设置图片的组合形式,支持WechatLayoutManager、DingLayoutManager
|
||||
// .setSize(100) // 必选,组合后Bitmap的尺寸,单位dp
|
||||
// .setGap(1) // 单个图片之间的距离,单位dp,默认0dp
|
||||
//// .setGapColor() // 单个图片间距的颜色,默认白色
|
||||
//// .setPlaceholder() // 单个图片加载失败的默认显示图片
|
||||
// .setUrls(picFileList.toArray(new String[picFileList.size()])) // 要加载的图片url数组
|
||||
// .setBitmaps() // 要加载的图片bitmap数组
|
||||
// .setResourceIds() // 要加载的图片资源id数组
|
||||
// .setImageView(nv_pic) // 直接设置要显示图片的ImageView
|
||||
// // 设置“子图片”的点击事件,需使用setImageView(),index和图片资源数组的索引对应
|
||||
//// .setOnSubItemClickListener(new OnSubItemClickListener() {
|
||||
//// @Override
|
||||
//// public void onSubItemClick(int index) {
|
||||
////
|
||||
//// }
|
||||
//// })
|
||||
//// // 加载进度的回调函数,如果不使用setImageView()方法,可在onComplete()完成最终图片的显示
|
||||
//// .setProgressListener(new ProgressListener() {
|
||||
//// @Override
|
||||
//// public void onStart() {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onComplete(Bitmap bitmap) {
|
||||
////
|
||||
//// }
|
||||
//// })
|
||||
// .build();
|
||||
|
||||
// CombineBitmap.init(this)
|
||||
// .setLayoutManager(new DingLayoutManager()) // 必选, 设置图片的组合形式,支持WechatLayoutManager、DingLayoutManager
|
||||
// .setSize(100) // 必选,组合后Bitmap的尺寸,单位dp
|
||||
// .setGap(1) // 单个图片之间的距离,单位dp,默认0dp
|
||||
//// .setGapColor() // 单个图片间距的颜色,默认白色
|
||||
//// .setPlaceholder() // 单个图片加载失败的默认显示图片
|
||||
// .setUrls(videoFileList.toArray(new String[videoFileList.size()])) // 要加载的图片url数组
|
||||
// .setBitmaps() // 要加载的图片bitmap数组
|
||||
// .setResourceIds() // 要加载的图片资源id数组
|
||||
// .setImageView(nv_video) // 直接设置要显示图片的ImageView
|
||||
// .build();
|
||||
Log.e("getThumbnail", "videoFileList size = " + videoFileList.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -456,4 +220,34 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == KeyEvent.ACTION_DOWN) {
|
||||
lazyExit();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private long mPreClickTime;
|
||||
|
||||
private void lazyExit() {
|
||||
if (System.currentTimeMillis() - mPreClickTime > 3000) {
|
||||
ToastUtil.show("再按一次,退出");
|
||||
mPreClickTime = System.currentTimeMillis();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public class Click {
|
||||
public void exit(View view) {
|
||||
lazyExit();
|
||||
}
|
||||
|
||||
public void toVip(View view) {
|
||||
startActivity(new Intent(MainActivity.this, VipActivity.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.uiui.videoplayer.activity.main;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.uiui.videoplayer.base.mvvm.BaseViewModel;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.databinding.ActivityMainBinding;
|
||||
|
||||
public class MainViewModel extends BaseViewModel<ActivityMainBinding> {
|
||||
@Override
|
||||
public ActivityMainBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
package com.uiui.videoplayer.activity.main.land;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
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 com.uiui.videoplayer.BuildConfig;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.base.BaseActivity;
|
||||
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;
|
||||
import com.uiui.videoplayer.utils.VideoUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
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.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class LandMainActivity 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.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,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
// //注意要清除 FLAG_TRANSLUCENT_STATUS flag
|
||||
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
|
||||
ButterKnife.bind(this);
|
||||
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
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
checkSelfPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_PERMISSION_CODE) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Log.e("TAG", "onRequestPermissionsResult: ");
|
||||
getThumbnail();
|
||||
} else if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(LandMainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
ToastUtil.show("需要存储空间权限才能正常使用软件");
|
||||
checkSelfPermission();
|
||||
} else {
|
||||
ToastUtil.show("请打开存储空间权限后使用软件");
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + this.getPackageName()));
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSelfPermission() {
|
||||
List<String> mPermissionList = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
for (String s : permissions) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
|
||||
mPermissionList.add(s);
|
||||
} else {
|
||||
Log.e("TAG", "checkSelfPermission: ");
|
||||
// mPresenter.getHomeVideo();
|
||||
getThumbnail();
|
||||
}
|
||||
}
|
||||
if (mPermissionList.size() > 0) {//有权限没有通过,需要申请
|
||||
ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSION_CODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<>();
|
||||
List<String> videoFileList = new ArrayList<>();
|
||||
String rootPath = JGYUtils.getInstance().getDownLoadPath() + File.separator;
|
||||
File file = new File(rootPath);
|
||||
if (file.exists()) {
|
||||
LinkedList<File> list = new LinkedList<File>();
|
||||
File[] files = file.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (File file2 : files) {
|
||||
if (file2.isDirectory()) {
|
||||
list.add(file2);
|
||||
} else {
|
||||
if (VideoUtils.isPicFormat(file2.getAbsolutePath())) {
|
||||
picFileList.add(file2.getAbsolutePath());
|
||||
} else if (VideoUtils.isVideoFormat(file2.getAbsolutePath())) {
|
||||
videoFileList.add(file2.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
File temp_file;
|
||||
while (!list.isEmpty()) {
|
||||
temp_file = list.removeFirst();
|
||||
files = temp_file.listFiles();
|
||||
if (files == null) {
|
||||
continue;
|
||||
}
|
||||
for (File file2 : files) {
|
||||
if (file2.isDirectory()) {
|
||||
list.add(file2);
|
||||
} else {
|
||||
if (VideoUtils.isPicFormat(file2.getAbsolutePath())) {
|
||||
picFileList.add(file2.getAbsolutePath());
|
||||
} else if (VideoUtils.isVideoFormat(file2.getAbsolutePath())) {
|
||||
videoFileList.add(file2.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e("traverseFolder1", "文件不存在!");
|
||||
}
|
||||
Log.e("ScanTask", "doInBackground: " + "Scan time = " + (System.currentTimeMillis() - s1) + "ms");
|
||||
Log.e("getThumbnail", "picFileList: " + picFileList);
|
||||
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: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
Log.e("getThumbnail", "videoFileList size = " + videoFileList.size());
|
||||
// CombineBitmap.init(this)
|
||||
// .setLayoutManager(new DingLayoutManager()) // 必选, 设置图片的组合形式,支持WechatLayoutManager、DingLayoutManager
|
||||
// .setSize(100) // 必选,组合后Bitmap的尺寸,单位dp
|
||||
// .setGap(1) // 单个图片之间的距离,单位dp,默认0dp
|
||||
//// .setGapColor() // 单个图片间距的颜色,默认白色
|
||||
//// .setPlaceholder() // 单个图片加载失败的默认显示图片
|
||||
// .setUrls(picFileList.toArray(new String[picFileList.size()])) // 要加载的图片url数组
|
||||
// .setBitmaps() // 要加载的图片bitmap数组
|
||||
// .setResourceIds() // 要加载的图片资源id数组
|
||||
// .setImageView(nv_pic) // 直接设置要显示图片的ImageView
|
||||
// // 设置“子图片”的点击事件,需使用setImageView(),index和图片资源数组的索引对应
|
||||
//// .setOnSubItemClickListener(new OnSubItemClickListener() {
|
||||
//// @Override
|
||||
//// public void onSubItemClick(int index) {
|
||||
////
|
||||
//// }
|
||||
//// })
|
||||
//// // 加载进度的回调函数,如果不使用setImageView()方法,可在onComplete()完成最终图片的显示
|
||||
//// .setProgressListener(new ProgressListener() {
|
||||
//// @Override
|
||||
//// public void onStart() {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onComplete(Bitmap bitmap) {
|
||||
////
|
||||
//// }
|
||||
//// })
|
||||
// .build();
|
||||
|
||||
// CombineBitmap.init(this)
|
||||
// .setLayoutManager(new DingLayoutManager()) // 必选, 设置图片的组合形式,支持WechatLayoutManager、DingLayoutManager
|
||||
// .setSize(100) // 必选,组合后Bitmap的尺寸,单位dp
|
||||
// .setGap(1) // 单个图片之间的距离,单位dp,默认0dp
|
||||
//// .setGapColor() // 单个图片间距的颜色,默认白色
|
||||
//// .setPlaceholder() // 单个图片加载失败的默认显示图片
|
||||
// .setUrls(videoFileList.toArray(new String[videoFileList.size()])) // 要加载的图片url数组
|
||||
// .setBitmaps() // 要加载的图片bitmap数组
|
||||
// .setResourceIds() // 要加载的图片资源id数组
|
||||
// .setImageView(nv_video) // 直接设置要显示图片的ImageView
|
||||
// .build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将本地图片转换为 Drawable
|
||||
*
|
||||
* @param file 文件路径
|
||||
* @return
|
||||
*/
|
||||
public Drawable path2Drawable(String file) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Drawable drawable = null;
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(fis);
|
||||
drawable = new BitmapDrawable(getResources(), bitmap);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,27 @@
|
||||
package com.uiui.videoplayer.activity.pic;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.adapter.PicAdapter;
|
||||
import com.uiui.videoplayer.base.BGAGridDivider;
|
||||
import com.uiui.videoplayer.base.BaseLightActivity;
|
||||
import com.uiui.videoplayer.base.GridSpaceItemDecoration;
|
||||
import com.uiui.videoplayer.base.BaseActivity;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class GalleryActivity extends BaseLightActivity implements GalleryContact.GalleryView {
|
||||
public class GalleryActivity extends BaseActivity implements GalleryContact.GalleryView {
|
||||
|
||||
@BindView(R.id.swipeRefreshLayout)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
@@ -47,11 +43,16 @@ public class GalleryActivity extends BaseLightActivity implements GalleryContact
|
||||
return R.layout.activity_gallery;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new GalleryPresenter(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
mPresenter.attachView(this);
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT, LinearLayoutManager.VERTICAL, false);
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.adapter.PreviewAdapter;
|
||||
import com.uiui.videoplayer.base.BaseLightActivity;
|
||||
import com.uiui.videoplayer.base.BaseActivity;
|
||||
import com.uiui.videoplayer.base.ScaleCircleNavigator;
|
||||
import com.uiui.videoplayer.bean.PhotoInfo;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class PreviewActivity extends BaseLightActivity {
|
||||
public class PreviewActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.viewPager)
|
||||
ViewPager viewPager;
|
||||
@@ -40,6 +40,11 @@ public class PreviewActivity extends BaseLightActivity {
|
||||
return R.layout.activity_preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
UltimateBarX.statusBar(this)
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package com.uiui.videoplayer.activity.video;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
@@ -23,7 +18,6 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -36,10 +30,9 @@ import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.adapter.VideoAdapter;
|
||||
import com.uiui.videoplayer.base.BaseLightActivity;
|
||||
import com.uiui.videoplayer.base.BaseActivity;
|
||||
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.SPUtils;
|
||||
@@ -54,7 +47,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class VideoActivity extends BaseLightActivity implements VideoContact.VideoView {
|
||||
public class VideoActivity extends BaseActivity implements VideoContact.VideoView {
|
||||
|
||||
private static final String TAG = VideoActivity.class.getSimpleName();
|
||||
|
||||
@@ -80,7 +73,7 @@ public class VideoActivity extends BaseLightActivity implements VideoContact.Vid
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new VideoPresenter(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
mPresenter.attachView(this);
|
||||
|
||||
Aria.download(this).register();
|
||||
@@ -101,8 +94,7 @@ public class VideoActivity extends BaseLightActivity implements VideoContact.Vid
|
||||
}
|
||||
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(VideoActivity.this);
|
||||
adapter.setOnLongClickListener(new VideoAdapter.onItemLongClickListener() {
|
||||
@@ -141,6 +133,11 @@ public class VideoActivity extends BaseLightActivity implements VideoContact.Vid
|
||||
return R.layout.activity_video;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.uiui.videoplayer.activity.vip;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.base.mvvm.BaseMvvmActivity;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.databinding.ActivityVipBinding;
|
||||
import com.uiui.videoplayer.utils.Utils;
|
||||
|
||||
public class VipActivity extends BaseMvvmActivity<VipViewModel, ActivityVipBinding> {
|
||||
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_vip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new Click());
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
protected void initData() {
|
||||
mViewModel.getSpaceInfoData().observe(this, new Observer<SpaceInfo>() {
|
||||
@Override
|
||||
public void onChanged(SpaceInfo spaceInfo) {
|
||||
if (spaceInfo == null) {
|
||||
// tv_rank.setText("普通");
|
||||
mViewDataBinding.tvSpaceFree.setText("0GB/0GB");
|
||||
mViewDataBinding.tvSpaceUsed.setText("0%");
|
||||
|
||||
} else {
|
||||
String home_video_grade = spaceInfo.getHome_video_grade();
|
||||
long quota = spaceInfo.getQuota();
|
||||
long use_quota = spaceInfo.getUse_quota();
|
||||
// tv_rank.setText(home_video_grade);
|
||||
mViewDataBinding.tvSpaceFree.setText(String.format(getString(R.string.space_free), Utils.formatFileSize(use_quota), Utils.formatFileSize(quota)));
|
||||
int percentage = (int) ((quota - use_quota) * 100 / (float) quota);
|
||||
mViewDataBinding.tvSpaceUsed.setText(String.format(getString(R.string.space_used), (percentage + "%")));
|
||||
}
|
||||
}
|
||||
});
|
||||
mViewModel.getHomeSpaceInfo();
|
||||
|
||||
}
|
||||
|
||||
public class Click {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void empty(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.uiui.videoplayer.activity.vip;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.videoplayer.base.mvvm.BaseViewModel;
|
||||
import com.uiui.videoplayer.bean.BaseResponse;
|
||||
import com.uiui.videoplayer.bean.SpaceInfo;
|
||||
import com.uiui.videoplayer.databinding.ActivityVipBinding;
|
||||
import com.uiui.videoplayer.network.NetInterfaceManager;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class VipViewModel extends BaseViewModel<ActivityVipBinding> {
|
||||
@Override
|
||||
public ActivityVipBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
private MutableLiveData<SpaceInfo> mSpaceInfoData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<SpaceInfo> getSpaceInfoData() {
|
||||
return mSpaceInfoData;
|
||||
}
|
||||
|
||||
public void getHomeSpaceInfo() {
|
||||
NetInterfaceManager.getInstance().getHomeSpaceInfoControl()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.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;
|
||||
mSpaceInfoData.setValue(spaceInfo);
|
||||
} else {
|
||||
mSpaceInfoData.setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getHomeSpaceInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getHomeSpaceInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.uiui.videoplayer.adapter;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class EquallyDividedItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private static final String TAG = EquallyDividedItemDecoration.class.getSimpleName();
|
||||
|
||||
private int mSpanCount;//横条目数量
|
||||
private int mHalfRowSpacing;//行间距的一半
|
||||
private int mHalfColumnSpacing;// 列间距的一半
|
||||
|
||||
|
||||
public EquallyDividedItemDecoration(int spanCount, int halfRowSpacing) {
|
||||
mSpanCount = spanCount;
|
||||
mHalfRowSpacing = halfRowSpacing;
|
||||
mHalfColumnSpacing = halfRowSpacing;
|
||||
}
|
||||
|
||||
public EquallyDividedItemDecoration(int spanCount, int halfRowSpacing, int halfColumnSpacing) {
|
||||
mSpanCount = spanCount;
|
||||
mHalfRowSpacing = halfRowSpacing;
|
||||
mHalfColumnSpacing = halfColumnSpacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int position = parent.getChildAdapterPosition(view); // 获取view 在adapter中的位置。
|
||||
Log.d(TAG, "getItemOffsets: position = " + position);
|
||||
|
||||
int itemCount = parent.getAdapter().getItemCount();//item全部数量
|
||||
Log.d(TAG, "getItemOffsets: itemCount = " + itemCount);
|
||||
|
||||
int column = position % mSpanCount; // view 所在的列
|
||||
Log.d(TAG, "getItemOffsets: column = " + column);
|
||||
|
||||
if (column == 0) {
|
||||
outRect.left = 2 * mHalfRowSpacing;
|
||||
outRect.right = mHalfRowSpacing;
|
||||
} else if (column == mSpanCount - 1) {
|
||||
outRect.left = mHalfRowSpacing;
|
||||
outRect.right = 2 * mHalfRowSpacing;
|
||||
} else {
|
||||
outRect.left = mHalfRowSpacing;
|
||||
outRect.right = mHalfRowSpacing;
|
||||
}
|
||||
|
||||
int row = (position / 3);//所在行
|
||||
Log.d(TAG, "getItemOffsets: row = " + row);
|
||||
int maxRow = (int) Math.ceil((double) itemCount / mSpanCount);//一共多少行
|
||||
Log.d(TAG, "getItemOffsets: maxRow = " + maxRow);
|
||||
|
||||
if (row == 0) {
|
||||
outRect.top = 2 * mHalfColumnSpacing;
|
||||
outRect.bottom = mHalfColumnSpacing;
|
||||
} else if (row == maxRow - 1) {
|
||||
outRect.top = mHalfColumnSpacing;
|
||||
outRect.bottom = 2 * mHalfColumnSpacing;
|
||||
} else {
|
||||
outRect.top = mHalfColumnSpacing;
|
||||
outRect.bottom = mHalfColumnSpacing;
|
||||
}
|
||||
|
||||
Log.d(TAG, "getItemOffsets: outRect.left = " + outRect.left);
|
||||
Log.d(TAG, "getItemOffsets: outRect.right = " + outRect.right);
|
||||
Log.d(TAG, "getItemOffsets: outRect.top = " + outRect.top);
|
||||
Log.d(TAG, "getItemOffsets: outRect.bottom = " + outRect.bottom);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,134 +1,32 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.ContentView;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
setContentView(this.getLayoutId());
|
||||
initView();
|
||||
initData();
|
||||
//最近任务和应用图标不一样
|
||||
// if (Build.VERSION.SDK_INT > 27) {
|
||||
// ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(getString(R.string.app_name), R.mipmap.ic_launcher, getColor(R.color.colorPrimary));
|
||||
// this.setTaskDescription(description);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
public abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
public abstract void initView();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
public abstract void initData();
|
||||
public abstract class BaseActivity extends BaseTransparentActivity {
|
||||
|
||||
public BaseActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ContentView
|
||||
public BaseActivity(@LayoutRes int contentLayoutId) {
|
||||
super(contentLayoutId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
lifecycleSubject.onNext(ActivityEvent.START);
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutId());
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
lifecycleSubject.onNext(ActivityEvent.RESUME);
|
||||
}
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onPause() {
|
||||
lifecycleSubject.onNext(ActivityEvent.PAUSE);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStop() {
|
||||
lifecycleSubject.onNext(ActivityEvent.STOP);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onDestroy() {
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public abstract class BaseDataBindingActivity extends BaseTransparentActivity {
|
||||
|
||||
public BaseDataBindingActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 加载显示Fragment的ViewPagerAdapter基类
|
||||
* 提供可以刷新的方法
|
||||
*
|
||||
* @author Fly
|
||||
* @e-mail 1285760616@qq.com
|
||||
* @time 2018/3/22
|
||||
*/
|
||||
public class BaseFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||
private List<Fragment> mFragmentList;
|
||||
private FragmentManager mFragmentManager;
|
||||
/**下面两个值用来保存Fragment的位置信息,用以判断该位置是否需要更新*/
|
||||
private SparseArray<String> mFragmentPositionMap;
|
||||
private SparseArray<String> mFragmentPositionMapAfterUpdate;
|
||||
|
||||
public BaseFragmentPagerAdapter(FragmentManager fm, List<Fragment> fragments) {
|
||||
super(fm);
|
||||
mFragmentList = fragments;
|
||||
mFragmentManager = fm;
|
||||
mFragmentList = fragments;
|
||||
mFragmentPositionMap = new SparseArray<>();
|
||||
mFragmentPositionMapAfterUpdate = new SparseArray<>();
|
||||
setFragmentPositionMap();
|
||||
setFragmentPositionMapForUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新之前的位置信息,用<hashCode, position>的键值对结构来保存
|
||||
*/
|
||||
private void setFragmentPositionMap() {
|
||||
mFragmentPositionMap.clear();
|
||||
for (int i = 0; i < mFragmentList.size(); i++) {
|
||||
mFragmentPositionMap.put(Long.valueOf(getItemId(i)).intValue(), String.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新之后的位置信息,用<hashCode, position>的键值对结构来保存
|
||||
*/
|
||||
private void setFragmentPositionMapForUpdate() {
|
||||
mFragmentPositionMapAfterUpdate.clear();
|
||||
for (int i = 0; i < mFragmentList.size(); i++) {
|
||||
mFragmentPositionMapAfterUpdate.put(Long.valueOf(getItemId(i)).intValue(), String.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在此方法中找到需要更新的位置返回POSITION_NONE,否则返回POSITION_UNCHANGED即可
|
||||
*/
|
||||
@Override
|
||||
public int getItemPosition(Object object) {
|
||||
int hashCode = object.hashCode();
|
||||
//查找object在更新后的列表中的位置
|
||||
String position = mFragmentPositionMapAfterUpdate.get(hashCode);
|
||||
//更新后的列表中不存在该object的位置了
|
||||
if (position == null) {
|
||||
return POSITION_NONE;
|
||||
} else {
|
||||
//如果更新后的列表中存在该object的位置, 查找该object之前的位置并判断位置是否发生了变化
|
||||
int size = mFragmentPositionMap.size();
|
||||
for (int i = 0; i < size ; i++) {
|
||||
int key = mFragmentPositionMap.keyAt(i);
|
||||
if (key == hashCode) {
|
||||
String index = mFragmentPositionMap.get(key);
|
||||
if (position.equals(index)) {
|
||||
//位置没变依然返回POSITION_UNCHANGED
|
||||
return POSITION_UNCHANGED;
|
||||
} else {
|
||||
//位置变了
|
||||
return POSITION_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return POSITION_UNCHANGED;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定的Fragment替换/更新为新的Fragment
|
||||
* @param oldFragment 旧Fragment
|
||||
* @param newFragment 新Fragment
|
||||
*/
|
||||
public void replaceFragment(Fragment oldFragment, Fragment newFragment) {
|
||||
int position = mFragmentList.indexOf(oldFragment);
|
||||
if (position == -1) {
|
||||
return;
|
||||
}
|
||||
//从Transaction移除旧的Fragment
|
||||
removeFragmentInternal(oldFragment);
|
||||
//替换List中对应的Fragment
|
||||
mFragmentList.set(position, newFragment);
|
||||
//刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定位置的Fragment替换/更新为新的Fragment,同{@link #replaceFragment(Fragment oldFragment, Fragment newFragment)}
|
||||
* @param position 旧Fragment的位置
|
||||
* @param newFragment 新Fragment
|
||||
*/
|
||||
public void replaceFragment(int position, Fragment newFragment) {
|
||||
Fragment oldFragment = mFragmentList.get(position);
|
||||
removeFragmentInternal(oldFragment);
|
||||
mFragmentList.set(position, newFragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定的Fragment
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void removeFragment(Fragment fragment) {
|
||||
//先从List中移除
|
||||
mFragmentList.remove(fragment);
|
||||
//然后从Transaction移除
|
||||
removeFragmentInternal(fragment);
|
||||
//最后刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定位置的Fragment,同 {@link #removeFragment(Fragment fragment)}
|
||||
* @param position
|
||||
*/
|
||||
public void removeFragment(int position) {
|
||||
Fragment fragment = mFragmentList.get(position);
|
||||
//然后从List中移除
|
||||
mFragmentList.remove(fragment);
|
||||
//先从Transaction移除
|
||||
removeFragmentInternal(fragment);
|
||||
//最后刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Fragment
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void addFragment(Fragment fragment) {
|
||||
mFragmentList.add(fragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定位置插入一个Fragment
|
||||
* @param position 插入位置
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void insertFragment(int position, Fragment fragment) {
|
||||
mFragmentList.add(position, fragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
public void notifyItemChanged() {
|
||||
//刷新之前重新收集位置信息
|
||||
setFragmentPositionMapForUpdate();
|
||||
notifyDataSetChanged();
|
||||
setFragmentPositionMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Transaction移除Fragment
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
private void removeFragmentInternal(Fragment fragment) {
|
||||
FragmentTransaction transaction = mFragmentManager.beginTransaction();
|
||||
transaction.remove(fragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
/**
|
||||
* 此方法不用position做返回值即可破解fragment tag异常的错误
|
||||
*/
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// 获取当前数据的hashCode,其实这里不用hashCode用自定义的可以关联当前Item对象的唯一值也可以,只要不是直接返回position
|
||||
return mFragmentList.get(position).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return mFragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mFragmentList.size();
|
||||
}
|
||||
|
||||
public List<Fragment> getFragments() {
|
||||
return mFragmentList;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.ContentView;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@@ -16,23 +13,19 @@ import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* {@link com.trello.rxlifecycle4.components.RxActivity}
|
||||
* copied form RxActivity}
|
||||
*/
|
||||
public abstract class BaseRxActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
public abstract class BaseLightActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
public BaseLightActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ContentView
|
||||
public BaseLightActivity(@LayoutRes int contentLayoutId) {
|
||||
super(contentLayoutId);
|
||||
public BehaviorSubject<ActivityEvent> getLifecycleSubject() {
|
||||
return lifecycleSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,40 +54,8 @@ public abstract class BaseLightActivity extends AppCompatActivity implements Lif
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
// StatusBarUtil.init(this);
|
||||
setContentView(this.getLayoutId());
|
||||
UltimateBarX.statusBar(this)
|
||||
// .transparent()
|
||||
.colorRes(R.color.colorAccent)
|
||||
.fitWindow(true)
|
||||
.light(false)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
// .color(Color.TRANSPARENT)
|
||||
.fitWindow(false)
|
||||
.light(false)
|
||||
.apply();
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
public abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
public abstract void initView();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
public abstract void initData();
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStart() {
|
||||
@@ -130,3 +91,4 @@ public abstract class BaseLightActivity extends AppCompatActivity implements Lif
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public abstract class BaseTransparentActivity extends BaseRxActivity {
|
||||
|
||||
public BaseTransparentActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(setNightMode())
|
||||
.fitWindow(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(setNightMode())
|
||||
.fitWindow(true)
|
||||
.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
protected abstract boolean setNightMode();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.uiui.videoplayer.base.mvvm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.uiui.videoplayer.base.BaseTransparentActivity;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
public abstract class BaseMvvmActivity<VM extends ViewModel, VDB extends ViewDataBinding> extends BaseTransparentActivity {
|
||||
|
||||
private static final String TAG = BaseMvvmActivity.class.getSimpleName();
|
||||
|
||||
protected VM mViewModel;
|
||||
protected VDB mViewDataBinding;
|
||||
protected Class<VM> vmClass;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//ViewDataBinding
|
||||
mViewDataBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mViewDataBinding.setLifecycleOwner(this);
|
||||
//ViewModel
|
||||
vmClass = (Class<VM>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
boolean isAbstract = Modifier.isAbstract(vmClass.getModifiers());
|
||||
Log.e(TAG, "isLocalClass:" + vmClass.getSimpleName().equals(ViewModel.class.getSimpleName()) + " isAbstract:" + isAbstract);
|
||||
if (!isAbstract) {//不是一个抽象类
|
||||
mViewModel = new ViewModelProvider(this).get(vmClass);
|
||||
}
|
||||
initDataBinding();
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
protected abstract void initDataBinding();
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.uiui.videoplayer.base.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* 所有viewmodel的基类
|
||||
*/
|
||||
public abstract class BaseViewModel<VDB extends ViewDataBinding> extends ViewModel implements ViewDataBindingCallback {
|
||||
|
||||
/**
|
||||
* 当前viewmodel对应的页面binding
|
||||
*/
|
||||
protected VDB binding;
|
||||
|
||||
@Override
|
||||
public void setVDBinding(ViewDataBinding vdBinding) {
|
||||
|
||||
binding = (VDB)vdBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VDB getVDBinding() {
|
||||
if (binding == null) {
|
||||
throw new NullPointerException("BaseViewModel >> getVDBinding >> null!!!");
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下文
|
||||
*/
|
||||
private WeakReference<Context> ctx;
|
||||
|
||||
@Override
|
||||
public void setCtx(Context context) {
|
||||
if(ctx == null) {
|
||||
ctx = new WeakReference<>(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getCtx() {
|
||||
if (ctx == null) {
|
||||
throw new NullPointerException("BaseViewModel >> getCtx >> null!!!");
|
||||
}
|
||||
return ctx.get();
|
||||
}
|
||||
|
||||
|
||||
public abstract void onDestroy();
|
||||
|
||||
private BehaviorSubject<ActivityEvent> mBehaviorSubject;
|
||||
|
||||
@Override
|
||||
public void setLifecycle(BehaviorSubject subject) {
|
||||
this.mBehaviorSubject =subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return mBehaviorSubject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.uiui.videoplayer.base.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public interface ViewDataBindingCallback<VDB extends ViewDataBinding> {
|
||||
|
||||
|
||||
void setVDBinding(VDB binding);
|
||||
|
||||
VDB getVDBinding() throws NullPointerException;
|
||||
|
||||
|
||||
void setCtx(Context context);
|
||||
|
||||
Context getCtx() throws NullPointerException;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> subject);
|
||||
|
||||
BehaviorSubject<ActivityEvent> getLifecycle();
|
||||
}
|
||||
@@ -17,15 +17,13 @@ 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.EquallyDividedItemDecoration;
|
||||
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.ScreenUtils;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -127,20 +125,12 @@ public class PictureFragment extends BaseFragment implements PictureContact.Pict
|
||||
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));
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
EquallyDividedItemDecoration equallyDividedItemDecoration = new EquallyDividedItemDecoration(SPAN_COUNT, ScreenUtils.dip2px(mContext, 1));
|
||||
recyclerView.addItemDecoration(equallyDividedItemDecoration);
|
||||
|
||||
mPicAdapter = new PicAdapter(layoutManager);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.addItemDecoration(BGAGridDivider.newInstanceWithSpaceRes(R.dimen.dp_2));
|
||||
recyclerView.setAdapter(mPicAdapter);
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
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;
|
||||
@@ -25,22 +18,19 @@ 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.EquallyDividedItemDecoration;
|
||||
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.ScreenUtils;
|
||||
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;
|
||||
@@ -65,8 +55,9 @@ public class VideoFragment extends BaseFragment implements VideoContact.VideoVie
|
||||
|
||||
private VideoPresenter mPresenter;
|
||||
private RecycleGridLayoutManager mManager;
|
||||
private VideoAdapter adapter;
|
||||
|
||||
private VideoAdapter mVideoAdapter;
|
||||
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";
|
||||
@@ -145,38 +136,22 @@ public class VideoFragment extends BaseFragment implements VideoContact.VideoVie
|
||||
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));
|
||||
|
||||
mManager = new RecycleGridLayoutManager(mContext, SPAN_COUNT);
|
||||
recyclerView.setLayoutManager(mManager);
|
||||
|
||||
EquallyDividedItemDecoration equallyDividedItemDecoration = new EquallyDividedItemDecoration(SPAN_COUNT, ScreenUtils.dip2px(mContext, 1));
|
||||
recyclerView.addItemDecoration(equallyDividedItemDecoration);
|
||||
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() {
|
||||
mVideoAdapter = new VideoAdapter(mContext);
|
||||
mVideoAdapter.setOnLongClickListener(new VideoAdapter.onItemLongClickListener() {
|
||||
@Override
|
||||
public void onItemLongClick(String path, int position) {
|
||||
showDialog(path, position);
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setAdapter(mVideoAdapter);
|
||||
|
||||
mPresenter.getHomeVideo();
|
||||
refreshLayout.setRefreshing(true);
|
||||
@@ -194,7 +169,7 @@ public class VideoFragment extends BaseFragment implements VideoContact.VideoVie
|
||||
dialog.dismiss();
|
||||
File file = new File(path);
|
||||
if (file.delete()) {
|
||||
adapter.removeItem(position);
|
||||
mVideoAdapter.removeItem(position);
|
||||
ToastUtil.show("删除成功");
|
||||
} else {
|
||||
ToastUtil.show("删除失败,检查权限是否开启");
|
||||
@@ -219,7 +194,7 @@ public class VideoFragment extends BaseFragment implements VideoContact.VideoVie
|
||||
} else {
|
||||
cl_nodata.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
adapter.setData(video);
|
||||
mVideoAdapter.setData(video);
|
||||
}
|
||||
refreshLayout.setRefreshing(false);
|
||||
}
|
||||
@@ -230,10 +205,6 @@ public class VideoFragment extends BaseFragment implements VideoContact.VideoVie
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
void running(DownloadTask task) {
|
||||
|
||||
@@ -33,7 +33,9 @@ public class Utils {
|
||||
if (fileS == 0) {
|
||||
return wrongSize;
|
||||
}
|
||||
if (fileS < 1048576) {
|
||||
if (fileS < 1024) {
|
||||
fileSizeString = df.format((double) fileS) + "MB";
|
||||
} else if (fileS < 1048576) {
|
||||
fileSizeString = df.format((double) fileS / 1024) + "GB";
|
||||
} else {
|
||||
fileSizeString = df.format((double) fileS / 1048576) + "TB";
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/icon_vip.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 1.9 KiB |
17
app/src/main/res/drawable/bt_vip_backround.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/btn_sure" />
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners
|
||||
android:bottomLeftRadius="@dimen/dp_16"
|
||||
android:bottomRightRadius="@dimen/dp_16"
|
||||
android:topLeftRadius="@dimen/dp_16"
|
||||
android:topRightRadius="@dimen/dp_16" />
|
||||
|
||||
<padding
|
||||
android:bottom="@dimen/dp_4"
|
||||
android:left="@dimen/dp_12"
|
||||
android:right="@dimen/dp_12"
|
||||
android:top="@dimen/dp_4" />
|
||||
</shape>
|
||||
17
app/src/main/res/drawable/vip_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="@android:color/white" />
|
||||
|
||||
<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_8"
|
||||
android:left="@dimen/dp_8"
|
||||
android:right="@dimen/dp_8"
|
||||
android:top="@dimen/dp_8" />
|
||||
|
||||
</shape>
|
||||
@@ -1,267 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.main.MainActivity">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="com.uiui.videoplayer.activity.main.MainActivity.Click" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
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">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout2"
|
||||
android:id="@+id/constraintLayout3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_height="match_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"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<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"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:onClick="@{click::exit}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="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: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_constraintStart_toEndOf="@+id/iv_back"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<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"
|
||||
android:background="@drawable/bt_vip_backround"
|
||||
android:onClick="@{click::toVip}"
|
||||
android:text="会员权益"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_8"
|
||||
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">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/constraintLayout2">
|
||||
|
||||
<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"
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/main_sliding_tab_layout"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tl_indicator_color="@color/black"
|
||||
app:tl_indicator_style="NORMAL"
|
||||
app:tl_indicator_width_equal_title="true"
|
||||
app:tl_tab_space_equal="true"
|
||||
app:tl_textBold="SELECT"
|
||||
app:tl_textSelectColor="@color/black"
|
||||
app:tl_textSelectSize="@dimen/sp_11"
|
||||
app:tl_textSize="@dimen/sp_10"
|
||||
app:tl_textUnSelectColor="@color/gray"
|
||||
app:tl_textUnSelectSize="@dimen/sp_10" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:id="@+id/tv_version"
|
||||
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"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_7"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/main_sliding_tab_layout"
|
||||
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"
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/main_sliding_tab_layout" />
|
||||
|
||||
<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_marginEnd="@dimen/dp_4"
|
||||
android:text="按时间顺序排序"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView" />
|
||||
|
||||
<ImageView
|
||||
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/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>
|
||||
</layout>
|
||||
267
app/src/main/res/layout/activity_main_land.xml
Normal file
@@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.main.MainActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
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/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_marginEnd="@dimen/dp_4"
|
||||
android:text="按时间顺序排序"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView" />
|
||||
|
||||
<ImageView
|
||||
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/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>
|
||||
80
app/src/main/res/layout/activity_vip.xml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="com.uiui.videoplayer.activity.vip.VipActivity.Click" />
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:onClick="@{click::exit}">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="@dimen/dp_240"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
android:background="@drawable/vip_background"
|
||||
android:onClick="@{click::empty}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:soundEffectsEnabled="false"
|
||||
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:layout_gravity="center"
|
||||
android:text="会员权益说明"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_11"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_44"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_vip" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_space_free"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="@string/space_free"
|
||||
android:textColor="@color/gray"
|
||||
android:textSize="@dimen/sp_9" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_space_used"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="@string/space_used"
|
||||
android:textColor="@color/gray"
|
||||
android:textSize="@dimen/sp_9" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
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
|
||||
@@ -15,8 +15,7 @@
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -24,6 +23,7 @@
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:overScrollMode="never"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
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
|
||||
@@ -17,13 +17,13 @@
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="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" />
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
<com.shehuan.niv.NiceImageView
|
||||
android:id="@+id/iv_pic"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
app:corner_radius="@dimen/dp_4"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -22,7 +21,6 @@
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/dp_2"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/lightGray"
|
||||
android:textSize="@dimen/sp_9"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -18,10 +18,8 @@
|
||||
android:id="@+id/video_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
app:corner_radius="@dimen/dp_4"
|
||||
app:is_cover_src="true" />
|
||||
|
||||
<com.shehuan.niv.NiceImageView
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 50 KiB |
@@ -4,4 +4,6 @@
|
||||
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
<string name="space_free">免费存储空间:%s/%s</string>
|
||||
<string name="space_used">剩余使用空间:%s</string>
|
||||
</resources>
|
||||
|
||||
@@ -7,15 +7,16 @@
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:windowBackground">@color/colorBackground</item>
|
||||
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
||||
|
||||
</style>
|
||||
|
||||
<!-- <!– Base application theme. –>-->
|
||||
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
|
||||
<!-- <!– Customize your theme here. –>-->
|
||||
<!-- <item name="colorPrimary">@color/white</item>-->
|
||||
<!-- <item name="colorPrimaryDark">@color/white</item>-->
|
||||
<!-- <item name="colorAccent">@color/defaultColor</item>-->
|
||||
<!-- </style>-->
|
||||
<!-- <!– Base application theme. –>-->
|
||||
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
|
||||
<!-- <!– Customize your theme here. –>-->
|
||||
<!-- <item name="colorPrimary">@color/white</item>-->
|
||||
<!-- <item name="colorPrimaryDark">@color/white</item>-->
|
||||
<!-- <item name="colorAccent">@color/defaultColor</item>-->
|
||||
<!-- </style>-->
|
||||
|
||||
<style name="CustomDialog" parent="android:style/Theme.Dialog">
|
||||
<!--背景颜色及和透明程度-->
|
||||
@@ -30,4 +31,24 @@
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
</style>
|
||||
|
||||
<style name="activity_styles" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- <item name="android:windowFullscreen">true</item>-->
|
||||
<!--设置dialog的背景-->
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<!--设置Dialog的windowFrame框为无-->
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<!--设置无标题-->
|
||||
<item name="windowNoTitle">true</item>
|
||||
<!--是否浮现在activity之上-->
|
||||
<item name="android:windowIsFloating">false</item>
|
||||
<!--是否半透明-->
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<!--设置窗口内容不覆盖-->
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<!--设置动画,在这里使用让它继承系统的Animation.Dialog-->
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
<!--背景是否模糊显示-->
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -25,6 +25,8 @@ public class RemoteManager {
|
||||
public static final String hidePackageKey = "HIDE_PACKAGE_NAME";
|
||||
public static final String disablePackageKey = "DISABLE_PACKAGE_NAME";
|
||||
|
||||
private static boolean mServiceConnected = false;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static RemoteManager sInstance;
|
||||
private Context mContext;
|
||||
@@ -41,6 +43,7 @@ public class RemoteManager {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: " + name);
|
||||
mServiceConnected = true;
|
||||
mIGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||
try {
|
||||
for (ConnectedListener listener : mListeners) {
|
||||
@@ -102,6 +105,9 @@ public class RemoteManager {
|
||||
|
||||
public void setListener(ConnectedListener listener) {
|
||||
mListeners.add(listener);
|
||||
if (mServiceConnected) {
|
||||
listener.onConnected();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeListener(ConnectedListener listener) {
|
||||
|
||||