首頁>技術>

《快播》,仿網易雲音樂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

  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • JNPF快速開發平臺六大功能,拒絕重複造輪子