Android腾讯微薄客户端开发九:博主详情界面篇(广播,听众,收听)

[img]http://dl.iteye.com/upload/attachment/527552/9bcc34ea-f809-3299-ab31-0170c4ebe5a4.jpg[/img]
[color=red]点击顶部的标题栏,界面跳转到此博主的关注界面[/color]
[img]http://dl.iteye.com/upload/attachment/527550/b82dede7-15c2-33c9-beb4-8d14b012e612.jpg[/img]
[color=red]关注界面,此界面下面的对话和点评以及上面的广播,听众和收听丑了点,没时间了,今天时间比较紧,美化的事情交给你们了。[/color]
public class UserInfoActivity extends Activity implements OnItemClickListener{
private String currentNick;
private String name;
private String origtext;
private String timestamp;
private DataHelper dataHelper;
private UserInfo user;
private MyWeiboSync weibo;
private Handler handler;
private AsyncImageLoader asyncImageLoader;
private UserInfoThread thread;
private String weiboid;
private String returnJsonStr;
private JSONObject dataObj ;
private ImageView user_headicon;
private TextView user_nick;
private TextView user_name;
private TextView user_origtext;
private TextView user_time;
private TextView user_sex;
private TextView user_age;
private TextView user_location;
private TextView user_verifyinfo;
private Button user_back_btn;
private Button user_dialog_btn;
private Button user_message_btn;
private GridView gridView;

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.user_info);
setUpViews();//设置view
setUpListeners();//设置listenter
asyncImageLoader = new AsyncImageLoader();
dataHelper = new DataHelper(UserInfoActivity.this);
weibo = new MyWeiboSync();
List<UserInfo> userList = dataHelper.GetUserList(false);

SharedPreferences preferences = getSharedPreferences("default_user",Activity.MODE_PRIVATE);
String nick = preferences.getString("user_default_nick", "");

if (nick != "") {
user = dataHelper.getUserByName(nick,userList);
}

weibo.setAccessTokenKey(user.getToken());
weibo.setAccessTokenSecrect(user.getTokenSecret());

//获取从上一界面传递过来的数据
Intent intent = getIntent();
name = intent.getStringExtra("name");
currentNick = intent.getStringExtra("nick");//昵称
origtext = intent.getStringExtra("origtext");
timestamp = intent.getStringExtra("timestamp");
user_name.setText("@"+name);
user_origtext.setText(origtext);
user_time.setText(timestamp);

handler = new UserInfoHandler();
thread = new UserInfoThread();
thread.start();//开启一个线程获取数据
}

private void setUpViews(){
user_headicon = (ImageView) findViewById(R.id.user_headicon);
user_nick = (TextView) findViewById(R.id.user_nick);
user_name = (TextView) findViewById(R.id.user_name);
user_origtext = (TextView) findViewById(R.id.user_origtext);
user_time = (TextView) findViewById(R.id.user_time);
user_sex = (TextView) findViewById(R.id.user_sex);
user_age = (TextView) findViewById(R.id.user_age);
user_location = (TextView) findViewById(R.id.user_location);
user_verifyinfo = (TextView) findViewById(R.id.user_verifyinfo);
user_back_btn = (Button) findViewById(R.id.user_back_btn);
user_dialog_btn = (Button) findViewById(R.id.user_dialog_btn);
user_message_btn = (Button) findViewById(R.id.user_message_btn);
gridView = (GridView)findViewById(R.id.user_grid);
}

private void setUpListeners(){
gridView.setOnItemClickListener(this);
}

class UserInfoThread extends Thread {
@Override
public void run() {
returnJsonStr = weibo.getUserInfoByName(weibo.getAccessTokenKey(), weibo.getAccessTokenSecrect(), name);
//通知handler处理数据
Message msg = handler.obtainMessage();
handler.sendMessage(msg);
}
}

class UserInfoHandler extends Handler {
@Override
public void handleMessage(Message msg){
Drawable cachedImage;
try {
dataObj = new JSONObject(returnJsonStr).getJSONObject("data");
cachedImage = asyncImageLoader.loadDrawable(dataObj.getString("head")+"/100",user_headicon, new ImageCallback(){
@Override
public void imageLoaded(Drawable imageDrawable,ImageView imageView, String imageUrl) {
imageView.setImageDrawable(imageDrawable);
}
});
if (cachedImage == null) {
user_headicon.setImageResource(R.drawable.icon);
} else {
user_headicon.setImageDrawable(cachedImage);
}
user_nick.setText(dataObj.getString("nick"));
user_sex.setText(dataObj.getInt("sex")==1?"男":"女");
if(dataObj.getInt("birth_year")!=0){
user_age.setText((Calendar.getInstance().get(Calendar.YEAR)-dataObj.getInt("birth_year"))+"岁");
}
user_location.setText(dataObj.getString("location"));
String verifyinfo = dataObj.getString("verifyinfo");
if(verifyinfo==null||"".equals(verifyinfo)){
user_verifyinfo.setText("这家伙很懒,没留什么");
}else{
user_verifyinfo.setText(verifyinfo);
}
final List<String> numsList = new ArrayList<String>();
numsList.add(dataObj.getString("tweetnum"));
numsList.add(dataObj.getString("fansnum"));
numsList.add(dataObj.getString("idolnum"));
gridView.setAdapter(new GridAdapter(UserInfoActivity.this, numsList));
} catch (JSONException e) {
e.printStackTrace();
}
}
}

class GridAdapter extends BaseAdapter {
private Context context;
private LayoutInflater inflater;
List<String> numList;

public GridAdapter(Context context, List<String> numList) {
super();
this.context = context;
this.numList = numList;
this.inflater = LayoutInflater.from(context);
}

@Override
public int getCount() {
return numList.size();
}

@Override
public Object getItem(int position) {
return numList.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent){
convertView = inflater.inflate(R.layout.userinfo_grid_item, null);
TextView num = (TextView)convertView.findViewById(R.id.userinfo_grid_num);
TextView title = (TextView)convertView.findViewById(R.id.userinfo_grid_title);
ImageView image = (ImageView)convertView.findViewById(R.id.userinfo_grid_image);
switch (position) {
case 0:
num.setText(numList.get(0));
title.setText("广播");
image.setVisibility(View.VISIBLE);
break;
case 1:
num.setText(numList.get(1));
title.setText("听众");
image.setVisibility(View.VISIBLE);
break;
case 2:
num.setText(numList.get(2));
title.setText("收听");
break;

default:
break;
}
return convertView;
}
}

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3){
switch (position) {
case 0:
Intent intent = new Intent(UserInfoActivity.this,TweetsActivity.class);
intent.putExtra("name", name);
intent.putExtra("nick",currentNick);
startActivity(intent);
break;
case 1:
Intent intent2 = new Intent(UserInfoActivity.this,FansActivity.class);
intent2.putExtra("name", name);
intent2.putExtra("nick",currentNick);
startActivity(intent2);
break;
case 2:
Intent intent3 = new Intent(UserInfoActivity.this,IdolActivity.class);
intent3.putExtra("name", name);
intent3.putExtra("nick",currentNick);
startActivity(intent3);
break;
default:
break;
}

}
}


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#c0c8d0"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@+id/user_top" android:paddingTop="5.0dip" android:layout_width="fill_parent" android:layout_height="60.0dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true">
<ImageView android:id="@+id/user_headicon" android:layout_marginLeft="8.0dip" android:layout_width="45.0dip" android:layout_height="45.0dip" android:layout_alignParentLeft="true"/>
<TextView android:id="@+id/user_nick" android:layout_marginLeft="5.0dip" android:layout_width="wrap_content" android:layout_toRightOf="@id/user_headicon" android:textColor="#384050"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/user_name" android:layout_width="wrap_content" android:layout_marginLeft="10.0dip" android:layout_toRightOf="@id/user_headicon" android:textColor="#687888"
android:layout_height="wrap_content" android:layout_below="@id/user_nick"/>
</RelativeLayout>
<LinearLayout android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_below="@id/user_top">
<ImageView android:background="#a0b0b0" android:layout_width="fill_parent" android:layout_height="1.0dip" android:scaleType="fitCenter"/>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip">
<GridView android:gravity="center" android:listSelector="@drawable/listitem_selector" android:id="@+id/user_grid" android:background="@drawable/userinfo_grid_bg" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="3"/>
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:background="@drawable/panel_bg">
<TextView android:id="@+id/user_sex" android:layout_marginLeft="5.0dip" android:layout_alignParentLeft="true" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/user_age" android:layout_toRightOf="@id/user_sex" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/user_location" android:layout_toRightOf="@id/user_age" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/user_verifyinfo" android:layout_marginLeft="5.0dip" android:layout_alignParentLeft="true" android:layout_below="@id/user_sex" android:layout_width="fill_parent" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content"/>
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:background="@drawable/panel_bg">
<TextView android:text="最新广播:" android:layout_width="fill_parent" android:layout_marginLeft="5.0dip" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/user_time" android:layout_width="wrap_content" android:layout_marginLeft="3.0dip" android:layout_marginTop="10.0dip" android:textSize="8.0sp" android:textColor="#788080"
android:layout_height="wrap_content" android:layout_alignParentRight="true"/>
<TextView android:id="@+id/user_origtext" android:layout_width="fill_parent" android:layout_marginLeft="5.0dip" android:textSize="12.0sp" android:textColor="#788080"
android:layout_height="wrap_content" android:layout_below="@id/user_time" android:layout_alignParentLeft="true"/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_alignParentBottom="true">
<Button android:id="@+id/user_back_btn" android:layout_width="40.0dip" android:drawableTop="@drawable/btn_back_selector" android:background="@drawable/bottom_back_bg"
android:layout_height="40.0dip" android:layout_alignParentLeft="true"/>
<LinearLayout android:id="@+id/widget41" android:layout_marginLeft="60.0dip" android:layout_alignParentBottom="true"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_toRightOf="@id/user_back_btn">
<ImageView android:background="#f8f8f8" android:layout_width="1.0dip" android:layout_height="20.0dip" android:scaleType="fitCenter"/>
<Button android:id="@+id/user_dialog_btn" android:layout_width="wrap_content" android:background="@drawable/bottom_bar_bg"
android:layout_height="wrap_content" android:text="对话"/>
<ImageView android:background="#f8f8f8" android:layout_width="1.0dip" android:layout_height="20.0dip" android:scaleType="fitCenter"/>
<Button android:id="@+id/user_message_btn" android:layout_width="wrap_content" android:background="@drawable/bottom_bar_bg"
android:layout_height="wrap_content" android:text="点评"/>
</LinearLayout>
<Button android:id="@+id/user_tohome_btn" android:layout_width="40.0dip"
android:layout_height="40.0dip" android:drawableTop="@drawable/btn_home_selector" android:background="@drawable/bottom_home_bg" android:layout_alignParentRight="true"/>
</RelativeLayout>
</RelativeLayout>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:paddingTop="3.0dip" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/userinfo_grid_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#586068"/>
<TextView android:id="@+id/userinfo_grid_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#98a0a0"/>
</LinearLayout>
<ImageView android:id="@+id/userinfo_grid_image" android:src="#d0d0d8" android:visibility="invisible" android:layout_width="1.0dip" android:layout_height="30.0dip" android:layout_marginLeft="30.0dip"/>
</LinearLayout>
技术选型 【后端】:Java 【框架】:springboot 【前端】:vue 【JDK版本】:JDK1.8 【服务器】:tomcat7+ 【数据库】:mysql 5.7+ 项目包含前后台完整源码。 项目都经过严格调试,确保可以运行! 具体项目介绍可查看博主文章或私聊获取 助力学习实践,提升编程技能,快来获取这份宝贵的资源吧! 在当今快速发展的信息技术领域,技术选型是决定一个项目成功与否的重要因素之一。基于以下的技术栈,我们为您带来了一份完善且经过实践验证的项目资源,让您在学习和提升编程技能的道路上事半功倍。以下是该项目的技术选型和其组件的详细介绍。 在后端技术方面,我们选择了Java作为编程语言。Java以其稳健性、跨平台性和丰富的库支持,在企业级应用中处于领导地位。项目采用了流行的Spring Boot框架,这个框架以简化Java企业级开发而闻名。Spring Boot提供了简洁的配置方式、内置的嵌入式服务器支持以及强大的生态系统,使开发者能够更高效地构建和部署应用。 前端技术方面,我们使用了Vue.js,这是一个用于构建用户界面的渐进式JavaScript框架。Vue以其易上手、灵活和性能出色而受到开发者的青睐,它的组件化开发思想也有助于提高代码的复用性和可维护性。 项目的编译和运行环境选择了JDK 1.8。尽管Java已经推出了更新的版本,但JDK 1.8依旧是一种成熟且稳定的选择,广泛应用于各类项目中,确保了兼容性和稳定性。 在服务器方面,本项目部署在Tomcat 7+之上。Tomcat是Apache软件基金会下的一个开源Servlet容器,也是应用最为广泛的Java Web服务器之一。其稳定性和可靠的性能表现为Java Web应用提供了坚实的支持。 数据库方面,我们采用了MySQL 5.7+。MySQL是一种高效、可靠且使用广泛的关系型数据库管理系统,5.7版本在性能和功能上都有显著的提升。 值得一提的是,该项目包含了前后台的完整源码,并经过严格调试,确保可以顺利运行。通过项目的学习和实践,您将能更好地掌握从后端到前端的完整开发流程,提升自己的编程技能。欢迎参考博主的详细文章或私信获取更多信息,利用这一宝贵资源来推进您的技术成长之路!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值