Collection of source codes, utilities, templates and snippets for Android development.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 5bc6ff1 Jul 6, 2018
Permalink
Failed to load latest commit information.
Base Update dependencies Jul 6, 2018
Deprecated Reformat code with K&R code style Jul 5, 2018
Res-Animation/anim Reformat code Jul 6, 2016
Res-Menu Change naming convention of resources Jun 30, 2018
Res-Parent-Activity Reformat code Jul 6, 2016
Res-Placeholder Fix layout height Jun 12, 2017
Res-Plurals/values Change naming convention of resources Jun 30, 2018
Res-Shape/drawable Change naming convention for dimens Mar 16, 2016
Res-Strings/values Change naming convention of resources Jun 30, 2018
Res-Theme Reformat code with K&R code style Jul 5, 2018
Src-ActionBar-Done-Bar Reformat code with K&R code style Jul 5, 2018
Src-ActionBar-List-Navigation Reformat code with K&R code style Jul 5, 2018
Src-ActionBar-Refresh Reformat code with K&R code style Jul 5, 2018
Src-ActionBar-Search Reformat code with K&R code style Jul 5, 2018
Src-Activity-Result/java Reformat code with K&R code style Jul 5, 2018
Src-AlarmManager Reformat code with K&R code style Jul 5, 2018
Src-Animation-Activity-Options/java/fragment Reformat code with K&R code style Jul 5, 2018
Src-Animation-Activity-Transition/java/activity Reformat code with K&R code style Jul 5, 2018
Src-Animation-Layout-Transition/java/fragment Reformat code with K&R code style Jul 5, 2018
Src-Animation-Page-Transformer/java/animation Reformat code with K&R code style Jul 5, 2018
Src-Animation-Property/java/fragment Reformat code with K&R code style Jul 5, 2018
Src-Application-Class/java Reformat code with K&R code style Jul 5, 2018
Src-Broadcast/java Reformat code with K&R code style Jul 5, 2018
Src-Bundle/java Reformat code with K&R code style Jul 5, 2018
Src-Config/java Reformat code with K&R code style Jul 5, 2018
Src-CoordinatorLayout Reformat code with K&R code style Jul 5, 2018
Src-Copy-Constructors/java/entity Reformat code with K&R code style Jul 5, 2018
Src-DialogFragment Reformat code with K&R code style Jul 5, 2018
Src-Dual-Pane Reformat code with K&R code style Jul 5, 2018
Src-Enum/java/entity Reformat code with K&R code style Jul 5, 2018
Src-File-Content-Observer/java Reformat code with K&R code style Jul 5, 2018
Src-Fullscreen Reformat code with K&R code style Jul 5, 2018
Src-Glide Reformat code with K&R code style Jul 5, 2018
Src-HTML-TextView/java/fragment Reformat code with K&R code style Jul 5, 2018
Src-Intent Reformat code with K&R code style Jul 5, 2018
Src-JobScheduler Reformat code with K&R code style Jul 5, 2018
Src-Location/java/viewmodel Reformat code with K&R code style Jul 5, 2018
Src-LocationUtility/java/utility Reformat code with K&R code style Jul 5, 2018
Src-MVC-Activity Reformat code with K&R code style Jul 5, 2018
Src-MVC-ExpandableListView Reformat code with K&R code style Jul 5, 2018
Src-MVC-Fragment Reformat code with K&R code style Jul 5, 2018
Src-MVC-ListView Reformat code with K&R code style Jul 5, 2018
Src-MVC-RecyclerView Reformat code with K&R code style Jul 5, 2018
Src-MVC-StickyListView Reformat code with K&R code style Jul 5, 2018
Src-MVC-TreeListView Reformat code with K&R code style Jul 5, 2018
Src-Map-Clustering Reformat code with K&R code style Jul 5, 2018
Src-Map Reformat code with K&R code style Jul 5, 2018
Src-Navigation-Drawer Reformat code with K&R code style Jul 5, 2018
Src-NavigationView Reformat code with K&R code style Jul 5, 2018
Src-Notification/java Reformat code with K&R code style Jul 5, 2018
Src-Parcelable/java/entity Reformat code with K&R code style Jul 5, 2018
Src-PopupMenu Reformat code with K&R code style Jul 5, 2018
Src-PreferenceFragment Reformat code with K&R code style Jul 5, 2018
Src-Preferences Reformat code with K&R code style Jul 5, 2018
Src-Receiver Reformat code with K&R code style Jul 5, 2018
Src-SSL Reformat code with K&R code style Jul 5, 2018
Src-Service/java/service Reformat code with K&R code style Jul 5, 2018
Src-SlidingPaneLayout Reformat code with K&R code style Jul 5, 2018
Src-Splash-Screen Reformat code with K&R code style Jul 5, 2018
Src-SwipeRefreshLayout Reformat code with K&R code style Jul 5, 2018
Src-Timer/java/fragment Reformat code with K&R code style Jul 5, 2018
Src-Version/java/activity Reformat code with K&R code style Jul 5, 2018
Src-ViewPager Reformat code with K&R code style Jul 5, 2018
Src-WebView/java/fragment Reformat code with K&R code style Jul 5, 2018
README.md Update README Jun 14, 2017

README.md

Android Templates and Utilities

Android Templates and Utilities is a collection of source codes, utilities, templates and snippets for Android development. It helps to build new apps and shows the best way how to implement certain things on Android platform.

I write these templates for my personal need. I use it almost every day for developing apps. It is something like cookbook for me. All my apps are based on these templates.

Note that all reusable utilities and classes have been moved to a new standalone library Alfonz. These templates use Alfonz as a dependency.

Content

In this repo you can find templates for styling app, handling activity result, working with alarm manager, animations, sending and receiving broadcasts, using dual pane layout, loading and caching images, working with intents, map, navigation drawer, showing notifications, working with parcelable, preferences, running service, setting SSL connection, timer, working with view pager, webview and much more. All templates were tested and should be compatible with Android 4.1 (API level 16).

Android Templates and Utilities are organized into 3 groups:

  • Base - basic skeleton of the Android project
  • Res - resource code including xml files, images
  • Src - source code including classes, resources

Usage

How to use these templates? Just copy a template into your project, rename package "com.example" to your own package name, rename classes' or resource's names if you want and customize the code to your needs. Some templates have /src/fragment/ExampleFragment.java class which demonstrates how to use the template in a Fragment.

Example

Example of creating a basic app skeleton with 1 Activity and 1 Fragment via Android Studio:

  • Create a new Android project with package name "com.example"
  • Copy & paste Base
  • Copy & paste Res-Placeholder
  • Copy & paste Res-Strings
  • Copy & paste Res-Theme
  • Copy & paste Src-Application-Class
  • Copy & paste Src-Config
  • Copy & paste Src-MVC-Activity
  • Copy & paste Src-MVC-Fragment
  • Add Alfonz dependencies in /mobile/build.gradle
  • Initialize Logcat utility inside ExampleApplication.onCreate(): Logcat.init(ExampleConfig.LOGS, "EXAMPLE");
  • Open ExampleActivity.java and comment out onCreateOptionsMenu(...) and onOptionsItemSelected(...) methods
  • Build the project and voilà, we have a basic MVC skeleton for our future app

Developed by

Petr Nohejl

License

Copyright 2012 Petr Nohejl

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.