Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to deal with 'JObject cannot be IntPtr.Zero' in listview item ?

$
0
0

I have a page in my app, where I show a list of files and their download progress ( using a progress bar).

Each list item looks like this:
image

Each list item is a custom cell, which I have rendered.
The view model (data) of each list item , looks something like this:

`public class FileEntry : ViewModel
{
private string _filename;
private long _totalsize;
private long _downloadedsize;
private DownloadFileStatus _downloadStatus;

    public string FileName{
        get {
            return _filename;
        }
        set {
            _filename = value;
        }
    }

    public long TotalSize{
        get {
            return _totalsize;
        }
        set {
            _totalsize = value;
        }
    }

    public long DownloadedSize{
        get {
            return _downloadedsize;
        }
        set {
            _downloadedsize = value;
            OnPropertyChanged("DownloadedSize");

        }
    }


    public FileEntry(LocalFile localFile){
        this._filename = localFile.Name;
        this._totalsize = localFile.Size;
        this._downloadedsize = 0L;
    }
}`

The custom cell has been bound to the above data model.

The Page's view model has a List of FileEntry objects, which is the ItemSource for the list view.

The progress bar in each list item is updated , when the DownloadedSize property's OnPropertyChanged is called. (Using OnCellPropertyChanged)

But when I try to move between pages, and come back to the download page, I get the following error,

`FATAL EXCEPTION: main

E/AndroidRuntime(28441): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

E/AndroidRuntime(28441): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)

E/AndroidRuntime(28441): at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(28441): Caused by: java.lang.reflect.InvocationTargetException

E/AndroidRuntime(28441): at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(28441): at java.lang.reflect.Method.invoke(Method.java:525)

E/AndroidRuntime(28441): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)

E/AndroidRuntime(28441): ... 2 more

E/AndroidRuntime(28441): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.

E/AndroidRuntime(28441): Parameter name: jobject

E/AndroidRuntime(28441): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue*) <0x0014c>

E/AndroidRuntime(28441): at Android.Views.View.set_Visibility (Android.Views.ViewStates) <0x00177>

E/AndroidRuntime(28441): at TCMobile.Droid.FilesDownloadListItemRenderer.setProgressBarVisibility (bool) <0x0003f>

E/AndroidRuntime(28441): at TCMobile.Droid.FilesDownloadListItemRenderer.OnCellPropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <0x0008f>

E/AndroidRuntime(28441): at Xamarin.Forms.Platform.Android.CellRenderer.OnGlobalCellPropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <0x00087>

E/AndroidRuntime(28441): at Xamarin.Forms.BindableObject.OnPropertyChanged (string) <0x0004f>

E/AndroidRuntime(28441): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty,Xamarin.Forms.BindableObject/BindablePropertyContext,object,bool,Xamarin.Forms.BindableObject/SetValueFlags,bool) <0x0028b>

E/AndroidRuntime(28441): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,Xamarin.Forms.BindableObject/SetValueFlags,Xamarin.Forms.BindableObject/SetValuePrivateFlags) <0x00503>

E/AndroidRuntime(28441): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,Xamarin.Forms.BindableObject/SetValueFlags) <0x00037>

E/AndroidRuntime(28441): at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) <0x00567>

E/AndroidRuntime(28441): at Xamarin.Forms.BindingExpression.Apply (bool) <0x0009b>

E/AndroidRuntime(28441): at Xamarin.Forms.BindingExpression/BindingExpressionPart.b__c () <0x00023>

E/AndroidRuntime(28441): at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>

E/AndroidRuntime(28441): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>

E/AndroidRuntime(28441): at (wrapper dynamic-method) object.789dfa56-d04a-4423-97fb-9e1ef27f32a7 (intptr,intptr) <0x0003b>

E/AndroidRuntime(28441):

E/AndroidRuntime(28441): at mono.java.lang.RunnableImplementor.n_run(Native Method)

E/AndroidRuntime(28441): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)

E/AndroidRuntime(28441): at android.os.Handler.handleCallback(Handler.java:730)

E/AndroidRuntime(28441): at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime(28441): at android.os.Looper.loop(Looper.java:213)

E/AndroidRuntime(28441): at android.app.ActivityThread.main(ActivityThread.java:5225)

E/AndroidRuntime(28441): ... 5 more`

Is there any way to avoid this ?

I have seen a bug raised in Bugzilla , similar to this.. https://bugzilla.xamarin.com/show_bug.cgi?id=24286


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>