一:簡述
今天給android開發者們,推薦一個金典的界面提示框架WisdomProgressHUD,使用簡潔方便。
WisdomProgressHUD 是一個半透明的 HUD 指示器。 WisdomProgressHUD 是android 版SDK,由java編寫,保證兼容性問題。
全局HUD單列對象,支持屬性動態調整, 支持延時調用,無需開發關心釋放問題,是一個強大的HUD庫,使用簡介,操作方便。
github 鏈接:https://github.com/tangjianfengVS/WisdomProgressHUD
二:WisdomProgressHUD 支持類型
1: Default (只有文字沒有圖片,默認使用)
2: Succee (有文字,有圖片,成功提示)
3: Error (有文字,有圖片,失敗提示)
4: Warning (有文字,有圖片,警告提示)
5: Loading (有文字,有圖片,加載中提示)("Loading" 和上面的類型不同,是耗時任務,不會自動消滅任務,需要手動調用 'dismiss',結束回調任務也不會實現)
三:WisdomProgressHUD 屬性設置
1: static float HUDTextSize = 13
說明: 提示時候的文字字體pd大小,設置最小值13號pd
2: static float HUDShowTime = 2500
說明: 提示時候的界面顯示時間,設置最小值1秒
3: task end handler task. (任務結束回調)
public interface FinishHandler { void finish(); }
......後面有待擴展
四:WisdomProgressHUD 使用分類
1: 在 "OnCreate" 中的調用:
說明: 爲了解決 android 機制不允許在 "OnCreate" 方法中向屏幕中添加UI問題,所以 "OnCreate"需要用到HUD,請調用 "startOnCreate" 方法。
2: 普通使用:
說明: 不在 "OnCreate" 中使用 "start" 方法。
3: 延遲使用:
說明:在當前時間延遲使用功能,調用 "after" 方法。
五:WisdomProgressHUD 具體API,參數
/** ---- 1: start show -----
* showState: task type, defoult value 'Default'. (任務類型)
* context : 'Context' value.
* text: show textView title value. (文字) */
public static void start(int showState, Context context, String text){ }
/** ----2: start show with 'WisdomProgressHUD.FinishHandler'-----
* showState: task type, defoult value 'Default'. (任務類型)
* context : 'Context' value.
* text: show textView title value. (文字)
* finishHandler: task end handler task. (任務結束回調) */
public static void start(int showState, Context context, String text, WisdomProgressHUD.FinishHandler finishHandler){ }
/** ---- 3: start show OnCreate -----
* Use the API when a prompt needs to be loaded in 'OnCreate'.(在 ‘OnCreate’ 中需要加載提示時使用API)
* showState: task type, defoult value 'Default'. (任務類型)
* context : 'Context'.
* text: show textView title value. (文字)
* ViewGroup: The 'Context' rootLayout. (Context的底層佈局) */
public static void startOnCreate(int showState, Context context, String text, ViewGroup rootView){ }
/** ---- 4:start show OnCreate with 'WisdomProgressHUD.FinishHandler' -----
* Use the API when a prompt needs to be loaded in 'OnCreate'.(在 ‘OnCreate’ 中需要加載提示時使用API)
* showState: task type, defoult value 'Default'. (任務類型)
* context : 'Context'.
* text: show textView title value. (文字)
* ViewGroup: The 'Context' rootLayout. (Context的底層佈局)
* finishHandler: task end handler task. (任務結束回調) */
public static void startOnCreate(int showState, Context context, String text, ViewGroup rootView, WisdomProgressHUD.FinishHandler finishHandler){ }
/** ----- 5: after task -----
* delay: after task time value. */
public static void after(final int showState, final Context context, final String text, long delay){ }
/** ----- 6: after task -----
* delay: after task time value. */
public static void after(final int showState, final Context context, final String text, final long delay, final WisdomProgressHUD.FinishHandler finishHandler){ }
/** 7: dismiss(手動釋放)*/
public static void dismiss() { }
六:WisdomScreenUtils: 提供屏幕尺寸轉換處理功能
/** 根據手機的分辨率從 dp 的單位 轉成爲 px(像素) */
public static int dip2px(Context context, float dpValue) { return (int) }
/** 根據手機的分辨率從 px(像素) 的單位 轉成爲 dp */
public static int px2dip(Context context, float pxValue) { return (int) }
/** 獲取屏幕密度 */
public static float getScreenDensity(Context context) { return float }
/** 獲取屏幕寬度(像素) */
public static int getScreenWidthPixels(Context context) { return int }
/** 獲取屏幕寬度(dp) */
public static float getScreenWidthDp(Context context) { return float }
/** 獲取屏幕高度(像素) */
public static int getScreenHeightPixels(Context context) { return int }
/** 獲取屏幕高度(dp) */
public static float getScreenHeightDp(Context context) { return float }
/** 獲取狀態欄高度 */
public static int getStatusHeight(Context context) { return int }
/** 保存屏幕截圖到本地
* @param activity
* @param strFileName 文件全路徑:例如 "/sdcard/screen_shot_20160424.jpg" */
public static void savScreenShot(Activity activity, String strFileName) { }
/** 截圖
* 也可以調用shell命令去截圖 screencap -p test.png
* @param activity 截取activity 所在的頁面的截圖,即使退到後臺也是截取這個activity */
private static Bitmap takeShot(Activity activity) { return Bitmap }
七: Android Studio SDK 集成:
1: build.gradle 配置 'https://jitpack.io' :
allprojects {
repositories { maven { url 'https://jitpack.io' } }
}
2: build.gradle 配置 'com.github.tangjianfengVS:WisdomProgressHUD:0.0.1' :
dependencies {
implementation 'com.github.tangjianfengVS:WisdomProgressHUD:0.0.1'
}
八:結語:
WisdomProgressHUD Android SDK,界面設計漂亮,並且是一款金典的HUD,並且支持屏蔽任務期間的用戶交互。
WisdomProgressHUD Android SDK,開發中使用方便,性能高效,自動管理生命週期,兼容'Oncreate'方法中調用,非常推薦給大家使用!
如有問題歡迎來信討論!