hawk icon indicating copy to clipboard operation
hawk copied to clipboard

URI create bug ?

Open giuseppesorce opened this issue 9 years ago • 5 comments

Hi when i save an object with URI, Hawk.put return true but the get does'nt work.

This is class

public class UserDataProfile {

public String displayName;
public String email;
public Uri photo;

public UserDataProfile(String displayName, String email, Uri photo) {
    this.displayName= displayName;
    this.email= email;
    this.photo=photo;
}

}

UserDataProfile userDataProfile= new UserDataProfile(acct.getDisplayName(), acct.getEmail(), acct.getPhotoUrl()); boolean bPut= Hawk.put("userDataProfile", userDataProfile);

bPut is true.. but when i get data .. return a null obj

UserDataProfile userDataProfile= Hawk.get("userDataProfile");

userDataProfile is null

giuseppesorce avatar Mar 15 '16 07:03 giuseppesorce

Hi, need to check this issue. thank for reporting

orhanobut avatar Mar 19 '16 11:03 orhanobut

Hi, I'm facing the same issue, got the following exception when converting from string (DefaultHawkFacade.java line 110) :

java.lang.RuntimeException: Failed to invoke private android.net.Uri() with no args

NameX44 avatar Nov 30 '16 09:11 NameX44

👍 Will check this issue.

orhanobut avatar Apr 02 '18 07:04 orhanobut

I also face this same problem. Hope could solve this soon. Thank you a lot

csshine avatar Apr 17 '18 10:04 csshine

find a solution. Hope could help.

link

`` public final class GsonUriParser implements Parser {

private Gson gson;

public GsonUriParser() {
}

@Override public <T> T fromJson(String content, Type type) throws JsonSyntaxException {
    if (TextUtils.isEmpty(content)) {
        return null;
    }
    this.gson = new GsonBuilder()
            .registerTypeAdapter(Uri.class, new UriDeserializer())
            .create();
    return gson.fromJson(content, type);
}

@Override public String toJson(Object body) {
    this.gson = new GsonBuilder()
            .registerTypeAdapter(Uri.class, new UriSerializer())
            .create();
    return gson.toJson(body);
}

}

csshine avatar Apr 17 '18 11:04 csshine