Coder Social home page Coder Social logo

supertoasts's People

Contributors

daimajia avatar developer-john-p avatar hav3n avatar johnpersano avatar lsamayoa 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  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

supertoasts's Issues

API inconsistent

Change from setTextSize(int) to setTextSize(float).

mMessageTextView.setTextSize expects float, not int.

// SuperToast
public void setTextSize(int textSize) {

    mMessageTextView.setTextSize(textSize);

}

can't show SuperToasts from BroadcastReceiver on lock screen

For some reason, SuperToasts appear on the lock screen when shown from an Activity, but not from a BroadcastReceiver (they show up on the home screen below the lock screen instead - you can see them if you quickly unlock the screen while the toast is still showing).

How to transport information for OnClickWrappers?

Hi John!
Well, now I see how you want to "restore" OnClickListeners for Buttons in Toasts - using the Wrapper classes and a tag. But your example case is too simple: how should I transport information to my potentially restored OnClickListener between orientation changes? In your demo it is clear that the "potentially destructive action" which gives a toast with a button cannot use any context data, like what should restored when the button is clicked!
...that is one reason why I do not like the restoring of toasts at all!
In my use cases, I create an OnClickListener class that inherently "knows" which data is to be worked on, just because I use inner classes. That cannot be done using your model at all. What is needed is a way to maybe also give a bundle to the Wrapper for each use of the toast - and that will have to be restored on orientation change as well...
See what I mean?
Thanks!
Olaf

Compatibility with android.support.v4.widget.DrawerLayout

Hi! I'm trying to add this library to my app. I-m using android.support.v4.widget.DrawerLayout as a root layout for my activity. Do you know of any compatibility issue? I don't get any specific error but the toast doesn't appears.

Thanks!

Static creator for reference holder

The creator method in parcelable referenceholder should be static. Now it crashes when you those need need to be restored with the following exception "expected receiver of type com.github.johnpersano.supertoasts.SuperCardToast$ReferenceHolder, but got null"

setGravity() for SuperActivitiyToast

I would like to slightly adjust the position of a SuperActivityToast, but it doesn't seem to have a setGravity() method, like SuperToast does. Can this be added?

Customize toast layout (Padding, No icons...)

Hi,

very good library ! I want to be able to customize my toast layout in order to manage by myself title's and button's text/padding on SuperActivityToast.

Could it be possible to set the action button without any icon, and after that to change every padding in the toast layout ?

Thx in advance !

Naming conventions

I notice, that the naming conventions of member fields, local variables and parameters are wildly mixed in the code.

In Android, it's convention to use the prefix "m" for member fields only, not for local variables. In your code, sometimes you have member fields without any prefix but also some local variables have an "m" prefix.

Makes your code hard to read and understand. I would offer help, but I am new to github and don't know how to contribute...

Useless calls to expensive methods

In SuperCardToast as an example, I found things like this:

if (activity.findViewById(R.id.card_container) != null) {
            mViewGroup = (LinearLayout) activity
                    .findViewById(R.id.card_container);

Now, findViewById is an expensive operation - is has to travel the view hierarchy just to find a specific id. It is unnecessary to call this method twice in a row when just caching the result and checking against null would yield the same result.
Could you improve your code in this respect, please?

SuperCardToast with ViewPager

I've a Fragment that holds a ViewPager. This ViewPager has 2 fragments (let's call them, "FragmentA" and "FragmentB" as tabbed views.

Both FragmentA and FragmentB have:

As root on their XML layout.
When FragmentB is on the screen and the user presses something in there to fire a Toast the Toast is displayed, always, on FragmentA (which is not visible to the user) and not in the FragmentB (where the user is).

It should fire the Toasts in the "on screen" fragment.

Is this a bug? I can't find out a solution for this and I can't find anything on google regarding this issue.

Remove dependency on min version being API level 15

Right now if you attempt to build the project with an api level less than 15 you'll get the following error:

ERROR: Debug has an indirect dependency on Android API level 15, but minSdkVersion for variant 'Debug' is API level 9

There's really no reason why support shouldn't be given for API level 8/9.

setTypeface is misleading - it just sets the style!

I wanted to supply my own typeface to the toasts - but the method named setTypeface actually takes an int and that is just the style to apply to the internal type face that is not accessible.

This method should be named setTypefaceStyle and it would be nice to have a real setTypeface that takes an arbitrary Typeface object.

.svn files in repo?

Is it necessary to have the svn directory&files in the git repository? Somehow this leads to strange effects when cloning the git repo!

Show over dialog?

SuperActivityToast works awesome, but I want to use it from an open dialog and it shows behind the dialog. Can you change it to show above all dialogs?

Alternatively, if you could put the LinearLayout for the SuperCardToast in any views layout instead of just the main layout, this would work as well.

Define the position of the toast?

In my app it would help greatly to define how close the toast is allowed to be at the bottom edge of the screen. Because there are some elements a user might want to interact with and that gets disturbed while the toast is being displayed.
Is it possible to add an option to define the position of the toasts?

Calling cancelAllSuperActivityToasts() in onResume() leaves a SuperActivityToast permanently on screen

While I definitely like the SuperToasts be coupled tightly with the Activity to preserve context, I found the following problem:
When my activity has an active SuperActivityToast with a relatively long duration and the user leaves this activity to another one, works there and then later goes back to the activity showing the SuperActivityToast, the toast still there. This is on the other hand another "context" problem as the action that initiated this toast can be really old and forgotten.

Then, because you added your Manager classes, I figured, I might add
SuperActivityToast.cancelAllSuperActivityToasts() in my onResume() method to make sure everything is cleaned up.

But with this addition I immediately ended up in an even worse situation: the former SuperActivityToast is still displayed and never disappears.

Must be a cleanup bug in the Manager?

How to add custom animations for SuperToast?

I found there were just four system animations(ANIMATION_FADE, ANIMATION_FLYIN, ANIMATION_SCALE, ANIMATION_POPUP) in SuperToast. I want to add some other custom animations. I try to do so, but it is noneffective. Can you add some custom animations?

Floating SuperCardToast?

Have you thought in adding a 'floating' style to SuperCardToasts? Something like what Crouton does.
I really like SuperCardToast and the customization possibilities, but two things made me finally discard it:

  • The need to add a new layout in my root view
  • Because SuperCardToast moves everything down, if working with lists this forces the adapter to repaint (and remeasure) everything over and over.

It would be nice to have the possibility to display the card over the current layout

Toasts similar to iOS "touch to dismiss"

I'm working on an Android app beside iOS developers, and the client wants a toast to appear similar to the way iOS can handle them, i.e. visible until something on the screen is touched (within the app's display, ignoring Notification bar & on-screen buttons)

Is it possible to have the "touch to dismiss" option to have the touch full-screen, and the toast to remain visible until the touch event?

Thanks in advance

Return instance from setters

Have you though of letting the setters return the according SuperToasts instance?

E.g.

SuperActivityToast superActivityToast = new SuperActivityToast(activity)
.setText(
    activity.getResources().getString(R.string.added_to_deck))
.setDuration(SuperToast.Duration.LONG)
.setAnimations(SuperToast.Animations.POPUP)
.setIcon(
                R.drawable.ic_added_to_deck,
                SuperToast.IconPosition.LEFT)
.setBackground(R.color.DeepYellow)
.setTextColor(Color.WHITE)
.setTextSize(16)
.setTouchToDismiss(true)
.show();

looks more readable than

SuperActivityToast superActivityToast = new SuperActivityToast(activity);
superActivityToast.setText(
    activity.getResources().getString(R.string.added_to_deck));
superActivityToast.setDuration(SuperToast.Duration.LONG);
superActivityToast.setAnimations(SuperToast.Animations.POPUP);
superActivityToast.setIcon(
                R.drawable.ic_added_to_deck,
                SuperToast.IconPosition.LEFT);
superActivityToast.setBackground(R.color.DeepYellow);
superActivityToast.setTextColor(Color.WHITE);
superActivityToast.setTextSize(16);
superActivityToast.setTouchToDismiss(true);
superActivityToast.show();

Just a proposal.

Resources NotFoundException

Hi,

THanks man for building this nice library.
I'm doing some proof of concept test with this library.
My big big problem is I'm not able to change background of Toast based on what I want.
This is my singleton class:

public final class SuperToast {

    private static SuperToast superToast;
    private static SuperActivityToast superActivityToast;

    private SuperToast()
    {

    }

    public static SuperToast getInstance(Activity activity)
    {
        if (superToast == null  ||  superActivityToast == null)
        {
            superToast = new SuperToast();
            superActivityToast = new SuperActivityToast(activity, Style.getStyle(Style.GREEN));

            config();
        }


        return superToast;
    }

    private static void config()
    {
        superActivityToast.setIcon(R.drawable.ic_launcher, IconPosition.LEFT);
        superActivityToast.setDuration(Duration.LONG);
        superActivityToast.setAnimations(Animations.SCALE);
        superActivityToast.setTextSize(17);
    }

    public void show(String message)
    {
        superActivityToast.setText(message);
        superActivityToast.show();
    }

}

Above class work fine however if I add superActivityToast.setBackground(Color.BLACK); code inside my config file then application crashes. and this is my log:

Process: com.myteksi.passenger, PID: 23154
    android.content.res.Resources$NotFoundException: Resource ID #0xff000000
            at android.content.res.Resources.getValue(Resources.java:1195)
            at android.content.res.Resources.getDrawable(Resources.java:729)
            at android.content.res.Resources.getDrawable(Resources.java:711)
            at android.view.View.setBackgroundResource(View.java:15327)
            at com.github.johnpersano.supertoasts.SuperActivityToast.setBackground(SuperActivityToast.java:526)
            at com.test.widget.SuperToast.config(SuperToast.java:49)
            at com.test.widget.SuperToast.getInstance(SuperToast.java:36)
            at com.test.passenger.v3.fragment.book.BookingFragment.onClick(BookingFragment.java:479)
            at android.view.View.performClick(View.java:4445)
            at android.view.View$PerformClick.run(View.java:18446)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
            at dalvik.system.NativeStart.main(Native Method)

I also tried to extend your Style class and override getStyle() method but had same problem.
Any idea would be appreciated...

Decomposition required

Right now there's five completely unrelated classes. Though works fine they're too large and difficult to read. A lot of code duplication can also be avoided.
It would be great to introduce some hierarchy and maybe couple interfaces...

SuperActivityToast now showing (and not clickable) occasionally ?

I am using SuperActivityToast to show a confirmation with an optional info button (which launches another activity).

Occasionally the toast doesn't come up. Occasionally it comes up but the button is not clickable. Noticed this happens when we try using it frequently. I am using it from a fragment. Any clues ?

Code below:

    subscribeConfirmationToast = new SuperActivityToast(getActivity(), SuperToast.Type.BUTTON);
    subscribeConfirmationToast.setTouchToDismiss(true);
    subscribeConfirmationToast.setText(getResources().getString(R.string.button_subscribe_confirmation));
    subscribeConfirmationToast.setButtonIcon(R.drawable.ic_action_database, 
            getResources().getString(R.string.page_title_subscribed));
    subscribeConfirmationToast.setDuration(SuperToast.Duration.SHORT);
    subscribeConfirmationToast.setOnClickWrapper(new OnClickWrapper(this.getClass().getName(), new OnClickListener() {
        @Override
        public void onClick(View view, Parcelable token) {
            SuperActivityToast.cancelAllSuperActivityToasts();
            EventBus.getDefault().post(new Event.ShowMyShowsClicked(getActivity()));    // This will launch another activity.           
        }
    }));

public void onEventMainThread(Event.ShowSubscribed event) {
    // some other UI updations
    if(subscribeConfirmationToast != null) {
        subscribeConfirmationToast.show();
    }
   }

When I bring back an activity, the SuperToasts stays there forever

I was just puzzeled - I had a toast on screen when I switched the app. Now brought back my app, and the toast is still there - and never goes away. :-(

I do NOT use any method to save or restore toasts, as I don't want that. But the toast is just there.

Could it be that I need to do the onSave/onResume actions to make the toast go away properly? Then I would like that to be more present in the documentation. For me, I thought I just implement that if I want toasts to be persistent....

Configure Interpolator

How about choosing the animation interpolator? Like bouncing, fading, coming from left to right or the other way around?

Why onTouchListener for button click?

Using SuperCardToasts with buttons isn't working so well for me in 1.3.2.

The button seems to have an OnTouchListener that dismisses the toast before the wrapped OnClickListener is called.

Why are you using Touch listeners instead of Click listeners for the button?

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.