Git Product home page Git Product logo

niftynotification's Introduction

#NiftyNotification

effects for android notifications.base on (Crouton)

Android Arsenal Build Status JitPack Maven

ScreenShot

Image

Usage

  NiftyNotificationView.build(this,msg, effect,R.id.mLyout)
      .setIcon(R.drawable.lion)    //You must call this method if you use ThumbSlider effect
      show();

<!-- ViewGroup-->
<RelativeLayout
      android:id="@+id/mLyout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >

</RelativeLayout>

Configuration

Configuration cfg=new Configuration.Builder()
      .setAnimDuration(700)
      .setDispalyDuration(1500)
      .setBackgroundColor("#FFBDC3C7")
      .setTextColor("#FF444444")
      .setIconBackgroundColor("#FFFFFFFF")
      .setTextPadding(5)                      //dp
      .setViewHeight(48)                      //dp
      .setTextLines(2)                        //You had better use setViewHeight and setTextLines together
      .setTextGravity(Gravity.CENTER)         //only text def  Gravity.CENTER,contain icon Gravity.CENTER_VERTICAL
      .build();

NiftyNotificationView.build(this,msg, effect,R.id.mLyout,cfg)
      .setIcon(R.drawable.lion)               //remove this line ,only text
      .setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      //add your code
      }
      })
      .show();                               //  show(boolean) allow duplicates   or showSticky() sticky notification,you can call removeSticky() method close it

Install

You can install using Gradle from JitPack. Add this to your build.gradle file:

	repositories {
	    maven { url "https://jitpack.io" }
	}
	
	dependencies {
	    compile 'com.github.sd6352051:NiftyNotification:1.2'
	}

Or copy this into your libs directory.

Effects

Flip, Jelly, Scale, SlideIn, SlideOnTop, Standard, ThumbSlider

License

Copyright 2014 litao.

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.

niftynotification's People

Contributors

jitpack-io avatar litao0621 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

niftynotification's Issues

Show method doesn't make toast visible after set it to hide

Hi, me again :)

I created a singleton class like this:

public class NiftyToast
{

    private static final String TAG = NiftyToast.class.getSimpleName();
    private static final int VISIBLE_TIME = 1 * 60 * 1000; // 1 minute

    private static NiftyToast instance = null;

    private static NiftyNotificationView mNiftyView = null;

    private NiftyToast()
    {

    }

    public synchronized static NiftyToast getInstance(final Activity activity, final String msg,
            int viewGroupResId)
    {
        if(NiftyToast.instance == null)
        {
            NiftyToast.instance = new NiftyToast();
        }

        if(NiftyToast.mNiftyView == null)
        {
            NiftyToast.mNiftyView = NiftyNotificationView
                    .build(activity, msg, Effects.flip, viewGroupResId, getConfig())
                    .setIcon(R.drawable.ic_launcher);
        }

        return instance;
    }

    private static Configuration getConfig()
    {
        return new Configuration.Builder()
                .setAnimDuration(700)
                .setDispalyDuration(VISIBLE_TIME)
                .setBackgroundColor("#FFBDC3C7")
                .setTextColor("#FF444444")
                .setIconBackgroundColor("#FFFFFFFF")
                .setTextPadding(5)                      //dp
                .setViewHeight(48)                      //dp
                .setTextLines(2)                        //You had better use setViewHeight and setTextLines together
                .setTextGravity(Gravity.CENTER)         //only text def  Gravity.CENTER,contain icon Gravity.CENTER_VERTICAL
                .build();
    }

    public void showNiftyToast()
    {
        mNiftyView.show();
    }

    public void hideNiftyToast()
    {
        mNiftyView.hide();
    }
}

I want to display "Searching network..." when I have no internet connection and hide it once device connected. I have created Receiver class and it's working fine. So, I have following method in my activity:

private void displayInternetRequired(boolean connectivityStatus)
    {
        NiftyToast toast = NiftyToast.getInstance(this, "Searching network...", R.id.main_frame);
        if (!connectivityStatus)
        {
            toast.showNiftyToast();
        }
        else
        {
            toast.hideNiftyToast();
        }
    }
  1. I can see toast message when there is no Internet connection
  2. Toast dismisses once Internet connected.
  3. Toast doesn't displays when there is no Internet connection.

I guess something is wrong with hide method. I appreciate if you can double check. Thanks.

How to change TypeFace

hi
is it possible to change Typeface of textview ? I would like to change font style .

tnx

NoClassDefFoundError:

i am getting this error

java.lang.NoClassDefFoundError: com.gitonway.lee.niftynotification.lib.Configuration$Builder

Toast goes behind when Fragment changes

Hi Friend, me again ;)

I have an issue and hope you have an idea :)

I have an activity. This activity contains two fragments. When activity launches first fragment displays and I display a text message as NiftyToast on top of page. Everything is working fine here.

When user click on any item in menu then first fragment replaces by second fragment. Now the problem is since NiftyToast is not context aware it is not remove from the screen. However, the bigger problem is it goes behind second fragment.

Is it possible that I always show NiftyTost on top of screen? This is an screenshot for your reference. Thanks.

02

How to specify NiftyNotificationView position?

Hi,

First of all, thank you very much for the good work and sharing it to all of us. I tried the component, and it's working well. But according to the APIs available, I can only show the nitification on top of the layout, but cannot show it at any specific location that I want (for instance center of the screen, for some specific product requirements).

So I'm wondering whether it's designed this way, or I haven't found how to do it yet.

Thanks again.

how to create animation before dismiss dialog

This library is very useful and it helped to me very much. thank you very much.
Now, i want to create animation before dismiss dialog. I had try to override dismiss() and onDismissListener() method, but it's not work.
Help me! Thank you.

Null pointer exception

Hi,

I just got crash. This is log. Hope it helps

10-24 17:31:12.124: E/AndroidRuntime(23114): FATAL EXCEPTION: main
10-24 17:31:12.124: E/AndroidRuntime(23114): Process: com.passenger, PID: 23114
10-24 17:31:12.124: E/AndroidRuntime(23114): java.lang.NullPointerException
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.view.ViewConfiguration.get(ViewConfiguration.java:313)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.view.View.<init>(View.java:3455)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.view.ViewGroup.<init>(ViewGroup.java:459)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.widget.FrameLayout.<init>(FrameLayout.java:93)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.gitonway.lee.niftynotification.lib.NiftyNotificationView.initializeCroutonViewGroup(NiftyNotificationView.java:166)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.gitonway.lee.niftynotification.lib.NiftyNotificationView.initializeNotifyView(NiftyNotificationView.java:158)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.gitonway.lee.niftynotification.lib.NiftyNotificationView.getView(NiftyNotificationView.java:150)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.gitonway.lee.niftynotification.lib.Manager.addNotifyToView(Manager.java:167)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.gitonway.lee.niftynotification.lib.Manager.handleMessage(Manager.java:117)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.os.Handler.dispatchMessage(Handler.java:102)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.os.Looper.loop(Looper.java:136)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at android.app.ActivityThread.main(ActivityThread.java:5146)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at java.lang.reflect.Method.invoke(Method.java:515)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
10-24 17:31:12.124: E/AndroidRuntime(23114):    at dalvik.system.NativeStart.main(Native Method)

My code in activity

private void displayInternetRequired(boolean connectivityStatus)
    {
        mNetworkErrorToast = NiftyToast.newInstance(this, getString(R.string.network_error_msg), R.id.main_frame);
        if (!connectivityStatus)
        {
            mNetworkErrorToast.showSticky();
        }
        else
        {
            mNetworkErrorToast.removeSticky();
        }
    }

My class:

public class NiftyToast
{
    private static final String TAG = NiftyToast.class.getSimpleName();

    private static NiftyNotificationView mNiftyView = null;

    private NiftyToast()
    {

    }

    /*
     * Don't forget to add .show() at the end of instance in order to display it
     */
    public static NiftyNotificationView newInstance (final Activity activity, final String msg,
            int viewGroupResId)
    {
        return NiftyNotificationView.build(activity, msg, Effects.flip, viewGroupResId, getConfig());
    }

    private static Configuration getConfig()
    {
        return new Configuration.Builder()
                .setAnimDuration(700)
                .setDispalyDuration(5000) // This setting is not important if showSticky() uses
                .setBackgroundColor("#FFFF0000")
                .setTextColor("#FFFFFFFF")
                .setIconBackgroundColor("#FFFFFFFF")
                .setTextPadding(5) // dp
                .setViewHeight(48) // dp
                .setTextLines(2)
                .setTextGravity(Gravity.CENTER)
                .build();
    }
}

click

Have a click event?

NiftyNotification starts after 5-10 second delay.

Hi @sd6352051 great library but the notification starts after 10 seconds of my successful API call is their anyway that i can show notification immediately.

My project is also taking time load the library i have no idea why this is happening please help.

Time to load native libraries: 3 ms (timestamps 6445-6448)
com.dunst.flutter I/cr.library_loader: Expected native library version number "46.0.2490.76", actual native library version number "46.0.2490.76"
Background sticky concurrent mark sweep GC freed 18912(1711KB) AllocSpace objects, 0(0B) LOS objects, 4% free, 36MB/38MB, paused 18.953ms total 54.001ms

Add to Maven Central or jCenter

Please add your library to one of the common repositories such as Maven Central or jCenter to allow simplified usage via Gradle.

show(isRepeat) doesn't work

Hi,

Thanks for the library. I'm testing your lib and I'm not sure if I did something wrong.
I added those two jar files in my libs folder.
I want to have an sticky notification that doesn't dismiss until I say. Based on what you have in lib class (https://github.com/sd6352051/NiftyNotification/blob/master/library/src/main/java/com/gitonway/lee/niftynotification/lib/NiftyNotificationView.java#L287), I tried to use this method that compiler is saying you should use show() method. Does two jar files are old that doesn't support show(bool)?

Is it possible that I add close button to view in order the toast to be dismissed by user?

Thanks

How can we solve this issue?

Why toast is transparent when I use in fragment? See in the below image.
When I call toast in the onCreateView method, the toast works great, but when I call in the click event button the toast is transparent, any idea?
Thanks a lot for this amazing lib, good work!

screenshot 1

Cache

Possible to cache notification. If i havent close notification and if i change to page i dont want to clear still waiting.

Grandle

How can I insert this library in a grandle? Thanks in advance!

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.