improved user lookup (though still not perfect)

fixed #777 - this should really work!
This commit is contained in:
Mariotaku Lee 2017-04-24 18:28:00 +08:00
parent cdf819fa0d
commit a376c6f01d
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
5 changed files with 19 additions and 4 deletions

View File

@ -36,7 +36,7 @@ subprojects {
Kotlin : '1.1.1',
SupportLib : '25.3.1',
MariotakuCommons : '0.9.13',
RestFu : '0.9.53',
RestFu : '0.9.54',
ObjectCursor : '0.9.16',
PlayServices : '10.2.1',
MapsUtils : '0.4.4',

View File

@ -37,11 +37,11 @@ public interface TimelinesResources {
@GET("/v1/timelines/public")
LinkHeaderList<Status> getPublicTimeline(@Query Paging paging, @Query(value = "local",
booleanEncoding = BooleanEncoding.KEY_IF_TRUE) boolean local)
booleanEncoding = BooleanEncoding.IGNORE_IF_FALSE) boolean local)
throws MicroBlogException;
@GET("/v1/timelines/tag/{tag}")
LinkHeaderList<Status> getHashtagTimeline(@Path("tag") String hashtag, @Query Paging paging,
@Query(value = "local", booleanEncoding = BooleanEncoding.KEY_IF_TRUE) boolean local)
@Query(value = "local", booleanEncoding = BooleanEncoding.IGNORE_IF_FALSE) boolean local)
throws MicroBlogException;
}

View File

@ -38,6 +38,7 @@ import java.util.List;
@ParcelablePlease
public class UserKey implements Comparable<UserKey>, Parcelable {
private static final String ID_PLACEHOLDER = "#placeholder";
public static final UserKey SELF = new UserKey("#self#", "#self#");
public static final UserKey INVALID = new UserKey("#invalid#", "#invalid#");

View File

@ -28,3 +28,7 @@ import org.mariotaku.twidere.model.UserKey
private const val mastodonPlaceholderId = "#mastodon*placeholder#"
val UserKey.isMastodonPlaceholder get() = mastodonPlaceholderId == id && host != null
fun MastodonPlaceholderUserKey(host: String?): UserKey {
return UserKey(mastodonPlaceholderId, host)
}

View File

@ -1393,11 +1393,21 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
override fun onLinkClick(link: String, orig: String?, accountKey: UserKey?,
extraId: Long, type: Int, sensitive: Boolean, start: Int, end: Int): Boolean {
val current = getCurrentMedia(link, extraId.toInt())
val position = extraId.toInt()
val current = getCurrentMedia(link, position)
if (current != null && !current.open_browser) {
expandOrOpenMedia(current)
return true
}
when (type) {
TwidereLinkify.LINK_TYPE_MENTION -> {
val status = adapter.getStatus(position)
val userKey = MastodonPlaceholderUserKey(status.user_key.host ?: accountKey?.host)
IntentUtils.openUserProfile(context, accountKey, userKey, link, null,
preferences[newDocumentApiKey], Referral.USER_MENTION, null)
return true
}
}
return super.onLinkClick(link, orig, accountKey, extraId, type, sensitive, start, end)
}