mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
improved statusnet api
This commit is contained in:
parent
7a77a25452
commit
680deb22c5
@ -1,6 +1,7 @@
|
||||
package org.mariotaku.twidere.api.statusnet.api;
|
||||
|
||||
import org.mariotaku.restfu.annotation.method.GET;
|
||||
import org.mariotaku.restfu.annotation.param.Path;
|
||||
import org.mariotaku.restfu.annotation.param.Query;
|
||||
import org.mariotaku.twidere.api.statusnet.model.StatusNetConfig;
|
||||
import org.mariotaku.twidere.api.twitter.TwitterException;
|
||||
@ -16,5 +17,6 @@ public interface StatusNetResources {
|
||||
@GET("/statusnet/config.json")
|
||||
StatusNetConfig getStatusNetConfig() throws TwitterException;
|
||||
|
||||
|
||||
@GET("/statusnet/conversation/{id}.json")
|
||||
ResponseList<Status> getStatusNetConversation(@Path("id") long statusId, @Query Paging paging) throws TwitterException;
|
||||
}
|
||||
|
@ -44,12 +44,6 @@ public interface PrivateTweetResources extends PrivateResources {
|
||||
@GET("/statuses/{id}/activity/summary.json")
|
||||
StatusActivitySummary getStatusActivitySummary(@Path("id") long statusId) throws TwitterException;
|
||||
|
||||
@GET("/statuses/{id}/activity/summary.json")
|
||||
StatusActivitySummary getStatusActivitySummary(@Path("id") long statusId, boolean includeUserEntities) throws TwitterException;
|
||||
|
||||
@GET("/conversation/show.json")
|
||||
ResponseList<Status> showConversation(@Query("id") long statusId) throws TwitterException;
|
||||
|
||||
@GET("/conversation/show.json")
|
||||
ResponseList<Status> showConversation(@Query("id") long statusId, @Query Paging paging) throws TwitterException;
|
||||
|
||||
|
@ -73,6 +73,9 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
||||
@JsonField(name = "listed_count")
|
||||
long listedCount = -1;
|
||||
|
||||
@JsonField(name = "groups_count")
|
||||
long groupsCount = -1;
|
||||
|
||||
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
|
||||
Date createdAt;
|
||||
|
||||
@ -299,6 +302,9 @@ public class User extends TwitterResponseObject implements Comparable<User> {
|
||||
return listedCount;
|
||||
}
|
||||
|
||||
public long getGroupsCount() {
|
||||
return groupsCount;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
|
@ -307,6 +307,9 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
|
||||
@JsonField(name = "profile_image_url_profile_size")
|
||||
@ParcelableThisPlease
|
||||
public String profile_image_url_profile_size;
|
||||
@JsonField(name = "groups_count")
|
||||
@ParcelableThisPlease
|
||||
public long groups_count = -1;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
|
@ -181,9 +181,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
private ProfileBannerImageView mProfileBannerView;
|
||||
private View mProfileBirthdayBannerView;
|
||||
private TextView mNameView, mScreenNameView, mDescriptionView, mLocationView, mURLView, mCreatedAtView,
|
||||
mListedCount, mFollowersCount, mFriendsCount, mHeaderErrorTextView;
|
||||
private View mDescriptionContainer, mLocationContainer, mURLContainer, mListedContainer, mFollowersContainer,
|
||||
mFriendsContainer;
|
||||
mHeaderErrorTextView;
|
||||
private TextView mListedCount, mFollowersCount, mFriendsCount, mGroupsCount;
|
||||
private View mDescriptionContainer, mLocationContainer, mURLContainer;
|
||||
private View mListedContainer, mFollowersContainer, mFriendsContainer, mGroupsContainer;
|
||||
private ImageView mHeaderErrorIcon;
|
||||
private ColorLabelRelativeLayout mProfileNameContainer;
|
||||
private View mProgressContainer, mHeaderErrorContainer;
|
||||
@ -554,9 +555,14 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
mCreatedAtView.setText(resources.getQuantityString(R.plurals.created_at_with_N_tweets_per_day, dailyTweets,
|
||||
createdAt, dailyTweets));
|
||||
mListedCount.setText(Utils.getLocalizedNumber(mLocale, user.listed_count));
|
||||
final long groupsCount = user.extras != null ? user.extras.groups_count : -1;
|
||||
mGroupsCount.setText(Utils.getLocalizedNumber(mLocale, groupsCount));
|
||||
mFollowersCount.setText(Utils.getLocalizedNumber(mLocale, user.followers_count));
|
||||
mFriendsCount.setText(Utils.getLocalizedNumber(mLocale, user.friends_count));
|
||||
|
||||
mListedContainer.setVisibility(user.listed_count < 0 ? View.GONE : View.VISIBLE);
|
||||
mGroupsContainer.setVisibility(groupsCount < 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
mMediaLoader.displayOriginalProfileImage(mProfileImageView, user);
|
||||
if (userColor != 0) {
|
||||
setUiColor(userColor);
|
||||
@ -1150,7 +1156,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
mURLView = (TextView) headerView.findViewById(R.id.url);
|
||||
mCreatedAtView = (TextView) headerView.findViewById(R.id.created_at);
|
||||
mListedContainer = headerView.findViewById(R.id.listed_container);
|
||||
mGroupsContainer = headerView.findViewById(R.id.groups_container);
|
||||
mListedCount = (TextView) headerView.findViewById(R.id.listed_count);
|
||||
mGroupsCount = (TextView) headerView.findViewById(R.id.groups_count);
|
||||
mFollowersContainer = headerView.findViewById(R.id.followers_container);
|
||||
mFollowersCount = (TextView) headerView.findViewById(R.id.followers_count);
|
||||
mFriendsContainer = headerView.findViewById(R.id.friends_container);
|
||||
|
@ -63,6 +63,8 @@ public class ConversationLoader extends TwitterAPIStatusesLoader {
|
||||
if (credentials == null) throw new TwitterException("Null credentials");
|
||||
if (Utils.isOfficialCredentials(getContext(), credentials)) {
|
||||
return twitter.showConversation(status.id, paging);
|
||||
} else if (!TwitterAPIFactory.isTwitterCredentials(credentials)) {
|
||||
return twitter.getStatusNetConversation(status.id, paging);
|
||||
}
|
||||
final List<Status> statuses = new ArrayList<>();
|
||||
final long maxId = getMaxId(), sinceId = getSinceId();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mariotaku.twidere.model.util;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.mariotaku.twidere.TwidereConstants;
|
||||
import org.mariotaku.twidere.api.twitter.model.UrlEntity;
|
||||
@ -17,7 +16,7 @@ import org.mariotaku.twidere.util.media.preview.PreviewMediaExtractor;
|
||||
/**
|
||||
* Created by mariotaku on 16/2/24.
|
||||
*/
|
||||
public class ParcelableUserUtils implements TwidereConstants{
|
||||
public class ParcelableUserUtils implements TwidereConstants {
|
||||
|
||||
public static ParcelableUser fromUser(User user, long accountId) {
|
||||
return fromUser(user, accountId, 0);
|
||||
@ -64,6 +63,7 @@ public class ParcelableUserUtils implements TwidereConstants{
|
||||
extras.statusnet_profile_url = user.getStatusnetProfileUrl();
|
||||
extras.profile_image_url_original = user.getProfileImageUrlOriginal();
|
||||
extras.profile_image_url_profile_size = user.getProfileImageUrlProfileSize();
|
||||
extras.groups_count = user.getGroupsCount();
|
||||
obj.extras = extras;
|
||||
obj.user_type = getUserType(extras.ostatus_uri);
|
||||
return obj;
|
||||
|
@ -151,9 +151,12 @@ public class TwitterWrapper implements Constants {
|
||||
try {
|
||||
return showUser(twitter, id, screenName);
|
||||
} catch (final TwitterException e) {
|
||||
if (e.isCausedByNetworkIssue()) throw e;
|
||||
// Twitter specific error for private API calling through proxy
|
||||
if (e.getStatusCode() == 200) {
|
||||
return showUserAlternative(twitter, id, screenName);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return showUserAlternative(twitter, id, screenName);
|
||||
}
|
||||
|
||||
public static void updateProfileBannerImage(final Context context, final long accountId,
|
||||
|
@ -362,6 +362,35 @@
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/groups_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/element_spacing_small">
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:id="@+id/groups_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="255" />
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/groups"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -755,4 +755,5 @@
|
||||
<string name="translation">Translation</string>
|
||||
<string name="shortener_version_incompatible">Incompatible tweet shortener</string>
|
||||
<string name="uploader_version_incompatible">Incompatible media uploader</string>
|
||||
<string name="groups">Groups</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user