added trend sorting (Mastodon), bug fix, renamed methods and variables, version upgrade
This commit is contained in:
parent
ac38db2d62
commit
3d61477a0e
|
@ -13,8 +13,8 @@ android {
|
||||||
applicationId 'org.nuclearfog.twidda'
|
applicationId 'org.nuclearfog.twidda'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode 72
|
versionCode 73
|
||||||
versionName '3.0.4'
|
versionName '3.0.5'
|
||||||
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,8 +391,9 @@ public class Mastodon implements Connection {
|
||||||
JSONArray array = new JSONArray(body.string());
|
JSONArray array = new JSONArray(body.string());
|
||||||
List<Trend> result = new ArrayList<>(array.length());
|
List<Trend> result = new ArrayList<>(array.length());
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
result.add(new MastodonTrend(array.getJSONObject(i), i));
|
result.add(new MastodonTrend(array.getJSONObject(i)));
|
||||||
}
|
}
|
||||||
|
Collections.sort(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
throw new MastodonException(response);
|
throw new MastodonException(response);
|
||||||
|
@ -415,8 +416,9 @@ public class Mastodon implements Connection {
|
||||||
JSONArray array = new JSONObject(body.string()).getJSONArray("hashtags");
|
JSONArray array = new JSONObject(body.string()).getJSONArray("hashtags");
|
||||||
List<Trend> result = new ArrayList<>(array.length());
|
List<Trend> result = new ArrayList<>(array.length());
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
result.add(new MastodonTrend(array.getJSONObject(i), i));
|
result.add(new MastodonTrend(array.getJSONObject(i)));
|
||||||
}
|
}
|
||||||
|
Collections.sort(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
throw new MastodonException(response);
|
throw new MastodonException(response);
|
||||||
|
|
|
@ -14,6 +14,8 @@ import org.nuclearfog.twidda.model.Emoji;
|
||||||
*/
|
*/
|
||||||
public class CustomEmoji implements Emoji {
|
public class CustomEmoji implements Emoji {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2848675481626033993L;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String url;
|
private String url;
|
||||||
private String category;
|
private String category;
|
||||||
|
@ -63,6 +65,14 @@ public class CustomEmoji implements Emoji {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Emoji emoji) {
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(code, emoji.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if emoji is visible for picker
|
||||||
|
*/
|
||||||
public boolean visible() {
|
public boolean visible() {
|
||||||
return visibleInPicker;
|
return visibleInPicker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class MastodonAccount implements Account {
|
||||||
private static final long serialVersionUID = -3212031070966866336L;
|
private static final long serialVersionUID = -3212031070966866336L;
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private long createdAt;
|
private long timestamp;
|
||||||
|
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private String bearer;
|
private String bearer;
|
||||||
|
@ -38,7 +38,7 @@ public class MastodonAccount implements Account {
|
||||||
this.bearer = bearer;
|
this.bearer = bearer;
|
||||||
this.client_id = client_id;
|
this.client_id = client_id;
|
||||||
this.client_secret = client_secret;
|
this.client_secret = client_secret;
|
||||||
createdAt = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
id = user.getId();
|
id = user.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ public class MastodonAccount implements Account {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLoginDate() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,12 @@ public class MastodonList implements UserList {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(UserList userlist) {
|
||||||
|
return Long.compare(userlist.getId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
if (!(obj instanceof UserList))
|
if (!(obj instanceof UserList))
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class MastodonNotification implements Notification {
|
||||||
private static final long serialVersionUID = 4113306729125959429L;
|
private static final long serialVersionUID = 4113306729125959429L;
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private long createdAt;
|
private long timestamp;
|
||||||
private int type;
|
private int type;
|
||||||
private User user;
|
private User user;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
@ -34,7 +34,7 @@ public class MastodonNotification implements Notification {
|
||||||
String typeStr = json.getString("type");
|
String typeStr = json.getString("type");
|
||||||
JSONObject statusJson = json.optJSONObject("status");
|
JSONObject statusJson = json.optJSONObject("status");
|
||||||
JSONObject userJson = json.getJSONObject("account");
|
JSONObject userJson = json.getJSONObject("account");
|
||||||
createdAt = StringTools.getTime(json.getString("created_at"), StringTools.TIME_MASTODON);
|
timestamp = StringTools.getTime(json.getString("created_at"), StringTools.TIME_MASTODON);
|
||||||
user = new MastodonUser(userJson);
|
user = new MastodonUser(userJson);
|
||||||
|
|
||||||
switch (typeStr) {
|
switch (typeStr) {
|
||||||
|
@ -94,8 +94,8 @@ public class MastodonNotification implements Notification {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,6 +119,12 @@ public class MastodonNotification implements Notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Notification notification) {
|
||||||
|
return Long.compare(notification.getTimestamp(), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
if (!(obj instanceof Notification))
|
if (!(obj instanceof Notification))
|
||||||
|
|
|
@ -15,18 +15,15 @@ public class MastodonTrend implements Trend {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4328931229081239280L;
|
private static final long serialVersionUID = 4328931229081239280L;
|
||||||
|
|
||||||
private int rank;
|
|
||||||
private int popularity;
|
private int popularity;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param json trend json object
|
* @param json trend json object
|
||||||
* @param pos array index
|
|
||||||
*/
|
*/
|
||||||
public MastodonTrend(JSONObject json, int pos) {
|
public MastodonTrend(JSONObject json) {
|
||||||
JSONArray history = json.optJSONArray("history");
|
JSONArray history = json.optJSONArray("history");
|
||||||
name = '#' + json.optString("name", "");
|
name = '#' + json.optString("name", "");
|
||||||
rank = pos + 1;
|
|
||||||
if (history != null && history.length() > 0) {
|
if (history != null && history.length() > 0) {
|
||||||
JSONObject latest = history.optJSONObject(0);
|
JSONObject latest = history.optJSONObject(0);
|
||||||
if (latest != null) {
|
if (latest != null) {
|
||||||
|
@ -50,7 +47,7 @@ public class MastodonTrend implements Trend {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRank() {
|
public int getRank() {
|
||||||
return rank;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,9 +57,21 @@ public class MastodonTrend implements Trend {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Trend trend) {
|
||||||
|
if (trend.getPopularity() > 0 && popularity > 0)
|
||||||
|
return Integer.compare(trend.getPopularity(), popularity);
|
||||||
|
if (trend.getPopularity() > 0)
|
||||||
|
return 1;
|
||||||
|
if (popularity > 0)
|
||||||
|
return -1;
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(name, trend.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "name=\"" + name + " rank=" + rank;
|
return "name=\"" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -108,7 +108,7 @@ public class MastodonUser implements User {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public class MastodonUser implements User {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(User o) {
|
public int compareTo(User o) {
|
||||||
return Long.compare(o.getCreatedAt(), createdAt);
|
return Long.compare(o.getTimestamp(), createdAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class AccountV1 implements Account {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLoginDate() {
|
public long getTimestamp() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,12 @@ public class MessageV1 implements Message {
|
||||||
return "from=" + sender + " message=\"" + text + "\"";
|
return "from=" + sender + " message=\"" + text + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Message message) {
|
||||||
|
return Long.compare(message.getTimestamp(), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get ID of the sender
|
* get ID of the sender
|
||||||
*
|
*
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class NotificationV1 implements Notification {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return status.getTimestamp();
|
return status.getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,4 +70,10 @@ public class NotificationV1 implements Notification {
|
||||||
Notification notification = ((Notification) obj);
|
Notification notification = ((Notification) obj);
|
||||||
return status.equals(notification.getStatus());
|
return status.equals(notification.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Notification notification) {
|
||||||
|
return Long.compare(notification.getTimestamp(), getTimestamp());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -56,6 +56,12 @@ public class TrendV1 implements Trend {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Trend trend) {
|
||||||
|
return Integer.compare(rank, trend.getRank());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class UserListV1 implements UserList {
|
||||||
private static final String PRIVATE = "private";
|
private static final String PRIVATE = "private";
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private long createdAt;
|
private long timestamp;
|
||||||
private String title;
|
private String title;
|
||||||
private String description;
|
private String description;
|
||||||
private int memberCount;
|
private int memberCount;
|
||||||
|
@ -42,7 +42,7 @@ public class UserListV1 implements UserList {
|
||||||
String idStr = json.getString("id_str");
|
String idStr = json.getString("id_str");
|
||||||
|
|
||||||
owner = new UserV1(json.getJSONObject("user"), currentId);
|
owner = new UserV1(json.getJSONObject("user"), currentId);
|
||||||
createdAt = StringTools.getTime(json.optString("created_at", ""), StringTools.TIME_TWITTER_V1);
|
timestamp = StringTools.getTime(json.optString("created_at", ""), StringTools.TIME_TWITTER_V1);
|
||||||
title = json.optString("name", "");
|
title = json.optString("name", "");
|
||||||
description = json.optString("description", "");
|
description = json.optString("description", "");
|
||||||
memberCount = json.optInt("member_count");
|
memberCount = json.optInt("member_count");
|
||||||
|
@ -65,7 +65,7 @@ public class UserListV1 implements UserList {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,6 +131,12 @@ public class UserListV1 implements UserList {
|
||||||
return "title=\"" + title + "\" description=\"" + description + "\"";
|
return "title=\"" + title + "\" description=\"" + description + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(UserList userlist) {
|
||||||
|
return Long.compare(userlist.getTimestamp(), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set manually follow status
|
* set manually follow status
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class UserV1 implements User {
|
||||||
|
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private long createdAt;
|
private long timestamp;
|
||||||
private String username;
|
private String username;
|
||||||
private String screenName;
|
private String screenName;
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -74,7 +74,7 @@ public class UserV1 implements User {
|
||||||
favoriteCount = json.optInt("favourites_count");
|
favoriteCount = json.optInt("favourites_count");
|
||||||
followReqSent = json.optBoolean("follow_request_sent");
|
followReqSent = json.optBoolean("follow_request_sent");
|
||||||
defaultImage = json.optBoolean("default_profile_image");
|
defaultImage = json.optBoolean("default_profile_image");
|
||||||
createdAt = StringTools.getTime(json.optString("created_at", ""), StringTools.TIME_TWITTER_V1);
|
timestamp = StringTools.getTime(json.optString("created_at", ""), StringTools.TIME_TWITTER_V1);
|
||||||
description = getDescription(json);
|
description = getDescription(json);
|
||||||
url = getUrl(json);
|
url = getUrl(json);
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ public class UserV1 implements User {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ public class UserV1 implements User {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(User o) {
|
public int compareTo(User o) {
|
||||||
return Long.compare(o.getCreatedAt(), createdAt);
|
return Long.compare(o.getTimestamp(), timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class UserV2 implements User {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class UserV2 implements User {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(User o) {
|
public int compareTo(User o) {
|
||||||
return Long.compare(o.getCreatedAt(), createdAt);
|
return Long.compare(o.getTimestamp(), createdAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.nuclearfog.twidda.model.Trend;
|
||||||
import org.nuclearfog.twidda.model.User;
|
import org.nuclearfog.twidda.model.User;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -354,11 +355,6 @@ public class AppDatabase {
|
||||||
*/
|
*/
|
||||||
private static final String FILTER_SELECT = LIST_SELECT + " AND " + UserExcludeTable.ID + "=?";
|
private static final String FILTER_SELECT = LIST_SELECT + " AND " + UserExcludeTable.ID + "=?";
|
||||||
|
|
||||||
/**
|
|
||||||
* default order for trend rows
|
|
||||||
*/
|
|
||||||
private static final String TREND_ORDER = TrendTable.INDEX + " ASC";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default sort order for logins
|
* default sort order for logins
|
||||||
*/
|
*/
|
||||||
|
@ -528,7 +524,7 @@ public class AppDatabase {
|
||||||
for (Notification notification : notifications) {
|
for (Notification notification : notifications) {
|
||||||
ContentValues column = new ContentValues();
|
ContentValues column = new ContentValues();
|
||||||
column.put(NotificationTable.ID, notification.getId());
|
column.put(NotificationTable.ID, notification.getId());
|
||||||
column.put(NotificationTable.TIME, notification.getCreatedAt());
|
column.put(NotificationTable.TIME, notification.getTimestamp());
|
||||||
column.put(NotificationTable.TYPE, notification.getType());
|
column.put(NotificationTable.TYPE, notification.getType());
|
||||||
column.put(NotificationTable.OWNER, settings.getLogin().getId());
|
column.put(NotificationTable.OWNER, settings.getLogin().getId());
|
||||||
column.put(NotificationTable.USER, notification.getUser().getId());
|
column.put(NotificationTable.USER, notification.getUser().getId());
|
||||||
|
@ -563,7 +559,7 @@ public class AppDatabase {
|
||||||
public void saveLogin(Account account) {
|
public void saveLogin(Account account) {
|
||||||
ContentValues values = new ContentValues(9);
|
ContentValues values = new ContentValues(9);
|
||||||
values.put(AccountTable.ID, account.getId());
|
values.put(AccountTable.ID, account.getId());
|
||||||
values.put(AccountTable.DATE, account.getLoginDate());
|
values.put(AccountTable.DATE, account.getTimestamp());
|
||||||
values.put(AccountTable.HOSTNAME, account.getHostname());
|
values.put(AccountTable.HOSTNAME, account.getHostname());
|
||||||
values.put(AccountTable.CLIENT_ID, account.getConsumerToken());
|
values.put(AccountTable.CLIENT_ID, account.getConsumerToken());
|
||||||
values.put(AccountTable.CLIENT_SECRET, account.getConsumerSecret());
|
values.put(AccountTable.CLIENT_SECRET, account.getConsumerSecret());
|
||||||
|
@ -896,7 +892,7 @@ public class AppDatabase {
|
||||||
public List<Trend> getTrends() {
|
public List<Trend> getTrends() {
|
||||||
String[] args = {Long.toString(settings.getTrendLocation().getId())};
|
String[] args = {Long.toString(settings.getTrendLocation().getId())};
|
||||||
SQLiteDatabase db = getDbRead();
|
SQLiteDatabase db = getDbRead();
|
||||||
Cursor cursor = db.query(TrendTable.NAME, TrendImpl.COLUMNS, TREND_SELECT, args, null, null, TREND_ORDER);
|
Cursor cursor = db.query(TrendTable.NAME, TrendImpl.COLUMNS, TREND_SELECT, args, null, null, null);
|
||||||
List<Trend> trends = new LinkedList<>();
|
List<Trend> trends = new LinkedList<>();
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
|
@ -904,6 +900,7 @@ public class AppDatabase {
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
Collections.sort(trends);
|
||||||
return trends;
|
return trends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1234,7 +1231,7 @@ public class AppDatabase {
|
||||||
userColumn.put(UserTable.LINK, user.getProfileUrl());
|
userColumn.put(UserTable.LINK, user.getProfileUrl());
|
||||||
userColumn.put(UserTable.LOCATION, user.getLocation());
|
userColumn.put(UserTable.LOCATION, user.getLocation());
|
||||||
userColumn.put(UserTable.BANNER, user.getOriginalBannerImageUrl());
|
userColumn.put(UserTable.BANNER, user.getOriginalBannerImageUrl());
|
||||||
userColumn.put(UserTable.SINCE, user.getCreatedAt());
|
userColumn.put(UserTable.SINCE, user.getTimestamp());
|
||||||
userColumn.put(UserTable.FRIENDS, user.getFollowing());
|
userColumn.put(UserTable.FRIENDS, user.getFollowing());
|
||||||
userColumn.put(UserTable.FOLLOWER, user.getFollower());
|
userColumn.put(UserTable.FOLLOWER, user.getFollower());
|
||||||
userColumn.put(UserTable.STATUSES, user.getStatusCount());
|
userColumn.put(UserTable.STATUSES, user.getStatusCount());
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class AccountImpl implements Account {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLoginDate() {
|
public long getTimestamp() {
|
||||||
return loginDate;
|
return loginDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ import org.nuclearfog.twidda.model.Emoji;
|
||||||
*/
|
*/
|
||||||
public class EmojiImpl implements Emoji {
|
public class EmojiImpl implements Emoji {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 4915542258264850899L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* projection of the emoji table columns
|
* projection of the emoji table columns
|
||||||
*/
|
*/
|
||||||
|
@ -69,4 +71,10 @@ public class EmojiImpl implements Emoji {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "code=\"" + code + "\" category=\"" + category + "\" url=\"" + url + "\"";
|
return "code=\"" + code + "\" category=\"" + category + "\" url=\"" + url + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Emoji emoji) {
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(code, emoji.getCode());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -100,6 +100,12 @@ public class MessageImpl implements Message {
|
||||||
return "from=" + sender + " message=\"" + text + "\"";
|
return "from=" + sender + " message=\"" + text + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Message message) {
|
||||||
|
return Long.compare(message.getTimestamp(), time);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return media key array
|
* @return media key array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class NotificationImpl implements Notification {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,12 @@ public class NotificationImpl implements Notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Notification notification) {
|
||||||
|
return Long.compare(notification.getTimestamp(), timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TrendImpl implements Trend {
|
||||||
};
|
};
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private int range;
|
private int popularity;
|
||||||
private int rank;
|
private int rank;
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class TrendImpl implements Trend {
|
||||||
*/
|
*/
|
||||||
public TrendImpl(Cursor cursor) {
|
public TrendImpl(Cursor cursor) {
|
||||||
name = cursor.getString(0);
|
name = cursor.getString(0);
|
||||||
range = cursor.getInt(1);
|
popularity = cursor.getInt(1);
|
||||||
rank = cursor.getInt(2);
|
rank = cursor.getInt(2);
|
||||||
id = cursor.getLong(3);
|
id = cursor.getLong(3);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class TrendImpl implements Trend {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPopularity() {
|
public int getPopularity() {
|
||||||
return range;
|
return popularity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,4 +71,18 @@ public class TrendImpl implements Trend {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "rank=" + rank + " name=\"" + name + "\"";
|
return "rank=" + rank + " name=\"" + name + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Trend trend) {
|
||||||
|
if (trend.getRank() > 0 && rank > 0)
|
||||||
|
return Integer.compare(rank, trend.getRank());
|
||||||
|
if (trend.getPopularity() > 0 && popularity > 0)
|
||||||
|
return Integer.compare(trend.getPopularity(), popularity);
|
||||||
|
if (trend.getPopularity() > 0)
|
||||||
|
return 1;
|
||||||
|
if (popularity > 0)
|
||||||
|
return -1;
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(name, trend.getName());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -120,7 +120,7 @@ public class UserImpl implements User {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreatedAt() {
|
public long getTimestamp() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ public class UserImpl implements User {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(User o) {
|
public int compareTo(User o) {
|
||||||
return Long.compare(o.getCreatedAt(), createdAt);
|
return Long.compare(o.getTimestamp(), createdAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public interface Account extends Serializable {
|
||||||
/**
|
/**
|
||||||
* @return date of the first login
|
* @return date of the first login
|
||||||
*/
|
*/
|
||||||
long getLoginDate();
|
long getTimestamp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return user information of the account
|
* @return user information of the account
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package org.nuclearfog.twidda.model;
|
package org.nuclearfog.twidda.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used for "custom emoji" implementation
|
* Interface used for "custom emoji" implementation
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public interface Emoji {
|
public interface Emoji extends Serializable, Comparable<Emoji> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* short code of an emoji used by the server
|
* short code of an emoji used by the server
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public interface Message extends Serializable {
|
public interface Message extends Serializable, Comparable<Message> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ID of the direct message
|
* @return ID of the direct message
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public interface Notification extends Serializable {
|
public interface Notification extends Serializable, Comparable<Notification> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mention
|
* mention
|
||||||
|
@ -70,7 +70,7 @@ public interface Notification extends Serializable {
|
||||||
*
|
*
|
||||||
* @return time
|
* @return time
|
||||||
*/
|
*/
|
||||||
long getCreatedAt();
|
long getTimestamp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get user from the notification
|
* get user from the notification
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public interface Trend extends Serializable {
|
public interface Trend extends Serializable, Comparable<Trend> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return trend name
|
* @return trend name
|
||||||
|
|
|
@ -27,7 +27,7 @@ public interface User extends Serializable, Comparable<User> {
|
||||||
/**
|
/**
|
||||||
* @return date of account creation
|
* @return date of account creation
|
||||||
*/
|
*/
|
||||||
long getCreatedAt();
|
long getTimestamp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return profile image url
|
* @return profile image url
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public interface UserList extends Serializable {
|
public interface UserList extends Serializable, Comparable<UserList> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ID of the user list
|
* @return ID of the user list
|
||||||
|
|
|
@ -645,7 +645,7 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user_createdAt.getVisibility() != VISIBLE) {
|
if (user_createdAt.getVisibility() != VISIBLE) {
|
||||||
String date = SimpleDateFormat.getDateTimeInstance().format(user.getCreatedAt());
|
String date = SimpleDateFormat.getDateTimeInstance().format(user.getTimestamp());
|
||||||
user_createdAt.setVisibility(VISIBLE);
|
user_createdAt.setVisibility(VISIBLE);
|
||||||
user_createdAt.setText(date);
|
user_createdAt.setText(date);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class TrendAdapter extends Adapter<ViewHolder> implements OnHolderClickLi
|
||||||
public void onBindViewHolder(@NonNull ViewHolder vh, int index) {
|
public void onBindViewHolder(@NonNull ViewHolder vh, int index) {
|
||||||
TrendHolder holder = (TrendHolder) vh;
|
TrendHolder holder = (TrendHolder) vh;
|
||||||
Trend trend = trends.get(index);
|
Trend trend = trends.get(index);
|
||||||
holder.setContent(trend);
|
holder.setContent(trend, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class AccountHolder extends ViewHolder implements OnClickListener {
|
||||||
* @param account content
|
* @param account content
|
||||||
*/
|
*/
|
||||||
public void setContent(Account account) {
|
public void setContent(Account account) {
|
||||||
date.setText(StringTools.formatCreationTime(itemView.getResources(), account.getLoginDate()));
|
date.setText(StringTools.formatCreationTime(itemView.getResources(), account.getTimestamp()));
|
||||||
User user = account.getUser();
|
User user = account.getUser();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
// set profile information
|
// set profile information
|
||||||
|
|
|
@ -63,9 +63,10 @@ public class TrendHolder extends ViewHolder implements OnClickListener {
|
||||||
* set view content
|
* set view content
|
||||||
*
|
*
|
||||||
* @param trend content information
|
* @param trend content information
|
||||||
|
* @param index index of the item
|
||||||
*/
|
*/
|
||||||
public void setContent(Trend trend) {
|
public void setContent(Trend trend, int index) {
|
||||||
rank.setText(trend.getRank() + ".");
|
rank.setText(index + 1 + ".");
|
||||||
name.setText(trend.getName());
|
name.setText(trend.getName());
|
||||||
if (trend.getPopularity() > 0) {
|
if (trend.getPopularity() > 0) {
|
||||||
Resources resources = vol.getResources();
|
Resources resources = vol.getResources();
|
||||||
|
|
Loading…
Reference in New Issue