package net.miz_hi.smileessence.command.user;

import android.app.Activity;
import android.app.ProgressDialog;
import net.miz_hi.smileessence.model.status.user.UserModel;
import net.miz_hi.smileessence.model.statuslist.timeline.impl.UserTimeline;
import net.miz_hi.smileessence.statuslist.StatusListAdapter;
import net.miz_hi.smileessence.statuslist.StatusListManager;
import net.miz_hi.smileessence.system.PageController;
import net.miz_hi.smileessence.task.impl.GetUserTask;
import net.miz_hi.smileessence.twitter.ResponseConverter;
import net.miz_hi.smileessence.view.fragment.impl.UserTimelineFragment;
import twitter4j.User;

public class UserCommandOpenTimeline extends UserCommand
{

    Activity activity;

    public UserCommandOpenTimeline(String userName, Activity activity)
    {
        super(userName);
        this.activity = activity;
    }

    @Override
    public String getName()
    {
        return "ユーザーのタイムラインを開く";
    }

    @Override
    public void workOnUiThread()
    {
        final ProgressDialog pd = ProgressDialog.show(activity, null, "取得中...", true);
        new GetUserTask(userName)
        {
            @Override
            public void onPostExecute(User user)
            {
                UserModel model = ResponseConverter.convert(user);
                UserTimelineFragment fragment = UserTimelineFragment.newInstance(model);
                PageController.getInstance().addPage(fragment);
                PageController.getInstance().moveToLast();
                UserTimeline timeline = new UserTimeline(model.userId);
                StatusListManager.registerUserTimeline(model.userId, timeline, new StatusListAdapter(activity, timeline));
                timeline.loadNewer();
                pd.dismiss();
            }
        }.callAsync();

    }

}

@@ -1348,426 +1348,612 @@
 line
-Fragment fragment = UserTimelineFragment.newInstance(model);%0D%0A                PageController.getInstance().addPage(fragment);%0D%0A                PageController.getInstance().moveToLast();%0D%0A                UserTimeline timeline = new UserTimeline(model.userId);%0D%0A                StatusListManager.registerUserTimeline(model.userId, timeline, new StatusListAdapter(activity, timeline));%0D%0A                timeline.loadNewer
+ timeline = new UserTimeline(model.userId);%0D%0A                StatusListManager.registerUserTimeline(model.userId, timeline, new StatusListAdapter(activity, timeline));%0D%0A                try%0D%0A                %7B%0D%0A                    timeline.loadNewer().get();%0D%0A                %7D%0D%0A                catch (Exception e)%0D%0A                %7B%0D%0A                    e.printStackTrace();%0D%0A                %7D%0D%0A                UserTimelineFragment fragment = UserTimelineFragment.newInstance(model);%0D%0A                PageController.getInstance().addPage(fragment);%0D%0A                PageController.getInstance().moveToLast
 ();%0D

Fix bug