ARNdroid / EasyTargetDiet

Android Easy Target Diet project.
4 stars 1 forks source link

Meal: back to int (with @IntDef) #225

Closed ARNdroid closed 9 years ago

ARNdroid commented 9 years ago

Sorry. This is the way in Android Projects.

Internally we may use Enums but in public API's using Android commons patterns is the best way to do.

ARNdroid commented 9 years ago

See this ugly construction:

    public static final Parcelable.Creator<FoodsUsageEntity> CREATOR
            = new Parcelable.Creator<FoodsUsageEntity>() {

        public FoodsUsageEntity createFromParcel(Parcel in) {

            final Long id = ParcelUtils.safeFromNullReadLong(in, SENTINEL_ID);
            final String dateId = in.readString();
            final Integer meal = ParcelUtils.safeFromNullReadInteger(in, SENTINEL_INT_VALUE);
            final Integer time = ParcelUtils.safeFromNullReadInteger(in, SENTINEL_INT_VALUE);
            final String description = in.readString();
            final Float value = ParcelUtils.safeFromNullReadFloat(in, SENTINEL_FLOAT_VALUE);
            //noinspection ResourceType
            return new FoodsUsageEntity(id, dateId, meal, time, description, value);
        }

        public FoodsUsageEntity[] newArray(int size) {
            return new FoodsUsageEntity[size];
        }
    };

We just started this fix and a lot of //noinspection ResourceType shown up in our code.

To remove the directive in above example we need to construct a new method: @MealType Integer ParcelUtils.safeFromNullReadMeal(...)

Other trick methods will be necessary.

The most appealing feature of @IntDef is not increasing the size of our apk with an enum. We think the new trick methods will lose any size gain.

The result code lacks easy readability and maintainability with no advantages. It seem to be easy explaining to API clients.

We vote for closing this issue with no implementation.

alceurneto commented 9 years ago

I agree!

ARNdroid commented 9 years ago

Closed without any implementation.