bindLifecycle(LifecycleOwner lifecycleOwner) {
12 | return AutoDispose.autoDisposable(
13 | AndroidLifecycleScopeProvider.from(lifecycleOwner)
14 | );
15 | }
16 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnViewDragListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | /**
4 | * Interface definition for a callback to be invoked when the photo is experiencing a drag event
5 | */
6 | public interface OnViewDragListener {
7 |
8 | /**
9 | * Callback for when the photo is experiencing a drag event. This cannot be invoked when the
10 | * user is scaling.
11 | *
12 | * @param dx The change of the coordinates in the x-direction
13 | * @param dy The change of the coordinates in the y-direction
14 | */
15 | void onDrag(float dx, float dy);
16 | }
17 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/BaseUrl.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import okhttp3.HttpUrl;
6 |
7 | /**
8 | * ================================================
9 | * 针对于 BaseUrl 在 App 启动时不能确定,需要请求服务器接口动态获取的应用场景
10 | *
11 | * Created by JessYan on 11/07/2017 14:58
12 | * ================================================
13 | */
14 | public interface BaseUrl {
15 | /**
16 | * 在调用 Retrofit API 接口之前,使用 Okhttp 或其他方式,请求到正确的 BaseUrl 并通过此方法返回
17 | *
18 | * @return
19 | */
20 | @NonNull
21 | HttpUrl url();
22 | }
23 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnScaleChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 |
4 | /**
5 | * Interface definition for callback to be invoked when attached ImageView scale changes
6 | */
7 | public interface OnScaleChangedListener {
8 |
9 | /**
10 | * Callback for when the scale changes
11 | *
12 | * @param scaleFactor the scale factor (less than 1 for zoom out, greater than 1 for zoom in)
13 | * @param focusX focal point X position
14 | * @param focusY focal point Y position
15 | */
16 | void onScaleChange(float scaleFactor, float focusX, float focusY);
17 | }
18 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnMatrixChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | import android.graphics.RectF;
4 |
5 | /**
6 | * Interface definition for a callback to be invoked when the internal Matrix has changed for
7 | * this View.
8 | */
9 | public interface OnMatrixChangedListener {
10 |
11 | /**
12 | * Callback for when the Matrix displaying the Drawable has changed. This could be because
13 | * the View's bounds have changed, or the user has zoomed.
14 | *
15 | * @param rect - Rectangle displaying the Drawable's new bounds.
16 | */
17 | void onMatrixChanged(RectF rect);
18 | }
19 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnViewTapListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | import android.view.View;
4 |
5 | public interface OnViewTapListener {
6 |
7 | /**
8 | * A callback to receive where the user taps on a ImageView. You will receive a callback if
9 | * the user taps anywhere on the view, tapping on 'whitespace' will not be ignored.
10 | *
11 | * @param view - View the user tapped.
12 | * @param x - where the user tapped from the left of the View.
13 | * @param y - where the user tapped from the top of the View.
14 | */
15 | void onViewTap(View view, float x, float y);
16 | }
17 |
--------------------------------------------------------------------------------
/business_module_http/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | business_module_http
3 |
4 | 未知错误
5 | 网络不可用
6 | 请求网络超时
7 | 数据解析错误
8 | 服务器发生错误
9 | 请求地址不存在
10 | 请求被服务器拒绝
11 | 请求被重定向到其他页面
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/utils/ScreenUtils.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.utils;
2 |
3 | import com.from.business.http.HttpBusiness;
4 |
5 | /**
6 | * @author Vea
7 | * @version 1.0.0
8 | * @since 2019-04-26
9 | */
10 | public class ScreenUtils {
11 | private static final float CONVERT_VALUE = 0.5f;
12 |
13 | /**
14 | * Dip to px
15 | *
16 | * @param dipValue dip 值
17 | * @return 返回转换后的单位
18 | */
19 | public static int dip2px(float dipValue) {
20 | final float scale = HttpBusiness.getHttpComponent().application().getResources().getDisplayMetrics().density;
21 | return (int) (dipValue * scale + CONVERT_VALUE);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | businessComponent
3 |
4 |
5 | 未知错误
6 | 网络不可用
7 | 请求网络超时
8 | 数据解析错误
9 | 服务器发生错误
10 | 请求地址不存在
11 | 请求被服务器拒绝
12 | 请求被重定向到其他页面
13 |
14 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/util/DelayedRunnable.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.util;
2 |
3 | public class DelayedRunnable implements Runnable {
4 | public long delayMillis;
5 | private Runnable runnable;
6 | public DelayedRunnable(Runnable runnable, long delayMillis) {
7 | this.runnable = runnable;
8 | this.delayMillis = delayMillis;
9 | }
10 | @Override
11 | public void run() {
12 | try {
13 | if (runnable != null) {
14 | runnable.run();
15 | runnable = null;
16 | }
17 | } catch (Throwable e) {
18 | if (!(e instanceof NoClassDefFoundError)) {
19 | e.printStackTrace();
20 | }
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/api/RefreshFooter.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.api;
2 |
3 | import android.support.annotation.RestrictTo;
4 |
5 | import static android.support.annotation.RestrictTo.Scope.LIBRARY;
6 | import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
7 | import static android.support.annotation.RestrictTo.Scope.SUBCLASSES;
8 |
9 | /**
10 | * 刷新底部
11 | * Created by SCWANG on 2017/5/26.
12 | */
13 | public interface RefreshFooter extends RefreshInternal {
14 |
15 | /**
16 | * 设置数据全部加载完成,将不能再次触发加载功能
17 | * @param noMoreData 是否有更多数据
18 | * @return true 支持全部加载完成的状态显示 false 不支持
19 | */
20 | @RestrictTo({LIBRARY,LIBRARY_GROUP,SUBCLASSES})
21 | boolean setNoMoreData(boolean noMoreData);
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/http/UserService.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.http;
2 |
3 |
4 | import java.util.List;
5 |
6 | import io.reactivex.Observable;
7 | import me.businesscomponent.entity.User;
8 | import retrofit2.http.GET;
9 | import retrofit2.http.Headers;
10 | import retrofit2.http.Query;
11 |
12 | public interface UserService {
13 | String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
14 |
15 | @Headers({HEADER_API_VERSION})
16 | @GET("/users")
17 | Observable> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
18 |
19 | @Headers({HEADER_API_VERSION})
20 | @GET("/usersERROR")
21 | Observable> getUserseRROR(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
22 | }
23 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/bean/ImageFolder.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.bean;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | public class ImageFolder implements Serializable {
7 | public String name;
8 | public ArrayList images;
9 |
10 | public ImageFolder(String name) {
11 | this.name = name;
12 | }
13 |
14 | public ImageFolder(String name, ArrayList images) {
15 | this.name = name;
16 | this.images = images;
17 | }
18 |
19 | public void addImage(ImageItem image) {
20 | if (image != null && image.path.length() > 0) {
21 | if (images == null) {
22 | images = new ArrayList<>();
23 | }
24 | images.add(image);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/entity/User.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.entity;
2 |
3 |
4 | public class User {
5 | private final int id;
6 | private final String login;
7 | private final String avatar_url;
8 |
9 | public User(int id, String login, String avatar_url) {
10 | this.id = id;
11 | this.login = login;
12 | this.avatar_url = avatar_url;
13 | }
14 |
15 | public String getAvatarUrl() {
16 | if (avatar_url.isEmpty()) return avatar_url;
17 | return avatar_url.split("\\?")[0];
18 | }
19 |
20 |
21 | public int getId() {
22 | return id;
23 | }
24 |
25 | public String getLogin() {
26 | return login;
27 | }
28 |
29 | @Override public String toString() {
30 | return "id -> " + id + " login -> " + login;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnSingleFlingListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | import android.view.MotionEvent;
4 |
5 | /**
6 | * A callback to be invoked when the ImageView is flung with a single
7 | * touch
8 | */
9 | public interface OnSingleFlingListener {
10 |
11 | /**
12 | * A callback to receive where the user flings on a ImageView. You will receive a callback if
13 | * the user flings anywhere on the view.
14 | *
15 | * @param e1 MotionEvent the user first touch.
16 | * @param e2 MotionEvent the user last touch.
17 | * @param velocityX distance of user's horizontal fling.
18 | * @param velocityY distance of user's vertical fling.
19 | */
20 | boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
21 | }
22 |
--------------------------------------------------------------------------------
/view_module_photoview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/view_module_picture/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/view_module_refresh/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/view_module_swipeback/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/view_module_swipeback/src/main/java/com/from/view/swipeback/SimpleSwipeBackDelegate.java:
--------------------------------------------------------------------------------
1 | package com.from.view.swipeback;
2 |
3 | import android.app.Activity;
4 |
5 | /**
6 | * @author Vea
7 | * @version 1.0.2
8 | * @since 2019-03
9 | */
10 | public class SimpleSwipeBackDelegate implements SwipeBackHelper.Delegate {
11 | /**
12 | * 正在滑动返回
13 | *
14 | * @param slideOffset 从 0 到 1
15 | */
16 | @Override
17 | public void onSwipeBackLayoutSlide(float slideOffset) {
18 | }
19 |
20 | /**
21 | * 没达到滑动返回的阈值,取消滑动返回动作,回到默认状态
22 | */
23 | @Override
24 | public void onSwipeBackLayoutCancel() {
25 | }
26 |
27 | /**
28 | * 滑动返回执行完毕,销毁当前 Activity
29 | *
30 | * @param activity 当前Activity
31 | */
32 | @Override
33 | public void onSwipeBackLayoutExecuted(Activity activity) {
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/http/GankService.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.http;
2 |
3 |
4 | import java.util.List;
5 |
6 | import io.reactivex.Observable;
7 | import me.businesscomponent.entity.GankBaseResponse;
8 | import me.businesscomponent.entity.GankItemBean;
9 | import retrofit2.http.GET;
10 | import retrofit2.http.Headers;
11 | import retrofit2.http.Path;
12 |
13 | import static com.from.business.http.retrofiturlmanager.RetrofitUrlManager.DOMAIN_NAME_HEADER;
14 |
15 | public interface GankService {
16 | String GANK_DOMAIN_NAME = "gank";
17 | String GANK_DOMAIN = "http://gank.io";
18 |
19 | /**
20 | * 妹纸列表
21 | */
22 | @Headers({DOMAIN_NAME_HEADER + GANK_DOMAIN_NAME})
23 | @GET("/api/data/福利/{num}/{page}")
24 | Observable>> getGirlList(@Path("num") int num, @Path("page") int page);
25 | }
26 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/drawable/maven_picture_folder_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
7 |
8 |
11 |
12 |
13 |
14 |
15 | -
20 |
21 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnPhotoTapListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | import android.widget.ImageView;
4 |
5 | /**
6 | * A callback to be invoked when the Photo is tapped with a single
7 | * tap.
8 | */
9 | public interface OnPhotoTapListener {
10 |
11 | /**
12 | * A callback to receive where the user taps on a photo. You will only receive a callback if
13 | * the user taps on the actual photo, tapping on 'whitespace' will be ignored.
14 | *
15 | * @param view ImageView the user tapped.
16 | * @param x where the user tapped from the of the Drawable, as percentage of the
17 | * Drawable width.
18 | * @param y where the user tapped from the top of the Drawable, as percentage of the
19 | * Drawable height.
20 | */
21 | void onPhotoTap(ImageView view, float x, float y);
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/taojiji/view/photoview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.taojiji.view.photoview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.taojiji.view.photoview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/view_module_refresh/src/androidTest/java/com/taojiji/view/refresh/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.taojiji.view.refresh;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.taojiji.view.refresh.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 | BUILD_TOOLS_VERSION=27.0.3
17 | APP_NAME=1.0.0
18 | APP_CODE=10
19 | COMPILE_SDK_VERSION=28
20 | MIN_SDK_VERSION=15
21 | TARGET_SDK_VERSION=28
22 |
--------------------------------------------------------------------------------
/view_module_swipeback/src/androidTest/java/com/taojiji/view/swipeback/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.taojiji.view.swipeback;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.taojiji.view.swipeback.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/common_component_build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion COMPILE_SDK_VERSION.toInteger()
5 |
6 | // compileOptions {
7 | // targetCompatibility JavaVersion.VERSION_1_8
8 | // sourceCompatibility JavaVersion.VERSION_1_8
9 | // }
10 |
11 | defaultConfig {
12 | minSdkVersion MIN_SDK_VERSION
13 | targetSdkVersion TARGET_SDK_VERSION
14 | versionCode APP_CODE.toInteger()
15 | versionName APP_NAME
16 | }
17 | buildTypes {
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | lintOptions {
27 | abortOnError false
28 | }
29 |
30 | }
31 |
32 | dependencies {
33 | compileOnly "com.android.support:appcompat-v7:$support_version"
34 | }
35 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/layout/maven_picture_item_camera_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/OnGestureListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2011, 2012 Chris Banes.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.from.view.photoview;
17 |
18 | interface OnGestureListener {
19 |
20 | void onDrag(float dx, float dy);
21 |
22 | void onFling(float startX, float startY, float velocityX,
23 | float velocityY);
24 |
25 | void onScale(float scaleFactor, float focusX, float focusY);
26 |
27 | }
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/lifecycle/CorrespondingEventsFunction.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.lifecycle;
2 |
3 | import com.uber.autodispose.OutsideScopeException;
4 |
5 | import io.reactivex.functions.Function;
6 |
7 | /**
8 | * A corresponding events function that acts as a normal {@link Function} but ensures a single event
9 | * type in the generic and tightens the possible exception thrown to {@link OutsideScopeException}.
10 | *
11 | * @param the event type.
12 | */
13 | public interface CorrespondingEventsFunction extends Function {
14 |
15 | /**
16 | * Given an event {@code event}, returns the next corresponding event that this lifecycle should
17 | * dispose on.
18 | *
19 | * @param event the source or start event.
20 | * @return the target event that should signal disposal.
21 | * @throws OutsideScopeException if the lifecycle exceeds its scope boundaries.
22 | */
23 | @Override E apply(E event) throws OutsideScopeException;
24 | }
25 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | image_select
3 | 全部图片
4 | 图片选择
5 | 最多只能选%1s张图片哦~
6 | 预览(%1s)
7 | 完成
8 | 完成(%1$s/%2$s)
9 | %1s张
10 | 0张
11 | 选择
12 | %1$s/%2$s
13 | 打开相机失败
14 | 拍一张
15 | 最大只支持选择%s大小图片
16 |
17 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/api/RefreshContent.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.api;
2 |
3 | import android.animation.ValueAnimator.AnimatorUpdateListener;
4 | import android.support.annotation.NonNull;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 |
8 | /**
9 | * 刷新内容组件
10 | * Created by SCWANG on 2017/5/26.
11 | */
12 | public interface RefreshContent {
13 |
14 | @NonNull
15 | View getView();
16 | @NonNull
17 | View getScrollableView();
18 |
19 | void onActionDown(MotionEvent e);
20 |
21 | void setUpComponent(RefreshKernel kernel, View fixedHeader, View fixedFooter);
22 | void setScrollBoundaryDecider(ScrollBoundaryDecider boundary);
23 |
24 | void setEnableLoadMoreWhenContentNotFull(boolean enable);
25 |
26 | void moveSpinner(int spinner, int headerTranslationViewId, int footerTranslationViewId);
27 |
28 | boolean canRefresh();
29 | boolean canLoadMore();
30 |
31 | AnimatorUpdateListener scrollContentWhenFinished(int spinner);
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/activity/BasePresenterOrViewModel.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.activity;
2 |
3 | import android.arch.lifecycle.Lifecycle;
4 |
5 | import com.from.business.http.lifecycle.AndroidLifecycleScopeProvider;
6 | import com.uber.autodispose.AutoDispose;
7 | import com.uber.autodispose.AutoDisposeConverter;
8 |
9 | import me.businesscomponent.BaseApplication;
10 | import timber.log.Timber;
11 |
12 | import static com.from.business.http.utils.Preconditions.checkNotNull;
13 |
14 | public class BasePresenterOrViewModel {
15 |
16 | protected Lifecycle mLifecycle;
17 |
18 | public void setLifecycle(Lifecycle mLifecycle) {
19 | this.mLifecycle = mLifecycle;
20 | Lifecycle.State currentState = mLifecycle.getCurrentState();
21 | Timber.tag(BaseApplication.TAG).d("setLifecycle:" + currentState.name());
22 | }
23 |
24 | public AutoDisposeConverter bindLifecycle() {
25 | return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(checkNotNull(mLifecycle)));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/listener/OnStateChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.listener;
2 |
3 |
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.RestrictTo;
6 |
7 | import com.from.view.refresh.api.RefreshLayout;
8 | import com.from.view.refresh.constant.RefreshState;
9 |
10 | import static android.support.annotation.RestrictTo.Scope.LIBRARY;
11 | import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
12 | import static android.support.annotation.RestrictTo.Scope.SUBCLASSES;
13 |
14 | /**
15 | * 刷新状态改变监听器
16 | * Created by SCWANG on 2017/5/26.
17 | */
18 |
19 | public interface OnStateChangedListener {
20 | /**
21 | * 状态改变事件 {@link RefreshState}
22 | * @param refreshLayout RefreshLayout
23 | * @param oldState 改变之前的状态
24 | * @param newState 改变之后的状态
25 | */
26 | @RestrictTo({LIBRARY,LIBRARY_GROUP,SUBCLASSES})
27 | void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/cache/CacheProviders.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.cache;
2 |
3 | import java.util.List;
4 | import java.util.concurrent.TimeUnit;
5 |
6 | import io.reactivex.Observable;
7 | import io.rx_cache2.DynamicKey;
8 | import io.rx_cache2.EvictProvider;
9 | import io.rx_cache2.LifeCache;
10 | import io.rx_cache2.Reply;
11 | import me.businesscomponent.entity.GankBaseResponse;
12 | import me.businesscomponent.entity.GankItemBean;
13 | import me.businesscomponent.entity.User;
14 |
15 | /**
16 | * Created by victor on 04/01/16.
17 | */
18 | public interface CacheProviders {
19 |
20 | @LifeCache(duration = 2, timeUnit = TimeUnit.MINUTES)
21 | Observable>> getUsers(Observable> oUsers, DynamicKey idLastUserQueried, EvictProvider evictProvider);
22 |
23 |
24 | @LifeCache(duration = 2, timeUnit = TimeUnit.MINUTES)
25 | Observable>>> getGirlList(Observable>> oGirlList, DynamicKey idLastUserQueried, EvictProvider evictProvider);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/internal/PaintDrawable.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.internal;
2 |
3 | import android.graphics.ColorFilter;
4 | import android.graphics.Paint;
5 | import android.graphics.PixelFormat;
6 | import android.graphics.drawable.Drawable;
7 |
8 | /**
9 | * 画笔 Drawable
10 | * Created by SCWANG on 2017/6/16.
11 | */
12 | public abstract class PaintDrawable extends Drawable {
13 |
14 | protected Paint mPaint = new Paint();
15 |
16 | protected PaintDrawable() {
17 | mPaint.setStyle(Paint.Style.FILL);
18 | mPaint.setAntiAlias(true);
19 | mPaint.setColor(0xffaaaaaa);
20 | }
21 |
22 | public void setColor(int color) {
23 | mPaint.setColor(color);
24 | }
25 |
26 | @Override
27 | public void setAlpha(int alpha) {
28 | mPaint.setAlpha(alpha);
29 | }
30 |
31 | @Override
32 | public void setColorFilter(ColorFilter cf) {
33 | mPaint.setColorFilter(cf);
34 | }
35 |
36 | @Override
37 | public int getOpacity() {
38 | return PixelFormat.TRANSLUCENT;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/weight/SuperCheckBox.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.weight;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.AppCompatCheckBox;
5 | import android.util.AttributeSet;
6 | import android.view.SoundEffectConstants;
7 |
8 | public class SuperCheckBox extends AppCompatCheckBox {
9 |
10 | public SuperCheckBox(Context context) {
11 | super(context);
12 | }
13 |
14 | public SuperCheckBox(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | public SuperCheckBox(Context context, AttributeSet attrs, int defStyle) {
19 | super(context, attrs, defStyle);
20 | }
21 |
22 | @Override
23 | public boolean performClick() {
24 | final boolean handled = super.performClick();
25 | if (!handled) {
26 | // View only makes a sound effect if the onClickListener was
27 | // called, so we'll need to make one here instead.
28 | playSoundEffect(SoundEffectConstants.CLICK);
29 | }
30 | return handled;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/business_module_http/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 | -if class com.from.business.http.lifecycle.LifecycleEventsObservable.ArchLifecycleObserver {
23 | (...);
24 | }
25 | -keep class com.from.business.http.lifecycle.LifecycleEventsObservable_ArchLifecycleObserver_LifecycleAdapter {
26 | (...);
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import me.businesscomponent.activity.HttpExampleActivity;
9 | import me.businesscomponent.activity.PicExampleActivity;
10 |
11 | /**
12 | * @author Vea
13 | * @since 2019-01
14 | */
15 | public class MainActivity extends AppCompatActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 | }
22 |
23 | public void onClick(View view) {
24 | switch (view.getId()) {
25 | case R.id.btnPicDemo:
26 | startActivity(new Intent(this, PicExampleActivity.class));
27 | break;
28 | case R.id.btnHttpDemo:
29 | startActivity(new Intent(this, HttpExampleActivity.class));
30 | break;
31 | default:
32 | break;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/weight/FixViewPager.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.weight;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.view.ViewPager;
7 | import android.util.AttributeSet;
8 | import android.view.MotionEvent;
9 |
10 | /**
11 | * 在使用photoView缩放时避免异常的出现
12 | *
13 | * author: ym.li
14 | * since: 2018/11/3
15 | */
16 |
17 | public class FixViewPager extends ViewPager {
18 | public FixViewPager(@NonNull Context context) {
19 | this(context, null);
20 | }
21 |
22 | public FixViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | @Override
27 | public boolean onInterceptTouchEvent(MotionEvent ev) {
28 | try {
29 | return super.onInterceptTouchEvent(ev);
30 | } catch (IllegalArgumentException e) {
31 | //uncomment if you really want to see these errors
32 | //e.printStackTrace();
33 | return false;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/lifecycle/LifecycleEventsObservable_ArchLifecycleObserver_LifecycleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.lifecycle;
2 |
3 | import android.arch.lifecycle.GeneratedAdapter;
4 | import android.arch.lifecycle.Lifecycle;
5 | import android.arch.lifecycle.LifecycleOwner;
6 | import android.arch.lifecycle.MethodCallsLogger;
7 |
8 | public class LifecycleEventsObservable_ArchLifecycleObserver_LifecycleAdapter implements GeneratedAdapter {
9 | final LifecycleEventsObservable.ArchLifecycleObserver mReceiver;
10 |
11 | LifecycleEventsObservable_ArchLifecycleObserver_LifecycleAdapter(LifecycleEventsObservable.ArchLifecycleObserver receiver) {
12 | this.mReceiver = receiver;
13 | }
14 |
15 | @Override
16 | public void callMethods(LifecycleOwner owner, Lifecycle.Event event, boolean onAny, MethodCallsLogger logger) {
17 | boolean hasLogger = logger != null;
18 | if (onAny) {
19 | if (!hasLogger || logger.approveCall("onStateChange", 4)) {
20 | this.mReceiver.onStateChange(owner, event);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/ClientModuleProvideRetrofitBuilderFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import dagger.internal.Factory;
6 | import retrofit2.Retrofit;
7 |
8 | public final class ClientModuleProvideRetrofitBuilderFactory implements Factory {
9 | private static final ClientModuleProvideRetrofitBuilderFactory INSTANCE =
10 | new ClientModuleProvideRetrofitBuilderFactory();
11 |
12 | @Override
13 | public Retrofit.Builder get() {
14 | return provideInstance();
15 | }
16 |
17 | public static Retrofit.Builder provideInstance() {
18 | return proxyProvideRetrofitBuilder();
19 | }
20 |
21 | public static ClientModuleProvideRetrofitBuilderFactory create() {
22 | return INSTANCE;
23 | }
24 |
25 | public static Retrofit.Builder proxyProvideRetrofitBuilder() {
26 | return Preconditions.checkNotNull(
27 | ClientModule.provideRetrofitBuilder(),
28 | "Cannot return null from a non-@Nullable @Provides method");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 下拉可以刷新
3 | 正在刷新…
4 | 等待底部加载完成…
5 | 释放立即刷新
6 | 刷新完成
7 | 刷新失败
8 | 上次更新 M-d HH:mm
9 | 释放进入二楼
10 |
11 | 上拉加载更多
12 | 释放立即加载
13 | 正在加载…
14 | 等待头部刷新完成…
15 | 加载完成
16 | 加载失败
17 | 没有更多数据了
18 |
19 | SmartRefreshLayout中没有找到内容视图。您是否忘记在xml布局文件中添加?
20 | %s 虚假区域\n代表运行时拖动的高度【%.1fdp】 \n而不会显示任何东西
21 |
22 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/ClientModuleProvideClientBuilderFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import dagger.internal.Factory;
6 | import okhttp3.OkHttpClient;
7 |
8 | public final class ClientModuleProvideClientBuilderFactory
9 | implements Factory {
10 | private static final ClientModuleProvideClientBuilderFactory INSTANCE =
11 | new ClientModuleProvideClientBuilderFactory();
12 |
13 | @Override
14 | public OkHttpClient.Builder get() {
15 | return provideInstance();
16 | }
17 |
18 | public static OkHttpClient.Builder provideInstance() {
19 | return proxyProvideClientBuilder();
20 | }
21 |
22 | public static ClientModuleProvideClientBuilderFactory create() {
23 | return INSTANCE;
24 | }
25 |
26 | public static OkHttpClient.Builder proxyProvideClientBuilder() {
27 | return Preconditions.checkNotNull(
28 | ClientModule.provideClientBuilder(),
29 | "Cannot return null from a non-@Nullable @Provides method");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/gradle.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 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleBaseUrlFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import dagger.internal.Factory;
6 | import okhttp3.HttpUrl;
7 |
8 | public final class HttpConfigModuleBaseUrlFactory implements Factory {
9 | private final HttpConfigModule module;
10 |
11 | public HttpConfigModuleBaseUrlFactory(HttpConfigModule module) {
12 | this.module = module;
13 | }
14 |
15 | @Override
16 | public HttpUrl get() {
17 | return provideInstance(module);
18 | }
19 |
20 | public static HttpUrl provideInstance(HttpConfigModule module) {
21 | return proxyProvideBaseUrl(module);
22 | }
23 |
24 | public static HttpConfigModuleBaseUrlFactory create(HttpConfigModule module) {
25 | return new HttpConfigModuleBaseUrlFactory(module);
26 | }
27 |
28 | public static HttpUrl proxyProvideBaseUrl(HttpConfigModule instance) {
29 | return Preconditions.checkNotNull(
30 | instance.provideBaseUrl(), "Cannot return null from a non-@Nullable @Provides method");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
9 |
10 |
14 |
15 |
20 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleInterceptorsFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import java.util.List;
6 |
7 | import dagger.internal.Factory;
8 | import okhttp3.Interceptor;
9 |
10 | public final class HttpConfigModuleInterceptorsFactory
11 | implements Factory> {
12 | private final HttpConfigModule module;
13 |
14 | public HttpConfigModuleInterceptorsFactory(HttpConfigModule module) {
15 | this.module = module;
16 | }
17 |
18 | @Override
19 | @Nullable
20 | public List get() {
21 | return provideInstance(module);
22 | }
23 |
24 | @Nullable
25 | public static List provideInstance(HttpConfigModule module) {
26 | return proxyProvideInterceptors(module);
27 | }
28 |
29 | public static HttpConfigModuleInterceptorsFactory create(HttpConfigModule module) {
30 | return new HttpConfigModuleInterceptorsFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static List proxyProvideInterceptors(HttpConfigModule instance) {
35 | return instance.provideInterceptors();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/integration/IRepositoryManager.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.integration;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 |
6 | /**
7 | * ================================================
8 | * 用来管理网络请求层,以及数据缓存层,以后可能添加数据库请求层
9 | *
10 | * ================================================
11 | */
12 | public interface IRepositoryManager {
13 | /**
14 | * 根据传入的 Class 获取对应的 Retrofit service
15 | *
16 | * @param service Retrofit service class
17 | * @param Retrofit service 类型
18 | * @return Retrofit service
19 | */
20 | @NonNull
21 | T obtainRetrofitService(@NonNull Class service);
22 |
23 | /**
24 | * 根据传入的 Class 获取对应的 RxCache service
25 | *
26 | * @param cache RxCache service class
27 | * @param RxCache service 类型
28 | * @return RxCache service
29 | */
30 | @NonNull
31 | T obtainCacheService(@NonNull Class cache);
32 |
33 | /**
34 | * 清理所有缓存
35 | */
36 | void clearAllCache();
37 |
38 | /**
39 | * 获取 {@link Context}
40 | *
41 | * @return {@link Context}
42 | */
43 | @NonNull
44 | Context getContext();
45 | }
46 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleGlobalHttpHandlerFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.from.business.http.HttpHandler;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleGlobalHttpHandlerFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleGlobalHttpHandlerFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | @Nullable
19 | public HttpHandler get() {
20 | return provideInstance(module);
21 | }
22 |
23 | @Nullable
24 | public static HttpHandler provideInstance(HttpConfigModule module) {
25 | return proxyProvideGlobalHttpHandler(module);
26 | }
27 |
28 | public static HttpConfigModuleGlobalHttpHandlerFactory create(
29 | HttpConfigModule module) {
30 | return new HttpConfigModuleGlobalHttpHandlerFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static HttpHandler proxyProvideGlobalHttpHandler(HttpConfigModule instance) {
35 | return instance.provideGlobalHttpHandler();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/view_module_swipeback/src/main/res/anim/maven_swipeback_translucent_exit.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
21 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/view_module_swipeback/src/main/res/anim/maven_swipeback_translucent_enter.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
21 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleFormatPrinterFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import com.from.business.http.log.FormatPrinter;
4 | import com.from.business.http.utils.Preconditions;
5 |
6 | import dagger.internal.Factory;
7 |
8 | public final class HttpConfigModuleFormatPrinterFactory
9 | implements Factory {
10 | private final HttpConfigModule module;
11 |
12 | public HttpConfigModuleFormatPrinterFactory(HttpConfigModule module) {
13 | this.module = module;
14 | }
15 |
16 | @Override
17 | public FormatPrinter get() {
18 | return provideInstance(module);
19 | }
20 |
21 | public static FormatPrinter provideInstance(HttpConfigModule module) {
22 | return proxyProvideFormatPrinter(module);
23 | }
24 |
25 | public static HttpConfigModuleFormatPrinterFactory create(HttpConfigModule module) {
26 | return new HttpConfigModuleFormatPrinterFactory(module);
27 | }
28 |
29 | public static FormatPrinter proxyProvideFormatPrinter(HttpConfigModule instance) {
30 | return Preconditions.checkNotNull(
31 | instance.provideFormatPrinter(),
32 | "Cannot return null from a non-@Nullable @Provides method");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/weight/SquareFrameLayout.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.weight;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.FrameLayout;
6 |
7 | /**
8 | * Doc 宽高一样的FrameLayout
9 | *
10 | * @author ym.li
11 | * @version 2.9.0
12 | * @since 2018/11/2/002
13 | */
14 | public class SquareFrameLayout extends FrameLayout {
15 | public SquareFrameLayout(Context context) {
16 | this(context, null);
17 | }
18 |
19 | public SquareFrameLayout(Context context, AttributeSet attrs) {
20 | this(context, attrs, 0);
21 | }
22 |
23 | public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 | }
26 |
27 | @Override
28 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
29 | setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
30 | getDefaultSize(0, heightMeasureSpec));
31 | int childWidthSize = getMeasuredWidth();
32 | // 高度和宽度一样
33 | heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(
34 | childWidthSize, MeasureSpec.EXACTLY);
35 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleExecutorServiceFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import java.util.concurrent.ExecutorService;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleExecutorServiceFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleExecutorServiceFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | public ExecutorService get() {
19 | return provideInstance(module);
20 | }
21 |
22 | public static ExecutorService provideInstance(HttpConfigModule module) {
23 | return proxyProvideExecutorService(module);
24 | }
25 |
26 | public static HttpConfigModuleExecutorServiceFactory create(HttpConfigModule module) {
27 | return new HttpConfigModuleExecutorServiceFactory(module);
28 | }
29 |
30 | public static ExecutorService proxyProvideExecutorService(HttpConfigModule instance) {
31 | return Preconditions.checkNotNull(
32 | instance.provideExecutorService(),
33 | "Cannot return null from a non-@Nullable @Provides method");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleOkhttpConfigurationFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.from.business.http.module.ClientModule;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleOkhttpConfigurationFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleOkhttpConfigurationFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | @Nullable
19 | public ClientModule.OkhttpConfiguration get() {
20 | return provideInstance(module);
21 | }
22 |
23 | @Nullable
24 | public static ClientModule.OkhttpConfiguration provideInstance(HttpConfigModule module) {
25 | return proxyProvideOkhttpConfiguration(module);
26 | }
27 |
28 | public static HttpConfigModuleOkhttpConfigurationFactory create(
29 | HttpConfigModule module) {
30 | return new HttpConfigModuleOkhttpConfigurationFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static ClientModule.OkhttpConfiguration proxyProvideOkhttpConfiguration(
35 | HttpConfigModule instance) {
36 | return instance.provideOkhttpConfiguration();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/imageloader/UIImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.imageloader;
2 |
3 | import android.widget.ImageView;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Doc 图片加载策略,可在项目中使用自己的图片加载框架
9 | *
10 | * @author ym.li
11 | * @version 2.9.0
12 | * @since 2018/11/2/002
13 | */
14 | public interface UIImageLoader extends Serializable {
15 | /**
16 | * @param imageView ImageView
17 | * @param path 图片加载路径
18 | * @param height 高度
19 | * @param width 宽度
20 | * @param defaultImage 默认图
21 | */
22 | void imageLoader(ImageView imageView, String path, int height, int width, int defaultImage);
23 |
24 | /**
25 | * @param imageView ImageView
26 | * @param path 图片加载路径
27 | * @param height 高度
28 | * @param width 宽度
29 | */
30 | void imageLoader(ImageView imageView, String path, int height, int width);
31 |
32 | /**
33 | * @param imageView ImageView
34 | * @param path 图片加载路径
35 | * @param defaultImage 默认图
36 | */
37 | void imageLoader(ImageView imageView, String path, int defaultImage);
38 |
39 | /**
40 | * @param imageView ImageView
41 | * @param path 图片加载路径
42 | */
43 | void imageLoader(ImageView imageView, String path);
44 | }
45 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleGsonConfigurationFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.from.business.http.module.AppModule;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleGsonConfigurationFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleGsonConfigurationFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | @Nullable
19 | public AppModule.GsonConfiguration get() {
20 | return provideInstance(module);
21 | }
22 |
23 | @Nullable
24 | public static AppModule.GsonConfiguration provideInstance(HttpConfigModule module) {
25 | return proxyProvideGsonConfiguration(module);
26 | }
27 |
28 | public static HttpConfigModuleGsonConfigurationFactory create(
29 | HttpConfigModule module) {
30 | return new HttpConfigModuleGsonConfigurationFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static AppModule.GsonConfiguration proxyProvideGsonConfiguration(
35 | HttpConfigModule instance) {
36 | return instance.provideGsonConfiguration();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/view_module_picture/README.md:
--------------------------------------------------------------------------------
1 | # view_module_picture
2 |
3 | ### 介绍
4 | 高仿微信的图片选择库
5 |
6 | #### 使用
7 | 1.引入 Module 或 gradle
8 | ```
9 | implementation 'com.from.view.photoview:view_module_photoview:1.0.0'
10 | implementation 'com.from.view.picture:view_module_picture:1.0.3.1'
11 |
12 | ```
13 | #### history
14 | - 1.0.3.1:添加选择图片时大小限制
15 |
16 | 代码可参考[PicExampleActivity](https://github.com/xwc520/BusinessComponent/blob/master/app/src/main/java/me/businesscomponent/activity/PicExampleActivity.java)
17 |
18 | ```
19 | @Override
20 | public void onClick(View v) {
21 | PictureSelector.with(PicExampleActivity.this)
22 | .selectSpec()
23 | .setMaxSelectImage(6)
24 | .setOpenCamera(true)
25 | .setImageLoader(new GlideImageLoader())
26 | .setSpanCount(3)
27 | .startForResult(SELECT_IMAGE);
28 | }
29 |
30 | @Override
31 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
32 | super.onActivityResult(requestCode, resultCode, data);
33 | if (resultCode == Activity.RESULT_OK && requestCode == SELECT_IMAGE) {
34 | List paths = PictureSelector.obtainPathResult(data);
35 | Toast.makeText(PicExampleActivity.this, paths.get(0), Toast.LENGTH_SHORT).show();
36 | }
37 | }
38 |
39 | ```
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/util/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.util;
2 |
3 | import android.content.res.Resources;
4 |
5 | /**
6 | * 像素密度计算工具
7 | */
8 | @SuppressWarnings("unused")
9 | public class DensityUtil {
10 |
11 | public float density;
12 |
13 | public DensityUtil() {
14 | density = Resources.getSystem().getDisplayMetrics().density;
15 | }
16 |
17 | /**
18 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
19 | * @param dpValue 虚拟像素
20 | * @return 像素
21 | */
22 | public static int dp2px(float dpValue) {
23 | return (int) (0.5f + dpValue * Resources.getSystem().getDisplayMetrics().density);
24 | }
25 |
26 | /**
27 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
28 | * @param pxValue 像素
29 | * @return 虚拟像素
30 | */
31 | public static float px2dp(int pxValue) {
32 | return (pxValue / Resources.getSystem().getDisplayMetrics().density);
33 | }
34 |
35 | /**
36 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
37 | * @param dpValue 虚拟像素
38 | * @return 像素
39 | */
40 | public int dip2px(float dpValue) {
41 | return (int) (0.5f + dpValue * density);
42 | }
43 |
44 | /**
45 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
46 | * @param pxValue 像素
47 | * @return 虚拟像素
48 | */
49 | public float px2dip(int pxValue) {
50 | return (pxValue / density);
51 | }
52 | }
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleRxCacheConfigurationFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.from.business.http.module.ClientModule;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleRxCacheConfigurationFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleRxCacheConfigurationFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | @Nullable
19 | public ClientModule.RxCacheConfiguration get() {
20 | return provideInstance(module);
21 | }
22 |
23 | @Nullable
24 | public static ClientModule.RxCacheConfiguration provideInstance(HttpConfigModule module) {
25 | return proxyProvideRxCacheConfiguration(module);
26 | }
27 |
28 | public static HttpConfigModuleRxCacheConfigurationFactory create(
29 | HttpConfigModule module) {
30 | return new HttpConfigModuleRxCacheConfigurationFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static ClientModule.RxCacheConfiguration proxyProvideRxCacheConfiguration(
35 | HttpConfigModule instance) {
36 | return instance.provideRxCacheConfiguration();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/retrofiturlmanager/InvalidUrlException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.from.business.http.retrofiturlmanager;
17 |
18 | import android.text.TextUtils;
19 |
20 | /**
21 | * ================================================
22 | * Url 无效的异常
23 | *
24 | * Created by JessYan on 2017/7/24.
25 | * Contact me
26 | * Follow me
27 | * ================================================
28 | */
29 | public class InvalidUrlException extends RuntimeException {
30 |
31 | public InvalidUrlException(String url) {
32 | super("You've configured an invalid url : " + (TextUtils.isEmpty(url) ? "EMPTY_OR_NULL_URL" : url));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/ClientModuleProvideRxCacheDirectoryFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import java.io.File;
6 |
7 | import javax.inject.Provider;
8 |
9 | import dagger.internal.Factory;
10 |
11 |
12 | public final class ClientModuleProvideRxCacheDirectoryFactory implements Factory {
13 | private final Provider cacheDirProvider;
14 |
15 | public ClientModuleProvideRxCacheDirectoryFactory(Provider cacheDirProvider) {
16 | this.cacheDirProvider = cacheDirProvider;
17 | }
18 |
19 | @Override
20 | public File get() {
21 | return provideInstance(cacheDirProvider);
22 | }
23 |
24 | public static File provideInstance(Provider cacheDirProvider) {
25 | return proxyProvideRxCacheDirectory(cacheDirProvider.get());
26 | }
27 |
28 | public static ClientModuleProvideRxCacheDirectoryFactory create(
29 | Provider cacheDirProvider) {
30 | return new ClientModuleProvideRxCacheDirectoryFactory(cacheDirProvider);
31 | }
32 |
33 | public static File proxyProvideRxCacheDirectory(File cacheDir) {
34 | return Preconditions.checkNotNull(
35 | ClientModule.provideRxCacheDirectory(cacheDir),
36 | "Cannot return null from a non-@Nullable @Provides method");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModulePrintHttpLogLevelFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import com.from.business.http.log.RequestInterceptor;
4 | import com.from.business.http.utils.Preconditions;
5 |
6 | import dagger.internal.Factory;
7 |
8 | public final class HttpConfigModulePrintHttpLogLevelFactory
9 | implements Factory {
10 | private final HttpConfigModule module;
11 |
12 | public HttpConfigModulePrintHttpLogLevelFactory(HttpConfigModule module) {
13 | this.module = module;
14 | }
15 |
16 | @Override
17 | public RequestInterceptor.Level get() {
18 | return provideInstance(module);
19 | }
20 |
21 | public static RequestInterceptor.Level provideInstance(HttpConfigModule module) {
22 | return proxyProvidePrintHttpLogLevel(module);
23 | }
24 |
25 | public static HttpConfigModulePrintHttpLogLevelFactory create(
26 | HttpConfigModule module) {
27 | return new HttpConfigModulePrintHttpLogLevelFactory(module);
28 | }
29 |
30 | public static RequestInterceptor.Level proxyProvidePrintHttpLogLevel(
31 | HttpConfigModule instance) {
32 | return Preconditions.checkNotNull(
33 | instance.providePrintHttpLogLevel(),
34 | "Cannot return null from a non-@Nullable @Provides method");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleRetrofitConfigurationFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.from.business.http.module.ClientModule;
6 |
7 | import dagger.internal.Factory;
8 |
9 | public final class HttpConfigModuleRetrofitConfigurationFactory
10 | implements Factory {
11 | private final HttpConfigModule module;
12 |
13 | public HttpConfigModuleRetrofitConfigurationFactory(HttpConfigModule module) {
14 | this.module = module;
15 | }
16 |
17 | @Override
18 | @Nullable
19 | public ClientModule.RetrofitConfiguration get() {
20 | return provideInstance(module);
21 | }
22 |
23 | @Nullable
24 | public static ClientModule.RetrofitConfiguration provideInstance(HttpConfigModule module) {
25 | return proxyProvideRetrofitConfiguration(module);
26 | }
27 |
28 | public static HttpConfigModuleRetrofitConfigurationFactory create(
29 | HttpConfigModule module) {
30 | return new HttpConfigModuleRetrofitConfigurationFactory(module);
31 | }
32 |
33 | @Nullable
34 | public static ClientModule.RetrofitConfiguration proxyProvideRetrofitConfiguration(
35 | HttpConfigModule instance) {
36 | return instance.provideRetrofitConfiguration();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/bean/ImageItem.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.bean;
2 |
3 | import java.io.Serializable;
4 |
5 | public class ImageItem implements Serializable {
6 | public String name; //图片的名字
7 | public String path; //图片的路径
8 | public int height; //图片的高度
9 | public int width; //图片的高度
10 | public long size; //图片大小
11 | public String mimeType; //图片的类型
12 | public long addTime; //图片的创建时间
13 |
14 | public ImageItem(String path, long time, String name, String mimeType, int width, int height, long size) {
15 | this.path = path;
16 | this.mimeType = mimeType;
17 | this.addTime = time;
18 | this.name = name;
19 | this.width = width;
20 | this.height = height;
21 | this.size = size;
22 | }
23 |
24 | public ImageItem(String path, String name) {
25 | this.path = path;
26 | this.name = name;
27 | }
28 |
29 | /**
30 | * 图片的路径和创建时间相同就认为是同一张图片
31 | */
32 | @Override
33 | public boolean equals(Object o) {
34 | try {
35 | ImageItem other = (ImageItem) o;
36 | return this.path.equalsIgnoreCase(other.path) && this.addTime == other.addTime;
37 | } catch (ClassCastException e) {
38 | e.printStackTrace();
39 | }
40 | return super.equals(o);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/internal/Beta.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The Dagger Authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dagger.internal;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 |
22 | import static java.lang.annotation.RetentionPolicy.SOURCE;
23 |
24 | /**
25 | * Signifies that a public API (public class, method or field) is subject to
26 | * incompatible changes, or even removal, in a future release. An API bearing
27 | * this annotation is exempt from any compatibility guarantees made by its
28 | * containing library. Note that the presence of this annotation implies nothing
29 | * about the quality or performance of the API in question, only the fact that
30 | * it is not "API-frozen."
31 | */
32 | @Documented
33 | @Retention(SOURCE)
34 | public @interface Beta {}
35 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleResponseErrorListenerFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import com.from.business.http.utils.Preconditions;
4 |
5 | import dagger.internal.Factory;
6 | import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
7 |
8 | public final class HttpConfigModuleResponseErrorListenerFactory
9 | implements Factory {
10 | private final HttpConfigModule module;
11 |
12 | public HttpConfigModuleResponseErrorListenerFactory(HttpConfigModule module) {
13 | this.module = module;
14 | }
15 |
16 | @Override
17 | public ResponseErrorListener get() {
18 | return provideInstance(module);
19 | }
20 |
21 | public static ResponseErrorListener provideInstance(HttpConfigModule module) {
22 | return proxyProvideResponseErrorListener(module);
23 | }
24 |
25 | public static HttpConfigModuleResponseErrorListenerFactory create(
26 | HttpConfigModule module) {
27 | return new HttpConfigModuleResponseErrorListenerFactory(module);
28 | }
29 |
30 | public static ResponseErrorListener proxyProvideResponseErrorListener(
31 | HttpConfigModule instance) {
32 | return Preconditions.checkNotNull(
33 | instance.provideResponseErrorListener(),
34 | "Cannot return null from a non-@Nullable @Provides method");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/Compat.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2011, 2012 Chris Banes.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.from.view.photoview;
17 |
18 | import android.annotation.TargetApi;
19 | import android.os.Build.VERSION;
20 | import android.os.Build.VERSION_CODES;
21 | import android.view.View;
22 |
23 | class Compat {
24 |
25 | private static final int SIXTY_FPS_INTERVAL = 1000 / 60;
26 |
27 | public static void postOnAnimation(View view, Runnable runnable) {
28 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
29 | postOnAnimationJellyBean(view, runnable);
30 | } else {
31 | view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
32 | }
33 | }
34 |
35 | @TargetApi(16)
36 | private static void postOnAnimationJellyBean(View view, Runnable runnable) {
37 | view.postOnAnimation(runnable);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/view_module_photoview/src/main/java/com/from/view/photoview/Util.java:
--------------------------------------------------------------------------------
1 | package com.from.view.photoview;
2 |
3 | import android.view.MotionEvent;
4 | import android.widget.ImageView;
5 |
6 | class Util {
7 |
8 | static void checkZoomLevels(float minZoom, float midZoom,
9 | float maxZoom) {
10 | if (minZoom >= midZoom) {
11 | throw new IllegalArgumentException(
12 | "Minimum zoom has to be less than Medium zoom. Call setMinimumZoom() with a more appropriate value");
13 | } else if (midZoom >= maxZoom) {
14 | throw new IllegalArgumentException(
15 | "Medium zoom has to be less than Maximum zoom. Call setMaximumZoom() with a more appropriate value");
16 | }
17 | }
18 |
19 | static boolean hasDrawable(ImageView imageView) {
20 | return imageView.getDrawable() != null;
21 | }
22 |
23 | static boolean isSupportedScaleType(final ImageView.ScaleType scaleType) {
24 | if (scaleType == null) {
25 | return false;
26 | }
27 | switch (scaleType) {
28 | case MATRIX:
29 | throw new IllegalStateException("Matrix scale type is not supported");
30 | }
31 | return true;
32 | }
33 |
34 | static int getPointerIndex(int action) {
35 | return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/AppModuleProvideExtrasFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import com.from.business.http.cache.Cache;
4 | import com.from.business.http.utils.Preconditions;
5 |
6 | import javax.inject.Provider;
7 |
8 | import dagger.internal.Factory;
9 |
10 |
11 | public final class AppModuleProvideExtrasFactory implements Factory> {
12 | private final Provider cacheFactoryProvider;
13 |
14 | public AppModuleProvideExtrasFactory(Provider cacheFactoryProvider) {
15 | this.cacheFactoryProvider = cacheFactoryProvider;
16 | }
17 |
18 | @Override
19 | public Cache get() {
20 | return provideInstance(cacheFactoryProvider);
21 | }
22 |
23 | public static Cache provideInstance(
24 | Provider cacheFactoryProvider) {
25 | return proxyProvideExtras(cacheFactoryProvider.get());
26 | }
27 |
28 | public static AppModuleProvideExtrasFactory create(
29 | Provider cacheFactoryProvider) {
30 | return new AppModuleProvideExtrasFactory(cacheFactoryProvider);
31 | }
32 |
33 | public static Cache proxyProvideExtras(Cache.Factory cacheFactory) {
34 | return Preconditions.checkNotNull(
35 | AppModule.provideExtras(cacheFactory),
36 | "Cannot return null from a non-@Nullable @Provides method");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/layout/maven_picture_item_images_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
26 |
27 |
28 |
36 |
37 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/AppModule.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 |
8 | import com.from.business.http.cache.Cache;
9 | import com.from.business.http.cache.CacheType;
10 | import com.from.business.http.integration.IRepositoryManager;
11 | import com.from.business.http.integration.RepositoryManager;
12 | import com.google.gson.Gson;
13 | import com.google.gson.GsonBuilder;
14 |
15 | /**
16 | * ================================================
17 | * 提供一些框架必须的实例的 {@link }
18 | *
19 | * ================================================
20 | */
21 | public abstract class AppModule {
22 | static Gson provideGson(Application application, @Nullable GsonConfiguration configuration) {
23 | GsonBuilder builder = new GsonBuilder();
24 | if (configuration != null)
25 | configuration.configGson(application, builder);
26 | return builder.create();
27 | }
28 |
29 | abstract IRepositoryManager bindRepositoryManager(RepositoryManager repositoryManager);
30 |
31 | static Cache provideExtras(Cache.Factory cacheFactory) {
32 | return cacheFactory.build(CacheType.EXTRAS);
33 | }
34 |
35 | public interface GsonConfiguration {
36 | void configGson(@NonNull Context context, @NonNull GsonBuilder builder);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/utils/PopUtils.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.icu.util.VersionInfo;
6 | import android.support.v4.app.FragmentManager;
7 |
8 | import me.businesscomponent.view.TipDialog;
9 |
10 | /**
11 | * 弹窗管理类
12 | *
13 | * @author : ym.li
14 | * @version : v2.6.0
15 | * @since : 2018/9/3/003
16 | */
17 | public class PopUtils {
18 | private PopUtils() {
19 |
20 | }
21 |
22 | public static TipDialog getTipDialog(Context context, boolean cancelable) {
23 | return new TipDialog.Builder(context)
24 | .setIconType(TipDialog.Builder.ICON_TYPE_LOADING)
25 | .create(cancelable);
26 | }
27 |
28 | /**
29 | * 获取菊花形状Dialog
30 | *
31 | * @param context 上下文
32 | * @return 返回TipDialog
33 | */
34 | public static TipDialog getTipDialog(Context context) {
35 | return getTipDialog(context, true);
36 | }
37 |
38 | /**
39 | * 获取带文字提示的菊花形状Dialog
40 | *
41 | * @param context 上下文
42 | * @param word 提示文字
43 | * @param iconType icon类型
44 | * @return 返回TipDialog
45 | */
46 | public static TipDialog getTipDialog(Context context, CharSequence word, @TipDialog.Builder.IconType int iconType) {
47 | return new TipDialog
48 | .Builder(context)
49 | .setIconType(iconType)
50 | .setTipWord(word)
51 | .create();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/util/ViscousFluidInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.util;
2 |
3 | import android.view.animation.Interpolator;
4 |
5 | public class ViscousFluidInterpolator implements Interpolator {
6 | /** Controls the viscous fluid effect (how much of it). */
7 | private static final float VISCOUS_FLUID_SCALE = 8.0f;
8 |
9 | private static final float VISCOUS_FLUID_NORMALIZE;
10 | private static final float VISCOUS_FLUID_OFFSET;
11 |
12 | static {
13 | // must be set to 1.0 (used in viscousFluid())
14 | VISCOUS_FLUID_NORMALIZE = 1.0f / viscousFluid(1.0f);
15 | // account for very small floating-point error
16 | VISCOUS_FLUID_OFFSET = 1.0f - VISCOUS_FLUID_NORMALIZE * viscousFluid(1.0f);
17 | }
18 |
19 | private static float viscousFluid(float x) {
20 | x *= VISCOUS_FLUID_SCALE;
21 | if (x < 1.0f) {
22 | x -= (1.0f - (float)Math.exp(-x));
23 | } else {
24 | float start = 0.36787944117f; // 1/e == exp(-1)
25 | x = 1.0f - (float)Math.exp(1.0f - x);
26 | x = start + x * (1.0f - start);
27 | }
28 | return x;
29 | }
30 |
31 | @Override
32 | public float getInterpolation(float input) {
33 | final float interpolated = VISCOUS_FLUID_NORMALIZE * viscousFluid(input);
34 | if (interpolated > 0) {
35 | return interpolated + VISCOUS_FLUID_OFFSET;
36 | }
37 | return interpolated;
38 | }
39 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BusinessComponent
2 |
3 | ### 介绍
4 | 整理 Android 最需要的 Lib 库,本着单一,less is more 原则。构建 Android 开发基础建设
5 |
6 |
7 | ### library 说明
8 |
9 | 1. [http 网络加载库 business_module_http](https://github.com/xwc520/BusinessComponent/tree/master/business_module_http)
10 | 2. [photoView](https://github.com/xwc520/BusinessComponent/tree/master/view_module_photoview)
11 | 3. [刷新和加载更多 view_module_refresh](https://github.com/xwc520/BusinessComponent/tree/master/view_module_refresh)
12 | 4. [0侵入侧滑返回 view_module_swipeback](https://github.com/xwc520/BusinessComponent/tree/master/view_module_swipeback)
13 | 5. [高仿微信图片选择 view_module_picture](https://github.com/xwc520/BusinessComponent/tree/master/view_module_picture)
14 |
15 | #### 参与贡献
16 | 1. [Vea](https://github.com/xwc520)
17 | 2. [MichaelJokAr](https://github.com/MichaelJokAr)
18 |
19 | ### 公众号
20 |
21 |
22 | ## License
23 | ```
24 | Copyright 2018, Vea
25 |
26 | Licensed under the Apache License, Version 2.0 (the "License");
27 | you may not use this file except in compliance with the License.
28 | You may obtain a copy of the License at
29 |
30 | http://www.apache.org/licenses/LICENSE-2.0
31 |
32 | Unless required by applicable law or agreed to in writing, software
33 | distributed under the License is distributed on an "AS IS" BASIS,
34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 | See the License for the specific language governing permissions and
36 | limitations under the License.
37 | ```
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/retrofiturlmanager/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.from.business.http.retrofiturlmanager;
17 |
18 | import okhttp3.HttpUrl;
19 |
20 | /**
21 | * ================================================
22 | * 工具类
23 | *
24 | * Created by JessYan on 2017/7/24.
25 | * Contact me
26 | * Follow me
27 | * ================================================
28 | */
29 | class Utils {
30 |
31 | private Utils() {
32 | throw new IllegalStateException("do not instantiation me");
33 | }
34 |
35 | static HttpUrl checkUrl(String url) {
36 | HttpUrl parseUrl = HttpUrl.parse(url);
37 | if (null == parseUrl) {
38 | throw new InvalidUrlException(url);
39 | } else {
40 | return parseUrl;
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/layout/maven_picture_select_image_bottom_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
24 |
25 |
36 |
37 |
--------------------------------------------------------------------------------
/business_module_http/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: "../common_component_build.gradle"
2 | android {
3 | compileOptions {
4 | targetCompatibility JavaVersion.VERSION_1_8
5 | sourceCompatibility JavaVersion.VERSION_1_8
6 | }
7 |
8 | }
9 | dependencies {
10 |
11 | //rx
12 | api rootProject.ext.dependencies["rxjava2"]
13 | api(rootProject.ext.dependencies["rxandroid2"]) {
14 | exclude module: 'rxjava'
15 | }
16 | api(rootProject.ext.dependencies["rxcache2"]) {
17 | exclude module: 'rxjava'
18 | exclude module: 'dagger'
19 | exclude module: 'api'
20 | }
21 | implementation(rootProject.ext.dependencies["rxcache-jolyglot-gson"]) {
22 | exclude module: 'gson'
23 | }
24 |
25 | api rootProject.ext.dependencies['rxerrorhandler2']
26 |
27 | //network
28 | api(rootProject.ext.dependencies["retrofit"]) {
29 | exclude module: 'okhttp'
30 | exclude module: 'okio'
31 | }
32 | implementation(rootProject.ext.dependencies["retrofit-converter-gson"]) {
33 | exclude module: 'gson'
34 | exclude module: 'okhttp'
35 | exclude module: 'okio'
36 | exclude module: 'retrofit'
37 | }
38 | implementation(rootProject.ext.dependencies["retrofit-adapter-rxjava2"]) {
39 | exclude module: 'rxjava'
40 | exclude module: 'okhttp'
41 | exclude module: 'retrofit'
42 | exclude module: 'okio'
43 | }
44 | api rootProject.ext.dependencies["okhttp3"]
45 | api rootProject.ext.dependencies["gson"]
46 | api "javax.inject:javax.inject:1"
47 | compileOnly 'com.uber.autodispose:autodispose-android:1.1.0'
48 | }
49 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleCacheFileFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.app.Application;
4 |
5 | import com.from.business.http.utils.Preconditions;
6 |
7 | import java.io.File;
8 |
9 | import javax.inject.Provider;
10 |
11 | import dagger.internal.Factory;
12 |
13 |
14 | public final class HttpConfigModuleCacheFileFactory implements Factory {
15 | private final HttpConfigModule module;
16 | private final Provider applicationProvider;
17 |
18 | public HttpConfigModuleCacheFileFactory(
19 | HttpConfigModule module, Provider applicationProvider) {
20 | this.module = module;
21 | this.applicationProvider = applicationProvider;
22 | }
23 |
24 | @Override
25 | public File get() {
26 | return provideInstance(module, applicationProvider);
27 | }
28 |
29 | public static File provideInstance(
30 | HttpConfigModule module, Provider applicationProvider) {
31 | return proxyProvideCacheFile(module, applicationProvider.get());
32 | }
33 |
34 | public static HttpConfigModuleCacheFileFactory create(
35 | HttpConfigModule module, Provider applicationProvider) {
36 | return new HttpConfigModuleCacheFileFactory(module, applicationProvider);
37 | }
38 |
39 | public static File proxyProvideCacheFile(HttpConfigModule instance, Application application) {
40 | return Preconditions.checkNotNull(
41 | instance.provideCacheFile(application),
42 | "Cannot return null from a non-@Nullable @Provides method");
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/retrofiturlmanager/parser/UrlParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.from.business.http.retrofiturlmanager.parser;
17 |
18 | import com.from.business.http.retrofiturlmanager.RetrofitUrlManager;
19 |
20 | import okhttp3.HttpUrl;
21 | import okhttp3.Request;
22 |
23 | /**
24 | * ================================================
25 | * Url解析器
26 | *
27 | * Created by JessYan on 17/07/2017 17:44
28 | * ================================================
29 | */
30 | public interface UrlParser {
31 | /**
32 | * 这里可以做一些初始化操作
33 | *
34 | * @param retrofitUrlManager {@link RetrofitUrlManager}
35 | */
36 | void init(RetrofitUrlManager retrofitUrlManager);
37 |
38 | /**
39 | * 将 {@link RetrofitUrlManager#mDomainNameHub} 中映射的 URL 解析成完整的{@link HttpUrl}
40 | * 用来替换 @{@link Request#url} 达到动态切换 URL
41 | *
42 | * @param domainUrl 用于替换的 URL 地址
43 | * @param url 旧 URL 地址
44 | * @return
45 | */
46 | HttpUrl parseUrl(HttpUrl domainUrl, HttpUrl url);
47 | }
48 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/internal/Preconditions.java:
--------------------------------------------------------------------------------
1 | //
2 | // Source code recreated from a .class file by IntelliJ IDEA
3 | // (powered by Fernflower decompiler)
4 | //
5 |
6 | package dagger.internal;
7 |
8 | public final class Preconditions {
9 | public static T checkNotNull(T reference) {
10 | if (reference == null) {
11 | throw new NullPointerException();
12 | } else {
13 | return reference;
14 | }
15 | }
16 |
17 | public static T checkNotNull(T reference, String errorMessage) {
18 | if (reference == null) {
19 | throw new NullPointerException(errorMessage);
20 | } else {
21 | return reference;
22 | }
23 | }
24 |
25 | public static T checkNotNull(T reference, String errorMessageTemplate, Object errorMessageArg) {
26 | if (reference == null) {
27 | if (!errorMessageTemplate.contains("%s")) {
28 | throw new IllegalArgumentException("errorMessageTemplate has no format specifiers");
29 | } else if (errorMessageTemplate.indexOf("%s") != errorMessageTemplate.lastIndexOf("%s")) {
30 | throw new IllegalArgumentException("errorMessageTemplate has more than one format specifier");
31 | } else {
32 | String argString = errorMessageArg instanceof Class ? ((Class)errorMessageArg).getCanonicalName() : String.valueOf(errorMessageArg);
33 | throw new NullPointerException(errorMessageTemplate.replace("%s", argString));
34 | }
35 | } else {
36 | return reference;
37 | }
38 | }
39 |
40 | private Preconditions() {
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/utils/UrlEncoderUtils.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.utils;
2 |
3 | /**
4 | * ================================================
5 | * Created by JessYan on 2018/9/14 14:10
6 | * ================================================
7 | */
8 | public class UrlEncoderUtils {
9 |
10 | private UrlEncoderUtils() {
11 | throw new IllegalStateException("you can't instantiate me!");
12 | }
13 |
14 | /**
15 | * 判断 str 是否已经 URLEncoder.encode() 过
16 | * 经常遇到这样的情况, 拿到一个 URL, 但是搞不清楚到底要不要 URLEncoder.encode()
17 | * 不做 URLEncoder.encode() 吧, 担心出错, 做 URLEncoder.encode() 吧, 又怕重复了
18 | *
19 | * @param str 需要判断的内容
20 | * @return 返回 {@code true} 为被 URLEncoder.encode() 过
21 | */
22 | public static boolean hasUrlEncoded(String str) {
23 | boolean encode = false;
24 | for (int i = 0; i < str.length(); i++) {
25 | char c = str.charAt(i);
26 | if (c == '%' && (i + 2) < str.length()) {
27 | // 判断是否符合urlEncode规范
28 | char c1 = str.charAt(i + 1);
29 | char c2 = str.charAt(i + 2);
30 | if (isValidHexChar(c1) && isValidHexChar(c2)) {
31 | encode = true;
32 | break;
33 | } else {
34 | break;
35 | }
36 | }
37 | }
38 | return encode;
39 | }
40 |
41 | /**
42 | * 判断 c 是否是 16 进制的字符
43 | *
44 | * @param c 需要判断的字符
45 | * @return 返回 {@code true} 为 16 进制的字符
46 | */
47 | private static boolean isValidHexChar(char c) {
48 | return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F');
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/MembersInjector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Dagger Authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dagger;
17 |
18 | /**
19 | * Injects dependencies into the fields and methods on instances of type {@code T}. Ignores the
20 | * presence or absence of an injectable constructor.
21 | *
22 | * @param type to inject members of
23 | *
24 | * @since 2.0 (since 1.0 without the provision that {@link #injectMembers} cannot accept
25 | * {@code null})
26 | */
27 | public interface MembersInjector {
28 |
29 | /**
30 | * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or
31 | * absence of an injectable constructor.
32 | *
33 | * Whenever a {@link Component} creates an instance, it performs this injection automatically
34 | * (after first performing constructor injection), so if you're able to let the component create
35 | * all your objects for you, you'll never need to use this method.
36 | *
37 | * @param instance into which members are to be injected
38 | * @throws NullPointerException if {@code instance} is {@code null}
39 | */
40 | void injectMembers(T instance);
41 | }
42 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/http/HttpConfigModuleCacheFactoryFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module.http;
2 |
3 | import android.app.Application;
4 |
5 | import com.from.business.http.cache.Cache;
6 | import com.from.business.http.utils.Preconditions;
7 |
8 | import javax.inject.Provider;
9 |
10 | import dagger.internal.Factory;
11 |
12 |
13 | public final class HttpConfigModuleCacheFactoryFactory implements Factory {
14 | private final HttpConfigModule module;
15 | private final Provider applicationProvider;
16 |
17 | public HttpConfigModuleCacheFactoryFactory(
18 | HttpConfigModule module, Provider applicationProvider) {
19 | this.module = module;
20 | this.applicationProvider = applicationProvider;
21 | }
22 |
23 | @Override
24 | public Cache.Factory get() {
25 | return provideInstance(module, applicationProvider);
26 | }
27 |
28 | public static Cache.Factory provideInstance(
29 | HttpConfigModule module, Provider applicationProvider) {
30 | return proxyProvideCacheFactory(module, applicationProvider.get());
31 | }
32 |
33 | public static HttpConfigModuleCacheFactoryFactory create(
34 | HttpConfigModule module, Provider applicationProvider) {
35 | return new HttpConfigModuleCacheFactoryFactory(module, applicationProvider);
36 | }
37 |
38 | public static Cache.Factory proxyProvideCacheFactory(
39 | HttpConfigModule instance, Application application) {
40 | return Preconditions.checkNotNull(
41 | instance.provideCacheFactory(application),
42 | "Cannot return null from a non-@Nullable @Provides method");
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/me/businesscomponent/activity/HttpExampleActivity.java:
--------------------------------------------------------------------------------
1 | package me.businesscomponent.activity;
2 |
3 | import android.arch.lifecycle.Lifecycle;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 |
8 | import com.from.business.http.retrofiturlmanager.RetrofitUrlManager;
9 | import com.uber.autodispose.AutoDisposeConverter;
10 |
11 | import me.businesscomponent.BaseApplication;
12 | import me.businesscomponent.utils.PopUtils;
13 | import me.businesscomponent.utils.RxLifecycleUtils;
14 | import timber.log.Timber;
15 |
16 | import static me.businesscomponent.http.GankService.GANK_DOMAIN;
17 | import static me.businesscomponent.http.GankService.GANK_DOMAIN_NAME;
18 |
19 | /**
20 | * @author Vea
21 | * @since 2019-01-16
22 | */
23 | public class HttpExampleActivity extends AppCompatActivity {
24 |
25 | private HttpPresenterOrViewModel pm;
26 |
27 | @Override
28 | protected void onCreate(@Nullable Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 |
31 | RetrofitUrlManager.getInstance().putDomain(GANK_DOMAIN_NAME, GANK_DOMAIN);
32 |
33 | pm = new HttpPresenterOrViewModel();
34 | pm.setLifecycle(getLifecycle());
35 |
36 | pm.getUserList(PopUtils.getTipDialog(this));
37 | pm.getGirlList();
38 |
39 | }
40 |
41 | public AutoDisposeConverter bindLifecycle() {
42 | return RxLifecycleUtils.bindLifecycle(this);
43 | }
44 |
45 |
46 | @Override
47 | protected void onStop() {
48 | super.onStop();
49 | Lifecycle.State currentState = getLifecycle().getCurrentState();
50 | Timber.tag(BaseApplication.TAG).d("stop:" + currentState.name());
51 | pm.stop();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/layout/maven_picture_select_image_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
41 |
--------------------------------------------------------------------------------
/view_module_swipeback/README.md:
--------------------------------------------------------------------------------
1 | # view_module_swipeback
2 |
3 | [  ](https://bintray.com/xwc/AndroidLibrary/view_module_swipeback/1.0.3/link)
4 |
5 | ### 介绍
6 | 无需继承和实现,侧滑只需一步,0接入成本,已适配Android 9P ,透明主题。
7 |
8 | #### 特性
9 | - 自动检索是否第一个Activity
10 | - 两种方式配置不需要侧滑Activity,使用 SwipeOptions 集中配置,或 Activity 实现接口 ISwipeBack 接口
11 | - 支持 9P 和 windowIsTranslucent 透明主题
12 | - 适配日夜间模式切换
13 |
14 | #### 预览
15 |
16 |
17 | #### 使用
18 | 1.引入 Module 或 gradle
19 | ```
20 | implementation 'com.from.view.swipeback:view_module_swipeback:1.0.6'
21 | ```
22 |
23 | 2.在 Application 初始化
24 | ```
25 | SwipeBackHelper.init(this);
26 | ```
27 | 3.配置项目(默认无需配置)
28 | ```
29 | SwipeOptions options = SwipeOptions.builder()
30 | .exclude(exclude) // 排除不需要侧滑的类
31 | // 以下默认值
32 | // .isWeChatStyle(true) // 是否是微信滑动返回样式
33 | // .isTrackingLeftEdge(true) // 是否仅仅跟踪左侧边缘的滑动返回
34 | // .isShadowAlphaGradient(true) // 阴影区域的透明度是否根据滑动的距离渐变
35 | // .isNavigationBarOverlap(false) // 底部导航条是否悬浮在内容上
36 | // .isNeedShowShadow(true) // 否显示滑动返回的阴影效果
37 | // .shadowResId() // 阴影资源 id
38 | .build();
39 | ```
40 | 4.动态控制是否需要侧滑(默认无需配置)
41 | ```
42 | public class TestActivity extends AppCompatActivity implements ISwipeBack {
43 | // 实现 ISwipeBack 接口,在某种情况下控制 isEnableGesture 函数返回值
44 | // 动态的支配是否开启侧滑
45 | @Override
46 | public boolean isEnableGesture() {
47 | return true;
48 | }
49 | }
50 | ```
51 |
52 | 值得注意的是,初始化之后你所使用的依赖库中的 Activity 也会拥有侧滑的能力.
53 | 不过你可使用 option 剔除,如你正好需要也可以保留
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Dagger Authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dagger;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | import dagger.internal.Beta;
25 |
26 | /**
27 | * Annotates a class that contributes to the object graph.
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(ElementType.TYPE)
31 | public @interface Module {
32 | /**
33 | * Additional {@code @Module}-annotated classes from which this module is
34 | * composed. The de-duplicated contributions of the modules in
35 | * {@code includes}, and of their inclusions recursively, are all contributed
36 | * to the object graph.
37 | */
38 | Class>[] includes() default {};
39 |
40 | /**
41 | * Any {@link Subcomponent}- or {@code @ProductionSubcomponent}-annotated classes which should be
42 | * children of the component in which this module is installed. A subcomponent may be listed in
43 | * more than one module in a component.
44 | *
45 | * @since 2.7
46 | */
47 | @Beta
48 | Class>[] subcomponents() default {};
49 | }
50 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/internal/ArrowDrawable.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.internal;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Path;
5 | import android.graphics.Rect;
6 | import android.graphics.drawable.Drawable;
7 | import android.support.annotation.NonNull;
8 |
9 | /**
10 | * 箭头图像
11 | * Created by SCWANG on 2018/2/5.
12 | */
13 |
14 | public class ArrowDrawable extends PaintDrawable {
15 |
16 | private int mWidth = 0;
17 | private int mHeight = 0;
18 | private Path mPath = new Path();
19 |
20 | @Override
21 | public void draw(@NonNull Canvas canvas) {
22 | final Drawable drawable = ArrowDrawable.this;
23 | final Rect bounds = drawable.getBounds();
24 | int width = bounds.width();
25 | int height = bounds.height();
26 | if (mWidth != width || mHeight != height) {
27 | int lineWidth = width * 30 / 225;
28 | mPath.reset();
29 |
30 | float vector1 = (float) (lineWidth * Math.sin(Math.PI/4));
31 | float vector2 = (float) (lineWidth / Math.sin(Math.PI/4));
32 | mPath.moveTo(width / 2, height);
33 | mPath.lineTo(0, height / 2);
34 | mPath.lineTo(vector1, height / 2 - vector1);
35 | mPath.lineTo(width / 2 - lineWidth / 2, height - vector2 - lineWidth / 2);
36 | mPath.lineTo(width / 2 - lineWidth / 2, 0);
37 | mPath.lineTo(width / 2 + lineWidth / 2, 0);
38 | mPath.lineTo(width / 2 + lineWidth / 2, height - vector2 - lineWidth / 2);
39 | mPath.lineTo(width - vector1, height / 2 - vector1);
40 | mPath.lineTo(width, height / 2);
41 | mPath.close();
42 |
43 | mWidth = width;
44 | mHeight = height;
45 | }
46 | canvas.drawPath(mPath, mPaint);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
28 |
29 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/retrofiturlmanager/onUrlChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.from.business.http.retrofiturlmanager;
17 |
18 | import okhttp3.HttpUrl;
19 |
20 | /**
21 | * ================================================
22 | * Url 监听器
23 | *
24 | * Created by JessYan on 20/07/2017 14:18
25 | * Contact me
26 | * Follow me
27 | * ================================================
28 | */
29 | public interface onUrlChangeListener {
30 |
31 | /**
32 | * 此方法在框架使用 {@code domainName} 作为 key,从 {@link RetrofitUrlManager#mDomainNameHub}
33 | * 中取出对应的 BaseUrl 构建新的 Url 之前会被调用
34 | *
35 | * 可以使用此回调确保 {@link RetrofitUrlManager#mDomainNameHub} 中是否已经存在自己期望的 BaseUrl
36 | * 如果不存在可以在此方法中进行 {@link RetrofitUrlManager#putDomain(String, String)}
37 | *
38 | * @param oldUrl
39 | * @param domainName
40 | */
41 | void onUrlChangeBefore(HttpUrl oldUrl, String domainName);
42 |
43 | /**
44 | * 当 Url 的 BaseUrl 被切换时回调
45 | * 调用时间是在接口请求服务器之前
46 | *
47 | * @param newUrl
48 | * @param oldUrl
49 | */
50 | void onUrlChanged(HttpUrl newUrl, HttpUrl oldUrl);
51 | }
52 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/PictureSelector.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 |
8 | import com.from.view.picture.ui.SelectImageActivity;
9 |
10 | import java.lang.ref.WeakReference;
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Doc 图片选择器入口
15 | *
16 | * @author ym.li
17 | * @version 2.9.0
18 | * @since 2018/11/2/002
19 | */
20 | public class PictureSelector {
21 | private WeakReference mActivity;
22 | private WeakReference mFragment;
23 |
24 | private PictureSelector(Activity activity) {
25 | this(activity, null);
26 | }
27 |
28 | public PictureSelector(Activity activity, Fragment fragment) {
29 | this.mActivity = new WeakReference<>(activity);
30 | this.mFragment = new WeakReference<>(fragment);
31 | }
32 |
33 | private PictureSelector(Fragment fragment) {
34 | this(fragment.getActivity(), fragment);
35 | }
36 |
37 | public static PictureSelector with(Fragment fragment) {
38 | return new PictureSelector(fragment);
39 | }
40 |
41 | public static PictureSelector with(Activity activity) {
42 | return new PictureSelector(activity);
43 | }
44 |
45 | public static ArrayList obtainPathResult(Intent data) {
46 | return data.getStringArrayListExtra(SelectImageActivity.RESULT_IMAGES);
47 | }
48 |
49 | public SelectorSpec selectSpec() {
50 | return SelectorSpec.getCleanInstance().withPictureSelector(this);
51 | }
52 |
53 | @Nullable
54 | Activity getActivity() {
55 | return mActivity.get();
56 | }
57 |
58 | @Nullable
59 | Fragment getFragment() {
60 | return mFragment != null ? mFragment.get() : null;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
15 |
21 |
22 |
23 |
38 |
39 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/AppModuleProvideGsonFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import android.app.Application;
4 |
5 | import com.from.business.http.utils.Preconditions;
6 | import com.google.gson.Gson;
7 |
8 | import javax.inject.Provider;
9 |
10 | import dagger.internal.Factory;
11 |
12 |
13 | public final class AppModuleProvideGsonFactory implements Factory {
14 | private final Provider applicationProvider;
15 | private final Provider configurationProvider;
16 |
17 | public AppModuleProvideGsonFactory(
18 | Provider applicationProvider,
19 | Provider configurationProvider) {
20 | this.applicationProvider = applicationProvider;
21 | this.configurationProvider = configurationProvider;
22 | }
23 |
24 | @Override
25 | public Gson get() {
26 | return provideInstance(applicationProvider, configurationProvider);
27 | }
28 |
29 | public static Gson provideInstance(
30 | Provider applicationProvider,
31 | Provider configurationProvider) {
32 | return proxyProvideGson(applicationProvider.get(), configurationProvider.get());
33 | }
34 |
35 | public static AppModuleProvideGsonFactory create(
36 | Provider applicationProvider,
37 | Provider configurationProvider) {
38 | return new AppModuleProvideGsonFactory(applicationProvider, configurationProvider);
39 | }
40 |
41 | public static Gson proxyProvideGson(
42 | Application application, AppModule.GsonConfiguration configuration) {
43 | return Preconditions.checkNotNull(
44 | AppModule.provideGson(application, configuration),
45 | "Cannot return null from a non-@Nullable @Provides method");
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/lifecycle/LifecycleScopeProvider.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.lifecycle;
2 |
3 | import com.uber.autodispose.ScopeProvider;
4 | import com.uber.autodispose.internal.DoNotMock;
5 |
6 | import io.reactivex.Completable;
7 | import io.reactivex.CompletableSource;
8 | import io.reactivex.Observable;
9 | import io.reactivex.annotations.CheckReturnValue;
10 | import io.reactivex.annotations.Nullable;
11 |
12 | /**
13 | * A convenience interface that, when implemented, helps provide information to create {@link
14 | * ScopeProvider} implementations that resolve the next corresponding lifecycle event and construct
15 | * a {@link Completable} representation of it from the {@link #lifecycle()} stream.
16 | *
17 | * Convenience resolver utilities for this can be found in {@link LifecycleScopes}.
18 | *
19 | * @param the lifecycle event type.
20 | * @see LifecycleScopes
21 | */
22 | @DoNotMock(value = "Use TestLifecycleScopeProvider instead")
23 | public interface LifecycleScopeProvider extends ScopeProvider {
24 |
25 | /**
26 | * @return a sequence of lifecycle events. Note that completion of this lifecycle will also
27 | * trigger disposal
28 | */
29 | @CheckReturnValue Observable lifecycle();
30 |
31 | /**
32 | * @return a sequence of lifecycle events. It's recommended to back this with a static instance to
33 | * avoid unnecessary object allocation.
34 | */
35 | @CheckReturnValue CorrespondingEventsFunction correspondingEvents();
36 |
37 | /**
38 | * @return the last seen lifecycle event, or {@code null} if none. Note that is {@code null} is
39 | * returned at subscribe-time, it will be used as a signal to throw a {@link
40 | * LifecycleNotStartedException}.
41 | */
42 | @Nullable E peekLifecycle();
43 |
44 | @Override default CompletableSource requestScope() {
45 | return LifecycleScopes.resolveScopeFromLifecycle(this);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/util/DesignUtil.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.util;
2 |
3 | import android.support.design.widget.AppBarLayout;
4 | import android.support.design.widget.CoordinatorLayout;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.from.view.refresh.api.RefreshKernel;
9 | import com.from.view.refresh.listener.CoordinatorLayoutListener;
10 |
11 | /**
12 | * Design 兼容包缺省尝试
13 | * Created by SCWANG on 2018/1/29.
14 | */
15 |
16 | public class DesignUtil {
17 |
18 | public static void checkCoordinatorLayout(View content, RefreshKernel kernel, CoordinatorLayoutListener listener) {
19 | try {//try 不能删除,不然会出现兼容性问题
20 | if (content instanceof CoordinatorLayout) {
21 | kernel.getRefreshLayout().setEnableNestedScroll(false);
22 | wrapperCoordinatorLayout(((ViewGroup) content)/*, kernel.getRefreshLayout()*/,listener);
23 | }
24 | } catch (Throwable ignored) {
25 | }
26 | }
27 |
28 | private static void wrapperCoordinatorLayout(ViewGroup layout/*, final RefreshLayout refreshLayout*/, final CoordinatorLayoutListener listener) {
29 | for (int i = layout.getChildCount() - 1; i >= 0; i--) {
30 | View view = layout.getChildAt(i);
31 | if (view instanceof AppBarLayout) {
32 | ((AppBarLayout) view).addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
33 | @Override
34 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
35 | listener.onCoordinatorUpdate(
36 | verticalOffset >= 0,
37 | /*refreshLayout.isEnableLoadMore() && */
38 | (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0);
39 | }
40 | });
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/res/layout/maven_picture_activity_preview_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
15 |
21 |
22 |
30 |
43 |
44 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/module/ClientModuleProRxErrorHandlerFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.module;
2 |
3 | import android.app.Application;
4 |
5 | import javax.inject.Provider;
6 |
7 | import dagger.internal.Factory;
8 | import me.jessyan.rxerrorhandler.core.RxErrorHandler;
9 | import me.jessyan.rxerrorhandler.handler.listener.ResponseErrorListener;
10 |
11 | import static com.from.business.http.utils.Preconditions.checkNotNull;
12 |
13 | public final class ClientModuleProRxErrorHandlerFactory implements Factory {
14 | private final Provider applicationProvider;
15 | private final Provider listenerProvider;
16 |
17 | public ClientModuleProRxErrorHandlerFactory(
18 | Provider applicationProvider, Provider listenerProvider) {
19 | this.applicationProvider = applicationProvider;
20 | this.listenerProvider = listenerProvider;
21 | }
22 |
23 | @Override
24 | public RxErrorHandler get() {
25 | return provideInstance(applicationProvider, listenerProvider);
26 | }
27 |
28 | public static RxErrorHandler provideInstance(
29 | Provider applicationProvider, Provider listenerProvider) {
30 | return proxyProRxErrorHandler(applicationProvider.get(), listenerProvider.get());
31 | }
32 |
33 | public static ClientModuleProRxErrorHandlerFactory create(
34 | Provider applicationProvider, Provider listenerProvider) {
35 | return new ClientModuleProRxErrorHandlerFactory(applicationProvider, listenerProvider);
36 | }
37 |
38 | public static RxErrorHandler proxyProRxErrorHandler(
39 | Application application, ResponseErrorListener listener) {
40 | return checkNotNull(ClientModule.proRxErrorHandler(application, listener),
41 | "Cannot return null from a non-@Nullable @Provides method");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/imageloader/GlideImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.imageloader;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.bumptech.glide.Glide;
6 | import com.bumptech.glide.request.RequestOptions;
7 |
8 | /**
9 | * Doc 默认为Glide加载图片
10 | *
11 | * @author ym.li
12 | * @version 2.9.0
13 | * @since 2018/11/2/002
14 | */
15 | public class GlideImageLoader implements UIImageLoader {
16 | @Override
17 | public void imageLoader(ImageView imageView, String path, int height, int width, int defaultImage) {
18 | Glide.with(imageView.getContext())
19 | .asBitmap()
20 | .load(path)
21 | .apply(new RequestOptions()
22 | .placeholder(defaultImage)
23 | .error(defaultImage)
24 | .override(width, height))
25 | .into(imageView);
26 | }
27 |
28 | @Override
29 | public void imageLoader(ImageView imageView, String path, int height, int width) {
30 | Glide.with(imageView.getContext())
31 | .asBitmap()
32 | .load(path)
33 | .apply(new RequestOptions()
34 | .override(width, height))
35 | .into(imageView);
36 | }
37 |
38 | @Override
39 | public void imageLoader(ImageView imageView, String path, int defaultImage) {
40 | Glide.with(imageView.getContext())
41 | .asBitmap()
42 | .load(path)
43 | .apply(new RequestOptions()
44 | .placeholder(defaultImage)
45 | .error(defaultImage))
46 | .into(imageView);
47 | }
48 |
49 | @Override
50 | public void imageLoader(ImageView imageView, String path) {
51 | Glide.with(imageView.getContext())
52 | .asBitmap()
53 | .load(path)
54 | .apply(new RequestOptions())
55 | .into(imageView);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/constant/DimensionStatus.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.constant;
2 |
3 | /**
4 | * 尺寸值的定义状态,用于在值覆盖的时候决定优先级
5 | * 越往下优先级越高
6 | */
7 | public enum DimensionStatus {
8 | DefaultUnNotify(false),//默认值,但是还没通知确认
9 | Default(true),//默认值
10 | XmlWrapUnNotify(false),//Xml计算,但是还没通知确认
11 | XmlWrap(true),//Xml计算
12 | XmlExactUnNotify(false),//Xml 的view 指定,但是还没通知确认
13 | XmlExact(true),//Xml 的view 指定
14 | XmlLayoutUnNotify(false),//Xml 的layout 中指定,但是还没通知确认
15 | XmlLayout(true),//Xml 的layout 中指定
16 | CodeExactUnNotify(false),//代码指定,但是还没通知确认
17 | CodeExact(true),//代码指定
18 | DeadLockUnNotify(false),//锁死,但是还没通知确认
19 | DeadLock(true);//锁死
20 | public final boolean notified;
21 |
22 | DimensionStatus(boolean notified) {
23 | this.notified = notified;
24 | }
25 |
26 | /**
27 | * 转换为未通知状态
28 | * @return 未通知状态
29 | */
30 | public DimensionStatus unNotify() {
31 | if (notified) {
32 | DimensionStatus prev = values()[ordinal() - 1];
33 | if (!prev.notified) {
34 | return prev;
35 | }
36 | return DefaultUnNotify;
37 | }
38 | return this;
39 | }
40 |
41 | /**
42 | * 转换为通知状态
43 | * @return 通知状态
44 | */
45 | public DimensionStatus notified() {
46 | if (!notified) {
47 | return values()[ordinal() + 1];
48 | }
49 | return this;
50 | }
51 |
52 | /**
53 | * 是否可以被新的状态替换
54 | * @param status 新转台
55 | * @return 小于等于
56 | */
57 | public boolean canReplaceWith(DimensionStatus status) {
58 | return ordinal() < status.ordinal() || ((!notified || CodeExact == this) && ordinal() == status.ordinal());
59 | }
60 |
61 | // /**
62 | // * 是否没有达到新的状态
63 | // * @param status 新转台
64 | // * @return 大于等于 gte
65 | // */
66 | // public boolean gteStatusWith(DimensionStatus status) {
67 | // return ordinal() >= status.ordinal();
68 | // }
69 | }
--------------------------------------------------------------------------------
/view_module_picture/src/main/java/com/from/view/picture/data/DateFormatUtil.java:
--------------------------------------------------------------------------------
1 | package com.from.view.picture.data;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | import java.text.SimpleDateFormat;
6 | import java.util.Calendar;
7 | import java.util.Date;
8 |
9 | /**
10 | * Doc 时间转换
11 | *
12 | * @author ym.li
13 | * @version 2.9.0
14 | * @since 2018/11/12/012
15 | */
16 | public class DateFormatUtil {
17 | /**
18 | * 获取图片创建日期
19 | *
20 | * @param time 时间戳
21 | * @return 返回格式化后的时间
22 | */
23 | public static String getImageTime(long time) {
24 | Calendar calendar = Calendar.getInstance();
25 | calendar.setTime(new Date());
26 | Calendar imageTime = Calendar.getInstance();
27 | imageTime.setTimeInMillis(time);
28 | if (sameDay(calendar, imageTime)) {
29 | return "今天";
30 | } else if (sameWeek(calendar, imageTime)) {
31 | return "本周";
32 | } else if (sameMonth(calendar, imageTime)) {
33 | return "本月";
34 | } else {
35 | Date date = new Date(time);
36 | @SuppressLint("SimpleDateFormat")
37 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM");
38 | return sdf.format(date);
39 | }
40 | }
41 |
42 | private static boolean sameDay(Calendar calendar1, Calendar calendar2) {
43 | return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
44 | && calendar1.get(Calendar.DAY_OF_YEAR) == calendar2.get(Calendar.DAY_OF_YEAR);
45 | }
46 |
47 | private static boolean sameWeek(Calendar calendar1, Calendar calendar2) {
48 | return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
49 | && calendar1.get(Calendar.WEEK_OF_YEAR) == calendar2.get(Calendar.WEEK_OF_YEAR);
50 | }
51 |
52 | private static boolean sameMonth(Calendar calendar1, Calendar calendar2) {
53 | return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
54 | && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/constant/RefreshState.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.constant;
2 |
3 | /**
4 | * 刷新状态
5 | */
6 | @SuppressWarnings("unused")
7 | public enum RefreshState {
8 | None(0,false,false,false,false),
9 | PullDownToRefresh(1,true,false,false,false), PullUpToLoad(2,true,false,false,false),
10 | PullDownCanceled(1,false,false,false,false), PullUpCanceled(2,false,false,false,false),
11 | ReleaseToRefresh(1,true,false,false,false), ReleaseToLoad(2,true,false,false,false),
12 | ReleaseToTwoLevel(1,true,false,false,true), TwoLevelReleased(1,false,false,false,true),
13 | RefreshReleased(1,false,false,false,false), LoadReleased(2,false,false,false,false),
14 | Refreshing(1,false,true,false,false), Loading(2,false,true,false,false), TwoLevel(1, false, true,false,true),
15 | RefreshFinish(1,false,false,true,false), LoadFinish(2,false,false,true,false), TwoLevelFinish(1,false,false,true,true);
16 |
17 | public final boolean isHeader;
18 | public final boolean isFooter;
19 | public final boolean isTwoLevel;
20 | public final boolean isDragging;// 正在拖动状态:PullDownToRefresh PullUpToLoad ReleaseToRefresh ReleaseToLoad ReleaseToTwoLevel
21 | public final boolean isOpening;// 正在刷新状态:Refreshing Loading TwoLevel
22 | public final boolean isFinishing;//正在完成状态:RefreshFinish LoadFinish TwoLevelFinish
23 |
24 | RefreshState(int role, boolean dragging, boolean opening, boolean finishing, boolean twoLevel) {
25 | this.isHeader = role == 1;
26 | this.isFooter = role == 2;
27 | this.isDragging = dragging;
28 | this.isOpening = opening;
29 | this.isFinishing = finishing;
30 | this.isTwoLevel = twoLevel;
31 | }
32 |
33 | public RefreshState toFooter() {
34 | if (isHeader && !isTwoLevel) {
35 | return values()[ordinal() + 1];
36 | }
37 | return this;
38 | }
39 |
40 | public RefreshState toHeader() {
41 | if (isFooter && !isTwoLevel) {
42 | return values()[ordinal()-1];
43 | }
44 | return this;
45 | }
46 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "me.businesscomponent"
7 | minSdkVersion 15
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | targetCompatibility JavaVersion.VERSION_1_8
21 | sourceCompatibility JavaVersion.VERSION_1_8
22 | }
23 | configurations {
24 | all*.exclude module: 'androidx'
25 | }
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(include: ['*.jar'], dir: 'libs')
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 | debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
34 | releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
35 | debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.2'
36 | implementation "com.android.support.constraint:constraint-layout:$constraint_layout"
37 | implementation "com.android.support:appcompat-v7:$support_version"
38 | implementation "com.android.support:recyclerview-v7:$support_version"
39 | implementation "com.android.support:design:$support_version"
40 | implementation "com.github.bumptech.glide:glide:$glide_version"
41 | api project(':view_module_photoview')
42 | api project(':view_module_picture')
43 | api project(':view_module_refresh')
44 | api project(':view_module_swipeback')
45 | api project(':business_module_http')
46 | implementation 'com.jakewharton.timber:timber:4.7.1'
47 | implementation 'com.uber.autodispose:autodispose-android:1.1.0'
48 | }
49 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/retrofiturlmanager/cache/Cache.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.retrofiturlmanager.cache;
2 |
3 | import java.util.Set;
4 |
5 | /**
6 | * ================================================
7 | * 缓存
8 | *
9 | * @see LruCache
10 | * ================================================
11 | */
12 | public interface Cache {
13 | /**
14 | * 返回当前缓存已占用的总 size
15 | *
16 | * @return {@code size}
17 | */
18 | int size();
19 |
20 | /**
21 | * 返回当前缓存所能允许的最大 size
22 | *
23 | * @return {@code maxSize}
24 | */
25 | int getMaxSize();
26 |
27 | /**
28 | * 返回这个 {@code key} 在缓存中对应的 {@code value}, 如果返回 {@code null} 说明这个 {@code key} 没有对应的 {@code value}
29 | *
30 | * @param key {@code key}
31 | * @return {@code value}
32 | */
33 | V get(K key);
34 |
35 | /**
36 | * 将 {@code key} 和 {@code value} 以条目的形式加入缓存,如果这个 {@code key} 在缓存中已经有对应的 {@code value}
37 | * 则此 {@code value} 被新的 {@code value} 替换并返回,如果为 {@code null} 说明是一个新条目
38 | *
39 | * @param key {@code key}
40 | * @param value {@code value}
41 | * @return 如果这个 {@code key} 在容器中已经储存有 {@code value}, 则返回之前的 {@code value} 否则返回 {@code null}
42 | */
43 | V put(K key, V value);
44 |
45 | /**
46 | * 移除缓存中这个 {@code key} 所对应的条目,并返回所移除条目的 value
47 | * 如果返回为 {@code null} 则有可能时因为这个 {@code key} 对应的 value 为 {@code null} 或条目不存在
48 | *
49 | * @param key {@code key}
50 | * @return 如果这个 {@code key} 在容器中已经储存有 {@code value} 并且删除成功则返回删除的 {@code value}, 否则返回 {@code null}
51 | */
52 | V remove(K key);
53 |
54 | /**
55 | * 如果这个 {@code key} 在缓存中有对应的 value 并且不为 {@code null}, 则返回 {@code true}
56 | *
57 | * @param key {@code key}
58 | * @return {@code true} 为在容器中含有这个 {@code key}, 否则为 {@code false}
59 | */
60 | boolean containsKey(K key);
61 |
62 | /**
63 | * 返回当前缓存中含有的所有 {@code key}
64 | *
65 | * @return {@code keySet}
66 | */
67 | Set keySet();
68 |
69 | /**
70 | * 清除缓存中所有的内容
71 | */
72 | void clear();
73 | }
74 |
--------------------------------------------------------------------------------
/view_module_refresh/src/main/java/com/from/view/refresh/impl/ScrollBoundaryDeciderAdapter.java:
--------------------------------------------------------------------------------
1 | package com.from.view.refresh.impl;
2 |
3 | import android.graphics.PointF;
4 | import android.view.View;
5 |
6 | import com.from.view.refresh.api.ScrollBoundaryDecider;
7 | import com.from.view.refresh.util.ScrollBoundaryUtil;
8 |
9 | /**
10 | * 滚动边界
11 | * Created by SCWANG on 2017/7/8.
12 | */
13 |
14 | @SuppressWarnings("WeakerAccess")
15 | public class ScrollBoundaryDeciderAdapter implements ScrollBoundaryDecider {
16 |
17 | //
18 | public PointF mActionEvent;
19 | public ScrollBoundaryDecider boundary;
20 | public boolean mEnableLoadMoreWhenContentNotFull = true;
21 |
22 | // void setScrollBoundaryDecider(ScrollBoundaryDecider boundary){
23 | // this.boundary = boundary;
24 | // }
25 |
26 | // void setActionEvent(MotionEvent event) {
27 | // //event 在没有必要时候会被设置为 null
28 | // mActionEvent = event;
29 | // }
30 | //
31 | // public void setEnableLoadMoreWhenContentNotFull(boolean enable) {
32 | // mEnableLoadMoreWhenContentNotFull = enable;
33 | // }
34 | //
35 |
36 | //
37 | @Override
38 | public boolean canRefresh(View content) {
39 | if (boundary != null) {
40 | return boundary.canRefresh(content);
41 | }
42 | //mActionEvent == null 时 canRefresh 不会动态递归搜索
43 | return ScrollBoundaryUtil.canRefresh(content, mActionEvent);
44 | }
45 |
46 | @Override
47 | public boolean canLoadMore(View content) {
48 | if (boundary != null) {
49 | return boundary.canLoadMore(content);
50 | }
51 | // if (mEnableLoadMoreWhenContentNotFull) {
52 | // //mActionEvent == null 时 canScrollDown 不会动态递归搜索
53 | // return !ScrollBoundaryUtil.canScrollDown(content, mActionEvent);
54 | // }
55 | //mActionEvent == null 时 canLoadMore 不会动态递归搜索
56 | return ScrollBoundaryUtil.canLoadMore(content, mActionEvent, mEnableLoadMoreWhenContentNotFull);
57 | }
58 | //
59 | }
60 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/HttpHandler.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.from.business.http.module.http.HttpConfigModule;
7 |
8 | import okhttp3.Interceptor;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 |
12 | /**
13 | * ================================================
14 | * 处理 Http 请求和响应结果的处理类
15 | * 使用 {@link HttpConfigModule.Builder#globalHttpHandler(HttpHandler)} 方法配置
16 | *
17 | * ================================================
18 | */
19 | public interface HttpHandler {
20 | /**
21 | * 这里可以先客户端一步拿到每一次 Http 请求的结果, 可以先解析成 Json, 再做一些操作, 如检测到 token 过期后
22 | * 重新请求 token, 并重新执行请求
23 | *
24 | * @param httpResult 服务器返回的结果 (已被框架自动转换为字符串)
25 | * @param chain {@link Interceptor.Chain}
26 | * @param response {@link Response}
27 | * @return {@link Response}
28 | */
29 | @NonNull
30 | Response onHttpResultResponse(@Nullable String httpResult, @NonNull Interceptor.Chain chain, @NonNull Response response);
31 |
32 | /**
33 | * 这里可以在请求服务器之前拿到 {@link Request}, 做一些操作比如给 {@link Request} 统一添加 token 或者 header 以及参数加密等操作
34 | *
35 | * @param chain {@link Interceptor.Chain}
36 | * @param request {@link Request}
37 | * @return {@link Request}
38 | */
39 | @NonNull
40 | Request onHttpRequestBefore(@NonNull Interceptor.Chain chain, @NonNull Request request);
41 |
42 | /**
43 | * 空实现
44 | */
45 | HttpHandler EMPTY = new HttpHandler() {
46 | @NonNull
47 | @Override
48 | public Response onHttpResultResponse(@Nullable String httpResult, @NonNull Interceptor.Chain chain, @NonNull Response response) {
49 | //不管是否处理, 都必须将 response 返回出去
50 | return response;
51 | }
52 |
53 | @NonNull
54 | @Override
55 | public Request onHttpRequestBefore(@NonNull Interceptor.Chain chain, @NonNull Request request) {
56 | //不管是否处理, 都必须将 request 返回出去
57 | return request;
58 | }
59 | };
60 | }
61 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/log/RequestInterceptorMembersInjector.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.log;
2 |
3 | import com.from.business.http.HttpHandler;
4 |
5 | import javax.inject.Provider;
6 |
7 | import dagger.MembersInjector;
8 |
9 |
10 | public final class RequestInterceptorMembersInjector
11 | implements MembersInjector {
12 | private final Provider mHandlerProvider;
13 | private final Provider mPrinterProvider;
14 | private final Provider printLevelProvider;
15 |
16 | public RequestInterceptorMembersInjector(
17 | Provider mHandlerProvider,
18 | Provider mPrinterProvider,
19 | Provider printLevelProvider) {
20 | this.mHandlerProvider = mHandlerProvider;
21 | this.mPrinterProvider = mPrinterProvider;
22 | this.printLevelProvider = printLevelProvider;
23 | }
24 |
25 | public static MembersInjector create(
26 | Provider mHandlerProvider,
27 | Provider mPrinterProvider,
28 | Provider printLevelProvider) {
29 | return new RequestInterceptorMembersInjector(
30 | mHandlerProvider, mPrinterProvider, printLevelProvider);
31 | }
32 |
33 | @Override
34 | public void injectMembers(RequestInterceptor instance) {
35 | injectHandler(instance, mHandlerProvider.get());
36 | injectPrinter(instance, mPrinterProvider.get());
37 | injectPrintLevel(instance, printLevelProvider.get());
38 | }
39 |
40 | public static void injectHandler(RequestInterceptor instance, HttpHandler mHandler) {
41 | instance.mHandler = mHandler;
42 | }
43 |
44 | public static void injectPrinter(RequestInterceptor instance, FormatPrinter mPrinter) {
45 | instance.mPrinter = mPrinter;
46 | }
47 |
48 | public static void injectPrintLevel(
49 | RequestInterceptor instance, RequestInterceptor.Level printLevel) {
50 | instance.printLevel = printLevel;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/business_module_http/README.md:
--------------------------------------------------------------------------------
1 | # business_module_http
2 |
3 | ## 介绍
4 | 封装最火的Retrofit ,Rx ,Oktttp 网络请求框架,让开发者轻松面对网络请求
5 |
6 | ### 特点
7 | - 可以动态切换任意一个 BaseUrl
8 | - 绑定生命周期解决内存泄漏
9 | - 支持缓存
10 | - 自定义拦截器
11 | - 自定义重试
12 | - 统一处理网络请求发生的错误
13 |
14 | ### 使用
15 | 引入 Module 或 gradle
16 | ```
17 | implementation 'com.from.business.http:business_module_http:1.0.0'
18 | implementation 'com.uber.autodispose:autodispose-android:1.2.0'
19 |
20 | allprojects {
21 | repositories {
22 | maven { url "https://jitpack.io" }
23 | }
24 | }
25 | ```
26 |
27 | ### 初始化
28 | ```
29 | HttpBusiness.init(Application, "host: https://api.github.com");
30 | ```
31 | ### 例子
32 |
33 | - 发起一个网络请求
34 |
35 | 如果和host不一致,请先调用只需调用一次
36 | ```
37 | RetrofitUrlManager.getInstance().putDomain("gank", "http://gank.io");
38 | ```
39 | 发起请求
40 | ```
41 | HttpComponent httpComponent = HttpBusiness.getHttpComponent();
42 |
43 | IRepositoryManager iRepositoryManager = httpComponent.repositoryManager();
44 |
45 | GankService gankService = iRepositoryManager.obtainRetrofitService(GankService.class);
46 |
47 | Observable>> observable = gankService
48 | .getGirlList(10, 1)
49 | .subscribeOn(Schedulers.io())
50 | .retryWhen(new RetryWithDelay(3, 2))
51 | .observeOn(AndroidSchedulers.mainThread());
52 |
53 | observable
54 | .as(bindLifecycle())
55 | .subscribe(
56 | new ErrorHandleSubscriber>>
57 | (httpComponent.rxErrorHandler()) {
58 | @Override
59 | public void onNext(GankBaseResponse> response) {
60 | // 业务逻辑
61 | }
62 | }
63 | );
64 | ```
65 |
66 | 使用RxCache缓存加载可参考[HttpPresenterOrViewModel](https://github.com/xwc520/BusinessComponent/blob/master/app/src/main/java/me/businesscomponent/activity/HttpPresenterOrViewModel.java)
67 |
68 |
69 | ### 感谢依赖库的开发作者们
70 | - [Uber](https://github.com/uber)
71 | - [JessYan](https://github.com/JessYanCoding)
72 | - more
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/Provides.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 The Dagger Authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dagger;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.METHOD;
24 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
25 |
26 | /**
27 | * Annotates methods of a {@linkplain Module module} to create a provider method binding. The
28 | * method's return type is bound to its returned value. The {@linkplain Component component}
29 | * implementation will pass dependencies to the method as parameters.
30 | *
31 | * Nullability
32 | *
33 | * Dagger forbids injecting {@code null} by default. Component implemenations that invoke
34 | * {@code @Provides} methods that return {@code null} will throw a {@link NullPointerException}
35 | * immediately thereafter. {@code @Provides} methods may opt into allowing {@code null} by
36 | * annotating the method with any {@code @Nullable} annotation like
37 | * {@code javax.annotation.Nullable} or {@code android.support.annotation.Nullable}.
38 | *
39 | *
If a {@code @Provides} method is marked {@code @Nullable}, Dagger will only
40 | * allow injection into sites that are marked {@code @Nullable} as well. A component that
41 | * attempts to pair a {@code @Nullable} provision with a non-{@code @Nullable} injection site
42 | * will fail to compile.
43 | */
44 | @Documented @Target(METHOD) @Retention(RUNTIME)
45 | public @interface Provides {
46 | }
47 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/log/RequestInterceptorFactory.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.log;
2 |
3 | import com.from.business.http.HttpHandler;
4 |
5 | import javax.inject.Provider;
6 |
7 | import dagger.internal.Factory;
8 |
9 |
10 | public final class RequestInterceptorFactory implements Factory {
11 | private final Provider mHandlerProvider;
12 | private final Provider mPrinterProvider;
13 | private final Provider printLevelProvider;
14 |
15 | public RequestInterceptorFactory(
16 | Provider mHandlerProvider,
17 | Provider mPrinterProvider,
18 | Provider printLevelProvider) {
19 | this.mHandlerProvider = mHandlerProvider;
20 | this.mPrinterProvider = mPrinterProvider;
21 | this.printLevelProvider = printLevelProvider;
22 | }
23 |
24 | @Override
25 | public RequestInterceptor get() {
26 | return provideInstance(mHandlerProvider, mPrinterProvider, printLevelProvider);
27 | }
28 |
29 | public static RequestInterceptor provideInstance(
30 | Provider mHandlerProvider,
31 | Provider mPrinterProvider,
32 | Provider printLevelProvider) {
33 | RequestInterceptor instance = new RequestInterceptor();
34 | RequestInterceptorMembersInjector.injectHandler(instance, mHandlerProvider.get());
35 | RequestInterceptorMembersInjector.injectPrinter(instance, mPrinterProvider.get());
36 | RequestInterceptorMembersInjector.injectPrintLevel(instance, printLevelProvider.get());
37 | return instance;
38 | }
39 |
40 | public static RequestInterceptorFactory create(
41 | Provider mHandlerProvider,
42 | Provider mPrinterProvider,
43 | Provider printLevelProvider) {
44 | return new RequestInterceptorFactory(mHandlerProvider, mPrinterProvider, printLevelProvider);
45 | }
46 |
47 | public static RequestInterceptor newRequestInterceptor() {
48 | return new RequestInterceptor();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.utils;
2 |
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 |
6 | /**
7 | * ================================================
8 | * 日志工具类
9 | *
10 | * Created by JessYan on 2015/11/23.
11 | * ================================================
12 | */
13 | public class LogUtils {
14 | private static final String DEFAULT_TAG = "Business_http";
15 | private static boolean isLog = true;
16 |
17 | private LogUtils() {
18 | throw new IllegalStateException("you can't instantiate me!");
19 | }
20 |
21 | public static boolean isLog() {
22 | return isLog;
23 | }
24 |
25 | public static void setLog(boolean isLog) {
26 | LogUtils.isLog = isLog;
27 | }
28 |
29 | public static void debugInfo(String tag, String msg) {
30 | if (!isLog || TextUtils.isEmpty(msg)) return;
31 | Log.d(tag, msg);
32 |
33 | }
34 |
35 | public static void debugInfo(String msg) {
36 | debugInfo(DEFAULT_TAG, msg);
37 | }
38 |
39 | public static void warnInfo(String tag, String msg) {
40 | if (!isLog || TextUtils.isEmpty(msg)) return;
41 | Log.w(tag, msg);
42 |
43 | }
44 |
45 | public static void warnInfo(String msg) {
46 | warnInfo(DEFAULT_TAG, msg);
47 | }
48 |
49 | /**
50 | * 这里使用自己分节的方式来输出足够长度的 message
51 | *
52 | * @param tag 标签
53 | * @param msg 日志内容
54 | */
55 | public static void debugLongInfo(String tag, String msg) {
56 | if (!isLog || TextUtils.isEmpty(msg)) return;
57 | msg = msg.trim();
58 | int index = 0;
59 | int maxLength = 3500;
60 | String sub;
61 | while (index < msg.length()) {
62 | if (msg.length() <= index + maxLength) {
63 | sub = msg.substring(index);
64 | } else {
65 | sub = msg.substring(index, index + maxLength);
66 | }
67 |
68 | index += maxLength;
69 | Log.d(tag, sub.trim());
70 | }
71 | }
72 |
73 | public static void debugLongInfo(String msg) {
74 | debugLongInfo(DEFAULT_TAG, msg);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/dagger/internal/InstanceFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Dagger Authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dagger.internal;
18 |
19 | import com.from.business.http.utils.Preconditions;
20 |
21 | import dagger.Lazy;
22 |
23 |
24 |
25 | /**
26 | * A {@link Factory} implementation that returns a single instance for all invocations of {@link
27 | * #get}.
28 | *
29 | *
Note that while this is a {@link Factory} implementation, and thus unscoped, each call to
30 | * {@link #get} will always return the same instance. As such, any scoping applied to this factory
31 | * is redundant and unnecessary. However, using this with {@link DoubleCheck#provider} is valid and
32 | * may be desired for testing or contractual guarantees.
33 | */
34 | public final class InstanceFactory implements Factory, Lazy {
35 | public static Factory create(T instance) {
36 | return new InstanceFactory(Preconditions.checkNotNull(instance, "instance cannot be null"));
37 | }
38 |
39 | public static Factory createNullable(T instance) {
40 | return instance == null
41 | ? InstanceFactory.nullInstanceFactory()
42 | : new InstanceFactory(instance);
43 | }
44 |
45 | @SuppressWarnings("unchecked") // bivariant implementation
46 | private static InstanceFactory nullInstanceFactory() {
47 | return (InstanceFactory) NULL_INSTANCE_FACTORY;
48 | }
49 |
50 | private static final InstanceFactory NULL_INSTANCE_FACTORY =
51 | new InstanceFactory(null);
52 |
53 | private final T instance;
54 |
55 | private InstanceFactory(T instance) {
56 | this.instance = instance;
57 | }
58 |
59 | @Override
60 | public T get() {
61 | return instance;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/component/HttpComponent.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.component;
2 |
3 | import android.app.Application;
4 |
5 | import com.from.business.http.HttpBusiness;
6 | import com.from.business.http.cache.Cache;
7 | import com.from.business.http.integration.IRepositoryManager;
8 | import com.from.business.http.module.http.HttpConfigModule;
9 | import com.google.gson.Gson;
10 |
11 | import java.io.File;
12 | import java.util.concurrent.ExecutorService;
13 |
14 | import me.jessyan.rxerrorhandler.core.RxErrorHandler;
15 | import okhttp3.OkHttpClient;
16 |
17 | /**
18 | * ================================================
19 | * 可通过 {@link HttpBusiness#getHttpComponent()} 拿到此接口的实现类
20 | * 拥有此接口的实现类即可调用对应的方法拿到 Dagger 提供的对应实例
21 | *
22 | * ================================================
23 | */
24 | public interface HttpComponent {
25 | Application application();
26 |
27 | /**
28 | * 用于管理网络请求层, 以及数据缓存层
29 | *
30 | * @return {@link IRepositoryManager}
31 | */
32 | IRepositoryManager repositoryManager();
33 |
34 | /**
35 | * RxJava 错误处理管理类
36 | *
37 | * @return {@link RxErrorHandler}
38 | */
39 | RxErrorHandler rxErrorHandler();
40 |
41 | /**
42 | * 网络请求框架
43 | *
44 | * @return {@link OkHttpClient}
45 | */
46 | OkHttpClient okHttpClient();
47 |
48 | /**
49 | * Json 序列化库
50 | *
51 | * @return {@link Gson}
52 | */
53 | Gson gson();
54 |
55 | /**
56 | * 缓存文件根目录 (RxCache 和 Glide 的缓存都已经作为子文件夹放在这个根目录下), 应该将所有缓存都统一放到这个根目录下
57 | * 便于管理和清理
58 | *
59 | * @return {@link File}
60 | */
61 | File cacheFile();
62 |
63 | /**
64 | * 用来存取一些整个 App 公用的数据, 切勿大量存放大容量数据, 这里的存放的数据和 {@link Application} 的生命周期一致
65 | *
66 | * @return {@link Cache}
67 | */
68 | Cache extras();
69 |
70 | /**
71 | * 用于创建框架所需缓存对象的工厂
72 | *
73 | * @return {@link Cache.Factory}
74 | */
75 | Cache.Factory cacheFactory();
76 |
77 | /**
78 | * 返回一个全局公用的线程池,适用于大多数异步需求。
79 | * 避免多个线程池创建带来的资源消耗。
80 | *
81 | * @return {@link ExecutorService}
82 | */
83 | ExecutorService executorService();
84 |
85 | interface Builder {
86 | Builder application(Application application);
87 |
88 | Builder globalConfigModule(HttpConfigModule globalConfigModule);
89 |
90 | HttpComponent build();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/business_module_http/src/main/java/com/from/business/http/log/FormatPrinter.java:
--------------------------------------------------------------------------------
1 | package com.from.business.http.log;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.from.business.http.module.http.HttpConfigModule;
7 |
8 | import java.util.List;
9 |
10 | import okhttp3.MediaType;
11 | import okhttp3.Request;
12 |
13 | /**
14 | * ================================================
15 | * 对 OkHttp 的请求和响应信息进行更规范和清晰的打印, 开发者可更根据自己的需求自行扩展打印格式
16 | *
17 | * @see DefaultFormatPrinter
18 | * @see HttpConfigModule.Builder#formatPrinter(FormatPrinter)
19 | * ================================================
20 | */
21 | public interface FormatPrinter {
22 | /**
23 | * 打印网络请求信息, 当网络请求时 {{@link okhttp3.RequestBody}} 可以解析的情况
24 | *
25 | * @param request
26 | * @param bodyString 发送给服务器的请求体中的数据(已解析)
27 | */
28 | void printJsonRequest(@NonNull Request request, @NonNull String bodyString);
29 |
30 | /**
31 | * 打印网络请求信息, 当网络请求时 {{@link okhttp3.RequestBody}} 为 {@code null} 或不可解析的情况
32 | *
33 | * @param request
34 | */
35 | void printFileRequest(@NonNull Request request);
36 |
37 | /**
38 | * 打印网络响应信息, 当网络响应时 {{@link okhttp3.ResponseBody}} 可以解析的情况
39 | *
40 | * @param chainMs 服务器响应耗时(单位毫秒)
41 | * @param isSuccessful 请求是否成功
42 | * @param code 响应码
43 | * @param headers 请求头
44 | * @param contentType 服务器返回数据的数据类型
45 | * @param bodyString 服务器返回的数据(已解析)
46 | * @param segments 域名后面的资源地址
47 | * @param message 响应信息
48 | * @param responseUrl 请求地址
49 | */
50 | void printJsonResponse(long chainMs, boolean isSuccessful, int code, @NonNull String headers, @Nullable MediaType contentType,
51 | @Nullable String bodyString, @NonNull List segments, @NonNull String message, @NonNull String responseUrl);
52 |
53 | /**
54 | * 打印网络响应信息, 当网络响应时 {{@link okhttp3.ResponseBody}} 为 {@code null} 或不可解析的情况
55 | *
56 | * @param chainMs 服务器响应耗时(单位毫秒)
57 | * @param isSuccessful 请求是否成功
58 | * @param code 响应码
59 | * @param headers 请求头
60 | * @param segments 域名后面的资源地址
61 | * @param message 响应信息
62 | * @param responseUrl 请求地址
63 | */
64 | void printFileResponse(long chainMs, boolean isSuccessful, int code, @NonNull String headers,
65 | @NonNull List segments, @NonNull String message, @NonNull String responseUrl);
66 | }
67 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------