effects for android notifications

Overview

#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.

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

    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.

    opened by Hesamedin 6
  • How can we solve this issue?

    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

    opened by MerliEsc 5
  • Toast goes behind when Fragment changes

    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

    opened by Hesamedin 4
  • Null pointer exception

    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();
        }
    }
    
    bug 
    opened by Hesamedin 3
  • how to create animation before dismiss dialog

    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.

    opened by DoaiNguyen 1
  • NiftyNotification starts after 5-10 second delay.

    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

    opened by ashokslsk 1
  • How to specify NiftyNotificationView position?

    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.

    opened by yangjiheng 1
  • show(isRepeat) doesn't work

    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

    opened by Hesamedin 1
Releases(1.2)
Owner
李涛
李涛
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
Parallax everywhere is a library with alternative android widgets with parallax effects.

Parallax Everywhere# Parallax everywhere (PEW) is a library with alternative android views using parallax effects. Demo You can try the demo app on go

fmSirvent 712 Nov 14, 2022
Library for creating blur effects under Android UI elements

BlurTutorial Meet BlurTutorial, an Android-based library made by Cleveroad Hurry to check our newest library that helps to blur the background in Andr

Cleveroad 150 Dec 16, 2022
Sliding cards with pretty gallery effects.

SlidingCard Sliding cards with pretty gallery effects. Download Include the following dependency in your build.gradle file. Gradle: repositories {

mxn 681 Sep 7, 2022
Draggable views with rotation and skew/scale effects

DraggableView Draggable views with rotation and skew/scale effects. Usage Implement DragController.IDragViewGroup Create instance of DragController Ov

Eugene Levenetc 562 Nov 11, 2022
A Jetpack Compose library with blur, pixelate, and other effects to keep your designer happy. Inspired by iOS UIVisualEffectView.

A Jetpack Compose library with blur, pixelate, and other effects to keep your designer happy. Inspired by iOS UIVisualEffectView.

清茶 67 Dec 30, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Dec 6, 2022
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Txus Ballesteros 1.5k Jan 2, 2023
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Muthuramakrishnan Viswanathan 1.2k Dec 30, 2022
A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out

FabricView - A new canvas drawing library for Android. The library was born as part of a project in SD Hacks (www.sdhacks.io) on October 3rd. It is cu

Antwan Gaggi 1k Dec 13, 2022
MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.

About MarkdownView (Markdown For Android) is an Android library that helps you display Markdown text or files (local/remote) as formatted HTML, and st

Feras Alnatsheh 1k Dec 20, 2022
SwipeBack for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swipe gesture

SwipeBack SwipeBack is for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swi

Hannes Dorfmann 697 Dec 14, 2022
A backport of the SwitchPreference component that was introduced on Android 4 (ICS / level 14). This port works on Android 2.1+ (Eclair MR1 / level 7).

Android Switch Preference Backport A backport of the SwitchPreference component that was introduced on Android 4 (ICS / level 14). This port works on

Benoit Lubek 498 Dec 29, 2022
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)

Wizard Pager Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (ht

Julián Suárez 520 Nov 11, 2022
Make your native android Toasts Fancy. A library that takes the standard Android toast to the next level with a variety of styling options. Style your toast from code.

FancyToast-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ... ma

Shashank Singhal 1.2k Dec 26, 2022
Make your native android Dialog Fancy. A library that takes the standard Android Dialog to the next level with a variety of styling options. Style your dialog from code.

FancyAlertDialog-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ..

Shashank Singhal 350 Dec 9, 2022
Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#

Xamarin.Android Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#. Build Status Platform

Xamarin 1.8k Jan 5, 2023