当前位置:   article > 正文

Android仿人人客户端(v5(8),2024年最新头条面试android

Android仿人人客户端(v5(8),2024年最新头条面试android

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip204888 (备注Android)
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

正文

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 mFreshNewsList = new LinkedList();

/**

  • 用户信息唯一标识

*/

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”); // 需要获取的信息的字段列表,各个字段用逗号隔开。

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

@Override

public Object parse(String json) throws JSONException {

LogUtil.i(TAG, "getProfileInfo() 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);

}

/**

  • 获取用户的图像

  • @param uid 用户Id

*/

public void getUserImage() {

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,推荐使用JSON,缺省值为XML

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

parameter.put(“method”, “users.getInfo”); // 你要访问那个接口,我们肯定调用用获取用户的信息的接口咯,该接口支持批量获取。

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

parameter.put(“fields”, “zidou,vip,mainurl”); // 返回的字段列表,可以指定返回那些字段,用逗号分隔。

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

@Override

public Object parse(String json) throws JSONException {

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

JSONArray jsonArray = new JSONArray(json);

JSONObject jsonObject = jsonArray.getJSONObject(0);

// 是否为vip用户,值1表示是;值0表示不是

final int zidou = jsonObject.optInt(“zidou”);

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

// 是否为vip用户等级,前提是zidou节点必须为1

final int vip = jsonObject.optInt(“vip”);

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

String headurl = jsonObject.optString(“mainurl”);

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

if (TextUtils.isEmpty(headurl)) {

LogUtil.i(TAG, “用户图像对应的URL为null”);

return null;

}

final String imageUrl = headurl;

mHandler.post(new Runnable() {

@Override

public void run() {

if (zidou == 1) {

btnVip.setVisibility(View.VISIBLE);

btnVip.setText(“VIP” + vip);

}

ImageInfo imgInfo = new ImageInfo(ivIconView, imageUrl);

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

}

最后

有任何问题,欢迎广大网友一起来交流,分享高阶Android学习视频资料和面试资料包~

偷偷说一句:群里高手如云,欢迎大家加群和大佬们一起交流讨论啊!

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注Android)
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

HttpsPost(Constant.API_SERVER_URL, parameter, new ParseCallback() {

@Override

public Object parse(String json) throws JSONException {

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

JSONArray jsonArray = new JSONArray(json);

JSONObject jsonObject = jsonArray.getJSONObject(0);

// 是否为vip用户,值1表示是;值0表示不是

final int zidou = jsonObject.optInt(“zidou”);

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

// 是否为vip用户等级,前提是zidou节点必须为1

final int vip = jsonObject.optInt(“vip”);

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

String headurl = jsonObject.optString(“mainurl”);

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

if (TextUtils.isEmpty(headurl)) {

LogUtil.i(TAG, “用户图像对应的URL为null”);

return null;

}

final String imageUrl = headurl;

mHandler.post(new Runnable() {

@Override

public void run() {

if (zidou == 1) {

btnVip.setVisibility(View.VISIBLE);

btnVip.setText(“VIP” + vip);

}

ImageInfo imgInfo = new ImageInfo(ivIconView, imageUrl);

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

}

最后

有任何问题,欢迎广大网友一起来交流,分享高阶Android学习视频资料和面试资料包~

偷偷说一句:群里高手如云,欢迎大家加群和大佬们一起交流讨论啊!

[外链图片转存中…(img-NnRhKSBA-1713708657705)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注Android)
[外链图片转存中…(img-BiRAVCqo-1713708657705)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/583377
推荐阅读
相关标签
  

闽ICP备14008679号