package com.bricechou.weiboclient.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.bricechou.weiboclient.R;
import com.bricechou.weiboclient.adapter.WeiboHomeAdapter;
import com.bricechou.weiboclient.api.WeiboRequestListener;
import com.bricechou.weiboclient.config.Constants;
import com.bricechou.weiboclient.db.LoginUserToken;
import com.bricechou.weiboclient.utils.BaseFragment;
import com.sina.weibo.sdk.openapi.StatusesAPI;
import com.sina.weibo.sdk.openapi.models.StatusList;

/**
 * Created by sdduser on 5/28/16.
 */
public class HomeFragment extends BaseFragment {

    private final static String TAG = "HomeFragment";
    private View mView;
    private ListView lv_home;
    private StatusesAPI mStatusesAPI;
    private StatusList mStatusList;

    /**
     * show the weibo home page
     *
     * @comment by BriceChou
     * @datetime 16-6-6 17:28
     * @TODO to show the weibo content
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        initView();
        initWeiboContent();
        return mView;
    }

    /**
     * initial the weibo content and display in the home page
     *
     * @author BriceChou
     * @datetime 16-6-6 15:14
     */
    private void initWeiboContent() {
        mStatusesAPI = new StatusesAPI(mMainActivity, Constants.APP_KEY, LoginUserToken.showAccessToken());
        mStatusesAPI.friendsTimeline(0, 0, 20, 1, false, 0, false, new WeiboRequestListener(mMainActivity) {
            @Override
            public void onComplete(String response) {
                super.onComplete(response);

                if (!TextUtils.isEmpty(response)) {
                    if (response.startsWith("{\"statuses\"")) {
                        // the Status instance load the data from JSON data.
                        mStatusList = mStatusList.parse(response);
                        lv_home.setAdapter(new WeiboHomeAdapter(mMainActivity,mStatusList.statusList));
                    }
                }
            }
        });
    }
    private void initView() {
        mView = View.inflate(mMainActivity, R.layout.frag_home, null);
        lv_home = (ListView) mView.findViewById(R.id.lv_home);
    }
}

@@ -531,16 +531,69 @@
 agment;%0A
+import com.bricechou.weiboclient.utils.TitleBuilder;%0A
 import c
@@ -1275,24 +1275,598 @@
 oContent();%0A
+        new TitleBuilder(mView)%0A                .setCenterText(%22%E5%B8%90%E5%8F%B7%E6%98%B5%E7%A7%B0%22)%0A                .setLeftImage(R.drawable.icon_friendattention)%0A                .setRightImage(R.drawable.icon_radar)%0A                .setLeftOnclickListener(new View.OnClickListener() %7B%0A                    @Override%0A                    public void onClick(View v) %7B%0A%0A%0A                    %7D%0A                %7D)%0A                .setRightOnclickListener(new View.OnClickListener() %7B%0A                    @Override%0A                    public void onClick(View v) %7B%0A%0A%0A                    %7D%0A                %7D);%0A
         retu

update home titlebar