Code Monkey home page Code Monkey logo

enhanced-content-layout's Introduction

enhanced-content-layout

A wrapper layout which allows easy integration of swipe to refresh and showing progress and messages.

Including the layout

In Layout XML

Wrap the content you want to enhance in the EnhancedContentLayout. Kepp in mind that the wrapped views will be invisible when showing a message etc. (e.g. you probably want to wrap toolbars etc.). Example:

<de.virality.enhancedcontentlayout.EnhancedContentLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/enahncedContent">

    ...

</de.virality.enhancedcontentlayout.EnhancedContentLayout>

With direkt instantiation

If you want to wrap the complete layout (for example in a fragment) you can directly instantiate it. Example:

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    enhancedContent = new EnhancedContentLayout(getContext(), R.layout.some_fragment, container);
    ...
    wrappedRecyclerView = (RecyclerView) enhancedContent.findViewById(R.id.recycler_view);
    ...
    enhancedContent.showProgress();
    ...
    return enhancedContent;
}

Use the enhanced features

Show a message

enhancedContent.showMessage(R.string.some_message);
enhancedContent.showMessage("Some message");

Useful for showing errors or empty messages (for lists). Hides the content and simply shows a message at the top of the layout.

Show progress

enhancedContent.showProgress();

Hides the content and shows a progressBar in the center of the layout.

Show content

enhancedContent.showContent();

Hides all other features (message, progressBar, ...) and shows the original content again (child views of the layout).

Enable Swipe to refresh

enhancedContent.enableSwipeToRefresh(@NonNull OnRefreshListener listener);

Enables swipe to refresh on the layout and calls the onRefresh() method when the the user pulls down the content.

ToDo

  • Make message position customizable (e.g. allow to position it in the center)
  • Allow to pass an optional String and OnClickListener to showMessage which then shows a button with the text and calls back on click. E.g. for error messages, this allows to add a "retry" button.
  • More customizations (e.g. background color, images, ...)
  • ...

enhanced-content-layout's People

Contributors

bisinger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.