├── .buckconfig
├── .gitignore
├── .gitmodules
├── .travis.yml
├── .watchmanconfig
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ ├── BootstrapAppRunner.java
│ │ ├── MockBootstrapApp.java
│ │ └── di
│ │ ├── MockAppComponent.java
│ │ └── MockProviderConfigModule.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── AutoBundleTogether.java
│ └── res
│ └── values
│ └── strings.xml
├── buckw
├── build.gradle
├── buildsystem
├── OpenKey.jks
├── android.jar
├── buildings.gradle
├── checkcC.sh
├── ci.sh
├── contrib_module_template.gradle
├── contrib_module_template_manifest.xml
├── dependencies.gradle
└── okbuck.gradle
├── contrib
├── bridge
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── piasy
│ │ │ │ └── octostars
│ │ │ │ └── bridge
│ │ │ │ ├── ApiError.java
│ │ │ │ ├── DbOpenHelper.java
│ │ │ │ ├── ErrorGsonAdapterFactory.java
│ │ │ │ ├── MiscModule.java
│ │ │ │ └── RxNetErrorProcessor.java
│ │ └── res
│ │ │ ├── drawable
│ │ │ ├── launch_screen.xml
│ │ │ └── white_text_selector.xml
│ │ │ ├── layout
│ │ │ └── ui_toolbar.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-v19
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── bridge
│ │ └── RxNetErrorProcessorTest.java
├── business
│ ├── .gitignore
│ ├── build.gradle
│ ├── libs
│ │ └── buck-android-support.jar
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ ├── AppShell.java
│ │ ├── BootstrapActivity.java
│ │ ├── BootstrapApp.java
│ │ ├── IApplication.java
│ │ ├── RouteTable.java
│ │ ├── analytics
│ │ ├── AppBlockCanaryContext.java
│ │ └── CrashReportingTree.java
│ │ └── di
│ │ ├── AppComponent.java
│ │ ├── AppModule.java
│ │ └── ProviderConfigModule.java
└── piasy
│ ├── repos
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── piasy
│ │ │ └── octostars
│ │ │ └── repos
│ │ │ ├── GitHubRepo.java
│ │ │ ├── RepoApiSource.java
│ │ │ ├── RepoDbSource.java
│ │ │ ├── ReposGsonAdapterFactory.java
│ │ │ ├── ReposModule.java
│ │ │ └── RepositoryRepo.java
│ │ └── sqldelight
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── repos
│ │ └── GitHubRepo.sq
│ ├── splash
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── yatatsu
│ │ │ └── autobundle
│ │ │ └── AutoBundleBindingDispatcher.java
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── piasy
│ │ │ └── octostars
│ │ │ └── features
│ │ │ └── splash
│ │ │ ├── SplashActivity.java
│ │ │ ├── SplashComponent.java
│ │ │ ├── SplashPresenter.java
│ │ │ └── SplashView.java
│ │ └── res
│ │ ├── layout
│ │ └── activity_splash.xml
│ │ └── values
│ │ └── strings.xml
│ ├── trending
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── debug
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ ├── github
│ │ │ └── piasy
│ │ │ │ └── octostars
│ │ │ │ └── features
│ │ │ │ └── trending
│ │ │ │ └── TrendingSplash.java
│ │ │ └── yatatsu
│ │ │ └── autobundle
│ │ │ └── AutoBundleBindingDispatcher.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── piasy
│ │ │ │ └── octostars
│ │ │ │ └── features
│ │ │ │ └── trending
│ │ │ │ ├── TrendingActivity.java
│ │ │ │ ├── TrendingAdapter.java
│ │ │ │ ├── TrendingComponent.java
│ │ │ │ ├── TrendingPresenter.java
│ │ │ │ ├── TrendingRepo.java
│ │ │ │ ├── TrendingSpSource.java
│ │ │ │ ├── TrendingView.java
│ │ │ │ └── TrendingWebSource.java
│ │ └── res
│ │ │ └── layout
│ │ │ ├── activity_trending.xml
│ │ │ └── ui_trending_repo_item.xml
│ │ └── test
│ │ ├── assets
│ │ └── https___github.com_trending_java_since=monthly.html
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── features
│ │ └── trending
│ │ └── TrendingWebSourceTest.java
│ └── users
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── users
│ │ └── UserDbSourceTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── octostars
│ │ └── users
│ │ ├── GitHubUser.java
│ │ ├── UserApiSource.java
│ │ ├── UserDbSource.java
│ │ ├── UserRepo.java
│ │ ├── UsersGsonAdapterFactory.java
│ │ └── UsersModule.java
│ └── sqldelight
│ └── com
│ └── github
│ └── piasy
│ └── octostars
│ └── users
│ └── GitHubUser.sq
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── install_app.sh
├── install_buck.sh
├── mocks
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── bootstrap
│ │ ├── base
│ │ └── model
│ │ │ └── provider
│ │ │ └── ProviderModuleExposure.java
│ │ └── mocks
│ │ ├── DebugSplashActivity.java
│ │ ├── MockDateTimeFormatter.java
│ │ ├── MockDbOpenHelper.java
│ │ └── MockSearchResult.java
│ └── res
│ ├── 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
├── new_contrib_module.sh
└── settings.gradle
/.buckconfig:
--------------------------------------------------------------------------------
1 | [ndk]
2 | gcc_version = 4.9
3 | [cache]
4 | http_mode = readwrite
5 | http_url = http://localhost:6457
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # IDE files
4 | /.idea/
5 | **/*.iml
6 |
7 | # Gradle files
8 | /.gradle/
9 | /build/
10 |
11 | # Local configuration file (sdk path, etc)
12 | /local.properties
13 |
14 | # Fabric appSecrit
15 | fabric.properties
16 |
17 | # inspect
18 | .buildProfile/
19 |
20 | # buck & OkBuck
21 | /buck-out/
22 | /.buckd/
23 | /.okbuck/
24 | .buckconfig.local
25 | .buckconfig
26 | **/BUCK
27 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "AndroidCodeQualityConfig"]
2 | path = AndroidCodeQualityConfig
3 | url = git@github.com:Piasy/AndroidCodeQualityConfig.git
4 | [submodule "base"]
5 | path = base
6 | url = git@github.com:Piasy/AndroidTDDBootStrap-base.git
7 | [submodule "testbase"]
8 | path = testbase
9 | url = git@github.com:Piasy/AndroidTDDBootStrap-testbase.git
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Disabling sudo moves build to the Container Based Infrastructure on Travis CI
2 | sudo: required
3 |
4 | # Handle git submodules yourself
5 | git:
6 | submodules: false
7 | # Use sed to replace the SSH URL with the public URL, then initialize submodules
8 | before_install:
9 | - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
10 | - git submodule update --init --recursive
11 | # - sh buildsystem/install_buck.sh
12 |
13 | language: android
14 | jdk: oraclejdk8
15 |
16 | android:
17 | components:
18 | - tools # to get the new `repository-11.xml`
19 | - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
20 | - platform-tools
21 | - build-tools-25.0.2
22 | - android-25
23 | - extra-google-m2repository
24 | - extra-android-m2repository
25 | licenses:
26 | - android-sdk-license-.+
27 | - android-sdk-preview-license-.+
28 | - google-gdk-license-.+
29 |
30 | # Emulator Management: Create, Start and Wait
31 | before_script:
32 | # - echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a
33 | # - emulator -avd test -no-audio -no-window &
34 | - touch bintray.properties
35 |
36 | script:
37 | # - android-wait-for-emulator
38 | # - adb shell input keyevent 82
39 | - bash buildsystem/ci.sh
40 |
41 | after_success:
42 | - bash <(curl -s https://codecov.io/bash)
43 |
44 | notifications:
45 | email:
46 | - xz4214@gmail.com
47 |
48 | cache:
49 | directories:
50 | - $HOME/.m2
51 | - $HOME/.gradle
52 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {
2 | "ignore_dirs": [
3 | "buck-out",
4 | ".buckd",
5 | ".idea",
6 | ".okbuck",
7 | "build",
8 | ".gradle",
9 | ".swp",
10 | ],
11 | "fsevents_latency": 0.05,
12 | "suppress_recrawl_warnings": true
13 | }
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Xu Jianlin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Router
2 | -keep class com.github.piasy.octostars.BuildConfig { *; }
3 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/piasy/octostars/BootstrapAppRunner.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.support.test.runner.AndroidJUnitRunner;
6 |
7 | /**
8 | * Created by Piasy{github.com/Piasy} on 11/09/2016.
9 | */
10 |
11 | public class BootstrapAppRunner extends AndroidJUnitRunner {
12 | @Override
13 | public Application newApplication(final ClassLoader cl, final String className,
14 | final Context context)
15 | throws InstantiationException, IllegalAccessException, ClassNotFoundException {
16 | AppShell.setRealAppName(MockBootstrapApp.class.getCanonicalName());
17 | return super.newApplication(cl, AppShell.class.getName(), context);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/piasy/octostars/MockBootstrapApp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars;
26 |
27 | import android.annotation.SuppressLint;
28 | import android.app.Application;
29 | import com.facebook.drawee.backends.pipeline.Fresco;
30 | import com.github.piasy.octostars.di.AppComponent;
31 | import com.github.piasy.octostars.di.AppModule;
32 | import com.github.piasy.octostars.di.DaggerMockAppComponent;
33 | import com.github.piasy.octostars.di.MockAppComponent;
34 | import com.github.piasy.octostars.di.MockProviderConfigModule;
35 | import com.google.gson.Gson;
36 | import com.joanzapata.iconify.Iconify;
37 | import com.joanzapata.iconify.fonts.MaterialModule;
38 | import javax.inject.Inject;
39 | import timber.log.Timber;
40 |
41 | /**
42 | * Created by Piasy{github.com/Piasy} on 3/7/16.
43 | */
44 | public class MockBootstrapApp extends BootstrapApp {
45 |
46 | // we do want singleton of app instance
47 | @SuppressLint("StaticFieldLeak")
48 | private static MockBootstrapApp sInstance;
49 |
50 | @Inject
51 | public Gson mGson;
52 |
53 | public MockBootstrapApp(final Application application) {
54 | super(application);
55 | }
56 |
57 | private static void setInstance(final MockBootstrapApp instance) {
58 | sInstance = instance;
59 | }
60 |
61 | public static MockBootstrapApp get() {
62 | return sInstance;
63 | }
64 |
65 | @Override
66 | public void onCreate() {
67 | super.onCreate();
68 |
69 | Timber.plant(new Timber.DebugTree());
70 | Fresco.initialize(mApplication);
71 | Iconify.with(new MaterialModule());
72 |
73 | setInstance(this);
74 | }
75 |
76 | @Override
77 | protected AppComponent createComponent() {
78 | final MockAppComponent appComponent = DaggerMockAppComponent.builder()
79 | .appModule(new AppModule(mApplication))
80 | .providerConfigModule(new MockProviderConfigModule())
81 | .build();
82 | appComponent.inject(this);
83 | return appComponent;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/piasy/octostars/di/MockAppComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.di;
26 |
27 | import com.github.piasy.octostars.MockBootstrapApp;
28 | import com.github.piasy.bootstrap.base.model.jsr310.JSR310Module;
29 | import com.github.piasy.bootstrap.base.model.provider.ProviderModule;
30 | import com.github.piasy.bootstrap.base.utils.UtilsModule;
31 | import com.github.piasy.octostars.bridge.MiscModule;
32 | import dagger.Component;
33 | import javax.inject.Singleton;
34 |
35 | /**
36 | * Created by Piasy{github.com/Piasy} on 15/7/23.
37 | *
38 | * DI appComponent abstraction for Application scope.
39 | * Application scope is {@link Singleton} scope, sub appComponent like {@link
40 | * com.github.piasy.yamvp.dagger2.ActivityScope} could have wilder scope.
41 | *
42 | * We put it inside app module, because {@link ProviderConfigModule} must locate in app module,
43 | * and there is no other side effect with this manner, besides, we can use
44 | * {@link dagger.Subcomponent} to define sub component, which need less code.
45 | */
46 | @Singleton
47 | @Component(
48 | modules = {
49 | AppModule.class,
50 |
51 | ProviderModule.class, ProviderConfigModule.class,
52 |
53 | JSR310Module.class, UtilsModule.class,
54 |
55 | MiscModule.class,
56 | })
57 | public interface MockAppComponent extends AppComponent {
58 | void inject(MockBootstrapApp app);
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/piasy/octostars/di/MockProviderConfigModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.di;
26 |
27 | import com.github.piasy.bootstrap.base.model.provider.RetrofitConfig;
28 | import io.appflate.restmock.RESTMockServer;
29 |
30 | /**
31 | * Created by Piasy{github.com/Piasy} on 3/7/16.
32 | */
33 | public class MockProviderConfigModule extends ProviderConfigModule {
34 |
35 | @Override
36 | RetrofitConfig provideRestConfig() {
37 | return RetrofitConfig.builder().baseUrl(RESTMockServer.getUrl()).build();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
28 |
29 |
38 |
42 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/octostars/AutoBundleTogether.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars;
26 |
27 | import android.app.Activity;
28 | import com.chenenyu.router.annotation.Route;
29 | import com.yatatsu.autobundle.AutoBundleField;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 04/02/2017.
33 | */
34 |
35 | @Route("dummy")
36 | public final class AutoBundleTogether extends Activity {
37 | @AutoBundleField
38 | boolean mDummy;
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | OctoStars
27 |
28 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | import com.android.build.gradle.internal.tasks.AndroidTestTask
2 |
3 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
4 | apply from: 'buildsystem/dependencies.gradle'
5 |
6 | buildscript {
7 | apply from: 'buildsystem/dependencies.gradle'
8 |
9 | configurations.all {
10 | resolutionStrategy {
11 | dependencySubstitution {
12 | substitute module('com.tunnelvisionlabs:antlr4') with module(
13 | 'org.antlr:antlr4:4.5.3')
14 | }
15 | }
16 | }
17 | repositories {
18 | jcenter()
19 | mavenCentral()
20 | maven {
21 | // For fabric
22 | url 'https://maven.fabric.io/public'
23 | }
24 | maven {
25 | url "https://plugins.gradle.org/m2/"
26 | }
27 | }
28 | dependencies {
29 | classpath 'com.android.tools.build:gradle:2.2.3'
30 |
31 | classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0'
32 | classpath 'de.mobilej.unmock:UnMockPlugin:0.5.1'
33 | classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1'
34 | classpath "net.rdrei.android.buildtimetracker:gradle-plugin:0.9.0"
35 | classpath 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.4'
36 | classpath 'com.github.promeg:android-git-sha-plugin:1.0.1'
37 | classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8"
38 | classpath('com.uber:okbuck:0.17.2') {
39 | exclude module: 'gradle'
40 | }
41 |
42 | classpath 'me.tatarka:gradle-retrolambda:3.3.0'
43 | classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
44 | classpath "com.squareup.sqldelight:gradle-plugin:$sqlDelightVersion"
45 | classpath "com.jakewharton:butterknife-gradle-plugin:$butterKnifeVersion"
46 | classpath 'io.fabric.tools:gradle:1.22.0'
47 | classpath('com.chenenyu.router:gradle-plugin:0.3.0') {
48 | exclude module: 'gradle'
49 | }
50 | }
51 | configurations.classpath.exclude group: 'com.android.tools.external.lombok'
52 | }
53 |
54 | allprojects {
55 | repositories {
56 | jcenter()
57 | mavenCentral()
58 | maven {
59 | // For icepick
60 | url 'https://clojars.org/repo/'
61 | }
62 | maven {
63 | // For fabric
64 | url 'https://maven.fabric.io/public'
65 | }
66 | maven { url "https://jitpack.io" }
67 | maven {
68 | url "http://dl.bintray.com/piasy/maven"
69 | }
70 | }
71 | }
72 |
73 | subprojects {
74 | afterEvaluate {
75 | // Log instrumentation tests results.
76 | tasks.withType(AndroidTestTask) { task ->
77 | task.doFirst {
78 | ant.lifecycleLogLevel = org.gradle.api.AntBuilder.AntMessagePriority.DEBUG
79 | }
80 | }
81 | }
82 | }
83 |
84 | apply from: 'buildsystem/okbuck.gradle'
85 |
86 | apply plugin: "build-time-tracker"
87 | buildtimetracker {
88 | reporters {
89 | csv {
90 | output "build/times.csv"
91 | append true
92 | header false
93 | }
94 |
95 | summary {
96 | ordered false
97 | threshold 50
98 | barstyle "unicode"
99 | }
100 |
101 | csvSummary {
102 | csv "build/times.csv"
103 | }
104 | }
105 | }
106 |
107 | task clean(type: Delete) {
108 | delete rootProject.buildDir
109 | }
110 |
--------------------------------------------------------------------------------
/buildsystem/OpenKey.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/buildsystem/OpenKey.jks
--------------------------------------------------------------------------------
/buildsystem/android.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/buildsystem/android.jar
--------------------------------------------------------------------------------
/buildsystem/buildings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | /*def keyConfigPath
26 | if (isFamily(FAMILY_WINDOWS)) {
27 | keyConfigPath = System.getenv('USERPROFILE') + File.separator + ".ssh" + File.separator +
28 | "TemplateKeyStore.properties"
29 | } else {
30 | keyConfigPath = System.getenv('HOME') + File.separator + ".ssh" + File.separator +
31 | "TemplateKeyStore.properties"
32 | }
33 |
34 | Properties props = new Properties()
35 | if (new File(keyConfigPath).exists()) {
36 | props.load(new FileInputStream(file(keyConfigPath)))
37 | }
38 |
39 | ext {
40 | signStoreFile = rootProject.file(props['keystore'])
41 | signStorePassword = props['keystore.password']
42 | signKeyAlias = props['key.alias']
43 | signKeyPassword = props['key.password']
44 | }*/
45 |
46 | ext {
47 | signStoreFile = rootProject.file('buildsystem/OpenKey.jks')
48 | signStorePassword = '123456'
49 | signKeyAlias = '123456'
50 | signKeyPassword = '123456'
51 |
52 | isComposeBuild = "true" == System.getenv("ANDROID_TDD_BOOTSTRAP_COMPOSE_BUILD")
53 | }
54 |
--------------------------------------------------------------------------------
/buildsystem/checkcC.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | adb shell setprop dalvik.vm.dexopt-flags v=n,o=v && \
3 | ./gradlew --stacktrace :app:cC \
4 | :contrib:piasy:users:cC
5 |
--------------------------------------------------------------------------------
/buildsystem/ci.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ./gradlew --stacktrace :base:check :base:jacocoReport \
3 | :app:check :app:jacocoReport \
4 | :contrib:business:check :contrib:business:jacocoReport \
5 | :contrib:bridge:check :contrib:bridge:jacocoReport \
6 | :contrib:piasy:users:check :contrib:piasy:users:jacocoReport \
7 | :contrib:piasy:repos:check :contrib:piasy:repos:jacocoReport \
8 | :contrib:piasy:trending:check :contrib:piasy:trending:jacocoReport \
9 | :contrib:piasy:splash:check :contrib:piasy:splash:jacocoReport
10 |
--------------------------------------------------------------------------------
/buildsystem/contrib_module_template.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply from: "$rootProject.projectDir/buildsystem/buildings.gradle"
26 |
27 | if (isComposeBuild) {
28 | apply plugin: 'com.android.library'
29 | } else {
30 | apply plugin: 'com.android.application'
31 | }
32 |
33 | apply plugin: 'me.tatarka.retrolambda'
34 | apply plugin: 'de.mobilej.unmock'
35 | apply plugin: 'com.github.ben-manes.versions'
36 | apply plugin: 'net.ltgt.errorprone'
37 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
38 |
39 | def isTravis = "true" == System.getenv("TRAVIS")
40 |
41 | android {
42 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
43 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
44 |
45 | defaultConfig {
46 | minSdkVersion rootProject.ext.androidMinSdkVersion
47 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
48 | versionCode rootProject.ext.releaseVersionCode
49 | versionName rootProject.ext.releaseVersionName
50 |
51 | if (!isComposeBuild) {
52 | applicationId "com.github.piasy.octostars.features."
53 | }
54 |
55 | multiDexEnabled true
56 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
57 | }
58 |
59 | signingConfigs {
60 | sign {
61 | storeFile signStoreFile
62 | storePassword signStorePassword
63 | keyAlias signKeyAlias
64 | keyPassword signKeyPassword
65 | }
66 | }
67 |
68 | buildTypes {
69 | debug {
70 | testCoverageEnabled isTravis
71 | signingConfig signingConfigs.sign
72 | }
73 | release {
74 | minifyEnabled false
75 | signingConfig signingConfigs.sign
76 | }
77 | }
78 |
79 | dexOptions {
80 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
81 | preDexLibraries = false
82 | javaMaxHeapSize "4g"
83 | }
84 |
85 | packagingOptions {
86 | exclude 'META-INF/LICENSE.txt'
87 | exclude 'META-INF/NOTICE.txt'
88 | exclude 'META-INF/services/javax.annotation.processing.Processor'
89 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
90 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
91 | exclude 'META-INF/rxjava.properties'
92 | }
93 |
94 | if (isTravis) {
95 | lintOptions {
96 | abortOnError false
97 | }
98 | }
99 | }
100 |
101 | unMock {
102 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
103 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
104 |
105 | keep "android.text.TextUtils"
106 | keepStartingWith "org.json."
107 | }
108 |
109 | dependencies {
110 | compile project(':base')
111 | compile project(':contrib:bridge')
112 | releaseProvided project(path: ':contrib:business', configuration: 'release')
113 |
114 | provided aptDependencies.autoValue // for ide
115 | annotationProcessor aptDependencies.autoValue // for okbuck
116 | provided aptDependencies.autoGsonApt // for ide
117 | annotationProcessor aptDependencies.autoGsonApt // for okbuck
118 | annotationProcessor aptDependencies.autoParcelApt
119 |
120 | annotationProcessor aptDependencies.daggerApt
121 |
122 | retrolambdaConfig aptDependencies.retrolambda
123 | errorprone aptDependencies.errorprone
124 |
125 | debugCompile project(path: ':contrib:business', configuration: 'debug')
126 | debugCompile project(':mocks')
127 |
128 | testCompile project(':mocks')
129 | testCompile project(':testbase')
130 |
131 | androidTestCompile project(':mocks')
132 | androidTestCompile project(':testbase')
133 | }
134 |
--------------------------------------------------------------------------------
/buildsystem/contrib_module_template_manifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/buildsystem/okbuck.gradle:
--------------------------------------------------------------------------------
1 | apply from: 'buildsystem/dependencies.gradle'
2 | apply plugin: 'com.uber.okbuck'
3 | okbuck {
4 | buildToolVersion = "$rootProject.ext.androidBuildToolsVersion"
5 | target = "android-$rootProject.ext.androidTargetSdkVersion"
6 | linearAllocHardLimit = [
7 | app: 16 * 1024 * 1024
8 | ]
9 | wrapper {
10 | repo = 'https://github.com/OkBuilds/buck.git'
11 | remove = ['.buckconfig.local', "**/BUCK"]
12 | watch += ["**/*.sq"]
13 | }
14 | intellij {
15 | sources = true
16 | }
17 | }
18 |
19 | Task okbuckTask = project.tasks.getByName("okbuck")
20 |
21 | subprojects { project ->
22 | afterEvaluate {
23 | if (project.plugins.hasPlugin('java')) {
24 | addCommonConfigurationForJavaModules(project)
25 | } else if (project.plugins.hasPlugin('com.android.application')
26 | || project.plugins.hasPlugin('com.android.library')) {
27 | addCommonConfigurationForAndroidModules(project, okbuckTask)
28 | }
29 |
30 | project.tasks.withType(Test) { Test task ->
31 | task.jvmArgs << "-Djava.awt.headless=true"
32 | }
33 | }
34 | }
35 |
36 | static def addCommonConfigurationForJavaModules(Project project) {
37 | if (project.plugins.hasPlugin('me.tatarka.retrolambda')) {
38 | project.sourceCompatibility = JavaVersion.VERSION_1_8
39 | project.targetCompatibility = JavaVersion.VERSION_1_8
40 | } else {
41 | project.sourceCompatibility = JavaVersion.VERSION_1_7
42 | project.targetCompatibility = JavaVersion.VERSION_1_7
43 | }
44 | }
45 |
46 | static def addCommonConfigurationForAndroidModules(Project project, Task okbuckTask) {
47 | project.android {
48 | compileOptions {
49 | if (project.plugins.hasPlugin('me.tatarka.retrolambda')) {
50 | sourceCompatibility JavaVersion.VERSION_1_8
51 | targetCompatibility JavaVersion.VERSION_1_8
52 | } else {
53 | sourceCompatibility JavaVersion.VERSION_1_7
54 | targetCompatibility JavaVersion.VERSION_1_7
55 | }
56 | }
57 | }
58 |
59 | def variants
60 | if (project.plugins.hasPlugin('com.android.application')) {
61 | variants = project.android.applicationVariants
62 | } else {
63 | variants = project.android.libraryVariants
64 | }
65 |
66 | if (project.plugins.hasPlugin('com.squareup.sqldelight')) {
67 | variants.all {
68 | Task sqlDelightTask = project.tasks.getByName("generate${it.name.capitalize()}SqlDelightInterface")
69 | okbuckTask.dependsOn(sqlDelightTask)
70 | project.android.sourceSets."${it.name}".java.srcDirs += [sqlDelightTask.outputs.files[0] as String]
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/contrib/bridge/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/contrib/bridge/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'me.tatarka.retrolambda'
27 | apply plugin: 'de.mobilej.unmock'
28 | apply plugin: 'com.github.ben-manes.versions'
29 | apply plugin: 'net.ltgt.errorprone'
30 | apply plugin: 'com.squareup.sqldelight'
31 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
32 |
33 | def isTravis = "true" == System.getenv("TRAVIS")
34 |
35 | android {
36 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
37 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
38 |
39 | defaultConfig {
40 | minSdkVersion rootProject.ext.androidMinSdkVersion
41 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
42 | versionCode rootProject.ext.releaseVersionCode
43 | versionName rootProject.ext.releaseVersionName
44 |
45 | multiDexEnabled true
46 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
47 | }
48 |
49 | buildTypes {
50 | debug {
51 | testCoverageEnabled isTravis
52 | }
53 | release {
54 | minifyEnabled false
55 | }
56 | }
57 |
58 | dexOptions {
59 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
60 | preDexLibraries = false
61 | javaMaxHeapSize "4g"
62 | }
63 |
64 | packagingOptions {
65 | exclude 'META-INF/LICENSE.txt'
66 | exclude 'META-INF/NOTICE.txt'
67 | exclude 'META-INF/services/javax.annotation.processing.Processor'
68 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
69 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
70 | exclude 'META-INF/rxjava.properties'
71 | }
72 |
73 | if (isTravis) {
74 | lintOptions {
75 | abortOnError false
76 | }
77 | }
78 | }
79 |
80 | unMock {
81 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
82 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
83 |
84 | keep "android.text.TextUtils"
85 | keep "android.util.Log"
86 | keepStartingWith "org.json."
87 | }
88 |
89 | dependencies {
90 | compile project(':contrib:piasy:repos')
91 |
92 | provided aptDependencies.autoValue // for ide
93 | annotationProcessor aptDependencies.autoValue // for okbuck
94 | provided aptDependencies.autoGsonApt // for ide
95 | annotationProcessor aptDependencies.autoGsonApt // for okbuck
96 | annotationProcessor aptDependencies.autoParcelApt
97 |
98 | annotationProcessor aptDependencies.daggerApt
99 |
100 | retrolambdaConfig aptDependencies.retrolambda
101 | errorprone aptDependencies.errorprone
102 |
103 | testCompile project(':mocks')
104 | testCompile project(':testbase')
105 |
106 | androidTestCompile project(':mocks')
107 | androidTestCompile project(':testbase')
108 | }
109 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/java/com/github/piasy/octostars/bridge/ApiError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import android.os.Parcelable;
28 | import android.support.annotation.Nullable;
29 | import com.google.auto.value.AutoValue;
30 | import com.google.gson.Gson;
31 | import com.google.gson.TypeAdapter;
32 | import java.util.List;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/8/9.
36 | */
37 | @SuppressWarnings("PMD.MethodNamingConventions")
38 | @AutoValue
39 | public abstract class ApiError implements Parcelable {
40 |
41 | public abstract String message();
42 |
43 | @Nullable
44 | public abstract String documentation_url();
45 |
46 | @Nullable
47 | public abstract List errors();
48 |
49 | public static TypeAdapter typeAdapter(final Gson gson) {
50 | return new AutoValue_ApiError.GsonTypeAdapter(gson);
51 | }
52 |
53 | @AutoValue
54 | public abstract static class Detail implements Parcelable {
55 |
56 | public abstract String resource();
57 |
58 | public abstract String field();
59 |
60 | public abstract String code();
61 |
62 | public static TypeAdapter typeAdapter(final Gson gson) {
63 | return new AutoValue_ApiError_Detail.GsonTypeAdapter(gson);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/java/com/github/piasy/octostars/bridge/DbOpenHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import android.content.Context;
28 | import android.database.sqlite.SQLiteDatabase;
29 | import android.database.sqlite.SQLiteOpenHelper;
30 | import android.support.annotation.NonNull;
31 | import com.github.piasy.octostars.repos.GitHubRepo;
32 | import com.github.piasy.octostars.users.GitHubUser;
33 | import javax.inject.Inject;
34 | import javax.inject.Singleton;
35 |
36 | /**
37 | * Created by piasy on 15/8/10.
38 | */
39 | @Singleton
40 | public class DbOpenHelper extends SQLiteOpenHelper {
41 |
42 | private static final String DB_NAME = "OctoStars_db";
43 |
44 | private static final int VERSION = 1;
45 |
46 | @Inject
47 | DbOpenHelper(@NonNull final Context context) {
48 | super(context, DB_NAME, null, VERSION);
49 | }
50 |
51 | @Override
52 | public void onCreate(final SQLiteDatabase db) {
53 | db.execSQL(GitHubUser.CREATE_TABLE);
54 | db.execSQL(GitHubRepo.CREATE_TABLE);
55 | }
56 |
57 | @Override
58 | public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
59 | // no impl
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/java/com/github/piasy/octostars/bridge/ErrorGsonAdapterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import com.github.piasy.bootstrap.base.model.gson.NullSafeTypeAdapterFactory;
28 | import com.google.gson.TypeAdapterFactory;
29 | import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 7/31/16.
33 | */
34 | @GsonTypeAdapterFactory
35 | abstract class ErrorGsonAdapterFactory implements TypeAdapterFactory {
36 | public static TypeAdapterFactory create() {
37 | return new NullSafeTypeAdapterFactory(new AutoValueGson_ErrorGsonAdapterFactory());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/java/com/github/piasy/octostars/bridge/MiscModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import com.github.piasy.octostars.repos.ReposModule;
28 | import com.github.piasy.octostars.users.UsersModule;
29 | import com.google.gson.TypeAdapterFactory;
30 | import dagger.Module;
31 | import dagger.Provides;
32 | import dagger.multibindings.IntoSet;
33 | import javax.inject.Singleton;
34 |
35 | /**
36 | * Created by Piasy{github.com/Piasy} on 20/01/2017.
37 | */
38 |
39 | @Module(includes = { UsersModule.class, ReposModule.class, })
40 | public class MiscModule {
41 | @Singleton
42 | @Provides
43 | @IntoSet
44 | TypeAdapterFactory provideAutoGsonAdapterFactory() {
45 | return ErrorGsonAdapterFactory.create();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/java/com/github/piasy/octostars/bridge/RxNetErrorProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import android.text.TextUtils;
28 | import com.google.gson.Gson;
29 | import javax.inject.Inject;
30 | import javax.inject.Singleton;
31 | import retrofit2.HttpException;
32 | import rx.functions.Action1;
33 | import timber.log.Timber;
34 |
35 | /**
36 | * Created by Piasy{github.com/Piasy} on 15/7/24.
37 | *
38 | * used for Rx network error handling
39 | * Usage: Observable.subscribe(onNext, RxNetErrorProcessor.NetErrorProcessor)
40 | * run in the observeOn() thread
41 | * onErrorReturn run in subscribeOn thread (retrofit run in background thread, not good for
42 | * error handling)
43 | *
44 | * Note: if you handle onError for the net request, than you should call it manually:
45 | * RxNetErrorProcessor.NetErrorProcessor.call(throwable);
46 | * Otherwise this method won't be invoked
47 | */
48 | @Singleton
49 | public class RxNetErrorProcessor implements Action1 {
50 |
51 | private final Gson mGson;
52 |
53 | @Inject
54 | RxNetErrorProcessor(final Gson gson) {
55 | mGson = gson;
56 | }
57 |
58 | /**
59 | * Final path of network error processing, submit it to server at production build.
60 | */
61 | @Override
62 | public void call(final Throwable throwable) {
63 | Timber.e(throwable, "RxNetErrorProcessor");
64 | }
65 |
66 | @SuppressWarnings("PMD.AvoidCatchingGenericException")
67 | public boolean tryWithApiError(final Throwable throwable, final Action1 handler) {
68 | if (throwable instanceof HttpException) {
69 | final HttpException exception = (HttpException) throwable;
70 | try {
71 | final String errorBody = exception.response().errorBody().string();
72 | final ApiError apiError = mGson.fromJson(errorBody, ApiError.class);
73 | if (!TextUtils.isEmpty(apiError.message())) {
74 | handler.call(apiError);
75 | return true;
76 | }
77 | } catch (Exception e) {
78 | call(throwable);
79 | }
80 | } else {
81 | call(throwable);
82 | }
83 | return false;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/drawable/launch_screen.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
28 |
29 |
30 |
31 | -
34 |
38 |
39 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/drawable/white_text_selector.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/layout/ui_toolbar.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/bridge/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/bridge/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/bridge/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/bridge/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/bridge/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/values-v19/dimens.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | 73dp
27 | 25dp
28 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | #ff99cc00
27 | #ff669900
28 | #ffaa66cc
29 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | 48dp
27 | 0dp
28 |
29 |
--------------------------------------------------------------------------------
/contrib/bridge/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
28 |
37 |
38 |
41 |
42 |
--------------------------------------------------------------------------------
/contrib/bridge/src/test/java/com/github/piasy/octostars/bridge/RxNetErrorProcessorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.bridge;
26 |
27 | import com.github.piasy.bootstrap.base.model.provider.ProviderModuleExposure;
28 | import com.github.piasy.bootstrap.testbase.TestUtil;
29 | import com.github.piasy.bootstrap.testbase.rules.ThreeTenBPRule;
30 | import com.google.gson.TypeAdapterFactory;
31 | import org.junit.Rule;
32 | import org.junit.Test;
33 | import org.mockito.Mock;
34 | import org.mockito.junit.MockitoJUnit;
35 | import org.mockito.junit.MockitoRule;
36 | import rx.functions.Action1;
37 |
38 | import static org.junit.Assert.assertFalse;
39 | import static org.junit.Assert.assertTrue;
40 | import static org.mockito.Matchers.any;
41 | import static org.mockito.Mockito.never;
42 | import static org.mockito.Mockito.only;
43 | import static org.mockito.Mockito.verify;
44 |
45 | /**
46 | * Created by Piasy{github.com/Piasy} on 5/5/16.
47 | */
48 | public class RxNetErrorProcessorTest {
49 |
50 | @Rule
51 | public ThreeTenBPRule mThreeTenBPRule = ThreeTenBPRule.junitTest();
52 | @Rule
53 | public MockitoRule mMockitoRule = MockitoJUnit.rule();
54 |
55 | @Mock
56 | private Action1 mApiErrorHandler;
57 |
58 | private TypeAdapterFactory mAdapterFactory = ErrorGsonAdapterFactory.create();
59 |
60 | @Test
61 | public void testProcessOtherException() {
62 | RxNetErrorProcessor rxNetErrorProcessor =
63 | new RxNetErrorProcessor(ProviderModuleExposure.exposeGson(mAdapterFactory));
64 | Throwable throwable = new IllegalArgumentException();
65 | assertFalse(rxNetErrorProcessor.tryWithApiError(throwable, mApiErrorHandler));
66 | verify(mApiErrorHandler, never()).call(any());
67 | }
68 |
69 | @Test
70 | public void testProcessNonApiNetworkError() {
71 | RxNetErrorProcessor rxNetErrorProcessor =
72 | new RxNetErrorProcessor(ProviderModuleExposure.exposeGson(mAdapterFactory));
73 | assertFalse(
74 | rxNetErrorProcessor.tryWithApiError(TestUtil.nonApiError(), mApiErrorHandler));
75 | verify(mApiErrorHandler, never()).call(any());
76 | }
77 |
78 | @Test
79 | public void testProcessInvalidApiError() {
80 | RxNetErrorProcessor rxNetErrorProcessor =
81 | new RxNetErrorProcessor(ProviderModuleExposure.exposeGson(mAdapterFactory));
82 | assertFalse(rxNetErrorProcessor.tryWithApiError(TestUtil.invalidApiError(),
83 | mApiErrorHandler));
84 | verify(mApiErrorHandler, never()).call(any());
85 | }
86 |
87 | @Test
88 | public void testProcessApiError() {
89 | RxNetErrorProcessor rxNetErrorProcessor =
90 | new RxNetErrorProcessor(ProviderModuleExposure.exposeGson(mAdapterFactory));
91 | assertTrue(rxNetErrorProcessor.tryWithApiError(TestUtil.apiError(), mApiErrorHandler));
92 | ApiError apiError = ProviderModuleExposure.exposeGson(mAdapterFactory)
93 | .fromJson(provideGithubAPIErrorStr(), ApiError.class);
94 | verify(mApiErrorHandler, only()).call(apiError);
95 | }
96 |
97 | private String provideGithubAPIErrorStr() {
98 | return "{\"message\":\"Validation Failed\",\"errors\":[{\"resource\":\"Issue\"," +
99 | "\"field\":\"title\",\"code\":\"missing_field\"}]}";
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/contrib/business/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/contrib/business/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.frogermcs.androiddevmetrics'
27 | apply plugin: 'me.tatarka.retrolambda'
28 | apply plugin: 'de.mobilej.unmock'
29 | apply plugin: 'com.github.ben-manes.versions'
30 | apply plugin: 'net.ltgt.errorprone'
31 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
32 |
33 | def isTravis = "true" == System.getenv("TRAVIS")
34 |
35 | android {
36 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
37 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
38 | publishNonDefault true
39 |
40 | defaultConfig {
41 | minSdkVersion rootProject.ext.androidMinSdkVersion
42 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
43 | versionCode rootProject.ext.releaseVersionCode
44 | versionName rootProject.ext.releaseVersionName
45 |
46 | consumerProguardFiles 'proguard-rules.pro'
47 |
48 | multiDexEnabled true
49 |
50 | buildConfigField "String", "API_BASE_URL", "\"https://api.github.com/\""
51 | buildConfigField "int", "EXOPACKAGE_FLAGS", "0"
52 | }
53 |
54 | buildTypes {
55 | debug {
56 | testCoverageEnabled isTravis
57 | buildConfigField "int", "EXOPACKAGE_FLAGS", "1"
58 | }
59 | qa {
60 | minifyEnabled false
61 | }
62 | release {
63 | minifyEnabled false
64 | }
65 | }
66 |
67 | dexOptions {
68 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
69 | preDexLibraries = false
70 | javaMaxHeapSize "4g"
71 | }
72 |
73 | packagingOptions {
74 | exclude 'META-INF/LICENSE.txt'
75 | exclude 'META-INF/NOTICE.txt'
76 | exclude 'META-INF/services/javax.annotation.processing.Processor'
77 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
78 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
79 | exclude 'META-INF/rxjava.properties'
80 | }
81 |
82 | if (isTravis) {
83 | lintOptions {
84 | abortOnError false
85 | }
86 | }
87 | }
88 |
89 | unMock {
90 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
91 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
92 |
93 | keep "android.text.TextUtils"
94 | keepStartingWith "org.json."
95 | }
96 |
97 | dependencies {
98 | compile fileTree(dir: 'libs', include: ['*.jar'])
99 |
100 | compile project(':contrib:bridge')
101 |
102 | compile featureDependencies.fresco
103 | compile featureDependencies.iconifyMD
104 | compile featureDependencies.gitSha
105 |
106 | compile(featureDependencies.crashlytics) {
107 | transitive = true;
108 | }
109 | compile(featureDependencies.answers) {
110 | transitive = true;
111 | }
112 |
113 | compile featureDependencies.stetho
114 | compile featureDependencies.strictmodeNotifier
115 | compile featureDependencies.anrWatchDog
116 | compile featureDependencies.blockCanary
117 | compile featureDependencies.leakCanary
118 | qaCompile featureDependencies.devMetrics
119 |
120 | annotationProcessor aptDependencies.daggerApt
121 |
122 | retrolambdaConfig aptDependencies.retrolambda
123 | errorprone aptDependencies.errorprone
124 | }
125 |
--------------------------------------------------------------------------------
/contrib/business/libs/buck-android-support.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/contrib/business/libs/buck-android-support.jar
--------------------------------------------------------------------------------
/contrib/business/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # buck exopackage
2 | -keepclassmembers,allowobfuscation class com.github.piasy.octostars.BootstrapApp {
3 | (android.app.Application);
4 | }
5 | -keepnames class com.github.piasy.octostars.BootstrapApp
6 |
--------------------------------------------------------------------------------
/contrib/business/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/AppShell.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars;
2 |
3 | import android.support.annotation.VisibleForTesting;
4 | import android.support.multidex.MultiDex;
5 | import com.facebook.buck.android.support.exopackage.ExopackageApplication;
6 | import com.github.piasy.octostars.business.BuildConfig;
7 |
8 | /**
9 | * Created by guyacong on 15/10/2.
10 | */
11 | public class AppShell extends ExopackageApplication {
12 |
13 | private static String sRealAppName = "com.github.piasy.octostars.BootstrapApp";
14 |
15 | private final boolean mIsExoPackage;
16 |
17 | public AppShell() {
18 | super(sRealAppName, BuildConfig.EXOPACKAGE_FLAGS != 0);
19 | mIsExoPackage = BuildConfig.EXOPACKAGE_FLAGS != 0;
20 | }
21 |
22 | @VisibleForTesting
23 | static void setRealAppName(final String realAppName) {
24 | sRealAppName = realAppName;
25 | }
26 |
27 | @Override
28 | protected void onBaseContextAttached() {
29 | if (!mIsExoPackage) {
30 | MultiDex.install(this);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/BootstrapActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars;
26 |
27 | import com.crashlytics.android.answers.Answers;
28 | import com.crashlytics.android.answers.CustomEvent;
29 | import com.github.piasy.bootstrap.base.android.BaseActivity;
30 | import com.github.piasy.octostars.business.BuildConfig;
31 | import org.threeten.bp.Duration;
32 | import org.threeten.bp.ZonedDateTime;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 16/4/13.
36 | */
37 | public abstract class BootstrapActivity extends BaseActivity {
38 | private ZonedDateTime mResume;
39 | private ZonedDateTime mPause;
40 |
41 | @Override
42 | protected void onResume() {
43 | super.onResume();
44 | if (isTrack()) {
45 | mResume = ZonedDateTime.now();
46 | Answers.getInstance()
47 | .logCustom(new CustomEvent("Activity onResume")
48 | .putCustomAttribute("Activity", this.getClass().getName())
49 | .putCustomAttribute("Time", currentTime(mResume)));
50 | }
51 | }
52 |
53 | @Override
54 | protected void onPause() {
55 | super.onPause();
56 | if (isTrack()) {
57 | mPause = ZonedDateTime.now();
58 | Answers.getInstance()
59 | .logCustom(new CustomEvent("Activity onPause")
60 | .putCustomAttribute("Activity", this.getClass().getName())
61 | .putCustomAttribute("Time", currentTime(mPause))
62 | .putCustomAttribute("Duration",
63 | Duration.between(mResume, mPause).toMinutes()));
64 | }
65 | }
66 |
67 | protected boolean isTrack() {
68 | return "release".equals(BuildConfig.BUILD_TYPE);
69 | }
70 |
71 | private String currentTime(final ZonedDateTime dateTime) {
72 | return String.format("%d-%d-%d %d:%d:%d", dateTime.getYear(), dateTime.getMonthValue(),
73 | dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(),
74 | dateTime.getSecond());
75 | }
76 | }
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/IApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars;
26 |
27 | import android.support.annotation.NonNull;
28 | import com.github.piasy.octostars.di.AppComponent;
29 |
30 | /**
31 | * Created by Piasy{github.com/Piasy} on 15/7/23.
32 | *
33 | * Interface that contains an {@link AppComponent}.
34 | */
35 | public interface IApplication {
36 | /**
37 | * get the {@link AppComponent} object.
38 | *
39 | * @return the {@link AppComponent} object.
40 | */
41 | @NonNull
42 | AppComponent appComponent();
43 | }
44 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/RouteTable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars;
26 |
27 | /**
28 | * Created by Piasy{github.com/Piasy} on 25/01/2017.
29 | */
30 |
31 | public final class RouteTable {
32 | public static final String TRENDING = "trending";
33 |
34 | private RouteTable() {
35 | // no instance
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/analytics/AppBlockCanaryContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.analytics;
26 |
27 | import com.github.moduth.blockcanary.BlockCanaryContext;
28 | import com.github.piasy.octostars.business.BuildConfig;
29 | import java.io.File;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 16/4/13.
33 | */
34 | public class AppBlockCanaryContext extends BlockCanaryContext {
35 |
36 | private static final int THRESHOLD = 500;
37 |
38 | @Override
39 | public int provideBlockThreshold() {
40 | return THRESHOLD;
41 | }
42 |
43 | @Override
44 | public boolean displayNotification() {
45 | return "debug".equals(BuildConfig.BUILD_TYPE);
46 | }
47 |
48 | @Override
49 | public String providePath() {
50 | return File.separator + BuildConfig.APPLICATION_ID + File.separator + "performance";
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/analytics/CrashReportingTree.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.analytics;
26 |
27 | import android.text.TextUtils;
28 | import android.util.Log;
29 | import com.crashlytics.android.Crashlytics;
30 | import timber.log.Timber;
31 |
32 | /**
33 | * Created by guyacong on 2015/4/11.
34 | */
35 | public class CrashReportingTree extends Timber.Tree {
36 |
37 | @Override
38 | protected void log(final int priority, final String tag, final String message,
39 | final Throwable t) {
40 | if (priority == Log.ERROR) {
41 | if (t != null) {
42 | Crashlytics.logException(t);
43 | }
44 | if (!TextUtils.isEmpty(message)) {
45 | Crashlytics.log(message);
46 | }
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/di/AppComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.di;
26 |
27 | import android.app.Application;
28 | import android.content.Context;
29 | import android.content.res.Resources;
30 | import com.f2prateek.rx.preferences2.RxSharedPreferences;
31 | import com.github.piasy.bootstrap.base.model.jsr310.JSR310Module;
32 | import com.github.piasy.bootstrap.base.model.jsr310.ThreeTenABPDelegate;
33 | import com.github.piasy.bootstrap.base.model.provider.ProviderModule;
34 | import com.github.piasy.bootstrap.base.utils.ScreenUtil;
35 | import com.github.piasy.bootstrap.base.utils.ToastUtil;
36 | import com.github.piasy.bootstrap.base.utils.UtilsModule;
37 | import com.github.piasy.octostars.bridge.MiscModule;
38 | import com.github.piasy.octostars.bridge.RxNetErrorProcessor;
39 | import com.google.gson.Gson;
40 | import com.squareup.sqlbrite.BriteDatabase;
41 | import dagger.Component;
42 | import javax.inject.Singleton;
43 | import okhttp3.OkHttpClient;
44 | import org.greenrobot.eventbus.EventBus;
45 | import org.threeten.bp.format.DateTimeFormatter;
46 | import retrofit2.Retrofit;
47 |
48 | /**
49 | * Created by Piasy{github.com/Piasy} on 15/7/23.
50 | *
51 | * DI appComponent abstraction for Application scope.
52 | * Application scope is {@link Singleton} scope, sub appComponent like {@link
53 | * com.github.piasy.yamvp.dagger2.ActivityScope} could have wilder scope.
54 | *
55 | * We put it inside app module, because {@link ProviderConfigModule} must locate in app module,
56 | * and there is no other side effect with this manner, besides, we can use
57 | * {@link dagger.Subcomponent} to define sub component, which need less code.
58 | */
59 | @Singleton
60 | @Component(
61 | modules = {
62 | AppModule.class,
63 |
64 | ProviderModule.class, ProviderConfigModule.class,
65 |
66 | JSR310Module.class, UtilsModule.class,
67 |
68 | MiscModule.class,
69 | })
70 | public interface AppComponent {
71 | Application application();
72 |
73 | Context context();
74 |
75 | Resources resources();
76 |
77 | DateTimeFormatter dateTimeFormatter();
78 |
79 | EventBus eventBus();
80 |
81 | OkHttpClient okHttpClient();
82 |
83 | Retrofit retrofit();
84 |
85 | Gson gson();
86 |
87 | BriteDatabase briteDatabase();
88 |
89 | RxSharedPreferences rxSharedPreferences();
90 |
91 | ThreeTenABPDelegate threeTenABPDelegate();
92 |
93 | ToastUtil toastUtil();
94 |
95 | RxNetErrorProcessor rxNetErrorProcessor();
96 |
97 | ScreenUtil screenUtil();
98 | }
99 |
--------------------------------------------------------------------------------
/contrib/business/src/main/java/com/github/piasy/octostars/di/AppModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2016 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.di;
26 |
27 | import android.app.Application;
28 | import android.content.Context;
29 | import android.content.res.Resources;
30 | import dagger.Module;
31 | import dagger.Provides;
32 | import javax.inject.Singleton;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/7/23.
36 | *
37 | * DI module abstraction for Application scope.
38 | */
39 | @Module
40 | public class AppModule {
41 |
42 | private final Application mApplication;
43 |
44 | public AppModule(final Application application) {
45 | mApplication = application;
46 | }
47 |
48 | @Singleton
49 | @Provides
50 | Application provideApplication() {
51 | return mApplication;
52 | }
53 |
54 | @Singleton
55 | @Provides
56 | Resources provideResources() {
57 | return mApplication.getResources();
58 | }
59 |
60 | @Singleton
61 | @Provides
62 | Context provideContext() {
63 | return mApplication;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'me.tatarka.retrolambda'
27 | apply plugin: 'de.mobilej.unmock'
28 | apply plugin: 'com.github.ben-manes.versions'
29 | apply plugin: 'net.ltgt.errorprone'
30 | apply plugin: 'com.squareup.sqldelight'
31 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
32 |
33 | def isTravis = "true" == System.getenv("TRAVIS")
34 |
35 | android {
36 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
37 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
38 |
39 | defaultConfig {
40 | minSdkVersion rootProject.ext.androidMinSdkVersion
41 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
42 | versionCode rootProject.ext.releaseVersionCode
43 | versionName rootProject.ext.releaseVersionName
44 |
45 | multiDexEnabled true
46 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
47 | }
48 |
49 | buildTypes {
50 | debug {
51 | testCoverageEnabled isTravis
52 | }
53 | release {
54 | minifyEnabled false
55 | }
56 | }
57 |
58 | dexOptions {
59 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
60 | preDexLibraries = false
61 | javaMaxHeapSize "4g"
62 | }
63 |
64 | packagingOptions {
65 | exclude 'META-INF/LICENSE.txt'
66 | exclude 'META-INF/NOTICE.txt'
67 | exclude 'META-INF/services/javax.annotation.processing.Processor'
68 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
69 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
70 | exclude 'META-INF/rxjava.properties'
71 | }
72 |
73 | if (isTravis) {
74 | lintOptions {
75 | abortOnError false
76 | }
77 | }
78 | }
79 |
80 | unMock {
81 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
82 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
83 |
84 | keep "android.text.TextUtils"
85 | keepStartingWith "org.json."
86 | }
87 |
88 | dependencies {
89 | compile project(':base')
90 | compile project(':contrib:piasy:users')
91 |
92 | provided aptDependencies.autoValue // for ide
93 | annotationProcessor aptDependencies.autoValue // for okbuck
94 | provided aptDependencies.autoGsonApt // for ide
95 | annotationProcessor aptDependencies.autoGsonApt // for okbuck
96 | annotationProcessor aptDependencies.autoParcelApt
97 |
98 | // workaround https://github.com/rharter/auto-value-gson/issues/80
99 | annotationProcessor files(rootProject.file('buildsystem/android.jar'))
100 |
101 | annotationProcessor aptDependencies.daggerApt
102 |
103 | retrolambdaConfig aptDependencies.retrolambda
104 | errorprone aptDependencies.errorprone
105 |
106 | testCompile project(':mocks')
107 | testCompile project(':testbase')
108 |
109 | androidTestCompile project(':mocks')
110 | androidTestCompile project(':testbase')
111 | }
112 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/java/com/github/piasy/octostars/repos/GitHubRepo.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars.repos;
2 |
3 | import android.database.sqlite.SQLiteStatement;
4 | import android.os.Parcelable;
5 | import com.github.piasy.octostars.users.GitHubUser;
6 | import com.github.piasy.octostars.users.UserRepo;
7 | import com.google.auto.value.AutoValue;
8 | import com.google.gson.Gson;
9 | import com.google.gson.TypeAdapter;
10 |
11 | /**
12 | * Created by Piasy{github.com/Piasy} on 22/01/2017.
13 | */
14 |
15 | @AutoValue
16 | public abstract class GitHubRepo implements GitHubRepoModel, Parcelable {
17 |
18 | public static TypeAdapter typeAdapter(final Gson gson) {
19 | return new AutoValue_GitHubRepo.GsonTypeAdapter(gson);
20 | }
21 |
22 | static GitHubRepo fake(final long id, final String name) {
23 | final GitHubUser owner = UserRepo.INVALID_USER;
24 | return new AutoValue_GitHubRepo(id, name, "", owner.login(), "", "", false, 0, 0, 0, owner);
25 | }
26 |
27 | static SQLiteStatement delete(final Delete_repo delete, final long id) {
28 | delete.program.clearBindings();
29 | delete.bind(id);
30 | return delete.program;
31 | }
32 |
33 | SQLiteStatement insert(final Insert_repo insert) {
34 | insert.program.clearBindings();
35 | insert.bind(id(), name(), full_name(), owner().login(), description(), html_url(), fork(),
36 | subscribers_count(), stargazers_count(), forks_count());
37 | return insert.program;
38 | }
39 |
40 | public abstract GitHubUser owner();
41 | }
42 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/java/com/github/piasy/octostars/repos/RepoApiSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.repos;
26 |
27 | import io.reactivex.Observable;
28 | import retrofit2.http.GET;
29 | import retrofit2.http.Path;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 15/7/23.
33 | *
34 | * Definition of Github API.
35 | */
36 | interface RepoApiSource {
37 |
38 | @GET("repos/{owner}/{repo}")
39 | Observable repo(@Path("owner") String owner, @Path("repo") String repo);
40 |
41 | @GET("repos/{full_name}")
42 | Observable repo(@Path(value = "full_name", encoded = true) String fullName);
43 | }
44 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/java/com/github/piasy/octostars/repos/ReposGsonAdapterFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars.repos;
2 |
3 | import com.github.piasy.bootstrap.base.model.gson.NullSafeTypeAdapterFactory;
4 | import com.google.gson.TypeAdapterFactory;
5 | import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;
6 |
7 | /**
8 | * Created by Piasy{github.com/Piasy} on 7/31/16.
9 | */
10 | @GsonTypeAdapterFactory
11 | abstract class ReposGsonAdapterFactory implements TypeAdapterFactory {
12 | public static TypeAdapterFactory create() {
13 | return new NullSafeTypeAdapterFactory(new AutoValueGson_ReposGsonAdapterFactory());
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/java/com/github/piasy/octostars/repos/ReposModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.repos;
26 |
27 | import com.google.gson.TypeAdapterFactory;
28 | import dagger.Module;
29 | import dagger.Provides;
30 | import dagger.multibindings.IntoSet;
31 | import javax.inject.Singleton;
32 | import retrofit2.Retrofit;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/8/5.
36 | */
37 | @Module
38 | public class ReposModule {
39 |
40 | @Provides
41 | RepoApiSource provideRepoApiSource(final Retrofit retrofit) {
42 | return retrofit.create(RepoApiSource.class);
43 | }
44 |
45 | @Singleton
46 | @Provides
47 | @IntoSet
48 | TypeAdapterFactory provideAutoGsonAdapterFactory() {
49 | return ReposGsonAdapterFactory.create();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/java/com/github/piasy/octostars/repos/RepositoryRepo.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars.repos;
2 |
3 | import com.github.piasy.bootstrap.base.rx.DisperseTransformer;
4 | import com.github.piasy.bootstrap.base.utils.RxUtil;
5 | import com.github.piasy.yamvp.dagger2.ActivityScope;
6 | import io.reactivex.Observable;
7 | import java.util.Collection;
8 | import java.util.List;
9 | import javax.inject.Inject;
10 |
11 | /**
12 | * Created by Piasy{github.com/Piasy} on 22/01/2017.
13 | */
14 |
15 | @ActivityScope
16 | public class RepositoryRepo {
17 | public static final long INVALID_ID = -1;
18 | public static final GitHubRepo INVALID_REPO = GitHubRepo.fake(INVALID_ID, "fake");
19 |
20 | private final RepoApiSource mRepoApiSource;
21 | private final RepoDbSource mRepoDbSource;
22 |
23 | @Inject
24 | RepositoryRepo(final RepoApiSource repoApiSource, final RepoDbSource repoDbSource) {
25 | mRepoApiSource = repoApiSource;
26 | mRepoDbSource = repoDbSource;
27 | }
28 |
29 | public Observable get(final String fullName, final boolean refresh) {
30 | return RxUtil.repoGet(
31 | mRepoDbSource.get(fullName),
32 | mRepoApiSource.repo(fullName)
33 | .doOnNext(mRepoDbSource::put),
34 | refresh
35 | );
36 | }
37 |
38 | public Observable> get(final Collection fullNames) {
39 | return Observable.fromIterable(fullNames)
40 | .compose(new DisperseTransformer<>(500))
41 | .flatMap(fullName -> get(fullName, false))
42 | .toList()
43 | .toObservable();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/contrib/piasy/repos/src/main/sqldelight/com/github/piasy/octostars/repos/GitHubRepo.sq:
--------------------------------------------------------------------------------
1 | import java.lang.Boolean;
2 | import java.lang.Integer;
3 |
4 | CREATE TABLE GitHubRepos (
5 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
6 | name TEXT NOT NULL,
7 | full_name TEXT NOT NULL,
8 | owner_login TEXT NULL,
9 | description TEXT NULL,
10 | html_url TEXT NOT NULL,
11 | fork INTEGER As Boolean NOT NULL,
12 | subscribers_count INTEGER As Integer NOT NULL,
13 | stargazers_count INTEGER As Integer NOT NULL,
14 | forks_count INTEGER As Integer NOT NULL
15 | );
16 |
17 | select_by_full_name:
18 | SELECT * FROM GitHubRepos WHERE full_name = ?;
19 |
20 | insert_repo:
21 | INSERT OR REPLACE INTO GitHubRepos
22 | (id, name, full_name, owner_login, description, html_url, fork, subscribers_count, stargazers_count, forks_count)
23 | VALUES
24 | (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
25 |
26 | delete_repo:
27 | DELETE FROM GitHubRepos WHERE id = ?;
28 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply from: "$rootProject.projectDir/buildsystem/buildings.gradle"
26 |
27 | if (isComposeBuild) {
28 | apply plugin: 'com.android.library'
29 | } else {
30 | apply plugin: 'com.android.application'
31 | }
32 |
33 | apply plugin: 'me.tatarka.retrolambda'
34 | apply plugin: 'de.mobilej.unmock'
35 | apply plugin: 'com.github.ben-manes.versions'
36 | apply plugin: 'net.ltgt.errorprone'
37 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
38 |
39 | def isTravis = "true" == System.getenv("TRAVIS")
40 |
41 | android {
42 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
43 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
44 |
45 | defaultConfig {
46 | minSdkVersion rootProject.ext.androidMinSdkVersion
47 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
48 | versionCode rootProject.ext.releaseVersionCode
49 | versionName rootProject.ext.releaseVersionName
50 |
51 | if (!isComposeBuild) {
52 | applicationId "com.github.piasy.octostars.features.splash"
53 | }
54 |
55 | multiDexEnabled true
56 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
57 | }
58 |
59 | signingConfigs {
60 | sign {
61 | storeFile signStoreFile
62 | storePassword signStorePassword
63 | keyAlias signKeyAlias
64 | keyPassword signKeyPassword
65 | }
66 | }
67 |
68 | buildTypes {
69 | debug {
70 | testCoverageEnabled isTravis
71 | signingConfig signingConfigs.sign
72 | }
73 | release {
74 | minifyEnabled false
75 | signingConfig signingConfigs.sign
76 | }
77 | }
78 |
79 | dexOptions {
80 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
81 | preDexLibraries = false
82 | javaMaxHeapSize "4g"
83 | }
84 |
85 | packagingOptions {
86 | exclude 'META-INF/LICENSE.txt'
87 | exclude 'META-INF/NOTICE.txt'
88 | exclude 'META-INF/services/javax.annotation.processing.Processor'
89 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
90 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
91 | exclude 'META-INF/rxjava.properties'
92 | }
93 |
94 | if (isTravis) {
95 | lintOptions {
96 | abortOnError false
97 | }
98 | }
99 | }
100 |
101 | unMock {
102 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
103 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
104 |
105 | keep "android.text.TextUtils"
106 | keepStartingWith "org.json."
107 | }
108 |
109 | dependencies {
110 | compile project(':contrib:bridge')
111 | releaseProvided project(path: ':contrib:business', configuration: 'release')
112 |
113 | annotationProcessor aptDependencies.daggerApt
114 |
115 | retrolambdaConfig aptDependencies.retrolambda
116 | errorprone aptDependencies.errorprone
117 |
118 | debugCompile project(path: ':contrib:business', configuration: 'debug')
119 |
120 | testCompile project(':mocks')
121 | testCompile project(':testbase')
122 |
123 | androidTestCompile project(':mocks')
124 | androidTestCompile project(':testbase')
125 | }
126 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
28 |
29 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/debug/java/com/yatatsu/autobundle/AutoBundleBindingDispatcher.java:
--------------------------------------------------------------------------------
1 | package com.yatatsu.autobundle;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.NonNull;
5 |
6 | public final class AutoBundleBindingDispatcher implements AutoBundleDispatcher {
7 | @Override
8 | public boolean bind(@NonNull Object target, @NonNull Bundle args) {
9 | return false;
10 | }
11 |
12 | @Override
13 | public boolean bind(@NonNull Object target) {
14 | return false;
15 | }
16 |
17 | @Override
18 | public boolean pack(@NonNull Object target, @NonNull Bundle args) {
19 | return false;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
28 |
29 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/java/com/github/piasy/octostars/features/splash/SplashActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.splash;
26 |
27 | import android.os.Bundle;
28 | import com.chenenyu.router.Router;
29 | import com.github.piasy.octostars.BootstrapActivity;
30 | import com.github.piasy.octostars.BootstrapApp;
31 | import com.github.piasy.octostars.RouteTable;
32 | import javax.inject.Inject;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/9/19.
36 | *
37 | * Splash activity. Init app and handle other Intent action.
38 | */
39 | public class SplashActivity extends BootstrapActivity implements SplashView {
40 |
41 | @Inject
42 | SplashPresenter mPresenter;
43 |
44 | private SplashComponent mSplashComponent;
45 |
46 | @Override
47 | protected void onCreate(final Bundle savedInstanceState) {
48 | setTheme(R.style.AppTheme);
49 | super.onCreate(savedInstanceState);
50 |
51 | setContentView(R.layout.activity_splash);
52 | mPresenter.attachView(this);
53 | }
54 |
55 | @Override
56 | protected void onDestroy() {
57 | super.onDestroy();
58 |
59 | mPresenter.detachView();
60 | mPresenter.onDestroy();
61 | }
62 |
63 | @Override
64 | protected boolean isTrack() {
65 | return false;
66 | }
67 |
68 | @Override
69 | protected void initializeDi() {
70 | mSplashComponent = DaggerSplashComponent.builder()
71 | .appComponent(BootstrapApp.get().appComponent())
72 | .build();
73 | mSplashComponent.inject(this);
74 | }
75 |
76 | @Override
77 | public SplashComponent getComponent() {
78 | return mSplashComponent;
79 | }
80 |
81 | @Override
82 | public void finishSplash(final boolean initSuccess) {
83 | if (initSuccess) {
84 | Router.build(RouteTable.TRENDING)
85 | .go(this);
86 | finish();
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/java/com/github/piasy/octostars/features/splash/SplashComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.splash;
26 |
27 | import com.github.piasy.octostars.di.AppComponent;
28 | import com.github.piasy.yamvp.dagger2.ActivityScope;
29 | import dagger.Component;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 15/9/19.
33 | *
34 | * Di appComponent for splash.
35 | */
36 | @ActivityScope
37 | @Component(dependencies = AppComponent.class)
38 | interface SplashComponent {
39 |
40 | void inject(SplashActivity activity);
41 | }
42 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/java/com/github/piasy/octostars/features/splash/SplashPresenter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.splash;
26 |
27 | import com.github.piasy.yamvp.dagger2.ActivityScope;
28 | import com.github.piasy.yamvp.rx.YaRxPresenter;
29 | import javax.inject.Inject;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 20/09/2016.
33 | */
34 |
35 | @ActivityScope
36 | class SplashPresenter extends YaRxPresenter {
37 | @Inject
38 | SplashPresenter() {
39 | super();
40 | }
41 |
42 | @Override
43 | public void attachView(final SplashView view) {
44 | super.attachView(view);
45 | getView().finishSplash(true);
46 | //addUtilDestroy(Observable
47 | // .fromCallable(() -> {
48 | // final Application app = BootstrapApp.application();
49 | // if ("release".equals(BuildConfig.BUILD_TYPE)) {
50 | // Timber.plant(new CrashReportingTree());
51 | // Fabric.with(app, new Crashlytics(), new Answers());
52 | // Crashlytics.setString("git_sha", GitShaUtils.getGitSha(app));
53 | // } else {
54 | // Timber.plant(new Timber.DebugTree());
55 | // }
56 | //
57 | // Iconify.with(new MaterialModule());
58 | // Router.initialize(app);
59 | //
60 | // return true;
61 | // })
62 | // .subscribeOn(Schedulers.io())
63 | // .subscribe(success -> {
64 | // if (isViewAttached()) {
65 | // getView().finishSplash(success);
66 | // }
67 | // }, RxUtil.OnErrorLogger));
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/java/com/github/piasy/octostars/features/splash/SplashView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.splash;
26 |
27 | import com.github.piasy.yamvp.YaView;
28 |
29 | /**
30 | * Created by Piasy{github.com/Piasy} on 20/09/2016.
31 | */
32 |
33 | interface SplashView extends YaView {
34 | void finishSplash(boolean initSuccess);
35 | }
36 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
33 |
34 |
44 |
--------------------------------------------------------------------------------
/contrib/piasy/splash/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 | Splashing
28 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.github.piasy.octostars.features.trending.TrendingSpSource
2 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
28 |
29 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/debug/java/com/github/piasy/octostars/features/trending/TrendingSplash.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import android.content.Intent;
28 | import android.os.Bundle;
29 | import android.support.annotation.Nullable;
30 | import com.github.piasy.bootstrap.mocks.DebugSplashActivity;
31 | import com.github.piasy.octostars.features.trending.TrendingActivity;
32 |
33 | /**
34 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
35 | */
36 |
37 | public class TrendingSplash extends DebugSplashActivity {
38 |
39 | @Override
40 | protected void onCreate(@Nullable Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | startActivity(new Intent(this, TrendingActivity.class));
44 | finish();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/debug/java/com/yatatsu/autobundle/AutoBundleBindingDispatcher.java:
--------------------------------------------------------------------------------
1 | package com.yatatsu.autobundle;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.NonNull;
5 |
6 | public final class AutoBundleBindingDispatcher implements AutoBundleDispatcher {
7 | @Override
8 | public boolean bind(@NonNull Object target, @NonNull Bundle args) {
9 | return false;
10 | }
11 |
12 | @Override
13 | public boolean bind(@NonNull Object target) {
14 | return false;
15 | }
16 |
17 | @Override
18 | public boolean pack(@NonNull Object target, @NonNull Bundle args) {
19 | return false;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
28 |
29 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import android.app.ProgressDialog;
28 | import android.os.Bundle;
29 | import android.support.v7.widget.LinearLayoutManager;
30 | import android.support.v7.widget.RecyclerView;
31 | import android.view.Window;
32 | import butterknife.BindView;
33 | import butterknife.ButterKnife;
34 | import com.chenenyu.router.annotation.Route;
35 | import com.github.piasy.octostars.BootstrapActivity;
36 | import com.github.piasy.octostars.BootstrapApp;
37 | import com.github.piasy.octostars.RouteTable;
38 | import com.github.piasy.octostars.repos.GitHubRepo;
39 | import java.util.List;
40 | import javax.inject.Inject;
41 |
42 | @Route(RouteTable.TRENDING)
43 | public class TrendingActivity extends BootstrapActivity implements TrendingView {
44 |
45 | @Inject
46 | TrendingPresenter mPresenter;
47 |
48 | @BindView(R2.id.mTrending)
49 | RecyclerView mTrending;
50 |
51 | private TrendingComponent mProfileComponent;
52 | private TrendingAdapter mTrendingAdapter;
53 | private ProgressDialog mProgressDialog;
54 |
55 | @Override
56 | protected void onCreate(final Bundle savedInstanceState) {
57 | super.onCreate(savedInstanceState);
58 |
59 | setContentView(R.layout.activity_trending);
60 | ButterKnife.bind(this);
61 |
62 | mPresenter.attachView(this);
63 |
64 | mTrending.setLayoutManager(new LinearLayoutManager(this));
65 | mTrendingAdapter = new TrendingAdapter();
66 | mTrending.setAdapter(mTrendingAdapter);
67 |
68 | mProgressDialog = new ProgressDialog(this);
69 | mProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
70 | mProgressDialog.setMessage("Loading...");
71 | mProgressDialog.setCanceledOnTouchOutside(false);
72 | mProgressDialog.show();
73 |
74 | mPresenter.loadTrending("java", TrendingRepo.SINCE_DAILY);
75 | }
76 |
77 | @Override
78 | protected void onDestroy() {
79 | super.onDestroy();
80 |
81 | mProgressDialog.dismiss();
82 | mPresenter.detachView();
83 | mPresenter.onDestroy();
84 | }
85 |
86 | @Override
87 | protected void initializeDi() {
88 | mProfileComponent = DaggerTrendingComponent.builder()
89 | .appComponent(BootstrapApp.get().appComponent())
90 | .build();
91 | mProfileComponent.inject(this);
92 | }
93 |
94 | @Override
95 | public TrendingComponent getComponent() {
96 | return mProfileComponent;
97 | }
98 |
99 | @Override
100 | public void showTrending(final List trending) {
101 | mProgressDialog.dismiss();
102 | mTrendingAdapter.showTrending(trending);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import android.support.annotation.LayoutRes;
28 | import android.support.v7.widget.RecyclerView;
29 | import android.view.ViewGroup;
30 | import android.widget.TextView;
31 | import butterknife.BindView;
32 | import com.github.piasy.bootstrap.base.ux.BaseViewHolder;
33 | import com.github.piasy.octostars.repos.GitHubRepo;
34 | import java.util.ArrayList;
35 | import java.util.List;
36 |
37 | /**
38 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
39 | */
40 |
41 | class TrendingAdapter extends RecyclerView.Adapter {
42 |
43 | private final List mTrendingRepos = new ArrayList<>();
44 |
45 | void showTrending(final List trendingRepos) {
46 | mTrendingRepos.clear();
47 | mTrendingRepos.addAll(trendingRepos);
48 | notifyDataSetChanged();
49 | }
50 |
51 | @Override
52 | public TrendingVH onCreateViewHolder(final ViewGroup parent, final int viewType) {
53 | return new TrendingVH(parent, R.layout.ui_trending_repo_item);
54 | }
55 |
56 | @Override
57 | public void onBindViewHolder(final TrendingVH holder, final int position) {
58 | holder.mTvFullName.setText(mTrendingRepos.get(position).full_name());
59 | }
60 |
61 | @Override
62 | public int getItemCount() {
63 | return mTrendingRepos.size();
64 | }
65 |
66 | static class TrendingVH extends BaseViewHolder {
67 |
68 | @BindView(R2.id.mTvFullName)
69 | TextView mTvFullName;
70 |
71 | public TrendingVH(final ViewGroup parent, final @LayoutRes int layout) {
72 | super(parent, layout);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingComponent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import com.github.piasy.octostars.di.AppComponent;
28 | import com.github.piasy.octostars.bridge.MiscModule;
29 | import com.github.piasy.yamvp.dagger2.ActivityScope;
30 | import dagger.Component;
31 |
32 | /**
33 | * Created by Piasy{github.com/Piasy} on 15/9/19.
34 | *
35 | * Di appComponent for splash.
36 | */
37 | @ActivityScope
38 | @Component(
39 | dependencies = AppComponent.class,
40 | modules = {
41 | MiscModule.class,
42 | })
43 | interface TrendingComponent {
44 | void inject(TrendingActivity activity);
45 | }
46 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingPresenter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import com.github.piasy.bootstrap.base.utils.RxUtil;
28 | import com.github.piasy.yamvp.dagger2.ActivityScope;
29 | import com.github.piasy.yamvp.rx.YaRxPresenter;
30 | import io.reactivex.android.schedulers.AndroidSchedulers;
31 | import io.reactivex.schedulers.Schedulers;
32 | import javax.inject.Inject;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 20/09/2016.
36 | */
37 |
38 | @ActivityScope
39 | class TrendingPresenter extends YaRxPresenter {
40 | private final TrendingRepo mTrendingRepo;
41 |
42 | @Inject
43 | TrendingPresenter(final TrendingRepo trendingRepo) {
44 | super();
45 | mTrendingRepo = trendingRepo;
46 | }
47 |
48 | void loadTrending(final String lang, final @TrendingRepo.Since String since) {
49 | addUtilDestroy(mTrendingRepo.trending(lang, since, false)
50 | .subscribeOn(Schedulers.io())
51 | .observeOn(AndroidSchedulers.mainThread(), true)
52 | .subscribe(getView()::showTrending, RxUtil.OnErrorLogger));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingRepo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import android.support.annotation.StringDef;
28 | import com.github.piasy.bootstrap.base.utils.RxUtil;
29 | import com.github.piasy.octostars.repos.GitHubRepo;
30 | import com.github.piasy.octostars.repos.RepositoryRepo;
31 | import com.github.piasy.yamvp.dagger2.ActivityScope;
32 | import io.reactivex.Observable;
33 | import java.lang.annotation.Retention;
34 | import java.lang.annotation.RetentionPolicy;
35 | import java.util.List;
36 | import javax.inject.Inject;
37 |
38 | /**
39 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
40 | */
41 |
42 | @ActivityScope
43 | public class TrendingRepo {
44 | public static final String SINCE_DAILY = "daily";
45 | public static final String SINCE_WEEKLY = "weekly";
46 | public static final String SINCE_MONTHLY = "monthly";
47 |
48 | private final TrendingWebSource mWebSource;
49 | private final TrendingSpSource mSpSource;
50 | private final RepositoryRepo mRepositoryRepo;
51 |
52 | @Inject
53 | TrendingRepo(final TrendingWebSource webSource, final TrendingSpSource spSource,
54 | final RepositoryRepo repositoryRepo) {
55 | mWebSource = webSource;
56 | mSpSource = spSource;
57 | mRepositoryRepo = repositoryRepo;
58 | }
59 |
60 | public Observable> trending(final String lang,
61 | final @TrendingRepo.Since String since, final boolean refresh) {
62 | return RxUtil.repoGet(
63 | mSpSource.get(lang, since),
64 | mWebSource.trending(lang, since)
65 | .doOnNext(trending -> mSpSource.put(trending, lang, since)),
66 | refresh)
67 | .flatMap(mRepositoryRepo::get);
68 | }
69 |
70 | @Retention(RetentionPolicy.SOURCE)
71 | @StringDef(value = { SINCE_DAILY, SINCE_WEEKLY, SINCE_MONTHLY })
72 | public @interface Since {
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingSpSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import com.f2prateek.rx.preferences2.RxSharedPreferences;
28 | import com.github.piasy.yamvp.dagger2.ActivityScope;
29 | import com.google.gson.Gson;
30 | import com.google.gson.reflect.TypeToken;
31 | import io.reactivex.Observable;
32 | import java.lang.reflect.Type;
33 | import java.util.List;
34 | import javax.inject.Inject;
35 |
36 | /**
37 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
38 | */
39 |
40 | @ActivityScope
41 | class TrendingSpSource {
42 | private static final String CACHE_KEY_FORMATTER = "trending_%s_%s";
43 |
44 | private final RxSharedPreferences mPreferences;
45 | private final Gson mGson;
46 |
47 | @Inject
48 | TrendingSpSource(final RxSharedPreferences preferences, final Gson gson) {
49 | mPreferences = preferences;
50 | mGson = gson;
51 | }
52 |
53 | Observable> get(final String lang,
54 | final @TrendingRepo.Since String since) {
55 | return Observable.create(emitter -> {
56 | final String cache = mPreferences.getString(cacheKey(lang, since), "[]").get();
57 | if ("[]".equals(cache)) {
58 | emitter.onComplete();
59 | return;
60 | }
61 | final Type type = new TypeToken>() {
62 | }.getType();
63 | emitter.onNext(mGson.fromJson(cache, type));
64 | emitter.onComplete();
65 | });
66 | }
67 |
68 | void put(final List trending, final String lang,
69 | final @TrendingRepo.Since String since) {
70 | mPreferences.getString(cacheKey(lang, since))
71 | .set(mGson.toJson(trending));
72 | }
73 |
74 | private String cacheKey(final String lang, final @TrendingRepo.Since String since) {
75 | return String.format(CACHE_KEY_FORMATTER, lang, since);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import com.github.piasy.octostars.repos.GitHubRepo;
28 | import com.github.piasy.yamvp.YaView;
29 | import java.util.List;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 20/09/2016.
33 | */
34 |
35 | interface TrendingView extends YaView {
36 | void showTrending(List trending);
37 | }
38 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/java/com/github/piasy/octostars/features/trending/TrendingWebSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import android.support.annotation.VisibleForTesting;
28 | import com.github.piasy.yamvp.dagger2.ActivityScope;
29 | import io.reactivex.Observable;
30 | import java.io.IOException;
31 | import java.util.ArrayList;
32 | import java.util.List;
33 | import javax.inject.Inject;
34 | import okhttp3.OkHttpClient;
35 | import okhttp3.Request;
36 | import okhttp3.Response;
37 | import org.jsoup.Jsoup;
38 | import org.jsoup.nodes.Document;
39 | import org.jsoup.select.Elements;
40 |
41 | /**
42 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
43 | */
44 |
45 | @ActivityScope
46 | class TrendingWebSource {
47 | private static final String TRENDING_URL_FORMATTER = "https://github.com/trending/%s?since=%s";
48 |
49 | private final OkHttpClient mOkHttpClient;
50 |
51 | @Inject
52 | TrendingWebSource(final OkHttpClient okHttpClient) {
53 | mOkHttpClient = okHttpClient;
54 | }
55 |
56 | Observable> trending(final String lang,
57 | final @TrendingRepo.Since String since) {
58 | return Observable.create(emitter -> {
59 | final String html = trendingHtml(lang, since);
60 | if (emitter.isDisposed()) {
61 | return;
62 | }
63 |
64 | final List trending = parseTrending(Jsoup.parse(html));
65 | if (emitter.isDisposed()) {
66 | return;
67 | }
68 |
69 | emitter.onNext(trending);
70 | emitter.onComplete();
71 | });
72 | }
73 |
74 | private String trendingHtml(final String lang,
75 | final @TrendingRepo.Since String since) throws IOException {
76 | final Request request = new Request.Builder()
77 | .url(String.format(TRENDING_URL_FORMATTER, lang, since))
78 | .get()
79 | .build();
80 | final Response response = mOkHttpClient.newCall(request).execute();
81 | return response.body().string();
82 | }
83 |
84 | @VisibleForTesting
85 | List parseTrending(final Document document) {
86 | final List trending = new ArrayList<>();
87 | final Elements repoList = document.getElementsByClass("repo-list");
88 | if (repoList == null || repoList.isEmpty()) {
89 | return trending;
90 | }
91 |
92 | final Elements repos = repoList.get(0).getElementsByTag("li");
93 | if (repos == null || repos.isEmpty()) {
94 | return trending;
95 | }
96 |
97 | final int size = repos.size();
98 | for (int i = 0; i < size; i++) {
99 | final Elements fullName = repos.get(i).getElementsByTag("h3");
100 | if (fullName != null && !fullName.isEmpty()) {
101 | trending.add(fullName.get(0).text().replace(" ", ""));
102 | }
103 | }
104 |
105 | return trending;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/res/layout/activity_trending.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/main/res/layout/ui_trending_repo_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
--------------------------------------------------------------------------------
/contrib/piasy/trending/src/test/java/com/github/piasy/octostars/features/trending/TrendingWebSourceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.features.trending;
26 |
27 | import com.github.piasy.bootstrap.testbase.TestUtil;
28 | import java.io.File;
29 | import java.util.Arrays;
30 | import java.util.List;
31 | import okhttp3.OkHttpClient;
32 | import org.jsoup.Jsoup;
33 | import org.jsoup.nodes.Document;
34 | import org.junit.Rule;
35 | import org.junit.Test;
36 | import org.mockito.Mock;
37 | import org.mockito.junit.MockitoJUnit;
38 | import org.mockito.junit.MockitoRule;
39 |
40 | import static com.google.common.truth.Truth.assertThat;
41 |
42 | /**
43 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
44 | */
45 | public class TrendingWebSourceTest {
46 | @Rule
47 | public MockitoRule mMockitoRule = MockitoJUnit.rule();
48 |
49 | @Mock
50 | OkHttpClient mOkHttpClient;
51 |
52 | @Test
53 | public void parseTrending() throws Exception {
54 | List expected = Arrays.asList(
55 | "aa112901/remusic",
56 | "harjot-oberai/MusicDNA",
57 | "youlookwhat/CloudReader",
58 | "mancj/SlideUp-Android",
59 | "Tencent/tinker",
60 | "ReactiveX/RxJava",
61 | "NYTimes/Store",
62 | "Blankj/AndroidUtilCode",
63 | "spring-projects/spring-boot",
64 | "LuckSiege/PictureSelector",
65 | "square/retrofit",
66 | "garretyoder/Colorful",
67 | "alibaba/ARouter",
68 | "square/okhttp",
69 | "google/guava",
70 | "GrenderG/Toasty",
71 | "Meituan-Dianping/walle",
72 | "elastic/elasticsearch",
73 | "daniel-stoneuk/material-about-library",
74 | "bumptech/glide",
75 | "PhilJay/MPAndroidChart",
76 | "spring-projects/spring-framework",
77 | "iluwatar/java-design-patterns",
78 | "JakeWharton/butterknife",
79 | "JetradarMobile/desertplaceholder"
80 | );
81 |
82 | File html = new File(TestUtil.projectRoot()
83 | + "contrib/piasy/trending/src/test/assets/https___github"
84 | + ".com_trending_java_since=monthly.html");
85 | Document document = Jsoup.parse(html, "utf-8");
86 |
87 | TrendingWebSource webSource = new TrendingWebSource(mOkHttpClient);
88 | List trending = webSource.parseTrending(document);
89 |
90 | assertThat(trending)
91 | .containsExactlyElementsIn(expected)
92 | .inOrder();
93 | }
94 | }
--------------------------------------------------------------------------------
/contrib/piasy/users/.gitignore:
--------------------------------------------------------------------------------
1 | /build/
2 |
--------------------------------------------------------------------------------
/contrib/piasy/users/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'me.tatarka.retrolambda'
27 | apply plugin: 'de.mobilej.unmock'
28 | apply plugin: 'com.github.ben-manes.versions'
29 | apply plugin: 'net.ltgt.errorprone'
30 | apply plugin: 'com.squareup.sqldelight'
31 | apply from: "$rootProject.projectDir/AndroidCodeQualityConfig/quality.gradle"
32 |
33 | def isTravis = "true" == System.getenv("TRAVIS")
34 |
35 | android {
36 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
37 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
38 |
39 | defaultConfig {
40 | minSdkVersion rootProject.ext.androidMinSdkVersion
41 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
42 | versionCode rootProject.ext.releaseVersionCode
43 | versionName rootProject.ext.releaseVersionName
44 |
45 | multiDexEnabled true
46 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
47 | }
48 |
49 | buildTypes {
50 | debug {
51 | testCoverageEnabled isTravis
52 | }
53 | release {
54 | minifyEnabled false
55 | }
56 | }
57 |
58 | dexOptions {
59 | // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
60 | preDexLibraries = false
61 | javaMaxHeapSize "4g"
62 | }
63 |
64 | packagingOptions {
65 | exclude 'META-INF/LICENSE.txt'
66 | exclude 'META-INF/NOTICE.txt'
67 | exclude 'META-INF/services/javax.annotation.processing.Processor'
68 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.properties'
69 | exclude 'META-INF/maven/com.google.dagger/dagger/pom.xml'
70 | exclude 'META-INF/rxjava.properties'
71 | }
72 |
73 | if (isTravis) {
74 | lintOptions {
75 | abortOnError false
76 | }
77 | }
78 | }
79 |
80 | unMock {
81 | downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/6.0.0_r1-robolectric-0/android-all-6.0.0_r1-robolectric-0.jar'
82 | downloadTo "${System.getenv('HOME')}/.gradle/caches/"
83 |
84 | keep "android.text.TextUtils"
85 | keepStartingWith "org.json."
86 | }
87 |
88 | dependencies {
89 | compile project(':base')
90 |
91 | provided aptDependencies.autoValue // for ide
92 | annotationProcessor aptDependencies.autoValue // for okbuck
93 | provided aptDependencies.autoGsonApt // for ide
94 | annotationProcessor aptDependencies.autoGsonApt // for okbuck
95 | annotationProcessor aptDependencies.autoParcelApt
96 |
97 | annotationProcessor aptDependencies.daggerApt
98 |
99 | retrolambdaConfig aptDependencies.retrolambda
100 | errorprone aptDependencies.errorprone
101 |
102 | testCompile project(':mocks')
103 | testCompile project(':testbase')
104 |
105 | androidTestCompile project(':mocks')
106 | androidTestCompile project(':testbase')
107 | }
108 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/androidTest/java/com/github/piasy/octostars/users/UserDbSourceTest.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars.users;
2 |
3 | import android.support.test.InstrumentationRegistry;
4 | import com.github.piasy.bootstrap.base.model.provider.ProviderModuleExposure;
5 | import com.github.piasy.bootstrap.mocks.MockDateTimeFormatter;
6 | import com.github.piasy.bootstrap.testbase.TestUtil;
7 | import com.github.piasy.bootstrap.testbase.rules.ThreeTenBPRule;
8 | import com.squareup.sqlbrite.BriteDatabase;
9 | import io.reactivex.observers.TestObserver;
10 | import java.util.List;
11 | import org.junit.Before;
12 | import org.junit.Rule;
13 | import org.junit.Test;
14 | import org.threeten.bp.ZoneId;
15 | import org.threeten.bp.ZonedDateTime;
16 |
17 | import static com.google.common.truth.Truth.assertThat;
18 |
19 | /**
20 | * Created by piasy on 15/8/11.
21 | */
22 | public class UserDbSourceTest {
23 | private static final String LOGIN = "Piasy";
24 | private static final String AVATAR = "avatar";
25 |
26 | @Rule
27 | public ThreeTenBPRule mThreeTenBPRule = ThreeTenBPRule.androidTest(
28 | InstrumentationRegistry.getContext());
29 |
30 | private UserDbSource mUserDbSource;
31 | private ZonedDateTime mDate;
32 |
33 | @Before
34 | public void setUp() {
35 | final BriteDatabase briteDb = ProviderModuleExposure.exposeBriteDb(
36 | InstrumentationRegistry.getContext(), GitHubUser.CREATE_TABLE);
37 | mUserDbSource = new UserDbSource(MockDateTimeFormatter.mockDateTimeFormatter(), briteDb);
38 | mDate = ZonedDateTime.of(2016, 5, 6, 0, 1, 0, 0, ZoneId.systemDefault());
39 |
40 | // Clearing table before each test case
41 | mUserDbSource.deleteAll();
42 | }
43 |
44 | @Test
45 | public void testInsert() {
46 | List storedUsers = mUserDbSource.getNow(LOGIN);
47 | assertThat(storedUsers).isEmpty();
48 |
49 | final GitHubUser user = GitHubUser.builder()
50 | .id(1L)
51 | .login(LOGIN)
52 | .avatar_url(AVATAR)
53 | .type(UserRepo.TYPE_USER)
54 | .updated_at(mDate)
55 | .build();
56 | mUserDbSource.put(user);
57 |
58 | storedUsers = mUserDbSource.getNow(LOGIN);
59 | assertThat(storedUsers)
60 | .containsExactly(user)
61 | .inOrder();
62 | }
63 |
64 | @Test
65 | public void testUpdate() {
66 | final GitHubUser user = GitHubUser.builder()
67 | .id(1L)
68 | .login(LOGIN)
69 | .avatar_url(AVATAR)
70 | .type(UserRepo.TYPE_USER)
71 | .updated_at(mDate)
72 | .build();
73 | mUserDbSource.put(user);
74 |
75 | final GitHubUser altered = GitHubUser.builder()
76 | .id(1L)
77 | .login(LOGIN)
78 | .avatar_url(AVATAR)
79 | .type(UserRepo.TYPE_USER)
80 | .updated_at(mDate.plusHours(1))
81 | .build();
82 | mUserDbSource.put(altered);
83 |
84 | List storedUsers = mUserDbSource.getNow(LOGIN);
85 | assertThat(storedUsers)
86 | .containsExactly(altered)
87 | .inOrder();
88 | }
89 |
90 | @Test
91 | public void testDelete() {
92 | final GitHubUser user = GitHubUser.builder()
93 | .id(1L)
94 | .login(LOGIN)
95 | .avatar_url(AVATAR)
96 | .type(UserRepo.TYPE_USER)
97 | .updated_at(mDate)
98 | .build();
99 | mUserDbSource.put(user);
100 |
101 | int deleted = mUserDbSource.delete(LOGIN);
102 | assertThat(deleted).isSameAs(1);
103 |
104 | List storedUsers = mUserDbSource.getNow(LOGIN);
105 | assertThat(storedUsers).isEmpty();
106 | }
107 |
108 | @Test
109 | public void testObserve() {
110 | final TestObserver testObserver = new TestObserver<>();
111 | mUserDbSource.observe(LOGIN).subscribe(testObserver);
112 | TestUtil.sleep(50); // ensure the chain is established
113 |
114 | final GitHubUser user = GitHubUser.builder()
115 | .id(1L)
116 | .login(LOGIN)
117 | .avatar_url(AVATAR)
118 | .type(UserRepo.TYPE_USER)
119 | .updated_at(mDate)
120 | .build();
121 | mUserDbSource.put(user);
122 | TestUtil.sleep(50); // ensure the triggered query completed
123 |
124 | final GitHubUser altered = GitHubUser.builder()
125 | .id(1L)
126 | .login(LOGIN)
127 | .avatar_url(AVATAR)
128 | .type(UserRepo.TYPE_USER)
129 | .updated_at(mDate.plusHours(1))
130 | .build();
131 | mUserDbSource.put(altered);
132 | TestUtil.sleep(50);
133 |
134 | mUserDbSource.delete(LOGIN);
135 | TestUtil.sleep(50);
136 |
137 | assertThat(testObserver.getEvents().get(0))
138 | .containsExactly(user, altered)
139 | .inOrder();
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/GitHubUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.users;
26 |
27 | import android.database.sqlite.SQLiteStatement;
28 | import android.os.Parcelable;
29 | import com.google.auto.value.AutoValue;
30 | import com.google.gson.Gson;
31 | import com.google.gson.TypeAdapter;
32 | import org.threeten.bp.ZonedDateTime;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/7/23.
36 | */
37 | @SuppressWarnings("PMD.MethodNamingConventions")
38 | @AutoValue
39 | public abstract class GitHubUser implements GitHubUserModel, Parcelable {
40 |
41 | public static TypeAdapter typeAdapter(final Gson gson) {
42 | return new AutoValue_GitHubUser.GsonTypeAdapter(gson);
43 | }
44 |
45 | public static Builder builder() {
46 | return new AutoValue_GitHubUser.Builder();
47 | }
48 |
49 | static GitHubUser fake(final long id, final String login, final String type) {
50 | return builder()
51 | .id(id)
52 | .login(login)
53 | .avatar_url("")
54 | .type(type)
55 | .build();
56 | }
57 |
58 | static SQLiteStatement delete(final Delete_by_login delete, final String login) {
59 | delete.program.clearBindings();
60 | delete.bind(login);
61 | return delete.program;
62 | }
63 |
64 | SQLiteStatement insert(final Insert_user insert) {
65 | insert.program.clearBindings();
66 | insert.bind(id(), login(), avatar_url(), type(), updated_at());
67 | return insert.program;
68 | }
69 |
70 | @AutoValue.Builder
71 | public abstract static class Builder {
72 |
73 | public abstract Builder id(final long id);
74 |
75 | public abstract Builder login(final String login);
76 |
77 | public abstract Builder avatar_url(final String avatarUrl);
78 |
79 | public abstract Builder type(final String type);
80 |
81 | public abstract Builder updated_at(final ZonedDateTime updatedAt);
82 |
83 | public abstract GitHubUser build();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/UserApiSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.users;
26 |
27 | import io.reactivex.Observable;
28 | import retrofit2.http.GET;
29 | import retrofit2.http.Path;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 15/7/23.
33 | *
34 | * Definition of Github API.
35 | */
36 | interface UserApiSource {
37 |
38 | @GET("users/{login}")
39 | Observable user(@Path("login") String login);
40 | }
41 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/UserDbSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.users;
26 |
27 | import android.database.Cursor;
28 | import android.support.annotation.VisibleForTesting;
29 | import com.github.piasy.bootstrap.base.model.jsr310.ZonedDateTimeDelightAdapter;
30 | import com.github.piasy.yamvp.dagger2.ActivityScope;
31 | import com.squareup.sqlbrite.BriteDatabase;
32 | import com.squareup.sqldelight.RowMapper;
33 | import hu.akarnokd.rxjava.interop.RxJavaInterop;
34 | import io.reactivex.Observable;
35 | import java.util.Collections;
36 | import java.util.List;
37 | import javax.inject.Inject;
38 | import org.threeten.bp.format.DateTimeFormatter;
39 |
40 | /**
41 | * Created by Piasy{github.com/Piasy} on 15/8/14.
42 | */
43 | @ActivityScope
44 | class UserDbSource {
45 |
46 | private final BriteDatabase mBriteDb;
47 |
48 | private final RowMapper mUserMapper;
49 |
50 | private final GitHubUser.Insert_user mInsertion;
51 | private final GitHubUser.Delete_by_login mDeletion;
52 |
53 | @Inject
54 | UserDbSource(final DateTimeFormatter dateTimeFormatter, final BriteDatabase briteDb) {
55 | mBriteDb = briteDb;
56 |
57 | final GitHubUser.Factory userFactory = new GitHubUser.Factory<>(
58 | AutoValue_GitHubUser::new,
59 | new ZonedDateTimeDelightAdapter(dateTimeFormatter));
60 | mUserMapper = userFactory.select_by_loginMapper();
61 |
62 | mDeletion = new GitHubUser.Delete_by_login(mBriteDb.getWritableDatabase());
63 | mInsertion = new GitHubUser.Insert_user(mBriteDb.getWritableDatabase(), userFactory);
64 | }
65 |
66 | List getNow(final String login) {
67 | final Cursor cursor = mBriteDb.query(GitHubUser.SELECT_BY_LOGIN, login);
68 | try {
69 | if (cursor.moveToFirst()) {
70 | return Collections.singletonList(mUserMapper.map(cursor));
71 | }
72 | return Collections.emptyList();
73 | } finally {
74 | cursor.close();
75 | }
76 | }
77 |
78 | Observable get(final String login) {
79 | return Observable.fromCallable(() -> getNow(login))
80 | .filter(list -> !list.isEmpty())
81 | .map(list -> list.get(0));
82 | }
83 |
84 | Observable observe(final String login) {
85 | return RxJavaInterop.toV2Observable(
86 | mBriteDb.createQuery(GitHubUser.TABLE_NAME, GitHubUser.SELECT_BY_LOGIN, login)
87 | .mapToOneOrDefault(mUserMapper::map, UserRepo.INVALID_USER)
88 | .filter(user -> user != UserRepo.INVALID_USER));
89 | }
90 |
91 | void put(final List users) {
92 | final BriteDatabase.Transaction transaction = mBriteDb.newTransaction();
93 | try {
94 | final int size = users.size();
95 | for (int i = 0; i < size; i++) {
96 | mBriteDb.executeInsert(GitHubUser.TABLE_NAME, users.get(i).insert(mInsertion));
97 | }
98 | transaction.markSuccessful();
99 | } finally {
100 | transaction.end();
101 | }
102 | }
103 |
104 | void put(final GitHubUser user) {
105 | mBriteDb.executeInsert(GitHubUser.TABLE_NAME, user.insert(mInsertion));
106 | }
107 |
108 | int delete(final String login) {
109 | return mBriteDb.executeUpdateDelete(GitHubUser.TABLE_NAME,
110 | GitHubUser.delete(mDeletion, login));
111 | }
112 |
113 | @VisibleForTesting
114 | int deleteAll() {
115 | return mBriteDb.delete(GitHubUser.TABLE_NAME, "1");
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/UserRepo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.users;
26 |
27 | import com.github.piasy.bootstrap.base.utils.RxUtil;
28 | import com.github.piasy.yamvp.dagger2.ActivityScope;
29 | import io.reactivex.Observable;
30 | import javax.inject.Inject;
31 |
32 | /**
33 | * Created by Piasy{github.com/Piasy} on 15/8/5.
34 | */
35 | @ActivityScope
36 | public class UserRepo {
37 |
38 | public static final String TYPE_USER = "User";
39 | public static final String TYPE_ORG = "Organization";
40 |
41 | public static final String ICONS_USER = "{md-person}";
42 | public static final String ICONS_ORG = "{md-people}";
43 |
44 | public static final long INVALID_ID = -1;
45 | public static final GitHubUser INVALID_USER = GitHubUser.fake(INVALID_ID, "fake", TYPE_USER);
46 |
47 | private final UserDbSource mUserDbSource;
48 | private final UserApiSource mUserApiSource;
49 |
50 | @Inject
51 | UserRepo(final UserDbSource userDbSource, final UserApiSource userApiSource) {
52 | mUserDbSource = userDbSource;
53 | mUserApiSource = userApiSource;
54 | }
55 |
56 | public Observable get(final String login, final boolean refresh) {
57 | return RxUtil.repoGet(
58 | mUserDbSource.get(login),
59 | mUserApiSource.user(login)
60 | .doOnNext(mUserDbSource::put),
61 | refresh
62 | );
63 | }
64 |
65 | public void put(final GitHubUser user) {
66 | mUserDbSource.put(user);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/UsersGsonAdapterFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.octostars.users;
2 |
3 | import com.github.piasy.bootstrap.base.model.gson.NullSafeTypeAdapterFactory;
4 | import com.google.gson.TypeAdapterFactory;
5 | import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;
6 |
7 | /**
8 | * Created by Piasy{github.com/Piasy} on 7/31/16.
9 | */
10 | @GsonTypeAdapterFactory
11 | abstract class UsersGsonAdapterFactory implements TypeAdapterFactory {
12 | public static TypeAdapterFactory create() {
13 | return new NullSafeTypeAdapterFactory(new AutoValueGson_UsersGsonAdapterFactory());
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/java/com/github/piasy/octostars/users/UsersModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.octostars.users;
26 |
27 | import com.google.gson.TypeAdapterFactory;
28 | import dagger.Module;
29 | import dagger.Provides;
30 | import dagger.multibindings.IntoSet;
31 | import javax.inject.Singleton;
32 | import retrofit2.Retrofit;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 15/8/5.
36 | */
37 | @Module
38 | public class UsersModule {
39 |
40 | @Provides
41 | UserApiSource provideUserApiSource(final Retrofit retrofit) {
42 | return retrofit.create(UserApiSource.class);
43 | }
44 |
45 | @Singleton
46 | @Provides
47 | @IntoSet
48 | TypeAdapterFactory provideAutoGsonAdapterFactory() {
49 | return UsersGsonAdapterFactory.create();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/contrib/piasy/users/src/main/sqldelight/com/github/piasy/octostars/users/GitHubUser.sq:
--------------------------------------------------------------------------------
1 | import org.threeten.bp.ZonedDateTime;
2 |
3 | CREATE TABLE GitHubUsers (
4 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
5 | login TEXT NOT NULL,
6 | avatar_url TEXT NOT NULL,
7 | type TEXT NOT NULL,
8 | updated_at TEXT AS ZonedDateTime NULL
9 | );
10 |
11 | insert_user:
12 | INSERT OR REPLACE INTO GitHubUsers
13 | (id, login, avatar_url, type, updated_at)
14 | VALUES
15 | (?, ?, ?, ?, ?);
16 |
17 | select_by_login:
18 | SELECT * FROM GitHubUsers WHERE login = ?;
19 |
20 | delete_by_login:
21 | DELETE FROM GitHubUsers WHERE login = ?;
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License (MIT)
3 | #
4 | # Copyright (c) 2017 Piasy
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in all
14 | # copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | # SOFTWARE.
23 | #
24 |
25 | org.gradle.daemon=true
26 | org.gradle.jvmargs=-Xmx8192m -XX\:MaxPermSize\=3072m
27 | org.gradle.configureondemand=true
28 | org.gradle.parallel=true
29 | # Set to true or false to enable or disable the build cache.
30 | #If this parameter is not set, the build cache is disabled by default.
31 | android.enableBuildCache=true
32 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 19 18:41:19 CST 2016
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/install_app.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BUILD_TYPE=$1
4 |
5 | if [[ -z "${BUILD_TYPE// }" ]]; then
6 | BUILD_TYPE="debug"
7 | fi
8 |
9 | BUILD_TASK="$(tr '[:lower:]' '[:upper:]' <<< ${BUILD_TYPE:0:1})${BUILD_TYPE:1}"
10 |
11 | export ANDROID_TDD_BOOTSTRAP_COMPOSE_BUILD=true
12 | ./gradlew :app:assemble${BUILD_TASK} --offline
13 | unset ANDROID_TDD_BOOTSTRAP_COMPOSE_BUILD
14 | adb install -r app/build/outputs/apk/app-${BUILD_TYPE}.apk
15 | adb shell am start -n com.github.piasy.octostars/com.github.piasy.octostars.features.splash.SplashActivity
16 |
--------------------------------------------------------------------------------
/install_buck.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | MODULE=$1
4 |
5 | if [[ -z "${MODULE// }" ]]; then
6 | echo "Please specify the module name!"
7 | exit 1
8 | fi
9 |
10 | echo "Building $MODULE..."
11 |
12 | if [[ "$MODULE" == "app" ]]; then
13 | export ANDROID_TDD_BOOTSTRAP_COMPOSE_BUILD=true
14 | ./gradlew okbuck --offline
15 | BUCK_TARGET="appDebug"
16 | ./buckw install -r -x ${BUCK_TARGET}
17 | unset ANDROID_TDD_BOOTSTRAP_COMPOSE_BUILD
18 | ./gradlew okbuck --offline
19 | else
20 | BUCK_TARGET="${MODULE//\//-}Debug"
21 | ./buckw install -r -x ${BUCK_TARGET}
22 | fi
23 |
--------------------------------------------------------------------------------
/mocks/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | src/main/assets/crashlytics-build.properties
3 | src/main/res/values/com_crashlytics_export_strings.xml
4 |
--------------------------------------------------------------------------------
/mocks/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2017 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 |
27 | android {
28 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
29 | buildToolsVersion rootProject.ext.androidBuildToolsVersion
30 |
31 | defaultConfig {
32 | minSdkVersion rootProject.ext.androidMinSdkVersion
33 | targetSdkVersion rootProject.ext.androidTargetSdkVersion
34 | versionCode rootProject.ext.releaseVersionCode
35 | versionName rootProject.ext.releaseVersionName
36 | }
37 |
38 | compileOptions {
39 | sourceCompatibility JavaVersion.VERSION_1_8
40 | targetCompatibility JavaVersion.VERSION_1_8
41 | }
42 | }
43 |
44 | dependencies {
45 | compile project(':base')
46 |
47 | compile featureDependencies.iconifyMD
48 | }
49 |
--------------------------------------------------------------------------------
/mocks/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
27 |
28 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/mocks/src/main/java/com/github/piasy/bootstrap/base/model/provider/ProviderModuleExposure.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.bootstrap.base.model.provider;
26 |
27 | import android.content.Context;
28 | import com.github.piasy.bootstrap.mocks.MockDbOpenHelper;
29 | import com.google.gson.Gson;
30 | import com.google.gson.TypeAdapterFactory;
31 | import com.squareup.sqlbrite.BriteDatabase;
32 | import java.util.Collections;
33 | import org.threeten.bp.ZoneId;
34 | import org.threeten.bp.chrono.IsoChronology;
35 | import org.threeten.bp.format.DateTimeFormatter;
36 | import org.threeten.bp.format.DateTimeFormatterBuilder;
37 | import org.threeten.bp.format.ResolverStyle;
38 | import org.threeten.bp.temporal.ChronoField;
39 |
40 | /**
41 | * Created by Piasy{github.com/Piasy} on 15/9/19.
42 | *
43 | * Expose method used internally for DI in test code.
44 | */
45 | public final class ProviderModuleExposure {
46 |
47 | private static final String TIME_FORMAT_ISO_8601 = "yyyy-MM-dd'T'HH:mm:ss'Z'";
48 | private static final DateTimeFormatter DATE_TIME_FORMATTER =
49 | new DateTimeFormatterBuilder().parseCaseInsensitive()
50 | .append(DateTimeFormatter.ISO_LOCAL_DATE)
51 | .appendLiteral('T')
52 | .appendValue(ChronoField.HOUR_OF_DAY, 2)
53 | .appendLiteral(':')
54 | .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
55 | .optionalStart()
56 | .appendLiteral(':')
57 | .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
58 | .appendLiteral('Z')
59 | .toFormatter()
60 | .withResolverStyle(ResolverStyle.STRICT)
61 | .withChronology(IsoChronology.INSTANCE)
62 | .withZone(ZoneId.systemDefault());
63 | private static final GsonConfig CONFIG = GsonConfig.builder()
64 | .dateTimeFormatter(DATE_TIME_FORMATTER)
65 | .dateFormatString(TIME_FORMAT_ISO_8601)
66 | .build();
67 |
68 | private ProviderModuleExposure() {
69 | // no instance
70 | }
71 |
72 | public static BriteDatabase exposeBriteDb(final Context context, final String tableCreation) {
73 | final BriteDbConfig config = BriteDbConfig.builder()
74 | .sqliteOpenHelper(
75 | new MockDbOpenHelper(context, Collections.singletonList(tableCreation)))
76 | .enableLogging(true)
77 | .build();
78 | return new ProviderModule().provideBriteDb(config);
79 | }
80 |
81 | public static Gson exposeGson(TypeAdapterFactory factory) {
82 | return new ProviderModule().provideGson(CONFIG, Collections.singleton(factory));
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/mocks/src/main/java/com/github/piasy/bootstrap/mocks/DebugSplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.bootstrap.mocks;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import com.joanzapata.iconify.Iconify;
7 | import com.joanzapata.iconify.fonts.MaterialModule;
8 | import timber.log.Timber;
9 |
10 | /**
11 | * Created by Piasy{github.com/Piasy} on 23/01/2017.
12 | */
13 |
14 | public class DebugSplashActivity extends Activity {
15 | @Override
16 | protected void onCreate(@Nullable Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 |
19 | Timber.plant(new Timber.DebugTree());
20 | Iconify.with(new MaterialModule());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/mocks/src/main/java/com/github/piasy/bootstrap/mocks/MockDateTimeFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.bootstrap.mocks;
2 |
3 | import org.threeten.bp.ZoneId;
4 | import org.threeten.bp.chrono.IsoChronology;
5 | import org.threeten.bp.format.DateTimeFormatter;
6 | import org.threeten.bp.format.DateTimeFormatterBuilder;
7 | import org.threeten.bp.format.ResolverStyle;
8 | import org.threeten.bp.temporal.ChronoField;
9 |
10 | /**
11 | * Created by Piasy{github.com/Piasy} on 5/5/16.
12 | */
13 | public final class MockDateTimeFormatter {
14 |
15 | private MockDateTimeFormatter() {
16 | // singleton
17 | }
18 |
19 | public static DateTimeFormatter mockDateTimeFormatter() {
20 | return SingletonHolder.INSTANCE;
21 | }
22 |
23 | private static class SingletonHolder {
24 | private static final DateTimeFormatter INSTANCE
25 | = new DateTimeFormatterBuilder().parseCaseInsensitive()
26 | .append(DateTimeFormatter.ISO_LOCAL_DATE)
27 | .appendLiteral('T')
28 | .appendValue(ChronoField.HOUR_OF_DAY, 2)
29 | .appendLiteral(':')
30 | .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
31 | .optionalStart()
32 | .appendLiteral(':')
33 | .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
34 | .appendLiteral('Z')
35 | .toFormatter()
36 | .withResolverStyle(ResolverStyle.STRICT)
37 | .withChronology(IsoChronology.INSTANCE)
38 | .withZone(ZoneId.systemDefault());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/mocks/src/main/java/com/github/piasy/bootstrap/mocks/MockDbOpenHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.bootstrap.mocks;
26 |
27 | import android.content.Context;
28 | import android.database.sqlite.SQLiteDatabase;
29 | import android.database.sqlite.SQLiteOpenHelper;
30 | import android.support.annotation.NonNull;
31 | import java.util.List;
32 |
33 | /**
34 | * Created by piasy on 15/8/10.
35 | */
36 | public class MockDbOpenHelper extends SQLiteOpenHelper {
37 |
38 | private static final String DB_NAME = "AndroidTDDBootStrap_db_mock";
39 |
40 | private static final int VERSION = 1;
41 |
42 | private final List mTableCreations;
43 |
44 | public MockDbOpenHelper(@NonNull final Context context, List tableCreations) {
45 | super(context, DB_NAME, null, VERSION);
46 | mTableCreations = tableCreations;
47 | }
48 |
49 | // Better than static final field -> allows VM to unload useless String
50 | // Because you need this string only once per application life on the device
51 |
52 | @Override
53 | public void onCreate(final SQLiteDatabase db) {
54 | final int size = mTableCreations.size();
55 | for (int i = 0; i < size; i++) {
56 | db.execSQL(mTableCreations.get(i));
57 | }
58 | }
59 |
60 | @Override
61 | public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
62 | // no impl
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/mocks/src/main/java/com/github/piasy/bootstrap/mocks/MockSearchResult.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.bootstrap.mocks;
2 |
3 | /**
4 | * Created by Piasy{github.com/Piasy} on 13/11/2016.
5 | */
6 |
7 | public final class MockSearchResult {
8 | private MockSearchResult() {
9 | // no instance
10 | }
11 |
12 | public static String simplified() {
13 | return "{\"total_count\":1,\"incomplete_results\":false,\"items\":[{\"login\":\"Piasy\"," +
14 | "\"avatar_url\":\"https://avatars.githubusercontent.com/u/3098704?v=3\"," +
15 | "\"type\":\"User\"}]}";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/mocks/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/mocks/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mocks/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/mocks/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mocks/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/mocks/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mocks/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/mocks/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mocks/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/AndroidTDDBootStrap/1e4895dd008c8b4eb8db748dcc4d3778257ab2ff/mocks/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/new_contrib_module.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | MOD_PATH=$1
4 |
5 | mkdir -p ${MOD_PATH}
6 |
7 | MODULES=`cat settings.gradle`
8 | NEW_MODULE=":${MOD_PATH//\//:}"
9 | echo "$MODULES,\n\t\t'$NEW_MODULE'" > settings.gradle
10 |
11 | CI_COMMANDS="`cat buildsystem/ci.sh` \\"
12 | echo "$CI_COMMANDS" > buildsystem/ci.sh
13 | echo "$NEW_MODULE:check $NEW_MODULE:jacocoReport" >> buildsystem/ci.sh
14 |
15 | cp buildsystem/contrib_module_template.gradle ${MOD_PATH}/build.gradle
16 | echo "/build/" > ${MOD_PATH}/.gitignore
17 |
18 | mkdir -p ${MOD_PATH}/src/main/java
19 | mkdir -p ${MOD_PATH}/src/debug/java
20 |
21 | cp buildsystem/contrib_module_template_manifest.xml ${MOD_PATH}/src/main/AndroidManifest.xml
22 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':base', ':testbase', ':mocks', ':app',
2 | ':contrib:business',
3 | ':contrib:bridge',
4 | ':contrib:piasy:users',
5 | ':contrib:piasy:repos',
6 | ':contrib:piasy:trending',
7 | ':contrib:piasy:splash'
8 |
--------------------------------------------------------------------------------