All Projects → ugurcany → Acn Android Framework

ugurcany / Acn Android Framework

An Android framework for rapid application development

Programming Languages

java
68154 projects - #9 most used programming language

Labels

ACN Android Framework Android Arsenal

Build Status Dependency Status API MIT license

ACN Android Framework is being developed to reduce application development effort and time providing custom...

  1. Application and Activity classes that encapsulate general configuration of application and initialization of many widely-used third-party libraries.
  2. View classes with sophisticated, yet easy-to-use features, powered by default views of Android and other third-party views shared on GitHub.

See test module for sample usage of the framework.

Table of Contents

  1. Context classes
  2. View classes
  3. Util classes
  4. How to use
  5. License

1. Context classes

The following classes can be found under context package:

AcnApplication (abstract class, extends Application)

  • Application class that extends AcnApplication needs to provide required params inside constructor method:
super.build()
        .cacheSize(1024 * 1024 * 5) // in bytes -- default: 1 kB
        .appFont("MyFont.ttf")      // located in the directory "assets/fonts/"
        .imageCacheInMemory(true)   // default: false
        .imageCacheOnDisk(true)     // default: false
        .imageFadeInDuration(300);  // in ms -- default: 0 ms

AcnActivity (abstract class, extends AppCompatActivity)

  • Activity class that extends AcnActivity needs to provide required params inside constructor method:
super.build(this)
        .contentRes(R.layout.my_activity)   // required
        .toolbarRes(R.id.toolbar)           // required
        .backButtonRes(R.id.back_button)    // nullable
        .backButtonVisible(true)            // default: false
        .statusBarColor(R.color.statusBar)  // nullable
        .usesButterKnife(true)              // default: false -- required to use Butter Knife(https://github.com/JakeWharton/butterknife) features
        .usesOttoEventBus(true)             // default: false -- registers/unregisters Otto Event Bus(https://github.com/square/otto) at onResume()/onPause()
        .internetStatusListener(new InternetStatusListener() {
            @Subscribe
            public void onInternetStatusChanged(ConnectivityStatus status) {
                /*DO SOMETHING HERE*/
            }
        });

2. View classes

The following classes can be found under view package:

AcnImageView (extends FrameLayout)

  • Includes the following UI components:
  • Supports loading image from URL, drawable, and assets
    • acn_imageview.setImageFromURL("http://goo.gl/T59s3M", zoomable);
    • acn_imageview.setImageFromDrawable(R.drawable.image, zoomable);
    • acn_imageview.setImageFromAssets("image.jpg", zoomable); (located in the directory assets/)
  • Supports zoomable images
    • Set the second param of above methods to true
  • Supports custom GIF image for loading animation
    • Set the following attributes in XML:
      • app:loadingGifSrc="loading.gif" (located in the directory assets/)
      • app:loadingGifSize="80dp"
  • Custom XML attributes:
    • scaleType (enum)
      • fitCenter (default)
      • centerCrop
      • fitXY
    • loadingGifSrc (string)
    • loadingGifSize (dimension)

AcnViewPager (extends LinearLayout)

  • Includes the following UI components:
  • Set fragments and tab titles with one line of code:
    • acn_viewpager.setContent(fragments, tabTitles);
  • Supports using Font Awesome icons inside tab titles
  • Custom XML attributes:
    • indicatorColor (color)
    • dividerColor (color)
    • selectedTitleColor (color)
    • unselectedTitleColor (color)
    • tabBackgroundColor (color)
    • tabTitleSize (dimension)
  • Screenshot

AcnImagePager (extends RelativeLayout)

  • Includes the following UI components:
  • Supports loading images from URL list
    • acn_imagepager.setImagesFromURLList(imageURLs, zoomable);
  • Supports zoomable images
    • Set the second param of above method to true
  • Supports custom GIF image for loading animation
    • Set the following attributes in XML:
      • app:loadingGifSrc="loading.gif" (located in the directory assets/)
      • app:loadingGifSize="80dp"
  • Custom XML attributes:
    • selectedIndicatorColor (color)
    • unselectedIndicatorColor (color)
    • selectedIndicatorSize (dimension)
    • unselectedIndicatorSize (dimension)
    • indicatorBottomMargin (dimension)
    • loadingGifSrc (string)
    • loadingGifSize (dimension)
  • Screenshot

AcnImageGallery (extends LinearLayout)

  • Includes two or three AcnImageView components at each row, depending on columnType attribute
    • Each image has an aspect ratio of 3:2 if columnType is set to pair
    • Each image has an aspect ratio of 1:1 if columnType is set to triplet
    • No limit for number of rows
  • Supports loading images from URL list
    • acn_imagegallery.setImagesFromURLList(imageURLs);
  • Set ImageClickHandler to handle image clicks
    • acn_imagegallery.setImageClickHandler(new ImageClickHandler() { ... });
  • Supports custom GIF image for loading animation
    • Set the following attributes in XML:
      • app:loadingGifSrc="loading.gif" (located in the directory assets/)
      • app:loadingGifSize="80dp"
  • Custom XML attributes:
    • spacing (dimension)
    • columnType (enum)
      • pair (default)
      • triplet
    • loadingGifSrc (string)
    • loadingGifSize (dimension)
  • Screenshot

AcnInfiniteListView (extends FrameLayout)

  • Includes the following UI components:
    • SwipeRefreshLayout
    • ListView
  • Initialize it as follows:
    • acn_infinitelistview.init(adapter, maxNumOfItems, loadingView);
      • adapter (InfiniteListAdapter)
        • Extend it to create your own adapter
          • Override its onNewLoadRequired() method to load new items when required
          • Override its onRefresh() method to set what to do on swipe-to-refresh
      • maxNumOfItems (int)
        • To make listview prevent loading more when item count reaches this number
      • loadingView (View)
        • Footer view to be displayed while loading new items
  • Includes the following methods:
    • acn_infinitelistview.addNewItem(item); -> adds new item to list
    • acn_infinitelistview.clearList(); -> clears entire list (and triggers onNewLoadRequired())
    • acn_infinitelistview.startLoading(); -> call this before item loading starts
    • acn_infinitelistview.stopLoading(); -> call this after item loading ends
  • Screenshot

AcnImageSlideshow (extends AcnImageView)

  • Supports loading images from URL list
    • acn_imageslideshow.setImagesAndStartAnimation(imageURLs, delayInMs);
      • delayInMs -> duration of time for each image displayed
  • You need to call acn_imageslideshow.stopAnimation(); at onDestroy() of your Activity or Fragment

AcnButton (extends FancyButton)

AcnTextView (extends IconTextView)

3. Util classes

The following classes can be found under util package:

BusProvider

  • Includes static instance of Otto Event Bus
  • Use this class to register/unregister Otto Event Bus
    • BusProvider.getInstance().register(this);
    • BusProvider.getInstance().unregister(this);

InternetStatusListener (abstract class)

  • Includes abstract method onInternetStatusChanged(ConnectivityStatus status)

ImageClickHandler (abstract class)

  • Includes abstract method onImageClicked(int position, String imageURL)

InfiniteListAdapter (abstract class, extends ArrayAdapter)

  • Constructor takes the following params:
    • activity (Activity)
    • itemLayoutRes (int)
      • e.g., R.layout.item_text
    • itemList (ArrayList)
  • Includes abstract methods onNewLoadRequired() and onRefresh()

4. How to use

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency:

dependencies {
    compile 'com.github.ugurcany:acn-android-framework:X.Y.Z'
}

Step 3. To be able to use all features of the framework, add the corresponding dependencies for the following libraries:

5. License

The MIT License (MIT)

Copyright (c) 2016 Ugurcan Yildirim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].