最后
希望本文对你有所启发,有任何面试上的建议也欢迎留言分享给大家。
好了,今天的分享就到这里,如果你对在面试中遇到的问题,或者刚毕业及工作几年迷茫不知道该如何准备面试并突破现状提升自己,对于自己的未来还不够了解不知道给如何规划,来看看同行们都是如何突破现状,怎么学习的,来吸收他们的面试以及工作经验完善自己的之后的面试计划及职业规划。
好了~如果你看到了这里,觉得文章写得不错就给个赞呗?如果你觉得那里值得改进的,请给我留言。一定会认真查询,修正不足。谢谢。
为什么某些人会一直比你优秀,是因为他本身就很优秀还一直在持续努力变得更优秀,而你是不是还在满足于现状内心在窃喜!希望读到这的您能点个小赞和关注下我,以后还会更新技术干货,谢谢您的支持!
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
33 分享相册的新鲜事。
36 page分享照片的新鲜事。
50 分享视频的新鲜事。
51 分享链接的新鲜事。
52 分享音乐的新鲜事。
53 page分享视频的新鲜事。
54 page分享链接的新鲜事。
55 page分享音乐的新鲜事。
定义一个全局变量用于纪录当前的新鲜事类型
/**
* 新鲜事类型
*/
// private String fresh_news_type = FRESH_NEWS_TYPE_ALL;
private String fresh_news_type = FRESH_NEWS_TYPE_SHARE;
我们先处理分享照片的新鲜事
/**
* 分享的新鲜事
*/
private static final String FRESH_NEWS_TYPE_SHARE = "32,33,36";
网络请求处理与前面的一样,修改了下面这行:
parameter.put("type", fresh_news_type); // 新鲜事的类别,多个类型以逗号分隔,type列表
网络请求处理完整的代码如下:
/**
* 向服务器端请求新鲜事的数据
*/
public void getFreshNews() {
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", "feed.get");
parameter.put("type", fresh_news_type); // 新鲜事的类别,多个类型以逗号分隔,type列表
// parameter.put("uid", ""); // 支持传入当前用户的一个好友ID,表示获取此好友的新鲜事,如果不传,默认为获取当前用户的新鲜事
parameter.put("page", page + ""); // 支持分页,指定页号,页号从1开始,默认值为1
parameter.put("count", pageCount + ""); // 支持分页,每一页记录数,默认值为30,最大50
AsyncHttpsPost asyncHttpsPost = new AsyncHttpsPost(Constant.API_SERVER_URL, parameter, new ParseCallback() {
@Override
public Object parse(String json) throws JSONException {
LogUtil.i(TAG, "json = " + json);
Gson gson = new Gson();
java.lang.reflect.Type type = new TypeToken<LinkedList<FreshNews>>() {
}.getType();
LinkedList<FreshNews> freshNewsList = gson.fromJson(json, type);
LogUtil.i(TAG, "freshNewsList = " + freshNewsList.size());
return freshNewsList;
}
}, new ResultCallback() {
@Override
public void onSuccess(Object obj) {
@SuppressWarnings("unchecked")
LinkedList<FreshNews> freshNewsList = (LinkedList<FreshNews>) obj;
if (freshNewsList.isEmpty()) {
return;
}
mFreshNewsList.addAll(freshNewsList);
mHandler.post(new Runnable() {
@Override
public void run() {
mLoadingView.setVisibility(View.GONE);
mFreshNewsAdapter.notifyDataSetChanged();
}
});
}
@Override
public void onFail(int errorCode) {
LogUtil.i(TAG, "freshNewsList errorCode = " + errorCode);
}
});
mDefaultThreadPool.execute(asyncHttpsPost);
mAsyncRequests.add(asyncHttpsPost);
}
关于分享的图片显示效果,人人官方客户端截图如下:
我猜测人人官方,用于显示分享的图片ImageView配置如下:
<ImageView
android:id="@+id/iv_photo_image"
android:layout_width="150dip"
android:layout_height="150dip"
android:layout_marginTop="10dip"
android:scaleType="centerCrop" />
解释: 人人官方的做法,显示固定大小的图片,根据设置的宽高选择中间的区域对原图进行剪裁。
我觉得裁剪后的图片看起来不舒服,我实现的效果图如下:
用于显示分享的图片ImageView配置如下:
<ImageView
android:id="@+id/iv_photo_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
完整的用于展示分享的照片的布局文件fresh_news_item_share_photo.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:orientation="horizontal" >
<View
android:id="@+id/v_photo_left_line"
android:layout_width="2dip"
android:layout_height="fill_parent"
android:background="#20333333" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_photo_owner_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff005092"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_photo_describe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:textColor="#000000"
android:textSize="13sp" />
<ImageView
android:id="@+id/iv_photo_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
<!-- 人人官方的做法,显示固定大小的图片,并对原图进行剪裁。根据设置的宽高选择适中的区域进行裁剪-->
<!--
<ImageView
android:id="@+id/iv_photo_image"
android:layout_width="150dip"
android:layout_height="150dip"
android:layout_marginTop="10dip"
android:scaleType="centerCrop" />
-->
<TextView
android:id="@+id/tv_photo_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:textColor="#ff888888"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
在fresh_news_list_item.xml布局文件中,添加用于展示分享的照片方式:
<!-- 分享的图片-->
<include
android:id="@+id/ll_share_photo"
android:layout_alignLeft="@+id/tv_nickname"
android:layout_below="@+id/tv_message_content"
android:layout_marginTop="10dip"
layout="@layout/fresh_news_item_share_photo"
android:visibility="gone" />
新鲜事列表数据适配器(FreshNewsAdapter)文件中,添加的处理:
case 32: // 分享照片的新鲜事。
case 33: // 分享相册的新鲜事。
// 设置分享标识图标
holder.text3.setCompoundDrawablesWithIntrinsicBounds(R.drawable.v5_0_1_newsfeed_share_icon, 0, 0, 0);
// 内容的前缀
String prefix1 = freshNews.getPrefix();
if (!TextUtils.isEmpty(prefix1)) {
holder.text2.setVisibility(View.VISIBLE);
holder.text2.setText(prefix1);
} else {
holder.text2.setVisibility(View.GONE);
}
break;
在新鲜事中包含的媒体内容中,添加的条件判断分支:
else if ("photo".equals(media_type)) {
holder.linearLayout3.setVisibility(View.VISIBLE);
ImageInfo imgInfo = new ImageInfo(holder.imageView2, att.getRaw_src());
mImageLoader.displayImage(imgInfo);
String owner_name = att.getOwner_name();
if(!TextUtils.isEmpty(owner_name)){
holder.text7.setVisibility(View.VISIBLE);
holder.text7.setText(owner_name);
} else {
holder.text7.setVisibility(View.GONE);
}
String description = freshNews.getDescription();
if(!TextUtils.isEmpty(description)){
holder.text8.setVisibility(View.VISIBLE);
holder.text8.setText(description);
} else {
holder.text8.setVisibility(View.GONE);
}
holder.text9.setText("【" + freshNews.getTitle() + "】");
}
FreshNewsAdapter文件到目前为止的完整代码如下:
package com.everyone.android.ui.freshnews;
import java.util.LinkedList;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.everyone.android.R;
import com.everyone.android.bitmap.ImageLoader;
import com.everyone.android.entity.Attachment;
import com.everyone.android.entity.Comment;
import com.everyone.android.entity.Comments;
import com.everyone.android.entity.FreshNews;
import com.everyone.android.entity.ImageInfo;
import com.everyone.android.entity.Source;
import com.everyone.android.ui.EveryoneActivity;
import com.everyone.android.utils.DensityUtil;
import com.everyone.android.utils.LogUtil;
/**
* 功能描述:新鲜事列表数据适配器
* @author android_ls
*/
public class FreshNewsAdapter extends BaseAdapter {
/**
* LOG打印标签
*/
private static final String TAG = "FreshNewsAdapter";
private LayoutInflater inflater;
private LinkedList<FreshNews> mFreshNewsList;
private EveryoneActivity mActivity;
private ImageLoader mImageLoader;
public FreshNewsAdapter(EveryoneActivity activity, LinkedList<FreshNews> freshNewsList) {
inflater = LayoutInflater.from(activity);
mActivity = activity;
mFreshNewsList = freshNewsList;
this.mImageLoader = new ImageLoader(mActivity);
}
@Override
public int getCount() {
return mFreshNewsList.size();
}
@Override
public Object getItem(int arg0) {
return mFreshNewsList.get(arg0);
}
@Override
public long getItemId(int position) {
return position;
}
/* (non-Javadoc)
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
*/
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.fresh_news_list_item, null);
holder = new ViewHolder();
holder.imageView1 = (ImageView) convertView.findViewById(R.id.iv_user_image);
holder.text1 = (TextView) convertView.findViewById(R.id.tv_nickname);
holder.text2 = (TextView) convertView.findViewById(R.id.tv_message_content);
holder.linearLayout1 = (LinearLayout) convertView.findViewById(R.id.ll_comments_content);
holder.linearLayout2 = (LinearLayout) convertView.findViewById(R.id.ll_update_status);
holder.linearLayout3 = (LinearLayout) convertView.findViewById(R.id.ll_share_photo);
holder.text7 = (TextView) convertView.findViewById(R.id.tv_photo_owner_name);
holder.text8 = (TextView) convertView.findViewById(R.id.tv_photo_describe);
holder.imageView2 = (ImageView) convertView.findViewById(R.id.iv_photo_image);
holder.text9 = (TextView) convertView.findViewById(R.id.tv_photo_source);
holder.text3 = (TextView) convertView.findViewById(R.id.tv_published);
holder.text4 = (TextView) convertView.findViewById(R.id.tv_source);
holder.text5 = (TextView) convertView.findViewById(R.id.tv_status_name);
holder.text6 = (TextView) convertView.findViewById(R.id.tv_status_content);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final FreshNews freshNews = mFreshNewsList.get(position);
// 姓名
holder.text1.setText(freshNews.getName());
// 加载图像
String headurl = freshNews.getHeadurl();
LogUtil.i(TAG, "headurl = " + headurl);
if (!TextUtils.isEmpty(headurl)) {
int widthPx = DensityUtil.dip2px(mActivity, 43);
ImageInfo imgInfo = new ImageInfo(holder.imageView1, headurl, widthPx, widthPx);
mImageLoader.displayImage(imgInfo);
}
LogUtil.i(TAG, "description = " + freshNews.getDescription());
LogUtil.i(TAG, "freshNews.getMessage() = " + freshNews.getMessage());
LogUtil.i(TAG, "freshNews.getTitle() = " + freshNews.getTitle());
LogUtil.i(TAG, "freshNews.getPrefix() = " + freshNews.getPrefix());
// 用户自定义输入的内容
String message = freshNews.getMessage();
if (!TextUtils.isEmpty(message)) {
holder.text2.setVisibility(View.VISIBLE);
holder.text2.setText(message);
} else {
holder.text2.setVisibility(View.GONE);
}
// page代表公共主页新鲜事
int feedType = freshNews.getFeed_type();
LogUtil.i(TAG, "feedType = " + feedType);
switch (feedType) {
case 10: // 更新状态的新鲜事。
case 11: // page更新状态的新鲜事。
// 设置状态标识图标
holder.text3.setCompoundDrawablesWithIntrinsicBounds(R.drawable.v5_0_1_newsfeed_status_icon, 0, 0, 0);
// 内容的前缀
String prefix = freshNews.getPrefix();
if (!TextUtils.isEmpty(prefix)) {
holder.text2.setVisibility(View.VISIBLE);
holder.text2.setText(prefix);
} else {
holder.text2.setVisibility(View.GONE);
}
break;
case 20: // 发表日志的新鲜事。
case 22: // page发表日志的新鲜事。
break;
case 21: // 分享日志的新鲜事。
case 23: // page分享日志的新鲜事。
break;
case 30: // 上传照片的新鲜事。
case 31: // page上传照片的新鲜事。
break;
case 32: // 分享照片的新鲜事。
case 33: // 分享相册的新鲜事。
// 设置分享标识图标
holder.text3.setCompoundDrawablesWithIntrinsicBounds(R.drawable.v5_0_1_newsfeed_share_icon, 0, 0, 0);
// 内容的前缀
String prefix1 = freshNews.getPrefix();
if (!TextUtils.isEmpty(prefix1)) {
holder.text2.setVisibility(View.VISIBLE);
holder.text2.setText(prefix1);
} else {
holder.text2.setVisibility(View.GONE);
}
break;
// ...
default:
break;
}
holder.linearLayout2.setVisibility(View.GONE);
holder.linearLayout3.setVisibility(View.GONE);
// 新鲜事中包含的媒体内容
LinkedList<Attachment> attachments = freshNews.getAttachment();
if (attachments != null) {
int size = attachments.size();
LogUtil.i(TAG, "size = " + size);
for (int i = 0; i < size; i++) {
Attachment att = attachments.get(i);
String media_type = att.getMedia_type();
LogUtil.i(TAG, "media_type = " + media_type);
LogUtil.i(TAG, "att.getContent() = " + att.getContent());
LogUtil.i(TAG, "getHref = " + att.getHref());
LogUtil.i(TAG, "att.getOwner_id() = " + att.getOwner_id());
LogUtil.i(TAG, "getOwner_name() = " + att.getOwner_name());
LogUtil.i(TAG, "getRaw_src() = " + att.getRaw_src());
LogUtil.i(TAG, "getScr() = " + att.getScr());
if ("status".equals(media_type)) {
holder.linearLayout2.setVisibility(View.VISIBLE);
holder.text5.setText(att.getOwner_name());
holder.text6.setText(att.getContent());
} else if ("photo".equals(media_type)) {
### 新的开始
改变人生,没有什么捷径可言,这条路需要自己亲自去走一走,只有深入思考,不断反思总结,保持学习的热情,一步一步构建自己完整的知识体系,才是最终的制胜之道,也是程序员应该承担的使命。
**《系列学习视频》**

**《系列学习文档》**

**《我的大厂面试之旅》**

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.youkuaiyun.com/topics/618156601)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
_name());
LogUtil.i(TAG, "getRaw_src() = " + att.getRaw_src());
LogUtil.i(TAG, "getScr() = " + att.getScr());
if ("status".equals(media_type)) {
holder.linearLayout2.setVisibility(View.VISIBLE);
holder.text5.setText(att.getOwner_name());
holder.text6.setText(att.getContent());
} else if ("photo".equals(media_type)) {
### 新的开始
改变人生,没有什么捷径可言,这条路需要自己亲自去走一走,只有深入思考,不断反思总结,保持学习的热情,一步一步构建自己完整的知识体系,才是最终的制胜之道,也是程序员应该承担的使命。
**《系列学习视频》**
[外链图片转存中...(img-DfDwugDP-1715849461875)]
**《系列学习文档》**
[外链图片转存中...(img-HAyjBxzT-1715849461876)]
**《我的大厂面试之旅》**
[外链图片转存中...(img-GUEt12WQ-1715849461876)]
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.youkuaiyun.com/topics/618156601)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**