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.tweet.TweetModel;
import net.miz_hi.smileessence.twitter.API;
import net.miz_hi.smileessence.twitter.ResponseConverter;
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.showStatus(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;
    }

}

@@ -126,56 +126,8 @@
 he;%0A
-import net.miz_hi.smileessence.core.MyExecutor;%0A
 impo
@@ -220,18 +220,30 @@
 ce.t
-witter.API
+ask.impl.ShowTweetTask
 ;%0Aim
@@ -364,46 +364,8 @@
 y;%0A%0A
-import java.util.concurrent.Callable;%0A
 impo
@@ -858,14 +858,8 @@
 del(
-final 
 long
@@ -1000,265 +1000,40 @@
 f = 
-MyExecutor.submit(new Callable%3CStatus%3E()%0A            %7B%0A%0A                @Override%0A                public Status call() throws Exception%0A                %7B%0A                    return API.showStatus(Client.getMainAccount(), id);%0A                %7D%0A            %7D
+new ShowTweetTask(id).callAsync(
 );%0A 

Refactor TweetUtils