Collection of source codes, utilities, templates and snippets for Android development.
Java Batchfile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Base Migrate to Android plugin for Gradle 3.0.1 Dec 18, 2017
Deprecated Casting findViewById is no longer necessary Sep 29, 2017
Res-Animation/anim Reformat code Jul 6, 2016
Res-Menu Screenshots Jun 12, 2017
Res-Parent-Activity Reformat code Jul 6, 2016
Res-Placeholder Fix layout height Jun 12, 2017
Res-Plurals/values Plurals Nov 8, 2013
Res-Shape/drawable Change naming convention for dimens Mar 16, 2016
Res-Strings/values Change some string names Mar 16, 2016
Res-Theme Fix themes.xml Jul 20, 2017
Src-ActionBar-Done-Bar Casting findViewById is no longer necessary Sep 29, 2017
Src-ActionBar-List-Navigation Casting findViewById is no longer necessary Sep 29, 2017
Src-ActionBar-Refresh Remove progress state from Fragment Jun 12, 2017
Src-ActionBar-Search Casting findViewById is no longer necessary Sep 29, 2017
Src-Activity-Result/java Fix imports Apr 18, 2017
Src-AlarmManager Return value in method directly Jun 12, 2017
Src-Animation-Activity-Options/java/fragment Remove old Build.VERSION.SDK_INT checks Jun 12, 2017
Src-Animation-Activity-Transition/java/activity Reformat code Jul 6, 2016
Src-Animation-Layout-Transition/java/fragment Remove old Build.VERSION.SDK_INT checks Jun 12, 2017
Src-Animation-Page-Transformer/java/animation Reformat code Jul 6, 2016
Src-Animation-Property/java/fragment Remove old Build.VERSION.SDK_INT checks Jun 12, 2017
Src-Application-Class/java Remove old unnecessary code Jun 12, 2017
Src-Broadcast/java LocalBroadcastManager Jul 25, 2017
Src-Bundle/java Reformat code Jul 6, 2016
Src-Config/java Remove old unnecessary code Jun 12, 2017
Src-CoordinatorLayout Casting findViewById is no longer necessary Sep 29, 2017
Src-Copy-Constructors/java/entity Rename MyModel to MyEntity Jun 12, 2017
Src-DialogFragment Casting findViewById is no longer necessary Sep 29, 2017
Src-Dual-Pane Casting findViewById is no longer necessary Sep 29, 2017
Src-Enum/java/entity Reformat code Jul 6, 2016
Src-File-Content-Observer/java Fix imports Apr 18, 2017
Src-Fullscreen Screenshots Jun 12, 2017
Src-Glide Fix GlideUtility so it can load circular bitmaps Sep 29, 2017
Src-HTML-TextView/java/fragment Casting findViewById is no longer necessary Sep 29, 2017
Src-Intent Fix imports Apr 18, 2017
Src-JobScheduler JobScheduler Jul 16, 2017
Src-Location/java/viewmodel Location Jul 14, 2017
Src-LocationUtility/java/utility Reformat code Jul 6, 2016
Src-MVC-Activity Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-ExpandableListView Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-Fragment Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-ListView Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-RecyclerView Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-StickyListView Casting findViewById is no longer necessary Sep 29, 2017
Src-MVC-TreeListView Casting findViewById is no longer necessary Sep 29, 2017
Src-Map-Clustering Casting findViewById is no longer necessary Sep 29, 2017
Src-Map Casting findViewById is no longer necessary Sep 29, 2017
Src-Navigation-Drawer Casting findViewById is no longer necessary Sep 29, 2017
Src-NavigationView Migrate to Android plugin for Gradle 3.0.1 Dec 18, 2017
Src-Notification/java Use application context Jun 12, 2017
Src-Parcelable/java/entity Rename MyModel to MyEntity Jun 12, 2017
Src-PopupMenu Casting findViewById is no longer necessary Sep 29, 2017
Src-PreferenceFragment Casting findViewById is no longer necessary Sep 29, 2017
Src-Preferences Use apply method instead of commit in Preferences utility Aug 18, 2016
Src-Receiver Remove deprecated classes Jun 12, 2017
Src-SSL Refactor SSL utility Jun 12, 2017
Src-Service/java/service Move ServiceUtility to Alfonz library Jun 28, 2017
Src-SlidingPaneLayout Casting findViewById is no longer necessary Sep 29, 2017
Src-Splash-Screen Splash screen Jul 31, 2017
Src-SwipeRefreshLayout Casting findViewById is no longer necessary Sep 29, 2017
Src-Timer/java/fragment Fix imports Apr 18, 2017
Src-Version/java/activity Fix imports Apr 18, 2017
Src-ViewPager Casting findViewById is no longer necessary Sep 29, 2017
Src-WebView/java/fragment Casting findViewById is no longer necessary Sep 29, 2017
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.