《快播》,仿网易云音乐UI,整体采用RxJava+Retrofit+MVP的架构,支持在线视频播放,在线图片浏览等功能。
用到第三方开源库:
- ButterKnife:依赖注入框架
- glide:图片加载
- retrofit:网络请求
- jieCaoVideoPlayer:播放器
抓取接口用于数据展示
效果图如下:
基类:
package com.zmj.qvod.base;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
public abstract class BaseActivity extends AppCompatActivity {
/**
* 是否沉浸状态栏
**/
private boolean isSetStatusBar = false;
/**
* 是否允许全屏
**/
private boolean mAllowFullScreen = false;
/**
* 是否允许屏幕旋转
**/
private boolean isAllowScreenRotate = false;
/**
* 当前Activity渲染的视图View
**/
private View mContextView = null;
/**
* 日志输出标志
**/
protected final String TAG = this.getClass().getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "BaseActivity-->onCreate()");
Bundle bundle = getIntent().getExtras();
initPrams(bundle);
//
mContextView = LayoutInflater.from(this).inflate(bindLayout(), null);
//
if (mAllowFullScreen) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
//
if (isSetStatusBar) {
steepStatusBar();
}
//
setContentView(bindLayout());
//
if (!isAllowScreenRotate) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
//
initView(mContextView);
//
setListener();
//
doBusiness(this);
}
/**
* [沉浸状态栏]
*/
private void steepStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 透明状态栏
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 透明导航栏
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
}
/**
* [初始化参数--加载xml视图之前]
*
* @param bundle
*/
public abstract void initPrams(Bundle bundle);
/**
* [绑定布局]
*
* @return
*/
public abstract int bindLayout();
/**
* [初始化控件]
*
* @param view
*/
public abstract void initView(final View view);
/**
* [绑定控件]
*
* @param resId
* @return
*/
protected <T extends View> T $(int resId) {
return (T) super.findViewById(resId);
}
/**
* [设置监听]
*/
public abstract void setListener();
/**
* [业务操作]
*
* @param mContext
*/
public abstract void doBusiness(Context mContext);
/**
* [页面跳转]
*
* @param clz
*/
public void startActivity(Class<?> clz) {
startActivity(new Intent(BaseActivity.this, clz));
}
/**
* [携带数据的页面跳转]
*
* @param clz
* @param bundle
*/
public void startActivity(Class<?> clz, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(this, clz);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
}
/**
* [含有Bundle通过Class打开编辑界面]
*
* @param cls
* @param bundle
* @param requestCode
*/
public void startActivityForResult(Class<?> cls, Bundle bundle,
int requestCode) {
Intent intent = new Intent();
intent.setClass(this, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivityForResult(intent, requestCode);
}
@Override
protected void onRestart() {
super.onRestart();
Log.d(TAG, "onRestart()");
}
@Override
protected void onStart() {
super.onStart();
Log.d(TAG, "onStart()");
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume()");
}
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause()");
}
@Override
protected void onStop() {
super.onStop();
Log.d(TAG, "onStop()");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy()");
}
/**
* [简化Toast]
*
* @param msg
*/
protected void showToast(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
/**
* [简化Toast]
*
* @param msg
*/
protected void showToast(int msg) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
/**
* [是否允许全屏]
*
* @param allowFullScreen
*/
public void setAllowFullScreen(boolean allowFullScreen) {
this.mAllowFullScreen = allowFullScreen;
}
/**
* [是否设置沉浸状态栏]
*
* @param isSetStatusBar
*/
public void setSteepStatusBar(boolean isSetStatusBar) {
this.isSetStatusBar = isSetStatusBar;
}
/**
* [是否允许屏幕旋转]
*
* @param isAllowScreenRotate
*/
public void setScreenRoate(boolean isAllowScreenRotate) {
this.isAllowScreenRotate = isAllowScreenRotate;
}
}
作者:zhaomingjian;Github开源地址:https://github.com/zhao-mingjian/qvod
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦