mListeners = new CopyOnWriteArrayList<>();
35 |
36 | @Override
37 | public void onReceive(Context context, Intent intent) {
38 | if (intent.getAction().equals(NET_CHANGED_ACTION)) {
39 | for (NetStateListener listener : mListeners) {
40 | listener.onNetChanged(LocalNetHelper.isConnected(context.getApplicationContext()));
41 | }
42 | }
43 | }
44 |
45 | static synchronized void addListener(NetStateListener listener) {
46 | if (mListeners.contains(listener)) {
47 | return;
48 | }
49 | mListeners.add(listener);
50 | }
51 |
52 | static synchronized void removeListener(NetStateListener listener) {
53 | mListeners.remove(listener);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/blur/src/main/java/com/dasu/blur/DBlur.java:
--------------------------------------------------------------------------------
1 | package com.dasu.blur;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.view.View;
7 |
8 | /**
9 | * Created by dasu on 2018/10/10.
10 | * 微信公众号:dasuAndroidTv
11 | * blog:https://www.jianshu.com/u/bb52a2918096
12 | *
13 | * 高斯模糊组件
14 | * 支持不同方式的高斯模糊,调用 #source() 后,根据 AndroidStudio 的代码提示查看后续支持的配置项,
15 | * 或者手动到 {@link BlurConfig} 查看即可
16 | *
17 | * 使用示例:
18 | *
19 | * DBlur.source(this, R.drawable.background).intoTarget(imageView).animAlpha().build().doBlur();
20 | *
21 | */
22 | public class DBlur {
23 |
24 | /**
25 | * 对传入的 Activity 的视图做模糊
26 | */
27 | public static BlurConfig.Builder source(Activity activity) {
28 | return new BlurConfig.Builder(activity);
29 | }
30 |
31 | /**
32 | * 对指定的 Bitmap 做高斯模糊
33 | */
34 | public static BlurConfig.Builder source(Context context, Bitmap bitmap) {
35 | return new BlurConfig.Builder(context, bitmap);
36 | }
37 |
38 | /**
39 | * 对指定的 View 的视图做高斯模糊
40 | */
41 | public static BlurConfig.Builder source(View view) {
42 | return new BlurConfig.Builder(view);
43 | }
44 |
45 | /**
46 | * 对本地 drawable 资源图片做高斯模糊
47 | */
48 | public static BlurConfig.Builder source(Context context, final int resId) {
49 | return new BlurConfig.Builder(context, resId);
50 | }
51 |
52 | /**
53 | * 如果有设置 {@link BlurConfig.Builder#cache(String)} 的配置的话,高斯模糊结束后会将 bitmap
54 | * 缓存到内存中,外部自行在需要时根据 key 值获取,但缓存容器不大,LRU 缓存。
55 | *
56 | * @param cacheKey bitmap的缓存key
57 | * @return bitmap 已被回收的话,返回 null
58 | */
59 | public static Bitmap getCacheBitmap(String cacheKey) {
60 | return BlurHelper.getCacheBitmap(cacheKey);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
22 |
23 |
28 |
29 |
34 |
35 |
40 |
41 |
46 |
47 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/dasu/utils/SpUtils.java:
--------------------------------------------------------------------------------
1 | package com.dasu.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * Created by dasu on 2018/5/5.
8 | * 微信公众号:dasuAndroidTv
9 | * blog:https://www.jianshu.com/u/bb52a2918096
10 | *
11 | */
12 |
13 | public class SpUtils {
14 | private SharedPreferences sp;
15 | private SharedPreferences.Editor editor;
16 |
17 | public SpUtils(Context context, String spName) {
18 | sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE);
19 | editor = sp.edit();
20 | editor.apply();
21 | }
22 |
23 | public void putString(String key, String value) {
24 | editor.putString(key, value).apply();
25 | }
26 |
27 | public String getString(String key, String defaultValue) {
28 | return sp.getString(key, defaultValue);
29 | }
30 |
31 | public void putInt(String key, int value) {
32 | editor.putInt(key, value).apply();
33 | }
34 |
35 | public int getInt(String key, int defaultValue) {
36 | return sp.getInt(key, defaultValue);
37 | }
38 |
39 | public void putLong(String key, long value) {
40 | editor.putLong(key, value).apply();
41 | }
42 |
43 | public long getLong(String key, long defaultValue) {
44 | return sp.getLong(key, defaultValue);
45 | }
46 |
47 | public void putFloat(String key, float value) {
48 | editor.putFloat(key, value).apply();
49 | }
50 |
51 | public float getFloat(String key, float defaultValue) {
52 | return sp.getFloat(key, defaultValue);
53 | }
54 |
55 | public void putBoolean(String key, boolean value) {
56 | editor.putBoolean(key, value).apply();
57 | }
58 |
59 | public boolean getBoolean(String key, boolean defaultValue) {
60 | return sp.getBoolean(key, defaultValue);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/database/src/main/java/com/dasu/database/DatabaseManager.java:
--------------------------------------------------------------------------------
1 | package com.dasu.database;
2 |
3 | import android.content.UriMatcher;
4 | import android.net.Uri;
5 |
6 | import java.util.LinkedHashMap;
7 |
8 | /**
9 | * Created by suxq on 2017/4/12.
10 | *
11 | * 数据库管理类,管理数据库名、版本号、数据库表、URI匹配等信息
12 | * 每次增删表都必须对该类进行同步维护
13 | */
14 |
15 | class DatabaseManager {
16 |
17 | static final String DB_NAME = "ganhuo.db";
18 |
19 | static final int DB_VERSION = 1;
20 |
21 | static final String AUTHORITY = "com.dasu.ganhuo.authority";
22 |
23 | private DatabaseManager() {}
24 |
25 | /**
26 | * 当前数据库版本对应的所有数据库表,只有添加到该集合里的表才会被创建
27 | */
28 | static LinkedHashMap sAllTables = new LinkedHashMap<>();
29 | static {
30 | // sAllTables.put(GanHuoTable.getInstance().getName(), GanHuoTable.getInstance());
31 | // sAllTables.put(PublishDateTable.getInstance().getName(), PublishDateTable.getInstance());
32 | }
33 |
34 | /**
35 | * 暴露给ContentProvider的表,只有在这里添加匹配规则的表,才能通过ContentProvider访问
36 | */
37 | static final int BLOG_TABLE = 1;
38 | static final int PUBLISH_DATE_TABLE = 2;
39 |
40 | static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
41 | static {
42 | // sUriMatcher.addURI(AUTHORITY, GanHuoTable.getInstance().getName(), BLOG_TABLE);
43 | // sUriMatcher.addURI(AUTHORITY, PublishDateTable.getInstance().getName(), PUBLISH_DATE_TABLE);
44 | }
45 |
46 | static String matchUri(Uri uri) {
47 | switch (sUriMatcher.match(uri)) {
48 | case BLOG_TABLE:
49 | // return GanHuoTable.getInstance().getName();
50 | case PUBLISH_DATE_TABLE:
51 | // return PublishDateTable.getInstance().getName();
52 | default:
53 | throw new IllegalArgumentException("Unknown URI " + uri);
54 | }
55 | }
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/tv/upload.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.bintray'
2 |
3 | version = libraryVersion
4 |
5 | if (project.hasProperty("android")) { // Android libraries
6 | task sourcesJar(type: Jar) {
7 | classifier = 'sources'
8 | from android.sourceSets.main.java.srcDirs
9 | }
10 |
11 | // task javadoc(type: Javadoc) {
12 | // source = android.sourceSets.main.java.srcDirs
13 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
14 | // }
15 | } else { // Java libraries
16 | task sourcesJar(type: Jar, dependsOn: classes) {
17 | classifier = 'sources'
18 | from sourceSets.main.allSource
19 | }
20 | }
21 |
22 | //task javadocJar(type: Jar, dependsOn: javadoc) {
23 | // classifier = 'javadoc'
24 | // from javadoc.destinationDir
25 | //}
26 |
27 | artifacts {
28 | // archives javadocJar
29 | archives sourcesJar
30 | }
31 |
32 | // Bintray
33 | Properties properties = new Properties()
34 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
35 |
36 | bintray {
37 | user = properties.getProperty("bintray.user")
38 | key = properties.getProperty("bintray.apikey")
39 | println user
40 | println key
41 |
42 | configurations = ['archives']
43 | pkg {
44 | repo = bintrayRepo
45 | name = bintrayName
46 | desc = libraryDescription
47 | websiteUrl = siteUrl
48 | vcsUrl = gitUrl
49 | licenses = allLicenses
50 | publish = true
51 | publicDownloadNumbers = true
52 | version {
53 | desc = libraryDescription
54 | gpg {
55 | sign = true //Determines whether to GPG sign the files. The default is false
56 | passphrase = properties.getProperty("bintray.gpg.password")
57 | //Optional. The passphrase for GPG signing'
58 | }
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/update/src/main/java/com/dasu/update/UpdateConfig.java:
--------------------------------------------------------------------------------
1 | package com.dasu.update;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * 升级组件的配置项
7 | * Created by suxq on 2018/7/6.
8 | */
9 |
10 | public abstract class UpdateConfig {
11 |
12 | static boolean isDebugLogEnable = false;
13 | boolean isAutoDownload = false;
14 | String mApkUrl;
15 | String mApkFilePath;
16 | Object mNewVersionInfo;
17 |
18 | /**
19 | * 返回 true,组件内部会去触发 apk 下载
20 | * @param context
21 | * @return
22 | */
23 | public abstract boolean checkVersion(Context context);
24 |
25 | /**
26 | * 设置是否打印debug日志
27 | * @param debugLogEnable
28 | * @return
29 | */
30 | public UpdateConfig setDebugLogEnable(boolean debugLogEnable) {
31 | isDebugLogEnable = debugLogEnable;
32 | return this;
33 | }
34 |
35 | /**
36 | * 设置 {@link UpdateController#checkUpdate(Context, UpdateConfig, OnUpdateListener)}
37 | * 之后是否自动去下载 apk
38 | * @param autoDownload
39 | * @return
40 | */
41 | public UpdateConfig setAutoDownload(boolean autoDownload) {
42 | isAutoDownload = autoDownload;
43 | return this;
44 | }
45 |
46 | /**
47 | * 设置 apk 下载的 url
48 | * @param apkUrl
49 | * @return
50 | */
51 | public UpdateConfig setApkUrl(String apkUrl) {
52 | mApkUrl = apkUrl;
53 | return this;
54 | }
55 |
56 | /**
57 | * 设置 apk 下载到本地的路径
58 | * @param apkFilePath
59 | * @return
60 | */
61 | public UpdateConfig setApkFilePath(String apkFilePath) {
62 | mApkFilePath = apkFilePath;
63 | return this;
64 | }
65 |
66 | /**
67 | * 设置版本信息,用于 {@link OnUpdateListener#onPreUpdate(Object)} 通知给 Ui 的新版本信息
68 | * @param newVersionInfo
69 | * @return
70 | */
71 | public UpdateConfig setNewVersionInfo(Object newVersionInfo) {
72 | mNewVersionInfo = newVersionInfo;
73 | return this;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/log/src/main/java/com/dasu/log/LogcatUtils.java:
--------------------------------------------------------------------------------
1 | package com.dasu.log;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by suxq on 2018/9/11.
7 | *
8 | * Logcat工具类,执行shell命令:logcat -v time 采集日志
9 | * 因为涉及到磁盘读写文件,因此使用前需先初始化并且手动开启该功能(默认关闭)
10 | *
11 | * 用法示例:
12 | *
13 | * LogUtils.init(context).setLogcatEnable(true);
14 | *
15 | * LogcatUtils.start();//开始采集
16 | *
17 | *
18 | * 内部具体实现逻辑在{@link LogcatHelper}
19 | */
20 | public final class LogcatUtils {
21 |
22 | private static LogcatHelper sLogcatHelper = new LogcatHelper();
23 |
24 | private LogcatUtils() {
25 | throw new UnsupportedOperationException("u can't instance it");
26 | }
27 |
28 | static {
29 | LogConfig.checkInit();
30 | }
31 |
32 | /**
33 | * 开始执行 logcat 命令,采集日志,功能默认关闭,如果要启用,需要在{@link LogConfig#setLogcatEnable(boolean)}开启该功能,否则即使调用了该方法也无效
34 | */
35 | public static void start() {
36 | sLogcatHelper.start();
37 | }
38 |
39 | /**
40 | * 停止采集
41 | */
42 | public static void stop() {
43 | sLogcatHelper.stop();
44 | }
45 |
46 | /**
47 | * kill掉logcat进程
48 | */
49 | public static void cleanup() {
50 | sLogcatHelper.cleanup();
51 | }
52 |
53 | /**
54 | * 将 log4j 生成的多份备份文件合并在一份中
55 | * @param context
56 | * @param dirPath 存放log4j文件的目录
57 | * @param fileName log4j生成的日志文件名
58 | * @return
59 | */
60 | public static String mergeLog4jFiles(Context context, String dirPath, String fileName) {
61 | return sLogcatHelper.mergeLog4jFiles(context, dirPath, fileName);
62 | }
63 |
64 | /**
65 | * 获取 logcat 通过 log4j 缓存到本地的文件名
66 | * @return
67 | */
68 | public static String getLog4jFileName() {
69 | return sLogcatHelper.sLogcatFile;
70 | }
71 |
72 | static void initLog4j() {
73 | sLogcatHelper.initLog4j();
74 | }
75 |
76 | static void updateLog4jConfig() {
77 | sLogcatHelper.updateLog4jConfig();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/volley/src/main/java/com/dasu/volley/wrapper/VolleyQueueSingleton.java:
--------------------------------------------------------------------------------
1 | package com.dasu.volley.wrapper;
2 |
3 | import com.android.volley.ExecutorDelivery;
4 | import com.android.volley.Request;
5 | import com.android.volley.RequestQueue;
6 | import com.android.volley.toolbox.BasicNetwork;
7 | import com.android.volley.toolbox.HurlStack;
8 | import com.android.volley.toolbox.NoCache;
9 |
10 | import java.util.concurrent.ExecutorService;
11 | import java.util.concurrent.Executors;
12 |
13 | class VolleyQueueSingleton {
14 | /**
15 | * Number of network request dispatcher threads to start.
16 | */
17 | private static final int DEFAULT_NETWORK_THREAD_POOL_SIZE = 6;
18 | private RequestQueue mRequestQueue;
19 | private volatile static VolleyQueueSingleton sInstance;
20 | private ExecutorService executorService = Executors.newCachedThreadPool();
21 |
22 | public static VolleyQueueSingleton getInstance() {
23 | if (sInstance == null) {
24 | synchronized (VolleyQueueSingleton.class) {
25 | if (sInstance == null) {
26 | sInstance = new VolleyQueueSingleton();
27 | }
28 | }
29 | }
30 | return sInstance;
31 | }
32 |
33 | private VolleyQueueSingleton() {
34 | // HttpsTrustManager.allowAllSSL();
35 | HurlStack stack = new SelfSignSslHurlStack();
36 | mRequestQueue = newAsyncRequestQueue(stack);
37 | }
38 |
39 | private RequestQueue newAsyncRequestQueue(HurlStack stack) {
40 | BasicNetwork network = new BasicNetwork(stack);
41 | //修改Volley的请求队列,构键新的线程池
42 | RequestQueue queue1 = new RequestQueue(new NoCache(), network, DEFAULT_NETWORK_THREAD_POOL_SIZE,
43 | new ExecutorDelivery(executorService));
44 | queue1.start();
45 | return queue1;
46 | }
47 |
48 | public void add(Request> request) {
49 | mRequestQueue.add(request);
50 | }
51 |
52 | public void cancelAll(Object tag) {
53 | mRequestQueue.cancelAll(tag);
54 | }
55 | }
--------------------------------------------------------------------------------
/upload.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.bintray'
2 |
3 | //使用步骤:
4 | //1. cd XXX, eg: cd utils
5 | //2. ..\gradlew install
6 | //3. ..\gradlew bintrayUpload
7 |
8 | version = libraryVersion
9 |
10 | if (project.hasProperty("android")) { // Android libraries
11 | task sourcesJar(type: Jar) {
12 | classifier = 'sources'
13 | from android.sourceSets.main.java.srcDirs
14 | }
15 |
16 | // task javadoc(type: Javadoc) {
17 | // source = android.sourceSets.main.java.srcDirs
18 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
19 | // }
20 | } else { // Java libraries
21 | task sourcesJar(type: Jar, dependsOn: classes) {
22 | classifier = 'sources'
23 | from sourceSets.main.allSource
24 | }
25 | }
26 |
27 | //task javadocJar(type: Jar, dependsOn: javadoc) {
28 | // classifier = 'javadoc'
29 | // from javadoc.destinationDir
30 | //}
31 |
32 | artifacts {
33 | // archives javadocJar
34 | archives sourcesJar
35 | }
36 |
37 | // Bintray
38 | Properties properties = new Properties()
39 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
40 |
41 | bintray {
42 | user = properties.getProperty("bintray.user")
43 | key = properties.getProperty("bintray.apikey")
44 | println user
45 | println key
46 |
47 | configurations = ['archives']
48 | pkg {
49 | repo = bintrayRepo
50 | name = bintrayName
51 | desc = libraryDescription
52 | websiteUrl = siteUrl
53 | vcsUrl = gitUrl
54 | licenses = allLicenses
55 | publish = true
56 | publicDownloadNumbers = true
57 | version {
58 | desc = libraryDescription
59 | gpg {
60 | sign = true //Determines whether to GPG sign the files. The default is false
61 | passphrase = properties.getProperty("bintray.gpg.password")
62 | //Optional. The passphrase for GPG signing'
63 | }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/fresco/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\softwares\Android\SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
27 |
28 | ###################### Fresco 混淆配置 ########################
29 |
30 | # Keep our interfaces so they can be used by other ProGuard rules.
31 | # See http://sourceforge.net/p/proguard/bugs/466/
32 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
33 | -keep,allowobfuscation @interface com.facebook.soloader.DoNotOptimize
34 |
35 | # Do not strip any method/class that is annotated with @DoNotStrip
36 | -keep @com.facebook.common.internal.DoNotStrip class *
37 | -keepclassmembers class * {
38 | @com.facebook.common.internal.DoNotStrip *;
39 | }
40 |
41 | # Do not strip any method/class that is annotated with @DoNotOptimize
42 | -keep @com.facebook.soloader.DoNotOptimize class *
43 | -keepclassmembers class * {
44 | @com.facebook.soloader.DoNotOptimize *;
45 | }
46 |
47 | # Keep native methods
48 | -keepclassmembers class * {
49 | native ;
50 | }
51 |
52 | -dontwarn okio.**
53 | -dontwarn com.squareup.okhttp.**
54 | -dontwarn okhttp3.**
55 | -dontwarn javax.annotation.**
56 | -dontwarn com.android.volley.toolbox.**
57 | -dontwarn com.facebook.infer.**
--------------------------------------------------------------------------------
/volley/src/main/java/com/dasu/volley/wrapper/ImageFileRequest.java:
--------------------------------------------------------------------------------
1 | package com.dasu.volley.wrapper;
2 |
3 | import com.android.volley.NetworkResponse;
4 | import com.android.volley.ParseError;
5 | import com.android.volley.Request;
6 | import com.android.volley.Response;
7 | import com.android.volley.toolbox.HttpHeaderParser;
8 | import com.dasu.volley.VolleyListener;
9 |
10 | import java.io.File;
11 | import java.io.FileNotFoundException;
12 | import java.io.FileOutputStream;
13 | import java.io.IOException;
14 |
15 | /**
16 | * Created by dasu on 2018/10/22.
17 | * 微信公众号:dasuAndroidTv
18 | * blog:https://www.jianshu.com/u/bb52a2918096
19 | */
20 | public class ImageFileRequest extends Request{
21 | private String mFilePath;
22 | private VolleyListener mVolleyListener;
23 |
24 | public ImageFileRequest(String url) {
25 | super(url, null);
26 | }
27 |
28 | public void setFilePath(String filePath) {
29 | mFilePath = filePath;
30 | }
31 |
32 | public void download(VolleyListener extends String> listener) {
33 | mVolleyListener = listener;
34 | VolleyQueueSingleton.getInstance().add(this);
35 | }
36 |
37 | @Override
38 | protected Response parseNetworkResponse(NetworkResponse response) {
39 | boolean result = true;
40 | byte[] data = response.data;
41 | File file = new File(mFilePath);
42 | if (file.exists()) {
43 | file.delete();
44 | }
45 | try {
46 | FileOutputStream fos = new FileOutputStream(file);
47 | fos.write(data);
48 | } catch (FileNotFoundException e) {
49 | e.printStackTrace();
50 | result = false;
51 | } catch (IOException e) {
52 | e.printStackTrace();
53 | result = false;
54 | }
55 |
56 | if (!result) {
57 | return Response.error(new ParseError(response));
58 | } else {
59 | return Response.success(mFilePath, HttpHeaderParser.parseCacheHeaders(response));
60 | }
61 | }
62 |
63 | @Override
64 | protected void deliverResponse(Object response) {
65 | if (mVolleyListener != null) {
66 | mVolleyListener.onSuccess(mFilePath);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/fresco/src/main/java/com/dasu/fresco/DFresco.java:
--------------------------------------------------------------------------------
1 | package com.dasu.fresco;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 |
6 | import com.facebook.imagepipeline.core.ImagePipelineConfig;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Created by dasu on 2018/10/19.
12 | * 微信公众号:dasuAndroidTv
13 | * blog:https://www.jianshu.com/u/bb52a2918096
14 | *
15 | * DFresco 组件访问入口
16 | *
17 | * adb shell setprop log.tag.DFresco VERBOSE 开启 fresco 内部日志
18 | */
19 | public final class DFresco {
20 | private static FrescoHelper sFrescoHelper = new FrescoHelper();
21 | private static boolean sIsInit = false;
22 |
23 | /**
24 | * 使用默认的初始化配置
25 | * @param context
26 | */
27 | public static void init(Context context) {
28 | sIsInit = true;
29 | init(context, null);
30 | }
31 |
32 | /**
33 | * 自定义初始化配置
34 | * @param context
35 | * @param config
36 | */
37 | public static void init(Context context, ImagePipelineConfig config) {
38 | sIsInit = true;
39 | sFrescoHelper.init(context, config);
40 | }
41 |
42 | /**
43 | * 加载 res 内的资源图片
44 | * @param context
45 | * @param resId
46 | * @return
47 | */
48 | public static FrescoController.LoadStep source(Context context, int resId) {
49 | checkInit();
50 | return new FrescoController.LoadStep(context, resId);
51 | }
52 |
53 | /**
54 | * 加载磁盘中的图片
55 | * @param localFile
56 | * @return
57 | */
58 | public static FrescoController.LoadStep source(File localFile) {
59 | checkInit();
60 | return new FrescoController.LoadStep(localFile);
61 | }
62 |
63 | /**
64 | * 加载网络中的图片
65 | * @param url
66 | * @return
67 | */
68 | public static FrescoController.DownloadStep source(String url) {
69 | checkInit();
70 | return new FrescoController.DownloadStep(url);
71 | }
72 |
73 | public static FrescoController.LoadStep source(Uri uri) {
74 | checkInit();
75 | return new FrescoController.LoadStep(uri);
76 | }
77 |
78 | private static void checkInit() {
79 | if (!sIsInit) {
80 | throw new UnsupportedOperationException("before use fresco, u should call DFrsco.init().");
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dasu/basemodule/wams/HomeArticlesResEntity.java:
--------------------------------------------------------------------------------
1 | package com.dasu.basemodule.wams;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | /**
8 | * Created by dasu on 2018/10/26.
9 | * 微信公众号:dasuAndroidTv
10 | * https://github.com/woshidasusu/DWanAndroid
11 | */
12 | public class HomeArticlesResEntity implements Serializable {
13 |
14 | private int curPage;
15 | private List datas;
16 | private int offset;
17 | private boolean over;
18 | private int pageCount;
19 | private int size;
20 | private int total;
21 |
22 | @Override
23 | public String toString() {
24 | return "HomeArticlesResEntity{" +
25 | "curPage=" + curPage +
26 | ", datas=" + datas +
27 | ", offset=" + offset +
28 | ", over=" + over +
29 | ", pageCount=" + pageCount +
30 | ", size=" + size +
31 | ", total=" + total +
32 | '}';
33 | }
34 |
35 | public int getCurPage() {
36 | return curPage;
37 | }
38 |
39 | public void setCurPage(int curPage) {
40 | this.curPage = curPage;
41 | }
42 |
43 | public List getDatas() {
44 | if (datas == null) {
45 | return new ArrayList<>();
46 | }
47 | return datas;
48 | }
49 |
50 | public void setDatas(List datas) {
51 | this.datas = datas;
52 | }
53 |
54 | public int getOffset() {
55 | return offset;
56 | }
57 |
58 | public void setOffset(int offset) {
59 | this.offset = offset;
60 | }
61 |
62 | public boolean isOver() {
63 | return over;
64 | }
65 |
66 | public void setOver(boolean over) {
67 | this.over = over;
68 | }
69 |
70 | public int getPageCount() {
71 | return pageCount;
72 | }
73 |
74 | public void setPageCount(int pageCount) {
75 | this.pageCount = pageCount;
76 | }
77 |
78 | public int getSize() {
79 | return size;
80 | }
81 |
82 | public void setSize(int size) {
83 | this.size = size;
84 | }
85 |
86 | public int getTotal() {
87 | return total;
88 | }
89 |
90 | public void setTotal(int total) {
91 | this.total = total;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/volley/src/main/java/com/dasu/volley/wrapper/HttpsTrustManager.java:
--------------------------------------------------------------------------------
1 | package com.dasu.volley.wrapper;
2 |
3 | import java.security.KeyManagementException;
4 | import java.security.NoSuchAlgorithmException;
5 | import java.security.SecureRandom;
6 | import java.security.cert.X509Certificate;
7 |
8 | import javax.net.ssl.HostnameVerifier;
9 | import javax.net.ssl.HttpsURLConnection;
10 | import javax.net.ssl.SSLContext;
11 | import javax.net.ssl.SSLSession;
12 | import javax.net.ssl.TrustManager;
13 | import javax.net.ssl.X509TrustManager;
14 |
15 | /**
16 | * Created by dasu on 2018/10/22.
17 | * 微信公众号:dasuAndroidTv
18 | * blog:https://www.jianshu.com/u/bb52a2918096
19 | */
20 | class HttpsTrustManager implements X509TrustManager {
21 | private static TrustManager[] trustManagers;
22 | private static final X509Certificate[] _AcceptedIssuers = new X509Certificate[] {};
23 |
24 | @Override
25 | public void checkClientTrusted(
26 | java.security.cert.X509Certificate[] x509Certificates, String s)
27 | throws java.security.cert.CertificateException {
28 | // To change body of implemented methods use File | Settings | File
29 | // Templates.
30 | }
31 |
32 | @Override
33 | public void checkServerTrusted(
34 | java.security.cert.X509Certificate[] x509Certificates, String s)
35 | throws java.security.cert.CertificateException {
36 | // To change body of implemented methods use File | Settings | File
37 | // Templates.
38 | }
39 |
40 | @Override
41 | public X509Certificate[] getAcceptedIssuers() {
42 | return _AcceptedIssuers;
43 | }
44 |
45 | public static void allowAllSSL() {
46 | HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
47 |
48 | @Override
49 | public boolean verify(String arg0, SSLSession arg1) {
50 | return true;
51 | }
52 |
53 | });
54 |
55 | SSLContext context = null;
56 | if (trustManagers == null) {
57 | trustManagers = new TrustManager[] { new HttpsTrustManager() };
58 | }
59 |
60 | try {
61 | context = SSLContext.getInstance("TLS");
62 | context.init(null, trustManagers, new SecureRandom());
63 | } catch (NoSuchAlgorithmException e) {
64 | e.printStackTrace();
65 | } catch (KeyManagementException e) {
66 | e.printStackTrace();
67 | }
68 | HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------