├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── kotlinc.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── afbaselibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ ├── me
│ │ └── imid
│ │ │ └── swipebacklayout
│ │ │ └── lib
│ │ │ ├── SwipeBackLayout.java
│ │ │ ├── Utils.java
│ │ │ ├── ViewDragHelper.java
│ │ │ └── app
│ │ │ ├── SwipeBackActivityBase.java
│ │ │ └── SwipeBackActivityHelper.java
│ └── net
│ │ └── arvin
│ │ └── afbaselibrary
│ │ ├── events
│ │ ├── Event.java
│ │ └── FinishAllEvent.java
│ │ ├── listeners
│ │ ├── ICheckPerm.java
│ │ ├── ITabContent.java
│ │ ├── ITabPager.java
│ │ ├── IWeakHandler.java
│ │ └── OnClickWithObjects.java
│ │ ├── mvp
│ │ ├── presenters
│ │ │ └── BasePresenter.java
│ │ └── views
│ │ │ └── IBaseView.java
│ │ ├── nets
│ │ ├── BaseNet.java
│ │ ├── callbacks
│ │ │ └── AbsAPICallback.java
│ │ ├── converters
│ │ │ ├── GsonConverterFactory.java
│ │ │ ├── GsonRequestBodyConverter.java
│ │ │ └── GsonResponseBodyConverter.java
│ │ ├── entities
│ │ │ ├── InputErrorEntity.java
│ │ │ ├── PageListEntity.java
│ │ │ └── ResultEntity.java
│ │ └── exceptions
│ │ │ ├── ApiException.java
│ │ │ └── ResultException.java
│ │ ├── uis
│ │ ├── activities
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseHeaderActivity.java
│ │ │ ├── BaseHtmlActivity.java
│ │ │ ├── BaseRefreshActivity.java
│ │ │ ├── BaseRefreshLoadingActivity.java
│ │ │ ├── BaseSwipeBackActivity.java
│ │ │ └── BaseTabActivity.java
│ │ ├── adapters
│ │ │ ├── BaseAdapter.java
│ │ │ ├── ItemViewDelegate.java
│ │ │ ├── ItemViewDelegateManager.java
│ │ │ ├── MultiItemTypeAdapter.java
│ │ │ ├── TabPagerAdapter.java
│ │ │ ├── holders
│ │ │ │ └── CommonHolder.java
│ │ │ └── wrapper
│ │ │ │ ├── EmptyWrapper.java
│ │ │ │ └── WrapperUtils.java
│ │ └── fragments
│ │ │ ├── BaseFragment.java
│ │ │ ├── BaseRefreshFragment.java
│ │ │ ├── BaseRefreshLoadingFragment.java
│ │ │ └── BaseTabFragment.java
│ │ ├── utils
│ │ ├── AFUtil.java
│ │ ├── ActivityUtil.java
│ │ ├── CertificateUtil.java
│ │ ├── EasyPermissionUtil.java
│ │ ├── FileUtil.java
│ │ ├── GlideUtil.java
│ │ ├── ScreenUtil.java
│ │ ├── TimeUtil.java
│ │ └── WeakHandler.java
│ │ └── widgets
│ │ ├── CircleIndicator.java
│ │ ├── GlideCircleTransform.java
│ │ ├── PagerSlidingTabStrip.java
│ │ ├── ProgressWebView.java
│ │ ├── TabStripView.java
│ │ └── WebView4Scroll.java
│ └── res
│ ├── anim
│ ├── af_right_out.xml
│ ├── scale_with_alpha.xml
│ └── ui_right_in.xml
│ ├── drawable-v21
│ └── bg_item.xml
│ ├── drawable-xhdpi
│ ├── ui_shadow_bottom.png
│ ├── ui_shadow_left.png
│ └── ui_shadow_right.png
│ ├── drawable-xxhdpi
│ ├── img_default_avatar.png
│ └── img_loading.png
│ ├── drawable
│ ├── bg_item.xml
│ ├── progeress_bar_style.xml
│ ├── selector_tab.xml
│ ├── ui_white_corner_bg.xml
│ └── white_radius.xml
│ ├── layout
│ ├── ui_layout_divider.xml
│ ├── ui_layout_empty.xml
│ ├── ui_layout_navi_tab_view.xml
│ ├── ui_layout_refresh.xml
│ ├── ui_layout_swipeback.xml
│ ├── ui_layout_tab.xml
│ └── ui_layout_webview.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── pre_identify.xml
│ ├── strings.xml
│ └── style.xml
├── aidlclient
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── readme.md
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── aidl
│ └── net
│ │ └── arvin
│ │ └── androidart
│ │ └── aidl
│ │ ├── IBinderPool.aidl
│ │ ├── IIntegerAdd.aidl
│ │ ├── IOnNewPersonIn.aidl
│ │ ├── IPersonCount.aidl
│ │ └── Person.aidl
│ ├── java
│ └── net
│ │ └── arvin
│ │ ├── aidlclient
│ │ ├── BinderPool.java
│ │ └── MainActivity.java
│ │ └── androidart
│ │ └── aidl
│ │ └── Person.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── aidl
│ └── net
│ │ └── arvin
│ │ └── androidart
│ │ └── aidl
│ │ ├── IBinderPool.aidl
│ │ ├── IIntegerAdd.aidl
│ │ ├── IOnNewPersonIn.aidl
│ │ ├── IPersonCount.aidl
│ │ └── Person.aidl
│ ├── java
│ └── net
│ │ └── arvin
│ │ └── androidart
│ │ ├── App.java
│ │ ├── MainActivity.java
│ │ ├── Toast
│ │ └── ToastActivity.java
│ │ ├── aidl
│ │ └── Person.java
│ │ ├── anim
│ │ ├── AnimActivity.java
│ │ ├── BaseViewWrapper.java
│ │ └── ViewWidthWrapper.java
│ │ ├── broadcast
│ │ ├── BroadcastActivity.java
│ │ └── StaticReceiver.java
│ │ ├── entities
│ │ ├── GitHubRepos.java
│ │ └── GitHubUserEntity.java
│ │ ├── handler
│ │ └── HandlerActivity.java
│ │ ├── intent
│ │ ├── FourthActivity.java
│ │ ├── IntentActivity.java
│ │ ├── SecondActivity.java
│ │ └── ThirdActivity.java
│ │ ├── jni
│ │ ├── JniActivity.java
│ │ └── NdkTest.java
│ │ ├── multiProcess
│ │ ├── BinderPoolService.java
│ │ ├── IntegerAddService.java
│ │ ├── PersonCountService.java
│ │ ├── ProcessActivity.java
│ │ └── aidlImpl
│ │ │ ├── BinderPoolImpl.java
│ │ │ ├── IntegerAddImpl.java
│ │ │ └── PersonCountImpl.java
│ │ ├── provider
│ │ ├── AddUserActivity.java
│ │ ├── ProviderActivity.java
│ │ └── UserProvider.java
│ │ ├── retrofit
│ │ ├── ArtApi.java
│ │ ├── ArtNet.java
│ │ └── GithubReposActivity.java
│ │ └── service
│ │ ├── ForegroundService.java
│ │ ├── ForegroundServiceActivity.java
│ │ ├── LifeService.java
│ │ ├── ServiceActivity.java
│ │ └── TestServiceLifeActivity.java
│ ├── jni
│ ├── Android.mk
│ ├── Application.mk
│ ├── NdkTest.cpp
│ └── net_arvin_androidart_jni_NdkTest.h
│ ├── libs
│ ├── arm64-v8a
│ │ └── libNdkTest.so
│ ├── armeabi-v7a
│ │ └── libNdkTest.so
│ ├── armeabi
│ │ └── libNdkTest.so
│ ├── mips
│ │ └── libNdkTest.so
│ ├── mips64
│ │ └── libNdkTest.so
│ ├── x86
│ │ └── libNdkTest.so
│ └── x86_64
│ │ └── libNdkTest.so
│ ├── obj
│ └── local
│ │ ├── arm64-v8a
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ ├── armeabi-v7a
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ ├── armeabi
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ ├── mips
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ ├── mips64
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ ├── x86
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ │ └── NdkTest
│ │ │ ├── NdkTest.o
│ │ │ └── NdkTest.o.d
│ │ └── x86_64
│ │ ├── libNdkTest.so
│ │ ├── libstdc++.a
│ │ └── objs
│ │ └── NdkTest
│ │ ├── NdkTest.o
│ │ └── NdkTest.o.d
│ └── res
│ ├── drawable-xxhdpi
│ ├── ic_back_white.png
│ └── ic_right.png
│ ├── drawable
│ └── bg_big_corner_primary_solid.xml
│ ├── layout
│ ├── activity_add_user.xml
│ ├── activity_anim.xml
│ ├── activity_broadcast.xml
│ ├── activity_github_repos.xml
│ ├── activity_hanlder.xml
│ ├── activity_intent.xml
│ ├── activity_jni.xml
│ ├── activity_main.xml
│ ├── activity_name.xml
│ ├── activity_notify_service.xml
│ ├── activity_process.xml
│ ├── activity_provider.xml
│ ├── activity_service.xml
│ ├── activity_test_service_life.xml
│ ├── activity_toast.xml
│ ├── item_repos.xml
│ ├── item_user.xml
│ ├── layout_header.xml
│ └── layout_toast.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── greendao
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── net
│ │ └── arvin
│ │ └── greendao
│ │ ├── Test.java
│ │ ├── entities
│ │ └── User.java
│ │ └── gen
│ │ ├── DaoMaster.java
│ │ ├── DaoSession.java
│ │ └── UserDao.java
│ └── res
│ └── values
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 注:
2 |
3 | * [个人博客](http://www.jianshu.com/u/8fcc3372beb7),之后的博客都迁移到简书上了,新增的代码应该会重新考虑如何存放,这个项目不再维护,具体内容都迁移了。
4 | * 开发框架的介绍我这边已经换了个项目去整理了,与之前的也有些调整,项目地址:[AFBaseLibrary](https://github.com/arvinljw/AFBaseLibrary)
5 |
6 |
--------------------------------------------------------------------------------
/afbaselibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/afbaselibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.neenbedankt.android-apt'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | }
15 |
16 | //noinspection SpellCheckingInspection
17 | dependencies {
18 | compile fileTree(include: ['*.jar'], dir: 'libs')
19 | compile 'com.android.support:appcompat-v7:25.1.1'
20 | compile 'com.android.support:recyclerview-v7:25.1.1'
21 | compile 'com.android.support:support-v4:25.1.1'
22 |
23 | compile 'com.android.support:percent:25.1.1'
24 | compile 'com.android.support:design:25.1.1'
25 | //retrofit+rxjava
26 | compile 'com.squareup.retrofit2:retrofit:2.2.0'
27 | compile 'com.squareup.retrofit2:converter-gson:2.2.0'
28 | compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
29 | compile 'io.reactivex:rxjava:1.2.1'
30 | compile 'io.reactivex:rxandroid:1.2.1'
31 | compile 'com.google.code.gson:gson:2.7'
32 | compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
33 | //图片加载
34 | compile 'com.github.bumptech.glide:glide:3.7.0'
35 | //页面事件交互
36 | compile 'org.greenrobot:eventbus:3.0.0'
37 | //分割线
38 | compile 'com.chanven.lib:cptr:1.1.0'
39 | compile 'com.yqritc:recyclerview-flexibledivider:1.2.9'
40 | //view注解
41 | compile 'com.jakewharton:butterknife:8.4.0'
42 | compile 'com.jakewharton:butterknife-compiler:8.4.0'
43 | //日志
44 | compile 'com.orhanobut:logger:1.15'
45 | // compile 'com.umeng.analytics:analytics:latest.integration'
46 | }
47 |
--------------------------------------------------------------------------------
/afbaselibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arvin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/me/imid/swipebacklayout/lib/app/SwipeBackActivityBase.java:
--------------------------------------------------------------------------------
1 | package me.imid.swipebacklayout.lib.app;
2 |
3 | import me.imid.swipebacklayout.lib.SwipeBackLayout;
4 | /**
5 | * @author Yrom
6 | */
7 | public interface SwipeBackActivityBase {
8 | /**
9 | * @return the SwipeBackLayout associated with this activity.
10 | */
11 | public abstract SwipeBackLayout getSwipeBackLayout();
12 |
13 | public abstract void setSwipeBackEnable(boolean enable);
14 |
15 | /**
16 | * Scroll out contentView and finish the activity
17 | */
18 | public abstract void scrollToFinishActivity();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/me/imid/swipebacklayout/lib/app/SwipeBackActivityHelper.java:
--------------------------------------------------------------------------------
1 | package me.imid.swipebacklayout.lib.app;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 |
9 | import net.arvin.afbaselibrary.R;
10 |
11 | import me.imid.swipebacklayout.lib.SwipeBackLayout;
12 | import me.imid.swipebacklayout.lib.Utils;
13 |
14 | /**
15 | * @author Yrom
16 | */
17 | public class SwipeBackActivityHelper {
18 | private Activity mActivity;
19 |
20 | private SwipeBackLayout mSwipeBackLayout;
21 |
22 | public SwipeBackActivityHelper(Activity activity) {
23 | mActivity = activity;
24 | }
25 |
26 | @SuppressWarnings("deprecation")
27 | public void onActivityCreate() {
28 | mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
29 | mActivity.getWindow().getDecorView().setBackgroundDrawable(null);
30 | mSwipeBackLayout = (SwipeBackLayout) LayoutInflater.from(mActivity).inflate(
31 | R.layout.ui_layout_swipeback, null);
32 | mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() {
33 | @Override
34 | public void onScrollStateChange(int state, float scrollPercent) {
35 | }
36 |
37 | @Override
38 | public void onEdgeTouch(int edgeFlag) {
39 | Utils.convertActivityToTranslucent(mActivity);
40 | }
41 |
42 | @Override
43 | public void onScrollOverThreshold() {
44 |
45 | }
46 | });
47 | }
48 |
49 | public void onPostCreate() {
50 | mSwipeBackLayout.attachToActivity(mActivity);
51 | }
52 |
53 | public View findViewById(int id) {
54 | if (mSwipeBackLayout != null) {
55 | return mSwipeBackLayout.findViewById(id);
56 | }
57 | return null;
58 | }
59 |
60 | public SwipeBackLayout getSwipeBackLayout() {
61 | return mSwipeBackLayout;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/events/Event.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.events;
2 |
3 | /**
4 | * created by arvin on 16/10/24 16:25
5 | * email:1035407623@qq.com
6 | */
7 | public class Event {
8 | }
9 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/events/FinishAllEvent.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.events;
2 |
3 | /**
4 | * created by arvin on 16/12/1 10:24
5 | * email:1035407623@qq.com
6 | */
7 | public class FinishAllEvent {
8 | }
9 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/listeners/ICheckPerm.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.listeners;
2 |
3 | /**
4 | * created by arvin on 17/1/30 22:07
5 | * email:1035407623@qq.com
6 | */
7 | public interface ICheckPerm {
8 | void agreeAllPermission();
9 | }
10 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/listeners/ITabContent.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.listeners;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | * created by arvin on 16/11/25 09:55
7 | * email:1035407623@qq.com
8 | */
9 | public interface ITabContent {
10 | Fragment getContent(int pos);
11 | }
12 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/listeners/ITabPager.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.listeners;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | * Created by arvin on 2016/2/4 15:23
7 | * .
8 | */
9 | public interface ITabPager {
10 | String getTitle();
11 | }
12 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/listeners/IWeakHandler.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.listeners;
2 |
3 | import android.os.Message;
4 |
5 | /**
6 | * Created by arvin on 2016/2/2 16:50.
7 | *
8 | */
9 | public interface IWeakHandler {
10 | void handleMessage(Message msg);
11 | }
12 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/listeners/OnClickWithObjects.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.listeners;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * created by arvin on 16/11/3 17:16
7 | * email:1035407623@qq.com
8 | */
9 | public abstract class OnClickWithObjects implements View.OnClickListener {
10 | private Object[] objects;
11 |
12 | public OnClickWithObjects(Object... objects) {
13 | this.objects = objects;
14 | }
15 |
16 | @Override
17 | public void onClick(View view) {
18 | onClick(view, objects);
19 | }
20 |
21 | public abstract void onClick(View view, Object[] objects);
22 | }
23 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/mvp/views/IBaseView.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.mvp.views;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import net.arvin.afbaselibrary.listeners.ICheckPerm;
8 |
9 | /**
10 | * created by arvin on 16/10/24 14:48
11 | * email:1035407623@qq.com
12 | * 所有View模块的父类
13 | */
14 | public interface IBaseView {
15 | int getContentViewId();
16 |
17 | void init(Bundle savedInstanceState);
18 |
19 | T getView(int id);
20 |
21 | void showToast(String message);
22 |
23 | void showProgress(String message);
24 |
25 | void hideProgress();
26 |
27 | void startActivity(Class clazz);
28 |
29 | void startActivity(Class clazz, Bundle bundle);
30 |
31 | void startActivityForResult(Class clazz, int requestCode);
32 |
33 | void startActivityForResult(Class clazz, int requestCode, Bundle bundle);
34 |
35 | void checkPermission(ICheckPerm listener, String resString, String... mPerms);
36 | }
37 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/callbacks/AbsAPICallback.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.callbacks;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.ParseException;
6 | import android.widget.Toast;
7 |
8 | import com.google.gson.JsonParseException;
9 | import com.orhanobut.logger.Logger;
10 |
11 | import net.arvin.afbaselibrary.nets.exceptions.ApiException;
12 | import net.arvin.afbaselibrary.nets.exceptions.ResultException;
13 | import net.arvin.afbaselibrary.utils.ActivityUtil;
14 |
15 | import org.json.JSONException;
16 |
17 | import java.net.ConnectException;
18 |
19 | import retrofit2.adapter.rxjava.HttpException;
20 | import rx.Subscriber;
21 |
22 | /**
23 | * created by arvin on 16/10/24 17:20
24 | * email:1035407623@qq.com
25 | */
26 | public abstract class AbsAPICallback extends Subscriber {
27 |
28 | //出错提示
29 | public final String networkMsg = "服务器开小差";
30 | public final String parseMsg = "数据解析出错";
31 | public final String net_connection = "网络连接错误";
32 | public final String unknownMsg = "未知错误";
33 |
34 | protected AbsAPICallback() {
35 | }
36 |
37 |
38 | @Override
39 | public void onError(Throwable e) {
40 | e = getThrowable(e);
41 |
42 | if (e instanceof HttpException) {//HTTP错误
43 |
44 | error(e, ((HttpException) e).code(), networkMsg);
45 |
46 | } else if (e instanceof ResultException) {//服务器返回的错误
47 |
48 | ResultException resultException = (ResultException) e;
49 | error(e, resultException.getErrCode(), resultException.getMessage());
50 | resultError(resultException);//处理错误
51 |
52 | } else if (e instanceof JsonParseException || e instanceof JSONException || e instanceof ParseException) {//解析错误
53 |
54 | error(e, ApiException.PARSE_ERROR, parseMsg);
55 |
56 | } else if (e instanceof ConnectException) {
57 | error(e, ApiException.PARSE_ERROR, net_connection);
58 | } else {//未知错误
59 | error(e, ApiException.UNKNOWN, unknownMsg);
60 | }
61 | }
62 |
63 | private Throwable getThrowable(Throwable e) {
64 | Throwable throwable = e;
65 | while (throwable.getCause() != null) {
66 | e = throwable;
67 | throwable = throwable.getCause();
68 | }
69 | return e;
70 | }
71 |
72 | private void resultError(ResultException e) {
73 | // if (e.getErrCode() == ApiException.RE_LOGIN) {
74 | // try {
75 | // Context currentActivity = ActivityUtil.getCurrentActivity();
76 | // if (currentActivity != null) {
77 | // Intent intent = new Intent(currentActivity, Class.forName("登录界面的包名.LoginActivity"));
78 | // currentActivity.startActivity(intent);
79 | // Toast.makeText(currentActivity, "请重新登录", Toast.LENGTH_SHORT).show();
80 | // }
81 | // } catch (Exception e1) {
82 | // e1.printStackTrace();
83 | // }
84 | // }
85 | }
86 |
87 | /**
88 | * 错误信息回调
89 | */
90 | private void error(Throwable e, int errorCode, String errorMsg) {
91 | ApiException ex = new ApiException(e, errorCode);
92 | Logger.d(e);
93 | ex.setDisplayMessage(errorMsg);
94 | onResultError(ex);
95 | }
96 |
97 | /**
98 | * 服务器返回的错误
99 | */
100 | protected abstract void onResultError(ApiException ex);
101 |
102 | @Override
103 | public void onCompleted() {
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/converters/GsonConverterFactory.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.converters;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.TypeAdapter;
5 | import com.google.gson.reflect.TypeToken;
6 |
7 | import java.lang.annotation.Annotation;
8 | import java.lang.reflect.Type;
9 |
10 | import okhttp3.RequestBody;
11 | import okhttp3.ResponseBody;
12 | import retrofit2.Converter;
13 | import retrofit2.Retrofit;
14 |
15 | /**
16 | * created by arvin on 16/10/24 17:20
17 | * email:1035407623@qq.com
18 | */
19 | public class GsonConverterFactory extends Converter.Factory {
20 | private final Gson gson;
21 |
22 | public GsonConverterFactory(Gson gson) {
23 | if (gson == null) {
24 | throw new NullPointerException("gson == null");
25 | }
26 | this.gson = gson;
27 | }
28 |
29 | public static GsonConverterFactory create() {
30 | return create(new Gson());
31 | }
32 |
33 | public static GsonConverterFactory create(Gson gson) {
34 | return new GsonConverterFactory(gson);
35 | }
36 |
37 | @Override
38 | public Converter responseBodyConverter(Type type, Annotation[] annotations,
39 | Retrofit retrofit) {
40 | return new GsonResponseBodyConverter<>(gson, type);
41 | }
42 |
43 | @Override
44 | public Converter, RequestBody> requestBodyConverter(Type type,
45 | Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
46 | TypeAdapter> adapter = gson.getAdapter(TypeToken.get(type));
47 | return new GsonRequestBodyConverter<>(gson, adapter);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/converters/GsonRequestBodyConverter.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.converters;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.TypeAdapter;
5 | import com.google.gson.stream.JsonWriter;
6 |
7 | import java.io.IOException;
8 | import java.io.OutputStreamWriter;
9 | import java.io.Writer;
10 | import java.nio.charset.Charset;
11 |
12 | import okhttp3.MediaType;
13 | import okhttp3.RequestBody;
14 | import okio.Buffer;
15 | import retrofit2.Converter;
16 |
17 | /**
18 | * created by arvin on 16/10/24 17:23
19 | * email:1035407623@qq.com
20 | */
21 | public class GsonRequestBodyConverter implements Converter {
22 | private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
23 | private static final Charset UTF_8 = Charset.forName("UTF-8");
24 |
25 | private final Gson gson;
26 | private final TypeAdapter adapter;
27 |
28 | public GsonRequestBodyConverter(Gson gson, TypeAdapter adapter) {
29 | this.gson = gson;
30 | this.adapter = adapter;
31 | }
32 |
33 | @Override
34 | public RequestBody convert(T value) throws IOException {
35 | Buffer buffer = new Buffer();
36 | Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);
37 | JsonWriter jsonWriter = gson.newJsonWriter(writer);
38 | adapter.write(jsonWriter, value);
39 | jsonWriter.close();
40 | return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/converters/GsonResponseBodyConverter.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.converters;
2 |
3 | import com.google.gson.Gson;
4 | import com.orhanobut.logger.Logger;
5 |
6 | import net.arvin.afbaselibrary.nets.entities.ResultEntity;
7 | import net.arvin.afbaselibrary.nets.exceptions.ResultException;
8 |
9 | import java.io.IOException;
10 | import java.lang.reflect.Type;
11 |
12 | import okhttp3.ResponseBody;
13 | import retrofit2.Converter;
14 |
15 | /**
16 | * created by arvin on 16/10/24 17:24
17 | * email:1035407623@qq.com
18 | */
19 | public class GsonResponseBodyConverter implements Converter {
20 | private final Gson gson;
21 | private final Type adapter;
22 |
23 | public GsonResponseBodyConverter(Gson gson, Type adapter) {
24 | this.gson = gson;
25 | this.adapter = adapter;
26 | }
27 |
28 | @Override
29 | public T convert(ResponseBody value) throws IOException {
30 | String response = value.string().replace("SUCCESS", 200 + "");
31 | try {
32 | Logger.i(response);
33 | ResultEntity resultModel = gson.fromJson(response, ResultEntity.class);
34 | if (resultModel.getStatus() == 200) {
35 | if (resultModel.getContent() != null) {
36 | return gson.fromJson(resultModel.getContent(), adapter);
37 | }
38 | return null;
39 | } else {
40 | throw new ResultException(resultModel.getStatus(), resultModel.getMessage());
41 | }
42 | } finally {
43 | value.close();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/entities/InputErrorEntity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.entities;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonObject;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import java.util.Map;
9 | import java.util.Set;
10 |
11 | /**
12 | * created by arvin on 16/10/24 17:23
13 | * email:1035407623@qq.com
14 | */
15 | public class InputErrorEntity {
16 |
17 | private JsonObject objectErrors;
18 |
19 | private JsonObject fieldErrors;
20 |
21 | private String errorMessage;
22 |
23 | public JsonObject getObjectErrors() {
24 | return objectErrors;
25 | }
26 |
27 | public void setObjectErrors(JsonObject objectErrors) {
28 | this.objectErrors = objectErrors;
29 | }
30 |
31 | public JsonObject getFieldErrors() {
32 | return fieldErrors;
33 | }
34 |
35 | public void setFieldErrors(JsonObject fieldErrors) {
36 | this.fieldErrors = fieldErrors;
37 | }
38 |
39 |
40 | public String getMessage() {
41 | if (errorMessage != null) {
42 | return errorMessage;
43 | }
44 | try {
45 | if (fieldErrors != null) {
46 | Set> entrySet = fieldErrors.entrySet();
47 | for (Map.Entry entry : entrySet) {
48 | JsonElement jObject = fieldErrors.get(entry.getKey());
49 | String[] datas = new Gson().fromJson(jObject, new TypeToken() {
50 | }.getType());
51 | for (String s : datas) {
52 | errorMessage = s;
53 | return s;
54 | }
55 | }
56 | }
57 | } catch (Exception e) {
58 | e.printStackTrace();
59 | }
60 | return null;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/entities/PageListEntity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.entities;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * created by arvin on 16/8/3 14:48
7 | * email:1035407623@qq.com
8 | */
9 | public class PageListEntity {
10 | private List content;
11 |
12 | public PageListEntity() {
13 | }
14 |
15 | public PageListEntity(List content) {
16 | this.content = content;
17 | }
18 |
19 | public List getContent() {
20 | return content;
21 | }
22 |
23 | public void setContent(List content) {
24 | this.content = content;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/entities/ResultEntity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.entities;
2 |
3 | import com.google.gson.JsonElement;
4 |
5 | /**
6 | * created by arvin on 16/10/24 17:25
7 | * email:1035407623@qq.com
8 | */
9 | public class ResultEntity {
10 | /**
11 | * 状态码
12 | */
13 | private int status;
14 | /**
15 | * 处理消息
16 | */
17 | private String message;
18 | /**
19 | * 内容
20 | */
21 | private JsonElement content;
22 |
23 | private InputErrorEntity inputError;
24 |
25 | public int getStatus() {
26 | return status;
27 | }
28 |
29 | public void setStatus(int status) {
30 | this.status = status;
31 | }
32 |
33 | public String getMessage() {
34 | if (inputError != null) {
35 | String temp = inputError.getMessage();
36 | if (temp != null) {
37 | return temp;
38 | }
39 | }
40 | return message;
41 | }
42 |
43 | public void setMessage(String message) {
44 | this.message = message;
45 | }
46 |
47 | public JsonElement getContent() {
48 | return content;
49 | }
50 |
51 | public void setContent(JsonElement content) {
52 | this.content = content;
53 | }
54 |
55 | public InputErrorEntity getInputError() {
56 | return inputError;
57 | }
58 |
59 | public void setInputError(InputErrorEntity inputError) {
60 | this.inputError = inputError;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/exceptions/ApiException.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.exceptions;
2 |
3 | /**
4 | * Created by Leo on 2016/5/4
5 | */
6 | public class ApiException extends Exception {
7 | private final int code;
8 | private String displayMessage;
9 |
10 | public static final int RE_LOGIN = 1000;
11 | public static final int PARSE_ERROR = 1001;
12 | public static final int UNKNOWN = 1002;
13 |
14 | public ApiException(Throwable throwable, int code) {
15 | super(throwable);
16 | this.code = code;
17 | }
18 |
19 | public int getCode() {
20 | return code;
21 | }
22 |
23 | public String getDisplayMessage() {
24 | return displayMessage;
25 | }
26 |
27 | public void setDisplayMessage(String msg) {
28 | this.displayMessage = msg;
29 | }
30 | }
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/nets/exceptions/ResultException.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.nets.exceptions;
2 |
3 | /**
4 | * created by arvin on 16/10/24 17:29
5 | * email:1035407623@qq.com
6 | */
7 | public class ResultException extends RuntimeException {
8 | private int errCode = 0;
9 |
10 | private String message;
11 |
12 | public ResultException(int errCode, String msg) {
13 | super(msg);
14 | this.errCode = errCode;
15 | this.message = msg;
16 | }
17 |
18 | public int getErrCode() {
19 | return errCode;
20 | }
21 |
22 | @Override
23 | public String getMessage() {
24 | return message;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/activities/BaseHeaderActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.activities;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.orhanobut.logger.Logger;
8 |
9 | import net.arvin.afbaselibrary.R;
10 |
11 | /**
12 | * created by arvin on 16/10/24 15:22
13 | * email:1035407623@qq.com
14 | * 带有标题和返回按钮的activity包含使用id:pre_tv_title(TextView)和pre_v_back(View)的组件即可
15 | */
16 | public abstract class BaseHeaderActivity extends BaseActivity {
17 | protected TextView tvTitle;
18 | protected View vBack;
19 |
20 | @Override
21 | public void init(Bundle savedInstanceState) {
22 | initHeader();
23 | initViews(savedInstanceState);
24 | }
25 |
26 | private void initHeader() {
27 | try {
28 | tvTitle = getView(R.id.pre_tv_title);
29 | tvTitle.setText(getTitleText());
30 | tvTitle.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | onTitleClicked(v);
34 | }
35 | });
36 | } catch (Exception e) {
37 | Logger.w("未设置标题id~");
38 | }
39 |
40 | try {
41 | vBack = getView(R.id.pre_v_back);
42 | vBack.setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | onBackPressed();
46 | }
47 | });
48 | vBack.setVisibility(isShowBackView() ? View.VISIBLE : View.GONE);
49 | } catch (Exception e) {
50 | Logger.w("未设置返回图标id~");
51 | }
52 | }
53 |
54 | protected boolean isShowBackView() {
55 | return true;
56 | }
57 |
58 | protected void onTitleClicked(View view) {
59 | }
60 |
61 | protected abstract String getTitleText();
62 |
63 | protected abstract void initViews(Bundle savedInstanceState);
64 | }
65 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/activities/BaseRefreshActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 |
6 | import net.arvin.afbaselibrary.R;
7 | import net.arvin.afbaselibrary.uis.fragments.BaseFragment;
8 |
9 | /**
10 | * created by arvin on 16/11/21 20:51
11 | * email:1035407623@qq.com
12 | */
13 | public abstract class BaseRefreshActivity extends BaseSwipeBackActivity implements SwipeRefreshLayout.OnRefreshListener {
14 | protected SwipeRefreshLayout mLayoutRefresh;
15 |
16 | @Override
17 | protected void initViews(Bundle savedInstanceState) {
18 | mLayoutRefresh = getView(R.id.pre_refresh);
19 | mLayoutRefresh.setColorSchemeResources(R.color.colorAccent);
20 | mLayoutRefresh.setOnRefreshListener(this);
21 | }
22 |
23 | protected void autoRefresh() {
24 | mLayoutRefresh.postDelayed(new Runnable() {
25 | @Override
26 | public void run() {
27 | mLayoutRefresh.setRefreshing(true);
28 | onRefresh();
29 | }
30 | }, 100);
31 | }
32 |
33 | protected void refreshComplete() {
34 | mLayoutRefresh.setRefreshing(false);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/activities/BaseSwipeBackActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.activities;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | import me.imid.swipebacklayout.lib.SwipeBackLayout;
7 | import me.imid.swipebacklayout.lib.Utils;
8 | import me.imid.swipebacklayout.lib.app.SwipeBackActivityBase;
9 | import me.imid.swipebacklayout.lib.app.SwipeBackActivityHelper;
10 |
11 | /**
12 | * created by arvin on 16/8/4 17:03
13 | * email:1035407623@qq.com
14 | */
15 | public abstract class BaseSwipeBackActivity extends BaseHeaderActivity implements SwipeBackActivityBase {
16 | private SwipeBackActivityHelper mHelper;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | mHelper = new SwipeBackActivityHelper(this);
22 | mHelper.onActivityCreate();
23 | }
24 |
25 | @Override
26 | protected void onPostCreate(Bundle savedInstanceState) {
27 | super.onPostCreate(savedInstanceState);
28 | mHelper.onPostCreate();
29 | }
30 |
31 | @Override
32 | public View findViewById(int id) {
33 | View v = super.findViewById(id);
34 | if (v == null && mHelper != null)
35 | return mHelper.findViewById(id);
36 | return v;
37 | }
38 |
39 | @Override
40 | public SwipeBackLayout getSwipeBackLayout() {
41 | return mHelper.getSwipeBackLayout();
42 | }
43 |
44 | @Override
45 | public void setSwipeBackEnable(boolean enable) {
46 | getSwipeBackLayout().setEnableGesture(enable);
47 | }
48 |
49 | @Override
50 | public void scrollToFinishActivity() {
51 | Utils.convertActivityToTranslucent(this);
52 | getSwipeBackLayout().scrollToFinishActivity();
53 | }
54 |
55 | @Override
56 | public void onBackPressed() {
57 | scrollToFinishActivity();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/activities/BaseTabActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.view.ViewPager;
5 |
6 | import net.arvin.afbaselibrary.R;
7 | import net.arvin.afbaselibrary.listeners.ITabContent;
8 | import net.arvin.afbaselibrary.listeners.ITabPager;
9 | import net.arvin.afbaselibrary.uis.adapters.TabPagerAdapter;
10 | import net.arvin.afbaselibrary.utils.ScreenUtil;
11 | import net.arvin.afbaselibrary.widgets.PagerSlidingTabStrip;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 |
18 | /**
19 | * created by arvin on 16/11/21 17:54
20 | * email:1035407623@qq.com
21 | */
22 | public abstract class BaseTabActivity extends BaseSwipeBackActivity implements ViewPager.OnPageChangeListener, ITabContent {
23 | protected PagerSlidingTabStrip mTabLayout;
24 | protected ViewPager mPager;
25 | protected List mItems = new ArrayList<>();
26 | protected TabPagerAdapter mAdapter;
27 | protected int selectedIndex = -1;
28 |
29 | @Override
30 | protected void initViews(Bundle savedInstanceState) {
31 | mTabLayout = getView(R.id.pre_tab_layout);
32 | mPager = getView(R.id.pre_pager);
33 | initTabView();
34 | getData();
35 | }
36 |
37 | private void initTabView() {
38 | mTabLayout.setTextColor(getTabTextColor());
39 | mTabLayout.setSelectedTextColorResource(getSelectedTabTextColor());
40 | mTabLayout.setIndicatorColorResource(getSelectedTabTextColor());
41 | mTabLayout.setIndicatorHeight(ScreenUtil.dp2px(2));
42 | mTabLayout.setUnderlineColor(getResources().getColor(R.color.black_divider));
43 | mTabLayout.setUnderlineHeight(ScreenUtil.dp2px(getUnderLineHeight()));
44 | mTabLayout.setDrawDivider(isDrawDivider());
45 | }
46 |
47 | protected float getUnderLineHeight() {
48 | return 1;
49 | }
50 |
51 | protected void initPager() {
52 | if (mItems == null || mItems.size() == 0) {
53 | return;
54 | }
55 | mAdapter = new TabPagerAdapter<>(getSupportFragmentManager(), mItems, this);
56 | mPager.setAdapter(mAdapter);
57 | mTabLayout.setTabAddWay(getItemAddWay());
58 | mTabLayout.setViewPager(mPager);
59 | mTabLayout.setOnPageChangeListener(this);
60 | }
61 |
62 | protected boolean isDrawDivider() {
63 | return false;
64 | }
65 |
66 | protected int getSelectedTabTextColor() {
67 | return R.color.colorAccent;
68 | }
69 |
70 | protected int getTabTextColor() {
71 | return R.color.black_normal;
72 | }
73 |
74 | protected PagerSlidingTabStrip.TabAddWay getItemAddWay() {
75 | if (mItems.size() <= 4) {
76 | return PagerSlidingTabStrip.TabAddWay.ITEM_MATCH;
77 | }
78 | return PagerSlidingTabStrip.TabAddWay.ITEM_WARP;
79 | }
80 |
81 | @Override
82 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
83 | }
84 |
85 | @Override
86 | public void onPageScrollStateChanged(int state) {
87 | }
88 |
89 | @Override
90 | public void onPageSelected(int position) {
91 | selectedIndex = position;
92 | }
93 |
94 | /**
95 | * 获取完数据后回调设置pager
96 | */
97 | protected abstract void getData();
98 | }
99 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/BaseAdapter.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 |
6 | import net.arvin.afbaselibrary.uis.adapters.holders.CommonHolder;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * created by arvin on 16/10/24 15:01
12 | * email:1035407623@qq.com
13 | */
14 | public abstract class BaseAdapter extends MultiItemTypeAdapter {
15 | protected Context mContext;
16 | protected int mLayoutId;
17 | protected List mItems;
18 | protected LayoutInflater mInflater;
19 |
20 | public BaseAdapter(final Context context, final int layoutId, List datas) {
21 | super(context, datas);
22 | mContext = context;
23 | mInflater = LayoutInflater.from(context);
24 | mLayoutId = layoutId;
25 | mItems = datas;
26 |
27 | addItemViewDelegate(new ItemViewDelegate() {
28 | @Override
29 | public int getItemViewLayoutId() {
30 | return layoutId;
31 | }
32 |
33 | @Override
34 | public boolean isForViewType(T item, int position) {
35 | return true;
36 | }
37 |
38 | @Override
39 | public void convert(CommonHolder holder, T t, int position) {
40 | BaseAdapter.this.convert(holder, t, position);
41 | }
42 | });
43 | }
44 |
45 | protected abstract void convert(CommonHolder holder, T item, int position);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/ItemViewDelegate.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters;
2 |
3 |
4 | import net.arvin.afbaselibrary.uis.adapters.holders.CommonHolder;
5 |
6 | /**
7 | * Created by zhy on 16/6/22
8 | */
9 | public interface ItemViewDelegate {
10 | int getItemViewLayoutId();
11 |
12 | boolean isForViewType(T item, int position);
13 |
14 | void convert(CommonHolder holder, T t, int position);
15 | }
16 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/ItemViewDelegateManager.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters;
2 |
3 | import android.support.v4.util.SparseArrayCompat;
4 |
5 | import net.arvin.afbaselibrary.uis.adapters.holders.CommonHolder;
6 |
7 |
8 | /**
9 | * Created by zhy on 16/6/22
10 | */
11 | public class ItemViewDelegateManager {
12 | SparseArrayCompat> delegates = new SparseArrayCompat<>();
13 |
14 | public int getItemViewDelegateCount() {
15 | return delegates.size();
16 | }
17 |
18 | public ItemViewDelegateManager addDelegate(ItemViewDelegate delegate) {
19 | int viewType = delegates.size();
20 | if (delegate != null) {
21 | delegates.put(viewType, delegate);
22 | // viewType++;
23 | }
24 | return this;
25 | }
26 |
27 | public ItemViewDelegateManager addDelegate(int viewType, ItemViewDelegate delegate) {
28 | if (delegates.get(viewType) != null) {
29 | throw new IllegalArgumentException(
30 | "An ItemViewDelegate is already registered for the viewType = "
31 | + viewType
32 | + ". Already registered ItemViewDelegate is "
33 | + delegates.get(viewType));
34 | }
35 | delegates.put(viewType, delegate);
36 | return this;
37 | }
38 |
39 | public ItemViewDelegateManager removeDelegate(ItemViewDelegate delegate) {
40 | if (delegate == null) {
41 | throw new NullPointerException("ItemViewDelegate is null");
42 | }
43 | int indexToRemove = delegates.indexOfValue(delegate);
44 |
45 | if (indexToRemove >= 0) {
46 | delegates.removeAt(indexToRemove);
47 | }
48 | return this;
49 | }
50 |
51 | public ItemViewDelegateManager removeDelegate(int itemType) {
52 | int indexToRemove = delegates.indexOfKey(itemType);
53 | if (indexToRemove >= 0) {
54 | delegates.removeAt(indexToRemove);
55 | }
56 | return this;
57 | }
58 |
59 | public int getItemViewType(T item, int position) {
60 | int delegatesCount = delegates.size();
61 | for (int i = delegatesCount - 1; i >= 0; i--) {
62 | ItemViewDelegate delegate = delegates.valueAt(i);
63 | if (delegate.isForViewType(item, position)) {
64 | return delegates.keyAt(i);
65 | }
66 | }
67 | throw new IllegalArgumentException(
68 | "No ItemViewDelegate added that matches position=" + position + " in data source");
69 | }
70 |
71 | public void convert(CommonHolder holder, T item, int position) {
72 | int delegatesCount = delegates.size();
73 | for (int i = 0; i < delegatesCount; i++) {
74 | ItemViewDelegate delegate = delegates.valueAt(i);
75 |
76 | if (delegate.isForViewType(item, position)) {
77 | delegate.convert(holder, item, position);
78 | return;
79 | }
80 | }
81 | throw new IllegalArgumentException(
82 | "No ItemViewDelegateManager added that matches position=" + position + " in data source");
83 | }
84 |
85 |
86 | public int getItemViewLayoutId(int viewType) {
87 | return delegates.get(viewType).getItemViewLayoutId();
88 | }
89 |
90 | public int getItemViewType(ItemViewDelegate itemViewDelegate) {
91 | return delegates.indexOfValue(itemViewDelegate);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/TabPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentStatePagerAdapter;
6 |
7 | import net.arvin.afbaselibrary.listeners.ITabContent;
8 | import net.arvin.afbaselibrary.listeners.ITabPager;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by arvin on 2016/2/4 15:26
14 | * .
15 | */
16 | public class TabPagerAdapter extends FragmentStatePagerAdapter {
17 | private List mList;
18 | private ITabContent tabContent;
19 |
20 | public TabPagerAdapter(FragmentManager fm, List list, ITabContent tabContent) {
21 | super(fm);
22 | this.mList = list;
23 | this.tabContent = tabContent;
24 | }
25 |
26 | @Override
27 | public CharSequence getPageTitle(int position) {
28 | return mList.get(position).getTitle();
29 | }
30 |
31 | @Override
32 | public int getCount() {
33 | return mList.size();
34 | }
35 |
36 | @Override
37 | public Fragment getItem(int position) {
38 | return tabContent.getContent(position);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/wrapper/EmptyWrapper.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters.wrapper;
2 |
3 | import android.support.v7.widget.GridLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import net.arvin.afbaselibrary.uis.adapters.holders.CommonHolder;
9 |
10 |
11 | /**
12 | * Created by zhy on 16/6/23
13 | */
14 | public class EmptyWrapper extends RecyclerView.Adapter {
15 | public static final int ITEM_TYPE_EMPTY = Integer.MAX_VALUE - 1;
16 |
17 | private RecyclerView.Adapter mInnerAdapter;
18 | private View mEmptyView;
19 | private int mEmptyLayoutId;
20 |
21 | public EmptyWrapper(RecyclerView.Adapter adapter) {
22 | mInnerAdapter = adapter;
23 | }
24 |
25 | private boolean isEmpty() {
26 | return (mEmptyView != null || mEmptyLayoutId != 0) && mInnerAdapter.getItemCount() == 0;
27 | }
28 |
29 | @Override
30 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
31 | if (isEmpty()) {
32 | CommonHolder holder;
33 | if (mEmptyView != null) {
34 | holder = CommonHolder.createViewHolder(parent.getContext(), mEmptyView);
35 | } else {
36 | holder = CommonHolder.createViewHolder(parent.getContext(), parent, mEmptyLayoutId);
37 | }
38 | return holder;
39 | }
40 | return mInnerAdapter.onCreateViewHolder(parent, viewType);
41 | }
42 |
43 | @Override
44 | public void onAttachedToRecyclerView(RecyclerView recyclerView) {
45 | WrapperUtils.onAttachedToRecyclerView(mInnerAdapter, recyclerView, new WrapperUtils.SpanSizeCallback() {
46 | @Override
47 | public int getSpanSize(GridLayoutManager gridLayoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position) {
48 | if (isEmpty()) {
49 | return gridLayoutManager.getSpanCount();
50 | }
51 | if (oldLookup != null) {
52 | return oldLookup.getSpanSize(position);
53 | }
54 | return 1;
55 | }
56 | });
57 | }
58 |
59 | @Override
60 | public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
61 | mInnerAdapter.onViewAttachedToWindow(holder);
62 | if (isEmpty()) {
63 | WrapperUtils.setFullSpan(holder);
64 | }
65 | }
66 |
67 |
68 | @Override
69 | public int getItemViewType(int position) {
70 | if (isEmpty()) {
71 | return ITEM_TYPE_EMPTY;
72 | }
73 | return mInnerAdapter.getItemViewType(position);
74 | }
75 |
76 | @Override
77 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
78 | if (isEmpty()) {
79 | return;
80 | }
81 | mInnerAdapter.onBindViewHolder(holder, position);
82 | }
83 |
84 | @Override
85 | public int getItemCount() {
86 | if (isEmpty()) return 1;
87 | return mInnerAdapter.getItemCount();
88 | }
89 |
90 | public void setEmptyView(View emptyView) {
91 | mEmptyView = emptyView;
92 | }
93 |
94 | public void setEmptyView(int layoutId) {
95 | mEmptyLayoutId = layoutId;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/adapters/wrapper/WrapperUtils.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.adapters.wrapper;
2 |
3 | import android.support.v7.widget.GridLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.StaggeredGridLayoutManager;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * Created by zhy on 16/6/28
10 | */
11 | public class WrapperUtils {
12 | public interface SpanSizeCallback {
13 | int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position);
14 | }
15 |
16 | public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
17 | innerAdapter.onAttachedToRecyclerView(recyclerView);
18 |
19 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
20 | if (layoutManager instanceof GridLayoutManager) {
21 | final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
22 | final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
23 |
24 | gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
25 | @Override
26 | public int getSpanSize(int position) {
27 | return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
28 | }
29 | });
30 | gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
31 | }
32 | }
33 |
34 | public static void setFullSpan(RecyclerView.ViewHolder holder) {
35 | ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
36 |
37 | if (lp != null
38 | && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
39 |
40 | StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
41 |
42 | p.setFullSpan(true);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/fragments/BaseRefreshFragment.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 |
6 | import net.arvin.afbaselibrary.R;
7 |
8 | /**
9 | * created by arvin on 16/11/21 20:51
10 | * email:1035407623@qq.com
11 | */
12 | public abstract class BaseRefreshFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
13 | protected SwipeRefreshLayout mLayoutRefresh;
14 |
15 | @Override
16 | public void init(Bundle savedInstanceState) {
17 | mLayoutRefresh = getView(R.id.pre_refresh);
18 | mLayoutRefresh.setColorSchemeResources(R.color.colorPrimary);
19 | mLayoutRefresh.setOnRefreshListener(this);
20 | }
21 |
22 | protected void autoRefresh() {
23 | mLayoutRefresh.postDelayed(new Runnable() {
24 | @Override
25 | public void run() {
26 | mLayoutRefresh.setRefreshing(true);
27 | onRefresh();
28 | }
29 | }, 100);
30 | }
31 |
32 | protected void refreshComplete() {
33 | mLayoutRefresh.setRefreshing(false);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/uis/fragments/BaseTabFragment.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.uis.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.view.ViewPager;
5 |
6 | import net.arvin.afbaselibrary.R;
7 | import net.arvin.afbaselibrary.listeners.ITabContent;
8 | import net.arvin.afbaselibrary.listeners.ITabPager;
9 | import net.arvin.afbaselibrary.uis.activities.BaseHeaderActivity;
10 | import net.arvin.afbaselibrary.uis.adapters.TabPagerAdapter;
11 | import net.arvin.afbaselibrary.utils.ScreenUtil;
12 | import net.arvin.afbaselibrary.widgets.PagerSlidingTabStrip;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * created by arvin on 16/11/21 17:54
19 | * email:1035407623@qq.com
20 | */
21 | public abstract class BaseTabFragment extends BaseFragment implements ViewPager.OnPageChangeListener, ITabContent {
22 | protected PagerSlidingTabStrip mTabLayout;
23 | protected ViewPager mPager;
24 | protected List mItems = new ArrayList<>();
25 | protected TabPagerAdapter mAdapter;
26 | protected int selectedIndex = -1;
27 |
28 | @Override
29 | public void init(Bundle savedInstanceState) {
30 | mTabLayout = getView(R.id.pre_tab_layout);
31 | mPager = getView(R.id.pre_pager);
32 | initTabView();
33 | getData();
34 | }
35 |
36 | private void initTabView() {
37 | mTabLayout.setTextColor(getTabTextColor());
38 | mTabLayout.setSelectedTextColorResource(getSelectedTabTextColor());
39 | mTabLayout.setIndicatorColorResource(getSelectedTabTextColor());
40 | mTabLayout.setIndicatorHeight(ScreenUtil.dp2px(2));
41 | mTabLayout.setUnderlineColor(getResources().getColor(R.color.black_divider));
42 | mTabLayout.setUnderlineHeight(ScreenUtil.dp2px(getUnderLineHeight()));
43 | mTabLayout.setDrawDivider(isDrawDivider());
44 | mTabLayout.setTabAddWay(getItemAddWay());
45 | }
46 |
47 | protected float getUnderLineHeight() {
48 | return 1;
49 | }
50 |
51 | protected void initPager() {
52 | if (mItems == null || mItems.size() == 0) {
53 | return;
54 | }
55 | mAdapter = new TabPagerAdapter<>(getChildFragmentManager(), mItems, this);
56 | mPager.setAdapter(mAdapter);
57 | mPager.setOffscreenPageLimit(mItems.size());
58 | mTabLayout.setViewPager(mPager);
59 | mTabLayout.setOnPageChangeListener(this);
60 | }
61 |
62 | protected boolean isDrawDivider() {
63 | return false;
64 | }
65 |
66 | protected int getSelectedTabTextColor() {
67 | return R.color.colorPrimary;
68 | }
69 |
70 | protected int getTabTextColor() {
71 | return R.color.black_normal;
72 | }
73 |
74 | protected PagerSlidingTabStrip.TabAddWay getItemAddWay() {
75 | return PagerSlidingTabStrip.TabAddWay.ITEM_WARP;
76 | }
77 |
78 | @Override
79 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
80 | }
81 |
82 | @Override
83 | public void onPageScrollStateChanged(int state) {
84 | }
85 |
86 | @Override
87 | public void onPageSelected(int position) {
88 | selectedIndex = position;
89 | }
90 |
91 | /**
92 | * 获取完数据后回调设置pager
93 | */
94 | protected abstract void getData();
95 | }
96 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/AFUtil.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.ActivityManager;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.pm.PackageInfo;
8 | import android.content.pm.PackageManager;
9 | import android.net.Uri;
10 | import android.os.Build;
11 | import android.widget.Toast;
12 |
13 | import java.util.ArrayList;
14 | import java.util.HashMap;
15 | import java.util.List;
16 |
17 | /**
18 | * created by arvin on 16/12/23 11:38
19 | * email:1035407623@qq.com
20 | */
21 | public class AFUtil {
22 | /**
23 | * 获取版本号
24 | */
25 | public static String getVersion(Context context) {
26 | try {
27 | PackageManager manager = context.getPackageManager();
28 | PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
29 | return info.versionName;
30 | } catch (Exception e) {
31 | e.printStackTrace();
32 | return "";
33 | }
34 | }
35 |
36 | public static void toCall(Context context, String mobile) {
37 | Intent intent = new Intent(Intent.ACTION_DIAL);
38 | Uri data = Uri.parse("tel:" + mobile);
39 | intent.setData(data);
40 | context.startActivity(intent);
41 | }
42 |
43 | /**
44 | * @param url 需要以http或https开头
45 | */
46 | public static void toHtml(Context context, String url) {
47 | Intent intent = new Intent(Intent.ACTION_VIEW);
48 | intent.setData(Uri.parse(url));
49 | context.startActivity(intent);
50 | }
51 |
52 | /**
53 | * 打开系统计算器
54 | */
55 | @TargetApi(15)
56 | public static void callCalculator(Context context) {
57 | ArrayList> items = new ArrayList>();
58 | final PackageManager pm = context.getPackageManager();
59 | List packs = pm.getInstalledPackages(0);
60 | for (PackageInfo pi : packs) {
61 | if (pi.packageName.toLowerCase().contains("calcul")) {
62 | HashMap map = new HashMap();
63 | map.put("appName", pi.applicationInfo.loadLabel(pm));
64 | map.put("packageName", pi.packageName);
65 | items.add(map);
66 | }
67 | }
68 | if (items.size() >= 1) {
69 | String packageName = (String) items.get(0).get("packageName");
70 | Intent i = pm.getLaunchIntentForPackage(packageName);
71 | if (i != null)
72 | context.startActivity(i);
73 | } else {
74 | Toast.makeText(context, "没有安装计算器", Toast.LENGTH_SHORT).show();
75 | }
76 | }
77 |
78 | /**
79 | * 打开系统日历
80 | */
81 | public static void callCalendar(Context context) {
82 | Intent intent = new Intent(Intent.ACTION_VIEW);
83 | intent.setData(Uri.parse("content://com.android.calendar/time"));
84 | context.startActivity(intent);
85 | }
86 |
87 | /**
88 | * 获取当前进程的名字
89 | */
90 | public static String getProcessName(Context context) {
91 | int pid = android.os.Process.myPid();
92 | String processName = "";
93 | ActivityManager manager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
94 | for (ActivityManager.RunningAppProcessInfo process : manager.getRunningAppProcesses()) {
95 | if (process.pid == pid) {
96 | processName = process.processName;
97 | }
98 | }
99 | return processName;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/ActivityUtil.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.app.Activity;
4 |
5 | import java.lang.reflect.Field;
6 | import java.util.Map;
7 |
8 | /**
9 | * created by arvin on 16/11/24 15:30
10 | * email:1035407623@qq.com
11 | */
12 | public class ActivityUtil {
13 | /**
14 | * 获取当前显示的Activity
15 | *
16 | * @return 当前Activity
17 | */
18 | public static Activity getCurrentActivity() {
19 | try {
20 | Class activityThreadClass = Class.forName("android.app.ActivityThread");
21 | Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
22 | Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
23 | activitiesField.setAccessible(true);
24 | Map activities = (Map) activitiesField.get(activityThread);
25 | for (Object activityRecord : activities.values()) {
26 | Class activityRecordClass = activityRecord.getClass();
27 | Field pausedField = activityRecordClass.getDeclaredField("paused");
28 | pausedField.setAccessible(true);
29 | if (!pausedField.getBoolean(activityRecord)) {
30 | Field activityField = activityRecordClass.getDeclaredField("activity");
31 | activityField.setAccessible(true);
32 | Activity activity = (Activity) activityField.get(activityRecord);
33 | return activity;
34 | }
35 | }
36 | } catch (Exception e) {
37 | e.printStackTrace();
38 | }
39 | return null;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/CertificateUtil.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 |
6 | import com.orhanobut.logger.Logger;
7 |
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.security.KeyStore;
11 | import java.security.SecureRandom;
12 | import java.security.cert.CertificateFactory;
13 |
14 | import javax.net.ssl.SSLContext;
15 | import javax.net.ssl.SSLSocketFactory;
16 | import javax.net.ssl.TrustManagerFactory;
17 |
18 | /**
19 | * created by arvin on 16/8/3 10:11
20 | * email:1035407623@qq.com
21 | */
22 | public class CertificateUtil {
23 |
24 | private static InputStream[] getCertificatesByAssert(Context context, String... certificateNames) {
25 | if (context == null) {
26 | Logger.d("context is empty");
27 | return null;
28 | }
29 | if (certificateNames == null) {
30 | Logger.d("certificate is empty");
31 | return null;
32 | }
33 |
34 | AssetManager assets = context.getAssets();
35 | InputStream[] certificates = new InputStream[certificateNames.length];
36 | for (int i = 0; i < certificateNames.length; i++) {
37 | String certificateName = certificateNames[i];
38 | try {
39 | certificates[i] = assets.open(certificateName);
40 | } catch (IOException e) {
41 | e.printStackTrace();
42 | }
43 | }
44 | return certificates;
45 | }
46 |
47 | public static SSLSocketFactory setCertificates(Context context, String... certificateNames) {
48 | InputStream[] certificates = getCertificatesByAssert(context, certificateNames);
49 | if (certificates == null) {
50 | return null;
51 | }
52 | try {
53 | CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
54 | KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
55 | keyStore.load(null);
56 | int index = 0;
57 | for (InputStream certificate : certificates) {
58 | String certificateAlias = Integer.toString(index++);
59 | keyStore.setCertificateEntry(certificateAlias, certificateFactory.generateCertificate(certificate));
60 |
61 | try {
62 | if (certificate != null)
63 | certificate.close();
64 | } catch (IOException e) {
65 | e.printStackTrace();
66 | }
67 | }
68 |
69 | SSLContext sslContext = SSLContext.getInstance("TLS");
70 |
71 | TrustManagerFactory trustManagerFactory =
72 | TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
73 |
74 | trustManagerFactory.init(keyStore);
75 | sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());
76 | return sslContext.getSocketFactory();
77 | } catch (Exception e) {
78 | e.printStackTrace();
79 | }
80 | return null;
81 | }
82 |
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/GlideUtil.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
8 | import com.bumptech.glide.load.model.GlideUrl;
9 |
10 | import net.arvin.afbaselibrary.R;
11 | import net.arvin.afbaselibrary.widgets.GlideCircleTransform;
12 |
13 | import java.io.InputStream;
14 |
15 | import okhttp3.OkHttpClient;
16 |
17 | /**
18 | * Created by arvin on 2016/5/24
19 | */
20 | public class GlideUtil {
21 | /**
22 | * 加载普通图片(http://或者file://)
23 | */
24 | public static void loadImage(Context context, String url, ImageView imageView) {
25 | Glide.with(context).load(url).placeholder(R.drawable.img_loading).error(R.drawable.img_loading).into(imageView);
26 | }
27 |
28 | /**
29 | * 加载为圆形图片(一般为头像加载)
30 | */
31 | public static void loadCircleImage(Context context, String url, ImageView imageView) {
32 | Glide.with(context).load(url).placeholder(R.drawable.img_default_avatar).error(R.drawable.img_default_avatar).
33 | transform(new GlideCircleTransform(context)).into(imageView);
34 | }
35 |
36 | /**
37 | * 加载本地图片(资源文件)
38 | */
39 | public static void loadLocalImage(Context context, int resId, ImageView imageView) {
40 | Glide.with(context).load(resId).into(imageView);
41 | }
42 |
43 | /**
44 | * 加载本地图片(资源文件)
45 | */
46 | public static void loadLocalCircleImage(Context context, int resId, ImageView imageView) {
47 | Glide.with(context).load(resId).transform(new GlideCircleTransform(context)).into(imageView);
48 | }
49 |
50 | /**
51 | * @param okHttpClient 使用Https时的,Net中的okHttpClient
52 | */
53 | public static void registerHttps(Context context, OkHttpClient okHttpClient) {
54 | Glide.get(context).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient));
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/ScreenUtil.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.view.WindowManager;
7 |
8 | import net.arvin.afbaselibrary.R;
9 |
10 | /**
11 | * Created by arvin on 2016/2/2 16:42.
12 | * 屏幕尺寸相关方法
13 | */
14 | @SuppressWarnings("all")
15 | public class ScreenUtil {
16 | private static WindowManager getWindowManager(Context context) {
17 | return (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
18 | }
19 |
20 | public static int getScreenWidth(Context context) {
21 | return getWindowManager(context).getDefaultDisplay().getWidth();
22 | }
23 |
24 | public static int getScreenHeight(Context context) {
25 | return getWindowManager(context).getDefaultDisplay().getHeight();
26 | }
27 |
28 | public static int px2dp(float pxValue) {
29 | final float scale = Resources.getSystem().getDisplayMetrics().density;
30 | return (int) (pxValue / scale + 0.5f);
31 | }
32 |
33 | public static int dp2px(float dipValue) {
34 | final float scale = Resources.getSystem().getDisplayMetrics().density;
35 | return (int) (dipValue * scale + 0.5f);
36 | }
37 |
38 | public static int px2sp(float pxValue) {
39 | final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
40 | return (int) (pxValue / fontScale + 0.5f);
41 | }
42 |
43 | public static int sp2px(float spValue) {
44 | final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
45 | return (int) (spValue * fontScale + 0.5f);
46 | }
47 |
48 | private static final int[] APPCOMPAT_CHECK_ATTRS = {R.attr.colorPrimary};
49 |
50 | public static void checkAppCompatTheme(Context context) {
51 | TypedArray typedArray = context.obtainStyledAttributes(APPCOMPAT_CHECK_ATTRS);
52 | final boolean failed = !typedArray.hasValue(0);
53 | if (typedArray != null) {
54 | typedArray.recycle();
55 | }
56 | if (failed) {
57 | throw new IllegalArgumentException("You need to use a Theme.AppCompat theme (or descendant) with the design library.");
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/utils/WeakHandler.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.utils;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import net.arvin.afbaselibrary.listeners.IWeakHandler;
7 |
8 | import java.lang.ref.WeakReference;
9 |
10 | /**
11 | * Created by arvin on 2016/2/2 16:48.
12 | * 避免内存泄露使用弱引用
13 | */
14 | public class WeakHandler extends Handler {
15 | private WeakReference mActivity;
16 |
17 | public WeakHandler(IWeakHandler activity) {
18 | mActivity = new WeakReference<>(activity);
19 | }
20 |
21 | @Override
22 | public void handleMessage(Message msg) {
23 | if (mActivity != null) {
24 | IWeakHandler weakHandleInterface = mActivity.get();
25 | if (weakHandleInterface != null) {
26 | weakHandleInterface.handleMessage(msg);
27 | }
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/widgets/GlideCircleTransform.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.widgets;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapShader;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 |
9 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
10 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
11 |
12 | /**
13 | * Created by arvin on 2016/6/1 13:38
14 | */
15 | public class GlideCircleTransform extends BitmapTransformation {
16 |
17 | public GlideCircleTransform(Context context) {
18 | super(context);
19 | }
20 |
21 | @Override
22 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
23 | return circleCrop(pool, toTransform);
24 | }
25 |
26 | /**
27 | * 根据宽高画圆
28 | */
29 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
30 | if (source == null) return null;
31 |
32 | int size = Math.min(source.getWidth(), source.getHeight());
33 | int x = (source.getWidth() - size) / 2;
34 | int y = (source.getHeight() - size) / 2;
35 |
36 | // TODO this could be acquired from the pool too
37 | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
38 |
39 | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
40 | if (result == null) {
41 | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
42 | }
43 |
44 | Canvas canvas = new Canvas(result);
45 | Paint paint = new Paint();
46 | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
47 | paint.setAntiAlias(true);
48 | float r = size / 2f;
49 | canvas.drawCircle(r, r, r, paint);
50 | return result;
51 | }
52 |
53 | @Override
54 | public String getId() {
55 | return getClass().getName();
56 | }
57 | }
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/widgets/ProgressWebView.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.widgets;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.webkit.WebView;
6 | import android.webkit.WebViewClient;
7 | import android.widget.ProgressBar;
8 |
9 | import net.arvin.afbaselibrary.R;
10 | import net.arvin.afbaselibrary.utils.ScreenUtil;
11 |
12 |
13 | @SuppressWarnings("deprecation")
14 | public class ProgressWebView extends WebView {
15 | private ProgressBar progressbar;
16 |
17 | public ProgressWebView(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | progressbar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
20 | progressbar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, ScreenUtil.dp2px(5), 0, 0));
21 | progressbar.setProgressDrawable(getResources().getDrawable(R.drawable.progeress_bar_style));
22 | progressbar.setProgress(5);
23 | addView(progressbar);
24 | setWebViewClient(new WebViewClient() {
25 | });
26 | setWebChromeClient(new WebChromeClient());
27 | }
28 |
29 | public class WebChromeClient extends android.webkit.WebChromeClient {
30 | @Override
31 | public void onProgressChanged(WebView view, int newProgress) {
32 | if (newProgress == 100) {
33 | progressbar.setVisibility(GONE);
34 | } else {
35 | if (progressbar.getVisibility() == GONE)
36 | progressbar.setVisibility(VISIBLE);
37 | progressbar.setProgress(newProgress + 5);
38 | }
39 | super.onProgressChanged(view, newProgress);
40 | }
41 | }
42 |
43 | @Override
44 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
45 | LayoutParams lp = (LayoutParams) progressbar.getLayoutParams();
46 | lp.x = l;
47 | lp.y = t;
48 | progressbar.setLayoutParams(lp);
49 | super.onScrollChanged(l, t, oldl, oldt);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/java/net/arvin/afbaselibrary/widgets/WebView4Scroll.java:
--------------------------------------------------------------------------------
1 | package net.arvin.afbaselibrary.widgets;
2 |
3 | import android.content.Context;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 | import android.util.AttributeSet;
6 | import android.webkit.WebView;
7 |
8 | /**
9 | * created by arvin on 17/1/16 09:37
10 | * email:1035407623@qq.com
11 | */
12 | public class WebView4Scroll extends WebView {
13 |
14 | private SwipeRefreshLayout swipeRefreshLayout;
15 |
16 | public WebView4Scroll(Context context) {
17 | super(context);
18 | }
19 |
20 | public WebView4Scroll(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public WebView4Scroll(Context context, AttributeSet attrs, int defStyleAttr) {
25 | super(context, attrs, defStyleAttr);
26 | }
27 |
28 | public void setSwipeRefreshLayout(SwipeRefreshLayout swipeRefreshLayout) {
29 | this.swipeRefreshLayout = swipeRefreshLayout;
30 | }
31 |
32 | @Override
33 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
34 | super.onScrollChanged(l, t, oldl, oldt);
35 | if(swipeRefreshLayout == null) {
36 | return;
37 | }
38 | if (this.getScrollY() == 0){
39 | swipeRefreshLayout.setEnabled(true);
40 | }else {
41 | swipeRefreshLayout.setEnabled(false);
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/anim/af_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/anim/scale_with_alpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/anim/ui_right_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-v21/bg_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_bottom.png
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_left.png
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/afbaselibrary/src/main/res/drawable-xhdpi/ui_shadow_right.png
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-xxhdpi/img_default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/afbaselibrary/src/main/res/drawable-xxhdpi/img_default_avatar.png
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable-xxhdpi/img_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/afbaselibrary/src/main/res/drawable-xxhdpi/img_loading.png
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable/bg_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable/progeress_bar_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable/selector_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable/ui_white_corner_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/drawable/white_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_navi_tab_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_refresh.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_swipeback.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/layout/ui_layout_webview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #1FFFFFFF
5 | #4DFFFFFF
6 | #B3FFFFFF
7 | #FFFFFFFF
8 |
9 |
10 | #1F000000
11 | #42000000
12 | #8A000000
13 | #DE000000
14 | #212121
15 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0.5dp
5 | 1dp
6 | 2dp
7 | 4dp
8 | 8dp
9 | 12dp
10 | 16dp
11 | 24dp
12 | 32dp
13 | 40dp
14 | 48dp
15 | 56dp
16 | 64dp
17 | 80dp
18 | 96dp
19 |
20 |
21 | 10sp
22 | 12sp
23 | 14sp
24 | 16sp
25 | 18sp
26 | 20sp
27 | 24sp
28 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/pre_identify.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 设置
3 | 取消
4 |
5 |
--------------------------------------------------------------------------------
/afbaselibrary/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
17 |
18 |
21 |
--------------------------------------------------------------------------------
/aidlclient/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/aidlclient/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile project(':afbaselibrary')
24 | }
25 |
--------------------------------------------------------------------------------
/aidlclient/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arvin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/aidlclient/readme.md:
--------------------------------------------------------------------------------
1 | 这是客户端的代码,服务端的代码请查看app中net.arvin.androidart.multiProcess和aidl文件下的内容,具体讲解看博客
--------------------------------------------------------------------------------
/aidlclient/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/aidlclient/src/main/aidl/net/arvin/androidart/aidl/IBinderPool.aidl:
--------------------------------------------------------------------------------
1 | // IBinderPool.aidl
2 | package net.arvin.androidart.aidl;
3 |
4 | // Declare any non-default types here with import statements
5 |
6 | interface IBinderPool {
7 | /**
8 | * @param binderCode, the unique token of specific Binder
9 | * @return specific Binder who's token is binderCode.
10 | */
11 | IBinder queryBinder(int binderCode);
12 | }
13 |
--------------------------------------------------------------------------------
/aidlclient/src/main/aidl/net/arvin/androidart/aidl/IIntegerAdd.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | interface IIntegerAdd {
4 | int add(int num1,int num2);
5 | }
6 |
--------------------------------------------------------------------------------
/aidlclient/src/main/aidl/net/arvin/androidart/aidl/IOnNewPersonIn.aidl:
--------------------------------------------------------------------------------
1 | // IOnNewPersonIn.aidl
2 | package net.arvin.androidart.aidl;
3 |
4 | import net.arvin.androidart.aidl.Person;
5 |
6 | interface IOnNewPersonIn {
7 | void onNewPersonIn(in Person newPerson);
8 | }
9 |
--------------------------------------------------------------------------------
/aidlclient/src/main/aidl/net/arvin/androidart/aidl/IPersonCount.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | import net.arvin.androidart.aidl.Person;
4 | import net.arvin.androidart.aidl.IOnNewPersonIn;
5 |
6 | interface IPersonCount {
7 | boolean addPerson(in Person person);
8 |
9 | List getPersons();
10 |
11 | void registerListener(in IOnNewPersonIn listener);
12 |
13 | void unregisterListener(in IOnNewPersonIn listener);
14 | }
15 |
--------------------------------------------------------------------------------
/aidlclient/src/main/aidl/net/arvin/androidart/aidl/Person.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 | parcelable Person;
3 |
--------------------------------------------------------------------------------
/aidlclient/src/main/java/net/arvin/aidlclient/BinderPool.java:
--------------------------------------------------------------------------------
1 | package net.arvin.aidlclient;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.ServiceConnection;
7 | import android.os.IBinder;
8 | import android.os.RemoteException;
9 | import android.util.Log;
10 |
11 | import net.arvin.androidart.aidl.IBinderPool;
12 |
13 | /**
14 | * created by arvin on 17/2/18 17:45
15 | * email:1035407623@qq.com
16 | */
17 | public class BinderPool {
18 | private static final String TAG = "BinderPool";
19 | public static final int BINDER_COMPUTE = 0;
20 | public static final int BINDER_PERSON_COUNT = 1;
21 |
22 | private Context mContext;
23 | private IBinderPool mBinderPool;
24 | private static BinderPool sInstance;
25 |
26 | private BinderPool(Context context) {
27 | mContext = context.getApplicationContext();
28 | connectBinderPoolService();
29 | }
30 |
31 | public static BinderPool getInstance(Context context) {
32 | if (sInstance == null) {
33 | synchronized (BinderPool.class) {
34 | if (sInstance == null) {
35 | sInstance = new BinderPool(context);
36 | }
37 | }
38 | }
39 | return sInstance;
40 | }
41 |
42 | private synchronized void connectBinderPoolService() {
43 | Intent service = new Intent();
44 | service.setComponent(new ComponentName("net.arvin.androidart",
45 | "net.arvin.androidart.multiProcess.BinderPoolService"));
46 | mContext.bindService(service, mBinderPoolConnection,
47 | Context.BIND_AUTO_CREATE);
48 | }
49 |
50 | public IBinder queryBinder(int binderCode) {
51 | IBinder binder = null;
52 | try {
53 | if (mBinderPool != null) {
54 | binder = mBinderPool.queryBinder(binderCode);
55 | }
56 | } catch (RemoteException e) {
57 | e.printStackTrace();
58 | }
59 | return binder;
60 | }
61 |
62 | private ServiceConnection mBinderPoolConnection = new ServiceConnection() {
63 |
64 | @Override
65 | public void onServiceDisconnected(ComponentName name) {
66 | }
67 |
68 | @Override
69 | public void onServiceConnected(ComponentName name, IBinder service) {
70 | mBinderPool = IBinderPool.Stub.asInterface(service);
71 | try {
72 | mBinderPool.asBinder().linkToDeath(mBinderPoolDeathRecipient, 0);
73 | } catch (RemoteException e) {
74 | e.printStackTrace();
75 | }
76 | }
77 | };
78 |
79 | private IBinder.DeathRecipient mBinderPoolDeathRecipient = new IBinder.DeathRecipient() {
80 | @Override
81 | public void binderDied() {
82 | Log.w(TAG, "binder died.");
83 | mBinderPool.asBinder().unlinkToDeath(mBinderPoolDeathRecipient, 0);
84 | mBinderPool = null;
85 | connectBinderPoolService();
86 | }
87 | };
88 | }
89 |
--------------------------------------------------------------------------------
/aidlclient/src/main/java/net/arvin/androidart/aidl/Person.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * created by arvin on 17/2/15 22:42
8 | * email:1035407623@qq.com
9 | */
10 | public class Person implements Parcelable {
11 | private String name;
12 | private int age;
13 |
14 | public Person(String name, int age) {
15 | this.name = name;
16 | this.age = age;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public int getAge() {
28 | return age;
29 | }
30 |
31 | public void setAge(int age) {
32 | this.age = age;
33 | }
34 |
35 | public Person() {
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "Person{" +
41 | "name='" + name + '\'' +
42 | ", age=" + age +
43 | '}' + "\n";
44 | }
45 |
46 | @Override
47 | public int describeContents() {
48 | return 0;
49 | }
50 |
51 | @Override
52 | public void writeToParcel(Parcel dest, int flags) {
53 | dest.writeString(this.name);
54 | dest.writeInt(this.age);
55 | }
56 |
57 | protected Person(Parcel in) {
58 | readFromParcel(in);
59 | }
60 |
61 | public void readFromParcel(Parcel in){
62 | this.name = in.readString();
63 | this.age = in.readInt();
64 | }
65 |
66 | public static final Creator CREATOR = new Creator() {
67 | @Override
68 | public Person createFromParcel(Parcel source) {
69 | return new Person(source);
70 | }
71 |
72 | @Override
73 | public Person[] newArray(int size) {
74 | return new Person[size];
75 | }
76 | };
77 | }
78 |
--------------------------------------------------------------------------------
/aidlclient/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/aidlclient/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/aidlclient/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #f8f8f8
8 |
9 |
--------------------------------------------------------------------------------
/aidlclient/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/aidlclient/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AIDLClient
3 |
4 |
--------------------------------------------------------------------------------
/aidlclient/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
20 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.model.application'
2 |
3 | model {
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 | defaultConfig {
8 | applicationId "net.arvin.androidart"
9 | minSdkVersion.apiLevel 14
10 | targetSdkVersion.apiLevel 25
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | buildConfigFields {
15 | create() {
16 | type "int"
17 | name "VALUE"
18 | value "1"
19 | }
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles.add(file("proguard-rules.pro"))
26 | }
27 | }
28 | ndk {
29 | moduleName "NdkTest"
30 | }
31 | }
32 | }
33 |
34 | dependencies {
35 | compile fileTree(include: ['*.jar'], dir: 'libs')
36 | compile project(':afbaselibrary')
37 | compile project(':greendao')
38 | }
39 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arvin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/aidl/net/arvin/androidart/aidl/IBinderPool.aidl:
--------------------------------------------------------------------------------
1 | // IBinderPool.aidl
2 | package net.arvin.androidart.aidl;
3 |
4 | // Declare any non-default types here with import statements
5 | interface IBinderPool {
6 | /**
7 | * @param binderCode, the unique token of specific Binder
8 | * @return specific Binder who's token is binderCode.
9 | */
10 | IBinder queryBinder(int binderCode);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/aidl/net/arvin/androidart/aidl/IIntegerAdd.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | interface IIntegerAdd {
4 | int add(int num1,int num2);
5 | }
6 |
--------------------------------------------------------------------------------
/app/src/main/aidl/net/arvin/androidart/aidl/IOnNewPersonIn.aidl:
--------------------------------------------------------------------------------
1 | // IOnNewPersonIn.aidl
2 | package net.arvin.androidart.aidl;
3 |
4 | import net.arvin.androidart.aidl.Person;
5 |
6 | interface IOnNewPersonIn {
7 | void onNewPersonIn(in Person newPerson);
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/aidl/net/arvin/androidart/aidl/IPersonCount.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | import net.arvin.androidart.aidl.Person;
4 | import net.arvin.androidart.aidl.IOnNewPersonIn;
5 |
6 | interface IPersonCount {
7 | boolean addPerson(in Person person);
8 |
9 | List getPersons();
10 |
11 | void registerListener(in IOnNewPersonIn listener);
12 |
13 | void unregisterListener(in IOnNewPersonIn listener);
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/aidl/net/arvin/androidart/aidl/Person.aidl:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 | parcelable Person;
3 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/App.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart;
2 |
3 | import android.app.Application;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.util.Log;
6 |
7 | import net.arvin.afbaselibrary.utils.AFUtil;
8 |
9 | /**
10 | * created by arvin on 17/2/8 21:03
11 | * email:1035407623@qq.com
12 | */
13 | public class App extends Application {
14 | public static int count = 0;
15 | public static App sInstance;
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | sInstance = this;
21 | Log.d("App start", "process name is " + AFUtil.getProcessName(this));
22 | // setDatabase();
23 | }
24 |
25 | public static App getInstance() {
26 | return sInstance;
27 | }
28 |
29 | // /**
30 | // * 设置greenDao
31 | // */
32 | // private void setDatabase() {
33 | // // 通过 DaoMaster 的内部类 DevOpenHelper,你可以得到一个便利的 SQLiteOpenHelper 对象。
34 | // // 可能你已经注意到了,你并不需要去编写「CREATE TABLE」这样的 SQL 语句,因为 greenDAO 已经帮你做了。
35 | // // 注意:默认的 DaoMaster.DevOpenHelper 会在数据库升级时,删除所有的表,意味着这将导致数据的丢失。
36 | // // 所以,在正式的项目中,你还应该做一层封装,来实现数据库的安全升级。
37 | // mHelper = new DaoMaster.DevOpenHelper(this, "art-db", null);
38 | // db = mHelper.getWritableDatabase();
39 | // // 注意:该数据库连接属于 DaoMaster,所以多个 Session 指的是相同的数据库连接。
40 | // mDaoMaster = new DaoMaster(db);
41 | // mDaoSession = mDaoMaster.newSession();
42 | // }
43 | //
44 | // public DaoSession getDaoSession() {
45 | // return mDaoSession;
46 | // }
47 | //
48 | // public SQLiteDatabase getDb() {
49 | // return db;
50 | // }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart;
2 |
3 | import android.content.res.Configuration;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | import net.arvin.afbaselibrary.uis.activities.BaseHeaderActivity;
8 | import net.arvin.androidart.anim.AnimActivity;
9 | import net.arvin.androidart.broadcast.BroadcastActivity;
10 | import net.arvin.androidart.intent.IntentActivity;
11 | import net.arvin.androidart.jni.JniActivity;
12 | import net.arvin.androidart.multiProcess.ProcessActivity;
13 | import net.arvin.androidart.provider.ProviderActivity;
14 | import net.arvin.androidart.retrofit.GithubReposActivity;
15 | import net.arvin.androidart.service.ServiceActivity;
16 | import net.arvin.androidart.toast.ToastActivity;
17 |
18 | import butterknife.OnClick;
19 |
20 | public class MainActivity extends BaseHeaderActivity {
21 |
22 | @Override
23 | public int getContentViewId() {
24 | return R.layout.activity_main;
25 | }
26 |
27 | @Override
28 | protected boolean isShowBackView() {
29 | return false;
30 | }
31 |
32 | @Override
33 | protected String getTitleText() {
34 | return getString(R.string.app_name);
35 | }
36 |
37 | @Override
38 | protected void initViews(Bundle savedInstanceState) {
39 | App.count = 1;
40 | Log.d("MainActivity", "count is " + App.count);
41 | }
42 |
43 | @OnClick(R.id.tv_intent_analyze)
44 | public void toIntentAnalyze() {
45 | startActivity(IntentActivity.class);
46 | }
47 |
48 | @OnClick(R.id.tv_custom_toast)
49 | public void toToast() {
50 | startActivity(ToastActivity.class);
51 | }
52 |
53 | @OnClick(R.id.tv_multi_process)
54 | public void toMultiProcess() {
55 | Bundle bundle = new Bundle();
56 | bundle.putInt(ProcessActivity.KEY_1, App.count);
57 | startActivity(ProcessActivity.class, bundle);
58 | }
59 |
60 | @Override
61 | public void onConfigurationChanged(Configuration newConfig) {
62 | super.onConfigurationChanged(newConfig);
63 | }
64 |
65 | @OnClick(R.id.tv_anim)
66 | public void toAnim() {
67 | startActivity(AnimActivity.class);
68 | }
69 |
70 | // @OnClick(R.id.tv_handler)
71 | // public void toHandler() {
72 | // startActivity(HandlerActivity.class);
73 | // }
74 |
75 | @OnClick(R.id.tv_service)
76 | public void toService() {
77 | startActivity(ServiceActivity.class);
78 | }
79 |
80 | @OnClick(R.id.tv_broadcast)
81 | public void toBroadcast() {
82 | startActivity(BroadcastActivity.class);
83 | }
84 |
85 | @OnClick(R.id.tv_provider)
86 | public void toProvider() {
87 | startActivity(ProviderActivity.class);
88 | }
89 |
90 | @OnClick(R.id.tv_retrofit)
91 | public void toRetrofit() {
92 | startActivity(GithubReposActivity.class);
93 | }
94 |
95 | @OnClick(R.id.tv_jni)
96 | public void toJNI() {
97 | startActivity(JniActivity.class);
98 | }
99 |
100 | /**
101 | * 第一个显示的界面记得重写onBackPressed方法,去掉动画
102 | */
103 | @Override
104 | public void onBackPressed() {
105 | finish();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/aidl/Person.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.aidl;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * created by arvin on 17/2/15 22:42
8 | * email:1035407623@qq.com
9 | */
10 | public class Person implements Parcelable {
11 | private String name;
12 | private int age;
13 |
14 | public String getName() {
15 | return name;
16 | }
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public int getAge() {
23 | return age;
24 | }
25 |
26 | public void setAge(int age) {
27 | this.age = age;
28 | }
29 |
30 | @Override
31 | public int describeContents() {
32 | return 0;
33 | }
34 |
35 | @Override
36 | public void writeToParcel(Parcel dest, int flags) {
37 | dest.writeString(this.name);
38 | dest.writeInt(this.age);
39 | }
40 |
41 |
42 | public Person() {
43 | }
44 |
45 | protected Person(Parcel in) {
46 | this.name = in.readString();
47 | this.age = in.readInt();
48 | }
49 |
50 | /**
51 | *为了支持out数据流向需要重写该方法
52 | * @param in
53 | */
54 | void readFromParcel(Parcel in){
55 | this.name = in.readString();
56 | this.age = in.readInt();
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return "Person{" +
62 | "name='" + name + '\'' +
63 | ", age=" + age +
64 | '}' + "\n";
65 | }
66 |
67 | public static final Creator CREATOR = new Creator() {
68 | @Override
69 | public Person createFromParcel(Parcel source) {
70 | return new Person(source);
71 | }
72 |
73 | @Override
74 | public Person[] newArray(int size) {
75 | return new Person[size];
76 | }
77 | };
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/anim/BaseViewWrapper.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.anim;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * created by arvin on 17/2/19 21:10
7 | * email:1035407623@qq.com
8 | */
9 | public abstract class BaseViewWrapper {
10 | protected View mTarget;
11 |
12 | public BaseViewWrapper(View mTarget) {
13 | this.mTarget = mTarget;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/anim/ViewWidthWrapper.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.anim;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * created by arvin on 17/2/19 21:11
7 | * email:1035407623@qq.com
8 | */
9 | public class ViewWidthWrapper extends BaseViewWrapper {
10 | public ViewWidthWrapper(View mTarget) {
11 | super(mTarget);
12 | }
13 |
14 | public void setWidth(int width) {
15 | mTarget.getLayoutParams().width = width;
16 | mTarget.requestLayout();
17 | }
18 |
19 | public int getWidth() {
20 | return mTarget.getWidth();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/broadcast/BroadcastActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.broadcast;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.os.Bundle;
8 |
9 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
10 | import net.arvin.androidart.R;
11 |
12 | import butterknife.OnClick;
13 |
14 | /**
15 | * created by arvin on 17/2/24 00:00
16 | * email:1035407623@qq.com
17 | */
18 | public class BroadcastActivity extends BaseSwipeBackActivity {
19 | private BroadcastReceiver mReceiver = new BroadcastReceiver() {
20 | @Override
21 | public void onReceive(Context context, Intent intent) {
22 | showToast("动态注册的广播");
23 | }
24 | };
25 | final String DYNAMICS_ACTION = "net.arvin.androidart.broadcast.dynamics";
26 | final String STATIC_ACTION = "net.arvin.androidart.broadcast.static";
27 |
28 | @Override
29 | public int getContentViewId() {
30 | return R.layout.activity_broadcast;
31 | }
32 |
33 | @Override
34 | protected String getTitleText() {
35 | return "广播相关";
36 | }
37 |
38 | @Override
39 | protected void initViews(Bundle savedInstanceState) {
40 | registerReceiver(mReceiver, getFilter());
41 | }
42 |
43 | private IntentFilter getFilter() {
44 | IntentFilter filter = new IntentFilter();
45 | filter.addAction(DYNAMICS_ACTION);
46 | return filter;
47 | }
48 |
49 | @OnClick(R.id.tv_static_broadcast)
50 | public void sendStaticBroadcast() {
51 | Intent intent = new Intent();
52 | intent.setAction(STATIC_ACTION);
53 | sendBroadcast(intent);
54 | }
55 |
56 | @OnClick(R.id.tv_dynamics_broadcast)
57 | public void sendDynamicsBroadcast() {
58 | Intent intent = new Intent();
59 | intent.setAction(DYNAMICS_ACTION);
60 | sendBroadcast(intent);
61 | }
62 |
63 | @Override
64 | protected void onDestroy() {
65 | unregisterReceiver(mReceiver);
66 | super.onDestroy();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/broadcast/StaticReceiver.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.broadcast;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.widget.Toast;
7 |
8 | /**
9 | * created by arvin on 17/2/24 00:02
10 | * email:1035407623@qq.com
11 | */
12 | public class StaticReceiver extends BroadcastReceiver {
13 | @Override
14 | public void onReceive(Context context, Intent intent) {
15 | Toast.makeText(context, "静态注册的广播", Toast.LENGTH_SHORT).show();
16 | // abortBroadcast();//拦截掉
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/entities/GitHubRepos.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.entities;
2 |
3 | /**
4 | * created by arvin on 17/2/27 20:13
5 | * email:1035407623@qq.com
6 | */
7 | public class GitHubRepos {
8 | private String name;
9 | private String full_name;
10 | private GitHubUserEntity owner;
11 | private int stargazers_count;
12 | private int forks_count;
13 |
14 | public String getName() {
15 | return name;
16 | }
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public String getFull_name() {
23 | return full_name;
24 | }
25 |
26 | public void setFull_name(String full_name) {
27 | this.full_name = full_name;
28 | }
29 |
30 | public GitHubUserEntity getOwner() {
31 | return owner;
32 | }
33 |
34 | public void setOwner(GitHubUserEntity owner) {
35 | this.owner = owner;
36 | }
37 |
38 | public int getStargazers_count() {
39 | return stargazers_count;
40 | }
41 |
42 | public void setStargazers_count(int stargazers_count) {
43 | this.stargazers_count = stargazers_count;
44 | }
45 |
46 | public int getForks_count() {
47 | return forks_count;
48 | }
49 |
50 | public void setForks_count(int forks_count) {
51 | this.forks_count = forks_count;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/entities/GitHubUserEntity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.entities;
2 |
3 | /**
4 | * created by arvin on 17/2/27 20:14
5 | * email:1035407623@qq.com
6 | */
7 | public class GitHubUserEntity {
8 | private String login;
9 | private String url;
10 | private String avatar_url;
11 |
12 | public String getLogin() {
13 | return login;
14 | }
15 |
16 | public void setLogin(String login) {
17 | this.login = login;
18 | }
19 |
20 | public String getUrl() {
21 | return url;
22 | }
23 |
24 | public void setUrl(String url) {
25 | this.url = url;
26 | }
27 |
28 | public String getAvatar_url() {
29 | return avatar_url;
30 | }
31 |
32 | public void setAvatar_url(String avatar_url) {
33 | this.avatar_url = avatar_url;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/handler/HandlerActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.handler;
2 |
3 | import android.os.Bundle;
4 | import android.os.Message;
5 |
6 | import net.arvin.afbaselibrary.listeners.IWeakHandler;
7 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
8 | import net.arvin.afbaselibrary.utils.WeakHandler;
9 | import net.arvin.androidart.R;
10 |
11 | /**
12 | * created by arvin on 17/2/20 21:41
13 | * email:1035407623@qq.com
14 | */
15 | public class HandlerActivity extends BaseSwipeBackActivity implements IWeakHandler {
16 | private WeakHandler mHandler;
17 |
18 | @Override
19 | public int getContentViewId() {
20 | return R.layout.activity_hanlder;
21 | }
22 |
23 | @Override
24 | protected String getTitleText() {
25 | return "消息机制";
26 | }
27 |
28 | @Override
29 | protected void initViews(Bundle savedInstanceState) {
30 | mHandler = new WeakHandler(this);
31 | mHandler.sendEmptyMessageDelayed(0, 1000);
32 |
33 | mHandler.postDelayed(new Runnable() {
34 | @Override
35 | public void run() {
36 | showToast("post呵呵");
37 | }
38 | }, 3000);
39 | }
40 |
41 | @Override
42 | public void handleMessage(Message msg) {
43 | if (msg.what == 0) {
44 | showToast("send呵呵");
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/intent/FourthActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.intent;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | public class FourthActivity extends SecondActivity {
7 |
8 | @Override
9 | protected String getActivityName() {
10 | return "FourthActivity";
11 | }
12 |
13 | @Override
14 | public void init(Bundle savedInstanceState) {
15 | super.init(savedInstanceState);
16 | Intent intent = getIntent();
17 | Bundle extras = intent.getExtras();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/intent/IntentActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.intent;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 |
7 | import net.arvin.afbaselibrary.uis.activities.BaseActivity;
8 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
9 | import net.arvin.androidart.R;
10 |
11 | import butterknife.OnClick;
12 |
13 | /**
14 | * 隐式intent匹配分析
15 | */
16 | public class IntentActivity extends BaseSwipeBackActivity {
17 |
18 | @Override
19 | public int getContentViewId() {
20 | return R.layout.activity_intent;
21 | }
22 |
23 | @Override
24 | protected String getTitleText() {
25 | return "Intent分析";
26 | }
27 |
28 | @Override
29 | protected void initViews(Bundle savedInstanceState) {
30 | }
31 |
32 | @OnClick(R.id.toSec)
33 | public void toSec() {
34 | Intent intent = new Intent();
35 | intent.setAction("SecondActivityAction");//注释掉这个发现,action不能不设置,至少要有一个匹配上
36 | // intent.setAction("SecondActivityAction1");
37 | // intent.setAction("SecondActivityAction2");
38 |
39 | // intent.setAction("SecondActivityAction3");//解开这个注释发现,如果intent中包含过滤器中未设置的action,则找不到组件
40 | // intent.setData(Uri.parse("https://"));//解开这个注释发现,如果过滤器中未设置data,则intent中设置了也找不到对应的组件
41 | startActivity(intent);
42 | }
43 |
44 | @OnClick(R.id.toThi)
45 | public void toThird() {
46 | Intent intent = new Intent();
47 | intent.setAction("ThirdActivityAction");
48 | intent.addCategory("ThirdActivityCategory");//注释掉这个发现,category不设置也可以,因为会有一个默认的category
49 | // intent.addCategory("ThirdActivityCategory1");
50 | // intent.addCategory("ThirdActivityCategory2");
51 | //解开上边任意一个注释,发现只要加入任意一个过滤器中包含的category就能匹配通过
52 |
53 | // intent.addCategory("ThirdActivityCategory3");//解开这个注释发现,如果intent中包含过滤器中未设置的category,则找不到组件
54 |
55 | //所以得出的结论是intent的category只要是过滤器的category的子集,则category匹配通过。
56 | startActivity(intent);
57 | }
58 |
59 | @OnClick(R.id.toFour)
60 | public void toFour() {
61 | Intent intent = new Intent();
62 | intent.setAction("FourActivityAction");
63 | // intent.setData(Uri.parse("http://"));//只保留这个注释,发现若是过滤器中URI和MIME都设置了,则intent中也要设置URI和MIME
64 | intent.setDataAndType(Uri.parse("http://"), "image/png");
65 | intent.setDataAndType(Uri.parse("https://"), "image/png");
66 | intent.setDataAndType(Uri.parse("https://"), "text/*");
67 | intent.setDataAndType(Uri.parse("http://"), "text/*");
68 | //以上四个发现只要intent中设置的URI结构和MIME只要在过滤器中包含了,即可通过
69 | //结论:只要过滤器中的URI结构和MIME在intent中能找到对应的URI和MIME就可以,URI结构的匹配是过滤器中有什么,intent中就必须有什么才能匹配通过
70 | startActivity(intent);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/intent/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.intent;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import net.arvin.afbaselibrary.uis.activities.BaseActivity;
7 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
8 | import net.arvin.androidart.R;
9 |
10 | import butterknife.BindView;
11 |
12 | public class SecondActivity extends BaseSwipeBackActivity {
13 | @BindView(R.id.tv_name)
14 | TextView tvName;
15 |
16 | @Override
17 | public int getContentViewId() {
18 | return R.layout.activity_name;
19 | }
20 |
21 | @Override
22 | public void init(Bundle savedInstanceState) {
23 | super.init(savedInstanceState);
24 | tvName.setText(getActivityName());
25 | }
26 |
27 | @Override
28 | protected String getTitleText() {
29 | return "";
30 | }
31 |
32 | @Override
33 | protected void initViews(Bundle savedInstanceState) {
34 |
35 | }
36 |
37 | protected String getActivityName() {
38 | return "SecondActivity";
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/intent/ThirdActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.intent;
2 |
3 | public class ThirdActivity extends SecondActivity {
4 | @Override
5 | protected String getActivityName() {
6 | return "ThirdActivity";
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/jni/JniActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.jni;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
7 | import net.arvin.androidart.R;
8 |
9 | import butterknife.ButterKnife;
10 | import butterknife.OnClick;
11 |
12 | /**
13 | * created by arvin on 17/3/2 14:22
14 | * email:1035407623@qq.com
15 | */
16 | public class JniActivity extends BaseSwipeBackActivity {
17 | @Override
18 | protected String getTitleText() {
19 | return "JNI的使用";
20 | }
21 |
22 | @Override
23 | protected void initViews(Bundle savedInstanceState) {
24 | }
25 |
26 | @Override
27 | public int getContentViewId() {
28 | return R.layout.activity_jni;
29 | }
30 |
31 | @OnClick({R.id.tv_reduce, R.id.tv_get_something})
32 | public void onClick(View view) {
33 | switch (view.getId()) {
34 | case R.id.tv_reduce:
35 | showToast("JNI reduce " + NdkTest.reduce(12, 5));
36 | break;
37 | case R.id.tv_get_something:
38 | showToast(NdkTest.getSomethingFromNDK());
39 | break;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/jni/NdkTest.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.jni;
2 |
3 | /**
4 | * created by arvin on 17/3/2 11:33
5 | * email:1035407623@qq.com
6 | */
7 | public class NdkTest {
8 | static {
9 | System.loadLibrary("NdkTest");
10 | }
11 |
12 | public static native String getSomethingFromNDK();
13 |
14 | public static native int reduce(int params1, int params2);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/BinderPoolService.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.os.IBinder;
7 | import android.os.Parcel;
8 | import android.os.RemoteException;
9 |
10 | import net.arvin.androidart.multiProcess.aidlImpl.BinderPoolImpl;
11 |
12 | /**
13 | * created by arvin on 17/2/18 17:52
14 | * email:1035407623@qq.com
15 | */
16 | public class BinderPoolService extends Service {
17 | private BinderPoolImpl binderPool;
18 |
19 | @Override
20 | public IBinder onBind(Intent intent) {
21 | // int check = checkCallingOrSelfPermission("net.arvin.androidart.permission.BinderPoolService");
22 | // if (check == PackageManager.PERMISSION_DENIED) {
23 | // return null;
24 | // }
25 | binderPool = new BinderPoolImpl() {
26 | @Override
27 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
28 | int check = checkCallingOrSelfPermission("net.arvin.androidart.permission.BinderPoolService");
29 | if (check == PackageManager.PERMISSION_DENIED) {
30 | return false;
31 | }
32 |
33 | String packageName;
34 | String[] packages = getPackageManager().getPackagesForUid(getCallingUid());
35 | if (packages != null && packages.length > 0) {
36 | packageName = packages[0];
37 | if (!packageName.startsWith("net.arvin")) {
38 | return false;
39 | }
40 | }
41 | return super.onTransact(code, data, reply, flags);
42 | }
43 | };
44 | return binderPool;
45 | }
46 |
47 | @Override
48 | public void onDestroy() {
49 | super.onDestroy();
50 | binderPool.onDestroy();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/IntegerAddService.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.os.RemoteException;
7 |
8 | import net.arvin.androidart.aidl.IIntegerAdd;
9 |
10 | /**
11 | * created by arvin on 17/2/14 21:46
12 | * email:1035407623@qq.com
13 | */
14 | public class IntegerAddService extends Service {
15 | private IBinder mBinder = new IIntegerAdd.Stub() {
16 | @Override
17 | public int add(int num1, int num2) throws RemoteException {
18 | return num1 + num2;
19 | }
20 | };
21 |
22 | @Override
23 | public IBinder onBind(Intent intent) {
24 | return mBinder;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/PersonCountService.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.os.RemoteException;
7 | import android.support.annotation.Nullable;
8 |
9 | import net.arvin.androidart.aidl.IOnNewPersonIn;
10 | import net.arvin.androidart.aidl.IPersonCount;
11 | import net.arvin.androidart.aidl.Person;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * created by arvin on 17/2/15 22:48
18 | * email:1035407623@qq.com
19 | */
20 | public class PersonCountService extends Service {
21 | private List persons;
22 |
23 | private IBinder mBinder = new IPersonCount.Stub() {
24 | @Override
25 | public boolean addPerson(Person person) throws RemoteException {
26 | boolean isExit = false;
27 | for (Person entity : persons) {
28 | if (entity.getName().equals(person.getName())) {
29 | isExit = true;
30 | break;
31 | }
32 | }
33 | if (!isExit) {
34 | persons.add(person);
35 | }
36 | return isExit;
37 | }
38 |
39 | @Override
40 | public List getPersons() throws RemoteException {
41 | return persons;
42 | }
43 |
44 | @Override
45 | public void registerListener(IOnNewPersonIn listener) throws RemoteException {
46 |
47 | }
48 |
49 | @Override
50 | public void unregisterListener(IOnNewPersonIn listener) throws RemoteException {
51 |
52 | }
53 | };
54 |
55 | @Nullable
56 | @Override
57 | public IBinder onBind(Intent intent) {
58 | return mBinder;
59 | }
60 |
61 | @Override
62 | public void onCreate() {
63 | super.onCreate();
64 | persons = new ArrayList<>();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/ProcessActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.ServiceConnection;
7 | import android.os.Bundle;
8 | import android.os.IBinder;
9 | import android.util.Log;
10 | import android.widget.TextView;
11 |
12 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
13 | import net.arvin.androidart.App;
14 | import net.arvin.androidart.R;
15 |
16 | import butterknife.BindView;
17 |
18 | /**
19 | * created by arvin on 17/2/8 20:54
20 | * email:1035407623@qq.com
21 | */
22 | public class ProcessActivity extends BaseSwipeBackActivity {
23 | public static final String KEY_1 = "KEY_1";
24 |
25 | @BindView(R.id.tv_service_start_status)
26 | TextView tvStatus;
27 | private ServiceConnection conn = new ServiceConnection() {
28 | @Override
29 | public void onServiceConnected(ComponentName name, IBinder service) {
30 | tvStatus.setText("计算服务已开启");
31 | }
32 |
33 | @Override
34 | public void onServiceDisconnected(ComponentName name) {
35 | }
36 | };
37 |
38 | @Override
39 | protected String getTitleText() {
40 | return "多进程通信";
41 | }
42 |
43 | @Override
44 | public int getContentViewId() {
45 | return R.layout.activity_process;
46 | }
47 |
48 | @Override
49 | protected void initViews(Bundle savedInstanceState) {
50 | Log.d("ProcessActivity", "remote count is " + App.count);
51 | Log.d("ProcessActivity", "from MainActivity count is " + getIntent().getExtras().getInt(KEY_1));
52 | //和MainActivity打印的对比可以知道,对于每个进程,都创建了一份自己的内存空间,所以同一个变量,在内存中都有着自己的值
53 | bindService(new Intent(this, IntegerAddService.class), conn, Context.BIND_AUTO_CREATE);
54 |
55 | /**
56 | * 首先要了解,编译生成的AIDL文件的结构,以及其意义!
57 | * 1、首先在要通信的两个进程中,添加相同路径和内容的AIDL文件,并编译;(路径与内容相同,是不是就代表了完全相同)
58 | * 2、创建对应的Service,在onBind中返回对应的Stub(这个就是IBinder);
59 | * 3、bindService,在ServiceConnection中获取到IBinder对象,从而获取到对应的接口;
60 | * 4、拿到接口后,就相当于回调一样简单;
61 | */
62 | }
63 |
64 | @Override
65 | protected void onDestroy() {
66 | unbindService(conn);
67 | super.onDestroy();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/aidlImpl/BinderPoolImpl.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess.aidlImpl;
2 |
3 | import android.os.IBinder;
4 | import android.os.RemoteException;
5 |
6 | import net.arvin.androidart.aidl.IBinderPool;
7 |
8 | import java.util.concurrent.CopyOnWriteArrayList;
9 |
10 | /**
11 | * created by arvin on 17/2/18 18:22
12 | * email:1035407623@qq.com
13 | */
14 | public class BinderPoolImpl extends IBinderPool.Stub {
15 | public static final int BINDER_COMPUTE = 0;
16 | public static final int BINDER_PERSON_COUNT = 1;
17 | private CopyOnWriteArrayList binders = new CopyOnWriteArrayList<>();
18 |
19 | @Override
20 | public IBinder queryBinder(int binderCode) throws RemoteException {
21 | IBinder binder = null;
22 | switch (binderCode) {
23 | case BINDER_PERSON_COUNT: {
24 | binder = new PersonCountImpl();
25 | binders.add(binder);
26 | break;
27 | }
28 | case BINDER_COMPUTE: {
29 | binder = new IntegerAddImpl();
30 | binders.add(binder);
31 | break;
32 | }
33 | default:
34 | break;
35 | }
36 | return binder;
37 | }
38 |
39 | public void onDestroy() {
40 | for (IBinder binder : binders) {
41 | if (binder instanceof PersonCountImpl) {
42 | ((PersonCountImpl) binder).onDestroy();
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/aidlImpl/IntegerAddImpl.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess.aidlImpl;
2 |
3 | import android.os.RemoteException;
4 |
5 | import net.arvin.androidart.aidl.IIntegerAdd;
6 |
7 | /**
8 | * created by arvin on 17/2/18 17:56
9 | * email:1035407623@qq.com
10 | */
11 | public class IntegerAddImpl extends IIntegerAdd.Stub {
12 | @Override
13 | public int add(int num1, int num2) throws RemoteException {
14 | return num1 + num2;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/multiProcess/aidlImpl/PersonCountImpl.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.multiProcess.aidlImpl;
2 |
3 | import android.os.RemoteCallbackList;
4 | import android.os.RemoteException;
5 |
6 | import net.arvin.androidart.aidl.IOnNewPersonIn;
7 | import net.arvin.androidart.aidl.IPersonCount;
8 | import net.arvin.androidart.aidl.Person;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.concurrent.CopyOnWriteArrayList;
13 | import java.util.concurrent.atomic.AtomicBoolean;
14 |
15 | /**
16 | * created by arvin on 17/2/18 17:54
17 | * email:1035407623@qq.com
18 | */
19 | public class PersonCountImpl extends IPersonCount.Stub {
20 | private AtomicBoolean isServiceDestroyed;
21 |
22 | private CopyOnWriteArrayList persons;
23 |
24 | private RemoteCallbackList mListeners;
25 |
26 | public PersonCountImpl() {
27 | isServiceDestroyed = new AtomicBoolean(false);
28 | initData();
29 | initListeners();
30 | new Thread(new ServiceWorker()).start();
31 | }
32 |
33 | private void initData() {
34 | if (persons == null) {
35 | persons = new CopyOnWriteArrayList<>();
36 | }
37 | }
38 |
39 | private void initListeners() {
40 | if (mListeners == null) {
41 | mListeners = new RemoteCallbackList<>();
42 | }
43 | }
44 |
45 | @Override
46 | public boolean addPerson(Person person) throws RemoteException {
47 | boolean isExit = false;
48 | for (Person entity : persons) {
49 | if (entity.getName().equals(person.getName())) {
50 | isExit = true;
51 | break;
52 | }
53 | }
54 | if (!isExit) {
55 | persons.add(person);
56 | }
57 | return isExit;
58 | }
59 |
60 | @Override
61 | public List getPersons() throws RemoteException {
62 | return persons;
63 | }
64 |
65 | @Override
66 | public void registerListener(IOnNewPersonIn listener) throws RemoteException {
67 | mListeners.register(listener);
68 | }
69 |
70 | @Override
71 | public void unregisterListener(IOnNewPersonIn listener) throws RemoteException {
72 | mListeners.unregister(listener);
73 | }
74 |
75 | private void onNewPersonIn(Person newPerson) {
76 | int size = mListeners.beginBroadcast();
77 | for (int i = 0; i < size; i++) {
78 | IOnNewPersonIn onNewPersonIn = mListeners.getBroadcastItem(i);
79 | try {
80 | if (onNewPersonIn != null) {
81 | onNewPersonIn.onNewPersonIn(newPerson);
82 | }
83 | } catch (RemoteException e) {
84 | e.printStackTrace();
85 | }
86 | }
87 | mListeners.finishBroadcast();
88 | }
89 |
90 | public void onDestroy() {
91 | isServiceDestroyed.set(true);
92 | }
93 |
94 | private class ServiceWorker implements Runnable {
95 |
96 | @Override
97 | public void run() {
98 | while (!isServiceDestroyed.get()) {
99 | try {
100 | Thread.sleep(5000);
101 | } catch (InterruptedException e) {
102 | e.printStackTrace();
103 | }
104 | Person newPerson = new Person();
105 | newPerson.setAge(24);
106 | newPerson.setName("nick");
107 | onNewPersonIn(newPerson);
108 | }
109 | }
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/retrofit/ArtApi.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.retrofit;
2 |
3 | import net.arvin.androidart.entities.GitHubRepos;
4 |
5 | import java.util.List;
6 |
7 | import retrofit2.http.GET;
8 | import retrofit2.http.Query;
9 | import rx.Observable;
10 |
11 | /**
12 | * created by arvin on 17/2/27 20:05
13 | * email:1035407623@qq.com
14 | */
15 | public interface ArtApi {
16 | String baseUrl = "https://api.github.com/";
17 |
18 | @GET("users/arvinljw/repos")
19 | Observable> repos(@Query("page") int page,@Query("per_page")int per_page);
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/retrofit/ArtNet.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.retrofit;
2 |
3 | import android.content.Context;
4 |
5 | import net.arvin.afbaselibrary.nets.BaseNet;
6 | import net.arvin.androidart.App;
7 |
8 | import retrofit2.converter.gson.GsonConverterFactory;
9 |
10 | /**
11 | * created by arvin on 17/2/27 20:05
12 | * email:1035407623@qq.com
13 | */
14 | public class ArtNet extends BaseNet {
15 | private static ArtNet mNet;
16 |
17 | public ArtNet() {
18 | super();
19 | converterFactory = GsonConverterFactory.create();
20 | }
21 |
22 | public static ArtNet getInstance() {
23 | if (mNet == null) {
24 | mNet = new ArtNet();
25 | }
26 | return mNet;
27 | }
28 |
29 | @Override
30 | protected String getBaseUrl() {
31 | return ArtApi.baseUrl;
32 | }
33 |
34 | @Override
35 | protected Context getContext() {
36 | return App.getInstance();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/retrofit/GithubReposActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.retrofit;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 |
5 | import net.arvin.afbaselibrary.nets.callbacks.AbsAPICallback;
6 | import net.arvin.afbaselibrary.nets.exceptions.ApiException;
7 | import net.arvin.afbaselibrary.uis.activities.BaseRefreshLoadingActivity;
8 | import net.arvin.afbaselibrary.uis.adapters.BaseAdapter;
9 | import net.arvin.afbaselibrary.uis.adapters.MultiItemTypeAdapter;
10 | import net.arvin.afbaselibrary.uis.adapters.holders.CommonHolder;
11 | import net.arvin.androidart.R;
12 | import net.arvin.androidart.entities.GitHubRepos;
13 |
14 | import java.util.List;
15 |
16 | import rx.android.schedulers.AndroidSchedulers;
17 | import rx.schedulers.Schedulers;
18 |
19 | /**
20 | * created by arvin on 17/2/27 20:28
21 | * email:1035407623@qq.com
22 | */
23 | public class GithubReposActivity extends BaseRefreshLoadingActivity {
24 | @Override
25 | protected MultiItemTypeAdapter getAdapter() {
26 | return new BaseAdapter(this, R.layout.item_repos, mItems) {
27 | @Override
28 | protected void convert(CommonHolder holder, GitHubRepos item, int position) {
29 | holder.setText(R.id.tv_full_name, item.getFull_name());
30 | holder.setText(R.id.tv_star_count, "star:" + item.getStargazers_count() + " fork:" + item.getForks_count());
31 | }
32 | };
33 | }
34 |
35 | @Override
36 | protected void loadData(final int page) {
37 | ArtNet.getInstance().getApi().repos(page, DEFAULT_SIZE).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
38 | .subscribe(new AbsAPICallback>() {
39 | @Override
40 | protected void onResultError(ApiException ex) {
41 | showToast(ex.getDisplayMessage());
42 | refreshComplete(false);
43 | }
44 |
45 | @Override
46 | public void onNext(List gitHubRepos) {
47 | if (page == FIRST_PAGE) {
48 | mItems.clear();
49 | }
50 | mItems.addAll(gitHubRepos);
51 | refreshComplete(gitHubRepos.size() > 0);
52 | }
53 | });
54 | }
55 |
56 | @Override
57 | protected String getTitleText() {
58 | return "arvinljw的github仓库";
59 | }
60 |
61 | @Override
62 | public int getContentViewId() {
63 | return R.layout.activity_github_repos;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/service/ForegroundService.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.service;
2 |
3 | import android.app.Notification;
4 | import android.app.Service;
5 | import android.content.Intent;
6 | import android.graphics.BitmapFactory;
7 | import android.os.IBinder;
8 | import android.os.Message;
9 | import android.os.Messenger;
10 | import android.support.annotation.Nullable;
11 | import android.support.v7.app.NotificationCompat;
12 |
13 | import net.arvin.afbaselibrary.listeners.IWeakHandler;
14 | import net.arvin.afbaselibrary.utils.WeakHandler;
15 | import net.arvin.androidart.R;
16 |
17 | /**
18 | * created by arvin on 17/2/23 23:29
19 | * email:1035407623@qq.com
20 | */
21 | public class ForegroundService extends Service implements IWeakHandler {
22 | /**
23 | * id不可设置为0,否则不能设置为前台service
24 | */
25 | private static final int NOTIFICATION_DOWNLOAD_PROGRESS_ID = 1;
26 |
27 | public static final int START_FORE = 1001;
28 | public static final int STOP_FORE = 1002;
29 |
30 | private boolean isRemove = false;//是否需要移除
31 |
32 | private Messenger mMessenger;
33 |
34 | /**
35 | * Notification
36 | */
37 | public void createNotification() {
38 | NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
39 | builder.setSmallIcon(R.mipmap.ic_launcher);
40 | builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
41 | builder.setAutoCancel(false);
42 | builder.setOngoing(true);
43 | builder.setShowWhen(true);
44 | builder.setContentTitle("这是一个前台服务");
45 | builder.setContentText("你好啊~");
46 | Notification notification = builder.build();
47 | startForeground(NOTIFICATION_DOWNLOAD_PROGRESS_ID, notification);
48 | }
49 |
50 | @Override
51 | public void onDestroy() {
52 | if (isRemove) {
53 | stopForeground(true);
54 | isRemove = false;
55 | }
56 | super.onDestroy();
57 | }
58 |
59 | @Nullable
60 | @Override
61 | public IBinder onBind(Intent intent) {
62 | mMessenger = new Messenger(new WeakHandler(this));
63 | return mMessenger.getBinder();
64 | }
65 |
66 | @Override
67 | public void handleMessage(Message msg) {
68 | switch (msg.what) {
69 | case START_FORE:
70 | if (!isRemove) {
71 | createNotification();
72 | isRemove = true;
73 | }
74 | break;
75 | case STOP_FORE:
76 | if (isRemove) {
77 | stopForeground(true);
78 | isRemove = false;
79 | }
80 | break;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/service/ForegroundServiceActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.service;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.ServiceConnection;
7 | import android.os.Bundle;
8 | import android.os.IBinder;
9 | import android.os.Message;
10 | import android.os.Messenger;
11 | import android.os.RemoteException;
12 |
13 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
14 | import net.arvin.androidart.R;
15 |
16 | import butterknife.OnClick;
17 |
18 | /**
19 | * created by arvin on 17/2/23 23:33
20 | * email:1035407623@qq.com
21 | */
22 | public class ForegroundServiceActivity extends BaseSwipeBackActivity {
23 | private Messenger mService;
24 |
25 | private ServiceConnection conn = new ServiceConnection() {
26 | @Override
27 | public void onServiceConnected(ComponentName name, IBinder service) {
28 | mService = new Messenger(service);
29 | }
30 |
31 | @Override
32 | public void onServiceDisconnected(ComponentName name) {
33 | mService = null;
34 | }
35 | };
36 |
37 | @Override
38 | public int getContentViewId() {
39 | return R.layout.activity_notify_service;
40 | }
41 |
42 | @Override
43 | protected String getTitleText() {
44 | return "前台服务测试";
45 | }
46 |
47 | @Override
48 | protected void initViews(Bundle savedInstanceState) {
49 | bindService(new Intent(this, ForegroundService.class), conn, Context.BIND_AUTO_CREATE);
50 | }
51 |
52 | @OnClick(R.id.tv_start)
53 | public void onStartFore() {
54 | Message msg = new Message();
55 | msg.what = ForegroundService.START_FORE;
56 | try {
57 | mService.send(msg);
58 | } catch (RemoteException e) {
59 | e.printStackTrace();
60 | }
61 | }
62 |
63 | @OnClick(R.id.tv_stop)
64 | public void onStopFore() {
65 | Message msg = new Message();
66 | msg.what = ForegroundService.STOP_FORE;
67 | try {
68 | mService.send(msg);
69 | } catch (RemoteException e) {
70 | e.printStackTrace();
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/service/LifeService.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.util.Log;
7 |
8 | import net.arvin.androidart.multiProcess.aidlImpl.IntegerAddImpl;
9 |
10 | /**
11 | * created by arvin on 17/2/23 22:22
12 | * email:1035407623@qq.com
13 | */
14 | public class LifeService extends Service {
15 | final String TAG = "LifeService";
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | //第一次被创建,不管是启动还是start都会调用,但只调用一次。
21 | Log.d(TAG, "onCreate");
22 | }
23 |
24 | @Override
25 | public int onStartCommand(Intent intent, int flags, int startId) {
26 | //每次startService时都会调用
27 | Log.d(TAG, "onStartCommand");
28 | return super.onStartCommand(intent, flags, startId);
29 | }
30 |
31 | @Override
32 | public IBinder onBind(Intent intent) {
33 | //第一次被绑定时调用
34 | Log.d(TAG, "onBind");//返回null,则onServiceConnected不会回调
35 | return new IntegerAddImpl();
36 | }
37 |
38 | @Override
39 | public boolean onUnbind(Intent intent) {
40 | //最后一个解绑的时候调用
41 | Log.d(TAG, "onUnbind");
42 | return super.onUnbind(intent);
43 | }
44 |
45 | @Override
46 | public void onRebind(Intent intent) {
47 | super.onRebind(intent);
48 | Log.d(TAG, "onRebind");
49 | }
50 |
51 | @Override
52 | public void onDestroy() {
53 | super.onDestroy();
54 | Log.d(TAG, "onDestroy");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/service/ServiceActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.service;
2 |
3 | import android.os.Bundle;
4 |
5 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
6 | import net.arvin.androidart.R;
7 |
8 | import butterknife.OnClick;
9 |
10 | /**
11 | * created by arvin on 17/2/23 23:37
12 | * email:1035407623@qq.com
13 | */
14 | public class ServiceActivity extends BaseSwipeBackActivity {
15 | @Override
16 | protected String getTitleText() {
17 | return "服务相关";
18 | }
19 |
20 | @Override
21 | protected void initViews(Bundle savedInstanceState) {
22 |
23 | }
24 |
25 | @Override
26 | public int getContentViewId() {
27 | return R.layout.activity_service;
28 | }
29 |
30 | @OnClick(R.id.tv_service_life)
31 | public void onServiceLife(){
32 | startActivity(TestServiceLifeActivity.class);
33 | }
34 | @OnClick(R.id.tv_foreground_service)
35 | public void onForegroundService(){
36 | startActivity(ForegroundServiceActivity.class);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/net/arvin/androidart/service/TestServiceLifeActivity.java:
--------------------------------------------------------------------------------
1 | package net.arvin.androidart.service;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.ServiceConnection;
7 | import android.os.Bundle;
8 | import android.os.IBinder;
9 |
10 | import net.arvin.afbaselibrary.uis.activities.BaseSwipeBackActivity;
11 | import net.arvin.androidart.R;
12 | import net.arvin.androidart.multiProcess.aidlImpl.IntegerAddImpl;
13 |
14 | import butterknife.OnClick;
15 |
16 | /**
17 | * created by arvin on 17/2/23 22:55
18 | * email:1035407623@qq.com
19 | */
20 | public class TestServiceLifeActivity extends BaseSwipeBackActivity {
21 |
22 | private IntegerAddImpl mService;
23 | private ServiceConnection conn = new ServiceConnection() {
24 | @Override
25 | public void onServiceConnected(ComponentName name, IBinder service) {
26 | mService = (IntegerAddImpl) service;
27 | }
28 |
29 | @Override
30 | public void onServiceDisconnected(ComponentName name) {
31 | mService = null;//内存不足,关闭service时调用
32 | }
33 | };
34 |
35 | private boolean isStartService = false;
36 |
37 | @Override
38 | public int getContentViewId() {
39 | return R.layout.activity_test_service_life;
40 | }
41 |
42 | @Override
43 | protected String getTitleText() {
44 | return "调试Service生命周期";
45 | }
46 |
47 | @Override
48 | protected void initViews(Bundle savedInstanceState) {
49 | }
50 |
51 | @OnClick(R.id.tv_start)
52 | public void onStartService() {
53 | if (!isStartService) {
54 | isStartService = true;
55 | startService(new Intent(this, LifeService.class));
56 | }
57 | }
58 |
59 | @OnClick(R.id.tv_stop)
60 | public void onStopService() {
61 | if (isStartService) {
62 | isStartService = false;
63 | stopService(new Intent(this, LifeService.class));
64 | }
65 | }
66 |
67 |
68 | @OnClick(R.id.tv_bind)
69 | public void onBindService() {
70 | if (mService == null) {
71 | bindService(new Intent(this, LifeService.class), conn, Context.BIND_AUTO_CREATE);
72 | }
73 | }
74 |
75 | @OnClick(R.id.tv_unbind)
76 | public void onUnbindService() {
77 | if (mService != null) {
78 | unbindService(conn);
79 | mService = null;
80 | }
81 | }
82 |
83 | @OnClick(R.id.tv_open)
84 | public void onOpen() {
85 | startActivity(TestServiceLifeActivity.class);
86 | }
87 |
88 | @Override
89 | protected void onDestroy() {
90 | onUnbindService();
91 | onStopService();
92 | super.onDestroy();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 |
4 | LOCAL_MODULE := NdkTest
5 | LOCAL_SRC_FILES := NdkTest.cpp
6 |
7 | include $(BUILD_SHARED_LIBRARY)
--------------------------------------------------------------------------------
/app/src/main/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_MODULES := NdkTest
2 |
3 | APP_ABI := all
--------------------------------------------------------------------------------
/app/src/main/jni/NdkTest.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by arvin on 17/3/2.
3 | //
4 |
5 | #include "net_arvin_androidart_jni_NdkTest.h"
6 |
7 | JNIEXPORT jstring JNICALL Java_net_arvin_androidart_jni_NdkTest_getSomethingFromNDK
8 | (JNIEnv *env, jclass type) {
9 | return env->NewStringUTF("Hello,I am from JNI!");
10 | }
11 |
12 | /*
13 | * Class: net_arvin_androidart_jni_NdkTest
14 | * Method: reduce
15 | * Signature: (II)I
16 | */
17 | JNIEXPORT jint JNICALL Java_net_arvin_androidart_jni_NdkTest_reduce
18 | (JNIEnv *env, jclass type, jint params1, jint params2) {
19 | return params1 - params2;
20 | }
--------------------------------------------------------------------------------
/app/src/main/jni/net_arvin_androidart_jni_NdkTest.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class net_arvin_androidart_jni_NdkTest */
4 |
5 | #ifndef _Included_net_arvin_androidart_jni_NdkTest
6 | #define _Included_net_arvin_androidart_jni_NdkTest
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: net_arvin_androidart_jni_NdkTest
12 | * Method: getSomethingFromNDK
13 | * Signature: ()Ljava/lang/String;
14 | */
15 | JNIEXPORT jstring JNICALL Java_net_arvin_androidart_jni_NdkTest_getSomethingFromNDK
16 | (JNIEnv *, jclass);
17 |
18 | /*
19 | * Class: net_arvin_androidart_jni_NdkTest
20 | * Method: reduce
21 | * Signature: (II)I
22 | */
23 | JNIEXPORT jint JNICALL Java_net_arvin_androidart_jni_NdkTest_reduce
24 | (JNIEnv *, jclass, jint, jint);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif
30 |
--------------------------------------------------------------------------------
/app/src/main/libs/arm64-v8a/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/arm64-v8a/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/armeabi-v7a/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/armeabi-v7a/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/armeabi/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/armeabi/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/mips/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/mips/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/mips64/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/mips64/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/x86/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/x86/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/libs/x86_64/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/libs/x86_64/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/arm64-v8a/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/arm64-v8a/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/armeabi-v7a/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/armeabi-v7a/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/armeabi/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/armeabi/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/mips/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/mips/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/mips64/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/mips64/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/x86/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/x86/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/libNdkTest.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/x86_64/libNdkTest.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/NdkTest/NdkTest.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/obj/local/x86_64/objs/NdkTest/NdkTest.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/NdkTest/NdkTest.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/NdkTest/NdkTest.o: jni/NdkTest.cpp \
2 | jni/net_arvin_androidart_jni_NdkTest.h
3 |
4 | jni/net_arvin_androidart_jni_NdkTest.h:
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_back_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/drawable-xxhdpi/ic_back_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/drawable-xxhdpi/ic_right.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_big_corner_primary_solid.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_add_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
14 |
15 |
23 |
24 |
25 |
34 |
35 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
14 |
15 |
21 |
22 |
28 |
29 |
35 |
36 |
37 |
38 |
39 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_broadcast.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_github_repos.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_hanlder.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_intent.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
17 |
18 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_jni.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
15 |
16 |
21 |
22 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
60 |
61 |
62 |
63 |
67 |
68 |
69 |
70 |
74 |
75 |
76 |
77 |
81 |
82 |
83 |
84 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_name.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_notify_service.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_process.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
14 |
15 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_provider.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
20 |
30 |
31 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_service.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test_service_life.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_repos.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
26 |
27 |
37 |
38 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #f8f8f8
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidArt
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
20 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath "com.android.tools.build:gradle-experimental:0.8.3"
10 | classpath 'com.android.tools.build:gradle:2.2.3'
11 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
12 | classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | # When configured, Gradle will run in incubating parallel mode.
10 | # This option should only be used with decoupled projects. More details, visit
11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12 | # org.gradle.parallel=true
13 |
14 | android.useDeprecatedNdk=true
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arvinljw/AndroidArt/100e3c77521d5cd668c3e25f94515ef97375cea7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.14.1-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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/greendao/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/greendao/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'org.greenrobot.greendao'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 25
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | greendao {
19 | schemaVersion 1
20 | daoPackage 'net.arvin.greendao.gen'
21 | targetGenDir 'src/main/java'
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile 'com.android.support:appcompat-v7:25.1.1'
29 |
30 | //数据库
31 | compile 'org.greenrobot:greendao:3.2.0'
32 | compile 'org.greenrobot:greendao-generator:3.2.0'
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/greendao/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arvin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/greendao/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/greendao/src/main/java/net/arvin/greendao/Test.java:
--------------------------------------------------------------------------------
1 | package net.arvin.greendao;
2 |
3 | /**
4 | * created by arvin on 17/3/2 12:51
5 | * email:1035407623@qq.com
6 | */
7 | public class Test {
8 | }
9 |
--------------------------------------------------------------------------------
/greendao/src/main/java/net/arvin/greendao/entities/User.java:
--------------------------------------------------------------------------------
1 | package net.arvin.greendao.entities;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import org.greenrobot.greendao.annotation.Entity;
7 | import org.greenrobot.greendao.annotation.Id;
8 | import org.greenrobot.greendao.annotation.Generated;
9 |
10 | /**
11 | * created by arvin on 17/3/2 12:51
12 | * email:1035407623@qq.com
13 | */
14 | @Entity
15 | public class User implements Parcelable {
16 | @Id(autoincrement = true)
17 | private long id;
18 | private String name;
19 | private int age;
20 |
21 | public long getId() {
22 | return id;
23 | }
24 |
25 | public void setId(long id) {
26 | this.id = id;
27 | }
28 |
29 | public String getName() {
30 | return name;
31 | }
32 |
33 | public void setName(String name) {
34 | this.name = name;
35 | }
36 |
37 | public int getAge() {
38 | return age;
39 | }
40 |
41 | public void setAge(int age) {
42 | this.age = age;
43 | }
44 |
45 | @Override
46 | public int describeContents() {
47 | return 0;
48 | }
49 |
50 | @Override
51 | public void writeToParcel(Parcel dest, int flags) {
52 | dest.writeLong(this.id);
53 | dest.writeString(this.name);
54 | dest.writeInt(this.age);
55 | }
56 |
57 | public User() {
58 | }
59 |
60 | protected User(Parcel in) {
61 | this.id = in.readLong();
62 | this.name = in.readString();
63 | this.age = in.readInt();
64 | }
65 |
66 | @Generated(hash = 446251977)
67 | public User(long id, String name, int age) {
68 | this.id = id;
69 | this.name = name;
70 | this.age = age;
71 | }
72 |
73 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
74 | @Override
75 | public User createFromParcel(Parcel source) {
76 | return new User(source);
77 | }
78 |
79 | @Override
80 | public User[] newArray(int size) {
81 | return new User[size];
82 | }
83 | };
84 | }
85 |
--------------------------------------------------------------------------------
/greendao/src/main/java/net/arvin/greendao/gen/DaoMaster.java:
--------------------------------------------------------------------------------
1 | package net.arvin.greendao.gen;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteDatabase.CursorFactory;
6 | import android.util.Log;
7 |
8 | import org.greenrobot.greendao.AbstractDaoMaster;
9 | import org.greenrobot.greendao.database.StandardDatabase;
10 | import org.greenrobot.greendao.database.Database;
11 | import org.greenrobot.greendao.database.DatabaseOpenHelper;
12 | import org.greenrobot.greendao.identityscope.IdentityScopeType;
13 |
14 |
15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16 | /**
17 | * Master of DAO (schema version 1): knows all DAOs.
18 | */
19 | public class DaoMaster extends AbstractDaoMaster {
20 | public static final int SCHEMA_VERSION = 1;
21 |
22 | /** Creates underlying database table using DAOs. */
23 | public static void createAllTables(Database db, boolean ifNotExists) {
24 | UserDao.createTable(db, ifNotExists);
25 | }
26 |
27 | /** Drops underlying database table using DAOs. */
28 | public static void dropAllTables(Database db, boolean ifExists) {
29 | UserDao.dropTable(db, ifExists);
30 | }
31 |
32 | /**
33 | * WARNING: Drops all table on Upgrade! Use only during development.
34 | * Convenience method using a {@link DevOpenHelper}.
35 | */
36 | public static DaoSession newDevSession(Context context, String name) {
37 | Database db = new DevOpenHelper(context, name).getWritableDb();
38 | DaoMaster daoMaster = new DaoMaster(db);
39 | return daoMaster.newSession();
40 | }
41 |
42 | public DaoMaster(SQLiteDatabase db) {
43 | this(new StandardDatabase(db));
44 | }
45 |
46 | public DaoMaster(Database db) {
47 | super(db, SCHEMA_VERSION);
48 | registerDaoClass(UserDao.class);
49 | }
50 |
51 | public DaoSession newSession() {
52 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
53 | }
54 |
55 | public DaoSession newSession(IdentityScopeType type) {
56 | return new DaoSession(db, type, daoConfigMap);
57 | }
58 |
59 | /**
60 | * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
61 | */
62 | public static abstract class OpenHelper extends DatabaseOpenHelper {
63 | public OpenHelper(Context context, String name) {
64 | super(context, name, SCHEMA_VERSION);
65 | }
66 |
67 | public OpenHelper(Context context, String name, CursorFactory factory) {
68 | super(context, name, factory, SCHEMA_VERSION);
69 | }
70 |
71 | @Override
72 | public void onCreate(Database db) {
73 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
74 | createAllTables(db, false);
75 | }
76 | }
77 |
78 | /** WARNING: Drops all table on Upgrade! Use only during development. */
79 | public static class DevOpenHelper extends OpenHelper {
80 | public DevOpenHelper(Context context, String name) {
81 | super(context, name);
82 | }
83 |
84 | public DevOpenHelper(Context context, String name, CursorFactory factory) {
85 | super(context, name, factory);
86 | }
87 |
88 | @Override
89 | public void onUpgrade(Database db, int oldVersion, int newVersion) {
90 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
91 | dropAllTables(db, true);
92 | onCreate(db);
93 | }
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/greendao/src/main/java/net/arvin/greendao/gen/DaoSession.java:
--------------------------------------------------------------------------------
1 | package net.arvin.greendao.gen;
2 |
3 | import java.util.Map;
4 |
5 | import org.greenrobot.greendao.AbstractDao;
6 | import org.greenrobot.greendao.AbstractDaoSession;
7 | import org.greenrobot.greendao.database.Database;
8 | import org.greenrobot.greendao.identityscope.IdentityScopeType;
9 | import org.greenrobot.greendao.internal.DaoConfig;
10 |
11 | import net.arvin.greendao.entities.User;
12 |
13 | import net.arvin.greendao.gen.UserDao;
14 |
15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16 |
17 | /**
18 | * {@inheritDoc}
19 | *
20 | * @see org.greenrobot.greendao.AbstractDaoSession
21 | */
22 | public class DaoSession extends AbstractDaoSession {
23 |
24 | private final DaoConfig userDaoConfig;
25 |
26 | private final UserDao userDao;
27 |
28 | public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig>
29 | daoConfigMap) {
30 | super(db);
31 |
32 | userDaoConfig = daoConfigMap.get(UserDao.class).clone();
33 | userDaoConfig.initIdentityScope(type);
34 |
35 | userDao = new UserDao(userDaoConfig, this);
36 |
37 | registerDao(User.class, userDao);
38 | }
39 |
40 | public void clear() {
41 | userDaoConfig.clearIdentityScope();
42 | }
43 |
44 | public UserDao getUserDao() {
45 | return userDao;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/greendao/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Greendao
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':afbaselibrary', ':aidlclient', ':greendao'
2 |
--------------------------------------------------------------------------------