1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2024-12-20 20:44:05 +01:00

improved fanfou location

This commit is contained in:
Mariotaku Lee 2016-03-26 13:05:58 +08:00
parent cb7611c5cd
commit bd52cbf054

View File

@ -10,11 +10,13 @@ import android.text.TextUtils;
import android.text.style.URLSpan;
import org.mariotaku.twidere.api.statusnet.model.Attention;
import org.mariotaku.twidere.api.twitter.model.GeoLocation;
import org.mariotaku.twidere.api.twitter.model.Place;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.User;
import org.mariotaku.twidere.api.twitter.model.UserMentionEntity;
import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableLocation;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.SpanItem;
import org.mariotaku.twidere.model.UserKey;
@ -91,7 +93,7 @@ public class ParcelableStatusUtils {
result.quoted_timestamp = quoted.getCreatedAt().getTime();
result.quoted_source = quoted.getSource();
result.quoted_media = ParcelableMediaUtils.fromStatus(quoted);
result.quoted_location = ParcelableLocationUtils.fromGeoLocation(quoted.getGeoLocation());
result.quoted_location = getLocation(quoted);
result.quoted_place_full_name = getPlaceFullName(quoted);
result.quoted_user_key = UserKeyUtils.fromUser(quotedUser);
@ -158,7 +160,7 @@ public class ParcelableStatusUtils {
}
result.media = ParcelableMediaUtils.fromStatus(status);
result.source = status.getSource();
result.location = ParcelableLocationUtils.fromGeoLocation(status.getGeoLocation());
result.location = getLocation(status);
result.is_favorite = status.isFavorited();
if (result.account_key.maybeEquals(result.retweeted_by_user_key)) {
result.my_retweet_id = result.id;
@ -213,8 +215,26 @@ public class ParcelableStatusUtils {
@Nullable
private static String getPlaceFullName(@NonNull Status status) {
Place place = status.getPlace();
if (place == null) return status.getLocation();
return place.getFullName();
if (place != null) return place.getFullName();
final String location = status.getLocation();
if (ParcelableLocation.valueOf(location) == null) {
return location;
}
return null;
}
@Nullable
private static ParcelableLocation getLocation(@NonNull Status status) {
GeoLocation geoLocation = status.getGeoLocation();
if (geoLocation != null) {
return ParcelableLocationUtils.fromGeoLocation(geoLocation);
}
final String locationString = status.getLocation();
final ParcelableLocation location = ParcelableLocation.valueOf(locationString);
if (location != null) {
return location;
}
return null;
}
private static long getTime(final Date date) {