this version is for extensions
This commit is contained in:
parent
20db4a554d
commit
9f601c86d0
|
@ -25,9 +25,12 @@ import android.os.Parcelable;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||||
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
|
import com.bluelinelabs.logansquare.annotation.OnJsonParseComplete;
|
||||||
|
import com.hannesdorfmann.parcelableplease.annotation.Bagger;
|
||||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelableNoThanks;
|
import com.hannesdorfmann.parcelableplease.annotation.ParcelableNoThanks;
|
||||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||||
|
|
||||||
|
import org.mariotaku.twidere.api.twitter.model.util.ParcelMapBagger;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -45,8 +48,9 @@ public class CardEntity implements Parcelable {
|
||||||
String url;
|
String url;
|
||||||
|
|
||||||
@JsonField(name = "binding_values")
|
@JsonField(name = "binding_values")
|
||||||
HashMap<String, RawBindingValue> rawBindingValues;
|
|
||||||
@ParcelableNoThanks
|
@ParcelableNoThanks
|
||||||
|
Map<String, RawBindingValue> rawBindingValues;
|
||||||
|
@Bagger(BindingValueMapBagger.class)
|
||||||
Map<String, BindingValue> bindingValues;
|
Map<String, BindingValue> bindingValues;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -88,7 +92,7 @@ public class CardEntity implements Parcelable {
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface BindingValue {
|
public interface BindingValue extends Parcelable {
|
||||||
|
|
||||||
String TYPE_STRING = "STRING";
|
String TYPE_STRING = "STRING";
|
||||||
String TYPE_IMAGE = "IMAGE";
|
String TYPE_IMAGE = "IMAGE";
|
||||||
|
@ -387,4 +391,10 @@ public class CardEntity implements Parcelable {
|
||||||
return new CardEntity[size];
|
return new CardEntity[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static class BindingValueMapBagger extends ParcelMapBagger<BindingValue> {
|
||||||
|
public BindingValueMapBagger() {
|
||||||
|
super(BindingValue.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,13 @@ import android.support.annotation.StringDef;
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||||
|
import com.hannesdorfmann.parcelableplease.annotation.Bagger;
|
||||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||||
|
|
||||||
|
import org.mariotaku.twidere.api.twitter.model.util.ParcelMapBagger;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,10 +38,12 @@ public class DMResponse implements Parcelable {
|
||||||
long lastSeenEvent;
|
long lastSeenEvent;
|
||||||
|
|
||||||
@JsonField(name = "users")
|
@JsonField(name = "users")
|
||||||
HashMap<String, User> users;
|
@Bagger(UserMapBagger.class)
|
||||||
|
Map<String, User> users;
|
||||||
|
|
||||||
@JsonField(name = "conversations")
|
@JsonField(name = "conversations")
|
||||||
HashMap<String, Conversation> conversations;
|
@Bagger(ConversationMapBagger.class)
|
||||||
|
Map<String, Conversation> conversations;
|
||||||
|
|
||||||
@JsonField(name = "entries")
|
@JsonField(name = "entries")
|
||||||
Entry[] entries;
|
Entry[] entries;
|
||||||
|
@ -278,7 +282,8 @@ public class DMResponse implements Parcelable {
|
||||||
@Status
|
@Status
|
||||||
String status;
|
String status;
|
||||||
@JsonField(name = "type")
|
@JsonField(name = "type")
|
||||||
Type type;
|
@Type
|
||||||
|
String type;
|
||||||
|
|
||||||
public Participant[] getParticipants() {
|
public Participant[] getParticipants() {
|
||||||
return participants;
|
return participants;
|
||||||
|
@ -304,14 +309,9 @@ public class DMResponse implements Parcelable {
|
||||||
return notificationsDisabled;
|
return notificationsDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Type {
|
@StringDef({Type.ONE_TO_ONE, Type.GROUP_DM})
|
||||||
ONE_TO_ONE("one_to_one"), GROUP_DM("group_dm");
|
public @interface Type {
|
||||||
|
String ONE_TO_ONE = "one_to_one", GROUP_DM = "group_dm";
|
||||||
private final String literal;
|
|
||||||
|
|
||||||
Type(String literal) {
|
|
||||||
this.literal = literal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParcelablePlease
|
@ParcelablePlease
|
||||||
|
@ -398,4 +398,16 @@ public class DMResponse implements Parcelable {
|
||||||
return new DMResponse[size];
|
return new DMResponse[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static class UserMapBagger extends ParcelMapBagger<User> {
|
||||||
|
public UserMapBagger() {
|
||||||
|
super(User.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConversationMapBagger extends ParcelMapBagger<Conversation> {
|
||||||
|
public ConversationMapBagger() {
|
||||||
|
super(Conversation.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,14 @@ import android.support.annotation.StringDef;
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||||
|
import com.hannesdorfmann.parcelableplease.annotation.Bagger;
|
||||||
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
|
||||||
|
|
||||||
|
import org.mariotaku.twidere.api.twitter.model.util.ParcelMapBagger;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +63,8 @@ public class MediaEntity extends UrlEntity implements Parcelable {
|
||||||
@Type
|
@Type
|
||||||
String type;
|
String type;
|
||||||
@JsonField(name = "sizes")
|
@JsonField(name = "sizes")
|
||||||
HashMap<String, Size> sizes;
|
@Bagger(SizeMapBagger.class)
|
||||||
|
Map<String, Size> sizes;
|
||||||
@JsonField(name = "source_status_id")
|
@JsonField(name = "source_status_id")
|
||||||
long sourceStatusId;
|
long sourceStatusId;
|
||||||
@JsonField(name = "source_user_id")
|
@JsonField(name = "source_user_id")
|
||||||
|
@ -69,7 +72,8 @@ public class MediaEntity extends UrlEntity implements Parcelable {
|
||||||
@JsonField(name = "video_info")
|
@JsonField(name = "video_info")
|
||||||
VideoInfo videoInfo;
|
VideoInfo videoInfo;
|
||||||
@JsonField(name = "features")
|
@JsonField(name = "features")
|
||||||
HashMap<String, Feature> features;
|
@Bagger(FeaturesMapBagger.class)
|
||||||
|
Map<String, Feature> features;
|
||||||
@JsonField(name = "ext_alt_text")
|
@JsonField(name = "ext_alt_text")
|
||||||
String altText;
|
String altText;
|
||||||
|
|
||||||
|
@ -470,4 +474,16 @@ public class MediaEntity extends UrlEntity implements Parcelable {
|
||||||
return new MediaEntity[size];
|
return new MediaEntity[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static class SizeMapBagger extends ParcelMapBagger<Size> {
|
||||||
|
public SizeMapBagger() {
|
||||||
|
super(Size.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FeaturesMapBagger extends ParcelMapBagger<Feature> {
|
||||||
|
public FeaturesMapBagger() {
|
||||||
|
super(Feature.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.mariotaku.twidere.api.twitter.model.util;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.hannesdorfmann.parcelableplease.ParcelBagger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mariotaku on 16/4/28.
|
||||||
|
*/
|
||||||
|
public abstract class ParcelMapBagger<T extends Parcelable> implements ParcelBagger<Map<String, T>> {
|
||||||
|
private final Class<T> cls;
|
||||||
|
|
||||||
|
protected ParcelMapBagger(Class<T> cls) {
|
||||||
|
this.cls = cls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void write(Map<String, T> value, Parcel out, int flags) {
|
||||||
|
if (value == null) {
|
||||||
|
out.writeInt(-1);
|
||||||
|
} else {
|
||||||
|
int size = value.size();
|
||||||
|
out.writeInt(size);
|
||||||
|
for (Map.Entry<String, T> entry : value.entrySet()) {
|
||||||
|
out.writeString(entry.getKey());
|
||||||
|
out.writeParcelable(entry.getValue(), flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Map<String, T> read(Parcel in) {
|
||||||
|
int size = in.readInt();
|
||||||
|
if (size < 0) return null;
|
||||||
|
HashMap<String, T> map = new HashMap<>();
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
final String key = in.readString();
|
||||||
|
final T value = in.readParcelable(cls.getClassLoader());
|
||||||
|
map.put(key, value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,8 +21,8 @@ android {
|
||||||
applicationId "org.mariotaku.twidere"
|
applicationId "org.mariotaku.twidere"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 194
|
versionCode 195
|
||||||
versionName "3.1.6.1"
|
versionName "3.1.6.2"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
|
|
Loading…
Reference in New Issue