Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Visibility Converter - Android - Release (MvvmCross)

I've developed an application for Android using MvvmCross. There is a part of it in which it should show either a ImageView or a MvxImageView. When i test it in debug mode it works fine, but when i change it to release mode the visibility converter seem to stop working. All the other converters work they way the should, only those converters stop working.

A resume from my xml:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">
    <ImageView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:scaleType="fitCenter"
        local:MvxBind="Visibility MyObject, Converter=ByteInverseVisibility; AssetImagePath MyObject, Converter=AttachmentTypeToSource" />
    <Mvx.MvxImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:maxHeight="150dp"
        android:adjustViewBounds="true"
        local:MvxBind="Visibility MyObject, Converter=ByteVisibility; Bitmap MyObject.Attachment, Converter=InMemoryImage" />
</LinearLayout>

The Converters:

public class ByteVisibilityConverter : MvxBaseVisibilityValueConverter<MyObjectClass>
{
    protected override MvxVisibility Convert(MyObjectClass value, object parameter, CultureInfo culture)
    {
        if (value.AttachType == AttachmentType.Photo && value.Attachment != null)
        {
            return MvxVisibility.Visible;
        }

        return MvxVisibility.Collapsed;
    }
}

public class ByteInverseVisibilityConverter : MvxBaseVisibilityValueConverter<MyObjectClass>
{
    protected override MvxVisibility Convert(MyObjectClassvalue, object parameter, CultureInfo culture)
    {
        if (value.AttachType != AttachmentType.Photo || value.Attachment == null)
        {
            return MvxVisibility.Visible;
        }

        return MvxVisibility.Collapsed;
    }
}
like image 962
Daniel Avatar asked Jan 31 '26 15:01

Daniel


1 Answers

The reason is because that the Visibility property is not being included in the packaging.

You gotta add something like:

public void Include(ImageView imageView)
    {
        imageView.Visibility = imageView.imageView;
    }

In your LinkerPleaseInclude.cs file.

like image 52
Gabriel Bastos Avatar answered Feb 03 '26 06:02

Gabriel Bastos