Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Compiler complains passing TrayStorage.Type.USER #73

Closed
jonameson opened this issue Jul 22, 2016 · 5 comments
Closed

Compiler complains passing TrayStorage.Type.USER #73

jonameson opened this issue Jul 22, 2016 · 5 comments

Comments

@jonameson
Copy link

jonameson commented Jul 22, 2016

The following causes the compiler to complain; TrayStorage.Type.USER needs to be an int.

private class MyPreference extends TrayPreferences {
    public MyPreference(@NonNull final Context context) {
        super(context, "myModule", VERSION, TrayStorage.Type.USER);
    }
}
@jannisveerkamp
Copy link
Contributor

This is correct. The third Parameter has to be an int: The Version Code.

You didn't define it. Add

private static final int VERSION = 1;

to your class and you should be fine. You can also remove the last Parameter since its the standard behavior (TrayStorage.Type.USER).

@jonameson
Copy link
Author

Hey, thanks for the quick reply. So the issue is not the VERSION param. I'm just saying that the constructors 4th param should be an enum of type "TrayStorage.Type". Or the "TrayStorage.Type" should be int and not enums. You guys should possible properly define that unless I'm not understanding something... :P

@jannisveerkamp
Copy link
Contributor

I'm not sure if I understand you correctly. You can pass 4 Parameters into the Constructor:

  1. A context (Type: Context)
  2. The name of the module (Type: String)
  3. The version code (Type: int)
  4. (optional) A storage type (Type: TrayStorage.Type)

Your posted Code should work if you define VERSION as an int.

@jonameson
Copy link
Author

Ah, you are correct. I was incorrectly using the constructor override. I was trying to pass the TrayStorage.Type as an int. My apologies. :/

@jannisveerkamp
Copy link
Contributor

You're welcome 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants