Coder Social home page Coder Social logo

andhud's Introduction

AndHUD

AndHUD is a Progress / HUD library for Android which allows you to easily add amazing HUDs to your app!

Features

  • Spinner (with and without Text)
  • Progress (with and without Text)
  • Image (with and without Text)
  • Success / Error (with and without Text)
  • Toasts
  • Xamarin.Android Support
  • Xamarin Component store
  • Similar API and functionality to BTProgressHUD for iOS
  • XHUD API to help be compatible with BTProgressHUD's API (also has XHUD API)

Quick and Simple

//Show a simple status message with an indeterminate spinner
AndHUD.Shared.Show(myActivity, "Status Message", -1, MaskType.Clear);

//Show a progress with a filling circle representing the progress amount
AndHUD.Shared.Show(myActivity, "Loading… 60%", 60);

//Show a success image with a message
AndHUD.Shared.ShowSuccess(myActivity, "It Worked!", MaskType.Clear, TimeSpan.FromSeconds(2));

//Show an error image with a message
AndHUD.Shared.ShowError(myActivity, "It no worked :()", MaskType.Black, TimeSpan.FromSeconds(2));

//Show a toast, similar to Android native toasts, but styled as AndHUD
AndHUD.Shared.ShowToast(myActivity, "This is a non-centered Toast…", MaskType.Clear, TimeSpan.FromSeconds(2));

//Show a custom image with text
AndHUD.Shared.ShowImage(myActivity, Resource.Drawable.MyCustomImage, "Custom");

//Dismiss a HUD that will or will not be automatically timed out
AndHUD.Shared.Dismiss(myActivity);

//Show a HUD and only close it when it's clicked
AndHUD.Shared.ShowToast(this, "Click this toast to close it!", MaskType.Clear, null, true, () => AndHUD.Shared.Dismiss(this));

Collage of Possible HUDs

Changes

v1.4.3

  • Fixed crashes when hud is dismissing itself while Activity or Window is tearing down

v1.4.2

  • Fixed text not being centered correctly

v1.4.1

  • Fixed NullReferenceException when showing non-centered toast #38
  • Added new sample App

v1.4

  • Added prepareDialogCallback which is called right after the Dialog has been created. This can be used to customize the Dialog further.
  • Added dialogShownCallback to get notified when the Dialog has appeared on the screen.
  • Updated Target Framework to Android Oreo 8.1
  • A plethora of bug fixes
    • Fixed Null Ref when trying to update progress wheel
    • Fixed Null Ref when trying to set an image on the HUD
    • Removed duplicate Dismiss call from showStatus
    • Prevent exceptions when trying to show/close hud, when Activity is dead or in background
    • Remove obsolete call to GetDrawable
    • Fixed MaskType conversion from XHUD to AndHUD

v1.3

  • Added cancelCallback parameter to allow dialogs to be cancellable
  • Added XHUD API to be compatible with BTProgressHUD
  • Renamed custom attributes to try and avoid collisions with other projects

v1.2

  • Made all resources lowercase to work around a Xamarin.Android bug
  • Changed all method signatures to request a Context now instead of Activity

v1.1

  • Target version now set to 3.1 (API Level 12), but can be used on 2.3 (API Level 9) and newer (anything below API Level 12 will lose the smooth animation for the progress indicator).

Other Options

  • MaskType: By default, MaskType.Black dims the background behind the HUD. Use MaskType.Clear to prevent the dimming. Use MaskType.None to allow interaction with views behind the HUD.
  • Timeout: If you provide a timeout, the HUD will automatically be dismissed after the timeout elapses, if you have not already dismissed it manually.
  • Click Callback: If you provide a clickCallback parameter, when the HUD is tapped by the user, the action supplied will be executed.
  • Cancel Callback: If you provide a cancelCallback parameter, the HUD can be cancelled by the user pressing the back button, which will cause the cancelCallback action to be executed.

Thanks

Thanks to Nic Wise (@fastchicken) who inspired the creation of this with his component BTProgressHUD (https://components.xamarin.com/view/btprogresshud/). It was so awesome for iOS that I needed to have it on Android as well :)

andhud's People

Contributors

beeradmoore avatar cheesebaron avatar gerryhigh avatar ghigh avatar martijn00 avatar redth 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

andhud's Issues

AndHUD.Shared.Dismiss on a view that had been closed causes exception - how to handle this?

Hi all, hi @Redth,

First of all, thank you for another great component (like PushSharp) and this AndHud.

I've got a WebView. On the webview I've added two eventHandlers for OnPageStarted and OnPageFinished. Both call AndHUD.Shared.Show and AndHUD.Shared.Dismiss and this works perfectly.

Then the following situation. I execute the this Javascript inside the WebView:

<div style="display: none">
<a href="https://myhost.com/default.aspx#appclosecommand" id="CloseThisView" class="btn btn-success">Continue</a>
</div>
<script type="text/javascript">
var link = document.getElementById('CloseThisView'),
event = document.createEvent('HTMLEvents');

event.initEvent('click', true, true);
link.dispatchEvent(event);
</script>

I catch this event using:

public override bool ShouldOverrideUrlLoading(WebView view, string url)

Then I use the Close command from MvvmCross inside the ViewModel:

private void GoToDashboardCommandExecute()
{
 Close(this);
}

This causes the view to close. This works nice. But, after this, the 'OnPageFinished' is called. And by that, the AndHUD.Shared.Dismiss is called. On a view that doesn't exist anymore. Causing an illigalargument-exception.

How can I handle this nicely? Perhaps I can do a check before calling Dismiss. For now I've got try-catch around the Dismiss method, but that ain't the nicest solution I think.

Any help/tips would be appriciated.

Many thanks in advance,
Eric

11-12 09:25:30.599 E/WindowManager( 3020): Activity md5ac38a9d6af40b058a648f5e3b4a2d104.OnlineView has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@428f3f30 that was originally added here
11-12 09:25:30.599 E/WindowManager( 3020): android.view.WindowLeaked: Activity md5ac38a9d6af40b058a648f5e3b4a2d104.OnlineView has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@428f3f30 that was originally added here
11-12 09:25:30.599 E/WindowManager( 3020): at android.view.ViewRootImpl.(ViewRootImpl.java:380)
11-12 09:25:30.599 E/WindowManager( 3020): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
11-12 09:25:30.599 E/WindowManager( 3020): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
11-12 09:25:30.599 E/WindowManager( 3020): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
11-12 09:25:30.599 E/WindowManager( 3020): at android.view.Window$LocalWindowManager.addView(Window.java:547)
11-12 09:25:30.599 E/WindowManager( 3020): at android.app.Dialog.show(Dialog.java:277)
11-12 09:25:30.599 E/WindowManager( 3020): at md5bcb6a4543e7a4af455649c39f2e90558.MyWebViewClient.n_onPageStarted(Native Method)
11-12 09:25:30.599 E/WindowManager( 3020): at md5bcb6a4543e7a4af455649c39f2e90558.MyWebViewClient.onPageStarted(MyWebViewClient.java:39)
11-12 09:25:30.599 E/WindowManager( 3020): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:325)
11-12 09:25:30.599 E/WindowManager( 3020): at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 09:25:30.599 E/WindowManager( 3020): at android.os.Looper.loop(Looper.java:137)
11-12 09:25:30.599 E/WindowManager( 3020): at android.app.ActivityThread.main(ActivityThread.java:4838)
11-12 09:25:30.599 E/WindowManager( 3020): at java.lang.reflect.Method.invokeNative(Native Method)
11-12 09:25:30.599 E/WindowManager( 3020): at java.lang.reflect.Method.invoke(Method.java:511)
11-12 09:25:30.599 E/WindowManager( 3020): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
11-12 09:25:30.599 E/WindowManager( 3020): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
11-12 09:25:30.599 E/WindowManager( 3020): at dalvik.system.NativeStart.main(Native Method)
11-12 09:25:36.179 I/MonoDroid( 3020): UNHANDLED EXCEPTION:
11-12 09:25:36.289 I/MonoDroid( 3020): Java.Lang.IllegalArgumentException: Exception of type 'Java.Lang.IllegalArgumentException' was thrown.
11-12 09:25:36.289 I/MonoDroid( 3020): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
11-12 09:25:36.289 I/MonoDroid( 3020): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr) [0x00062] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:554
11-12 09:25:36.289 I/MonoDroid( 3020): at Android.App.Dialog.Dismiss () [0x00043] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Dialog.cs:558
11-12 09:25:36.289 I/MonoDroid( 3020): at AndroidHUD.AndHUD/c__AnonStorey4.<>m__0 () <IL 0x0001c, 0x000d3>
11-12 09:25:36.289 I/MonoDroid( 3020): at AndroidHUD.AndHUD/c__AnonStorey4.<>m__1 (object) <IL 0x00006, 0x00057>
11-12 09:25:36.289 I/MonoDroid( 3020): at Android.App.SyncContext.Send (System.Threading.SendOrPostCallback,object) [0x00025] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:26
11-12 09:25:36.289 I/MonoDroid( 3020): at AndroidHUD.AndHUD.DismissCurrent (Android.Content.Context) <IL 0x00067, 0x003ef>
11-12 09:25:36.289 I/MonoDroid( 3020): at AndroidHUD.AndHUD.Dismiss (Android.Content.Context) <IL 0x00003, 0x0005b>

AndHUD.Shared.Show() (and others) are throwing exceptions if called back-to-back

Context: I have about three HUD displays that need to be displayed one right after another.

Error: NullReference Exception. "imageView" is null.

// In my Activity

private async void DoWork() 
{

var p = new Progress<double>();
p.ProgressChanged += (object o, double val) => {
  // Update UI with progress
  AndHUD.Shared.Show(_parentContext,@"Getting data..",val,MaskType.Black);
};

await SomeLongRunningTask(p).ContinueWith((x)=>{
  // Our first task is complete, do next long running task
  await OtherLongRunningTask(p); // Reuse 'p' as its just reporting visual progress
}).ContinueWith((x)=>{
  // We're completely done getting data, lets say so
  AndHUD.Shared.ShowSuccess(@"Done!"); // <= This right here tosses up an exception!
});

}

// In AndHUD.cs 
// Around line 286 - 290

/* ... */

Application.SynchronizationContext.Post(state => {
  imageView.SetImageDrawable(image); // imageView is NULL!
  statusText.Text = status ?? ""; // statusText is NULL!
}, null);
/* ... */

The thing is, there is another method that has this Application.SynchronizationContext.Post call... and it also fails.

Is there a certain way of calling different HUD variations back to back? Should I be manually dismissing the Huds before making the next one appear? Is there maybe a better way of doing this?

Now, I have tried adding in checks in these to see if the values are null, but I'm not sure if that will mess up anything.

AndHUD exception in Android 5.0.1 (API21) ?

Hi,

I've been using AndHud in my production application since yet with no problems and an amazing facility... thanks for your work first !

But I've made an update of my solution to target Android 5.0.1 (my test device GalasyS4 has been updated), and I got a problem...

It seems to happens at " AndroidHUD.AndHUD.ShowStatus" that was working until this update of target version.

Does anybody have this problem with Android API 21 ? is AndHUD compatible ?

EDIT : apparently this happens only in debug, not in release... maybe my configuration ?

This is my (very simple) call :

AndHUD.Shared.Show(_act, null, -1, MaskType.Clear, default(TimeSpan?), null, true, null);

And this is the stacktrace of the error :

System.Diagnostics.Debugger.Mono_UnhandledException_internal () in
System.Diagnostics.Debugger.Mono_UnhandledException (ex={Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.

--- End of managed exception stack trace ---
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
... 1 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Android.Runtime.JNIEnv.m__0 (intptr) <IL 0x0000b, 0x00080>
at Java.Lang.Object.GetObject (intptr,Android.Runtime.JniHandleOwnership,System.Type) <IL 0x0002d, 0x001c7>
at Java.Lang.Object._GetObject<Android.Views.Window> (intptr,Android.Runtime.JniHandleOwnership) <0x00107>
at Java.Lang.Object.GetObject<Android.Views.Window> (intptr,Android.Runtime.JniHandleOwnership) <0x0006f>
at Android.App.Dialog.get_Window () <IL 0x00054, 0x00203>
at AndroidHUD.AndHUD/c__AnonStorey3.<>m__0 (object) <IL 0x00040, 0x00177>
at Android.App.SyncContext.Send (System.Threading.SendOrPostCallback,object) <IL 0x00031, 0x0019b>
at AndroidHUD.AndHUD.SetupDialog (Android.Content.Context,AndroidHUD.MaskType,System.Action,System.Func4<Android.Content.Context, Android.App.Dialog, AndroidHUD.MaskType, Android.Views.View>) <IL 0x0003d, 0x00243> at AndroidHUD.AndHUD.showStatus (Android.Content.Context,bool,string,AndroidHUD.MaskType,System.Nullable1<System.TimeSpan>,System.Action,bool,System.Action) <IL 0x000cd, 0x0068b>
at AndroidHUD.AndHUD.Show (Android.Content.Context,string,int,AndroidHUD.MaskType,System.Nullable`1<System.TimeSpan>,System.Action,bool,System.Action) <IL 0x0002c, 0x0021b>
at Kiosk_Android.Activity_Web/HelloWebViewClient.OnPageStarted

Thanks for return.

Jérôme

Feature request : Ability to get an image fill for progress instead of a still image

I'm asking that now that I see you're reworking on this Nuget lately.

I don't really know how hard it would be to create here but instead of the circle fill (who's been working really great so far for me, thanks a lot for that !), would it be possible to get an image getting filled depending of the progress ?
Maybe with the idea of using 2 different pictures, one slowly covering the other ?

Thanks a lot

In Android 7.0 not showing the process

Hi We have an issue on Android 7.0,

We used the below statement to display the process percentage in Android.
Its works well till Android 6.0.1

AndHUD.Shared.Show(Forms.Context, "Loading... " + percentage + "%", percentage, MaskType.Clear);

In Andorid 7.0
It's shows always Loading...0% . Could you please help me on this.

Change message without dismissing and showing dialog

I have an issue/feature I am trying to get working. I am able to use the project just fine. However, when using the Show function I am having to show without a progress which should take me into the showStatus function. Let's say my application is processing 20 different messages. for each one that is shown it appears that the dialog is dismissing and then showing again for each message. I would rather just change the message and keep the same dialog open. So, I began looking for a solution to this. When looking at the showStatus function within AndHud is it not a bug that the function is going to call DismissCurrent (context); without any criteria? This is the 3rd statement in the function. The 4th and 5th actually has criteria before the DismissCurrent is called. Looking at the else of the "if (CurrentDialog == null)" seems like it would do what I want it to but I believe because of the dismiss that is happening it will never keep the same dialog open and just change the text. Is this correct?

Internal showStatus call Dismissing Previous Dialog no matter what.

Ln 95 of AndHUD.cs: DismissCurrent (context);
seems to be the problem.

There are already checks to dismiss the current dialog if necessary or to just update the text, and this line doesn't exist in showImage or showProgress.

Easy to see if you set the MaskType to black and try re-calling Show with no progress given.

NullReferenceException within the AndHUD.showProgress() and AndHUD.showImage()

Hi,
This is a bug that was found by the Xamarin Support. I am including their comments at the bottom.

The Xamarin Support made a patch that can be found here:
https://gist.github.com/brendanzagaeski/9376167

I downloaded master but I could not find any null-checks so I guess the "bug" is still there.

Regards

/Mats Lindestam (massemysing)

Xamarin Support Comments:
I think I've made some progress on the AndHUD issue too. The problem I was able to hit was a NullReferenceException within the
AndHUD.showProgress() and AndHUD.showImage() private methods [1]. In the debugger configuration, with the debugger attached, this caused
the IDE to pause on the uncaught exception. If I continued through the exceptions, the application would crash. In the release configuration, the
application would just crash straight away.

[1] Stack trace:
at AndroidHUD.AndHUD/c__AnonStorey1.<>m__7 (object) <IL 0x00011, 0x00058>
at Android.App.SyncContext/c__AnonStorey2E.<>m__1F () [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-
series/0deb0164/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-
series/0deb0164/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-
series/0deb0164/source/monodroid/src/Mono.Android/platforms/android-18/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.44f56ebe-39c7-495d-b5f2-18e81dfbb28d (intptr,intptr) <IL 0x00011, 0x0003b>

To stop these crashes, I tried a quick experiment of downloading the AndHUD source [2], and adding some conditional logic [3] around the
locations of the problematic null values. This seemed to help. I believe this is a bug in AndHUD. AndHUD is not properly guarding against a
condition where the progress wheel or image view has already been removed from the display. I think the interaction with Google Play Services is
coincidental.

.NET Standard 2.0 compatibility

"Package AndHUD 1.2.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0)." when installed on common library. On the Android part, everything went well.

How to solve this?

loading.axml missing content

Within our app when we call Show(this, "Please wait") from the MainActivity, the background goes dark but the Progress wheel and text is not seen. This used to work okay and works correctly in a demo app trying reproduce it, so the issue clearly lies with our xamarin forms project.

We have included the AndHUD project within our code to find the cause, and it appears that the content of Resource.Layout.loading is empty when running the code. It contains no ProgressBar and no TextView, even though they are present at design time. For example, view.FindViewById(Resource.Id.textViewStatus) within showStatus returns null.

After many days investigating we cannot find out why the content should be missing. Does anybody have any idea?

timeout callback

When passing in a timeout parameter if the timespan expires is there any callback that can fire so we know when it timedout? I see there is a cancelCallback but that only appears to be for if they hit the back button.

Long status texts are clipped

Using a longer status text, such as "Checking for new version", causes only the first few words to display, as "Checking for".

It would be better if the longer text instead caused the dialog to expand horizontally, or the text was split into multiple lines and the dialog expands vertically.

Support for .net MAUI

🚀 Feature Requests

Can this library be available for .net MAUI
We have several apps to be migrated to .net MAUI and it will be helpful to reuse this.

Platforms affected (mark all that apply)

  • 📱 iOS
  • 🤖 Android

AndHUD is not displaying properly in some cases.

I am using AndHUD for a long time and didn't get this kind of issue.

My project, When I am trying to display a HUD in a screen, it appears and disappears automatically.

This is happening only in 2 or 3 screens only, all other places, it is working fine.

I checked whether it is written multiple times or not, But it is happing in that activity where we are showing only one time.

Also, we are getting below error logs in our error reporting tool

Java.Interop
JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
Java.Interop
JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Android.App
Dialog.Dismiss ()
AndroidHUD
AndHUD+<DismissCurrent>c__AnonStorey4.<>m__0 ()
AndroidHUD
AndHUD+<DismissCurrent>c__AnonStorey4.<>m__1 (System.Object state)
Android.App
SyncContext.Send (System.Threading.SendOrPostCallback d, System.Object state)
AndroidHUD
AndHUD.DismissCurrent (Android.Content.Context context)
AndroidHUD
AndHUD.showStatus (Android.Content.Context context, System.Boolean spinner, System.String status, AndroidHUD.MaskType maskType, System.Nullable`1[T] timeout, System.Action clickCallback, System.Boolean centered, System.Action cancelCallback)
AndroidHUD
AndHUD.Show (Android.Content.Context context, System.String status, System.Int32 progress, AndroidHUD.MaskType maskType, System.Nullable`1[T] timeout, System.Action clickCallback, System.Boolean centered, System.Action cancelCallback)
MyActivity+<myfunction>d__22.MoveNext ()
java.lang.IllegalArgumentException: View=DecorView@5a985e0[] not attached to window manager
android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:552)
android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:433)
android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:131)
android.app.Dialog.dismissDialog(Dialog.java:462)
android.app.Dialog.dismiss(Dialog.java:445)
mono.android.widget.AdapterView_OnItemClickListenerImplementor.n_onItemClick(Native Method)
mono.android.widget.AdapterView_OnItemClickListenerImplementor.onItemClick(AdapterView_OnItemClickListenerImplementor.java:30)
android.widget.AdapterView.performItemClick(AdapterView.java:350)
android.widget.AbsListView.performItemClick(AbsListView.java:1683)
android.widget.AbsListView$PerformClick.run(AbsListView.java:4094)
android.widget.AbsListView$10.run(AbsListView.java:6583)
android.os.Handler.handleCallback(Handler.java:789)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:164)
android.app.ActivityThread.main(ActivityThread.java:6944)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Can you please help me how can I resolve this.

Update NuGet package

Xamarin announced that they will discontinue the component store in favor of NuGet. But the AndHUD version in the component store is 1.3.1 and on NuGet 1.2.0.

Please update the NuGet package.

Progress amount doesn't work on Android 2.3

We're develping an application for Android as minimum SDK 2.3.
The Progress component runs ok when I use an indeterminate progress (not passing progress parameter), but when we try to show the progress on the circle, passing the progress parameter, I get an error, as shown:

System.TypeLoadException: Could not load type 'Android.Animation.ValueAnimator' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.

I know the animation is not avaliable when under API Level 11 (3.0), but shouldn't this animation only affect the smoothness of the component and not be used at all when the running SDK is 2.3?

I found another person having the same problem here

Can't use AndHUD in Xamarin Forms Android project

Hi there,

I managed to get the BTProgressHUD working in my Xamarin forms (iOS) project but could not get AndHUD to work in the Xamarin Forms (Android) project. I created an interface in the PCL with project level implementations i.e. in iOS I used BTProgressHUD and Android I used AndHUD.

For Android, the hud doesn't show up at all. The code is as follows:

IHudService.cs

public interface IHudService
{
    void ShowHud(string ProgressText = "Loading...");
    void HideHud();
    void SetText(string Text);
    void SetProgress(double Progress, string ProgressText = "");
    void Toast(string message = "Hello....", bool showToastCentered = true, double timeoutMs = 10000);
}

Android implementation of IHudService i.e. HudService.cs

[assembly: Dependency(typeof(HudService))]
namespace WhatDoISay.Mobile.Droid.Services
{
    public class HudService : IHudService
    {
        Android.Views.View _load;
        bool isHudVisible;

		public void HideHud()
		{
			Device.BeginInvokeOnMainThread(() =>
			{
				AndHUD.Shared.Dismiss(Forms.Context);
				if (_load != null)
					_load.Visibility = ViewStates.Gone;
				isHudVisible = false;
			});
		}

		public void SetProgress(double Progress, string ProgressText = "")
		{
			if (!isHudVisible)
				return;
			Device.BeginInvokeOnMainThread(() =>
			{
				int progress = (int) (Progress * 100);
				AndHUD.Shared.Show(Forms.Context, ProgressText + progress + "%", progress, MaskType.Black);
			});
		}

		public void SetText(string Text)
		{
			if (!isHudVisible)
				return;
			Device.BeginInvokeOnMainThread(() =>
			{
				AndHUD.Shared.Show(Forms.Context, Text, maskType: MaskType.Black);
			});
		}

		public void ShowHud(string ProgressText = "Loading...")
		{
			Device.BeginInvokeOnMainThread(() =>
			{
				AndHUD.Shared.Show(Forms.Context, ProgressText, maskType: MaskType.Black);
				isHudVisible = true;
			});
		}

		public void Toast(string message = "Hello....", bool showToastCentered = true, double timeoutMs = 10000)
		{
			AndHUD.Shared.ShowToast(Forms.Context, message, MaskType.Black, TimeSpan.FromMilliseconds(timeoutMs), showToastCentered);
		}

		Android.Views.View CustomLoadingView(string ProgressText)
		{
			Android.Views.View loadingView = new Android.Views.View(Forms.Context);

			return loadingView;
		}
	}
}

I have a page called CategoriesPage.xaml. In this page I have a scrollview. I am invoking the hudService in the Scrolled event of the scrollview on this page as follows:

public partial class CategoriesPage : ContentPage
{
	public IHudService hudService { get; } = DependencyService.Get<IHudService>();
	private async void CategoriesScroller_Scrolled(object sender, ScrolledEventArgs e)
	{
		if (e.ScrollY < 5)
		{
			Task task = Task.Run(() =>
			{
				hudService.ShowHud();
				App.Locator.CategoriesVM.DeleteCategoriesCommand.Execute(null);
				hudService.HideHud();
			});
		}
	} 
}

Basically, I'm trying to have a "scroll down to refresh" behavior. Upon debugging, I can see that it is able to execute all the 3 lines and the methods therein but for some reason the hud does not show on Android at all.

Any ideas assistance would really be appreciated.

Thanks
Noel

Resources not found

hi..
i added component to xamarin project mono for android, but mark the 5 errors

AndroidHUD.Resource.Drawable.RoundedBg = ....Resource.Drawable.RoundedBg;
AndroidHUD.Resource.Drawable.RoundedBgDark=....Resource.Drawable.RoundedBgDark;

AndroidHUD.Resource.Layout.Loading = ....Resource.Layout.Loading;
AndroidHUD.Resource.Layout.LoadingImage = ....Resource.Layout.LoadingImage;
AndroidHUD.Resource.Layout.LoadingProgress = ...Resource.Layout.LoadingProgress;

the ....Resource.Layout not contains defintiion for Loading for every resource... some form of fix

Change Loading Color

Hello,
Its great controls. But i have an issue.
How to change color of "Loading" sipping circle.

Regards
Ankush

uncatchable java.lang.IllegalArgumentException upon configuration change

Hi!
Me again.
I am using a background process (Task) to load some viewmodels (using MvvmCross) and I just want to display the progress of this action using AndHUD.Shared.Show("loading", )
That works fine now as long as I do not change the orientation of my device. As soon as I do that, I get a java.lang.IllegarArgumentException. Unfortumately I cannot catch that with Xamarin.

To be more precise: I call "Show('loading', <someNumber) several times in my background thread. As soon as the configuration change takes place, the very next call to that method results in the "illegalArgumentException"

Might be related to the following Stackoverflow post: http://stackoverflow.com/questions/2745061/java-lang-illegalargumentexception-view-not-attached-to-window-manager

[Android 9.0] ShowToast not working with AndHUD 1.4.0

Hi,

We have an issue with ShowToast function, which throw no error but stop async execution.

We just upgraded our project from Xamarin Forms 3.1 (3.1.0.583944) to 3.4 (latest release 3.4.0.1029999), we are also now targeting Android 9.0, and AndHUD to 1.4.0.
I've done some tests, and AndHUD update is the problem.
Rollback to 1.2.0 solves the problem.
Rollback to 8.1 Android target or Xamarin Forms 3.1 didn't change issue.

NET 6 Support

🚀 Feature Requests

Compile for net6.0-android. Branch available here: https://github.com/aritchie/AndHUD

Happy to send PR

Platforms affected (mark all that apply)

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms

Method not found when called via UserDialogs

When calling UserDialogs.Instance.Progress(new ProgressDialogConfig { Title = "title" }); when using Acr.UserDialogs 7.0.1 and AndHUD 1.4.1, I get the following exception:

System.MissingMethodException has been thrown
Method not found: void AndroidHUD.AndHUD.Show(Android.Content.Context,string,int,AndroidHUD.MaskType,System.Nullable`1<System.TimeSpan>,System.Action,bool,System.Action)
  at Acr.UserDialogs.Extensions+<>c__DisplayClass2_0.<SafeRunOnUi>b__0 () [0x00000] in <73df0cb700aa467eaaf0c6c42f01763a>:0 

This works when using AndHUD 1.2.0, which makes it seem like a breaking change or bug was introduced in 1.4.1. There is a related issue in UserDialogs here.

java error code 2

Hi,
I cannot get andhud to compile in with either the nuget or the project from github.
I am using android.support v28, tried 1.41 and 1.2. Clean build remove bin and obj etc.
And help would be appreciated.

I also set to multidex enabled through project options, tried the proguard / enable disable.

Thanks,
Matt
Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error MSB6006: "java" exited with code 2.

Setting focus on load and then showing/dismissing AndHUD removes keyboard

My use case is to request focus to an EditText on CreateView or OnResume and show the soft keyboard. At the same time I'm loading data and displaying the HUD and then dismissing it.

What I've found is that the keyboard appears momentarily (barely) and then the dismiss must be removing the keyboard. Has anyone else seen this?

I've found that if I comment out the show/dismiss the keyboard remains up. I've played around with the timing some as well but currently don't have a workaround.

Add Release Notes to NuGet

Create Release Notes and add them to the NuGet so changes can be seen there, instead of having to go to this repo and read the README file.

And HUD Show spinner like disabled state when something happening on mainthread

screen shot 2018-01-19 at 2 48 40 pm

My app is a BIM app and I am using loading indicator frequently while user is working on 3d model,
The loading indicator sometimes appears like disabled(like in attached image) when we render 3d model in the background,
But we are able to convince our UAT team that this is obvious bug since both (loading indicator and 3d rendereing) are happening on main thread

But our real problem is that. AndHUD changed permanently (like in attached image) in other parts of the app as well, even though that actions are background actions.

we even tried to create new AndHUD for all loading instead of using AndHUD.Shared but still no use.

Feature request: dismiss callback

Hi, thanks for the great component!

Is it possible to add an extra parameter to Show* methods to perform an action when the HUD is dismissed? Similar to this:

// finish the current activity on click or when HUD times out
AndHUD.Shared.ShowError(this, "Fatal error",
    timeout: TimeSpan.FromSeconds(3),
    clickCallback: () => Finish(),
    dismissCallback: () => Finish());

Intermittent mono-rt dump using AndHUD within Xamarin.Forms App.

I have an intermittent problem where my app crashes with the following mono-rt dump...

[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_void_method_a (intptr,intptr&,intptr,intptr,Java.Interop.JniArgumentValue*) <0x00053>
[mono-rt]   at Java.Interop.JniEnvironment/InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference,Java.Interop.JniMethodInfo,Java.Interop.JniArgumentValue*) [0x0006c] in /Users/builder/data/lanes/3511/0e59c362/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11639
[mono-rt]   at Java.Interop.JniPeerMembers/JniInstanceMethods.InvokeVirtualVoidMethod (string,Java.Interop.IJavaPeerable,Java.Interop.JniArgumentValue*) [0x00031] in /Users/builder/data/lanes/3511/0e59c362/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:26
[mono-rt]   at Android.App.Dialog.SetContentView (Android.Views.View) [0x0002c] in /Users/builder/data/lanes/3511/0e59c362/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Dialog.cs:2160
[mono-rt]   at AndroidHUD.AndHUD/<SetupDialog>c__AnonStorey3.<>m__0 (object) <IL 0x000be, 0x00483>
[mono-rt]   at Android.App.SyncContext.Send (System.Threading.SendOrPostCallback,object) [0x00025] in /Users/builder/data/lanes/3511/0e59c362/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:26
[mono-rt]   at AndroidHUD.AndHUD.SetupDialog (Android.Content.Context,AndroidHUD.MaskType,System.Action,System.Func`4<Android.Content.Context, Android.App.Dialog, AndroidHUD.MaskType, Android.Views.View>) <IL 0x0003d, 0x0023f>
[mono-rt]   at AndroidHUD.AndHUD.showStatus (Android.Content.Context,bool,string,AndroidHUD.MaskType,System.Nullable`1<System.TimeSpan>,System.Action,bool,System.Action) <IL 0x000cd, 0x0064f>
[mono-rt]   at AndroidHUD.AndHUD.Show (Android.Content.Context,string,int,AndroidHUD.MaskType,System.Nullable`1<System.TimeSpan>,System.Action,bool,System.Action) <IL 0x0002c, 0x0021f>
[mono-rt]   at Apollo1.Droid.MainActivity.showProgress (Apollo1.Domain.ProgressEvent) [0x00059] in /Volumes/Devology/Source Code/Agile Orange Ltd/Apollo1.Mobile/Apollo1.Android/MainActivity.cs:254
[mono-rt]   at Apollo1.Droid.MainActivity/<handleProgressEvent>c__AnonStorey0.<>m__0 () [0x000c2] in /Volumes/Devology/Source Code/Agile Orange Ltd/Apollo1.Mobile/Apollo1.Android/MainActivity.cs:241
[mono-rt]   at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3511/0e59c362/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
[mono-rt]   at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/3511/0e59c362/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
[mono-rt]   at (wrapper dynamic-method) object.3f472f08-eb57-4472-a265-297a4af40e0a (intptr,intptr) <IL 0x00011, 0x0003b>
[mono-rt]   at (wrapper native-to-managed) object.3f472f08-eb57-4472-a265-297a4af40e0a (intptr,intptr) <IL 0x00021, 0x000ef>

I'm not sure whether it's something I'm doing that's funky, but it does work 99% of the time, I've raised a question on Stack Overflow with some more details about how I'm using it within Xamarin Forms (as a Xamarin Component).

Could not install package 'AndHUD 2.0.1'

🐛 Bug Report

Could not install package 'AndHUD 2.0.1'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v13.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Expected behavior

Update the package

Reproduction steps

Try to update the package in Xamarin.Android project

Configuration

Version: 2.0.1

Platform:

  • 🤖 Xamarin.Android

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.