Git Product home page Git Product logo

informer's Introduction

Informer

Handle network errors with elegance by providing users with error messages they can interact with. Use a simple API for showing inline and Snackbar messages to give network errors consistency across your app.

Usage

Setting up Informer is pretty straightforward. Check out the sample app for setup.

Configure

Make sure you reference jitpack.io in your root build.gradle file

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

Then add Informer to your dependencies

dependencies {
    compile 'com.github.ryansimon:informer:1.0.1'
}

Todo

Add additional examples and more thorough documentation.

License

Copyright 2016 Ryan Simon

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.

informer's People

Contributors

ryansimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tonykazanjian

informer's Issues

NetworkErrorHandler should have a flag to prevent it from being automatically dismissed when the action button is clicked

Just as a sample, the current configuration for action buttons is like this

private static void configureNoNetworkView(@NonNull final Context context,
                                               @NonNull final TextView errorMessage,
                                               @NonNull final TextView actionButton,
                                               @NonNull final NetworkErrorHandler networkErrorHandler) {
        errorMessage.setText(networkErrorHandler.mNoInternetText);
        actionButton.setText(networkErrorHandler.mNoInternetActionText);
        actionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                networkErrorHandler.dismiss();
            }
        });
    }

I propose a flag on the builder called autoDismissMsgOnActionClick with a default value of false. Which would revise the above code like so

private static void configureNoNetworkView(@NonNull final Context context,
                                               @NonNull final TextView errorMessage,
                                               @NonNull final TextView actionButton,
                                               @NonNull final NetworkErrorHandler networkErrorHandler) {
        errorMessage.setText(networkErrorHandler.mNoInternetText);
        actionButton.setText(networkErrorHandler.mNoInternetActionText);
        actionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                if(autoDismissMsgOnActionClick) networkErrorHandler.dismiss();
            }
        });
    }

The builder method would look like this

public Builder autoDismissMsgOnActionClick(boolean autoDismissMsgOnActionClick) {
            mAutoDismissMsgOnActionClick= autoDismissMsgOnActionClick;
            return this;
        }

This would solve for the use case where the user clicks the action button, but returns to the app with no changes. This is most apparent when shutting internet connection off, clicking the action button to go to wifi settings, and then coming back to the app without having turned the wifi on.

The network message is gone, and the screen is left blank. Though it's solvable by running the network code onResume again, it's a bit inconvenient.

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.