Android仿人人客户端(v5

49 阅读8分钟

        View view = mInflater.inflate(R.layout.fresh_news_popupwindow, null);

        mPopupWindow = new PopupWindow(view, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, true);

        mPopupWindow.setBackgroundDrawable(new BitmapDrawable());

        mPopupWindow.setAnimationStyle(R.style.fresh_news_popup_animation);



        mPopupListView = (ListView) view.findViewById(R.id.popup_listview);

        mTexts = this.getResources().getStringArray(R.array.personal_homepage_filter_list);

        mPopupAdapter = new FreshNewsPopupAdapter(this, mIcons, mTexts);

        mPopupListView.setAdapter(mPopupAdapter);

      3、运行效果图如下:

       4、添加顶部下拉菜单的Item事件处理,实现对新鲜事类型的过滤。


        // 设置顶部下拉菜单的Item事件处理

        mPopupListView.setOnItemClickListener(new OnItemClickListener() {



            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                mPopupWindow.dismiss();



                // 当前选择的项与之前的一样,则不做处理。

                if (mPopupAdapter.getPosition() == position) {

                    return;

                }



                // 新鲜事过滤事件处理

                fresh_news_type = freshNewsTypes[position];



                LogUtil.i(TAG, "onItemClick position = " + position);

                LogUtil.i(TAG, "onItemClick fresh_news_type = " + fresh_news_type);



                mPopupAdapter.setPosition(position);

                mPopupAdapter.notifyDataSetChanged();

                

                topMenuNavbar.tvTitle.setText(mTexts[position]);

                

                if(PERSONAL_HOMEPAGE_TYPE_LATELY.equals(fresh_news_type))

                {

                    // 最近来访

                } 

                else if(PERSONAL_HOMEPAGE_TYPE_DATA.equals(fresh_news_type))

                { 

                    // 资料

                    

                } else {

                    page = 1;

                    mFreshNewsList.clear();



                    getFreshNews();

                }

            }

        });

        新鲜事的类型分为以下几种,代码如下:


 /**

     * 发表的新鲜事,默认请求所有类型的新鲜事

     */

    private static final String FRESH_NEWS_TYPE_ALL = "10,11,20,21,22,23,30,31,32,33,34,35,36";



    /**

     * 照片(相册)

     */

    private static final String FRESH_NEWS_TYPE_PHOTO = "30,31";



    /**

     * 状态

     */

    private static final String FRESH_NEWS_TYPE_STATUS = "10,11";



    /**

     * 日志

     */

    private static final String FRESH_NEWS_TYPE_BLOG = "20,22";



    /**

     * 分享的新鲜事

     */

    private static final String FRESH_NEWS_TYPE_SHARE = "21,23,32,33,36";

    

    /**

     * 最近来访

     */

    private static final String PERSONAL_HOMEPAGE_TYPE_LATELY = "1";

    

    /**

     * 资料

     */

    private static final String PERSONAL_HOMEPAGE_TYPE_DATA = "2";

    

    /**

     * 新鲜事类型数组

     */

    private String[] freshNewsTypes = { 

            PERSONAL_HOMEPAGE_TYPE_LATELY,

            FRESH_NEWS_TYPE_ALL, 

            PERSONAL_HOMEPAGE_TYPE_DATA,

            FRESH_NEWS_TYPE_PHOTO,

            FRESH_NEWS_TYPE_STATUS,

            FRESH_NEWS_TYPE_BLOG,

            FRESH_NEWS_TYPE_SHARE};



    /**

     * 新鲜事类型,默认为当前所支持的全部类型

     */

    private String fresh_news_type = FRESH_NEWS_TYPE_ALL;

     运行效果图如下:

 好友个人主页(新鲜事)

好友个人主页(状态)

好友个人主页(相册)

好友个人主页(分享)

好友个人主页(日志)

二、实现好友的个人主页资料信息的获取和展示

       1、配置用于显示资料信息UI布局文件(personal_homepage_user_basic.xml),代码如下:


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:background="#FFFFFF"

    android:orientation="vertical" >



    <RelativeLayout

        android:id="@+id/rl_friends"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content" 

        android:background="@drawable/fresh_news_list_item_selector">



        <TextView

            android:id="@+id/tv_friends_count"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_centerVertical="true"

            android:paddingBottom="10dip"

            android:paddingLeft="20dip"

            android:paddingTop="10dp"

            android:textColor="#ff005092"

            android:textSize="16sp" />



        <ImageView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_centerVertical="true"

            android:layout_marginRight="8dip"

            android:src="@drawable/v5_0_1_profile_to_friend_list_img" />



        <View

            android:layout_width="fill_parent"

            android:layout_height="1dip"

            android:layout_below="@+id/tv_friends_count"

            android:background="@drawable/v5_0_1_profile_header_divider" />

    </RelativeLayout>



    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="15dip"

        android:paddingTop="10dp"

        android:text="基本信息"

        android:textColor="#FF333333"

        android:textSize="13sp" />



    <View

        android:layout_width="fill_parent"

        android:layout_height="1.5dip"

        android:background="@drawable/v5_0_1_profile_header_divider" />



    <TextView

        android:id="@+id/tv_renren_id"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="20dip"

        android:paddingTop="10dp"

        android:textColor="#80333333"

        android:textSize="16sp" />



    <View

        android:layout_width="fill_parent"

        android:layout_height="1dip"

        android:background="@drawable/v5_0_1_profile_header_divider" />



    <TextView

        android:id="@+id/tv_gender"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="20dip"

        android:paddingTop="10dp"

        android:textColor="#80333333"

        android:textSize="16sp" />



    <View

        android:layout_width="fill_parent"

        android:layout_height="1dip"

        android:background="@drawable/v5_0_1_profile_header_divider" />



    <TextView

        android:id="@+id/tv_birth"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="20dip"

        android:paddingTop="10dp"

        android:textColor="#80333333"

        android:textSize="16sp" />



    <View

        android:layout_width="fill_parent"

        android:layout_height="1dip"

        android:background="@drawable/v5_0_1_profile_header_divider" />



    <TextView

        android:id="@+id/tv_hometown"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="20dip"

        android:paddingTop="10dp"

        android:textColor="#80333333"

        android:textSize="16sp" />



    <View

        android:layout_width="fill_parent"

        android:layout_height="1dip"

        android:background="@drawable/v5_0_1_profile_header_divider" />



    <TextView

        android:id="@+id/tv_network"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:paddingBottom="10dip"

        android:paddingLeft="20dip"

        android:paddingTop="10dp"

        android:textColor="#80333333"

        android:textSize="16sp" />



</LinearLayout>

      2、将的基本信息资料显示组件,添加到ListVew的 FooterView。代码如下:


        mBasicInfoView = (LinearLayout) mInflater.inflate(R.layout.personal_homepage_user_basic, null);

        mBasicInfoView.setVisibility(View.GONE);

        mListView.addFooterView(mBasicInfoView);

      3、获取 基本信息资料显示的各个组件,代码如下:


        tvRenrenId = (TextView) mBasicInfoView.findViewById(R.id.tv_renren_id);

        tvGender = (TextView) mBasicInfoView.findViewById(R.id.tv_gender);

        tvBirth = (TextView) mBasicInfoView.findViewById(R.id.tv_birth);

        tvHometown = (TextView) mBasicInfoView.findViewById(R.id.tv_hometown);

        tvNetwork = (TextView) mBasicInfoView.findViewById(R.id.tv_network);

       4、修改 获取用户个人主页信息的网络请求方法,代码如下:


    /**

     * 获取用户个人主页的信息

     */

    public void getProfileInfo() {

        String accessToken = mAuthTokenManager.getAccessToken();

        LogUtil.e(TAG, "accessToken = " + accessToken);



        Map<String, String> parameter = new HashMap<String, String>();

        parameter.put("v", "1.0"); // API的版本号,固定值为1.0 

        parameter.put("access_token", accessToken); // OAuth2.0验证授权后获得的token。

        parameter.put("format", "JSON"); // 返回值的格式。请指定为JSON或者XML

        parameter.put("call_id", "1.0"); // 请求队列号



        parameter.put("method", "users.getProfileInfo");

        parameter.put("uid", uid + ""); // 个人主页用户的Id 

        parameter.put("fields", "base_info,status,friends_count"); // 需要获取的信息的字段列表,各个字段用逗号隔开。

        AsyncHttpsPost asyncHttpsPost = new AsyncHttpsPost(Constant.API_SERVER_URL, parameter, new ParseCallback() {



            @Override

            public Object parse(String json) throws JSONException {

                LogUtil.i(TAG, "json = " + json);

                final JSONObject jsonObject = new JSONObject(json);



                mHandler.post(new Runnable() {



                    @Override

                    public void run() {

                        String name = jsonObject.optString("name");

                        LogUtil.i(TAG, "name = " + name);



                        String headurl = jsonObject.optString("headurl");

                        LogUtil.i(TAG, "headurl = " + headurl);



                        int star = jsonObject.optInt("star");

                        LogUtil.i(TAG, "star = " + star);



                        JSONObject jsonStatus = jsonObject.optJSONObject("status");

                        String status = jsonStatus.optString("content");

                        LogUtil.i(TAG, "status = " + status);



                        tvName.setText(name);

                        tvStatusContent.setText(status);



                        if (star == 1) {

                            ivStar.setVisibility(View.VISIBLE);

                        }



                        // 加载用户图像

                        /*ImageInfo imgInfo = new ImageInfo(ivIconView, headurl);

                        new ImageLoader(PersonalHomepageActivity.this).displayImage(imgInfo);*/



                        int friends_count = jsonObject.optInt("friends_count");

                        LogUtil.i(TAG, "friends_count = " + friends_count);

                        tvFriendsCount.setText(friends_count + "个好友");

                        

                        int uid = jsonObject.optInt("uid");

                        LogUtil.i(TAG, "uid = " + uid);

                        

                        String network_name = jsonObject.optString("network_name");

                        LogUtil.i(TAG, "network_name = " + network_name);

                        

                        JSONObject jsonBaseInfo = jsonObject.optJSONObject("base_info");

                        JSONObject jsonBirth = jsonBaseInfo.optJSONObject("birth");

                        JSONObject jsonHometown = jsonBaseInfo.optJSONObject("hometown");

                        

                        int gender = jsonBaseInfo.optInt("gender");

                        LogUtil.i(TAG, "gender = " + gender);

                        

                        String birth_month = jsonBirth.optString("birth_month");

                        LogUtil.i(TAG, "birth_month = " + birth_month);

                        

                        String birth_day = jsonBirth.optString("birth_day");

                        LogUtil.i(TAG, "birth_day = " + birth_day);

                        

                        String birth_year = jsonBirth.optString("birth_year");

                        LogUtil.i(TAG, "birth_year = " + birth_year);

                        

                        String province = jsonHometown.optString("province");

                        LogUtil.i(TAG, "province = " + province);

                        

                        String city = jsonHometown.optString("city");

                        LogUtil.i(TAG, "city = " + city);

                        

                        String sexString = "男";

                        if(gender == 0){

                            sexString = "女";

                        }

                        

                        tvRenrenId.setText("人人ID:" + uid);

                        tvGender.setText("性别:" + sexString);

                        tvBirth.setText("生日:" + birth_year + "年" + birth_month + "月" + birth_day + "日");

                        tvHometown.setText("家乡:" + province + " " + city);

                        tvNetwork.setText("网络:" + network_name);

                        

                    }

                });



                return null;

            }

        }, new ResultCallback() {



            @Override

            public void onSuccess(final Object obj) {

                /* {

                      "uid":221659942,

                      "status":{"content":"我才知道草莓翻转,是这个意思(偷笑) 转自谭静:明天最后一门考试,结束后,就真的迎来暑假啦~~哇卡卡卡~~~下学期也终于木有课了~~~(twg)(大笑)(ys)(流口水)","time":"2013-07-02 14:37:01"},

                      "star":1,

                      "network_name":"西北大学",

                      "headurl":"http://hdn.xnimg.cn/photos/hdn421/20130614/1350/tiny_cm9Q_ec73000461fa113e.jpg",

                      "name":"谭静",

                      "base_info":{"birth":{"birth_month":3,"birth_day":21,"birth_year":"1987"},"hometown":{"province":"河北","city":"唐山市"},"gender":0}

                   }*/

            }



            @Override

            public void onFail(int errorCode) {

                LogUtil.i(TAG, "freshNewsList errorCode = " + errorCode);



            }

        });



        mDefaultThreadPool.execute(asyncHttpsPost);

        mAsyncRequests.add(asyncHttpsPost);

    }

       5、在顶部下拉菜单Item点击事件处理器( public void onItemClick(AdapterView<?> parent, View view, int position, long id) { })中,添加相应的处理。代码如下:


                else if(PERSONAL_HOMEPAGE_TYPE_DATA.equals(fresh_news_type))

                { 

                    // 资料

                    tvType.setText("好友信息");

                    mBasicInfoView.setVisibility(View.VISIBLE);

                    

                    page = 1;

                    mFreshNewsList.clear();

                    mListView.setPullLoadEnable(false);

                    mListView.setPullRefreshEnable(false);

                    mFreshNewsAdapter.notifyDataSetChanged();

                } else {

                    mBasicInfoView.setVisibility(View.GONE);

                    

                    page = 1;

                    mFreshNewsList.clear();



                    getFreshNews();

                }

        6、运行效果图如下:

三、个人(好友)主页界面到目前为止,完整的代码如下:


package com.everyone.android.ui;



import java.text.SimpleDateFormat;

import java.util.HashMap;

import java.util.LinkedList;

import java.util.Map;



import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;



import android.graphics.drawable.BitmapDrawable;

import android.os.Bundle;

import android.text.TextUtils;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.Button;

import android.widget.FrameLayout.LayoutParams;

import android.widget.ImageView;

import android.widget.LinearLayout;

import android.widget.ListView;

import android.widget.PopupWindow;

import android.widget.RelativeLayout;

import android.widget.TextView;

import android.widget.Toast;



import com.everyone.android.R;

import com.everyone.android.api.NetworkBaseActivity;

import com.everyone.android.bitmap.ImageLoader;

import com.everyone.android.callback.ParseCallback;

import com.everyone.android.callback.ResultCallback;

import com.everyone.android.entity.FreshNews;

import com.everyone.android.entity.ImageInfo;

import com.everyone.android.net.AsyncBaseRequest;

import com.everyone.android.net.AsyncHttpsPost;

import com.everyone.android.ui.freshnews.FreshNewsAdapter;

import com.everyone.android.ui.freshnews.FreshNewsPopupAdapter;

import com.everyone.android.utils.Constant;

import com.everyone.android.utils.LogUtil;

import com.everyone.android.widget.TopMenuNavbar;

import com.everyone.android.widget.XListView;

import com.everyone.android.widget.XListView.IXListViewListener;

import com.google.gson.Gson;

import com.google.gson.reflect.TypeToken;



/**

 * 功能描述:个人主页(当前登录用户的个人主页或者好友的个人主页)

 * @author android_ls

 */

public class PersonalHomepageActivity extends NetworkBaseActivity implements IXListViewListener, OnClickListener {



    /**

     * LOG打印标签

     */

    private static final String TAG = PersonalHomepageActivity.class.getSimpleName();

    

    private TopMenuNavbar topMenuNavbar;



    private XListView mListView;



    private FreshNewsAdapter mFreshNewsAdapter;



    /**

     * 新鲜事信息集合

     */

    private LinkedList<FreshNews> mFreshNewsList = new LinkedList<FreshNews>();



    /**

     * 用户信息唯一标识

     */

    private int uid;



    /**

     * 每一页记录数,默认值为30,最大50 

     */

    private int pageCount = 30;



    /**

     * 当前获取第几页,默认值为1

     */

    private int page = 1;



    private LayoutInflater mInflater;



    // 用户图像

    private ImageView ivIconView;



    // 用户名

    private TextView tvName;



    // 表示该用户是否为星级用户 1表示该用户是星级用户,0表示否

    private ImageView ivStar;



    // 用户状态信息

    private TextView tvStatusContent;



    // 是否为VIP用户

    private Button btnVip;

    

    /**

     * 显示当前过滤的信息所属的类型

     */

    private TextView tvType;

    

    /**

     * 指定信息类型的总数

     */

    private TextView tvTypeCount;



    /**

     * 发表的新鲜事,默认请求所有类型的新鲜事

     */

    private static final String FRESH_NEWS_TYPE_ALL = "10,11,20,21,22,23,30,31,32,33,34,35,36";



    /**

     * 照片(相册)

     */

    private static final String FRESH_NEWS_TYPE_PHOTO = "30,31";



    /**

     * 状态

     */

    private static final String FRESH_NEWS_TYPE_STATUS = "10,11";



    /**

     * 日志

     */

    private static final String FRESH_NEWS_TYPE_BLOG = "20,22";



    /**

     * 分享的新鲜事

     */

    private static final String FRESH_NEWS_TYPE_SHARE = "21,23,32,33,36";

    

    /**

     * 最近来访

     */

    private static final String PERSONAL_HOMEPAGE_TYPE_LATELY = "1";

    

    /**

     * 资料

     */

    private static final String PERSONAL_HOMEPAGE_TYPE_DATA = "2";

    

    /**

     * 新鲜事类型数组

     */

    private String[] freshNewsTypes = { 

            PERSONAL_HOMEPAGE_TYPE_LATELY,

            FRESH_NEWS_TYPE_ALL, 

            PERSONAL_HOMEPAGE_TYPE_DATA,

            FRESH_NEWS_TYPE_PHOTO,

            FRESH_NEWS_TYPE_STATUS,

            FRESH_NEWS_TYPE_BLOG,

            FRESH_NEWS_TYPE_SHARE};



    /**

     * 新鲜事类型,默认为当前所支持的全部类型

     */

    private String fresh_news_type = FRESH_NEWS_TYPE_ALL;



    private PopupWindow mPopupWindow;



    /**

     * 顶部下拉列表

     */

    private ListView mPopupListView;



    /**

     * 顶部下拉列表数据适配器

     */

    private FreshNewsPopupAdapter mPopupAdapter;



    /**

     * 顶部下拉列表的操作提示文本数组

     */

    private String[] mTexts;



    /**

     * 顶部下拉列表的操作指示图标Id数组

     */

    private int[] mIcons = { 

            R.drawable.v5_0_1_profile_popupwindow_type_visitor_background,

            R.drawable.v5_0_1_profile_popupwindow_type_minifeed_background,

            R.drawable.v5_0_1_profile_popupwindow_type_info_background,

            R.drawable.v5_0_1_profile_popupwindow_type_album_background,

            R.drawable.v5_0_1_profile_popupwindow_type_status_background,

            R.drawable.v5_0_1_profile_popupwindow_type_blog_background,

            R.drawable.v5_0_1_profile_popupwindow_type_share_background};



    private LinearLayout mBasicInfoView;

    private TextView tvRenrenId;

    private TextView tvGender;

    private TextView tvBirth;

    private TextView tvHometown;

    private TextView tvNetwork;

    

    private RelativeLayout rlFriends;

    private TextView tvFriendsCount;

    

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);



        setupPopupWindow();

    }



    @Override

    protected int getLayoutId() {

        return R.layout.personal_homepage;

    }



    private void setupPopupWindow() {

        View view = mInflater.inflate(R.layout.fresh_news_popupwindow, null);

        mPopupWindow = new PopupWindow(view, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, true);

        mPopupWindow.setBackgroundDrawable(new BitmapDrawable());

        mPopupWindow.setAnimationStyle(R.style.fresh_news_popup_animation);



        mPopupListView = (ListView) view.findViewById(R.id.popup_listview);

        mTexts = this.getResources().getStringArray(R.array.personal_homepage_filter_list);

        mPopupAdapter = new FreshNewsPopupAdapter(this, mIcons, mTexts);

        mPopupListView.setAdapter(mPopupAdapter);

        

        // 设置默认选中新鲜事项

        fresh_news_type = freshNewsTypes[1];

        mPopupAdapter.setPosition(1);

        mPopupAdapter.notifyDataSetChanged();

        topMenuNavbar.tvTitle.setText(mTexts[1]);

        

        // 设置顶部下拉菜单的Item事件处理

        mPopupListView.setOnItemClickListener(new OnItemClickListener() {



            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                mPopupWindow.dismiss();



                // 当前选择的项与之前的一样,则不做处理。

                if (mPopupAdapter.getPosition() == position) {

                    return;

                }



                // 新鲜事过滤事件处理

                fresh_news_type = freshNewsTypes[position];



                LogUtil.i(TAG, "onItemClick position = " + position);

                LogUtil.i(TAG, "onItemClick fresh_news_type = " + fresh_news_type);



                mPopupAdapter.setPosition(position);

                mPopupAdapter.notifyDataSetChanged();

                

                topMenuNavbar.tvTitle.setText(mTexts[position]);

                tvType.setText(mTexts[position]);

                

                if(PERSONAL_HOMEPAGE_TYPE_LATELY.equals(fresh_news_type))

                {

                    // 最近来访

                    Toast.makeText(PersonalHomepageActivity.this.getApplicationContext(), "抱歉,您选择的项官方API暂时未提供如何获取相应的数据!", Toast.LENGTH_LONG).show();

                } 

                else if(PERSONAL_HOMEPAGE_TYPE_DATA.equals(fresh_news_type))

                { 

                    // 资料

                    tvType.setText("好友信息");

                    mBasicInfoView.setVisibility(View.VISIBLE);

                    

                    page = 1;

                    mFreshNewsList.clear();

                    mListView.setPullLoadEnable(false);

                    mListView.setPullRefreshEnable(false);

                    mFreshNewsAdapter.notifyDataSetChanged();

                } else {

                    mBasicInfoView.setVisibility(View.GONE);

                    

                    page = 1;

                    mFreshNewsList.clear();



                    getFreshNews();

                }

            }

        });

    }

    

    @Override

    protected void setupViews() {

        topMenuNavbar = (TopMenuNavbar) this.findViewById(R.id.rl_top_menu_navbar);

        topMenuNavbar.tvRightOperationName.setVisibility(View.GONE);

        topMenuNavbar.ivRightLine.setVisibility(View.GONE);



        // 将顶部左侧的menu图标换成back图标

        LinearLayout llBackMenu = topMenuNavbar.llShowMenu;

        ImageView ivBack = (ImageView) llBackMenu.findViewById(R.id.iv_back);

        ivBack.setImageResource(R.drawable.v5_0_1_flipper_head_back);



        // 将顶部右侧的刷新按钮换成下拉菜单图标

        LinearLayout llDownOperation = topMenuNavbar.mLlRefresh;

        ImageView ivOperation = (ImageView) llDownOperation.findViewById(R.id.iv_refresh);

        ivOperation.setImageResource(R.drawable.v5_0_1_flipper_head_menu);



        llBackMenu.setOnClickListener(this);

        llDownOperation.setOnClickListener(this);

        topMenuNavbar.mLlDownList.setOnClickListener(this);



        mListView = (XListView) this.findViewById(R.id.listview);

        mListView.setPullLoadEnable(false);

        mListView.setPullRefreshEnable(false);

        mListView.setXListViewListener(this);



        // HeadView组件

        mInflater = LayoutInflater.from(this.getContext());

        LinearLayout mHeadView = (LinearLayout) mInflater.inflate(R.layout.personal_homepage_head, null);

        mListView.addHeaderView(mHeadView);



        // 用户基本信息组件

        mBasicInfoView = (LinearLayout) mInflater.inflate(R.layout.personal_homepage_user_basic, null);

        mBasicInfoView.setVisibility(View.GONE);

        mListView.addFooterView(mBasicInfoView);

        

        mFreshNewsAdapter = new FreshNewsAdapter(this, mFreshNewsList);

        mListView.setAdapter(mFreshNewsAdapter);



        tvName = (TextView) mHeadView.findViewById(R.id.tv_name);

        ivIconView = (ImageView) mHeadView.findViewById(R.id.iv_icon);

        ivStar = (ImageView) mHeadView.findViewById(R.id.iv_star);

        tvStatusContent = (TextView) mHeadView.findViewById(R.id.tv_status_content);

        btnVip = (Button) mHeadView.findViewById(R.id.btn_vip);

        tvType = (TextView) mHeadView.findViewById(R.id.tv_type);

        tvTypeCount = (TextView) mHeadView.findViewById(R.id.tv_type_count);

        

        tvRenrenId = (TextView) mBasicInfoView.findViewById(R.id.tv_renren_id);

        tvGender = (TextView) mBasicInfoView.findViewById(R.id.tv_gender);

        tvBirth = (TextView) mBasicInfoView.findViewById(R.id.tv_birth);

        tvHometown = (TextView) mBasicInfoView.findViewById(R.id.tv_hometown);

        tvNetwork = (TextView) mBasicInfoView.findViewById(R.id.tv_network);

        

        // 好友的数量

        rlFriends = (RelativeLayout) mBasicInfoView.findViewById(R.id.rl_friends);

        tvFriendsCount = (TextView) mBasicInfoView.findViewById(R.id.tv_friends_count);

        rlFriends.setOnClickListener(this);

    }



    @Override

    protected void initialized() {

        // TODO Auto-generated method stub

        uid = this.getIntent().getIntExtra("actor_id", -1);

        LogUtil.i(TAG, "uid = " + uid);



        getProfileInfo();

        getUserImage();

        getFreshNews();

    }



    @Override

    public void onClick(View v) {

        // TODO Auto-generated method stub



        switch (v.getId()) {

        case R.id.ll_back:

            onBackPressed();

            break;

        case R.id.ll_down_list:

            if (mPopupWindow != null) {

                mPopupWindow.showAsDropDown(topMenuNavbar);

            }

            break;

        case R.id.rl_friends:

            // 切换到好友列表界面

            

            break; 

        default:

            break;

        }

    }



    // 下拉刷新

    @Override

    public void onRefresh() {

        page = 1;

        getFreshNews();

    }



    // 加载更多

    @Override

    public void onLoadMore() {

        page++;

        getFreshNews();

    }

    

    /**

     * 获取用户个人主页的信息

     */

    public void getProfileInfo() {

        String accessToken = mAuthTokenManager.getAccessToken();

        LogUtil.e(TAG, "accessToken = " + accessToken);



        Map<String, String> parameter = new HashMap<String, String>();

        parameter.put("v", "1.0"); // API的版本号,固定值为1.0 

        parameter.put("access_token", accessToken); // OAuth2.0验证授权后获得的token。

        parameter.put("format", "JSON"); // 返回值的格式。请指定为JSON或者XML

        parameter.put("call_id", "1.0"); // 请求队列号



        parameter.put("method", "users.getProfileInfo");

        parameter.put("uid", uid + ""); // 个人主页用户的Id 

        parameter.put("fields", "base_info,status,friends_count"); // 需要获取的信息的字段列表,各个字段用逗号隔开。
这里我就分享一份资料,希望可以帮助到大家提升进阶。

内容包含:**Android学习PDF+架构视频+面试文档+源码笔记****高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料** 这几块的内容。分享给大家,非常适合近期有面试和想在技术道路上继续精进的朋友。

如果你有需要的话,可以[**点击Android学习PDF+架构视频+面试文档+源码笔记获取免费领取方式**](https://github.com/a120464/Android-P7/blob/master/Android%E5%BC%80%E5%8F%91%E4%B8%8D%E4%BC%9A%E8%BF%99%E4%BA%9B%EF%BC%9F%E5%A6%82%E4%BD%95%E9%9D%A2%E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)

> 喜欢本文的话,不妨给我点个小赞、评论区留言或者转发支持一下呗~

![img](https://p9-xtjj-sign.byteimg.com/tos-cn-i-73owjymdk6/3537498e201d447e948444349f8a6b9e~tplv-73owjymdk6-jj-mark-v1:0:0:0:0:5o6Y6YeR5oqA5pyv56S-5Yy6IEAg55So5oi3MzIxMjA3NDIwNDUy:q75.awebp?rk3s=f64ab15b&x-expires=1772345882&x-signature=rRkAVfjiD8KtGsfeI0K9qMrQn%2FU%3D)