Skip to content

An android library for displaying Facebook/Instagram inspired feeds

License

Notifications You must be signed in to change notification settings

mkamals1989/ImageFeedView

 
 

Repository files navigation

ImageFeedView

Download Build Status

A simple Android library for creating data feeds so that data can be loaded dynamically as the user scrolls. This is inspired by scrolling through photos on Facebook or Instagram.

This is still a work in progress. See TODO

This library uses GestureViews for its photo viewer and wraps this for easy usage with a feed.

This is roughly based on the FeedCollectionViewController library for Swift that you can find here

Example

To run the example project, clone the repo, and run the sample configuration. The example project demonstrates the functionality without using any actual content, it creates coloured images to illustrate its use with a large amount of content.

Installation

Through build.gradle:

compile 'com.oliveroneill:imagefeedview:1.0.2'

Usage

To set up a feed, you need to extend ImageFeedView with your image class:

class ExampleImageFeedView : ImageFeedView<ExampleImageClass> {
    constructor(ctx: Context) : super(ctx)
    constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs)
}

Then use this class in your layout file:

<com.oliveroneill.imagefeedview.ImageFeedView
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Then implement an ImageFeedController for loading images:

    override fun loadImage(item: ExampleImageClass, imgView:ImageView, listener: LoadListener?) {
        // TODO
    }

    override fun recycleImage(imgView:ImageView) {
        // TODO
    }

    override fun clear() {
        // TODO
    }

Then set up an ImageFeedConfig:

val config = ImageFeedConfig(controller)
        .setToolbar(toolbar)
        .setTranslucentStatusBar(true)
feed.show(config)

For custom grid items or photo viewers, use setGridAdapter(adapter : PhotoListAdapter<T>) and setPagerAdapter(adapter : PhotoPagerAdapter<T>).

Testing

Testing is done through JUnit, these tests are located in the imagefeedview project.

Todo

  • Figure out why double tap breaks with data uri images when loaded a second time
  • Set placeholder images
  • Make pager toolbar easily configurable
  • Make grid item views configurable
  • Make pager item views configurable (specify a common layout and have simple setters for that)
  • Allow custom error messages

Author

Oliver O'Neill

License

ImageFeedView is available under the MIT license. See the LICENSE file for more info.

About

An android library for displaying Facebook/Instagram inspired feeds

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%