老司機帶你重構Android的v4包的部分源碼

版權聲明:本文為博主原創文章,未經博主允許不得轉載。https://www.jianshu.com/p/a08d754944c4

轉載請標明出處:
https://www.jianshu.com/p/a08d754944c4
本文出自 AWeiLoveAndroid的博客


【前言】過年回家忙著干活,忙著給親戚的孩子發紅包,好累,忙里偷閑打開studio看了一下v4包,之前看過幾個類,這次是每個類都看了一下,原來Android的v4包的源碼也有一些是寫的不是那么友好的,還有很多改善空間。

下面就拿其中的android.support.v4.text這個包里面的 TextUtilsCompatTextUtilsCompatJellybeanMr1 這兩個類來做一個具體講解。

本文源碼同步發布在github,詳情請點擊 https://github.com/AweiLoveAndroid/refactor-android-support-v4

一、首先看一下Androidv4包下面的 TextUtilsCompatTextUtilsCompatJellybeanMr1 源碼:

(一)TextUtilsCompat 源碼:
public final class TextUtilsCompat {private static class TextUtilsCompatImpl {TextUtilsCompatImpl() {}@NonNullpublic String htmlEncode(@NonNull String s) {StringBuilder sb = new StringBuilder();char c;for (int i = 0; i < s.length(); i++) {c = s.charAt(i);switch (c) {case '<':sb.append("&lt;"); //$NON-NLS-1$break;case '>':sb.append("&gt;"); //$NON-NLS-1$break;case '&':sb.append("&amp;"); //$NON-NLS-1$break;case '\''://http://www.w3.org/TR/xhtml1// The named character reference &apos; (the apostrophe, U+0027) was// introduced in XML 1.0 but does not appear in HTML. Authors should// therefore use &#39; instead of &apos; to work as expected in HTML 4// user agents.sb.append("&#39;"); //$NON-NLS-1$break;case '"':sb.append("&quot;"); //$NON-NLS-1$break;default:sb.append(c);}}return sb.toString();}public int getLayoutDirectionFromLocale(@Nullable Locale locale) {if (locale != null && !locale.equals(ROOT)) {final String scriptSubtag = ICUCompat.maximizeAndGetScript(locale);if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);// This is intentionally limited to Arabic and Hebrew scripts, since older// versions of Android platform only considered those scripts to be right-to-left.if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {return ViewCompat.LAYOUT_DIRECTION_RTL;}}return ViewCompat.LAYOUT_DIRECTION_LTR;}/*** Fallback algorithm to detect the locale direction. Rely on the first char of the* localized locale name. This will not work if the localized locale name is in English* (this is the case for ICU 4.4 and "Urdu" script)** @param locale* @return the layout direction. This may be one of:* {@link ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/private static int getLayoutDirectionFromFirstChar(@NonNull Locale locale) {switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {case Character.DIRECTIONALITY_RIGHT_TO_LEFT:case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:return ViewCompat.LAYOUT_DIRECTION_RTL;case Character.DIRECTIONALITY_LEFT_TO_RIGHT:default:return ViewCompat.LAYOUT_DIRECTION_LTR;}}}private static class TextUtilsCompatJellybeanMr1Impl extends TextUtilsCompatImpl {TextUtilsCompatJellybeanMr1Impl() {}@Override@NonNullpublic String htmlEncode(@NonNull String s) {return TextUtilsCompatJellybeanMr1.htmlEncode(s);}@Overridepublic int getLayoutDirectionFromLocale(@Nullable Locale locale) {return TextUtilsCompatJellybeanMr1.getLayoutDirectionFromLocale(locale);}}private static final TextUtilsCompatImpl IMPL;static {final int version = Build.VERSION.SDK_INT;if (version >= 17) { // JellyBean MR1IMPL = new TextUtilsCompatJellybeanMr1Impl();} else {IMPL = new TextUtilsCompatImpl();}}/*** Html-encode the string.* @param s the string to be encoded* @return the encoded string*/@NonNullpublic static String htmlEncode(@NonNull String s) {return IMPL.htmlEncode(s);}/*** Return the layout direction for a given Locale** @param locale the Locale for which we want the layout direction. Can be null.* @return the layout direction. This may be one of:* {@link ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/public static int getLayoutDirectionFromLocale(@Nullable Locale locale) {return IMPL.getLayoutDirectionFromLocale(locale);}public static final Locale ROOT = new Locale("", "");static String ARAB_SCRIPT_SUBTAG = "Arab";static String HEBR_SCRIPT_SUBTAG = "Hebr";private TextUtilsCompat() {}
}
(二)TextUtilsCompatJellybeanMr1 源碼:
/*** Jellybean MR1 - specific TextUtils API access.*/
@RequiresApi(17)
@TargetApi(17)
class TextUtilsCompatJellybeanMr1 {@NonNullpublic static String htmlEncode(@NonNull String s) {return TextUtils.htmlEncode(s);}public static int getLayoutDirectionFromLocale(@Nullable Locale locale) {return TextUtils.getLayoutDirectionFromLocale(locale);}
}

二、分析一下以上源碼的一些需要改進的問題(僅個人理解,如有不同意見,歡迎提出):

通過以上源碼來看,看起來確實有點不是很舒服。

(一)排列順序有點亂,我格式化了一下,如下,看的稍微清楚了一些:
/*** 格式化之后的TextUtilsCompat類*/
public class TextUtilsCompat {private static final TextUtilsCompatImpl IMPL;public static final Locale ROOT = new Locale("", "");static String ARAB_SCRIPT_SUBTAG = "Arab";static String HEBR_SCRIPT_SUBTAG = "Hebr";private TextUtilsCompat() {}static {final int version = Build.VERSION.SDK_INT;if (version >= 17) { // JellyBean MR1IMPL = new TextUtilsCompatJellybeanMr1Impl();} else {IMPL = new TextUtilsCompatImpl();}}/*** Html-encode the string.* @param s the string to be encoded* @return the encoded string*/@NonNullpublic static String htmlEncode(@NonNull String s) {return IMPL.htmlEncode(s);}/*** Return the layout direction for a given Locale** @param locale the Locale for which we want the layout direction. Can be null.* @return the layout direction. This may be one of:* {@link ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/public static int getLayoutDirectionFromLocale(@Nullable Locale locale) {return IMPL.getLayoutDirectionFromLocale(locale);}private static class TextUtilsCompatImpl {TextUtilsCompatImpl() {}@NonNullpublic String htmlEncode(@NonNull String s) {StringBuilder sb = new StringBuilder();char c;for (int i = 0; i < s.length(); i++) {c = s.charAt(i);switch (c) {case '<':sb.append("&lt;"); //$NON-NLS-1$break;case '>':sb.append("&gt;"); //$NON-NLS-1$break;case '&':sb.append("&amp;"); //$NON-NLS-1$break;case '\''://http://www.w3.org/TR/xhtml1// The named character reference &apos; (the apostrophe, U+0027) was// introduced in XML 1.0 but does not appear in HTML. Authors should// therefore use &#39; instead of &apos; to work as expected in HTML 4// user agents.sb.append("&#39;"); //$NON-NLS-1$break;case '"':sb.append("&quot;"); //$NON-NLS-1$break;default:sb.append(c);}}return sb.toString();}public int getLayoutDirectionFromLocale(@Nullable Locale locale) {if (locale != null && !locale.equals(ROOT)) {final String scriptSubtag = ICUCompat.maximizeAndGetScript(locale);if (scriptSubtag == null) {return getLayoutDirectionFromFirstChar(locale);}// This is intentionally limited to Arabic and Hebrew scripts, since older// versions of Android platform only considered those scripts to be right-to-left.if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {return ViewCompat.LAYOUT_DIRECTION_RTL;}}return ViewCompat.LAYOUT_DIRECTION_LTR;}/*** Fallback algorithm to detect the locale direction. Rely on the first char of the* localized locale name. This will not work if the localized locale name is in English* (this is the case for ICU 4.4 and "Urdu" script)** @param locale* @return the layout direction. This may be one of:* {@link ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/private static int getLayoutDirectionFromFirstChar(@NonNull Locale locale) {switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {case Character.DIRECTIONALITY_RIGHT_TO_LEFT:case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:return ViewCompat.LAYOUT_DIRECTION_RTL;case Character.DIRECTIONALITY_LEFT_TO_RIGHT:default:return ViewCompat.LAYOUT_DIRECTION_LTR;}}}private static class TextUtilsCompatJellybeanMr1Impl extends TextUtilsCompatImpl {TextUtilsCompatJellybeanMr1Impl() {}@Override@NonNullpublic String htmlEncode(@NonNull String s) {return TextUtilsCompatJellybeanMr1.htmlEncode(s);}@Overridepublic int getLayoutDirectionFromLocale(@Nullable Locale locale) {return TextUtilsCompatJellybeanMr1.getLayoutDirectionFromLocale(locale);}}}
(二)TextUtilsCompat 這個類里面有兩個內部類,一個是TextUtilsCompatImpl,一個是TextUtilsCompatJellybeanMr1Impl,TextUtilsCompatJellybeanMr1Impl是繼承自TextUtilsCompatImpl的。
(三)從靜態代碼塊看出,api 大于17 使用 new TextUtilsCompatJellybeanMr1Impl(); api小于17 使用TextUtilsCompatImpl。TextUtilsCompat,TextUtilsCompatImpl和TextUtilsCompatJellybeanMr1Impl里面都有 htmlEncode 方法和 getLayoutDirectionFromLocale 方法。

靜態代碼塊里面通過TextUtilsCompatImpl IMPL這個常量來判斷,當api大于17用TextUtilsCompatJellybeanMr1Impl,否則用TextUtilsCompatImpl,然后htmlEncode方法調用了對應內部類里面的htmlEncode方法,getLayoutDirectionFromLocale調用了對應內部類里面的getLayoutDirectionFromLocale方法。

(四)TextUtilsCompatImpl和TextUtilsCompatJellybeanMr1Impl里面都有 htmlEncode 方法和 getLayoutDirectionFromLocale 方法,看看它們的區別。

(1)TextUtilsCompatJellybeanMr1Impl這個內部類的方法解析:

  • htmlEncode(@NonNull String s) 方法 返回的是:
TextUtilsCompatJellybeanMr1.htmlEncode(s); ==> 調用了TextUtils.htmlEncode(s);
  • getLayoutDirectionFromLocale(@Nullable Locale locale) 方法返回的是:
TextUtilsCompatJellybeanMr1.getLayoutDirectionFromLocale(locale); ==> 調用了TextUtils.getLayoutDirectionFromLocale(locale);

(2)TextUtilsCompatImpl這個內部類的方法解析:

  • htmlEncode(@NonNull String s) 方法 返回的是:
在這個方法內部寫了一遍,跟TextUtils.htmlEncode(s);方法里面的一模一樣。
  • getLayoutDirectionFromLocale(@Nullable Locale locale) 方法返回的是:
重新寫了一遍,這個方法是真正有所區別的地方。

三、根據我做過項目用到的MVP的開發模式,我把共同的htmlEncode方法和getLayoutDirectionFromLocale方法抽取出一個接口,然后分別用兩個實現類去實現接口,然后用TextUtilsCompat這個類去判斷調用哪個實現類的方法,這樣看起來更直觀一些。具體步驟如下:

(一)抽取公共接口ITextUtilsCompat
/*** 抽取公用的接口*/
public interface ITextUtilsCompat {/*** Html-encode the string.* @param s the string to be encoded* @return the encoded string*/public String htmlEncode(@NonNull String s);/*** Return the layout direction for a given Locale** @param locale the Locale for which we want the layout direction. Can be null.* @return the layout direction. This may be one of:* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/public int getLayoutDirectionFromLocale(@Nullable Locale locale);
}
(二)寫一個TextUtilsCompatJellybeanMr1實現ITextUtilsCompat 接口,然后把之前TextUtilsCompatJellybeanMr1類里面的復制過來,具體如下:
/*** 兼容Android 17+ 版本* Jellybean MR1 - specific TextUtils API access.*/
@RequiresApi(17)
@TargetApi(17)
class TextUtilsCompatJellybeanMr1 implements ITextUtilsCompat{@Override@NonNullpublic String htmlEncode(@NonNull String s) {return TextUtils.htmlEncode(s);}@Overridepublic int getLayoutDirectionFromLocale(@Nullable Locale locale) {return TextUtils.getLayoutDirectionFromLocale(locale);}
}
(三)寫一個類TextUtilsCompatImpl實現ITextUtilsCompat 接口,然后把之前TextUtilsCompat類里面的有關代碼復制過來,具體如下:
/*** Android 17以下版本使用這個類*/
class TextUtilsCompatImpl implements ITextUtilsCompat{public static final Locale ROOT = new Locale("", "");static String ARAB_SCRIPT_SUBTAG = "Arab";static String HEBR_SCRIPT_SUBTAG = "Hebr";@Override@NonNullpublic String htmlEncode(@NonNull String s) {StringBuilder sb = new StringBuilder();char c;for (int i = 0; i < s.length(); i++) {c = s.charAt(i);switch (c) {case '<':sb.append("&lt;"); //$NON-NLS-1$break;case '>':sb.append("&gt;"); //$NON-NLS-1$break;case '&':sb.append("&amp;"); //$NON-NLS-1$break;case '\''://http://www.w3.org/TR/xhtml1// The named character reference &apos; (the apostrophe, U+0027) was// introduced in XML 1.0 but does not appear in HTML. Authors should// therefore use &#39; instead of &apos; to work as expected in HTML 4// user agents.sb.append("&#39;"); //$NON-NLS-1$break;case '"':sb.append("&quot;"); //$NON-NLS-1$break;default:sb.append(c);}}return sb.toString();}@Overridepublic int getLayoutDirectionFromLocale(@Nullable Locale locale) {if (locale != null && !locale.equals(ROOT)) {final String scriptSubtag = ICUCompat.maximizeAndGetScript(locale);if (scriptSubtag == null) {return getLayoutDirectionFromFirstChar(locale);}// This is intentionally limited to Arabic and Hebrew scripts, since older// versions of Android platform only considered those scripts to be right-to-left.if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {return ViewCompat.LAYOUT_DIRECTION_RTL;}}return ViewCompat.LAYOUT_DIRECTION_LTR;}/*** Fallback algorithm to detect the locale direction. Rely on the first char of the* localized locale name. This will not work if the localized locale name is in English* (this is the case for ICU 4.4 and "Urdu" script)** @param locale* @return the layout direction. This may be one of:* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/private static int getLayoutDirectionFromFirstChar(@NonNull Locale locale) {switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {case Character.DIRECTIONALITY_RIGHT_TO_LEFT:case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:return ViewCompat.LAYOUT_DIRECTION_RTL;case Character.DIRECTIONALITY_LEFT_TO_RIGHT:default:return ViewCompat.LAYOUT_DIRECTION_LTR;}}
}
(四)封裝TextUtilsCompat給調用者使用,具體如下:
/*** v4包下面的TextUtilsCompat的簡單優化* 這里使用的是策略模式,根據不同api版本調用不同的接口實現類* 這樣寫更好維護。*/
public final class TextUtilsCompat {private static final ITextUtilsCompat IMPL;private TextUtilsCompat() {}static {final int version = Build.VERSION.SDK_INT;// JellyBean MR1 大于等于17if (version >= Build.VERSION_CODES.JELLY_BEAN_MR1) {IMPL = new TextUtilsCompatJellybeanMr1();} else {IMPL = new TextUtilsCompatImpl();}}/*** Html-encode the string.* @param s the string to be encoded* @return the encoded string*/@NonNullpublic static String htmlEncode(@NonNull String s) {return IMPL.htmlEncode(s);}/*** Return the layout direction for a given Locale** @param locale the Locale for which we want the layout direction. Can be null.* @return the layout direction. This may be one of:* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_LTR} or* {@link android.support.v4.view.ViewCompat#LAYOUT_DIRECTION_RTL}.** Be careful: this code will need to be updated when vertical scripts will be supported*/public static int getLayoutDirectionFromLocale(@Nullable Locale locale) {return IMPL.getLayoutDirectionFromLocale(locale);}}

到此,TextUtilsCompat 這個類就封裝完了。看完之后是不是很清爽?其實還有很多類似的類都可以根據類似的方式做一下改進的。源碼不是完美的,只要掌握以上示例代碼的思想還是很容易的讓代碼更好理解,更簡潔清晰的。

【好消息】我的微信公眾號正式開通了,關注一下吧!
關注一下我的公眾號吧

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/284098.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/284098.shtml
英文地址,請注明出處:http://en.pswp.cn/news/284098.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

.NET靜態代碼織入——肉夾饃(Rougamo) 發布1.1.0

肉夾饃是什么肉夾饃(https://github.com/inversionhourglass/Rougamo)通過靜態代碼織入方式實現AOP的組件。.NET常用的AOP有Castle DynamicProxy、AspectCore等&#xff0c;以上兩種AOP組件都是通過運行時生成一個代理類執行AOP代碼的&#xff0c;肉夾饃則是在代碼編譯時直接修…

Msys2 國內源(2017.3.30)

確定可用&#xff01; Server https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch轉載于:https://www.cnblogs.com/baud/p/6644887.html

基于 IdentityServer3 實現 OAuth 2.0 授權服務【密碼模式(Resource Owner Password Credentials)】...

密碼模式&#xff08;Resource Owner Password Credentials Grant&#xff09;中&#xff0c;用戶向客戶端提供自己的用戶名和密碼。客戶端使用這些信息&#xff0c;向"服務商提供商"索要授權。基于之前的 IdentityServer3 實現 OAuth 2.0 授權服務【客戶端模式(Clie…

【GlobalMapper精品教程】035:用CASS自帶數據創建高程地形、等高線教程

本文講述globalmapper用CASS自帶數據創建高程地形、等高線教程。 文章目錄 1. 坐標生成點2. 點轉高程格網3. 生成等高線4. 保存等高線CASS自帶等高線數據dgx.dat預覽:包含點號、編碼、東坐標、北坐標、高程5列,可以不用做任何修改,在Globalmapper中生成點。 1. 坐標生成點 …

SaaS產品的免費試用到底該怎么做

”SaaS產品的免費試用&#xff0c;絕不僅僅只是開放產品試用期這么簡單&#xff0c;很多企業并沒有重視免費試用模式的搭建和轉化路徑“ 很多SaaS廠商的產品都會提供免費試用的機會&#xff0c;雖然試用的最終目標是促成用戶為產品價值付費&#xff0c;但是很多SaaS廠商在開放系…

【.NET6+WPF】WPF使用prism框架+Unity IOC容器實現MVVM雙向綁定和依賴注入

前言&#xff1a;在C/S架構上&#xff0c;WPF無疑已經是“桌面一霸”了。在.NET生態環境中&#xff0c;很多小伙伴還在使用Winform開發C/S架構的桌面應用。但是WPF也有很多年的歷史了&#xff0c;并且基于MVVM的開發模式&#xff0c;受到了很多開發者的喜愛。并且隨著工業化的進…

sql 中 limit 與 limit,offset連用的區別

① select * from table limit 2,1; #跳過2條取出1條數據&#xff0c;limit后面是從第2條開始讀&#xff0c;讀取1條信息&#xff0c;即讀取第3條數據 ② select * from table limit 2 offset 1; #從第1條&#xff08;不包括&#xff09;數據開始取出2條…

【ArcGIS Pro微課1000例】0022:基于DEM進行流域分析生成流域圖

文章目錄 一、填洼二、流向分析三、計算流域一、填洼 填洼Fill,在進行水文分析后續操作前,首先要對DEM進行填洼,創建無凹陷點的DEM。 填洼需要使用水文分析工具下的【填洼】。 確定輸入與輸出即可。 填洼結果: 二、流向分析 在ArcGIS中使用的是八方向流量建模(D8算法),工…

Spring配置文件中bean標簽的scope屬性

轉自&#xff1a;https://fj-sh-chz.iteye.com/blog/1775149 singleton &#xff08;默認屬性&#xff09; Spring將Bean放入Spring IOC容器的緩存池中&#xff0c;并將Bean引用返回給調用者&#xff0c;spring IOC繼續對這些Bean進行后續的生命管理。BeanFactory只管理一個共…

[轉]Druid概述

目錄 1.Apache Druid簡介 2.Apache Druid架構 2.1 服務器類型 2.1.1 Master Server 2.1.2 Query 2.1.3 Data Server 2.2 外部依賴 2.2.1 Deep Storage 2.2.2 Metadata Storage 2.2.3 Zookeeper 2.3 存儲設計 3.在HDP上安裝Apache Druid 3.1 準備數據庫 3.2 安裝…

在 .NET MAUI 中如何更好地自定義控件

點擊上方藍字關注我們&#xff08;本文閱讀時間&#xff1a;10分鐘)今天&#xff0c;我想談談并向您展示在.NET MAUI中完全自定義控件的方法。在查看 .NET MAUI 之前&#xff0c;讓我們回到幾年前&#xff0c;回到 Xamarin.Forms 時代。那時&#xff0c;我們有很多自定義控件的…

【GlobalMapper精品教程】036:基于DEM的流域計算生成流域圖

Globalmapper基于DEM的流域計算生成流域圖教程。 文章目錄一、加載DEM二、流域分析一、加載DEM 加載配套實驗數據。 二、流域分析 GM中的流域分析工具位于分析→生成流域&#xff0c;如下所示&#xff1a; 參數設置如下&#xff1a; 流域計算結果&#xff1a;

html之file標簽 --- 圖片上傳前預覽 -- FileReader

記得以前做網站時&#xff0c;曾經需要實現一個圖片上傳到服務器前&#xff0c;先預覽的功能。當時用html的<input type"file"/>標簽一直實現不了&#xff0c;最后舍棄了這個標簽&#xff0c;使用了其他方式來實現了這個功能。 今天無意發現了一個知識點&#…

Android Studio3.0簡介

Android Studio 3.0.0 Android Studio 3.0.0 (2017年10月)是一個主要版本&#xff0c;包括各種新功能和改進 Android插件的Gradle 3.0.0 ? 支持Android 8.0 ? 支持Java 8庫和Java 8語言功能&#xff08;沒有Jack編譯器&#xff09; ? 支持Android測試支持庫1.0&#xff08;A…

嵌入式linux面試題解析(二)——C語言部分三

嵌入式linux面試題解析&#xff08;二&#xff09;——C語言部分三1、下面的程序會出現什么結果#include <stdio.h>#include <stdlib.h>#include <string.h>void getmemory(char *p){ p(char *) malloc(100); strcpy(p,”hello world”);}int main( ){…

什么是JavaBean、Bean? 什么是POJO、PO、DTO、VO、BO ? 什么是EJB、EntityBean?

前言&#xff1a; 在Java開發中經常遇到這些概念問題&#xff0c;有的可能理解混淆&#xff0c;有的可能理解不到位&#xff0c;特此花了很多時間理順了這些概念。不過有些概念實際開發中并沒有使用到&#xff0c;可能理解還不夠準確&#xff0c;只能靠后續不斷糾正了。 1、什么…

【GlobalMapper精品教程】037:構建泰森多邊形(Thiessen Polygon)實例精解

泰森多邊形是進行快速插值和分析地理實體影響區域的常用工具。例如,用離散點的性質描述多邊形區域的性質,用離散點的數據計算泰森多邊形區域的數據。泰森多邊形可用于定性分析、統計分析和臨近分析等。 文章目錄 一、泰森多邊形的概念二、泰森多邊形的特點三、泰森多邊形構建…

WPF 實現 Gitee 泡泡菜單「完」

WPF 實現 Gitee 泡泡菜單「完」氣泡菜單「完」作者&#xff1a;WPFDevelopersOrg原文鏈接&#xff1a; https://github.com/WPFDevelopersOrg/WPFDevelopers框架使用大于等于.NET40&#xff1b;Visual Studio 2022;項目使用 MIT 開源許可協議&#xff1b;需要實現泡泡菜單需…

BZOJ 4516: [Sdoi2016]生成魔咒 [后綴自動機]

4516: [Sdoi2016]生成魔咒 題意&#xff1a;詢問一個字符串每個前綴有多少不同的子串 做了一下SDOI2016R1D2&#xff0c;題好水啊隨便AK 強行開map上SAM 每個狀態的貢獻就是\(Max(s)-Min(s)1\) 插入的時候維護一下就行了 #include <iostream> #include <cstdio> #i…

Fiddler抓包5-接口測試(Composer)

前言 Fiddler最大的優勢在于抓包&#xff0c;我們大部分使用的功能也在抓包的功能上&#xff0c;fiddler做接口測試也是非常方便的。 對應沒有接口測試文檔的時候&#xff0c;可以直接抓完包后&#xff0c;copy請求參數&#xff0c;修改下就可以了。 一、Composer簡介 點開右側…