blob: 1f7042f39b642f36e6dae5a92d0e75697deda9d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package net.miz_hi.smileessence.status;
import net.miz_hi.smileessence.Client;
import net.miz_hi.smileessence.cache.TweetCache;
import net.miz_hi.smileessence.core.MyExecutor;
import net.miz_hi.smileessence.model.status.ResponseConverter;
import net.miz_hi.smileessence.model.status.tweet.TweetModel;
import net.miz_hi.smileessence.twitter.API;
import twitter4j.Status;
import twitter4j.UserMentionEntity;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
public class TweetUtils
{
public static boolean isReply(Status st)
{
if (st == null)
{
return false;
}
for (UserMentionEntity ume : st.getUserMentionEntities())
{
if (ume.getScreenName().equals(Client.getMainAccount().getScreenName()))
{
return true;
}
}
return false;
}
public static TweetModel getOrCreateStatusModel(final long id)
{
TweetModel statusModel = TweetCache.get(id);
if (statusModel == null)
{
Future<Status> f = MyExecutor.submit(new Callable<Status>()
{
@Override
public Status call() throws Exception
{
return API.getStatus(Client.getMainAccount(), id);
}
});
Status status;
try
{
status = f.get();
}
catch (Exception e)
{
e.printStackTrace();
status = null;
}
if (status == null)
{
return null;
}
statusModel = ResponseConverter.convert(status);
}
return statusModel;
}
}
|