├── .gitignore
├── ApiClient.iml
├── LICENSE
├── README.md
├── apiclient-accountmanager
├── .gitignore
├── apiclient-accountmanager.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── fabianterhorst
│ └── apiclient
│ └── accountmanager
│ ├── ApiAuthenticator.java
│ ├── ApiAuthenticatorActivity.java
│ └── ApiAuthenticatorService.java
├── apiclient-components
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── fabianterhorst
│ └── apiclient
│ └── components
│ ├── RxActivity.java
│ └── RxFragment.java
├── apiclient
├── .gitignore
├── apiclient.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── fabianterhorst
│ └── apiclient
│ ├── ApiClient.java
│ ├── ApiObserver.java
│ ├── ApiStorage.java
│ ├── IApi.java
│ ├── IApiObserver.java
│ ├── IApiStorage.java
│ └── Utils
│ ├── AuthUtils.java
│ ├── GsonUtils.java
│ ├── RemoveNullListSerializer.java
│ └── StringUtils.java
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── io
│ │ └── fabianterhorst
│ │ └── apiclient
│ │ └── app
│ │ ├── Github.java
│ │ ├── GithubApi.java
│ │ ├── MainActivity.java
│ │ ├── MyApplication.java
│ │ ├── RepositoriesAdapter.java
│ │ └── Repository.java
│ └── res
│ ├── layout
│ ├── activity_main.xml
│ └── item_repository.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-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── publish.gradle
├── publishaccountmanager.gradle
├── publishcomponents.gradle
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | *.idea
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | *.iml
37 |
--------------------------------------------------------------------------------
/ApiClient.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2015 Aleksey Masny
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ApiClient
2 | A easy to use api client that combines the power of Retrofit, Realm, Gson, Rxjava and Retrolambda in a library for Java and Android
3 |
4 | ##### Add to build.gradle
5 |
6 | ```groovy
7 | compile 'io.fabianterhorst:apiclient:0.4'
8 | compile 'io.fabianterhorst:apiclient-accountmanager:0.1'
9 | compile 'io.fabianterhorst:apiclient-components:0.1'
10 | ```
11 |
12 | #### First Step
13 |
14 | Create your Api Class
15 |
16 | ```java
17 | public class Twitter extends ApiClient implements TwitterApi {
18 |
19 | public Twitter(Realm realm, String apiKey) {
20 | super(realm, TwitterApi.PARAM_API_KEY, apiKey, TwitterApi.class, TwitterApi.END_POINT);
21 | }
22 |
23 | public static void init(String apiKey) {
24 | init(new Twitter(apiKey));
25 | }
26 |
27 | @Override
28 | public Observable> getTweets() {
29 | //Here you can define the tablename for realm and the fieldname if needed to sort the tweets with
30 | return getApiObservable(getApi().getTweets(), Tweet.class, "name");
31 | }
32 |
33 | @Override
34 | public Observable> getComments(ArrayList ids) {
35 | //You can also get results only for specific ids
36 | return getApiObservable(getApi().getComments(), Comment.class, "id", ids);
37 | }
38 | }
39 | ```
40 |
41 | #### Second Step
42 |
43 | Create your Api Interface (The Retrofit way)
44 |
45 | ```java
46 | public interface TwitterApi {
47 |
48 | @GET("tweets")
49 | Observable> getTweets();
50 |
51 | @GET("comments")
52 | Observable> getComments(@Query("id") ArrayList ids);
53 | }
54 | ```
55 |
56 | #### Third Step
57 |
58 | Initiate the Singleton in the Application onCreate
59 |
60 | ```java
61 | public class MyApplication extends Application {
62 |
63 | @Override
64 | public void onCreate() {
65 | super.onCreate();
66 | RealmConfiguration config = new RealmConfiguration.Builder(this)
67 | .deleteRealmIfMigrationNeeded()
68 | .build();
69 | Realm.setDefaultConfiguration(config);
70 | Twitter.init("0123456789");
71 | }
72 | }
73 | ```
74 |
75 | #### Fourth Step
76 |
77 | Use it and have fun. The library is handling the saving, the loading and the refreshing for you.
78 |
79 | ```java
80 | Twitter twitter = Twitter.getInstance();
81 |
82 | twitter.getTweets().subscribe(tweets-> System.out.println(tweets));
83 | ```
84 |
85 | ### FAQ
86 |
87 | ##### How to handle Android Activity lifecycle
88 |
89 | You can use the ApiClient component module to get access to RxActivity and RxFragment
90 |
91 | In your Activity you have to get the Singleton with the Activity lifecycle. Your activity has to extend RxActivity.
92 |
93 | ```java
94 | Twitter twitter = Twitter.getInstance(bindToLifecycle());
95 | ```
96 |
97 | And thats everythink you have to do to prevent memory leaks.
98 |
99 | ##### RealmList doesn´t support null objects. How can i ignore null object inside the response json?
100 |
101 | You can override the gson builder inside your api class and add custom deserializer adapters to avoid adding null objects.
102 |
103 | ```java
104 | @Override
105 | public GsonBuilder getGsonBuilder(GsonBuilder gsonBuilder) {
106 | GsonUtils.registerRemoveNullListSerializer(gsonBuilder, new TypeToken>() {}, MyFirstObject.class);
107 | GsonUtils.registerRemoveNullListSerializer(gsonBuilder, new TypeToken>() {}, MySecondObject.class);
108 | GsonUtils.registerRemoveNullListSerializer(gsonBuilder, new TypeToken>() {}, MyThirdObject.class);
109 | return gsonBuilder;
110 | }
111 | ```
112 |
113 | ##### How to change the api key from everywhere?
114 |
115 | You can use the ```setApiKey``` method.
116 |
117 | ```java
118 | Twitter.getInstance().setApiKey("9876543210");
119 | ```
120 |
121 | ##### How to add other query parameters?
122 |
123 | You can override the ```getHttpUrlBuilder(HttpUrl.Builder builder)``` method from the api client.
124 |
125 | ```java
126 | @Override
127 | public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
128 | return addQueryParameter("lang", Locale.getDefault().getLanguage());
129 | }
130 | ```
131 |
132 | ##### How to use a authentication
133 |
134 | The easiest way is to use the AuthUtils to add a authentication via the request builder for post parameters and headers or the http url builder for query parameter
135 |
136 | myurl.com/api
137 | ```java
138 | @Override
139 | public Request.Builder getRequestBuilder(Request.Builder builder) {
140 | return AuthUtils.addDefaultAuthentication(builder, getApiKey());
141 | }
142 | ```
143 |
144 | myurl.com/api?apiKey=012345
145 | ```java
146 | @Override
147 | public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
148 | AuthUtils.addDefaultAuthentication(builder, "apiKey", getApiKey());
149 | return builder.addQueryParameter("lang", Locale.getDefault().getLanguage());
150 | }
151 | ```
152 |
153 | ### License
154 | Copyright 2016 Fabian Terhorst
155 |
156 | Licensed under the Apache License, Version 2.0 (the "License");
157 | you may not use this file except in compliance with the License.
158 | You may obtain a copy of the License at
159 |
160 | http://www.apache.org/licenses/LICENSE-2.0
161 |
162 | Unless required by applicable law or agreed to in writing, software
163 | distributed under the License is distributed on an "AS IS" BASIS,
164 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
165 | See the License for the specific language governing permissions and
166 | limitations under the License.
167 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/apiclient-accountmanager.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
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 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 24
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 'com.android.support:appcompat-v7:24.1.1'
23 | }
24 |
25 |
26 | apply from: '../publishaccountmanager.gradle'
--------------------------------------------------------------------------------
/apiclient-accountmanager/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/fabianterhorst/Desktop/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 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/src/main/java/io/fabianterhorst/apiclient/accountmanager/ApiAuthenticator.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.accountmanager;
2 |
3 | import android.accounts.AbstractAccountAuthenticator;
4 | import android.accounts.Account;
5 | import android.accounts.AccountAuthenticatorResponse;
6 | import android.accounts.AccountManager;
7 | import android.accounts.NetworkErrorException;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.os.Bundle;
11 | import android.text.TextUtils;
12 |
13 | import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
14 |
15 | public class ApiAuthenticator extends AbstractAccountAuthenticator {
16 |
17 | private Context mContext;
18 | private Class mAuthActivityClass;
19 |
20 | public ApiAuthenticator(Context context, Class authActivityClass){
21 | super(context);
22 | this.mContext = context;
23 | this.mAuthActivityClass = authActivityClass;
24 | }
25 |
26 | @Override
27 | public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
28 | return null;
29 | }
30 |
31 | @Override
32 | public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
33 | final Intent intent = new Intent(mContext, mAuthActivityClass);
34 | intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
35 | intent.putExtra(AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, authTokenType);
36 | intent.putExtra(AccountManager.ACTION_AUTHENTICATOR_INTENT, true);
37 | intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
38 |
39 | final Bundle bundle = new Bundle();
40 | bundle.putParcelable(AccountManager.KEY_INTENT, intent);
41 | return bundle;
42 | }
43 |
44 | @Override
45 | public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException {
46 | return null;
47 | }
48 |
49 | @Override
50 | public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
51 | final AccountManager am = AccountManager.get(mContext);
52 | String authToken = am.peekAuthToken(account, authTokenType);
53 |
54 | // If we get an authToken - we return it
55 | if (!TextUtils.isEmpty(authToken)) {
56 | final Bundle result = new Bundle();
57 | result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
58 | result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
59 | result.putString(AccountManager.KEY_AUTHTOKEN, account.name);
60 | return result;
61 | }
62 |
63 | // If we get here, then we couldn't access the user's password - so we
64 | // need to re-prompt them for their credentials. We do that by creating
65 | // an intent to display our AuthenticatorActivity.
66 | final Intent intent = new Intent(mContext, mAuthActivityClass);
67 | intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
68 | intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);
69 | intent.putExtra(AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, authTokenType);
70 | intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);
71 | final Bundle bundle = new Bundle();
72 | bundle.putParcelable(AccountManager.KEY_INTENT, intent);
73 | return bundle;
74 | }
75 |
76 | @Override
77 | public String getAuthTokenLabel(String authTokenType) {
78 | return authTokenType + " (Label)";
79 | }
80 |
81 | @Override
82 | public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
83 | return null;
84 | }
85 |
86 | @Override
87 | public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException {
88 | final Bundle result = new Bundle();
89 | result.putBoolean(KEY_BOOLEAN_RESULT, false);
90 | return result;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/src/main/java/io/fabianterhorst/apiclient/accountmanager/ApiAuthenticatorActivity.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.accountmanager;
2 |
3 | import android.accounts.Account;
4 | import android.accounts.AccountAuthenticatorResponse;
5 | import android.accounts.AccountManager;
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.support.v7.app.AppCompatActivity;
9 |
10 | public class ApiAuthenticatorActivity extends AppCompatActivity {
11 |
12 | private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
13 | private Bundle mResultBundle = null;
14 | private String mAccountType, mAccountName, mAuthToken, mAccountPassword, mAuthTokenType;
15 | private AccountManager mAccountManager;
16 |
17 | /**
18 | * Retrieves the AccountAuthenticatorResponse from either the intent of the savedInstanceState, if the
19 | * savedInstanceState is non-zero.
20 | * @param savedInstanceState the save instance data of this Activity, may be null
21 | */
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | mAccountAuthenticatorResponse =
26 | getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
27 |
28 | if (mAccountAuthenticatorResponse != null) {
29 | mAccountAuthenticatorResponse.onRequestContinued();
30 | }
31 |
32 | mAccountManager = AccountManager.get(getBaseContext());
33 | mAccountType = getIntent().getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
34 | mAccountName = getIntent().getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
35 | mAuthTokenType = getIntent().getStringExtra(AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME);
36 | }
37 |
38 | public void login(){
39 | Bundle data = new Bundle();
40 | data.putString(AccountManager.KEY_ACCOUNT_NAME, mAccountName);
41 | data.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccountType);
42 | data.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
43 | data.putString(AccountManager.KEY_PASSWORD, mAccountPassword);
44 | Intent res = new Intent();
45 | res.putExtras(data);
46 | finishLogin(res);
47 | }
48 |
49 | private void finishLogin(Intent intent) {
50 |
51 | String accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
52 | String accountPassword = intent.getStringExtra(AccountManager.KEY_PASSWORD);
53 | Account account = new Account(accountName, intent.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE));
54 |
55 | if (getIntent().getBooleanExtra(AccountManager.ACTION_AUTHENTICATOR_INTENT, false)) {
56 | String authToken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN);
57 | mAccountManager.addAccountExplicitly(account, accountPassword, null);
58 | mAccountManager.setAuthToken(account, mAuthTokenType, authToken);
59 | } else {
60 | mAccountManager.setPassword(account, accountPassword);
61 | }
62 |
63 | setAccountAuthenticatorResult(intent.getExtras());
64 | setResult(RESULT_OK, intent);
65 | finish();
66 | }
67 |
68 | /**
69 | * Set the result that is to be sent as the result of the request that caused this
70 | * Activity to be launched. If result is null or this method is never called then
71 | * the request will be canceled.
72 | * @param result this is returned as the result of the AbstractAccountAuthenticator request
73 | */
74 | public final void setAccountAuthenticatorResult(Bundle result) {
75 | mResultBundle = result;
76 | }
77 |
78 | /**
79 | * Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
80 | */
81 | public void finish() {
82 | if (mAccountAuthenticatorResponse != null) {
83 | // send the result bundle back if set, otherwise send an error.
84 | if (mResultBundle != null) {
85 | mAccountAuthenticatorResponse.onResult(mResultBundle);
86 | } else {
87 | mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
88 | "canceled");
89 | }
90 | mAccountAuthenticatorResponse = null;
91 | }
92 | super.finish();
93 | }
94 |
95 | public void setAccountPassword(String accountPassword) {
96 | this.mAccountPassword = accountPassword;
97 | }
98 |
99 | public boolean addNewAccount(){
100 | return getIntent().getBooleanExtra(AccountManager.ACTION_AUTHENTICATOR_INTENT, false);
101 | }
102 |
103 | public void setAuthToken(String authToken) {
104 | this.mAuthToken = authToken;
105 | }
106 |
107 | public void setAccountName(String accountName) {
108 | this.mAccountName = accountName;
109 | }
110 |
111 | public void setAccountType(String accountType) {
112 | this.mAccountType = accountType;
113 | }
114 |
115 | public void setAuthTokenType(String mAuthTokenType) {
116 | this.mAuthTokenType = mAuthTokenType;
117 | }
118 |
119 | public String getAccountType() {
120 | return mAccountType;
121 | }
122 |
123 | public String getAuthToken() {
124 | return mAuthToken;
125 | }
126 |
127 | public String getAccountPassword() {
128 | return mAccountPassword;
129 | }
130 |
131 | public Class getTarget(){
132 | return null;
133 | }
134 |
135 | public AccountManager getAccountManager() {
136 | return mAccountManager;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/apiclient-accountmanager/src/main/java/io/fabianterhorst/apiclient/accountmanager/ApiAuthenticatorService.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.accountmanager;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 |
7 | public class ApiAuthenticatorService extends Service {
8 |
9 | @Override
10 | public IBinder onBind(Intent intent) {
11 | ApiAuthenticator authenticator = new ApiAuthenticator(this, getAuthActivityClass());
12 | return authenticator.getIBinder();
13 | }
14 |
15 | public Class getAuthActivityClass(){
16 | return null;
17 | }
18 | }
--------------------------------------------------------------------------------
/apiclient-components/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
--------------------------------------------------------------------------------
/apiclient-components/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 24
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 'com.android.support:appcompat-v7:24.1.1'
23 | compile 'com.trello:rxlifecycle:0.5.0'
24 | compile 'io.reactivex:rxjava:1.1.8'
25 | compile 'io.reactivex:rxandroid:1.2.0'
26 | }
27 |
28 | apply from: '../publishcomponents.gradle'
--------------------------------------------------------------------------------
/apiclient-components/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/fabianterhorst/Desktop/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 |
--------------------------------------------------------------------------------
/apiclient-components/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/apiclient-components/src/main/java/io/fabianterhorst/apiclient/components/RxActivity.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.components;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.CallSuper;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | import com.trello.rxlifecycle.ActivityEvent;
8 | import com.trello.rxlifecycle.ActivityLifecycleProvider;
9 | import com.trello.rxlifecycle.RxLifecycle;
10 |
11 | import rx.Observable;
12 | import rx.subjects.BehaviorSubject;
13 |
14 | public class RxActivity extends AppCompatActivity implements ActivityLifecycleProvider {
15 |
16 | private final BehaviorSubject lifecycleSubject = BehaviorSubject.create();
17 |
18 | @Override
19 | public final Observable lifecycle() {
20 | return lifecycleSubject.asObservable();
21 | }
22 |
23 | @Override
24 | public final Observable.Transformer bindUntilEvent(ActivityEvent event) {
25 | return RxLifecycle.bindUntilActivityEvent(lifecycleSubject, event);
26 | }
27 |
28 | @Override
29 | public final Observable.Transformer bindToLifecycle() {
30 | return RxLifecycle.bindActivity(lifecycleSubject);
31 | }
32 |
33 | @Override
34 | @CallSuper
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | lifecycleSubject.onNext(ActivityEvent.CREATE);
38 | }
39 |
40 | @Override
41 | @CallSuper
42 | protected void onStart() {
43 | super.onStart();
44 | lifecycleSubject.onNext(ActivityEvent.START);
45 | }
46 |
47 | @Override
48 | @CallSuper
49 | protected void onResume() {
50 | super.onResume();
51 | lifecycleSubject.onNext(ActivityEvent.RESUME);
52 | }
53 |
54 | @Override
55 | @CallSuper
56 | protected void onPause() {
57 | lifecycleSubject.onNext(ActivityEvent.PAUSE);
58 | super.onPause();
59 | }
60 |
61 | @Override
62 | @CallSuper
63 | protected void onStop() {
64 | lifecycleSubject.onNext(ActivityEvent.STOP);
65 | super.onStop();
66 | }
67 |
68 | @Override
69 | @CallSuper
70 | protected void onDestroy() {
71 | lifecycleSubject.onNext(ActivityEvent.DESTROY);
72 | super.onDestroy();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/apiclient-components/src/main/java/io/fabianterhorst/apiclient/components/RxFragment.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.components;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.CallSuper;
6 | import android.support.v4.app.Fragment;
7 | import android.view.View;
8 |
9 | import com.trello.rxlifecycle.FragmentEvent;
10 | import com.trello.rxlifecycle.FragmentLifecycleProvider;
11 | import com.trello.rxlifecycle.RxLifecycle;
12 |
13 | import rx.Observable;
14 | import rx.subjects.BehaviorSubject;
15 |
16 | public class RxFragment extends Fragment implements FragmentLifecycleProvider {
17 |
18 | private final BehaviorSubject lifecycleSubject = BehaviorSubject.create();
19 |
20 | @Override
21 | public final Observable lifecycle() {
22 | return lifecycleSubject.asObservable();
23 | }
24 |
25 | @Override
26 | public final Observable.Transformer bindUntilEvent(FragmentEvent event) {
27 | return RxLifecycle.bindUntilFragmentEvent(lifecycleSubject, event);
28 | }
29 |
30 | @Override
31 | public final Observable.Transformer bindToLifecycle() {
32 | return RxLifecycle.bindFragment(lifecycleSubject);
33 | }
34 |
35 | @Override
36 | @CallSuper
37 | public void onAttach(Context context) {
38 | super.onAttach(context);
39 | lifecycleSubject.onNext(FragmentEvent.ATTACH);
40 | }
41 |
42 | @Override
43 | @CallSuper
44 | public void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | lifecycleSubject.onNext(FragmentEvent.CREATE);
47 | }
48 |
49 | @Override
50 | @CallSuper
51 | public void onViewCreated(View view, Bundle savedInstanceState) {
52 | super.onViewCreated(view, savedInstanceState);
53 | lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
54 | }
55 |
56 | @Override
57 | @CallSuper
58 | public void onStart() {
59 | super.onStart();
60 | lifecycleSubject.onNext(FragmentEvent.START);
61 | }
62 |
63 | @Override
64 | @CallSuper
65 | public void onResume() {
66 | super.onResume();
67 | lifecycleSubject.onNext(FragmentEvent.RESUME);
68 | }
69 |
70 | @Override
71 | @CallSuper
72 | public void onPause() {
73 | lifecycleSubject.onNext(FragmentEvent.PAUSE);
74 | super.onPause();
75 | }
76 |
77 | @Override
78 | @CallSuper
79 | public void onStop() {
80 | lifecycleSubject.onNext(FragmentEvent.STOP);
81 | super.onStop();
82 | }
83 |
84 | @Override
85 | @CallSuper
86 | public void onDestroyView() {
87 | lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);
88 | super.onDestroyView();
89 | }
90 |
91 | @Override
92 | @CallSuper
93 | public void onDestroy() {
94 | lifecycleSubject.onNext(FragmentEvent.DESTROY);
95 | super.onDestroy();
96 | }
97 |
98 | @Override
99 | @CallSuper
100 | public void onDetach() {
101 | lifecycleSubject.onNext(FragmentEvent.DETACH);
102 | super.onDetach();
103 | }
104 | }
--------------------------------------------------------------------------------
/apiclient/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
--------------------------------------------------------------------------------
/apiclient/apiclient.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
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 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/apiclient/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'realm-android'
3 | apply plugin: 'me.tatarka.retrolambda'
4 |
5 | android {
6 | compileSdkVersion 24
7 | buildToolsVersion "24.0.1"
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 24
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | compileOptions {
23 | sourceCompatibility JavaVersion.VERSION_1_8
24 | targetCompatibility JavaVersion.VERSION_1_8
25 | }
26 | }
27 |
28 | dependencies {
29 | retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0'
30 | compile 'com.squareup.retrofit2:retrofit:2.0.2'
31 | compile 'com.squareup.retrofit2:converter-gson:2.0.2'
32 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
33 |
34 | compile 'com.squareup.okhttp3:okhttp:3.4.1'
35 |
36 | compile 'io.reactivex:rxjava:1.1.8'
37 | compile 'io.reactivex:rxjava-async-util:0.21.0'
38 | compile 'io.reactivex:rxandroid:1.2.0'
39 | }
40 |
41 | apply from: '../publish.gradle'
42 |
--------------------------------------------------------------------------------
/apiclient/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/fabianterhorst/Desktop/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 |
--------------------------------------------------------------------------------
/apiclient/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/ApiClient.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import com.google.gson.ExclusionStrategy;
4 | import com.google.gson.FieldAttributes;
5 | import com.google.gson.GsonBuilder;
6 |
7 | import io.realm.Realm;
8 | import io.realm.RealmObject;
9 | import okhttp3.HttpUrl;
10 | import okhttp3.Interceptor;
11 | import okhttp3.OkHttpClient;
12 | import okhttp3.Request;
13 | import retrofit2.Retrofit;
14 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
15 | import retrofit2.converter.gson.GsonConverterFactory;
16 | import rx.Observable;
17 |
18 | public class ApiClient extends ApiObserver implements IApi {
19 |
20 | private Api mApi;
21 |
22 | private final Class mClazz;
23 |
24 | private String mApiKey;
25 |
26 | private final String mApiBaseUrl;
27 |
28 | private static ApiClient mInstance;
29 |
30 | private final Interceptor API_KEY_INTERCEPTOR = chain -> {
31 | Request oldRequest = chain.request();
32 | HttpUrl httpUrl = getHttpUrlBuilder(oldRequest.url().newBuilder()).build();
33 | Request.Builder builder = getRequestBuilder(oldRequest.newBuilder());
34 | builder.url(httpUrl);
35 | return chain.proceed(builder.build());
36 | };
37 |
38 | public ApiClient(Class clazz, String apiBaseUrl) {
39 | this.mClazz = clazz;
40 | this.mApiBaseUrl = apiBaseUrl;
41 | }
42 |
43 | public ApiClient(String apiKey, Class clazz, String apiBaseUrl) {
44 | this.mApiKey = apiKey;
45 | this.mClazz = clazz;
46 | this.mApiBaseUrl = apiBaseUrl;
47 | }
48 |
49 | public ApiClient(Realm realm, String apiKey, Class clazz, String apiBaseUrl) {
50 | super(realm);
51 | this.mApiKey = apiKey;
52 | this.mClazz = clazz;
53 | this.mApiBaseUrl = apiBaseUrl;
54 | }
55 |
56 | /**
57 | * Set the api key for the default interceptor
58 | * This api key will set as a query parameter value with the parameter key you have specify by initialising the ApiClient to the url
59 | *
60 | * @param apiKey to set as a url parameter
61 | */
62 | @Override
63 | public void setApiKey(String apiKey) {
64 | this.mApiKey = apiKey;
65 | }
66 |
67 | /**
68 | * Get the api key
69 | */
70 | public String getApiKey(){
71 | return mApiKey;
72 | }
73 |
74 | /**
75 | * Getting the UrlBuilder for the OkHttp interceptor
76 | * Here you can add your own implementation to authenticate your application
77 | *
78 | * @param builder http url builder
79 | * @return the modified http url builder for the interceptor
80 | */
81 | @Override
82 | public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
83 | return builder;
84 | }
85 |
86 | /**
87 | * Getting the RequestBuilder for the OkHttp interceptor
88 | * Here you can add your own implementation to authenticate your application
89 | *
90 | * @param builder http request builder
91 | * @return the modified http request builder for the interceptor
92 | */
93 | @Override
94 | public Request.Builder getRequestBuilder(Request.Builder builder) {
95 | return builder;
96 | }
97 |
98 | /**
99 | * Get the current api instance. You have to call init() before
100 | *
101 | * @return the current api instance
102 | */
103 | @SuppressWarnings("unchecked")
104 | public static E getInstance() {
105 | mInstance.setLifecycle(null);
106 | return (E) mInstance;
107 | }
108 |
109 | /**
110 | *
111 | * Get the current api instance with the given lifecycle. You have to call init() before
112 | *
113 | * @param lifecycle lifecycle from the activity or the fragment
114 | * @param api client type
115 | * @return the current api instance
116 | */
117 | @SuppressWarnings("unchecked")
118 | public static E getInstance(Observable.Transformer, ?> lifecycle) {
119 | mInstance.setLifecycle(lifecycle);
120 | return (E) mInstance;
121 | }
122 |
123 | /**
124 | * Lightweight method to init the api instance. Should be called in Application#onCreate()
125 | * Can be modified in the api class to prevent the application to initiate the api class itself
126 | *
127 | * @param apiClient api client
128 | */
129 | public static void init(ApiClient apiClient) {
130 | mInstance = apiClient;
131 | }
132 |
133 | @Override
134 | public GsonBuilder getGsonBuilder(GsonBuilder gsonBuilder) {
135 | return gsonBuilder;
136 | }
137 |
138 | /**
139 | * Get the api singleton from the api interface
140 | *
141 | * @return api
142 | */
143 | @Override
144 | public Api getApi() {
145 | if (mApi == null) {
146 | mApi = new Retrofit.Builder()
147 | .client(new OkHttpClient.Builder()
148 | .addInterceptor(API_KEY_INTERCEPTOR)
149 | .build())
150 | .baseUrl(mApiBaseUrl)
151 | .addConverterFactory(GsonConverterFactory.create(getGsonBuilder(new GsonBuilder())
152 | .setExclusionStrategies(new ExclusionStrategy() {
153 | @Override
154 | public boolean shouldSkipField(FieldAttributes f) {
155 | return f.getDeclaringClass().equals(RealmObject.class);
156 | }
157 |
158 | @Override
159 | public boolean shouldSkipClass(Class> clazz) {
160 | return false;
161 | }
162 | })
163 | .create()))
164 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
165 | .build()
166 | .create(mClazz);
167 | }
168 | return mApi;
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/ApiObserver.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import java.util.List;
4 |
5 | import io.realm.Realm;
6 | import io.realm.RealmObject;
7 | import io.realm.RealmResults;
8 | import rx.Observable;
9 | import rx.android.schedulers.AndroidSchedulers;
10 | import rx.schedulers.Schedulers;
11 |
12 | public class ApiObserver extends ApiStorage implements IApiObserver {
13 |
14 | private Observable.Transformer mLifecycle;
15 |
16 | public ApiObserver() {
17 | }
18 |
19 | public ApiObserver(Realm realm) {
20 | super(realm);
21 | }
22 |
23 | protected void setLifecycle(Observable.Transformer mLifecycle) {
24 | this.mLifecycle = mLifecycle;
25 | }
26 |
27 | protected Observable.Transformer getLifecycle() {
28 | return mLifecycle != null ? mLifecycle : o -> o;
29 | }
30 |
31 | @Override
32 | public - Observable
> getApiObservable(Observable> api, Class- realmClass, String sortedField, List ids) {
33 | if (getStorage() != null) {
34 | RealmResults
- realmResults;
35 | if (sortedField != null)
36 | realmResults = (ids == null) ? getItems(realmClass, sortedField) : getItems(realmClass, sortedField, ids);
37 | else
38 | realmResults = getItems(realmClass);
39 | Observable
> realmObserver = realmResults.asObservable()
40 | .filter(RealmResults::isLoaded)
41 | .compose(getLifecycle())
42 | .switchMap(Observable::just);
43 | Observable> retrofitObserver = api
44 | .compose(applySchedulers())
45 | .compose(getLifecycle());
46 | return Observable.>create(subscriber -> {
47 | realmObserver.take(2).subscribe(subscriber::onNext, subscriber::onError, subscriber::onCompleted);
48 | retrofitObserver.subscribe(this::setItems, subscriber::onError);
49 | }).compose(getLifecycle());
50 | } else
51 | return api;
52 | }
53 |
54 | @Override
55 | public - Observable
> getApiObservable(Observable> api, Class- realmClass) {
56 | return getApiObservable(api, realmClass, null);
57 | }
58 |
59 | @Override
60 | public
- Observable
> getApiObservable(Observable> api, Class- realmClass, String sortedField) {
61 | return getApiObservable(api, realmClass, sortedField, null);
62 | }
63 |
64 | /**
65 | * Apply the default android schedulers to a observable
66 | *
67 | * @param the current observable
68 | * @return the transformed observable
69 | */
70 | protected Observable.Transformer applySchedulers() {
71 | return observable -> observable.subscribeOn(Schedulers.io())
72 | .observeOn(AndroidSchedulers.mainThread())
73 | .unsubscribeOn(Schedulers.io());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/ApiStorage.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import java.util.List;
4 |
5 | import io.realm.Realm;
6 | import io.realm.RealmObject;
7 | import io.realm.RealmQuery;
8 | import io.realm.RealmResults;
9 |
10 | public class ApiStorage implements IApiStorage {
11 |
12 | private Realm mRealm;
13 |
14 | public ApiStorage(){
15 | this.mRealm = Realm.getDefaultInstance();
16 | }
17 |
18 | public ApiStorage(Realm realm){
19 | this.mRealm = realm;
20 | }
21 |
22 | @Override
23 | public Realm getStorage() {
24 | return mRealm;
25 | }
26 |
27 | @Override
28 | public
- RealmQuery
- getQuery(Class
- objectClass) {
29 | return mRealm.where(objectClass);
30 | }
31 |
32 | @Override
33 | public
- RealmResults
- getItems(Class
- objectClass) {
34 | return getQuery(objectClass).findAllAsync();
35 | }
36 |
37 | @Override
38 | public
- RealmResults
- getItems(Class
- objectClass, String sortedFieldName) {
39 | return getQuery(objectClass).findAllSortedAsync(sortedFieldName);
40 | }
41 |
42 | @Override
43 | public
- RealmResults
- getItems(Class
- objectClass, String sortedFieldName, List ids) {
44 | RealmQuery
- query = getQuery(objectClass);
45 | for (int i = 0; i < ids.size() - 1; i++) {
46 | query = query.equalTo(sortedFieldName, ids.get(i)).or();
47 | }
48 | query = query.equalTo(sortedFieldName, ids.get(ids.size() - 1));
49 |
50 | return query.findAllSortedAsync(sortedFieldName);
51 | }
52 |
53 | @Override
54 | public
- void setItems(List
- items) {
55 | mRealm.executeTransactionAsync(realm -> realm.copyToRealmOrUpdate(items));
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/IApi.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import com.google.gson.GsonBuilder;
4 |
5 | import okhttp3.HttpUrl;
6 | import okhttp3.Request;
7 |
8 | public interface IApi {
9 | GsonBuilder getGsonBuilder(GsonBuilder gsonBuilder);
10 | Api getApi();
11 | void setApiKey(String mApiKey);
12 | HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder);
13 | Request.Builder getRequestBuilder(Request.Builder builder);
14 | }
15 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/IApiObserver.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import java.util.List;
4 |
5 | import io.realm.RealmObject;
6 | import rx.Observable;
7 |
8 | public interface IApiObserver {
9 |
- Observable
> getApiObservable(Observable> api, Class- realmClass, String sortedField, List ids);
10 |
- Observable
> getApiObservable(Observable> api, Class- realmClass, String sortedField);
11 |
- Observable
> getApiObservable(Observable> api, Class- realmClass);
12 | }
13 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/IApiStorage.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient;
2 |
3 | import java.util.List;
4 |
5 | import io.realm.Realm;
6 | import io.realm.RealmObject;
7 | import io.realm.RealmQuery;
8 | import io.realm.RealmResults;
9 |
10 | public interface IApiStorage {
11 | Realm getStorage();
12 |
- RealmQuery
- getQuery(Class
- objectClass);
13 |
- RealmResults
- getItems(Class
- objectClass);
14 |
- RealmResults
- getItems(Class
- objectClass, String sortedFieldName);
15 |
- RealmResults
- getItems(Class
- objectClass, String sortedFieldName, List allowedIds);
16 |
- void setItems(List
- items);
17 | }
18 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/Utils/AuthUtils.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.Utils;
2 |
3 | import okhttp3.HttpUrl;
4 | import okhttp3.Request;
5 |
6 | public class AuthUtils {
7 |
8 | public static String DEFAULT_AUTH_HEADER = "Authorization";
9 | public static String DEFAULT_AUTH_HEADER_PREFIX = "Bearer ";
10 |
11 | public static HttpUrl.Builder addDefaultAuthentication(HttpUrl.Builder builder, String apiKeyParameter, String apiKey) {
12 | return builder.addQueryParameter(apiKeyParameter, apiKey);
13 | }
14 |
15 | public static Request.Builder addDefaultAuthentication(Request.Builder builder, String apiKey) {
16 | return builder.addHeader(DEFAULT_AUTH_HEADER, DEFAULT_AUTH_HEADER_PREFIX + apiKey);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/Utils/GsonUtils.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.Utils;
2 |
3 | import com.google.gson.GsonBuilder;
4 | import com.google.gson.reflect.TypeToken;
5 |
6 | import io.realm.RealmList;
7 | import io.realm.RealmObject;
8 |
9 | public class GsonUtils {
10 |
11 | /**
12 | * Add NullListSerializer to the Gson Builder
13 | * This allow the use of RealmList with Null Values from Json in Objects
14 | *
15 | * @param gsonBuilder gson builder
16 | * @param typeToken type token
17 | * @param item item for the serializer
18 | * @param
- generic type from item
19 | */
20 | public static
- void registerRemoveNullListSerializer(GsonBuilder gsonBuilder, TypeToken> typeToken, Class
- item) {
21 | gsonBuilder.registerTypeAdapter(typeToken.getType(), new RemoveNullListSerializer<>(item));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/Utils/RemoveNullListSerializer.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.Utils;
2 |
3 | import com.google.gson.JsonArray;
4 | import com.google.gson.JsonDeserializationContext;
5 | import com.google.gson.JsonDeserializer;
6 | import com.google.gson.JsonElement;
7 | import com.google.gson.JsonNull;
8 | import com.google.gson.JsonParseException;
9 |
10 | import java.lang.reflect.Type;
11 | import java.util.Iterator;
12 |
13 | import io.realm.RealmList;
14 | import io.realm.RealmObject;
15 |
16 | public class RemoveNullListSerializer
- implements JsonDeserializer> {
17 |
18 | private Class
- clazz;
19 |
20 | public RemoveNullListSerializer(Class
- clazz){
21 | this.clazz = clazz;
22 | }
23 |
24 | @Override
25 | public RealmList
- deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
26 | JsonArray array = json.getAsJsonArray();
27 | Iterator i = array.iterator();
28 | while (i.hasNext()) {
29 | JsonElement je = i.next();
30 | if (je instanceof JsonNull)
31 | i.remove();
32 | }
33 | RealmList
- list = new RealmList<>();
34 | for (JsonElement je : array) {
35 | list.add(context.deserialize(je, clazz));
36 | }
37 | return list;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/apiclient/src/main/java/io/fabianterhorst/apiclient/Utils/StringUtils.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.Utils;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.List;
6 |
7 | public class StringUtils {
8 |
9 | /**
10 | * Creating a string from a list
11 | * For example new List(){1,2,3} will output "1,2,3"
12 | * Is sometimes needed for a url query parameter
13 | *
14 | * @param list List
15 | * @return string
16 | */
17 | public static String joinList(List list) {
18 | return list.toString().replaceAll(",", ",").replaceAll("[\\[.\\].\\s+]", "");
19 | }
20 |
21 | /**
22 | * Creating a list from a string
23 | * For example "1,2,3" will output new List(){1,2,3}
24 | *
25 | * @param list List
26 | * @return string
27 | */
28 | public static List getListFromString(String list) {
29 | List stringList = Arrays.asList(list.split("\\s*,\\s*"));
30 | List integerList = new ArrayList<>();
31 | for (String string : stringList) {
32 | integerList.add(Integer.parseInt(string));
33 | }
34 | return integerList;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | *.idea
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | *.iml
37 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'me.tatarka.retrolambda'
3 | apply plugin: 'realm-android'
4 |
5 | android {
6 | compileSdkVersion 24
7 | buildToolsVersion "24.0.1"
8 |
9 | defaultConfig {
10 | applicationId "io.fabianterhorst.apiclient.app"
11 | minSdkVersion 14
12 | targetSdkVersion 24
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | compileOptions {
23 | sourceCompatibility JavaVersion.VERSION_1_8
24 | targetCompatibility JavaVersion.VERSION_1_8
25 | }
26 | }
27 |
28 | dependencies {
29 | retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0'
30 | compile 'com.android.support:appcompat-v7:24.1.1'
31 | compile 'com.android.support:recyclerview-v7:24.1.1'
32 | compile 'com.trello:rxlifecycle-components:0.6.0'
33 | compile project (':apiclient')
34 | }
35 |
--------------------------------------------------------------------------------
/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/fabianterhorst/Desktop/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/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/Github.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import java.util.List;
4 |
5 | import io.fabianterhorst.apiclient.ApiClient;
6 | import retrofit2.http.Path;
7 | import rx.Observable;
8 |
9 | public class Github extends ApiClient implements GithubApi {
10 |
11 | public Github() {
12 | super(GithubApi.class, GithubApi.END_POINT);
13 | }
14 |
15 | public static void init() {
16 | init(new Github());
17 | }
18 |
19 | @Override
20 | public Observable
> getRepositories(@Path("user") String user) {
21 | return getApiObservable(getApi().getRepositories(user), Repository.class);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/GithubApi.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import java.util.List;
4 |
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Path;
7 | import rx.Observable;
8 |
9 | public interface GithubApi {
10 |
11 | String END_POINT = "https://api.github.com";
12 |
13 | @GET("/users/{user}/repos")
14 | Observable> getRepositories(@Path("user") String user);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/MainActivity.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 |
7 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
8 |
9 | public class MainActivity extends RxAppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.repositories);
16 | RepositoriesAdapter adapter = new RepositoriesAdapter();
17 | if(recyclerView != null) {
18 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
19 | recyclerView.setAdapter(adapter);
20 | }
21 | //Github github = Github.getInstance(); is also working, but does not un subscribe on orientation change for example
22 | Github github = Github.getInstance(bindToLifecycle());
23 | github.getRepositories("realm").subscribe(adapter::setRepositories);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/MyApplication.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import android.app.Application;
4 |
5 | import io.realm.Realm;
6 | import io.realm.RealmConfiguration;
7 |
8 | public class MyApplication extends Application {
9 |
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 | RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
14 | .deleteRealmIfMigrationNeeded()
15 | .build();
16 | Realm.setDefaultConfiguration(realmConfiguration);
17 | Github.init();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/RepositoriesAdapter.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | public class RepositoriesAdapter extends RecyclerView.Adapter {
13 |
14 | private List repositories;
15 |
16 | public static class ViewHolder extends RecyclerView.ViewHolder {
17 | public TextView name;
18 | public ViewHolder(View view) {
19 | super(view);
20 | name = (TextView) view.findViewById(R.id.repository_name);
21 | }
22 | }
23 |
24 | public RepositoriesAdapter() {
25 | setHasStableIds(true);
26 | repositories = new ArrayList<>();
27 | }
28 |
29 | public void setRepositories(List repositories) {
30 | this.repositories = repositories;
31 | notifyDataSetChanged();
32 | }
33 |
34 | @Override
35 | public long getItemId(int position) {
36 | return repositories.get(position).getId();
37 | }
38 |
39 | @Override
40 | public RepositoriesAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
41 | int viewType) {
42 | View v = LayoutInflater.from(parent.getContext())
43 | .inflate(R.layout.item_repository, parent, false);
44 | return new ViewHolder(v);
45 | }
46 |
47 | @Override
48 | public void onBindViewHolder(ViewHolder holder, int position) {
49 | holder.name.setText(repositories.get(position).getName());
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return repositories.size();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/io/fabianterhorst/apiclient/app/Repository.java:
--------------------------------------------------------------------------------
1 | package io.fabianterhorst.apiclient.app;
2 |
3 | import io.realm.RealmObject;
4 | import io.realm.annotations.PrimaryKey;
5 | import io.realm.annotations.RealmClass;
6 |
7 | @RealmClass
8 | public class Repository extends RealmObject {
9 |
10 | @PrimaryKey
11 | private long id;
12 |
13 | private String name;
14 |
15 | public Repository() {
16 |
17 | }
18 |
19 | public void setId(long id) {
20 | this.id = id;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public String getName() {
32 | return name;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_repository.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | App
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | repositories {
4 | jcenter()
5 | maven {
6 | url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
7 | }
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:2.1.0'
11 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
12 | classpath 'io.realm:realm-gradle-plugin:1.1.1'
13 | classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
14 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1"
15 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | jcenter()
22 | maven { url "https://jitpack.io" }
23 | maven {
24 | url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
25 | }
26 | maven {
27 | url "https://oss.sonatype.org/content/repositories/snapshots/"
28 | }
29 | }
30 | }
31 |
32 | task wrapper(type: Wrapper) {
33 | gradleVersion = '2.14.1'
34 | }
35 |
36 | task clean(type: Delete) {
37 | delete rootProject.buildDir
38 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FabianTerhorst/ApiClient/42b0a74c0585600525a80b97214a138b8567925a/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:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/publish.gradle:
--------------------------------------------------------------------------------
1 | //apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 | apply plugin: 'maven-publish'
5 | apply plugin: 'com.jfrog.bintray'
6 | apply plugin: 'maven'
7 |
8 | def siteUrl = 'https://github.com/FabianTerhorst/ApiClient'
9 | def gitUrl = 'https://github.com/FabianTerhorst/ApiClient.git'
10 |
11 | version = "0.4.4"
12 | group = "io.fabianterhorst"
13 |
14 | /*task createPom << {
15 | pom {
16 | project {
17 | groupId group
18 | artifactId 'apiclient'
19 | version version
20 |
21 | inceptionYear '2016'
22 | licenses {
23 | license {
24 | name 'The Apache Software License, Version 2.0'
25 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
26 | distribution 'repo'
27 | }
28 | }
29 | }
30 | }.writeTo("pom.xml")
31 | }
32 |
33 | publishing {
34 | publications {
35 | maven(MavenPublication) {
36 | from components.java
37 | }
38 | }
39 | }*/
40 |
41 |
42 | /*task createPom << {
43 | //repositories.mavenInstaller {
44 | // This generates POM.xml with proper parameters
45 | pom {
46 | //noinspection GroovyAssignabilityCheck
47 | project {
48 | packaging 'aar'
49 |
50 | // Add your description here
51 | name 'Fast and easy to use Api Client'
52 | url siteUrl
53 |
54 | // Set your license
55 | licenses {
56 | license {
57 | name 'The Apache Software License, Version 2.0'
58 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
59 | }
60 | }
61 | developers {
62 | developer {
63 | id 'fabianterhorst'
64 | name 'Fabian Terhorst'
65 | email 'fabian.terhorst@gmail.com'
66 | }
67 | }
68 | scm {
69 | connection gitUrl
70 | developerConnection gitUrl
71 | url siteUrl
72 | }
73 | }
74 | // }
75 | }.writeTo("pom.xml")
76 | }*/
77 | install {
78 | repositories.mavenInstaller {
79 | // This generates POM.xml with proper parameters
80 | pom {
81 | //noinspection GroovyAssignabilityCheck
82 | project {
83 | packaging 'aar'
84 |
85 | // Add your description here
86 | name 'Fast and easy to use Api Client'
87 | url siteUrl
88 |
89 | // Set your license
90 | licenses {
91 | license {
92 | name 'The Apache Software License, Version 2.0'
93 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
94 | }
95 | }
96 | developers {
97 | developer {
98 | id 'fabianterhorst'
99 | name 'Fabian Terhorst'
100 | email 'fabian.terhorst@gmail.com'
101 | }
102 | }
103 | scm {
104 | connection gitUrl
105 | developerConnection gitUrl
106 | url siteUrl
107 | }
108 | }
109 | }
110 | }
111 | }
112 |
113 |
114 | task sourcesJar(type: Jar) {
115 | from android.sourceSets.main.java.srcDirs
116 | classifier = 'sources'
117 | }
118 |
119 | task javadoc(type: Javadoc) {
120 | source = android.sourceSets.main.java.srcDirs
121 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
122 | }
123 |
124 | artifacts {
125 | archives sourcesJar
126 | }
127 |
128 | Properties properties = new Properties()
129 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
130 |
131 | bintray {
132 | user = properties.getProperty("bintray.user")
133 | key = properties.getProperty("bintray.apikey")
134 |
135 | configurations = ['archives']
136 | pkg {
137 | repo = "maven"
138 | name = "apiclient"
139 | websiteUrl = siteUrl
140 | vcsUrl = gitUrl
141 | licenses = ['Apache-2.0']
142 | publish = true
143 | }
144 | }
--------------------------------------------------------------------------------
/publishaccountmanager.gradle:
--------------------------------------------------------------------------------
1 | //apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | def siteUrl = 'https://github.com/FabianTerhorst/ApiClient'
5 | def gitUrl = 'https://github.com/FabianTerhorst/ApiClient.git'
6 |
7 | version = "0.1"
8 | group = "io.fabianterhorst"
9 |
10 | /*install {
11 | repositories.mavenInstaller {
12 | // This generates POM.xml with proper parameters
13 | pom {
14 | //noinspection GroovyAssignabilityCheck
15 | project {
16 | packaging 'aar'
17 |
18 | // Add your description here
19 | name 'Account Manager for the Api Client'
20 | url siteUrl
21 |
22 | // Set your license
23 | licenses {
24 | license {
25 | name 'The Apache Software License, Version 2.0'
26 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
27 | }
28 | }
29 | developers {
30 | developer {
31 | id 'fabianterhorst'
32 | name 'Fabian Terhorst'
33 | email 'fabian.terhorst@gmail.com'
34 | }
35 | }
36 | scm {
37 | connection gitUrl
38 | developerConnection gitUrl
39 | url siteUrl
40 | }
41 | }
42 | }
43 | }
44 | }*/
45 |
46 |
47 | task sourcesJar(type: Jar) {
48 | from android.sourceSets.main.java.srcDirs
49 | classifier = 'sources'
50 | }
51 |
52 | task javadoc(type: Javadoc) {
53 | source = android.sourceSets.main.java.srcDirs
54 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
55 | }
56 |
57 | artifacts {
58 | archives sourcesJar
59 | }
60 |
61 | Properties properties = new Properties()
62 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
63 |
64 | bintray {
65 | user = properties.getProperty("bintray.user")
66 | key = properties.getProperty("bintray.apikey")
67 |
68 | configurations = ['archives']
69 | pkg {
70 | repo = "maven"
71 | name = "apiclient-accountmanager"
72 | websiteUrl = siteUrl
73 | vcsUrl = gitUrl
74 | licenses = ['Apache-2.0']
75 | publish = true
76 | }
77 | }
--------------------------------------------------------------------------------
/publishcomponents.gradle:
--------------------------------------------------------------------------------
1 | //apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | def siteUrl = 'https://github.com/FabianTerhorst/ApiClient'
5 | def gitUrl = 'https://github.com/FabianTerhorst/ApiClient.git'
6 |
7 | version = "0.1"
8 | group = "io.fabianterhorst"
9 |
10 | /*install {
11 | repositories.mavenInstaller {
12 | // This generates POM.xml with proper parameters
13 | pom {
14 | //noinspection GroovyAssignabilityCheck
15 | project {
16 | packaging 'aar'
17 |
18 | // Add your description here
19 | name 'Components for the Api Client'
20 | url siteUrl
21 |
22 | // Set your license
23 | licenses {
24 | license {
25 | name 'The Apache Software License, Version 2.0'
26 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
27 | }
28 | }
29 | developers {
30 | developer {
31 | id 'fabianterhorst'
32 | name 'Fabian Terhorst'
33 | email 'fabian.terhorst@gmail.com'
34 | }
35 | }
36 | scm {
37 | connection gitUrl
38 | developerConnection gitUrl
39 | url siteUrl
40 | }
41 | }
42 | }
43 | }
44 | }*/
45 |
46 |
47 | task sourcesJar(type: Jar) {
48 | from android.sourceSets.main.java.srcDirs
49 | classifier = 'sources'
50 | }
51 |
52 | task javadoc(type: Javadoc) {
53 | source = android.sourceSets.main.java.srcDirs
54 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
55 | }
56 |
57 | artifacts {
58 | archives sourcesJar
59 | }
60 |
61 | Properties properties = new Properties()
62 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
63 |
64 | bintray {
65 | user = properties.getProperty("bintray.user")
66 | key = properties.getProperty("bintray.apikey")
67 |
68 | configurations = ['archives']
69 | pkg {
70 | repo = "maven"
71 | name = "apiclient-components"
72 | websiteUrl = siteUrl
73 | vcsUrl = gitUrl
74 | licenses = ['Apache-2.0']
75 | publish = true
76 | }
77 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':apiclient', ':apiclient-components', ':apiclient-accountmanager', ':app'
2 |
--------------------------------------------------------------------------------