├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zuzuche │ │ └── demo │ │ └── fastdev │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── zuzuche │ │ │ └── demo │ │ │ └── fastdev │ │ │ ├── MainActivity.java │ │ │ ├── MyApplication.java │ │ │ ├── Test1Activity.java │ │ │ ├── common │ │ │ ├── AccountService.java │ │ │ └── LanguageService.java │ │ │ └── component │ │ │ └── network │ │ │ ├── CoolAPi.java │ │ │ ├── TestViewModel.java │ │ │ └── bean │ │ │ ├── City.java │ │ │ └── TaobaoTest.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── zuzuche │ └── demo │ └── fastdev │ └── ExampleUnitTest.java ├── build.gradle ├── doc ├── readme.txt └── 模块化,组件化.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── librarys ├── baselib │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── zzc │ │ │ └── component │ │ │ └── common │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── zzc │ │ │ │ └── baselib │ │ │ │ ├── arch │ │ │ │ ├── ActionEntity.java │ │ │ │ ├── ActivityUtils.java │ │ │ │ ├── ConsumerLiveData.java │ │ │ │ ├── LifeViewModel.java │ │ │ │ ├── UIBehaviorViewModel.java │ │ │ │ └── support │ │ │ │ │ └── ConsumerObserverProxy.java │ │ │ │ ├── base │ │ │ │ ├── AppBase.java │ │ │ │ ├── AppData.java │ │ │ │ ├── BaseApplication.java │ │ │ │ └── CommonData.java │ │ │ │ ├── easycomponent │ │ │ │ ├── AppImpl.java │ │ │ │ ├── DeviceImpl.java │ │ │ │ ├── DimenImpl.java │ │ │ │ ├── NetworkImpl.java │ │ │ │ ├── ResourceImpl.java │ │ │ │ ├── ToastImpl.java │ │ │ │ └── UtilsInitialize.java │ │ │ │ ├── readme.txt │ │ │ │ ├── support │ │ │ │ ├── permission │ │ │ │ │ ├── InstallRationale.java │ │ │ │ │ ├── OverlayRationale.java │ │ │ │ │ ├── PermissionDialog.java │ │ │ │ │ ├── RuntimeRationale.java │ │ │ │ │ └── ZZPermission.java │ │ │ │ └── rx │ │ │ │ │ └── RxSimple.java │ │ │ │ ├── ui │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── BaseFragment.java │ │ │ │ ├── BaseLiveActivity.java │ │ │ │ ├── BaseToolbarFragment.java │ │ │ │ ├── PageFrameActivity.java │ │ │ │ ├── ToolbarBaseActivity.java │ │ │ │ ├── dialog │ │ │ │ │ ├── BaseDialog.java │ │ │ │ │ └── MenuDialog.java │ │ │ │ ├── listener │ │ │ │ │ ├── IProgressDialog.java │ │ │ │ │ └── IRxObserveDisposer.java │ │ │ │ ├── viewtools │ │ │ │ │ ├── CanClickChecker.java │ │ │ │ │ ├── OnSingleClickListener.java │ │ │ │ │ └── RepeatClickChecker.java │ │ │ │ └── widget │ │ │ │ │ ├── badgetab │ │ │ │ │ ├── BadgeTabLayout.java │ │ │ │ │ └── BadgeTabView.java │ │ │ │ │ ├── loadpage │ │ │ │ │ └── XSwipeRefreshLayout.java │ │ │ │ │ ├── recyclerview │ │ │ │ │ ├── AutoView.java │ │ │ │ │ ├── HolderRes.java │ │ │ │ │ ├── OnRecyclerviewItemClickListener.java │ │ │ │ │ ├── TalentAdapter.java │ │ │ │ │ ├── TalentHolder.java │ │ │ │ │ ├── TalentHolderInfo.java │ │ │ │ │ └── tools │ │ │ │ │ │ ├── DividerItemDecoration.java │ │ │ │ │ │ └── ItemOffsetDecoration.java │ │ │ │ │ └── statusbar │ │ │ │ │ ├── AppCompatStatusBar.java │ │ │ │ │ ├── StatusBarRecyclerView.java │ │ │ │ │ ├── StatusBarUtils.java │ │ │ │ │ └── StatusBarView.java │ │ │ │ └── util │ │ │ │ ├── ApplicationUtils.java │ │ │ │ ├── BitmapUtil.java │ │ │ │ ├── CollectionUtils.java │ │ │ │ ├── DeviceToken.java │ │ │ │ ├── DeviceUtils.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── L.java │ │ │ │ ├── MD5.java │ │ │ │ ├── NetworkUtils.java │ │ │ │ ├── NumberUtils.java │ │ │ │ ├── PackageUtils.java │ │ │ │ ├── PhotoUtils.java │ │ │ │ ├── ResourceUtils.java │ │ │ │ ├── SDCardUtils.java │ │ │ │ ├── SerializableUtils.java │ │ │ │ ├── SharedPrefUtils.java │ │ │ │ ├── SignatureUtils.java │ │ │ │ ├── StringUtils.java │ │ │ │ ├── T.java │ │ │ │ ├── ToastUtils.java │ │ │ │ ├── UIRunner.java │ │ │ │ ├── UIUtils.java │ │ │ │ └── Utils.java │ │ └── res │ │ │ ├── layout │ │ │ ├── base_activity_page_frame.xml │ │ │ ├── base_activity_page_frame_inc_title.xml │ │ │ ├── base_default_placeholder_progress.xml │ │ │ ├── base_view_recycler_view_footer.xml │ │ │ ├── base_view_stateful.xml │ │ │ ├── base_view_version.xml │ │ │ ├── base_view_version_download.xml │ │ │ ├── common_activity_fragment.xml │ │ │ ├── common_dialog_menu.xml │ │ │ ├── common_permission_alert.xml │ │ │ └── common_toolbar.xml │ │ │ ├── values-v21 │ │ │ └── styles.xml │ │ │ ├── values-zh-rCN │ │ │ └── strings.xml │ │ │ └── values │ │ │ ├── attrs_badge_tab.xml │ │ │ ├── attrs_stateful_layout.xml │ │ │ ├── attrs_tintable_image_view.xml │ │ │ ├── ids.xml │ │ │ ├── strings.xml │ │ │ ├── styles.xml │ │ │ └── themes.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── zzc │ │ └── component │ │ └── common │ │ └── ExampleUnitTest.java ├── design_style │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── zzc │ │ │ └── design │ │ │ └── style │ │ │ └── readme.txt │ │ └── res │ │ ├── anim │ │ ├── activity_close_enter.xml │ │ ├── activity_close_exit.xml │ │ ├── activity_enter.xml │ │ ├── activity_exit.xml │ │ ├── activity_open_enter.xml │ │ ├── activity_open_exit.xml │ │ ├── anim_bottom_in.xml │ │ ├── anim_bottom_out.xml │ │ ├── anim_top_in.xml │ │ ├── anim_top_out.xml │ │ ├── dialog_enter.xml │ │ ├── dialog_enter_translate_bottom.xml │ │ ├── dialog_exit.xml │ │ ├── dialog_exit_translate_bottom.xml │ │ ├── h_fragment_enter.xml │ │ ├── h_fragment_exit.xml │ │ ├── h_fragment_pop_enter.xml │ │ ├── h_fragment_pop_exit.xml │ │ ├── idle.xml │ │ ├── pic_activity_enter.xml │ │ ├── pic_activity_exit.xml │ │ ├── plugin_enter.xml │ │ ├── plugin_exit.xml │ │ ├── slide_in_left.xml │ │ ├── slide_in_right.xml │ │ ├── slide_out_left.xml │ │ └── slide_out_right.xml │ │ ├── drawable │ │ ├── bg_common_item.xml │ │ ├── bg_dialog.xml │ │ └── text_cursor_dark.xml │ │ ├── mipmap-xxhdpi │ │ ├── nav_back.png │ │ └── right.png │ │ ├── values-v21 │ │ ├── styles.xml │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── themes.xml ├── easycommon │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── zuzuche │ │ └── easycomponents │ │ └── common │ │ ├── UtilFunction.java │ │ └── annotation │ │ ├── AutoGetUtil.java │ │ └── EasyUtil.java ├── easycompiler │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── zuzuche │ │ └── easycomponents │ │ └── compiler │ │ └── UtilInitProcessor.java ├── easycomponents │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── zzc │ │ │ └── component │ │ │ └── composite │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── zzc │ │ │ │ └── easycomponents │ │ │ │ ├── base │ │ │ │ ├── Easys.java │ │ │ │ ├── IBuilder.java │ │ │ │ ├── IComponent.java │ │ │ │ └── IUtil.java │ │ │ │ ├── component │ │ │ │ ├── ComponentManager.java │ │ │ │ ├── Components.java │ │ │ │ ├── NetworkComponent.java │ │ │ │ └── proxy │ │ │ │ │ └── NetworkComponentProxy.java │ │ │ │ ├── readme.txt │ │ │ │ ├── support │ │ │ │ └── ComponentRuntimeException.java │ │ │ │ ├── util │ │ │ │ ├── App.java │ │ │ │ ├── Device.java │ │ │ │ ├── Dimen.java │ │ │ │ ├── Network.java │ │ │ │ ├── Resource.java │ │ │ │ ├── Toast.java │ │ │ │ ├── Utils.java │ │ │ │ ├── UtilsManager.java │ │ │ │ └── Views.java │ │ │ │ └── widget │ │ │ │ └── Widgets.java │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── zzc │ │ └── component │ │ └── composite │ │ └── ExampleUnitTest.java └── networklib │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zzc │ │ └── network │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── zzc │ │ │ └── network │ │ │ ├── ApiBuilder.java │ │ │ ├── ApiBuilderOuter.java │ │ │ ├── ZHttpClient.java │ │ │ ├── cache │ │ │ ├── CacheStrategy.java │ │ │ ├── CacheStrategyInterceptor.java │ │ │ ├── CacheStrategyUtil.java │ │ │ ├── HttpLoggingInterceptor.java │ │ │ └── NetworkInterceptor.java │ │ │ ├── easycomponent │ │ │ └── NetworkComponentImpl.java │ │ │ ├── response │ │ │ ├── BaseResponse.java │ │ │ ├── BaseResponseObserver.java │ │ │ ├── DefaultPriCResponseDataCallback.java │ │ │ ├── DefaultResponseCodeHandle.java │ │ │ ├── HttpResponse.java │ │ │ ├── IHttpResponse.java │ │ │ ├── IRxResponseProgress.java │ │ │ ├── PriorityCacheResponseCallback.java │ │ │ ├── PriorityCacheResponseDataCallback.java │ │ │ ├── ResponseDataObserver.java │ │ │ ├── ResponseObserver.java │ │ │ ├── SupportProcedure.java │ │ │ └── SupportResponseLifecycle.java │ │ │ └── support │ │ │ ├── ClearTokenEvent.java │ │ │ ├── GlobalRequestAdapter.java │ │ │ ├── NeedQuickLoginEvent.java │ │ │ ├── ProgressResponseBody.java │ │ │ └── RequestKey.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── zzc │ └── network │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.zuzuche.demo.fastdev" 7 | minSdkVersion 27 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | compileOptions { 23 | //use java 1.8 with Android Studio 3.0+ 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | // 这个是解决lint报错的代码 28 | lintOptions { 29 | // 防止在发布的时候出现因MissingTranslation导致Build Failed! 30 | disable 'MissingTranslation' 31 | disable 'ExtraTranslation' 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation fileTree(dir: 'libs', include: ['*.jar']) 37 | annotationProcessor project(':librarys:easycompiler') 38 | 39 | implementation project(":librarys:baselib") 40 | implementation project(":librarys:easycomponents") 41 | implementation project(":librarys:networklib") 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /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/androidTest/java/com/zuzuche/demo/fastdev/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev; 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.zuzuche.demo.fastdev", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev; 2 | 3 | import android.arch.lifecycle.MediatorLiveData; 4 | import android.content.Intent; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import com.zuzuche.demo.fastdev.component.network.CoolAPi; 10 | import com.zzc.baselib.arch.ConsumerLiveData; 11 | import com.zzc.baselib.util.L; 12 | import com.zzc.easycomponents.component.Components; 13 | import com.zzc.easycomponents.util.Utils; 14 | import com.zzc.network.support.GlobalRequestAdapter; 15 | 16 | import okhttp3.HttpUrl; 17 | import okhttp3.Request; 18 | 19 | public class MainActivity extends AppCompatActivity { 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | L.d("======="+Utils.resource().toString()); 26 | L.d("=======" + Utils.app().packageName() + " " + Utils.app().version() + " " + Utils.device().device()); 27 | Components.network().builder(CoolAPi.class) 28 | .baseUrl("https://suggest.taobao.com/") 29 | .requestAdapter(new GlobalRequestAdapter() { 30 | 31 | @Override 32 | public void addHeader(Request.Builder builder) { 33 | 34 | } 35 | 36 | @Override 37 | public void addQueryParams(HttpUrl.Builder httpUrlBuilder) { 38 | 39 | } 40 | }).build(); 41 | 42 | Components.network().api(CoolAPi.class).testSearchNetwork("城").subscribe(); 43 | 44 | 45 | data.postValue("222"); 46 | data1.postValue("333"); 47 | 48 | data.observe(this, data -> { 49 | L.d("======data " + data); 50 | }); 51 | data1.observe(this, data -> { 52 | L.d("======data1 " + data); 53 | }); 54 | 55 | // 56 | // ViewModel viewModel = ViewModelProviders.of(this).get(TestViewModel.class); 57 | } 58 | 59 | MediatorLiveData data = new MediatorLiveData<>(); 60 | ConsumerLiveData data1 = new ConsumerLiveData<>(); 61 | 62 | public void test1(View view) { 63 | startActivity(new Intent(this, Test1Activity.class)); 64 | } 65 | 66 | @Override 67 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 68 | super.onRestoreInstanceState(savedInstanceState); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev; 2 | 3 | import com.zzc.baselib.base.AppBase; 4 | import com.zzc.baselib.base.BaseApplication; 5 | import com.zzc.baselib.easycomponent.UtilsInitialize; 6 | import com.zzc.easycomponents.base.Easys; 7 | import com.zzc.easycomponents.component.Components; 8 | import com.zzc.easycomponents.util.Utils; 9 | import com.zzc.network.easycomponent.NetworkComponentImpl; 10 | 11 | /** 12 | * @author Roye 13 | * @date 2018/10/25 14 | */ 15 | public class MyApplication extends BaseApplication { 16 | 17 | @Override 18 | public void onCreate() { 19 | super.onCreate(); 20 | 21 | AppBase.setDebug(true); 22 | 23 | initEasyComponent(); 24 | } 25 | 26 | void initEasyComponent() { 27 | Easys.init(this); //初始化上下文 28 | 29 | UtilsInitialize.init(); //初始化工具类 30 | 31 | Components.manager().init(new NetworkComponentImpl()); //初始化网络组件 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/Test1Activity.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | 5 | /** 6 | * @author Roye 7 | * @date 2018/11/16 8 | */ 9 | public class Test1Activity extends AppCompatActivity { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/common/AccountService.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.common; 2 | 3 | /** 4 | * @author Roye 5 | * @date 2018/11/14 6 | */ 7 | public class AccountService { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/common/LanguageService.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.common; 2 | 3 | /** 4 | * @author Roye 5 | * @date 2018/11/14 6 | */ 7 | public class LanguageService { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/component/network/CoolAPi.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.component.network; 2 | 3 | import com.zuzuche.demo.fastdev.component.network.bean.TaobaoTest; 4 | import com.zzc.network.cache.CacheStrategy; 5 | 6 | import io.reactivex.Observable; 7 | import retrofit2.Call; 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Headers; 10 | import retrofit2.http.Query; 11 | 12 | /** 13 | * @Headers("Cache-Control: max-age=640000") 直接请求,有缓存且未过期返回缓存,否则读网络并写缓存 14 | * @Headers("Cache-Control:no-cache") 直接请求网络,不做缓存 15 | * @Headers("Cache-Control:no-store") 直接请求网络,不存临时缓存 16 | * @Headers("Cache-Control:public, only-if-cached, max-stale=2419200") 直接请求缓存 17 | * @GET("select/search.php") 18 | * @GET("book/{id}") 19 | * @POST 20 | * @FormUrlEncoded 21 | */ 22 | public interface CoolAPi { 23 | 24 | @Headers(CacheStrategy.ONLY_CACHE) 25 | @GET("sug?code=utf-8") 26 | public Observable testSearchOnlyCache(@Query("q") String keyword); 27 | 28 | @Headers(CacheStrategy.NETWORK) 29 | @GET("sug?code=utf-8") 30 | public Observable testSearchNetwork(@Query("q") String keyword); 31 | 32 | @Headers(CacheStrategy.CACHE_1_HOUR) 33 | @GET("sug?code=utf-8") 34 | public Observable testSearchCacheAge(@Query("q") String keyword); 35 | 36 | @Headers(CacheStrategy.CACHE_AND_REFRESH) 37 | @GET("sug?code=utf-8") 38 | public Call testSearchSceneCacheCall(@Query("q") String keyword); 39 | 40 | @Headers(CacheStrategy.CACHE) 41 | @GET("sug?code=utf-8") 42 | public Observable testSearchSceneCache(@Query("q") String keyword); 43 | 44 | @Headers(CacheStrategy.REFRESH) 45 | @GET("sug?code=utf-8") 46 | public Observable testSearchSceneRefresh(@Query("q") String keyword); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/component/network/TestViewModel.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.component.network; 2 | 3 | import android.arch.lifecycle.ViewModel; 4 | 5 | /** 6 | * @author Roye 7 | * @date 2018/11/7 8 | */ 9 | public class TestViewModel extends ViewModel { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/component/network/bean/City.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.component.network.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Roye 7 | * @date 2018/6/30 8 | */ 9 | public class City implements Serializable { 10 | 11 | 12 | public City() { 13 | } 14 | 15 | public String getCity() { 16 | return city; 17 | } 18 | 19 | public void setCity(String city) { 20 | this.city = city; 21 | } 22 | 23 | public boolean isEasy() { 24 | return easy; 25 | } 26 | 27 | public void setEasy(boolean easy) { 28 | this.easy = easy; 29 | } 30 | 31 | public String getCity_cn() { 32 | return city_cn; 33 | } 34 | 35 | public void setCity_cn(String city_cn) { 36 | this.city_cn = city_cn; 37 | } 38 | 39 | public String getCity_en() { 40 | return city_en; 41 | } 42 | 43 | public void setCity_en(String city_en) { 44 | this.city_en = city_en; 45 | } 46 | 47 | public String getRegion_cn() { 48 | return region_cn; 49 | } 50 | 51 | public void setRegion_cn(String region_cn) { 52 | this.region_cn = region_cn; 53 | } 54 | 55 | public String getRegion_en() { 56 | return region_en; 57 | } 58 | 59 | public void setRegion_en(String region_en) { 60 | this.region_en = region_en; 61 | } 62 | 63 | public String getState() { 64 | return state; 65 | } 66 | 67 | public void setState(String state) { 68 | this.state = state; 69 | } 70 | 71 | public String getLetter() { 72 | return letter; 73 | } 74 | 75 | public void setLetter(String letter) { 76 | this.letter = letter; 77 | } 78 | 79 | public String getPinyin() { 80 | return pinyin; 81 | } 82 | 83 | public void setPinyin(String pinyin) { 84 | this.pinyin = pinyin; 85 | } 86 | 87 | public String getRegion() { 88 | return region; 89 | } 90 | 91 | public void setRegion(String region) { 92 | this.region = region; 93 | } 94 | 95 | public String getLandmark_id() { 96 | return landmark_id; 97 | } 98 | 99 | public void setLandmark_id(String landmark_id) { 100 | this.landmark_id = landmark_id; 101 | } 102 | 103 | public String getLandmark_en() { 104 | return landmark_en; 105 | } 106 | 107 | public void setLandmark_en(String landmark_en) { 108 | this.landmark_en = landmark_en; 109 | } 110 | 111 | public String getLandmark_cn() { 112 | return landmark_cn; 113 | } 114 | 115 | public void setLandmark_cn(String landmark_cn) { 116 | this.landmark_cn = landmark_cn; 117 | } 118 | 119 | private String city; 120 | private boolean easy; 121 | private String city_cn; 122 | private String city_en; 123 | private String region; 124 | private String region_cn; 125 | private String region_en; 126 | private String state; 127 | private String letter; 128 | private String landmark_id; 129 | private String landmark_en; 130 | private String landmark_cn; 131 | private String pinyin; 132 | 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/zuzuche/demo/fastdev/component/network/bean/TaobaoTest.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev.component.network.bean; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Roye 8 | * @date 2018/9/12 9 | */ 10 | public class TaobaoTest implements Serializable { 11 | 12 | public List> result; 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | fast_dev 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/zuzuche/demo/fastdev/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zuzuche.demo.fastdev; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.1.4' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /doc/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /doc/模块化,组件化.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/doc/模块化,组件化.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Tue Apr 18 10:17:49 CST 2017 16 | systemProp.http.proxyHost=127.0.0.1 17 | org.gradle.jvmargs=-Xmx1536m 18 | systemProp.http.proxyPort=1080 19 | 20 | supportLibVersion = 27.0.2 21 | okHttpVersion = 3.10.0 22 | retrofitVersion = 2.4.0 23 | rxandroidVersion = 2.0.2 24 | lifecycleVersion = + 25 | gsonVersion = 2.8.2 26 | eventbusVersion = 3.0.0 27 | multidexVersion = 1.0.3 28 | andPermissionVersion = 2.0.0-rc11 29 | firebaseVersion = 15.0.2 30 | gmsVersion = 15.0.1 31 | constraintVersion = 1.0.2 32 | glideVersion = 4.0.0 33 | 34 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superroye/lefastdev/e5e9bd55332e6a1626fe29750e80e037915901e6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 18 18:22:43 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /librarys/baselib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /librarys/baselib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 27 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 21 10 | targetSdkVersion 27 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | 30 | 31 | implementation project(":librarys:design_style") 32 | implementation project(":librarys:easycomponents") 33 | 34 | api "com.android.support:appcompat-v7:${supportLibVersion}" 35 | api "com.android.support:design:${supportLibVersion}" 36 | api "com.android.support:recyclerview-v7:${supportLibVersion}" 37 | api "com.android.support:cardview-v7:${supportLibVersion}" 38 | 39 | api "io.reactivex.rxjava2:rxandroid:${rxandroidVersion}" 40 | 41 | api("android.arch.lifecycle:extensions:${lifecycleVersion}") { 42 | exclude group: 'com.android.support', module: 'support-fragment' 43 | exclude group: 'com.android.support', module: 'support-annotations' 44 | } 45 | annotationProcessor "android.arch.lifecycle:compiler:${lifecycleVersion}" 46 | 47 | api("com.yanzhenjie:permission:${andPermissionVersion}") { 48 | exclude group: 'com.android.support', module: 'support-fragment' 49 | } 50 | 51 | api "com.google.code.gson:gson:${gsonVersion}" 52 | api "org.greenrobot:eventbus:${eventbusVersion}" 53 | api "com.android.support:multidex:${multidexVersion}" 54 | 55 | api "com.android.support.constraint:constraint-layout:${constraintVersion}" 56 | 57 | annotationProcessor project(':librarys:easycompiler') 58 | 59 | } 60 | -------------------------------------------------------------------------------- /librarys/baselib/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 | -------------------------------------------------------------------------------- /librarys/baselib/src/androidTest/java/com/zzc/component/common/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zzc.component.common; 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.zzc.component.common.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/ActionEntity.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch; 2 | 3 | public class ActionEntity { 4 | 5 | public int id; 6 | public Object[] extra; 7 | 8 | public ActionEntity(int id, Object[] extra) { 9 | this.id = id; 10 | this.extra = extra; 11 | } 12 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/ActivityUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.ContextWrapper; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | /** 10 | * @author Roye 11 | * @date 2018/8/23 12 | */ 13 | public class ActivityUtils { 14 | 15 | public static FragmentActivity getActivity(Context context) { 16 | Context context1 = context; 17 | while (!(context1 instanceof Activity) && context1 instanceof ContextWrapper) { 18 | context1 = ((ContextWrapper) context1).getBaseContext(); 19 | } 20 | 21 | AppCompatActivity activity = null; 22 | if (context1 instanceof AppCompatActivity) { 23 | activity = (AppCompatActivity) context1; 24 | } 25 | if (activity == null) { 26 | android.util.Log.e("ActivityUtils", "current activity is null"); 27 | } 28 | return activity; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/ConsumerLiveData.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch; 2 | 3 | import android.arch.lifecycle.LifecycleOwner; 4 | import android.arch.lifecycle.LiveData; 5 | import android.arch.lifecycle.MediatorLiveData; 6 | import android.arch.lifecycle.Observer; 7 | import android.support.annotation.NonNull; 8 | import android.support.annotation.Nullable; 9 | 10 | import com.zzc.baselib.arch.support.ConsumerObserverProxy; 11 | 12 | import java.util.LinkedHashMap; 13 | 14 | /** 15 | * @author Roye 16 | * @date 2018/11/14 17 | * 1、跟普通的livedata不同,它是每次setvalue只通知一次,不会因为UI active而再度通知 18 | * 2、适合用于弹toast,一次性动画场景 19 | */ 20 | public class ConsumerLiveData extends MediatorLiveData { 21 | 22 | private MediatorLiveData delegate; 23 | 24 | public ConsumerLiveData() { 25 | delegate = new MediatorLiveData(); 26 | } 27 | 28 | @Override 29 | public void postValue(T value) { 30 | delegate.postValue(value); 31 | } 32 | 33 | @Override 34 | public void setValue(T value) { 35 | delegate.setValue(value); 36 | } 37 | 38 | @Override 39 | public void addSource(@NonNull LiveData source, @NonNull Observer onChanged) { 40 | delegate.addSource(source, onChanged); 41 | } 42 | 43 | @Nullable 44 | @Override 45 | public T getValue() { 46 | return delegate.getValue(); 47 | } 48 | 49 | @Override 50 | public boolean hasActiveObservers() { 51 | return delegate.hasActiveObservers(); 52 | } 53 | 54 | @Override 55 | public boolean hasObservers() { 56 | return delegate.hasObservers(); 57 | } 58 | 59 | private LinkedHashMap, ConsumerObserverProxy> mObservers = 60 | new LinkedHashMap<>(); 61 | 62 | @Override 63 | public void observe(@NonNull LifecycleOwner owner, @NonNull Observer observer) { 64 | ConsumerObserverProxy proxy = mObservers.get(observer); 65 | 66 | if (proxy == null) { 67 | proxy = new ConsumerObserverProxy(observer); 68 | mObservers.put(observer, proxy); 69 | } 70 | 71 | delegate.observe(owner, proxy); 72 | } 73 | 74 | @Override 75 | public void observeForever(@NonNull Observer observer) { 76 | ConsumerObserverProxy proxy = new ConsumerObserverProxy(observer); 77 | mObservers.put(observer, proxy); 78 | 79 | delegate.observeForever(proxy); 80 | } 81 | 82 | @Override 83 | public void removeObserver(@NonNull Observer observer) { 84 | ConsumerObserverProxy proxy = mObservers.get(observer); 85 | if (proxy != null) { 86 | delegate.removeObserver(proxy); 87 | } 88 | } 89 | 90 | @Override 91 | public void removeObservers(@NonNull LifecycleOwner owner) { 92 | delegate.removeObservers(owner); 93 | } 94 | 95 | @Override 96 | public void removeSource(@NonNull LiveData toRemote) { 97 | delegate.removeSource(toRemote); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/LifeViewModel.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch; 2 | 3 | import android.arch.lifecycle.Lifecycle; 4 | import android.arch.lifecycle.LifecycleObserver; 5 | import android.arch.lifecycle.LifecycleOwner; 6 | import android.arch.lifecycle.OnLifecycleEvent; 7 | import android.arch.lifecycle.ViewModel; 8 | import android.arch.lifecycle.ViewModelProviders; 9 | import android.support.v4.app.Fragment; 10 | import android.support.v4.app.FragmentActivity; 11 | 12 | /** 13 | * @author Roye 14 | * @date 2018/8/22 15 | */ 16 | public class LifeViewModel extends ViewModel implements LifecycleObserver { 17 | 18 | public UIBehaviorViewModel mUIBehaviorViewModel; 19 | 20 | @OnLifecycleEvent(Lifecycle.Event.ON_START) 21 | public void onStart(LifecycleOwner lifecycleOwner){ 22 | if(lifecycleOwner instanceof Fragment){ 23 | mUIBehaviorViewModel = ViewModelProviders.of((Fragment)lifecycleOwner).get(UIBehaviorViewModel.class); 24 | }else if(lifecycleOwner instanceof FragmentActivity){ 25 | mUIBehaviorViewModel = ViewModelProviders.of((FragmentActivity)lifecycleOwner).get(UIBehaviorViewModel.class); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/UIBehaviorViewModel.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch; 2 | 3 | import android.arch.lifecycle.ViewModel; 4 | import android.text.TextUtils; 5 | 6 | import com.zzc.baselib.ui.listener.IProgressDialog; 7 | 8 | /** 9 | * @author Roye 10 | * @date 2018/11/14 11 | */ 12 | public final class UIBehaviorViewModel extends ViewModel implements IProgressDialog { 13 | 14 | public static final int LOADING_HIDE = 0; 15 | public static final int LOADING_SHOW = 1; 16 | private ConsumerLiveData loading; 17 | private ConsumerLiveData animation; 18 | 19 | public UIBehaviorViewModel() { 20 | loading = new ConsumerLiveData(); 21 | animation = new ConsumerLiveData(); 22 | } 23 | 24 | public ConsumerLiveData loading() { 25 | return loading; 26 | } 27 | 28 | public ConsumerLiveData animation() { 29 | return animation; 30 | } 31 | 32 | @Override 33 | public void showLoading(String text) { 34 | String text1 = text; 35 | if(TextUtils.isEmpty(text1)){ 36 | text = "loading..."; 37 | } 38 | loading().postValue(new ActionEntity(LOADING_SHOW, new Object[]{text})); 39 | } 40 | 41 | @Override 42 | public void hideLoading() { 43 | loading().postValue(new ActionEntity(LOADING_HIDE, null)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/arch/support/ConsumerObserverProxy.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.arch.support; 2 | 3 | import android.arch.lifecycle.Observer; 4 | import android.support.annotation.Nullable; 5 | 6 | /** 7 | * @author Roye 8 | * @date 2018/11/14 9 | */ 10 | public class ConsumerObserverProxy implements Observer { 11 | 12 | private int version; 13 | private Observer delegate; 14 | 15 | public ConsumerObserverProxy(Observer observer) { 16 | this.delegate = observer; 17 | } 18 | 19 | @Override 20 | public void onChanged(@Nullable T data) { 21 | int newVersion; 22 | if (data == null) { 23 | newVersion = 0; 24 | } else { 25 | newVersion = data.hashCode(); 26 | } 27 | if (newVersion != version) { 28 | version = newVersion; 29 | delegate.onChanged(data); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/base/AppBase.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.base; 2 | 3 | import android.app.Application; 4 | import android.text.TextUtils; 5 | 6 | import com.zzc.baselib.util.ApplicationUtils; 7 | import com.zzc.baselib.util.L; 8 | import com.zzc.baselib.util.SharedPrefUtils; 9 | import com.zzc.baselib.util.UIUtils; 10 | 11 | /** 12 | * @author Roye 13 | * @date 2018/10/24 14 | */ 15 | public class AppBase { 16 | 17 | public static String APP_ID; 18 | public static String APP_CHANNEL; 19 | public static Application app; 20 | public static String ENV; 21 | public static boolean DEBUG; 22 | public static boolean PRODUCT_ENV; 23 | 24 | public static final String SP_KEY_APPID = "appId"; 25 | public static final String SP_KEY_CHANNEL = "app_channel"; 26 | public static final String SP_KEY_ENV = "env"; 27 | public static final String ENV_TEST = "test"; 28 | public static final String ENV_PRODUCT = "product"; 29 | 30 | public static void init(Application app, boolean isDebug) { 31 | AppBase.app = app; 32 | DEBUG = isDebug; 33 | 34 | L.setDebug(isDebug); 35 | 36 | APP_ID = String.valueOf(ApplicationUtils.getMetadataInt(app, SP_KEY_APPID)); 37 | SharedPrefUtils.put(SP_KEY_APPID, APP_ID); 38 | 39 | initChannel(); 40 | 41 | initEnv(); 42 | 43 | UIUtils.init(app); 44 | } 45 | 46 | private static void initChannel() { 47 | String channel = ApplicationUtils.getMetadataString(app, SP_KEY_CHANNEL); 48 | if (TextUtils.isEmpty(channel)) { 49 | channel = String.valueOf(ApplicationUtils.getMetadataInt(app, SP_KEY_CHANNEL)); 50 | } 51 | APP_CHANNEL = channel; 52 | String channel_sp = SharedPrefUtils.get(SP_KEY_CHANNEL); 53 | if (TextUtils.isEmpty(channel_sp)) { 54 | SharedPrefUtils.put(SP_KEY_CHANNEL, APP_CHANNEL); 55 | } else { 56 | APP_CHANNEL = channel_sp; 57 | } 58 | } 59 | 60 | private static void initEnv() { 61 | String env = SharedPrefUtils.get(SP_KEY_ENV); 62 | if (TextUtils.isEmpty(env)) { 63 | env = ApplicationUtils.getMetadataString(app, SP_KEY_ENV); 64 | } 65 | 66 | setEnv(env); 67 | } 68 | 69 | public static void setEnv(String env) { 70 | if (env != null) { 71 | ENV = env; 72 | } else { 73 | ENV = ENV_TEST; 74 | } 75 | 76 | PRODUCT_ENV = !ENV_TEST.equals(ENV); 77 | 78 | SharedPrefUtils.put(SP_KEY_ENV, ENV); 79 | } 80 | 81 | public static void setDebug(boolean debug) { 82 | DEBUG = debug; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/base/AppData.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.base; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.zzc.baselib.util.DeviceUtils; 6 | 7 | /** 8 | * Created by Roye on 2018/5/23. 9 | */ 10 | public class AppData { 11 | 12 | public final static String SP_FILE = "app_data"; 13 | private static final String SP_KEY_UID = "uid"; 14 | private static final String SP_KEY_TOKEN = "token"; 15 | private static final String SP_KEY_ACCESS_TOKEN = "accessToken"; 16 | private static final String SP_KEY_USERFACE = "userFace"; 17 | private static final String SP_KEY_USERNICK = "userNick"; 18 | private static final String SP_KEY_UUID = "uuid"; 19 | private static final String SP_KEY_ACCOUNT_TYPE = "account_type"; //1 正式 2 游客 20 | 21 | private static CommonData data; 22 | 23 | private static CommonData getData() { 24 | if (data == null) { 25 | data = new CommonData(SP_FILE); 26 | } 27 | return data; 28 | } 29 | 30 | public static String getUuid() { 31 | String uuid = getData().getValue(SP_KEY_UUID); 32 | if (TextUtils.isEmpty(uuid)) { 33 | uuid = DeviceUtils.deviceUUId(AppBase.app); 34 | getData().setValue(SP_KEY_UUID, uuid); 35 | } 36 | 37 | return uuid; 38 | } 39 | 40 | public static String getUid() { 41 | return getData().getValue(SP_KEY_UID); 42 | } 43 | 44 | public static void setUid(String uid) { 45 | getData().setValue(SP_KEY_UID, uid); 46 | } 47 | 48 | public static String getToken() { 49 | return getData().getValue(SP_KEY_TOKEN); 50 | } 51 | 52 | public static void setToken(String token) { 53 | getData().setValue(SP_KEY_TOKEN, token); 54 | } 55 | 56 | public static String getNick() { 57 | return getData().getValue(SP_KEY_USERNICK); 58 | } 59 | 60 | public static void setNick(String nick) { 61 | getData().setValue(SP_KEY_USERNICK, nick); 62 | } 63 | 64 | public static String getHead() { 65 | return getData().getValue(SP_KEY_USERFACE); 66 | } 67 | 68 | public static void setHead(String head) { 69 | getData().setValue(SP_KEY_USERFACE, head); 70 | } 71 | 72 | public static String getAccessToken() { 73 | return getData().getValue(SP_KEY_ACCESS_TOKEN); 74 | } 75 | 76 | public static void setAccessToken(String accessToken) { 77 | getData().setValue(SP_KEY_ACCESS_TOKEN, accessToken); 78 | } 79 | 80 | public static int getAccountType() { 81 | return getData().getIntValue(SP_KEY_ACCOUNT_TYPE); 82 | } 83 | 84 | public static void setAccountType(int accountType) { 85 | getData().setValue(SP_KEY_ACCOUNT_TYPE, accountType); 86 | } 87 | 88 | 89 | public static void clear() { 90 | getData().clear(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.base; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.content.Context; 6 | import android.os.Bundle; 7 | import android.support.multidex.MultiDex; 8 | 9 | import com.zzc.baselib.BuildConfig; 10 | 11 | public class BaseApplication extends Application implements Application.ActivityLifecycleCallbacks { 12 | 13 | @Override 14 | protected void attachBaseContext(Context base) { 15 | super.attachBaseContext(base); 16 | 17 | MultiDex.install(this); 18 | } 19 | 20 | @Override 21 | public void onCreate() { 22 | super.onCreate(); 23 | AppBase.init(this, BuildConfig.DEBUG); 24 | registerActivityLifecycleCallbacks(this); 25 | } 26 | 27 | @Override 28 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) { 29 | 30 | } 31 | 32 | @Override 33 | public void onActivityStarted(Activity activity) { 34 | 35 | } 36 | 37 | @Override 38 | public void onActivityResumed(Activity activity) { 39 | } 40 | 41 | @Override 42 | public void onActivityPaused(Activity activity) { 43 | } 44 | 45 | @Override 46 | public void onActivityStopped(Activity activity) { 47 | 48 | } 49 | 50 | @Override 51 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { 52 | 53 | } 54 | 55 | @Override 56 | public void onActivityDestroyed(Activity activity) { 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/base/CommonData.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.base; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | public class CommonData { 7 | public String mSpFileName; 8 | 9 | public CommonData(String fileName) { 10 | mSpFileName = fileName; 11 | } 12 | 13 | private SharedPreferences getSp() { 14 | return AppBase.app.getSharedPreferences(mSpFileName, Context.MODE_PRIVATE); 15 | } 16 | 17 | public void setValue(String key, String value) { 18 | SharedPreferences sp = getSp(); 19 | SharedPreferences.Editor editor = sp.edit(); 20 | if (value == null) { 21 | editor.remove(key); 22 | } else { 23 | editor.putString(key, value); 24 | } 25 | 26 | editor.commit(); 27 | } 28 | 29 | public void setValue(String key, int value) { 30 | SharedPreferences sp = getSp(); 31 | SharedPreferences.Editor editor = sp.edit(); 32 | editor.putInt(key, value); 33 | editor.commit(); 34 | } 35 | 36 | public void setValue(String key, long value) { 37 | SharedPreferences sp = getSp(); 38 | SharedPreferences.Editor editor = sp.edit(); 39 | editor.putLong(key, value); 40 | editor.commit(); 41 | } 42 | 43 | public void setValue(String key, boolean value) { 44 | SharedPreferences sp = getSp(); 45 | SharedPreferences.Editor editor = sp.edit(); 46 | editor.putBoolean(key, value); 47 | editor.commit(); 48 | } 49 | 50 | public long getLongValue(String key) { 51 | SharedPreferences sp = getSp(); 52 | return sp.getLong(key, 0); 53 | } 54 | 55 | public boolean getBooleanValue(String key) { 56 | SharedPreferences sp = getSp(); 57 | return sp.getBoolean(key, false); 58 | } 59 | 60 | public boolean getBooleanValue(String key, boolean defaultValue) { 61 | SharedPreferences sp = getSp(); 62 | return sp.getBoolean(key, defaultValue); 63 | } 64 | 65 | public int getIntValue(String key) { 66 | SharedPreferences sp = getSp(); 67 | return sp.getInt(key, 0); 68 | } 69 | 70 | public String getValue(String key) { 71 | return getValue(key, ""); 72 | } 73 | 74 | public String getValue(String key, String defaultValue) { 75 | SharedPreferences sp = getSp(); 76 | return sp.getString(key, defaultValue); 77 | } 78 | 79 | public void clear() { 80 | SharedPreferences sp = getSp(); 81 | SharedPreferences.Editor editor = sp.edit(); 82 | editor.clear(); 83 | editor.commit(); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/AppImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zzc.baselib.util.PackageUtils; 4 | import com.zzc.easycomponents.base.Easys; 5 | import com.zzc.easycomponents.util.App; 6 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 7 | /** 8 | * @author Roye 9 | * @date 2018/11/13 10 | */ 11 | @EasyUtil 12 | public class AppImpl extends App { 13 | 14 | public int versionCode() { 15 | return PackageUtils.getVersionCode(Easys.getApp()); 16 | } 17 | 18 | @Override 19 | public String version() { 20 | return PackageUtils.getVersion(Easys.getApp()); 21 | } 22 | 23 | @Override 24 | public String packageName() { 25 | return Easys.getApp().getPackageName(); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/DeviceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import android.os.Build; 4 | 5 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 6 | import com.zzc.baselib.util.DeviceUtils; 7 | import com.zzc.easycomponents.base.Easys; 8 | import com.zzc.easycomponents.util.Device; 9 | 10 | /** 11 | * @author Roye 12 | * @date 2018/11/13 13 | */ 14 | @EasyUtil 15 | public class DeviceImpl extends Device { 16 | 17 | @Override 18 | public String imei() { 19 | return DeviceUtils.getIMEI(Easys.getApp()); 20 | } 21 | 22 | @Override 23 | public String brand() { 24 | return Build.BRAND; 25 | } 26 | 27 | @Override 28 | public String model() { 29 | return Build.MODEL; 30 | } 31 | 32 | @Override 33 | public String device() { 34 | return Build.DEVICE; 35 | } 36 | 37 | @Override 38 | public String product() { 39 | return Build.PRODUCT; 40 | } 41 | 42 | @Override 43 | public String display() { 44 | return Build.DISPLAY; 45 | } 46 | 47 | @Override 48 | public String manufacture() { 49 | return Build.MANUFACTURER; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/DimenImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 4 | import com.zzc.baselib.base.AppBase; 5 | import com.zzc.baselib.util.UIUtils; 6 | import com.zzc.easycomponents.util.Dimen; 7 | 8 | /** 9 | * @author Roye 10 | * @date 2018/11/13 11 | */ 12 | @EasyUtil 13 | public class DimenImpl extends Dimen { 14 | 15 | public DimenImpl() { 16 | UIUtils.init(AppBase.app); 17 | } 18 | 19 | @Override 20 | public int dp2px(float dpValue) { 21 | return UIUtils.dp2px(dpValue); 22 | } 23 | 24 | @Override 25 | public int px2dp(float pxValue) { 26 | return UIUtils.px2dp(pxValue); 27 | } 28 | 29 | @Override 30 | public int getScreenMinEdge() { 31 | return UIUtils.getScreenMinEdge(AppBase.app); 32 | } 33 | 34 | @Override 35 | public int getScreenHeight() { 36 | return UIUtils.getScreenHeight(AppBase.app); 37 | } 38 | 39 | @Override 40 | public int getScreenWidth() { 41 | return UIUtils.getScreenWidth(AppBase.app); 42 | } 43 | 44 | @Override 45 | public int getStatusBarHeight() { 46 | return UIUtils.getStatusBarHeight(AppBase.app); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/NetworkImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 4 | import com.zzc.baselib.util.NetworkUtils; 5 | import com.zzc.easycomponents.util.Network; 6 | 7 | /** 8 | * @author Roye 9 | * @date 2018/11/13 10 | */ 11 | @EasyUtil 12 | public class NetworkImpl extends Network { 13 | 14 | @Override 15 | public boolean isAvailable() { 16 | return NetworkUtils.isAvailable(); 17 | } 18 | 19 | @Override 20 | public boolean is2G() { 21 | return NetworkUtils.is2G(); 22 | } 23 | 24 | @Override 25 | public boolean isWifi() { 26 | return NetworkUtils.isWifi(); 27 | } 28 | 29 | @Override 30 | public String getType() { 31 | return NetworkUtils.getType(); 32 | } 33 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/ResourceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 4 | import com.zzc.baselib.util.ResourceUtils; 5 | import com.zzc.easycomponents.util.Resource; 6 | 7 | /** 8 | * @author Roye 9 | * @date 2018/11/13 10 | */ 11 | @EasyUtil 12 | public class ResourceImpl extends Resource { 13 | 14 | @Override 15 | public int getAnim(String name) { 16 | return ResourceUtils.getAnim(name); 17 | } 18 | 19 | @Override 20 | public int getAttr(String name) { 21 | return ResourceUtils.getAttr(name); 22 | } 23 | 24 | @Override 25 | public int getColor(String name) { 26 | return ResourceUtils.getColor(name); 27 | } 28 | 29 | @Override 30 | public int getDrawable(String name) { 31 | return ResourceUtils.getDrawable(name); 32 | } 33 | 34 | @Override 35 | public int getId(String name) { 36 | return ResourceUtils.getId(name); 37 | } 38 | 39 | @Override 40 | public int getLayout(String name) { 41 | return ResourceUtils.getLayout(name); 42 | } 43 | 44 | @Override 45 | public int getString(String name) { 46 | return ResourceUtils.getString(name); 47 | } 48 | 49 | @Override 50 | public int getStyle(String name) { 51 | return ResourceUtils.getStyle(name); 52 | } 53 | 54 | @Override 55 | public int getMipmap(String name) { 56 | return ResourceUtils.getMipmap(name); 57 | } 58 | 59 | @Override 60 | public int getRes(String type, String name) { 61 | return ResourceUtils.getRes(type, name); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/ToastImpl.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zuzuche.easycomponents.common.annotation.EasyUtil; 4 | import com.zzc.baselib.util.ToastUtils; 5 | import com.zzc.easycomponents.util.Toast; 6 | 7 | /** 8 | * @author Roye 9 | * @date 2018/11/13 10 | */ 11 | @EasyUtil 12 | public class ToastImpl extends Toast { 13 | @Override 14 | public boolean isTooFast() { 15 | return ToastUtils.isTooFast(); 16 | } 17 | 18 | @Override 19 | public boolean isTooFast(int delay) { 20 | return ToastUtils.isTooFast(delay); 21 | } 22 | 23 | @Override 24 | public boolean isSame(String msg) { 25 | return ToastUtils.isSame(msg); 26 | } 27 | 28 | @Override 29 | public void showToast(String msg) { 30 | ToastUtils.showToast(msg); 31 | } 32 | 33 | @Override 34 | public void showToast(int resId) { 35 | ToastUtils.showToast(resId); 36 | } 37 | 38 | @Override 39 | public void showToastAtCenter(String msg) { 40 | ToastUtils.showToastAtCenter(msg); 41 | } 42 | 43 | @Override 44 | public void showToastAtCenter(int resId) { 45 | ToastUtils.showToastAtCenter(resId); 46 | } 47 | 48 | @Override 49 | public void showToastAtTop(String msg) { 50 | ToastUtils.showToastAtTop(msg); 51 | } 52 | 53 | @Override 54 | public void showToastAtTop(int resId) { 55 | ToastUtils.showToastAtTop(resId); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/easycomponent/UtilsInitialize.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.easycomponent; 2 | 3 | import com.zzc.easycomponents.util.Utils; 4 | 5 | /** 6 | * @author Roye 7 | * @date 2018/11/13 8 | */ 9 | public class UtilsInitialize { 10 | 11 | public static void init(){ 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 包含: 3 | 1 life-arch,livedata基本封装 4 | 2 基础SharePerference封装 5 | 3 环境设置,包括接口环境,debug环境(可控制日志输出) 6 | 4 基础Activity/Fragment 7 | 5 dialog, tab, statusbar 8 | 6 recyclerview快速开发 9 | 7 viewtools 10 | 8 动态权限 11 | 9 工具类 12 | 10 多任务处理Rxjava 13 | 11 Eventbus事件总线 14 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/support/permission/InstallRationale.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.support.permission; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | 6 | import com.yanzhenjie.permission.Rationale; 7 | import com.yanzhenjie.permission.RequestExecutor; 8 | 9 | import java.io.File; 10 | import com.zzc.baselib.R; 11 | 12 | /** 13 | * Created by YanZhenjie on 2018/4/29. 14 | */ 15 | public class InstallRationale implements Rationale { 16 | 17 | @Override 18 | public void showRationale(Context context, File data, final RequestExecutor executor) { 19 | new PermissionDialog.Builder(context) 20 | .canCancel(false) 21 | .title(R.string.common_tips) 22 | .message("您的手机不允许安装应用") 23 | .positive(R.string.common_resume) 24 | .cancel(R.string.common_cancel) 25 | .onClickListener(new DialogInterface.OnClickListener() { 26 | @Override 27 | public void onClick(DialogInterface dialog, int which) { 28 | if (DialogInterface.BUTTON_POSITIVE == which) { 29 | executor.execute(); 30 | } else { 31 | executor.cancel(); 32 | } 33 | } 34 | }).createDialog(true).show(); 35 | } 36 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/support/permission/OverlayRationale.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.support.permission; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | 6 | import com.yanzhenjie.permission.Rationale; 7 | import com.yanzhenjie.permission.RequestExecutor; 8 | import com.zzc.baselib.R; 9 | 10 | /** 11 | * Created by YanZhenjie on 2018/5/30. 12 | */ 13 | public class OverlayRationale implements Rationale { 14 | @Override 15 | public void showRationale(Context context, Void data, final RequestExecutor executor) { 16 | String message = String.format(context.getString(R.string.common_permission_resume_message), context.getString(R.string.common_floatwindow)); 17 | new PermissionDialog.Builder(context) 18 | .canCancel(false) 19 | .title(R.string.common_tips) 20 | .message(message) 21 | .positive(R.string.common_resume) 22 | .cancel(R.string.common_cancel) 23 | .onClickListener(new DialogInterface.OnClickListener() { 24 | @Override 25 | public void onClick(DialogInterface dialog, int which) { 26 | if (DialogInterface.BUTTON_POSITIVE == which) { 27 | executor.execute(); 28 | } else { 29 | executor.cancel(); 30 | } 31 | } 32 | }).createDialog(true).show(); 33 | } 34 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/support/permission/RuntimeRationale.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.support.permission; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.text.TextUtils; 6 | 7 | import com.yanzhenjie.permission.Permission; 8 | import com.yanzhenjie.permission.Rationale; 9 | import com.yanzhenjie.permission.RequestExecutor; 10 | import com.zzc.baselib.R; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by YanZhenjie on 2018/1/1. 16 | */ 17 | public final class RuntimeRationale implements Rationale> { 18 | 19 | @Override 20 | public void showRationale(Context context, List permissions, final RequestExecutor executor) { 21 | List permissionNames = Permission.transformText(context, permissions); 22 | String title = context.getString(R.string.common_title_tips, TextUtils.join("\n", permissionNames)); 23 | String message = context.getString(R.string.message_permission_always_failed, TextUtils.join("\n", permissionNames)); 24 | 25 | new PermissionDialog.Builder(context) 26 | .canCancel(false) 27 | .title(title) 28 | .message(message) 29 | .positive(R.string.common_setting) 30 | .cancel(R.string.common_cancel) 31 | .onClickListener(new DialogInterface.OnClickListener() { 32 | @Override 33 | public void onClick(DialogInterface dialog, int which) { 34 | if (DialogInterface.BUTTON_POSITIVE == which) { 35 | executor.execute(); 36 | } else { 37 | executor.cancel(); 38 | } 39 | } 40 | }).createDialog(true).show(); 41 | } 42 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/support/rx/RxSimple.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.support.rx; 2 | 3 | import io.reactivex.Observable; 4 | import io.reactivex.ObservableOnSubscribe; 5 | import io.reactivex.android.schedulers.AndroidSchedulers; 6 | import io.reactivex.functions.Function; 7 | import io.reactivex.schedulers.Schedulers; 8 | 9 | /** 10 | * @author Roye 11 | * @date 2018/9/6 12 | */ 13 | public class RxSimple { 14 | 15 | public static Observable createSubscriber(ObservableOnSubscribe observableOnSubscribe) { 16 | Observable observable = Observable.create(observableOnSubscribe) 17 | .subscribeOn(Schedulers.io()) 18 | .observeOn(AndroidSchedulers.mainThread()); 19 | return observable; 20 | } 21 | 22 | public static Observable createMap(Function function, T input) { 23 | Observable observable = Observable.just(input).map(function).subscribeOn(Schedulers.io()) 24 | .observeOn(AndroidSchedulers.mainThread()); 25 | return observable; 26 | } 27 | 28 | public static void runOnUIThread(final Runnable runnable) { 29 | Observable.just("").map(new Function() { 30 | @Override 31 | public String apply(String s) throws Exception { 32 | runnable.run(); 33 | return ""; 34 | } 35 | }).subscribeOn(AndroidSchedulers.mainThread()).subscribe(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/BaseLiveActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui; 2 | 3 | import android.arch.lifecycle.Observer; 4 | import android.arch.lifecycle.ViewModelProviders; 5 | import android.support.annotation.Nullable; 6 | 7 | import com.zzc.baselib.arch.ActionEntity; 8 | import com.zzc.baselib.arch.UIBehaviorViewModel; 9 | 10 | /** 11 | * @author Roye 12 | * @date 2018/11/14 13 | */ 14 | public class BaseLiveActivity extends BaseActivity { 15 | 16 | public void addBaseUIObserver() { 17 | UIBehaviorViewModel viewModel = ViewModelProviders.of(this).get(UIBehaviorViewModel.class); 18 | viewModel.loading().observe(this, new Observer() { 19 | @Override 20 | public void onChanged(@Nullable ActionEntity data) { 21 | if (data != null) { 22 | if (data.id == UIBehaviorViewModel.LOADING_SHOW) { 23 | if (data.extra != null && data.extra[0] != null) { 24 | showLoading(String.valueOf(data.extra[0])); 25 | } 26 | } else { 27 | hideLoading(); 28 | } 29 | } 30 | } 31 | }); 32 | viewModel.animation().observe(this, new Observer() { 33 | @Override 34 | public void onChanged(@Nullable ActionEntity data) { 35 | if (data != null) { 36 | } 37 | } 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/BaseToolbarFragment.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.zzc.baselib.R; 12 | 13 | /** 14 | * Created by Roye on 2018/5/25. 15 | */ 16 | public class BaseToolbarFragment extends BaseFragment { 17 | 18 | @Nullable 19 | @Override 20 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 21 | View root = super.onCreateView(inflater, container, savedInstanceState); 22 | 23 | Toolbar toolbar = root.findViewById(R.id.toolbar); 24 | if (toolbar != null) 25 | toolbar.setNavigationOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View v) { 28 | getActivity().onBackPressed(); 29 | } 30 | }); 31 | 32 | return root; 33 | } 34 | 35 | public void setTitle(String title) { 36 | TextView customTitleName = findView(R.id.custom_title_name); 37 | if (customTitleName != null) 38 | customTitleName.setText(title); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/ToolbarBaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.Toolbar; 5 | import android.view.MenuItem; 6 | import android.view.View; 7 | import android.widget.TextView; 8 | 9 | import com.zzc.baselib.R; 10 | 11 | public abstract class ToolbarBaseActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener { 12 | 13 | protected Toolbar toolbar; 14 | protected TextView customTitleName; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | 20 | toolbar = findView(R.id.toolbar); 21 | customTitleName = findView(R.id.custom_title_name); 22 | setupToolbar(); 23 | } 24 | 25 | protected void setupToolbar() { 26 | if (toolbar != null) { 27 | if (customTitleName != null) { 28 | toolbar.setTitle(""); 29 | customTitleName.setText(getTitle()); 30 | } else { 31 | toolbar.setTitle(getTitle()); 32 | } 33 | if (hideNavigationIcon()) { 34 | toolbar.setNavigationIcon(null); 35 | } else { 36 | toolbar.setNavigationOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | onBackPressed(); 40 | } 41 | }); 42 | } 43 | int menu = getToolbarInflateMenu(); 44 | if (menu > 0) { 45 | toolbar.getMenu().clear(); 46 | toolbar.inflateMenu(menu); 47 | toolbar.setOnMenuItemClickListener(this); 48 | } 49 | } 50 | } 51 | 52 | protected int getToolbarInflateMenu() { 53 | return 0; 54 | } 55 | 56 | protected boolean hideNavigationIcon() { 57 | return false; 58 | } 59 | 60 | @Override 61 | public boolean onMenuItemClick(MenuItem menuItem) { 62 | return false; 63 | } 64 | 65 | public void setTitleName(CharSequence title) { 66 | if (customTitleName != null) { 67 | customTitleName.setText(title); 68 | } else if (toolbar != null) { 69 | toolbar.setTitle(title); 70 | } 71 | } 72 | 73 | public Toolbar getToolbar() { 74 | return toolbar; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/dialog/BaseDialog.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.dialog; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.StyleRes; 8 | import android.view.Gravity; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.view.WindowManager; 12 | import android.widget.FrameLayout; 13 | 14 | import com.zzc.baselib.R; 15 | 16 | /** 17 | * 自定义dialog基础类 18 | * 19 | * @author MUTOU 20 | */ 21 | public abstract class BaseDialog extends Dialog { 22 | 23 | /** 是否位于底部 */ 24 | protected boolean alignBottom = false; 25 | 26 | public BaseDialog(Context context) { 27 | this(context, false); 28 | } 29 | 30 | /** 31 | * @param context 32 | * @param alignBottom 是否位于底部,从底部弹出 33 | */ 34 | public BaseDialog(Context context, boolean alignBottom) { 35 | this(context, R.style.Dialog, alignBottom); 36 | } 37 | 38 | public BaseDialog(@NonNull Context context, @StyleRes int themeResId) { 39 | this(context, themeResId, false); 40 | } 41 | 42 | public BaseDialog(@NonNull Context context, @StyleRes int themeResId, boolean alignBottom) { 43 | super(context, themeResId); 44 | this.alignBottom = alignBottom; 45 | if (alignBottom) { 46 | WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); 47 | layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; 48 | onWindowAttributesChanged(layoutParams); 49 | getWindow().setWindowAnimations(R.style.DialogAnim_Bottom); 50 | } 51 | } 52 | 53 | @Override 54 | protected void onCreate(Bundle savedInstanceState) { 55 | super.onCreate(savedInstanceState); 56 | FrameLayout layout = new FrameLayout(getContext()); 57 | View view = getView(layout); 58 | view.setMinimumWidth(getMinimumWidth()); 59 | layout.addView(view); 60 | setContentView(layout); 61 | } 62 | 63 | /** 64 | * dialog 最小宽度 65 | * 66 | * @return 67 | */ 68 | protected int getMinimumWidth() { 69 | int width = getContext().getResources().getDisplayMetrics().widthPixels; 70 | return alignBottom ? width : (int) (width * 0.75); 71 | } 72 | 73 | /** 74 | * 获取Dialog视图,由子类实现并返回 75 | * 76 | * @return 77 | */ 78 | protected abstract View getView(ViewGroup parent); 79 | 80 | } 81 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/listener/IProgressDialog.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.listener; 2 | 3 | /** 4 | * Created by Roye on 2018/5/18. 5 | */ 6 | public interface IProgressDialog { 7 | 8 | public void showLoading(String text); 9 | public void hideLoading(); 10 | } 11 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/listener/IRxObserveDisposer.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.listener; 2 | 3 | import io.reactivex.disposables.Disposable; 4 | 5 | /** 6 | * Created by Roye on 2018/5/18. 7 | */ 8 | public interface IRxObserveDisposer { 9 | 10 | public void addDisposable(Disposable disposable); 11 | } 12 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/viewtools/CanClickChecker.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.viewtools; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.text.Editable; 5 | import android.text.TextWatcher; 6 | import android.view.View; 7 | import android.widget.RadioGroup; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by Roye on 2018/6/6. 12 | */ 13 | public class CanClickChecker { 14 | 15 | private View clickView; 16 | private int clickValues; 17 | private int canClickValue; 18 | 19 | public CanClickChecker(View clickView) { 20 | this.clickView = clickView; 21 | } 22 | 23 | public void setCheckWidgets(View... widgets) { 24 | clickValues = 0; 25 | for (int i = 0; i < widgets.length; i++) { 26 | final int c = i; 27 | canClickValue |= 1 << c; 28 | if (widgets[i] instanceof TextView) { 29 | ((TextView) widgets[c]).addTextChangedListener(new TextWatcher() { 30 | @Override 31 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 32 | 33 | } 34 | 35 | @Override 36 | public void onTextChanged(CharSequence s, int start, int before, int count) { 37 | 38 | } 39 | 40 | @Override 41 | public void afterTextChanged(Editable s) { 42 | int bitValue = 1 << c; 43 | if (s.length() == 0) { 44 | clickValues &= (0xffff ^ bitValue); 45 | } else { 46 | clickValues |= bitValue; 47 | } 48 | setClickState(); 49 | } 50 | }); 51 | } else if (widgets[i] instanceof RadioGroup) { 52 | RadioGroup radioGroup = (RadioGroup) widgets[i]; 53 | radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { 54 | @SuppressLint("ResourceType") 55 | @Override 56 | public void onCheckedChanged(RadioGroup group, int checkedId) { 57 | int bitValue = 1 << c; 58 | if (group.getCheckedRadioButtonId() < 1) { 59 | clickValues &= (0xffff ^ bitValue); 60 | } else { 61 | clickValues |= bitValue; 62 | } 63 | setClickState(); 64 | } 65 | }); 66 | } 67 | } 68 | setClickState(); 69 | } 70 | 71 | 72 | private void setClickState() { 73 | clickView.setEnabled(canClickValue == clickValues); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/viewtools/OnSingleClickListener.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.viewtools; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * @author Roye 7 | * @date 2018/10/8 8 | */ 9 | public abstract class OnSingleClickListener implements View.OnClickListener { 10 | 11 | @Override 12 | public void onClick(View v) { 13 | if (RepeatClickChecker.invalidClick(v)) { 14 | return; 15 | } 16 | onSingleClick(v); 17 | } 18 | 19 | public abstract void onSingleClick(View view); 20 | } 21 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/viewtools/RepeatClickChecker.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.viewtools; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by Roye on 2018/6/6. 7 | */ 8 | public class RepeatClickChecker { 9 | 10 | private static long clickTime = 0; 11 | private static int viewHashcode = 0; 12 | 13 | public static boolean invalidClick(View view) { 14 | long current = System.currentTimeMillis(); 15 | 16 | if (view.hashCode() != viewHashcode) { 17 | viewHashcode = view.hashCode(); 18 | clickTime = current; 19 | return false; 20 | } 21 | if (current - clickTime < 1000) { 22 | clickTime = current; 23 | return true; 24 | } else { 25 | clickTime = current; 26 | return false; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/recyclerview/AutoView.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.recyclerview; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by Roye on 2016/12/12. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.FIELD) 13 | public @interface AutoView { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/recyclerview/HolderRes.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.recyclerview; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by Roye on 2016/12/12. 10 | */ 11 | 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target(ElementType.TYPE) 14 | public @interface HolderRes { 15 | int value() default 0; 16 | 17 | String resName() default ""; 18 | } 19 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/recyclerview/OnRecyclerviewItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.recyclerview; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by Roye on 2018/5/31. 7 | */ 8 | public interface OnRecyclerviewItemClickListener { 9 | 10 | public void onItemClickListener(View child, TalentHolderInfo holderInfo); 11 | } 12 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/recyclerview/TalentHolder.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.recyclerview; 2 | 3 | import android.app.Activity; 4 | import android.content.res.Resources; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.Log; 7 | import android.view.View; 8 | 9 | import com.zzc.baselib.arch.ActivityUtils; 10 | 11 | import java.lang.reflect.Field; 12 | 13 | /** 14 | * Created by Roye on 2016/12/10. 15 | */ 16 | 17 | public abstract class TalentHolder extends RecyclerView.ViewHolder { 18 | 19 | String TAG = TalentHolder.class.getSimpleName(); 20 | 21 | public T itemValue; 22 | public OnRecyclerviewItemClickListener mItemClickListener; 23 | 24 | public TalentHolder(View itemView) { 25 | super(itemView); 26 | initView(); 27 | } 28 | 29 | public final void bind(T data) { 30 | itemValue = data; 31 | Activity activity = ActivityUtils.getActivity(itemView.getContext()); 32 | if (activity != null && (activity.isFinishing() || activity.isDestroyed())) { 33 | Log.w(TAG, "activity is finishing or destroyed."); 34 | return; 35 | } 36 | toView(); 37 | } 38 | 39 | public void initView() { 40 | Field[] fields = getClass().getDeclaredFields(); 41 | if (fields != null) { 42 | Resources res = itemView.getResources(); 43 | String packageName = itemView.getContext().getPackageName(); 44 | try { 45 | for (int i = 0; i < fields.length; i++) { 46 | if (fields[i].getAnnotation(AutoView.class) != null) { 47 | String viewName = fields[i].getName(); 48 | View view = itemView.findViewById(res.getIdentifier(viewName, "id", packageName)); 49 | if (view != null) { 50 | fields[i].setAccessible(true); 51 | fields[i].set(this, view); 52 | } 53 | } 54 | } 55 | } catch (IllegalAccessException e) { 56 | e.printStackTrace(); 57 | } 58 | } 59 | } 60 | 61 | protected void setOnItemClick(OnRecyclerviewItemClickListener listener) { 62 | mItemClickListener = listener; 63 | 64 | if (listener == null || itemView.hasOnClickListeners()) {//不覆盖item的原来click事件 65 | return; 66 | } 67 | itemView.setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | TalentHolderInfo holderInfo = new TalentHolderInfo(TalentHolder.this.getClass(), itemValue, getAdapterPosition()); 71 | mItemClickListener.onItemClickListener(v, holderInfo); 72 | } 73 | }); 74 | } 75 | 76 | //局部刷新 77 | public void onPayload(Object payload) { 78 | 79 | } 80 | 81 | public T findV(int resId) { 82 | return (T) itemView.findViewById(resId); 83 | } 84 | 85 | public abstract void toView(); 86 | 87 | public void recycle() { 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/recyclerview/TalentHolderInfo.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.recyclerview; 2 | 3 | /** 4 | * @author Roye 5 | * @date 2018/6/30 6 | */ 7 | public class TalentHolderInfo { 8 | 9 | public int position; 10 | public Class holderClass; 11 | public Object itemValue; 12 | 13 | public TalentHolderInfo(Class holderClass, Object itemValue, int position) { 14 | this.holderClass = holderClass; 15 | this.itemValue = itemValue; 16 | this.position = position; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/statusbar/StatusBarRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.statusbar; 2 | 3 | import android.arch.lifecycle.Lifecycle; 4 | import android.arch.lifecycle.LifecycleObserver; 5 | import android.arch.lifecycle.LifecycleOwner; 6 | import android.arch.lifecycle.OnLifecycleEvent; 7 | import android.content.Context; 8 | import android.support.annotation.Nullable; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.util.AttributeSet; 11 | 12 | import com.zzc.baselib.arch.ActivityUtils; 13 | 14 | /** 15 | * @author Roye 16 | * @date 2018/8/16 17 | */ 18 | public class StatusBarRecyclerView extends RecyclerView implements LifecycleObserver { 19 | 20 | int scrolly; 21 | AppCompatStatusBar appCompatStatusBar; 22 | 23 | public StatusBarRecyclerView(Context context, @Nullable AttributeSet attrs) { 24 | super(context, attrs); 25 | 26 | Context lifecyContext = ActivityUtils.getActivity(context); 27 | if (lifecyContext instanceof LifecycleOwner) { 28 | ((LifecycleOwner) lifecyContext).getLifecycle().addObserver(this); 29 | } 30 | } 31 | 32 | @OnLifecycleEvent(Lifecycle.Event.ON_CREATE) 33 | public void onCreate() { 34 | appCompatStatusBar = new AppCompatStatusBar(getContext()); 35 | 36 | addOnScrollListener(new OnScrollListener() { 37 | @Override 38 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 39 | scrolly += dy; 40 | appCompatStatusBar.onScrollY(scrolly); 41 | } 42 | }); 43 | } 44 | 45 | public void onHiddenChanged(boolean hidden) { 46 | if (!hidden) { 47 | appCompatStatusBar.onScrollY(scrolly); 48 | } else { 49 | appCompatStatusBar.resetState(); 50 | } 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/ui/widget/statusbar/StatusBarView.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.ui.widget.statusbar; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by Jaeger on 16/6/8. 9 | * 10 | * Email: chjie.jaeger@gmail.com 11 | * GitHub: https://github.com/laobie 12 | */ 13 | public class StatusBarView extends View { 14 | 15 | public StatusBarView(Context context, AttributeSet attrs) { 16 | super(context, attrs); 17 | } 18 | 19 | public StatusBarView(Context context) { 20 | super(context); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * Created by Roye on 2017/7/1. 7 | */ 8 | 9 | public class CollectionUtils { 10 | 11 | public static boolean isEmpty(Collection list) { 12 | return list == null || list.isEmpty(); 13 | } 14 | 15 | public static boolean has(int target, int... vals) { 16 | if (vals == null) { 17 | return true; 18 | } 19 | for (int i = 0; i < vals.length; i++) { 20 | if (target == vals[i]) { 21 | return true; 22 | } 23 | } 24 | return false; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/DeviceToken.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import java.io.Serializable; 4 | 5 | public class DeviceToken implements Serializable { 6 | 7 | public String token; 8 | } 9 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/MD5.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.FileInputStream; 6 | import java.io.InputStream; 7 | import java.io.UnsupportedEncodingException; 8 | import java.security.MessageDigest; 9 | import java.security.NoSuchAlgorithmException; 10 | 11 | public class MD5 12 | { 13 | private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 14 | 'a', 'b', 'c', 'd', 'e', 'f' }; 15 | 16 | public static String toHexString(byte[] b) { 17 | StringBuilder sb = new StringBuilder(b.length * 2); 18 | for (byte element : b) { 19 | sb.append(HEX_DIGITS[(element & 0xf0) >>> 4]); 20 | sb.append(HEX_DIGITS[element & 0x0f]); 21 | } 22 | return sb.toString(); 23 | } 24 | 25 | public static String md5sum(String filename) { 26 | InputStream fis; 27 | byte[] buffer = new byte[1024]; 28 | int numRead = 0; 29 | MessageDigest md5; 30 | try{ 31 | fis = new FileInputStream(filename); 32 | md5 = MessageDigest.getInstance("MD5"); 33 | while ((numRead = fis.read(buffer)) > 0) { 34 | md5.update(buffer, 0, numRead); 35 | } 36 | fis.close(); 37 | return toHexString(md5.digest()); 38 | } catch (Exception e) { 39 | Log.v("MD5", "Error!"); 40 | return null; 41 | } 42 | } 43 | 44 | private static MessageDigest messageDigest; 45 | 46 | public synchronized static String toMd5(String string) { 47 | 48 | byte[] hash = null; 49 | 50 | try { 51 | if(messageDigest == null){ 52 | messageDigest = MessageDigest.getInstance("MD5"); 53 | } 54 | messageDigest.reset(); 55 | messageDigest.update(string.getBytes("UTF-8")); 56 | hash = messageDigest.digest(); 57 | 58 | } catch (NoSuchAlgorithmException e) { 59 | 60 | throw new RuntimeException("Huh, MD5 should be supported?", e); 61 | 62 | } catch (UnsupportedEncodingException e) { 63 | 64 | throw new RuntimeException("Huh, UTF-8 should be supported?", e); 65 | 66 | } 67 | 68 | StringBuffer md5StrBuff = new StringBuffer(); 69 | 70 | for (int i = 0; i < hash.length; i++) { 71 | if (Integer.toHexString(0xFF & hash[i]).length() == 1) 72 | md5StrBuff.append("0").append(Integer.toHexString(0xFF & hash[i])); 73 | else 74 | md5StrBuff.append(Integer.toHexString(0xFF & hash[i])); 75 | } 76 | 77 | return md5StrBuff.toString(); 78 | 79 | /*StringBuilder hex = new StringBuilder(hash.length * 2); 80 | 81 | for (byte b : hash) { 82 | 83 | if ((b & 0xFF) < 0x10) hex.append("0"); 84 | 85 | hex.append(Integer.toHexString(b & 0xFF)); 86 | 87 | } 88 | 89 | return hex.toString();*/ 90 | 91 | } 92 | 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/NumberUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class NumberUtils { 6 | 7 | public static int parseIntDef(String val) { 8 | int def = 0; 9 | try{ 10 | def = Integer.parseInt(val); 11 | }catch (Exception e) { 12 | def = 0; 13 | } 14 | return def; 15 | } 16 | 17 | public static int parseInt(String val, int defInt) { 18 | int def = defInt; 19 | try{ 20 | def = Integer.parseInt(val); 21 | }catch (Exception e) { 22 | } 23 | return def; 24 | } 25 | 26 | public static float parseFloat(String val, float defInt) { 27 | float def = defInt; 28 | try{ 29 | def = Float.parseFloat(val); 30 | }catch (Exception e) { 31 | } 32 | return def; 33 | } 34 | 35 | public static long parseLongDef(String val) { 36 | long def = 0; 37 | try{ 38 | def = Long.parseLong(val); 39 | }catch (Exception e) { 40 | def = 0; 41 | } 42 | return def; 43 | } 44 | 45 | public static int aroundInt(float val) { 46 | return new BigDecimal(val).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); 47 | } 48 | 49 | public static int aroundIntMore(float val) { 50 | int intVal = aroundInt(val); 51 | if (val > intVal) { 52 | return intVal + 1; 53 | } 54 | return intVal; 55 | } 56 | 57 | public static double round(double value, int scale, int roundingMode) { 58 | BigDecimal bd = new BigDecimal(value); 59 | bd = bd.setScale(scale, roundingMode); 60 | double d = bd.doubleValue(); 61 | bd = null; 62 | return d; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/PackageUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.ApplicationInfo; 7 | import android.content.pm.PackageInfo; 8 | import android.content.pm.PackageManager; 9 | import android.content.pm.PackageManager.NameNotFoundException; 10 | import android.content.pm.ResolveInfo; 11 | import android.net.Uri; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * PackageManager,PackageName的相关操作 17 | * 18 | * 19 | * @author yy:909012690@lishaoqi 20 | * @version 创建时间:2014-3-10 下午4:51:32 21 | */ 22 | public class PackageUtils { 23 | 24 | /** 25 | * 获取版本号 26 | * 27 | * @param context 28 | * @return 29 | */ 30 | public static String getVersion(Context context) { 31 | try { 32 | PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 33 | return pi.versionName; 34 | } catch (NameNotFoundException e) { 35 | // TODO Auto-generated catch block 36 | e.printStackTrace(); 37 | return "未知版本"; 38 | } 39 | } 40 | 41 | /** 42 | * 获取版本号(内部识别号) 43 | * 44 | * @param context 45 | * @return 46 | */ 47 | public static int getVersionCode(Context context) { 48 | try { 49 | PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 50 | return pi.versionCode; 51 | } catch (NameNotFoundException e) { 52 | // TODO Auto-generated catch block 53 | e.printStackTrace(); 54 | return 0; 55 | } 56 | } 57 | 58 | /** 59 | * 打开应用 60 | * 61 | * @param content 62 | * @param packageName 63 | * @param className 64 | */ 65 | public static void startApp(Context content, String packageName, String className) { 66 | ComponentName mComponentName = new ComponentName(packageName, className); 67 | Intent i = new Intent(); 68 | if (mComponentName != null) { 69 | i.setComponent(mComponentName); 70 | } 71 | content.startActivity(i); 72 | } 73 | 74 | /** 75 | * 列出所有应用 76 | * 77 | * @param context 78 | * @return 79 | */ 80 | public static List loadAllApps(Context context) { 81 | Intent intent = new Intent(Intent.ACTION_MAIN, null); 82 | intent.addCategory(Intent.CATEGORY_LAUNCHER); 83 | return context.getPackageManager().queryIntentActivities(intent, 0); 84 | } 85 | 86 | /** 87 | * 列出所有应用的信息 88 | * 89 | * @param context 90 | * @return 91 | */ 92 | public static List listApplicationInfos(Context context) { 93 | return context.getPackageManager().getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); 94 | } 95 | 96 | /** 97 | * uninstall package normal by system intent 98 | * 99 | * @param context 100 | * @param packageName 101 | * package name of app 102 | * @return whether package name is empty 103 | */ 104 | public static boolean uninstall(Context context, String packageName) { 105 | if (packageName == null || packageName.length() == 0) { 106 | return false; 107 | } 108 | 109 | Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse(new StringBuilder(32).append("package:").append(packageName).toString())); 110 | i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 111 | context.startActivity(i); 112 | return true; 113 | } 114 | 115 | public static ApplicationInfo getUninstallApkInfo(Context context, String apkPath) { 116 | PackageManager pm = context.getPackageManager(); 117 | PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES); 118 | if (info != null) { 119 | ApplicationInfo appInfo = info.applicationInfo; 120 | return appInfo; 121 | } 122 | 123 | return null; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/ResourceUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.content.res.Resources; 4 | 5 | import com.zzc.baselib.base.AppBase; 6 | 7 | public class ResourceUtils { 8 | 9 | public static int getAnim(String name) { 10 | return getRes("anim", name); 11 | } 12 | 13 | public static int getAttr(String name) { 14 | return getRes("attr", name); 15 | } 16 | 17 | public static int getColor(String name) { 18 | return getRes("color", name); 19 | } 20 | 21 | public static int getDrawable(String name) { 22 | return getRes("drawable", name); 23 | } 24 | 25 | public static int getId(String name) { 26 | return getRes("id", name); 27 | } 28 | 29 | public static int getLayout(String name) { 30 | return getRes("layout", name); 31 | } 32 | 33 | public static int getString(String name) { 34 | return getRes("string", name); 35 | } 36 | 37 | public static int getStyle(String name) { 38 | return getRes("style", name); 39 | } 40 | 41 | public static int getMipmap(String name) { 42 | return getRes("mipmap", name); 43 | } 44 | 45 | public static int getRes(String type, String name) { 46 | String packageName = AppBase.app.getPackageName(); 47 | Resources res = AppBase.app.getResources(); 48 | int identifier = res.getIdentifier(name, type, packageName); 49 | if (identifier == 0) { 50 | 51 | } 52 | return identifier; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/SDCardUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.os.Environment; 4 | import android.os.StatFs; 5 | 6 | import java.io.File; 7 | 8 | public class SDCardUtils { 9 | 10 | /** 11 | * 判断SDCard是否可用 12 | * 13 | * @return 14 | */ 15 | public static boolean isSDCardEnable() { 16 | String state = Environment.getExternalStorageState(); 17 | if (Environment.MEDIA_MOUNTED.equals(state) || !Environment.isExternalStorageRemovable()) { 18 | return true; 19 | } 20 | return false; 21 | 22 | } 23 | 24 | /** 25 | * 获取SD卡路径 26 | * 27 | * @return 28 | */ 29 | public static String getSDCardPath() { 30 | return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator; 31 | } 32 | 33 | /** 34 | * 获取SD卡的剩余容量 单位byte 35 | * 36 | * @return 37 | */ 38 | public static long getSDCardAllSize() { 39 | if (isSDCardEnable()) { 40 | StatFs stat = new StatFs(getSDCardPath()); 41 | // 获取空闲的数据块的数量 42 | long availableBlocks = (long) stat.getAvailableBlocks() - 4; 43 | // 获取单个数据块的大小(byte) 44 | long freeBlocks = stat.getAvailableBlocks(); 45 | return freeBlocks * availableBlocks; 46 | } 47 | return 0; 48 | } 49 | 50 | /** 51 | * 获取指定路径所在空间的剩余可用容量字节数,单位byte 52 | * 53 | * @param filePath 54 | * @return 容量字节 SDCard可用空间,内部存储可用空间 55 | */ 56 | public static long getFreeBytes(String filePath) { 57 | // 如果是sd卡的下的路径,则获取sd卡可用容量 58 | if (filePath.startsWith(getSDCardPath())) { 59 | filePath = getSDCardPath(); 60 | } else {// 如果是内部存储的路径,则获取内存存储的可用容量 61 | filePath = Environment.getDataDirectory().getAbsolutePath(); 62 | } 63 | StatFs stat = new StatFs(filePath); 64 | long availableBlocks = (long) stat.getAvailableBlocks() - 4; 65 | return stat.getBlockSize() * availableBlocks; 66 | } 67 | 68 | /** 69 | * 获取系统存储路径 70 | * 71 | * @return 72 | */ 73 | public static String getRootDirectoryPath() { 74 | return Environment.getRootDirectory().getAbsolutePath(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/SerializableUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.ObjectInputStream; 11 | import java.io.ObjectOutputStream; 12 | 13 | /** 14 | * @author yy:909012690@lishaoqi 15 | * @version 创建时间:2014年4月11日 下午6:10:41 16 | */ 17 | public class SerializableUtils { 18 | 19 | 20 | public static String output(Context context, String name, Object obj) { 21 | File folder = FileUtils.getFileDir(context, "serial"); 22 | return output(new File(folder, name), obj); 23 | } 24 | 25 | public static String output(File xmlFile, Object obj) { 26 | ObjectOutputStream oos = null; 27 | try { 28 | if (!xmlFile.exists()) 29 | xmlFile.createNewFile(); 30 | if (xmlFile.canWrite()) { 31 | oos = new ObjectOutputStream(new FileOutputStream(xmlFile)); 32 | oos.writeObject(obj); 33 | oos.flush(); 34 | return xmlFile.getAbsolutePath(); 35 | } 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } finally { 39 | if (oos != null) 40 | try { 41 | oos.close(); 42 | } catch (IOException e) { 43 | } 44 | } 45 | return null; 46 | } 47 | 48 | public static T load(Context context, String name, Class toValueType) { 49 | File folder = FileUtils.getFileDir(context, "serial"); 50 | return load(new File(folder, name), toValueType); 51 | } 52 | 53 | @SuppressWarnings("unchecked") 54 | public static synchronized T load(final File file, Class toValueType) { 55 | if(file == null || !file.exists()) 56 | return null; 57 | 58 | ObjectInputStream ois = null; 59 | try { 60 | ois = new ObjectInputStream(new FileInputStream(file)); 61 | Object obj = ois.readObject(); 62 | if (obj != null) 63 | return (T) obj; 64 | } catch (Exception e) { 65 | // xmlFile.delete(); 66 | Log.w("SerializableUtils", "load(): " + e.getMessage() + " name: " + file.getAbsolutePath()); 67 | e.printStackTrace(); 68 | } finally { 69 | if (ois != null) 70 | try { 71 | ois.close(); 72 | } catch (IOException e) { 73 | } 74 | } 75 | return null; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/T.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | /** 4 | * Created by Roye on 2018/4/8. 5 | */ 6 | 7 | public class T { 8 | 9 | public static int parseIntDef(String val) { 10 | int def = 0; 11 | try { 12 | def = Integer.parseInt(val); 13 | } catch (Exception e) { 14 | def = 0; 15 | } 16 | return def; 17 | } 18 | 19 | public static int parseInt(String val, int defInt) { 20 | int def = defInt; 21 | try { 22 | def = Integer.parseInt(val); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | return def; 27 | } 28 | 29 | public static long parseLongDef(String val) { 30 | long def = 0; 31 | try { 32 | def = Long.parseLong(val); 33 | } catch (Exception e) { 34 | def = 0; 35 | } 36 | return def; 37 | } 38 | 39 | public static int aroundInt(float val) { 40 | return new java.math.BigDecimal(val).setScale(0, java.math.BigDecimal.ROUND_HALF_UP).intValue(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/ToastUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.text.TextUtils; 4 | import android.view.Gravity; 5 | import android.widget.Toast; 6 | 7 | import com.zzc.baselib.base.AppBase; 8 | 9 | /** 10 | * Created by liqi on 2016-2-23. 11 | */ 12 | public class ToastUtils { 13 | 14 | private static long time = 0; 15 | private static String last = ""; 16 | 17 | public static boolean isTooFast() { 18 | return isTooFast(600); 19 | } 20 | 21 | public static boolean isTooFast(int delay) { 22 | long curTime = System.currentTimeMillis(); 23 | long span = curTime - time; 24 | time = curTime; 25 | if (span < delay) { 26 | return true; 27 | } else { 28 | return false; 29 | } 30 | } 31 | 32 | public static boolean isSame(String msg) { 33 | if (!TextUtils.isEmpty(msg)) { 34 | if (msg.equals(last)) 35 | return true; 36 | } 37 | last = msg; 38 | return false; 39 | } 40 | 41 | public static void showToast(final String msg) { 42 | if (!isTooFast() || !isSame(msg)) { 43 | UIRunner.runOnUI(new Runnable() { 44 | @Override 45 | public void run() { 46 | Toast.makeText(AppBase.app, msg, Toast.LENGTH_SHORT).show(); 47 | } 48 | }, 100); 49 | } 50 | } 51 | 52 | public static void showToast(int resId) { 53 | String msg = AppBase.app.getString(resId); 54 | showToast(msg); 55 | } 56 | 57 | public static void showToastAtCenter(String msg) { 58 | if (isTooFast()) 59 | return; 60 | if (AppBase.app == null) 61 | return; 62 | 63 | Toast toast = Toast.makeText(AppBase.app, msg, Toast.LENGTH_SHORT); 64 | toast.setGravity(Gravity.CENTER, 0, 0); 65 | toast.show(); 66 | } 67 | 68 | public static void showToastAtCenter(int resId) { 69 | if (isTooFast()) 70 | return; 71 | if (AppBase.app == null) 72 | return; 73 | 74 | Toast toast = Toast.makeText(AppBase.app, resId, Toast.LENGTH_SHORT); 75 | toast.setGravity(Gravity.CENTER, 0, 0); 76 | toast.show(); 77 | } 78 | 79 | public static void showToastAtTop(String msg) { 80 | if (isTooFast()) 81 | return; 82 | if (AppBase.app == null) 83 | return; 84 | Toast toast = Toast.makeText(AppBase.app, msg, Toast.LENGTH_SHORT); 85 | toast.setGravity(Gravity.TOP, 0, 200); 86 | toast.show(); 87 | } 88 | 89 | public static void showToastAtTop(int resId) { 90 | if (isTooFast()) 91 | return; 92 | if (AppBase.app == null) 93 | return; 94 | Toast toast = Toast.makeText(AppBase.app, resId, Toast.LENGTH_SHORT); 95 | toast.setGravity(Gravity.TOP, 0, 200); 96 | toast.show(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/java/com/zzc/baselib/util/UIRunner.java: -------------------------------------------------------------------------------- 1 | package com.zzc.baselib.util; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | public class UIRunner { 7 | 8 | static Handler mHandler; 9 | 10 | public static void runOnUI(Runnable runnable) { 11 | if (mHandler == null) { 12 | mHandler = new Handler(Looper.getMainLooper()); 13 | } 14 | mHandler.post(runnable); 15 | } 16 | 17 | public static void runOnUI(Runnable runnable, long delayMs) { 18 | if (mHandler == null) { 19 | mHandler = new Handler(Looper.getMainLooper()); 20 | } 21 | mHandler.postDelayed(runnable, delayMs); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_activity_page_frame.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_activity_page_frame_inc_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_default_placeholder_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_view_recycler_view_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 21 | 22 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_view_stateful.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /librarys/baselib/src/main/res/layout/base_view_version.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 22 | 23 |