Sample Android app that i use at Tiger Application as a reference for new Android projects. It demonstrates the architecture, tools that i use when developing for the Android platform.
(Nowadays, i have used this pattern in at least 3 projects, it turns out to speed up the android development and make a cool application.)
Libraries and tools included:
- Support libraries
- RecyclerViews
- RxJava and RxAndroid
- RxBus
- Retrofit 2
- OKHttp
- Dagger 2
- Butterknife
- Timber
- Glide
- Functional tests with Espresso
- Robolectric
- Mockito
- Checkstyle, PMD and Findbugs for code analysis
- JDK 1.8
- Android SDK.
- Android N (API 24) .
- Latest Android SDK Tools and build tools.
This project follows Android architecture guidelines that are based on MVP. For more details, you can checkout android-architecture
Imagine you have to implement a sign in screen (Include an activity only).
- Create a new package under
ui
calledsignin
- Create an new class called
SignInActivityView
that extendsActivityView<SignInActivityViewPresenter>
. - Create a
SignInActivityViewPresenter
class that extendsActivityPresenter<SignInActivityView>
- Implement the methods in
SignInActivityView
andSignInActivityViewPresenter
, add functions that your Activity requires to perform the necessary actions, e.g.signIn(String email)
. Once the sign in action finishes you should callview.showSignInSuccessful()
in presenter. - Create a
SignInActivityViewPresenterTest
and write unit tests forsignIn(email)
. - Fragments also provide the same workflow.
From above, you should have SignInActivityView
and SignInActivityViewPresenter
in your ui.signin
package to define your MVP view.
This project include code analysis tools and unit test tools, but still working on unit test and functional test for this project.
The following code analysis tools are set up on this project:
- PMD: It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. See this project's PMD ruleset.
./gradlew pmd
- Findbugs: This tool uses static analysis to find bugs in Java code. Unlike PMD, it uses compiled Java bytecode instead of source code.
./gradlew findbugs
- Checkstyle: It ensures that the code style follows your team development guidelines. See checkstyle config file.
./gradlew checkstyle
To ensure that your code is valid and stable use check:
./gradlew check
This will run checkstyle -> findbugs -> PMD -> Android Lint -> Unit Test. All Done!
To quickly start a new project, you can:
- Keep the
mvp
package and rename thetiger
package to your application. - Modify package in
build.gradle
andAndroidManifest.xml
. - Add sign config to project.
- Add proguard files to project, if it's the library proguard file, you should put it in
proguards
folder. - If you want to enable jni support, checkout
build.gradle
for more details. - All Done! Enjoy your development.
- Unit Test For Project
- Project Template for Android Studio IDE
- Usage Examples For New Project
Q: How to do pull requests?
A: Ensure good code quality and consistent formatting.
Copyright 2016 HwangJR, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.