code stringlengths 3 1.18M | language stringclasses 1 value |
|---|---|
package com.outsourcing.bottle.domain;
public class ExchangeShowTipsEntry {
private int show_infoex_tips;
private int show_picex_tips;
public int getShow_infoex_tips() {
return show_infoex_tips;
}
public void setShow_infoex_tips(int show_infoex_tips) {
this.show_infoex_tips = show_infoex_tips;
}
public int getShow_picex_tips() {
return show_picex_tips;
}
public void setShow_picex_tips(int show_picex_tips) {
this.show_picex_tips = show_picex_tips;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class GroupEntry {
private int groupid;
private String group;
public int getGroupid() {
return groupid;
}
public void setGroupid(int groupid) {
this.groupid = groupid;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class LoginUserInfo {
private ResponseResult results;
private LoginUserInfoEntry loginuser_info;
private List<PasterDirConfigEntry> pasterdir_privs_list;
public LoginUserInfo() {
super();
}
public LoginUserInfo(ResponseResult results,
LoginUserInfoEntry loginuser_info) {
super();
this.results = results;
this.loginuser_info = loginuser_info;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public LoginUserInfoEntry getLoginuser_info() {
return loginuser_info;
}
public void setLoginuser_info(LoginUserInfoEntry loginuser_info) {
this.loginuser_info = loginuser_info;
}
public List<PasterDirConfigEntry> getPasterdir_privs_list() {
return pasterdir_privs_list;
}
public void setPasterdir_privs_list(List<PasterDirConfigEntry> pasterdir_privs_list) {
this.pasterdir_privs_list = pasterdir_privs_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class PhotoEntry {
private int pic_id;
private String pic_url;
private int comments_num;
private int is_doodle;
public int getPic_id() {
return pic_id;
}
public void setPic_id(int pic_id) {
this.pic_id = pic_id;
}
public String getPic_url() {
return pic_url;
}
public void setPic_url(String pic_url) {
this.pic_url = pic_url;
}
public int getComments_num() {
return comments_num;
}
public void setComments_num(int comments_num) {
this.comments_num = comments_num;
}
public int getIs_doodle() {
return is_doodle;
}
public void setIs_doodle(int is_doodle) {
this.is_doodle = is_doodle;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class CityEntry {
private String country;
private String province;
private String city;
private int cityid;
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getCityid() {
return cityid;
}
public void setCityid(int cityid) {
this.cityid = cityid;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class ExPicFeedEntry {
private int expicfeed_uid;
private int expicfeed_type;
private String expicfeed_nickname;
private String expicfeed_avatar;
private String expicfeed_content;
private String expicfeed_comment;
private String expicfeed_time;
private String expicfeed_location;
private float expicfeed_lng;
private float expicfeed_lat;
private int expicfeed_recv_uid;
private String expicfeed_recv_nickname;
private int expicfeed_isnew;
private int location_delete_enable_2;
private int location_objtype_2;
private int location_objid_2;
public int getLocation_delete_enable_2() {
return location_delete_enable_2;
}
public void setLocation_delete_enable_2(int location_delete_enable_2) {
this.location_delete_enable_2 = location_delete_enable_2;
}
public int getLocation_objtype_2() {
return location_objtype_2;
}
public void setLocation_objtype_2(int location_objtype_2) {
this.location_objtype_2 = location_objtype_2;
}
public int getLocation_objid_2() {
return location_objid_2;
}
public void setLocation_objid_2(int location_objid_2) {
this.location_objid_2 = location_objid_2;
}
public int getExpicfeed_uid() {
return expicfeed_uid;
}
public void setExpicfeed_uid(int expicfeed_uid) {
this.expicfeed_uid = expicfeed_uid;
}
public int getExpicfeed_type() {
return expicfeed_type;
}
public void setExpicfeed_type(int expicfeed_type) {
this.expicfeed_type = expicfeed_type;
}
public String getExpicfeed_nickname() {
return expicfeed_nickname;
}
public void setExpicfeed_nickname(String expicfeed_nickname) {
this.expicfeed_nickname = expicfeed_nickname;
}
public String getExpicfeed_avatar() {
return expicfeed_avatar;
}
public void setExpicfeed_avatar(String expicfeed_avatar) {
this.expicfeed_avatar = expicfeed_avatar;
}
public String getExpicfeed_content() {
return expicfeed_content;
}
public void setExpicfeed_content(String expicfeed_content) {
this.expicfeed_content = expicfeed_content;
}
public String getExpicfeed_comment() {
return expicfeed_comment;
}
public void setExpicfeed_comment(String expicfeed_comment) {
this.expicfeed_comment = expicfeed_comment;
}
public String getExpicfeed_time() {
return expicfeed_time;
}
public void setExpicfeed_time(String expicfeed_time) {
this.expicfeed_time = expicfeed_time;
}
public int getExpicfeed_isnew() {
return expicfeed_isnew;
}
public void setExpicfeed_isnew(int expicfeed_isnew) {
this.expicfeed_isnew = expicfeed_isnew;
}
public String getExpicfeed_location() {
return expicfeed_location;
}
public void setExpicfeed_location(String expicfeed_location) {
this.expicfeed_location = expicfeed_location;
}
public float getExpicfeed_lng() {
return expicfeed_lng;
}
public void setExpicfeed_lng(float expicfeed_lng) {
this.expicfeed_lng = expicfeed_lng;
}
public float getExpicfeed_lat() {
return expicfeed_lat;
}
public void setExpicfeed_lat(float expicfeed_lat) {
this.expicfeed_lat = expicfeed_lat;
}
public int getExpicfeed_recv_uid() {
return expicfeed_recv_uid;
}
public void setExpicfeed_recv_uid(int expicfeed_recv_uid) {
this.expicfeed_recv_uid = expicfeed_recv_uid;
}
public String getExpicfeed_recv_nickname() {
return expicfeed_recv_nickname;
}
public void setExpicfeed_recv_nickname(String expicfeed_recv_nickname) {
this.expicfeed_recv_nickname = expicfeed_recv_nickname;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
* 捞网类型
* @author 06peng
*
*/
public class BottleNetTypeEntry {
private int nettypeid;
private String nettype_name_cn;
private String nettype_name_en;
private String nettype_desc_cn;
private String nettype_desc_en;
private String nettype_sjwicon;
private int nettype_isshow;
private int nettype_location_select;
public int getNettypeid() {
return nettypeid;
}
public void setNettypeid(int nettypeid) {
this.nettypeid = nettypeid;
}
public String getNettype_name_cn() {
return nettype_name_cn;
}
public void setNettype_name_cn(String nettype_name_cn) {
this.nettype_name_cn = nettype_name_cn;
}
public String getNettype_name_en() {
return nettype_name_en;
}
public void setNettype_name_en(String nettype_name_en) {
this.nettype_name_en = nettype_name_en;
}
public String getNettype_desc_cn() {
return nettype_desc_cn;
}
public void setNettype_desc_cn(String nettype_desc_cn) {
this.nettype_desc_cn = nettype_desc_cn;
}
public String getNettype_desc_en() {
return nettype_desc_en;
}
public void setNettype_desc_en(String nettype_desc_en) {
this.nettype_desc_en = nettype_desc_en;
}
public String getNettype_sjwicon() {
return nettype_sjwicon;
}
public void setNettype_sjwicon(String nettype_sjwicon) {
this.nettype_sjwicon = nettype_sjwicon;
}
public int getNettype_isshow() {
return nettype_isshow;
}
public void setNettype_isshow(int nettype_isshow) {
this.nettype_isshow = nettype_isshow;
}
public int getNettype_location_select() {
return nettype_location_select;
}
public void setNettype_location_select(int nettype_location_select) {
this.nettype_location_select = nettype_location_select;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class ExFeedInfoEntry {
private int exfeed_uid;
private int exfeed_type;
private String exfeed_nickname;
private String exfeed_avatar;
private String exfeed_content;
private String exfeed_comment;
private String exfeed_time;
private String exfeed_location;
private int exfeed_isnew;
private float exfeed_lng;
private float exfeed_lat;
/****用于照片交换动态+留言****/
private int location_delete_enable_2;
private int location_objtype_2;
private int location_objid_2;
/***用于资料交换动态***/
private int location_delete_enable;
private int location_objtype;
private int location_objid;
public int getLocation_delete_enable() {
return location_delete_enable;
}
public void setLocation_delete_enable(int location_delete_enable) {
this.location_delete_enable = location_delete_enable;
}
public int getLocation_objtype() {
return location_objtype;
}
public void setLocation_objtype(int location_objtype) {
this.location_objtype = location_objtype;
}
public int getLocation_objid() {
return location_objid;
}
public void setLocation_objid(int location_objid) {
this.location_objid = location_objid;
}
public int getLocation_delete_enable_2() {
return location_delete_enable_2;
}
public void setLocation_delete_enable_2(int location_delete_enable_2) {
this.location_delete_enable_2 = location_delete_enable_2;
}
public int getLocation_objtype_2() {
return location_objtype_2;
}
public void setLocation_objtype_2(int location_objtype_2) {
this.location_objtype_2 = location_objtype_2;
}
public int getLocation_objid_2() {
return location_objid_2;
}
public void setLocation_objid_2(int location_objid_2) {
this.location_objid_2 = location_objid_2;
}
public int getExfeed_uid() {
return exfeed_uid;
}
public void setExfeed_uid(int exfeed_uid) {
this.exfeed_uid = exfeed_uid;
}
public int getExfeed_type() {
return exfeed_type;
}
public void setExfeed_type(int exfeed_type) {
this.exfeed_type = exfeed_type;
}
public String getExfeed_nickname() {
return exfeed_nickname;
}
public void setExfeed_nickname(String exfeed_nickname) {
this.exfeed_nickname = exfeed_nickname;
}
public String getExfeed_avatar() {
return exfeed_avatar;
}
public void setExfeed_avatar(String exfeed_avatar) {
this.exfeed_avatar = exfeed_avatar;
}
public String getExfeed_content() {
return exfeed_content;
}
public void setExfeed_content(String exfeed_content) {
this.exfeed_content = exfeed_content;
}
public String getExfeed_comment() {
return exfeed_comment;
}
public void setExfeed_comment(String exfeed_comment) {
this.exfeed_comment = exfeed_comment;
}
public String getExfeed_time() {
return exfeed_time;
}
public void setExfeed_time(String exfeed_time) {
this.exfeed_time = exfeed_time;
}
public String getExfeed_location() {
return exfeed_location;
}
public void setExfeed_location(String exfeed_location) {
this.exfeed_location = exfeed_location;
}
public float getExfeed_lng() {
return exfeed_lng;
}
public void setExfeed_lng(float exfeed_lng) {
this.exfeed_lng = exfeed_lng;
}
public float getExfeed_lat() {
return exfeed_lat;
}
public void setExfeed_lat(float exfeed_lat) {
this.exfeed_lat = exfeed_lat;
}
public int getExfeed_isnew() {
return exfeed_isnew;
}
public void setExfeed_isnew(int exfeed_isnew) {
this.exfeed_isnew = exfeed_isnew;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class BottleEntry {
private int btid;
private int bttypeid;
private int bt_uid;
private String bt_nickname;
private String bt_avatar;
private String bt_feed;
private String bt_time;
private String bt_location;
private float bt_lng;
private float bt_lat;
private int bt_showaddress;
private String bt_tag;
private String bt_copy_info;
private String bt_content;
private String bt_doing;
private String bt_smallpic;
private String bt_bigpic;
private int bt_allow_spread;
private int bt_copy_enable;
private int bt_open_drop_show;
private int bt_like_enable;
private int bt_pic_locked;
private int bt_allow_tuya;
private int bt_enable_tuya;
private int bt_liked;
private String bt_opfeed;
private String bt_optime;
private int bt_opuid;
private String bt_opnickname;
private String bt_opavatar;
private String bt_oplocation;
private float bt_oplng;
private float bt_oplat;
private String bt_opdistance;
private int btlikes_count;
private int btfeeds_count;
private List<BottleLikeEntry> btlikes_list;
private List<BottleFeedEntry> btfeeds_list;
public int getBtid() {
return btid;
}
public void setBtid(int btid) {
this.btid = btid;
}
public int getBttypeid() {
return bttypeid;
}
public void setBttypeid(int bttypeid) {
this.bttypeid = bttypeid;
}
public int getBt_uid() {
return bt_uid;
}
public void setBt_uid(int bt_uid) {
this.bt_uid = bt_uid;
}
public String getBt_nickname() {
return bt_nickname;
}
public void setBt_nickname(String bt_nickname) {
this.bt_nickname = bt_nickname;
}
public String getBt_avatar() {
return bt_avatar;
}
public void setBt_avatar(String bt_avatar) {
this.bt_avatar = bt_avatar;
}
public String getBt_feed() {
return bt_feed;
}
public void setBt_feed(String bt_feed) {
this.bt_feed = bt_feed;
}
public String getBt_time() {
return bt_time;
}
public void setBt_time(String bt_time) {
this.bt_time = bt_time;
}
public String getBt_location() {
return bt_location;
}
public void setBt_location(String bt_location) {
this.bt_location = bt_location;
}
public float getBt_lng() {
return bt_lng;
}
public void setBt_lng(float bt_lng) {
this.bt_lng = bt_lng;
}
public float getBt_lat() {
return bt_lat;
}
public void setBt_lat(float bt_lat) {
this.bt_lat = bt_lat;
}
public String getBt_tag() {
return bt_tag;
}
public void setBt_tag(String bt_tag) {
this.bt_tag = bt_tag;
}
public String getBt_copy_info() {
return bt_copy_info;
}
public void setBt_copy_info(String bt_copy_info) {
this.bt_copy_info = bt_copy_info;
}
public String getBt_content() {
return bt_content;
}
public void setBt_content(String bt_content) {
this.bt_content = bt_content;
}
public String getBt_doing() {
return bt_doing;
}
public void setBt_doing(String bt_doing) {
this.bt_doing = bt_doing;
}
public String getBt_smallpic() {
return bt_smallpic;
}
public void setBt_smallpic(String bt_smallpic) {
this.bt_smallpic = bt_smallpic;
}
public String getBt_bigpic() {
return bt_bigpic;
}
public void setBt_bigpic(String bt_bigpic) {
this.bt_bigpic = bt_bigpic;
}
public int getBt_allow_spread() {
return bt_allow_spread;
}
public void setBt_allow_spread(int bt_allow_spread) {
this.bt_allow_spread = bt_allow_spread;
}
public int getBt_copy_enable() {
return bt_copy_enable;
}
public void setBt_copy_enable(int bt_copy_enable) {
this.bt_copy_enable = bt_copy_enable;
}
public int getBt_allow_tuya() {
return bt_allow_tuya;
}
public void setBt_allow_tuya(int bt_allow_tuya) {
this.bt_allow_tuya = bt_allow_tuya;
}
public int getBt_liked() {
return bt_liked;
}
public void setBt_liked(int bt_liked) {
this.bt_liked = bt_liked;
}
public int getBt_open_drop_show() {
return bt_open_drop_show;
}
public void setBt_open_drop_show(int bt_open_drop_show) {
this.bt_open_drop_show = bt_open_drop_show;
}
public int getBt_like_enable() {
return bt_like_enable;
}
public void setBt_like_enable(int bt_like_enable) {
this.bt_like_enable = bt_like_enable;
}
public int getBt_pic_locked() {
return bt_pic_locked;
}
public void setBt_pic_locked(int bt_pic_locked) {
this.bt_pic_locked = bt_pic_locked;
}
public String getBt_opfeed() {
return bt_opfeed;
}
public void setBt_opfeed(String bt_opfeed) {
this.bt_opfeed = bt_opfeed;
}
public String getBt_optime() {
return bt_optime;
}
public void setBt_optime(String bt_optime) {
this.bt_optime = bt_optime;
}
public int getBt_opuid() {
return bt_opuid;
}
public void setBt_opuid(int bt_opuid) {
this.bt_opuid = bt_opuid;
}
public String getBt_opnickname() {
return bt_opnickname;
}
public void setBt_opnickname(String bt_opnickname) {
this.bt_opnickname = bt_opnickname;
}
public String getBt_opavatar() {
return bt_opavatar;
}
public void setBt_opavatar(String bt_opavatar) {
this.bt_opavatar = bt_opavatar;
}
public String getBt_oplocation() {
return bt_oplocation;
}
public void setBt_oplocation(String bt_oplocation) {
this.bt_oplocation = bt_oplocation;
}
public float getBt_oplng() {
return bt_oplng;
}
public void setBt_oplng(float bt_oplng) {
this.bt_oplng = bt_oplng;
}
public float getBt_oplat() {
return bt_oplat;
}
public void setBt_oplat(float bt_oplat) {
this.bt_oplat = bt_oplat;
}
public String getBt_opdistance() {
return bt_opdistance;
}
public void setBt_opdistance(String bt_opdistance) {
this.bt_opdistance = bt_opdistance;
}
public int getBtlikes_count() {
return btlikes_count;
}
public void setBtlikes_count(int btlikes_count) {
this.btlikes_count = btlikes_count;
}
public int getBtfeeds_count() {
return btfeeds_count;
}
public void setBtfeeds_count(int btfeeds_count) {
this.btfeeds_count = btfeeds_count;
}
public List<BottleLikeEntry> getBtlikes_list() {
return btlikes_list;
}
public void setBtlikes_list(List<BottleLikeEntry> btlikes_list) {
this.btlikes_list = btlikes_list;
}
public List<BottleFeedEntry> getBtfeeds_list() {
return btfeeds_list;
}
public void setBtfeeds_list(List<BottleFeedEntry> btfeeds_list) {
this.btfeeds_list = btfeeds_list;
}
public int getBt_showaddress() {
return bt_showaddress;
}
public void setBt_showaddress(int bt_showaddress) {
this.bt_showaddress = bt_showaddress;
}
public int getBt_enable_tuya() {
return bt_enable_tuya;
}
public void setBt_enable_tuya(int bt_enable_tuya) {
this.bt_enable_tuya = bt_enable_tuya;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class ExInfoSessionEntry {
private int exsid;
private int exs_uid;
private String exs_nickname;
private String exs_avatar;
private int exs_ouid;
private String exs_onickname;
private String exs_oavatar;
private String exs_firstfeed;
private String exs_firstfeedtime;
private int exs_success;
private int exs_infoex_rejectshow;
private int exs_infoex_acceptshow;
private int exs_infoex_visibleshow;
private int exs_infoex_invisibleshow;
public int getExsid() {
return exsid;
}
public void setExsid(int exsid) {
this.exsid = exsid;
}
public int getExs_uid() {
return exs_uid;
}
public void setExs_uid(int exs_uid) {
this.exs_uid = exs_uid;
}
public String getExs_nickname() {
return exs_nickname;
}
public void setExs_nickname(String exs_nickname) {
this.exs_nickname = exs_nickname;
}
public String getExs_avatar() {
return exs_avatar;
}
public void setExs_avatar(String exs_avatar) {
this.exs_avatar = exs_avatar;
}
public int getExs_ouid() {
return exs_ouid;
}
public void setExs_ouid(int exs_ouid) {
this.exs_ouid = exs_ouid;
}
public String getExs_onickname() {
return exs_onickname;
}
public void setExs_onickname(String exs_onickname) {
this.exs_onickname = exs_onickname;
}
public String getExs_oavatar() {
return exs_oavatar;
}
public void setExs_oavatar(String exs_oavatar) {
this.exs_oavatar = exs_oavatar;
}
public String getExs_firstfeed() {
return exs_firstfeed;
}
public void setExs_firstfeed(String exs_firstfeed) {
this.exs_firstfeed = exs_firstfeed;
}
public String getExs_firstfeedtime() {
return exs_firstfeedtime;
}
public void setExs_firstfeedtime(String exs_firstfeedtime) {
this.exs_firstfeedtime = exs_firstfeedtime;
}
public int getExs_success() {
return exs_success;
}
public void setExs_success(int exs_success) {
this.exs_success = exs_success;
}
public int getExs_infoex_rejectshow() {
return exs_infoex_rejectshow;
}
public void setExs_infoex_rejectshow(int exs_infoex_rejectshow) {
this.exs_infoex_rejectshow = exs_infoex_rejectshow;
}
public int getExs_infoex_acceptshow() {
return exs_infoex_acceptshow;
}
public void setExs_infoex_acceptshow(int exs_infoex_acceptshow) {
this.exs_infoex_acceptshow = exs_infoex_acceptshow;
}
public int getExs_infoex_visibleshow() {
return exs_infoex_visibleshow;
}
public void setExs_infoex_visibleshow(int exs_infoex_visibleshow) {
this.exs_infoex_visibleshow = exs_infoex_visibleshow;
}
public int getExs_infoex_invisibleshow() {
return exs_infoex_invisibleshow;
}
public void setExs_infoex_invisibleshow(int exs_infoex_invisibleshow) {
this.exs_infoex_invisibleshow = exs_infoex_invisibleshow;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class InitFriendInfo {
ResponseResult results;
List<FriendEntry> users_list;
List<FriendGroupEntry> groups_list;
private ShowtipsEntry show_config;
int rscount;
public InitFriendInfo() {
super();
}
public InitFriendInfo(ResponseResult results,
List<FriendEntry> users_list,
List<FriendGroupEntry> groups_list, int rscount) {
super();
this.results = results;
this.users_list = users_list;
this.groups_list = groups_list;
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<FriendEntry> getUsers_list() {
return users_list;
}
public void setUsers_list(List<FriendEntry> users_list) {
this.users_list = users_list;
}
public List<FriendGroupEntry> getGroups_list() {
return groups_list;
}
public void setGroups_list(List<FriendGroupEntry> groups_list) {
this.groups_list = groups_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public ShowtipsEntry getShow_config() {
return show_config;
}
public void setShow_config(ShowtipsEntry show_config) {
this.show_config = show_config;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class GroupInfo {
private ResponseResult results;
private List<GroupEntry> mygroups_list;
public GroupInfo() {
super();
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<GroupEntry> getMygroups_list() {
return mygroups_list;
}
public void setMygroups_list(List<GroupEntry> mygroups_list) {
this.mygroups_list = mygroups_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class FriendFeedEntry {
private int feed_uid;
private String feed_nickname;
private String feed_avatar;
private String feed_content;
private int feed_picid;
private String feed_time;
private String feed_smallpic;
private String feed_bigpic;
/**相关用户的uid(评论照片的动态,加好友的动态才有,对应照片所属者uid和被加好友的用户uid)*/
private int feed_related_uid;
/**相关用户的昵称(评论照片的动态,加好友的动态才有,对应照片所属者uid和被加好友的用户uid)*/
private String feed_related_nickname;
private int isnew;
public int getFeed_uid() {
return feed_uid;
}
public void setFeed_uid(int feed_uid) {
this.feed_uid = feed_uid;
}
public String getFeed_nickname() {
return feed_nickname;
}
public void setFeed_nickname(String feed_nickname) {
this.feed_nickname = feed_nickname;
}
public String getFeed_avatar() {
return feed_avatar;
}
public void setFeed_avatar(String feed_avatar) {
this.feed_avatar = feed_avatar;
}
public String getFeed_content() {
return feed_content;
}
public void setFeed_content(String feed_content) {
this.feed_content = feed_content;
}
public int getFeed_picid() {
return feed_picid;
}
public void setFeed_picid(int feed_picid) {
this.feed_picid = feed_picid;
}
public String getFeed_time() {
return feed_time;
}
public void setFeed_time(String feed_time) {
this.feed_time = feed_time;
}
public String getFeed_smallpic() {
return feed_smallpic;
}
public void setFeed_smallpic(String feed_smallpic) {
this.feed_smallpic = feed_smallpic;
}
public String getFeed_bigpic() {
return feed_bigpic;
}
public void setFeed_bigpic(String feed_bigpic) {
this.feed_bigpic = feed_bigpic;
}
public int getFeed_related_uid() {
return feed_related_uid;
}
public void setFeed_related_uid(int feed_related_uid) {
this.feed_related_uid = feed_related_uid;
}
public String getFeed_related_nickname() {
return feed_related_nickname;
}
public void setFeed_related_nickname(String feed_related_nickname) {
this.feed_related_nickname = feed_related_nickname;
}
public int getIsnew() {
return isnew;
}
public void setIsnew(int isnew) {
this.isnew = isnew;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class SubCareerEntry {
private int career_subclassid;
private String career_subclass;
public int getCareer_subclassid() {
return career_subclassid;
}
public void setCareer_subclassid(int career_subclassid) {
this.career_subclassid = career_subclassid;
}
public String getCareer_subclass() {
return career_subclass;
}
public void setCareer_subclass(String career_subclass) {
this.career_subclass = career_subclass;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
import android.R.integer;
public class ExFeedPicEntry {
private int exfeed_uid;
private int exfeed_type;
private String exfeed_nickname;
private String exfeed_avatar;
private String exfeed_content;
private String exfeed_comment;
private int exfeed_picid;
private String exfeed_pic;
private String exfeed_pic_big;
private int exfeed_pic_liked;
private int exfeed_pic_locked;
private int exfeed_like_enable;
private int exfeed_forward_enable;
private String exfeed_time;
private String exfeed_location;
private int exfeed_isnew;
private float exfeed_lng;
private float exfeed_lat;
private List<ExPicFeedEntry> expicfeeds_list;
private int expicfeeds_count;
private int exfeed_pic_allowtuya;
private int exfeed_pic_enabletuya;
private int exfeed_pic_srcpicid;
public int getExfeed_pic_allowtuya() {
return exfeed_pic_allowtuya;
}
public void setExfeed_pic_allowtuya(int exfeed_pic_allowtuya) {
this.exfeed_pic_allowtuya = exfeed_pic_allowtuya;
}
public int getExfeed_pic_enabletuya() {
return exfeed_pic_enabletuya;
}
public void setExfeed_pic_enabletuya(int exfeed_pic_enabletuya) {
this.exfeed_pic_enabletuya = exfeed_pic_enabletuya;
}
public int getExfeed_pic_srcpicid() {
return exfeed_pic_srcpicid;
}
public void setExfeed_pic_srcpicid(int exfeed_pic_srcpicid) {
this.exfeed_pic_srcpicid = exfeed_pic_srcpicid;
}
private int location_delete_enable;
private int location_objtype;
private int location_objid;
public int getLocation_delete_enable() {
return location_delete_enable;
}
public void setLocation_delete_enable(int location_delete_enable) {
this.location_delete_enable = location_delete_enable;
}
public int getLocation_objtype() {
return location_objtype;
}
public void setLocation_objtype(int location_objtype) {
this.location_objtype = location_objtype;
}
public int getLocation_objid() {
return location_objid;
}
public void setLocation_objid(int location_objid) {
this.location_objid = location_objid;
}
public int getExfeed_uid() {
return exfeed_uid;
}
public void setExfeed_uid(int exfeed_uid) {
this.exfeed_uid = exfeed_uid;
}
public int getExfeed_type() {
return exfeed_type;
}
public void setExfeed_type(int exfeed_type) {
this.exfeed_type = exfeed_type;
}
public String getExfeed_nickname() {
return exfeed_nickname;
}
public void setExfeed_nickname(String exfeed_nickname) {
this.exfeed_nickname = exfeed_nickname;
}
public String getExfeed_avatar() {
return exfeed_avatar;
}
public void setExfeed_avatar(String exfeed_avatar) {
this.exfeed_avatar = exfeed_avatar;
}
public String getExfeed_content() {
return exfeed_content;
}
public void setExfeed_content(String exfeed_content) {
this.exfeed_content = exfeed_content;
}
public String getExfeed_comment() {
return exfeed_comment;
}
public void setExfeed_comment(String exfeed_comment) {
this.exfeed_comment = exfeed_comment;
}
public int getExfeed_picid() {
return exfeed_picid;
}
public void setExfeed_picid(int exfeed_picid) {
this.exfeed_picid = exfeed_picid;
}
public String getExfeed_pic() {
return exfeed_pic;
}
public void setExfeed_pic(String exfeed_pic) {
this.exfeed_pic = exfeed_pic;
}
public String getExfeed_pic_big() {
return exfeed_pic_big;
}
public void setExfeed_pic_big(String exfeed_pic_big) {
this.exfeed_pic_big = exfeed_pic_big;
}
public int getExfeed_pic_liked() {
return exfeed_pic_liked;
}
public void setExfeed_pic_liked(int exfeed_pic_liked) {
this.exfeed_pic_liked = exfeed_pic_liked;
}
public int getExfeed_pic_locked() {
return exfeed_pic_locked;
}
public void setExfeed_pic_locked(int exfeed_pic_locked) {
this.exfeed_pic_locked = exfeed_pic_locked;
}
public int getExfeed_like_enable() {
return exfeed_like_enable;
}
public void setExfeed_like_enable(int exfeed_like_enable) {
this.exfeed_like_enable = exfeed_like_enable;
}
public int getExfeed_forward_enable() {
return exfeed_forward_enable;
}
public void setExfeed_forward_enable(int exfeed_forward_enable) {
this.exfeed_forward_enable = exfeed_forward_enable;
}
public String getExfeed_time() {
return exfeed_time;
}
public void setExfeed_time(String exfeed_time) {
this.exfeed_time = exfeed_time;
}
public String getExfeed_location() {
return exfeed_location;
}
public void setExfeed_location(String exfeed_location) {
this.exfeed_location = exfeed_location;
}
public float getExfeed_lng() {
return exfeed_lng;
}
public void setExfeed_lng(float exfeed_lng) {
this.exfeed_lng = exfeed_lng;
}
public float getExfeed_lat() {
return exfeed_lat;
}
public void setExfeed_lat(float exfeed_lat) {
this.exfeed_lat = exfeed_lat;
}
public int getExpicfeeds_count() {
return expicfeeds_count;
}
public void setExpicfeeds_count(int expicfeeds_count) {
this.expicfeeds_count = expicfeeds_count;
}
public List<ExPicFeedEntry> getExpicfeeds_list() {
return expicfeeds_list;
}
public void setExpicfeeds_list(List<ExPicFeedEntry> expicfeeds_list) {
this.expicfeeds_list = expicfeeds_list;
}
public int getExfeed_isnew() {
return exfeed_isnew;
}
public void setExfeed_isnew(int exfeed_isnew) {
this.exfeed_isnew = exfeed_isnew;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class BottleTimelineShowTipsEntry {
private int show_sendbt_tips;
private int show_gainbt_tips;
public int getShow_sendbt_tips() {
return show_sendbt_tips;
}
public void setShow_sendbt_tips(int show_sendbt_tips) {
this.show_sendbt_tips = show_sendbt_tips;
}
public int getShow_gainbt_tips() {
return show_gainbt_tips;
}
public void setShow_gainbt_tips(int show_gainbt_tips) {
this.show_gainbt_tips = show_gainbt_tips;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class OUserInfoEntry {
private String onickname;
private int osex;
private String oavatar;
private String ocountry;
private String ocity;
private String omemo;
private String odoing;
public String getOnickname() {
return onickname;
}
public void setOnickname(String onickname) {
this.onickname = onickname;
}
public int getOsex() {
return osex;
}
public void setOsex(int osex) {
this.osex = osex;
}
public String getOavatar() {
return oavatar;
}
public void setOavatar(String oavatar) {
this.oavatar = oavatar;
}
public String getOcountry() {
return ocountry;
}
public void setOcountry(String ocountry) {
this.ocountry = ocountry;
}
public String getOcity() {
return ocity;
}
public void setOcity(String ocity) {
this.ocity = ocity;
}
public String getOmemo() {
return omemo;
}
public void setOmemo(String omemo) {
this.omemo = omemo;
}
public String getOdoing() {
return odoing;
}
public void setOdoing(String odoing) {
this.odoing = odoing;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class BottleInfo {
private ResponseResult results;
private BottleInfoEntry btinfo;
public BottleInfo(){
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public void setBtinfo(BottleInfoEntry btinfo) {
this.btinfo = btinfo;
}
public BottleInfoEntry getBtinfo() {
return btinfo;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class CommentEntry {
private int commentid;
private int comment_uid;
private String comment_nickname;
private String comment_avatar;
private String comment_content;
private String comment_replycomment;
private String comment_time;
private String comment_location;
private float comment_lng;
private float comment_lat;
private int comment_type;
private int comment_tuyapicid;
private String comment_tuyapic_small;
private String comment_tuyapic_big;
private String comment_tuyapic_tuya;
private int location_delete_enable_2;
private int location_objtype_2;
private int location_objid_2;
public int getComment_type() {
return comment_type;
}
public void setComment_type(int comment_type) {
this.comment_type = comment_type;
}
public int getComment_tuyapicid() {
return comment_tuyapicid;
}
public void setComment_tuyapicid(int comment_tuyapicid) {
this.comment_tuyapicid = comment_tuyapicid;
}
public String getComment_tuyapic_small() {
return comment_tuyapic_small;
}
public void setComment_tuyapic_small(String comment_tuyapic_small) {
this.comment_tuyapic_small = comment_tuyapic_small;
}
public String getComment_tuyapic_big() {
return comment_tuyapic_big;
}
public void setComment_tuyapic_big(String comment_tuyapic_big) {
this.comment_tuyapic_big = comment_tuyapic_big;
}
public String getComment_tuyapic_tuya() {
return comment_tuyapic_tuya;
}
public void setComment_tuyapic_tuya(String comment_tuyapic_tuya) {
this.comment_tuyapic_tuya = comment_tuyapic_tuya;
}
public int getLocation_delete_enable_2() {
return location_delete_enable_2;
}
public void setLocation_delete_enable_2(int location_delete_enable_2) {
this.location_delete_enable_2 = location_delete_enable_2;
}
public int getLocation_objtype_2() {
return location_objtype_2;
}
public void setLocation_objtype_2(int location_objtype_2) {
this.location_objtype_2 = location_objtype_2;
}
public int getLocation_objid_2() {
return location_objid_2;
}
public void setLocation_objid_2(int location_objid_2) {
this.location_objid_2 = location_objid_2;
}
public int getCommentid() {
return commentid;
}
public void setCommentid(int commentid) {
this.commentid = commentid;
}
public int getComment_uid() {
return comment_uid;
}
public void setComment_uid(int comment_uid) {
this.comment_uid = comment_uid;
}
public String getComment_nickname() {
return comment_nickname;
}
public void setComment_nickname(String comment_nickname) {
this.comment_nickname = comment_nickname;
}
public String getComment_avatar() {
return comment_avatar;
}
public void setComment_avatar(String comment_avatar) {
this.comment_avatar = comment_avatar;
}
public String getComment_content() {
return comment_content;
}
public void setComment_content(String comment_content) {
this.comment_content = comment_content;
}
public String getComment_replycomment() {
return comment_replycomment;
}
public void setComment_replycomment(String comment_replycomment) {
this.comment_replycomment = comment_replycomment;
}
public String getComment_time() {
return comment_time;
}
public void setComment_time(String comment_time) {
this.comment_time = comment_time;
}
public String getComment_location() {
return comment_location;
}
public void setComment_location(String comment_location) {
this.comment_location = comment_location;
}
public float getComment_lng() {
return comment_lng;
}
public void setComment_lng(float comment_lng) {
this.comment_lng = comment_lng;
}
public float getComment_lat() {
return comment_lat;
}
public void setComment_lat(float comment_lat) {
this.comment_lat = comment_lat;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class NoticeInfo {
private ResponseResult results;
private List<NoticeEntry> notices_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<NoticeEntry> getNotices_list() {
return notices_list;
}
public void setNotices_list(List<NoticeEntry> notices_list) {
this.notices_list = notices_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public NoticeInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class MessageInfo {
private ResponseResult results;
private List<MessageEntry> message_sessions_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<MessageEntry> getMessage_sessions_list() {
return message_sessions_list;
}
public void setMessage_sessions_list(List<MessageEntry> message_sessions_list) {
this.message_sessions_list = message_sessions_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public MessageInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class ExchangePicInfo {
private ResponseResult results;
private ExPicOuidInfoEntry ouid_info;
private ExPicSessionEntry exs_info;
private List<ExFeedPicEntry> exfeeds_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public ExPicOuidInfoEntry getOuid_info() {
return ouid_info;
}
public void setOuid_info(ExPicOuidInfoEntry ouid_info) {
this.ouid_info = ouid_info;
}
public ExPicSessionEntry getExs_info() {
return exs_info;
}
public void setExs_info(ExPicSessionEntry exs_info) {
this.exs_info = exs_info;
}
public List<ExFeedPicEntry> getExfeeds_list() {
return exfeeds_list;
}
public void setExfeeds_list(List<ExFeedPicEntry> exfeeds_list) {
this.exfeeds_list = exfeeds_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
* 瓶友等级
* @author 06peng
*
*/
public class FriendLevelEntry {
private int flevel_id;
private String flevel_name_cn;
private String flevel_name_en;
private int flevel_level;
private int flevel_credit;
private int flevel_ttcredit;
private String flevel_cron;
public int getFlevel_id() {
return flevel_id;
}
public void setFlevel_id(int flevel_id) {
this.flevel_id = flevel_id;
}
public String getFlevel_name_cn() {
return flevel_name_cn;
}
public void setFlevel_name_cn(String flevel_name_cn) {
this.flevel_name_cn = flevel_name_cn;
}
public String getFlevel_name_en() {
return flevel_name_en;
}
public void setFlevel_name_en(String flevel_name_en) {
this.flevel_name_en = flevel_name_en;
}
public int getFlevel_level() {
return flevel_level;
}
public void setFlevel_level(int flevel_level) {
this.flevel_level = flevel_level;
}
public int getFlevel_credit() {
return flevel_credit;
}
public void setFlevel_credit(int flevel_credit) {
this.flevel_credit = flevel_credit;
}
public int getFlevel_ttcredit() {
return flevel_ttcredit;
}
public void setFlevel_ttcredit(int flevel_ttcredit) {
this.flevel_ttcredit = flevel_ttcredit;
}
public String getFlevel_cron() {
return flevel_cron;
}
public void setFlevel_cron(String flevel_cron) {
this.flevel_cron = flevel_cron;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class FriendGroupEntry {
private int groupid;
private String groupname;
public int getGroupid() {
return groupid;
}
public void setGroupid(int groupid) {
this.groupid = groupid;
}
public String getGroupname() {
return groupname;
}
public void setGroupname(String groupname) {
this.groupname = groupname;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
* 瓶子类型
* @author 06peng
*
*/
public class BottleTypeEntry {
private int bttypeid;
private String bttype_name_cn;
private String bttype_name_en;
private String bttype_desc_cn;
private String bttype_desc_en;
private String bttype_tips_cn;
private String bttype_tips_en;
private String bttype_sjdicon;
private String bttype_sjwicon;
private int bttype_samecity;
private int bttype_samecity_show;
private int bttype_samearea;
private int bttype_samearea_show;
private int bttype_needsex;
private int bttype_needsex_show;
private int bttype_needage;
private int bttype_needage_show;
private int bttype_allow_sendfriend;
private int bttype_allow_pick;
private int bttype_pick_show;
private int bttype_allow_spread;
private int bttype_spread_show;
private int bttype_message_show;
private int bttype_message_must;
private int bttype_pic_show;
private int bttype_pic_must;
private int bttype_doing_show;
private int bttype_doing_must;
private int bttype_poll_show;
private int bttype_poll_must;
private int bttype_otheruserfeed;
private int bttype_otheruserfeed_show;
private int bttype_otheruserreply;
private int bttype_otheruserreply_show;
private int bttype_isshow;
private int bttype_location_select;
private List<BottleTagEntry> bttype_tags;
public int getBttypeid() {
return bttypeid;
}
public void setBttypeid(int bttypeid) {
this.bttypeid = bttypeid;
}
public String getBttype_name_cn() {
return bttype_name_cn;
}
public void setBttype_name_cn(String bttype_name_cn) {
this.bttype_name_cn = bttype_name_cn;
}
public String getBttype_name_en() {
return bttype_name_en;
}
public void setBttype_name_en(String bttype_name_en) {
this.bttype_name_en = bttype_name_en;
}
public String getBttype_desc_cn() {
return bttype_desc_cn;
}
public void setBttype_desc_cn(String bttype_desc_cn) {
this.bttype_desc_cn = bttype_desc_cn;
}
public String getBttype_desc_en() {
return bttype_desc_en;
}
public void setBttype_desc_en(String bttype_desc_en) {
this.bttype_desc_en = bttype_desc_en;
}
public String getBttype_tips_cn() {
return bttype_tips_cn;
}
public void setBttype_tips_cn(String bttype_tips_cn) {
this.bttype_tips_cn = bttype_tips_cn;
}
public String getBttype_tips_en() {
return bttype_tips_en;
}
public void setBttype_tips_en(String bttype_tips_en) {
this.bttype_tips_en = bttype_tips_en;
}
public String getBttype_sjdicon() {
return bttype_sjdicon;
}
public void setBttype_sjdicon(String bttype_sjdicon) {
this.bttype_sjdicon = bttype_sjdicon;
}
public String getBttype_sjwicon() {
return bttype_sjwicon;
}
public void setBttype_sjwicon(String bttype_sjwicon) {
this.bttype_sjwicon = bttype_sjwicon;
}
public int getBttype_samecity() {
return bttype_samecity;
}
public void setBttype_samecity(int bttype_samecity) {
this.bttype_samecity = bttype_samecity;
}
public int getBttype_samecity_show() {
return bttype_samecity_show;
}
public void setBttype_samecity_show(int bttype_samecity_show) {
this.bttype_samecity_show = bttype_samecity_show;
}
public int getBttype_samearea() {
return bttype_samearea;
}
public void setBttype_samearea(int bttype_samearea) {
this.bttype_samearea = bttype_samearea;
}
public int getBttype_samearea_show() {
return bttype_samearea_show;
}
public void setBttype_samearea_show(int bttype_samearea_show) {
this.bttype_samearea_show = bttype_samearea_show;
}
public int getBttype_needsex() {
return bttype_needsex;
}
public void setBttype_needsex(int bttype_needsex) {
this.bttype_needsex = bttype_needsex;
}
public int getBttype_needsex_show() {
return bttype_needsex_show;
}
public void setBttype_needsex_show(int bttype_needsex_show) {
this.bttype_needsex_show = bttype_needsex_show;
}
public int getBttype_needage() {
return bttype_needage;
}
public void setBttype_needage(int bttype_needage) {
this.bttype_needage = bttype_needage;
}
public int getBttype_needage_show() {
return bttype_needage_show;
}
public void setBttype_needage_show(int bttype_needage_show) {
this.bttype_needage_show = bttype_needage_show;
}
public int getBttype_allow_sendfriend() {
return bttype_allow_sendfriend;
}
public void setBttype_allow_sendfriend(int bttype_allow_sendfriend) {
this.bttype_allow_sendfriend = bttype_allow_sendfriend;
}
public int getBttype_allow_pick() {
return bttype_allow_pick;
}
public void setBttype_allow_pick(int bttype_allow_pick) {
this.bttype_allow_pick = bttype_allow_pick;
}
public int getBttype_pick_show() {
return bttype_pick_show;
}
public void setBttype_pick_show(int bttype_pick_show) {
this.bttype_pick_show = bttype_pick_show;
}
public int getBttype_allow_spread() {
return bttype_allow_spread;
}
public void setBttype_allow_spread(int bttype_allow_spread) {
this.bttype_allow_spread = bttype_allow_spread;
}
public int getBttype_spread_show() {
return bttype_spread_show;
}
public void setBttype_spread_show(int bttype_spread_show) {
this.bttype_spread_show = bttype_spread_show;
}
public int getBttype_message_show() {
return bttype_message_show;
}
public void setBttype_message_show(int bttype_message_show) {
this.bttype_message_show = bttype_message_show;
}
public int getBttype_message_must() {
return bttype_message_must;
}
public void setBttype_message_must(int bttype_message_must) {
this.bttype_message_must = bttype_message_must;
}
public int getBttype_pic_show() {
return bttype_pic_show;
}
public void setBttype_pic_show(int bttype_pic_show) {
this.bttype_pic_show = bttype_pic_show;
}
public int getBttype_pic_must() {
return bttype_pic_must;
}
public void setBttype_pic_must(int bttype_pic_must) {
this.bttype_pic_must = bttype_pic_must;
}
public int getBttype_doing_show() {
return bttype_doing_show;
}
public void setBttype_doing_show(int bttype_doing_show) {
this.bttype_doing_show = bttype_doing_show;
}
public int getBttype_doing_must() {
return bttype_doing_must;
}
public void setBttype_doing_must(int bttype_doing_must) {
this.bttype_doing_must = bttype_doing_must;
}
public int getBttype_poll_show() {
return bttype_poll_show;
}
public void setBttype_poll_show(int bttype_poll_show) {
this.bttype_poll_show = bttype_poll_show;
}
public int getBttype_poll_must() {
return bttype_poll_must;
}
public void setBttype_poll_must(int bttype_poll_must) {
this.bttype_poll_must = bttype_poll_must;
}
public int getBttype_otheruserfeed() {
return bttype_otheruserfeed;
}
public void setBttype_otheruserfeed(int bttype_otheruserfeed) {
this.bttype_otheruserfeed = bttype_otheruserfeed;
}
public int getBttype_otheruserfeed_show() {
return bttype_otheruserfeed_show;
}
public void setBttype_otheruserfeed_show(int bttype_otheruserfeed_show) {
this.bttype_otheruserfeed_show = bttype_otheruserfeed_show;
}
public int getBttype_otheruserreply() {
return bttype_otheruserreply;
}
public void setBttype_otheruserreply(int bttype_otheruserreply) {
this.bttype_otheruserreply = bttype_otheruserreply;
}
public int getBttype_otheruserreply_show() {
return bttype_otheruserreply_show;
}
public void setBttype_otheruserreply_show(int bttype_otheruserreply_show) {
this.bttype_otheruserreply_show = bttype_otheruserreply_show;
}
public List<BottleTagEntry> getBttype_tags() {
return bttype_tags;
}
public void setBttype_tags(List<BottleTagEntry> bttype_tags) {
this.bttype_tags = bttype_tags;
}
public int getBttype_isshow() {
return bttype_isshow;
}
public void setBttype_isshow(int bttype_isshow) {
this.bttype_isshow = bttype_isshow;
}
public int getBttype_location_select() {
return bttype_location_select;
}
public void setBttype_location_select(int bttype_location_select) {
this.bttype_location_select = bttype_location_select;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.ArrayList;
import java.util.List;
public class ExFeedEntry {
private int exfeed_uid;
private int exfeed_type;
private String exfeed_nickname;
private String exfeed_avatar;
private String exfeed_content;
private String exfeed_comment;
private int exfeed_picid;
private String exfeed_pic;
private String exfeed_pic_big;
private String exfeed_pic_tuya;//涂鸦的拼接图路径
private int exfeed_pic_liked;
private int exfeed_pic_locked;
private int exfeed_like_enable;
private int exfeed_forward_enable;
private int exfeed_pic_allowtuya;
private int exfeed_pic_enabletuya;
private int exfeed_pic_srcpicid;
private String exfeed_time;
private String exfeed_location;
private int exfeed_isnew;
private float exfeed_lng;
private float exfeed_lat;
private List<ExPicFeedEntry> expicfeeds_list;
private int expicfeeds_count;
public int getExfeed_uid() {
return exfeed_uid;
}
public void setExfeed_uid(int exfeed_uid) {
this.exfeed_uid = exfeed_uid;
}
public int getExfeed_type() {
return exfeed_type;
}
public void setExfeed_type(int exfeed_type) {
this.exfeed_type = exfeed_type;
}
public String getExfeed_nickname() {
return exfeed_nickname;
}
public void setExfeed_nickname(String exfeed_nickname) {
this.exfeed_nickname = exfeed_nickname;
}
public String getExfeed_avatar() {
return exfeed_avatar;
}
public void setExfeed_avatar(String exfeed_avatar) {
this.exfeed_avatar = exfeed_avatar;
}
public String getExfeed_content() {
return exfeed_content;
}
public void setExfeed_content(String exfeed_content) {
this.exfeed_content = exfeed_content;
}
public String getExfeed_comment() {
return exfeed_comment;
}
public void setExfeed_comment(String exfeed_comment) {
this.exfeed_comment = exfeed_comment;
}
public int getExfeed_picid() {
return exfeed_picid;
}
public void setExfeed_picid(int exfeed_picid) {
this.exfeed_picid = exfeed_picid;
}
public String getExfeed_pic() {
return exfeed_pic;
}
public void setExfeed_pic(String exfeed_pic) {
this.exfeed_pic = exfeed_pic;
}
public String getExfeed_pic_big() {
return exfeed_pic_big;
}
public void setExfeed_pic_big(String exfeed_pic_big) {
this.exfeed_pic_big = exfeed_pic_big;
}
public int getExfeed_pic_liked() {
return exfeed_pic_liked;
}
public void setExfeed_pic_liked(int exfeed_pic_liked) {
this.exfeed_pic_liked = exfeed_pic_liked;
}
public int getExfeed_pic_locked() {
return exfeed_pic_locked;
}
public void setExfeed_pic_locked(int exfeed_pic_locked) {
this.exfeed_pic_locked = exfeed_pic_locked;
}
public int getExfeed_like_enable() {
return exfeed_like_enable;
}
public void setExfeed_like_enable(int exfeed_like_enable) {
this.exfeed_like_enable = exfeed_like_enable;
}
public String getExfeed_time() {
return exfeed_time;
}
public void setExfeed_time(String exfeed_time) {
this.exfeed_time = exfeed_time;
}
public int getExfeed_forward_enable() {
return exfeed_forward_enable;
}
public void setExfeed_forward_enable(int exfeed_forward_enable) {
this.exfeed_forward_enable = exfeed_forward_enable;
}
public String getExfeed_location() {
return exfeed_location;
}
public void setExfeed_location(String exfeed_location) {
this.exfeed_location = exfeed_location;
}
public float getExfeed_lng() {
return exfeed_lng;
}
public void setExfeed_lng(float exfeed_lng) {
this.exfeed_lng = exfeed_lng;
}
public float getExfeed_lat() {
return exfeed_lat;
}
public void setExfeed_lat(float exfeed_lat) {
this.exfeed_lat = exfeed_lat;
}
public void setExpicfeeds_count(int expicfeeds_count) {
this.expicfeeds_count = expicfeeds_count;
}
public int getExpicfeeds_count() {
return expicfeeds_count;
}
public void setExpicfeeds_list(ArrayList<ExPicFeedEntry> expicfeeds_list) {
this.expicfeeds_list = expicfeeds_list;
}
public List<ExPicFeedEntry> getExpicfeeds_list() {
return expicfeeds_list;
}
public int getExfeed_isnew() {
return exfeed_isnew;
}
public void setExfeed_isnew(int exfeed_isnew) {
this.exfeed_isnew = exfeed_isnew;
}
public String getExfeed_pic_tuya() {
return exfeed_pic_tuya;
}
public void setExfeed_pic_tuya(String exfeed_pic_tuya) {
this.exfeed_pic_tuya = exfeed_pic_tuya;
}
public int getExfeed_pic_allowtuya() {
return exfeed_pic_allowtuya;
}
public void setExfeed_pic_allowtuya(int exfeed_pic_allowtuya) {
this.exfeed_pic_allowtuya = exfeed_pic_allowtuya;
}
public int getExfeed_pic_enabletuya() {
return exfeed_pic_enabletuya;
}
public void setExfeed_pic_enabletuya(int exfeed_pic_enabletuya) {
this.exfeed_pic_enabletuya = exfeed_pic_enabletuya;
}
public int getExfeed_pic_srcpicid() {
return exfeed_pic_srcpicid;
}
public void setExfeed_pic_srcpicid(int exfeed_pic_srcpicid) {
this.exfeed_pic_srcpicid = exfeed_pic_srcpicid;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
* 第三方绑定平台相关接口
* @author 06peng
*
*/
public class PlatformBindConfig {
public static final String Twitter = "twitter";
public static final String Facebook = "facebook";
public static final String Renren = "renren";
public static final String Sina = "sina";
public static final String Tencent = "tencent";
public static final String Douban = "douban";
public static final String QQ = "qq";
public static final String Sitekey = "4ab7a74661d88d67a2e6f0f325d146d2";
public static final String Twitter_AppName = "MobiBottle";
public static final String Twitter_ConsumerKey = "jNWR4oXiboDzQlqFthJ59w";
public static final String Twitter_ConsumerSecret = "gJ8XC6cEIQ5IYiybgtB3XYMGRKRZ9yVtl2hXqP4qLw";
public static final String Twitter_Request_Token = "https://api.twitter.com/oauth/request_token";
public static final String Twitter_Authorize = "https://api.twitter.com/oauth/authorize";
public static final String Twitter_Access_Token = "https://api.twitter.com/oauth/access_token";
public static final String Callback = "http://www.mobibottle.com";
public static final String Facebook_AppName = "MobiBottle";
public static final String Facebook_AppID = "325972527449263";
public static final String Facebook_AppSecret = "be1e84fba724a7322aa6e67908cd5a1e";
public static final String Fackbook_Authorize = "https://www.facebook.com/dialog/oauth?client_id="+Facebook_AppID+"" +
"&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token";
public static final String Renren_Id = "163679";
public static final String Renren_Callback = "http://graph.renren.com/oauth/login_success.html";
public static final String Renren_AppKey = "d39507214c734be590620f5a9337cc58";
public static final String Renren_AppSecret = "64438fb7b0894b5f8d5ee01656ecc41f";
public static final String Renren_Authorize = "https://graph.renren.com/oauth/authorize?client_id=163679" +
"&response_type=code&redirect_uri=" + Renren_Callback;
public static final String Renren_Token = "https://graph.renren.com/oauth/token?";
public static final String Sina_AppKey = "1645898057";
public static final String Sina_AppSecret = "b2562bf27ebd9166490c15f046fda9d9";
public static final String Sina_Request_Token = "http://api.t.sina.com.cn/oauth/request_token";
public static final String Sina_Authorize = "http://api.t.sina.com.cn/oauth/authorize";
public static final String Sina_Access_Token = "http://api.t.sina.com.cn/oauth/access_token";
public static final String Sina_Authorize2 = "https://api.weibo.com/oauth2/authorize?client_id="+Sina_AppKey+"" +
"&response_type=code&redirect_uri=" + Callback;
public static final String Sina_Access_Token2 = "https://api.weibo.com/oauth2/access_token?client_id="+Sina_AppKey+"&client_secret="+Sina_AppSecret+"" +
"&grant_type=authorization_code&redirect_uri="+Callback+"&code=";
public static final String Tencent_AppKey = "801128949";
public static final String Tencent_AppSecret = "3a66f81a95b058af9a7850c1fa26ce46";
public static final String Tencent_Authorize_2 = "https://open.t.qq.com/cgi-bin/oauth2/authorize?client_id="+Tencent_AppKey+"" +
"&response_type=code&redirect_uri=" + Callback;
public static final String Tencent_Access_Token_2 = "https://open.t.qq.com/cgi-bin/oauth2/access_token?client_id="+Tencent_AppKey+"" +
"&client_secret="+Tencent_AppSecret+"&redirect_uri="+Callback+"&grant_type=authorization_code&code=";
public static final String Douban_AppKey = "027578c8325f731b07606a58971e5951";
public static final String Douban_AppSecret = "ad36dea269906cde";
public static final String Douban_Request_Token = "http://www.douban.com/service/auth/request_token";
public static final String Douban_Authorize = "http://www.douban.com/service/auth/authorize";
public static final String Douban_Access_Token = "http://www.douban.com/service/auth/access_token";
public static final String QQ_AppKey = "100271211";
public static final String QQ_AppSecret = "4feed01e671929f225d08406ac612176";
public static final String QQ_Request_Token = "http://openapi.qzone.qq.com/oauth/qzoneoauth_request_token";
// public static final String QQ_Authorize = "http://openapi.qzone.qq.com/oauth/qzoneoauth_authorize";
// public static final String QQ_Access_Token = "http://openapi.qzone.qq.com/oauth/qzoneoauth_access_token";
public static final String QQ_Authorize = "https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id="+QQ_AppKey+"" +
"&display=mobile&scope=get_user_info,add_share,get_fanslist,get_idollist&redirect_uri="+Callback;
public static final String Goolge_Places_AppKey = "AIzaSyBw5Y9XgRxqKC8ubVDtmwDzMvIZy2bVTbs";
public static int getOpenType(String platform) {
if (platform.equals(Sina)) {
return 1;
} else if (platform.equals(QQ)) {
return 0;
} else if (platform.equals(Douban)) {
return 4;
} else if (platform.equals(Renren)) {
return 3;
} else if (platform.equals(Tencent)) {
return 2;
} else if (platform.equals(Twitter)) {
return 5;
} else {
return 6;
}
}
}
| Java |
package com.outsourcing.bottle.domain;
public class ExchangePicInfoEntry {
private int suid;
private String snickname;
private String savatar;
private int ruid;
private String rnickname;
private String ravatar;
private String exfeed_send_content;
private String exfeed_send_comment;
private String exfeed_send_time;
private String exfeed_send_location;
private float exfeed_send_lng;
private float exfeed_send_lat;
private String exfeed_pic;
private String exfeed_pic_big;
private int exfeed_pic_liked;
private int exfeed_like_enable;
private int exfeed_forward_enable;
/**********新增*******************/
private int location_delete_enable;
private int location_objtype;
private int location_objid;
private String exfeed_pic_tuya;
private int exfeed_pic_allowtuya;
private int exfeed_pic_enabletuya;
private int exfeed_pic_srcpicid;
public int getLocation_delete_enable() {
return location_delete_enable;
}
public void setLocation_delete_enable(int location_delete_enable) {
this.location_delete_enable = location_delete_enable;
}
public int getLocation_objtype() {
return location_objtype;
}
public void setLocation_objtype(int location_objtype) {
this.location_objtype = location_objtype;
}
public int getLocation_objid() {
return location_objid;
}
public void setLocation_objid(int location_objid) {
this.location_objid = location_objid;
}
public String getExfeed_pic_tuya() {
return exfeed_pic_tuya;
}
public void setExfeed_pic_tuya(String exfeed_pic_tuya) {
this.exfeed_pic_tuya = exfeed_pic_tuya;
}
public int getExfeed_pic_allowtuya() {
return exfeed_pic_allowtuya;
}
public void setExfeed_pic_allowtuya(int exfeed_pic_allowtuya) {
this.exfeed_pic_allowtuya = exfeed_pic_allowtuya;
}
public int getExfeed_pic_enabletuya() {
return exfeed_pic_enabletuya;
}
public void setExfeed_pic_enabletuya(int exfeed_pic_enabletuya) {
this.exfeed_pic_enabletuya = exfeed_pic_enabletuya;
}
public int getExfeed_pic_srcpicid() {
return exfeed_pic_srcpicid;
}
public void setExfeed_pic_srcpicid(int exfeed_pic_srcpicid) {
this.exfeed_pic_srcpicid = exfeed_pic_srcpicid;
}
public int getSuid() {
return suid;
}
public void setSuid(int suid) {
this.suid = suid;
}
public String getSnickname() {
return snickname;
}
public void setSnickname(String snickname) {
this.snickname = snickname;
}
public String getSavatar() {
return savatar;
}
public void setSavatar(String savatar) {
this.savatar = savatar;
}
public int getRuid() {
return ruid;
}
public void setRuid(int ruid) {
this.ruid = ruid;
}
public String getRnickname() {
return rnickname;
}
public void setRnickname(String rnickname) {
this.rnickname = rnickname;
}
public String getRavatar() {
return ravatar;
}
public void setRavatar(String ravatar) {
this.ravatar = ravatar;
}
public String getExfeed_send_content() {
return exfeed_send_content;
}
public void setExfeed_send_content(String exfeed_send_content) {
this.exfeed_send_content = exfeed_send_content;
}
public String getExfeed_send_comment() {
return exfeed_send_comment;
}
public void setExfeed_send_comment(String exfeed_send_comment) {
this.exfeed_send_comment = exfeed_send_comment;
}
public String getExfeed_send_time() {
return exfeed_send_time;
}
public void setExfeed_send_time(String exfeed_send_time) {
this.exfeed_send_time = exfeed_send_time;
}
public String getExfeed_send_location() {
return exfeed_send_location;
}
public void setExfeed_send_location(String exfeed_send_location) {
this.exfeed_send_location = exfeed_send_location;
}
public float getExfeed_send_lng() {
return exfeed_send_lng;
}
public void setExfeed_send_lng(float exfeed_send_lng) {
this.exfeed_send_lng = exfeed_send_lng;
}
public float getExfeed_send_lat() {
return exfeed_send_lat;
}
public void setExfeed_send_lat(float exfeed_send_lat) {
this.exfeed_send_lat = exfeed_send_lat;
}
public String getExfeed_pic() {
return exfeed_pic;
}
public void setExfeed_pic(String exfeed_pic) {
this.exfeed_pic = exfeed_pic;
}
public String getExfeed_pic_big() {
return exfeed_pic_big;
}
public void setExfeed_pic_big(String exfeed_pic_big) {
this.exfeed_pic_big = exfeed_pic_big;
}
public int getExfeed_pic_liked() {
return exfeed_pic_liked;
}
public void setExfeed_pic_liked(int exfeed_pic_liked) {
this.exfeed_pic_liked = exfeed_pic_liked;
}
public int getExfeed_like_enable() {
return exfeed_like_enable;
}
public void setExfeed_like_enable(int exfeed_like_enable) {
this.exfeed_like_enable = exfeed_like_enable;
}
public int getExfeed_forward_enable() {
return exfeed_forward_enable;
}
public void setExfeed_forward_enable(int exfeed_forward_enable) {
this.exfeed_forward_enable = exfeed_forward_enable;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class SchoolInfo {
private ResponseResult results;
private EducationInfo edu_info;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public EducationInfo getEdu_info() {
return edu_info;
}
public void setEdu_info(EducationInfo edu_info) {
this.edu_info = edu_info;
}
public SchoolInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
import android.R.integer;
/**
*
* @author 06peng
*
*/
public class PictureEnrty {
private String nickname;
private int sex;
private String memo;
private String avatar;
private int albumid;
private String album_title;
private String country;
private String city;
private String doing;
private String pic_time;
private String pic_desc;
private String pic_location;
private String pic_url;
private float pic_lng;
private float pic_lat;
private int ouid;
private int picid;
private int pic_srcpicid;
private String pic_tuya_url;
private int pic_allow_tuya;
private int pic_like_mode;
private int location_delete_enable;
private int location_objtype;
private int location_objid;
public int getPicid() {
return picid;
}
public void setPicid(int picid) {
this.picid = picid;
}
public int getPic_srcpicid() {
return pic_srcpicid;
}
public void setPic_srcpicid(int pic_srcpicid) {
this.pic_srcpicid = pic_srcpicid;
}
public String getPic_tuya_url() {
return pic_tuya_url;
}
public void setPic_tuya_url(String pic_tuya_url) {
this.pic_tuya_url = pic_tuya_url;
}
public int getPic_allow_tuya() {
return pic_allow_tuya;
}
public void setPic_allow_tuya(int pic_allow_tuya) {
this.pic_allow_tuya = pic_allow_tuya;
}
public int getPic_like_mode() {
return pic_like_mode;
}
public void setPic_like_mode(int pic_like_mode) {
this.pic_like_mode = pic_like_mode;
}
public int getLocation_delete_enable() {
return location_delete_enable;
}
public void setLocation_delete_enable(int location_delete_enable) {
this.location_delete_enable = location_delete_enable;
}
public int getLocation_objtype() {
return location_objtype;
}
public void setLocation_objtype(int location_objtype) {
this.location_objtype = location_objtype;
}
public int getLocation_objid() {
return location_objid;
}
public void setLocation_objid(int location_objid) {
this.location_objid = location_objid;
}
public int getOuid() {
return ouid;
}
public void setOuid(int ouid) {
this.ouid = ouid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public int getAlbumid() {
return albumid;
}
public void setAlbumid(int albumid) {
this.albumid = albumid;
}
public String getAlbum_title() {
return album_title;
}
public void setAlbum_title(String album_title) {
this.album_title = album_title;
}
public String getPic_time() {
return pic_time;
}
public void setPic_time(String pic_time) {
this.pic_time = pic_time;
}
public String getPic_desc() {
return pic_desc;
}
public void setPic_desc(String pic_desc) {
this.pic_desc = pic_desc;
}
public String getPic_location() {
return pic_location;
}
public void setPic_location(String pic_location) {
this.pic_location = pic_location;
}
public float getPic_lng() {
return pic_lng;
}
public void setPic_lng(float pic_lng) {
this.pic_lng = pic_lng;
}
public float getPic_lat() {
return pic_lat;
}
public void setPic_lat(float pic_lat) {
this.pic_lat = pic_lat;
}
public String getPic_url() {
return pic_url;
}
public void setPic_url(String pic_url) {
this.pic_url = pic_url;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDoing() {
return doing;
}
public void setDoing(String doing) {
this.doing = doing;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class PhotoInfo {
private ResponseResult results;
private PhotoUserInfoEntry user_info;
private List<PhotoEntry> albumpics_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public PhotoUserInfoEntry getUser_info() {
return user_info;
}
public void setUser_info(PhotoUserInfoEntry user_info) {
this.user_info = user_info;
}
public List<PhotoEntry> getAlbumpics_list() {
return albumpics_list;
}
public void setAlbumpics_list(List<PhotoEntry> albumpics_list) {
this.albumpics_list = albumpics_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public PhotoInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class BasicInfoEntry {
private String nickname;
private String residecountry;
private String resideprovince;
private String residecity;
private String birthcountry;
private String birthprovince;
private String birthcity;
private String workcountry;
private String workprovince;
private String workcity;
private int birthyear;
private int birthmonth;
private int birthday;
private String career_class;
private String career_subclass;
/**婚恋状态,选择项:(0:未填写、1:单身、2:非单身)。*/
private int marry;
private String blood;
private int residecityid;
private int birthcityid;
private int workcityid;
private int career_subclassid;
private int career_classid;
private String login_user;
private String login_email;
public int getCareer_subclassid() {
return career_subclassid;
}
public void setCareer_subclassid(int career_subclassid) {
this.career_subclassid = career_subclassid;
}
public int getCareer_classid() {
return career_classid;
}
public void setCareer_classid(int career_classid) {
this.career_classid = career_classid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getResidecountry() {
return residecountry;
}
public void setResidecountry(String residecountry) {
this.residecountry = residecountry;
}
public String getResideprovince() {
return resideprovince;
}
public void setResideprovince(String resideprovince) {
this.resideprovince = resideprovince;
}
public String getResidecity() {
return residecity;
}
public void setResidecity(String residecity) {
this.residecity = residecity;
}
public String getBirthcountry() {
return birthcountry;
}
public void setBirthcountry(String birthcountry) {
this.birthcountry = birthcountry;
}
public String getBirthprovince() {
return birthprovince;
}
public void setBirthprovince(String birthprovince) {
this.birthprovince = birthprovince;
}
public String getBirthcity() {
return birthcity;
}
public void setBirthcity(String birthcity) {
this.birthcity = birthcity;
}
public String getWorkcountry() {
return workcountry;
}
public void setWorkcountry(String workcountry) {
this.workcountry = workcountry;
}
public String getWorkprovince() {
return workprovince;
}
public void setWorkprovince(String workprovince) {
this.workprovince = workprovince;
}
public String getWorkcity() {
return workcity;
}
public void setWorkcity(String workcity) {
this.workcity = workcity;
}
public int getBirthyear() {
return birthyear;
}
public void setBirthyear(int birthyear) {
this.birthyear = birthyear;
}
public int getBirthmonth() {
return birthmonth;
}
public void setBirthmonth(int birthmonth) {
this.birthmonth = birthmonth;
}
public int getBirthday() {
return birthday;
}
public void setBirthday(int birthday) {
this.birthday = birthday;
}
public String getCareer_class() {
return career_class;
}
public void setCareer_class(String career_class) {
this.career_class = career_class;
}
public String getCareer_subclass() {
return career_subclass;
}
public void setCareer_subclass(String career_subclass) {
this.career_subclass = career_subclass;
}
public int getMarry() {
return marry;
}
public void setMarry(int marry) {
this.marry = marry;
}
public String getBlood() {
return blood;
}
public void setBlood(String blood) {
this.blood = blood;
}
public int getResidecityid() {
return residecityid;
}
public void setResidecityid(int residecityid) {
this.residecityid = residecityid;
}
public int getBirthcityid() {
return birthcityid;
}
public void setBirthcityid(int birthcityid) {
this.birthcityid = birthcityid;
}
public int getWorkcityid() {
return workcityid;
}
public void setWorkcityid(int workcityid) {
this.workcityid = workcityid;
}
public String getLogin_user() {
return login_user;
}
public void setLogin_user(String login_user) {
this.login_user = login_user;
}
public String getLogin_email() {
return login_email;
}
public void setLogin_email(String login_email) {
this.login_email = login_email;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class CityInfo {
private ResponseResult results;
private List<CityEntry> cities_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<CityEntry> getCities_list() {
return cities_list;
}
public void setCities_list(List<CityEntry> cities_list) {
this.cities_list = cities_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public CityInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class CompanyInfo {
private ResponseResult results;
private List<CompanyEntry> mycompanies_list;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<CompanyEntry> getMycompanies_list() {
return mycompanies_list;
}
public void setMycompanies_list(List<CompanyEntry> mycompanies_list) {
this.mycompanies_list = mycompanies_list;
}
public CompanyInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
public class MaybeFriendEntry {
private int mkuid;
private String mknickname;
private int mksex;
private String mkavatar;
private String mkcountry;
private String mkcity;
private String mkmemo;
private String mkdoing;
private String relation_twitter;
private String relation_facebook;
private String relation_sina;
private String relation_tqq;
private String relation_renren;
private String relation_douban;
private String relation_qq;
private String relation_schoolmate;
private String relation_sameresidecity;
private String relation_samebirthcity;
private String relation_sameworkcity;
private int isnew;
public int getMkuid() {
return mkuid;
}
public void setMkuid(int mkuid) {
this.mkuid = mkuid;
}
public String getMknickname() {
return mknickname;
}
public void setMknickname(String mknickname) {
this.mknickname = mknickname;
}
public int getMksex() {
return mksex;
}
public void setMksex(int mksex) {
this.mksex = mksex;
}
public String getMkavatar() {
return mkavatar;
}
public void setMkavatar(String mkavatar) {
this.mkavatar = mkavatar;
}
public String getMkcountry() {
return mkcountry;
}
public void setMkcountry(String mkcountry) {
this.mkcountry = mkcountry;
}
public String getMkcity() {
return mkcity;
}
public void setMkcity(String mkcity) {
this.mkcity = mkcity;
}
public String getMkmemo() {
return mkmemo;
}
public void setMkmemo(String mkmemo) {
this.mkmemo = mkmemo;
}
public String getMkdoing() {
return mkdoing;
}
public void setMkdoing(String mkdoing) {
this.mkdoing = mkdoing;
}
public String getRelation_twitter() {
return relation_twitter;
}
public void setRelation_twitter(String relation_twitter) {
this.relation_twitter = relation_twitter;
}
public String getRelation_facebook() {
return relation_facebook;
}
public void setRelation_facebook(String relation_facebook) {
this.relation_facebook = relation_facebook;
}
public String getRelation_sina() {
return relation_sina;
}
public void setRelation_sina(String relation_sina) {
this.relation_sina = relation_sina;
}
public String getRelation_tqq() {
return relation_tqq;
}
public void setRelation_tqq(String relation_tqq) {
this.relation_tqq = relation_tqq;
}
public String getRelation_renren() {
return relation_renren;
}
public void setRelation_renren(String relation_renren) {
this.relation_renren = relation_renren;
}
public String getRelation_douban() {
return relation_douban;
}
public void setRelation_douban(String relation_douban) {
this.relation_douban = relation_douban;
}
public String getRelation_qq() {
return relation_qq;
}
public void setRelation_qq(String relation_qq) {
this.relation_qq = relation_qq;
}
public String getRelation_schoolmate() {
return relation_schoolmate;
}
public void setRelation_schoolmate(String relation_schoolmate) {
this.relation_schoolmate = relation_schoolmate;
}
public String getRelation_sameresidecity() {
return relation_sameresidecity;
}
public void setRelation_sameresidecity(String relation_sameresidecity) {
this.relation_sameresidecity = relation_sameresidecity;
}
public String getRelation_samebirthcity() {
return relation_samebirthcity;
}
public void setRelation_samebirthcity(String relation_samebirthcity) {
this.relation_samebirthcity = relation_samebirthcity;
}
public String getRelation_sameworkcity() {
return relation_sameworkcity;
}
public void setRelation_sameworkcity(String relation_sameworkcity) {
this.relation_sameworkcity = relation_sameworkcity;
}
public int getIsnew() {
return isnew;
}
public void setIsnew(int isnew) {
this.isnew = isnew;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
* 开放平台
* @author 06peng
*
*/
public class PlatformAccount {
/**
* 开放平台类型
* QQ(0)、
* 新浪微博(1)、
* 腾讯微博(2)、
* 人人网(3)、
* 豆瓣网(4)、
* twitter(5)、
* facebook(6)。
*/
private int openType;
private String accessToken;
private String tokenSecret;
private String nickName;
/**
* 开放平台uid(QQ为一个用户ID的字符串,腾讯微博为用户登录名,其他开放平台为一个数字ID)
*/
private String openUid;
/**
* 开放平台性别(新浪微博、腾讯微博、人人网有,其他没有)
*/
private int openSex;
/**
* 开放平台过期标识(人人网特有)
*/
private String openExpire;
private String openAvatar;
public int getOpenType() {
return openType;
}
public void setOpenType(int openType) {
this.openType = openType;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getTokenSecret() {
return tokenSecret;
}
public void setTokenSecret(String tokenSecret) {
this.tokenSecret = tokenSecret;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getOpenUid() {
return openUid;
}
public void setOpenUid(String openUid) {
this.openUid = openUid;
}
public int getOpenSex() {
return openSex;
}
public void setOpenSex(int openSex) {
this.openSex = openSex;
}
public String getOpenExpire() {
return openExpire;
}
public void setOpenExpire(String openExpire) {
this.openExpire = openExpire;
}
public String getOpenAvatar() {
return openAvatar;
}
public void setOpenAvatar(String openAvatar) {
this.openAvatar = openAvatar;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class BottleFeedInfo {
private ResponseResult results;
private List<SpaceBottleFeedEntry> btfeeds_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<SpaceBottleFeedEntry> getBtfeeds_list() {
return btfeeds_list;
}
public void setBtfeeds_list(List<SpaceBottleFeedEntry> btfeeds_list) {
this.btfeeds_list = btfeeds_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public BottleFeedInfo() {
super();
}
public BottleFeedInfo(ResponseResult results, List<SpaceBottleFeedEntry> btfeeds_list, int rscount) {
super();
this.results = results;
this.btfeeds_list = btfeeds_list;
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class BottleFeedLocationInfo {
private ResponseResult results;
private List<BottleFeedLocationEntry> btfeedslocation_list;
private int rscount;
public BottleFeedLocationInfo() {
super();
}
public BottleFeedLocationInfo(ResponseResult results,List<BottleFeedLocationEntry> btfeedslocation_list, int rscount) {
super();
this.results = results;
this.btfeedslocation_list = btfeedslocation_list;
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<BottleFeedLocationEntry> getBtfeedslocation_list() {
return btfeedslocation_list;
}
public void setBtfeedslocation_list(
List<BottleFeedLocationEntry> btfeedslocation_list) {
this.btfeedslocation_list = btfeedslocation_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class ProfileEntry {
/**对方资料是否对你可见。选择项:是(1)、否(0)*/
private int info_visible;
private String residecity; //居住地(国家、省份、城市)。无论资料是否可见,都可以看到。
/**
* 如果对方资料对你不可见,这里为空
*/
private String hometown;
private String workcity;
private String birthday;
private String blood;
private String marriagestatus;
// private String QQ;
// private String MSN;
// private String email;
// private String mobile;
private String edustatus;
private String school;
private String company;
private String career;
public ProfileEntry() {
super();
}
public int getInfo_visible() {
return info_visible;
}
public void setInfo_visible(int info_visible) {
this.info_visible = info_visible;
}
public String getResidecity() {
return residecity;
}
public void setResidecity(String residecity) {
this.residecity = residecity;
}
public String getHometown() {
return hometown;
}
public void setHometown(String hometown) {
this.hometown = hometown;
}
public String getWorkcity() {
return workcity;
}
public void setWorkcity(String workcity) {
this.workcity = workcity;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getBlood() {
return blood;
}
public void setBlood(String blood) {
this.blood = blood;
}
public String getMarriagestatus() {
return marriagestatus;
}
public void setMarriagestatus(String marriagestatus) {
this.marriagestatus = marriagestatus;
}
public String getEdustatus() {
return edustatus;
}
public void setEdustatus(String edustatus) {
this.edustatus = edustatus;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCareer() {
return career;
}
public void setCareer(String career) {
this.career = career;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class UserBasicInfo {
private ResponseResult results;
private BasicInfoEntry basic_info;
public UserBasicInfo() {
super();
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public BasicInfoEntry getBasic_info() {
return basic_info;
}
public void setBasic_info(BasicInfoEntry basic_info) {
this.basic_info = basic_info;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class PushNoticeInfo {
private int new_notice_count;
private int new_message_count;
private int new_btfeed_count;
private int new_exfeed_count;
private int new_maybeknow_count;
private String message_content;
private String message_avatar;
public int getNew_notice_count() {
return new_notice_count;
}
public void setNew_notice_count(int new_notice_count) {
this.new_notice_count = new_notice_count;
}
public int getNew_message_count() {
return new_message_count;
}
public void setNew_message_count(int new_message_count) {
this.new_message_count = new_message_count;
}
public int getNew_btfeed_count() {
return new_btfeed_count;
}
public void setNew_btfeed_count(int new_btfeed_count) {
this.new_btfeed_count = new_btfeed_count;
}
public int getNew_exfeed_count() {
return new_exfeed_count;
}
public void setNew_exfeed_count(int new_exfeed_count) {
this.new_exfeed_count = new_exfeed_count;
}
public String getMessage_content() {
return message_content;
}
public void setMessage_content(String message_content) {
this.message_content = message_content;
}
public String getMessage_avatar() {
return message_avatar;
}
public void setMessage_avatar(String message_avatar) {
this.message_avatar = message_avatar;
}
public int getNew_maybeknow_count() {
return new_maybeknow_count;
}
public void setNew_maybeknow_count(int new_maybeknow_count) {
this.new_maybeknow_count = new_maybeknow_count;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class ExchangeTimelineInfo {
private ResponseResult results;
private ExchangeShowTipsEntry showtips;
private List<ExsessionsEntry> exsessions_list;
private int rscount;
public ExchangeTimelineInfo() {
super();
}
public ExchangeTimelineInfo(ResponseResult results,
ExchangeShowTipsEntry showtips,
List<ExsessionsEntry> exsessions_list, int rscount) {
super();
this.results = results;
this.showtips = showtips;
this.exsessions_list = exsessions_list;
this.rscount = rscount;
}
public ExchangeShowTipsEntry getShowtips() {
return showtips;
}
public void setShowtips(ExchangeShowTipsEntry showtips) {
this.showtips = showtips;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public void setExsessions_list(List<ExsessionsEntry> exsessions_list) {
this.exsessions_list = exsessions_list;
}
public List<ExsessionsEntry> getExsessions_list() {
return exsessions_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class GroupFriendEntry {
private int groupid;
private String groupname;
public int getGroupid() {
return groupid;
}
public void setGroupid(int groupid) {
this.groupid = groupid;
}
public String getGroupname() {
return groupname;
}
public void setGroupname(String groupname) {
this.groupname = groupname;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class MessageEntry {
private int uid;
private String nickname;
private String avatar;
private String content;
private int isnew;
private String message_time;
private String message_location;
private float message_lng;
private float message_lat;
private int location_delete_enable;
private int location_objtype;
private int location_objid;
public int getLocation_delete_enable() {
return location_delete_enable;
}
public void setLocation_delete_enable(int location_delete_enable) {
this.location_delete_enable = location_delete_enable;
}
public int getLocation_objtype() {
return location_objtype;
}
public void setLocation_objtype(int location_objtype) {
this.location_objtype = location_objtype;
}
public int getLocation_objid() {
return location_objid;
}
public void setLocation_objid(int location_objid) {
this.location_objid = location_objid;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getIsnew() {
return isnew;
}
public void setIsnew(int isnew) {
this.isnew = isnew;
}
public String getMessage_time() {
return message_time;
}
public void setMessage_time(String message_time) {
this.message_time = message_time;
}
public String getMessage_location() {
return message_location;
}
public void setMessage_location(String message_location) {
this.message_location = message_location;
}
public float getMessage_lng() {
return message_lng;
}
public void setMessage_lng(float message_lng) {
this.message_lng = message_lng;
}
public float getMessage_lat() {
return message_lat;
}
public void setMessage_lat(float message_lat) {
this.message_lat = message_lat;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class ExPicSessionEntry {
private int exsid;
private int exs_uid;
private String exs_nickname;
private String exs_avatar;
private int exs_ouid;
private String exs_onickname;
private String exs_oavatar;
private String exs_firstfeed;
private String exs_firstfeedtime;
private int exs_success;
private int exs_picex_rejectshow;
private int exs_picex_visibleshow;
private int exs_picex_invisibleshow;
public int getExsid() {
return exsid;
}
public void setExsid(int exsid) {
this.exsid = exsid;
}
public int getExs_uid() {
return exs_uid;
}
public void setExs_uid(int exs_uid) {
this.exs_uid = exs_uid;
}
public String getExs_nickname() {
return exs_nickname;
}
public void setExs_nickname(String exs_nickname) {
this.exs_nickname = exs_nickname;
}
public String getExs_avatar() {
return exs_avatar;
}
public void setExs_avatar(String exs_avatar) {
this.exs_avatar = exs_avatar;
}
public int getExs_ouid() {
return exs_ouid;
}
public void setExs_ouid(int exs_ouid) {
this.exs_ouid = exs_ouid;
}
public String getExs_onickname() {
return exs_onickname;
}
public void setExs_onickname(String exs_onickname) {
this.exs_onickname = exs_onickname;
}
public String getExs_oavatar() {
return exs_oavatar;
}
public void setExs_oavatar(String exs_oavatar) {
this.exs_oavatar = exs_oavatar;
}
public String getExs_firstfeed() {
return exs_firstfeed;
}
public void setExs_firstfeed(String exs_firstfeed) {
this.exs_firstfeed = exs_firstfeed;
}
public String getExs_firstfeedtime() {
return exs_firstfeedtime;
}
public void setExs_firstfeedtime(String exs_firstfeedtime) {
this.exs_firstfeedtime = exs_firstfeedtime;
}
public int getExs_success() {
return exs_success;
}
public void setExs_success(int exs_success) {
this.exs_success = exs_success;
}
public int getExs_picex_rejectshow() {
return exs_picex_rejectshow;
}
public void setExs_picex_rejectshow(int exs_picex_rejectshow) {
this.exs_picex_rejectshow = exs_picex_rejectshow;
}
public int getExs_picex_visibleshow() {
return exs_picex_visibleshow;
}
public void setExs_picex_visibleshow(int exs_picex_visibleshow) {
this.exs_picex_visibleshow = exs_picex_visibleshow;
}
public int getExs_picex_invisibleshow() {
return exs_picex_invisibleshow;
}
public void setExs_picex_invisibleshow(int exs_picex_invisibleshow) {
this.exs_picex_invisibleshow = exs_picex_invisibleshow;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class BottleInfoEntry {
private int bttypeid;
private int bt_uid;
private String bt_nickname;
private String bt_avatar;
private String bt_feed;
private String bt_time;
private String bt_location;
private float bt_lng;
private float bt_lat;
private int bt_showaddress;
private String bt_tag;
private String bt_copy_info;
private String bt_content;
private String bt_doing;
private String bt_smallpic;
private String bt_bigpic;
private int bt_allow_spread;
private int bt_allow_tuya;
private int bt_enable_tuya;
private int bt_copy_enable;
private int bt_like_enable;
private int bt_pic_locked;
private int bt_liked;
private int bt_srcbtid;
private String bt_srcfeed;
private String bt_srctime;
private int bt_srcuid;
private String bt_srcnickname;
private String bt_srcavatar;
private String bt_srclocation;
private float bt_srclng;
private float bt_srclat;
private String bt_opfeed;
private String bt_optime;
private int bt_opuid;
private String bt_opnickname;
private String bt_opavatar;
private String bt_oplocation;
private float bt_oplng;
private float bt_oplat;
private String bt_opdistance;
public int getBttypeid() {
return bttypeid;
}
public void setBttypeid(int bttypeid) {
this.bttypeid = bttypeid;
}
public int getBt_uid() {
return bt_uid;
}
public void setBt_uid(int bt_uid) {
this.bt_uid = bt_uid;
}
public String getBt_nickname() {
return bt_nickname;
}
public void setBt_nickname(String bt_nickname) {
this.bt_nickname = bt_nickname;
}
public String getBt_avatar() {
return bt_avatar;
}
public void setBt_avatar(String bt_avatar) {
this.bt_avatar = bt_avatar;
}
public String getBt_feed() {
return bt_feed;
}
public void setBt_feed(String bt_feed) {
this.bt_feed = bt_feed;
}
public String getBt_time() {
return bt_time;
}
public void setBt_time(String bt_time) {
this.bt_time = bt_time;
}
public String getBt_location() {
return bt_location;
}
public void setBt_location(String bt_location) {
this.bt_location = bt_location;
}
public float getBt_lng() {
return bt_lng;
}
public void setBt_lng(float bt_lng) {
this.bt_lng = bt_lng;
}
public float getBt_lat() {
return bt_lat;
}
public void setBt_lat(float bt_lat) {
this.bt_lat = bt_lat;
}
public String getBt_tag() {
return bt_tag;
}
public void setBt_tag(String bt_tag) {
this.bt_tag = bt_tag;
}
public String getBt_content() {
return bt_content;
}
public void setBt_content(String bt_content) {
this.bt_content = bt_content;
}
public String getBt_doing() {
return bt_doing;
}
public void setBt_doing(String bt_doing) {
this.bt_doing = bt_doing;
}
public String getBt_smallpic() {
return bt_smallpic;
}
public void setBt_smallpic(String bt_smallpic) {
this.bt_smallpic = bt_smallpic;
}
public String getBt_bigpic() {
return bt_bigpic;
}
public void setBt_bigpic(String bt_bigpic) {
this.bt_bigpic = bt_bigpic;
}
public int getBt_allow_spread() {
return bt_allow_spread;
}
public void setBt_allow_spread(int bt_allow_spread) {
this.bt_allow_spread = bt_allow_spread;
}
public int getBt_copy_enable() {
return bt_copy_enable;
}
public void setBt_copy_enable(int bt_copy_enable) {
this.bt_copy_enable = bt_copy_enable;
}
public int getBt_like_enable() {
return bt_like_enable;
}
public void setBt_like_enable(int bt_like_enable) {
this.bt_like_enable = bt_like_enable;
}
public int getBt_pic_locked() {
return bt_pic_locked;
}
public void setBt_pic_locked(int bt_pic_locked) {
this.bt_pic_locked = bt_pic_locked;
}
public int getBt_liked() {
return bt_liked;
}
public void setBt_liked(int bt_liked) {
this.bt_liked = bt_liked;
}
public int getBt_showaddress() {
return bt_showaddress;
}
public void setBt_showaddress(int bt_showaddress) {
this.bt_showaddress = bt_showaddress;
}
public int getBt_allow_tuya() {
return bt_allow_tuya;
}
public void setBt_allow_tuya(int bt_allow_tuya) {
this.bt_allow_tuya = bt_allow_tuya;
}
public int getBt_enable_tuya() {
return bt_enable_tuya;
}
public void setBt_enable_tuya(int bt_enable_tuya) {
this.bt_enable_tuya = bt_enable_tuya;
}
public int getBt_srcbtid() {
return bt_srcbtid;
}
public void setBt_srcbtid(int bt_srcbtid) {
this.bt_srcbtid = bt_srcbtid;
}
public String getBt_srcfeed() {
return bt_srcfeed;
}
public void setBt_srcfeed(String bt_srcfeed) {
this.bt_srcfeed = bt_srcfeed;
}
public String getBt_srctime() {
return bt_srctime;
}
public void setBt_srctime(String bt_srctime) {
this.bt_srctime = bt_srctime;
}
public int getBt_srcuid() {
return bt_srcuid;
}
public void setBt_srcuid(int bt_srcuid) {
this.bt_srcuid = bt_srcuid;
}
public float getBt_srclng() {
return bt_srclng;
}
public void setBt_srclng(float bt_srclng) {
this.bt_srclng = bt_srclng;
}
public String getBt_srcavatar() {
return bt_srcavatar;
}
public void setBt_srcavatar(String bt_srcavatar) {
this.bt_srcavatar = bt_srcavatar;
}
public String getBt_srcnickname() {
return bt_srcnickname;
}
public void setBt_srcnickname(String bt_srcnickname) {
this.bt_srcnickname = bt_srcnickname;
}
public String getBt_srclocation() {
return bt_srclocation;
}
public void setBt_srclocation(String bt_srclocation) {
this.bt_srclocation = bt_srclocation;
}
public float getBt_srclat() {
return bt_srclat;
}
public void setBt_srclat(float bt_srclat) {
this.bt_srclat = bt_srclat;
}
public String getBt_opfeed() {
return bt_opfeed;
}
public void setBt_opfeed(String bt_opfeed) {
this.bt_opfeed = bt_opfeed;
}
public String getBt_optime() {
return bt_optime;
}
public void setBt_optime(String bt_optime) {
this.bt_optime = bt_optime;
}
public int getBt_opuid() {
return bt_opuid;
}
public void setBt_opuid(int bt_opuid) {
this.bt_opuid = bt_opuid;
}
public String getBt_opnickname() {
return bt_opnickname;
}
public void setBt_opnickname(String bt_opnickname) {
this.bt_opnickname = bt_opnickname;
}
public String getBt_opavatar() {
return bt_opavatar;
}
public void setBt_opavatar(String bt_opavatar) {
this.bt_opavatar = bt_opavatar;
}
public String getBt_oplocation() {
return bt_oplocation;
}
public void setBt_oplocation(String bt_oplocation) {
this.bt_oplocation = bt_oplocation;
}
public float getBt_oplng() {
return bt_oplng;
}
public void setBt_oplng(float bt_oplng) {
this.bt_oplng = bt_oplng;
}
public float getBt_oplat() {
return bt_oplat;
}
public void setBt_oplat(float bt_oplat) {
this.bt_oplat = bt_oplat;
}
public String getBt_opdistance() {
return bt_opdistance;
}
public void setBt_opdistance(String bt_opdistance) {
this.bt_opdistance = bt_opdistance;
}
public String getBt_copy_info() {
return bt_copy_info;
}
public void setBt_copy_info(String bt_copy_info) {
this.bt_copy_info = bt_copy_info;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.ArrayList;
import java.util.List;
public class BottleLikeListInfo {
private ResponseResult results;
private List<BottleLikeEntry> btlikes_list;
private int btlikes_count;
public BottleLikeListInfo(){
}
public BottleLikeListInfo(ResponseResult results,
ArrayList<BottleLikeEntry> btlikes_list, int btlikes_count) {
super();
this.results = results;
this.btlikes_list = btlikes_list;
this.btlikes_count = btlikes_count;
}
public List<BottleLikeEntry> getBtlikes_list() {
return btlikes_list;
}
public void setBtlikes_list(ArrayList<BottleLikeEntry> btlikes_list) {
this.btlikes_list = btlikes_list;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public void setBtlikes_count(int btlikes_count) {
this.btlikes_count = btlikes_count;
}
public int getBtlikes_count() {
return btlikes_count;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class CareerInfo {
private ResponseResult results;
private List<CareerEntry> careers_list;
public CareerInfo() {
super();
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<CareerEntry> getCareers_list() {
return careers_list;
}
public void setCareers_list(List<CareerEntry> careers_list) {
this.careers_list = careers_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class SpaceInfo {
private ResponseResult results;
private SpaceEntry space_info;
private List<FriendGroupEntry> groups_list;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public SpaceEntry getSpace_info() {
return space_info;
}
public void setSpace_info(SpaceEntry space_info) {
this.space_info = space_info;
}
public List<FriendGroupEntry> getGroups_list() {
return groups_list;
}
public void setGroups_list(List<FriendGroupEntry> groups_list) {
this.groups_list = groups_list;
}
public SpaceInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
public class BottleLikeEntry {
private int like_uid;
private String like_nickname;
private String like_avatar;
private int like_type;
public int getLike_uid() {
return like_uid;
}
public void setLike_uid(int like_uid) {
this.like_uid = like_uid;
}
public String getLike_nickname() {
return like_nickname;
}
public void setLike_nickname(String like_nickname) {
this.like_nickname = like_nickname;
}
public String getLike_avatar() {
return like_avatar;
}
public void setLike_avatar(String like_avatar) {
this.like_avatar = like_avatar;
}
public int getLike_type() {
return like_type;
}
public void setLike_type(int like_type) {
this.like_type = like_type;
}
}
| Java |
package com.outsourcing.bottle.domain;
public class MyFriendEntry {
private int fuid;
private String fnickname;
private int fsex;
private String btf_avatar;
private int groupid;
private String fcountry;
private String fcity;
private String fmemo;
private String fdoing;
public int getFuid() {
return fuid;
}
public void setFuid(int fuid) {
this.fuid = fuid;
}
public String getFnickname() {
return fnickname;
}
public void setFnickname(String fnickname) {
this.fnickname = fnickname;
}
public int getFsex() {
return fsex;
}
public void setFsex(int fsex) {
this.fsex = fsex;
}
public String getFavatar() {
return btf_avatar;
}
public void setFavatar(String btf_avatar) {
this.btf_avatar = btf_avatar;
}
public int getGroupid() {
return groupid;
}
public void setGroupid(int groupid) {
this.groupid = groupid;
}
public String getFcountry() {
return fcountry;
}
public void setFcountry(String fcountry) {
this.fcountry = fcountry;
}
public String getFcity() {
return fcity;
}
public void setFcity(String fcity) {
this.fcity = fcity;
}
public String getFmemo() {
return fmemo;
}
public void setFmemo(String fmemo) {
this.fmemo = fmemo;
}
public String getFdoing() {
return fdoing;
}
public void setFdoing(String fdoing) {
this.fdoing = fdoing;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class MaybeKnowFriendInfo {
private ResponseResult results;
private List<MaybeFriendEntry> maybeknows_list;
private int rscount;
public MaybeKnowFriendInfo() {
super();
}
public MaybeKnowFriendInfo(ResponseResult results,
List<MaybeFriendEntry> maybeknows_list, int rscount) {
super();
this.results = results;
this.maybeknows_list = maybeknows_list;
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<MaybeFriendEntry> getMaybeknows_list() {
return maybeknows_list;
}
public void setMaybeknows_list(List<MaybeFriendEntry> maybeknows_list) {
this.maybeknows_list = maybeknows_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class CheckFriendApplyInfo {
private ResponseResult results;
private List<MaybeFriendEntry> maybeknows_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<MaybeFriendEntry> getMaybeknows_list() {
return maybeknows_list;
}
public void setMaybeknows_list(List<MaybeFriendEntry> maybeknows_list) {
this.maybeknows_list = maybeknows_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class FriendEntry {
private int uid;
private String nickname;
private int sex;
private String avatar;
private String country;
private String city;
/**备注*/
private String memo;
private String doing;
private boolean isSelected;
/**头像是否可以点击。选择项:是(1)、否(0)*/
private int avatar_click;
/**头像右侧按钮显示模式。选择项:已经照片交换(0)、未照片交换(1)、已经资料交换(2)、未资料交换(3)、多选(4)、单选(5)*/
private int button_mode;
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean isSelected) {
this.isSelected = isSelected;
}
public String getDoing() {
return doing;
}
public void setDoing(String doing) {
this.doing = doing;
}
public int getAvatar_click() {
return avatar_click;
}
public void setAvatar_click(int avatar_click) {
this.avatar_click = avatar_click;
}
public int getButton_mode() {
return button_mode;
}
public void setButton_mode(int button_mode) {
this.button_mode = button_mode;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class BottleFeedListInfo {
private ResponseResult results;
private List<BottleFeedListEntry> btfeeds_list;
private int rscount;
public BottleFeedListInfo() {
super();
}
public BottleFeedListInfo(ResponseResult results,
List<BottleFeedListEntry> btfeeds_list, int rscount) {
super();
this.results = results;
this.btfeeds_list = btfeeds_list;
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<BottleFeedListEntry> getBtfeeds_list() {
return btfeeds_list;
}
public void setBtfeeds_list(List<BottleFeedListEntry> btfeeds_list) {
this.btfeeds_list = btfeeds_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class ProfileInfo {
private ResponseResult results;
private ProfileEntry profile_info;
public ProfileInfo() {
super();
}
public ProfileInfo(ResponseResult results, ProfileEntry profile_info) {
super();
this.results = results;
this.profile_info = profile_info;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public ProfileEntry getProfile_info() {
return profile_info;
}
public void setProfile_info(ProfileEntry profile_info) {
this.profile_info = profile_info;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class EducationInfo {
private String status;
private List<SchoolEntry> myschools_list;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<SchoolEntry> getMyschools_list() {
return myschools_list;
}
public void setMyschools_list(List<SchoolEntry> myschools_list) {
this.myschools_list = myschools_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class PhotoUserInfoEntry {
private String nickname;
private int sex;
private String avatar;
private String memo;
private String album_title;
private String doing;
private String country;
private String city;
private int ouid;
public int getOuid() {
return ouid;
}
public void setOuid(int ouid) {
this.ouid = ouid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getAlbum_title() {
return album_title;
}
public void setAlbum_title(String album_title) {
this.album_title = album_title;
}
public String getDoing() {
return doing;
}
public void setDoing(String doing) {
this.doing = doing;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class CompanyEntry {
private int companyid;
private String company;
public int getCompanyid() {
return companyid;
}
public void setCompanyid(int companyid) {
this.companyid = companyid;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class ExchangePicFeedInfo {
private ResponseResult results;
private ExchangePicInfoEntry pic_info;
private List<ExFeedInfoEntry> exfeeds_list;
private int rscount;
public ExchangePicFeedInfo() {
super();
}
public ExchangePicFeedInfo(ResponseResult results,
ExchangePicInfoEntry pic_info, List<ExFeedInfoEntry> exfeeds_list,
int rscount) {
super();
this.results = results;
this.pic_info = pic_info;
this.exfeeds_list = exfeeds_list;
this.rscount = rscount;
}
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public ExchangePicInfoEntry getPic_info() {
return pic_info;
}
public void setPic_info(ExchangePicInfoEntry pic_info) {
this.pic_info = pic_info;
}
public List<ExFeedInfoEntry> getExfeeds_list() {
return exfeeds_list;
}
public void setExfeeds_list(List<ExFeedInfoEntry> exfeeds_list) {
this.exfeeds_list = exfeeds_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
* 服务器返回结果
* @author 06peng
*
*/
public class ResponseResult {
/**
* 授权是否成功,如果授权失败,
* 则返回错误原因并且取不到以下接口的信息,选择项:是(1)、否(0)
*/
private int authok;
/**
* 错误原因
*/
private String errmsg;
public int getAuthok() {
return authok;
}
public void setAuthok(int authok) {
this.authok = authok;
}
public String getErrmsg() {
return errmsg;
}
public void setErrmsg(String errmsg) {
this.errmsg = errmsg;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class ExsessionsEntry {
private int exsid;
private int exs_uid;
private String exs_nickname;
private String exs_avatar;
private int exs_ouid;
private String exs_onickname;
private String exs_oavatar;
private int exs_type;
private String exs_firstfeed;
private String exs_firstfeedtime;
private int exs_success;
private int exs_infoex_rejectshow;
private int exs_infoex_acceptshow;
private int exs_infoex_visibleshow;
private int exs_infoex_invisibleshow;
private int exs_picex_rejectshow;
private int exs_picex_visibleshow;
private int exs_picex_invisibleshow;
private List<ExFeedEntry> exfeeds_list;
private int exfeeds_count;
public int getExsid() {
return exsid;
}
public void setExsid(int exsid) {
this.exsid = exsid;
}
public int getExs_uid() {
return exs_uid;
}
public void setExs_uid(int exs_uid) {
this.exs_uid = exs_uid;
}
public String getExs_nickname() {
return exs_nickname;
}
public void setExs_nickname(String exs_nickname) {
this.exs_nickname = exs_nickname;
}
public String getExs_avatar() {
return exs_avatar;
}
public void setExs_avatar(String exs_avatar) {
this.exs_avatar = exs_avatar;
}
public int getExs_ouid() {
return exs_ouid;
}
public void setExs_ouid(int exs_ouid) {
this.exs_ouid = exs_ouid;
}
public String getExs_onickname() {
return exs_onickname;
}
public void setExs_onickname(String exs_onickname) {
this.exs_onickname = exs_onickname;
}
public String getExs_oavatar() {
return exs_oavatar;
}
public void setExs_oavatar(String exs_oavatar) {
this.exs_oavatar = exs_oavatar;
}
public int getExs_type() {
return exs_type;
}
public void setExs_type(int exs_type) {
this.exs_type = exs_type;
}
public String getExs_firstfeed() {
return exs_firstfeed;
}
public void setExs_firstfeed(String exs_firstfeed) {
this.exs_firstfeed = exs_firstfeed;
}
public String getExs_firstfeedtime() {
return exs_firstfeedtime;
}
public void setExs_firstfeedtime(String exs_firstfeedtime) {
this.exs_firstfeedtime = exs_firstfeedtime;
}
public int getExs_success() {
return exs_success;
}
public void setExs_success(int exs_success) {
this.exs_success = exs_success;
}
public int getExs_infoex_rejectshow() {
return exs_infoex_rejectshow;
}
public void setExs_infoex_rejectshow(int exs_infoex_rejectshow) {
this.exs_infoex_rejectshow = exs_infoex_rejectshow;
}
public int getExs_infoex_acceptshow() {
return exs_infoex_acceptshow;
}
public void setExs_infoex_acceptshow(int exs_infoex_acceptshow) {
this.exs_infoex_acceptshow = exs_infoex_acceptshow;
}
public int getExs_infoex_visibleshow() {
return exs_infoex_visibleshow;
}
public void setExs_infoex_visibleshow(int exs_infoex_visibleshow) {
this.exs_infoex_visibleshow = exs_infoex_visibleshow;
}
public int getExs_infoex_invisibleshow() {
return exs_infoex_invisibleshow;
}
public void setExs_infoex_invisibleshow(int exs_infoex_invisibleshow) {
this.exs_infoex_invisibleshow = exs_infoex_invisibleshow;
}
public int getExs_picex_rejectshow() {
return exs_picex_rejectshow;
}
public void setExs_picex_rejectshow(int exs_picex_rejectshow) {
this.exs_picex_rejectshow = exs_picex_rejectshow;
}
public int getExs_picex_visibleshow() {
return exs_picex_visibleshow;
}
public void setExs_picex_visibleshow(int exs_picex_visibleshow) {
this.exs_picex_visibleshow = exs_picex_visibleshow;
}
public int getExs_picex_invisibleshow() {
return exs_picex_invisibleshow;
}
public void setExs_picex_invisibleshow(int exs_picex_invisibleshow) {
this.exs_picex_invisibleshow = exs_picex_invisibleshow;
}
public int getExfeeds_count() {
return exfeeds_count;
}
public void setExfeeds_count(int exfeeds_count) {
this.exfeeds_count = exfeeds_count;
}
public List<ExFeedEntry> getExfeeds_list() {
return exfeeds_list;
}
public void setExfeeds_list(List<ExFeedEntry> exfeeds_list) {
this.exfeeds_list = exfeeds_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class AlbumEntry {
private int album_id;
private String album_title;
private int album_picnum;
private String album_cover;
public int getAlbum_id() {
return album_id;
}
public void setAlbum_id(int album_id) {
this.album_id = album_id;
}
public String getAlbum_title() {
return album_title;
}
public void setAlbum_title(String album_title) {
this.album_title = album_title;
}
public int getAlbum_picnum() {
return album_picnum;
}
public void setAlbum_picnum(int album_picnum) {
this.album_picnum = album_picnum;
}
public String getAlbum_cover() {
return album_cover;
}
public void setAlbum_cover(String album_cover) {
this.album_cover = album_cover;
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
/**
*
* @author 06peng
*
*/
public class PictrueInfo {
private ResponseResult results;
private PictureEnrty pic_info;
private List<CommentEntry> comments_list;
private int rscount;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public PictureEnrty getPic_info() {
return pic_info;
}
public void setPic_info(PictureEnrty pic_info) {
this.pic_info = pic_info;
}
public List<CommentEntry> getComments_list() {
return comments_list;
}
public void setComments_list(List<CommentEntry> comments_list) {
this.comments_list = comments_list;
}
public int getRscount() {
return rscount;
}
public void setRscount(int rscount) {
this.rscount = rscount;
}
public PictrueInfo() {
super();
}
}
| Java |
package com.outsourcing.bottle.domain;
import java.util.List;
public class PastersListInfo {
private ResponseResult results;
private List<StickEntry> pasters_list;
public ResponseResult getResults() {
return results;
}
public void setResults(ResponseResult results) {
this.results = results;
}
public List<StickEntry> getPasters_list() {
return pasters_list;
}
public void setPasters_list(List<StickEntry> pasters_list) {
this.pasters_list = pasters_list;
}
}
| Java |
package com.outsourcing.bottle.domain;
/**
*
* @author 06peng
*
*/
public class NoticeEntry {
private int uid;
private String nickname;
private String avatar;
private String content;
private int isnew;
/**通知类型,选择项:照片类通知(0)、瓶子类通知(1)、接受好友申请通知(2)、申请好友通知(3)*/
private int notice_type;
private int notice_picid;
private int notice_btid;
private String notice_time;
private String notice_smallpic;
private String notice_bigpic;
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getIsnew() {
return isnew;
}
public void setIsnew(int isnew) {
this.isnew = isnew;
}
public int getNotice_type() {
return notice_type;
}
public void setNotice_type(int notice_type) {
this.notice_type = notice_type;
}
public int getNotice_picid() {
return notice_picid;
}
public void setNotice_picid(int notice_picid) {
this.notice_picid = notice_picid;
}
public int getNotice_btid() {
return notice_btid;
}
public void setNotice_btid(int notice_btid) {
this.notice_btid = notice_btid;
}
public String getNotice_time() {
return notice_time;
}
public void setNotice_time(String notice_time) {
this.notice_time = notice_time;
}
public String getNotice_smallpic() {
return notice_smallpic;
}
public void setNotice_smallpic(String notice_smallpic) {
this.notice_smallpic = notice_smallpic;
}
public String getNotice_bigpic() {
return notice_bigpic;
}
public void setNotice_bigpic(String notice_bigpic) {
this.notice_bigpic = notice_bigpic;
}
}
| Java |
package com.outsourcing.bottle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.support.v4.app.FragmentActivity;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.Toast;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.outsourcing.bottle.ui.HomeActivity;
import com.outsourcing.bottle.ui.LoginPlatformActivity;
import com.outsourcing.bottle.util.ActivityManager;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.BottleApplication;
import com.outsourcing.bottle.util.CommandTaskEvent;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.widget.CustomDialog;
/**
*
* @author mzba
*
*/
public class BasicActivity extends FragmentActivity implements BasicUIEvent {
public static final int DESTROYDIALOG = 0x00000101;
private final static int cancelAlertDialog = 0x00000102;
private final static int destroyDialogByFinish = 0x00000103;
public CustomDialog dialog;
protected Toast toast;
public int CanvasHeight;
public int CanvasWidth;
public BottleApplication app;
private double latitude;
private double longitude;
public String bestProvider;
public LocationManager locationManager;
public Location location;
public static final int open_location_network = 2001;
public LocationClient mLocationClient = null;
public MyLocationListenner myListener = new MyLocationListenner();
public String countryIso;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
AppContext.setContext(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
TextUtil.setCtxForGetResString(this);
ActivityManager.addActivity(this);
LinearLayout layout = new LinearLayout(this);
Button bt = new Button(this);
layout.addView(bt);
DisplayMetrics displayMetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
CanvasWidth = displayMetrics.widthPixels;
CanvasHeight = displayMetrics.heightPixels;
// getWindow().setSoftInputMode(
// WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (bestProvider == null) {
bestProvider = locationManager.getBestProvider(getCriteria(), false);
if (bestProvider == null) {
bestProvider = LocationManager.NETWORK_PROVIDER;
}
}
location = locationManager.getLastKnownLocation(bestProvider);
}
@Override
protected void onResume() {
super.onResume();
if (AppContext.getContext() instanceof SplashActivity
|| AppContext.getContext() instanceof LoginPlatformActivity) {
return;
}
if (AppContext.getInstance().getLogin_uid() == 0
|| AppContext.getInstance().getLogin_token() == null) {
initConfig();
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
Intent intent;
if (AppContext.getContext() == null) {
intent = new Intent(this, HomeActivity.class);
}
else {
intent = new Intent(this, AppContext.getContext().getClass());
}
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
return super.onKeyUp(keyCode, event);
}
@Override
protected void onDestroy() {
if (toast != null) {
toast.cancel();
}
super.onDestroy();
}
protected boolean onBackClick() {
finish();
return false;
}
public View getLayoutView(int layout) {
return LayoutInflater.from(this).inflate(layout, null);
}
@Override
public void execute(int mes, Object obj) {
}
public void eventTask(int CommandID, String tips, Object obj) {
try {
CommandTaskEvent com = new CommandTaskEvent(this, this, tips);
com.execute((new Object[] { CommandID + "", obj }));
} catch (Exception e) {
e.printStackTrace();
}
}
public AlertDialog alert = null;
public boolean alertIsShow = false;
public void loading(String msg) {
try {
if (this.isFinishing()) {
return;
}
if (dialog == null || !dialog.isShowing()) {
View progressview = LayoutInflater.from(BasicActivity.this)
.inflate(R.layout.progress_dialog, null);
CustomDialog.Builder progressBuilder = new CustomDialog.Builder(
BasicActivity.this);
progressBuilder.setContentView(progressview);
dialog = progressBuilder.create();
dialog.show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void destroyDialog() {
basicHandler.sendEmptyMessage(DESTROYDIALOG);
}
public void onToast(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
/**
* 系统信息 必须在handler或者控件触发 调用才有效
*
* @param message
*/
@SuppressWarnings("deprecation")
public void setSysMes(String message) {
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
if (alert == null)
alert = new AlertDialog.Builder(this).create();
if (!alert.isShowing()) {
alertIsShow = true;
alert.setTitle(getString(R.string.system_info));
alert.setMessage(message);
alert.setButton(getString(R.string.confirm_ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
alertIsShow = false;
}
});
alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
alertIsShow = false;
}
});
alert.show();
}
}
/**
* 系统信息 必须在handler或者控件触发 调用才有效
*
* @param message
*/
@SuppressWarnings("deprecation")
public void setSysMes(String message, final int what) {
if (message == null || "出错了".equals(message)) {
return;
}
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
if (alert == null)
alert = new AlertDialog.Builder(this).create();
if (!alertIsShow) {
alertIsShow = true;
alert.setTitle(getString(R.string.system_info));
alert.setMessage(message);
alert.setButton(getString(R.string.confirm_ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
sysMesPositiveButtonEvent(what);
alertIsShow = false;
}
});
alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
alertIsShow = false;
}
});
alert.show();
}
}
/**
* dismiss alert 系统信息提示框
*/
public void cancelAlertDialog() {
if (alert != null && alert.isShowing()) {
Message localMessage = Message.obtain(basicHandler, cancelAlertDialog);
basicHandler.sendMessage(localMessage);
}
}
/**
* 系统信息选择提示 必须在handler或者控件触发 调用才有效
*
* @param message
* @param what
*/
public void showChoseMes(String message, final int what) {
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
Builder alert = new AlertDialog.Builder(this); // 为了避免 setSysMes(String
// message,final int
// what) 出现 “否”选择
if (!alertIsShow) {
alertIsShow = true;
alert.setTitle(getString(R.string.system_info));
alert.setMessage(message);
alert.setPositiveButton(getString(R.string.confirm_yes),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
sysMesPositiveButtonEvent(what);
alertIsShow = false;
}
});
alert.setNegativeButton(getString(R.string.confirm_no),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
sysMesNegativeButtonEvent(what);
alertIsShow = false;
}
});
alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
sysMesOnCancelEvent(what);
alertIsShow = false;
}
});
alert.show();
}
}
/**
* 系统信息提示ok按钮回调方法 是 showChoseMes(String message,final int
* what),setSysMes(String message,final int what)方法回调
*/
public void sysMesPositiveButtonEvent(int what) {
}
/**
* 系统信息提示no按钮回调方法 是 showChoseMes(String message,final int what)方法回调
*
* @param what
*/
public void sysMesNegativeButtonEvent(int what) {
}
/**
* 系统信息提示no按钮回调方法 是 showChoseMes(String message,final int what)方法回调
*
* @param what
*/
public void sysMesOnCancelEvent(int what) {
}
public void destroyDialogByFinish() {
Message localMessage = Message.obtain(basicHandler, destroyDialogByFinish);
basicHandler.sendMessage(localMessage);
}
public void finish() {
try {
if (dialog != null && dialog.isShowing()) {
destroyDialogByFinish();
} else {
super.finish();
}
// ActivityManager.removeActivity(this);
System.gc();
} catch (Exception e) {
e.printStackTrace();
}
}
public void finishAll() {
try {
if (dialog != null && dialog.isShowing()) {
destroyDialogByFinish();
} else {
super.finish();
}
System.gc();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 选择菜单 弹出框
* @param choices 显示的菜单
* @param chooseType 菜单的类型,为了区别其他菜单
*/
public void chooseAction(String[] choices, final int chooseType) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doSelectChooseEvent(which, chooseType);
}
});
builder.create().show();
}
public void doSelectChooseEvent(int which, int chooseType) {
}
public Handler basicHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case DESTROYDIALOG:
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
break;
case cancelAlertDialog:
if (alert != null && alert.isShowing()) {
alert.cancel();
}
break;
case destroyDialogByFinish:
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
BasicActivity.this.finish();
break;
case AppContext.GPS_LOCATE_TIMEOUT:
System.out.println(">>>>>>>>>>>>>>>>>>>>> GPS locate timeout .............");
networkLocat();
// locationManager.removeUpdates(locationListener);
break;
case AppContext.START_GPS_LOCATE:
if (!getGpsState(BasicActivity.this)) {
toggleGPS();
}
break;
case AppContext.GPS_LOCATE_SUCCESS:
locateSuccess();
break;
case AppContext.NETWORK_LOCATE_SUCCESS:
locateSuccess();
break;
default:
break;
}
}
};
public void locateSuccess() {
try {
if (mLocationClient != null) {
mLocationClient.stop();
} else {
toggleGPS();
locationManager.removeUpdates(locationListener);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean getGpsState(Context context) {
if (null == context)
return false;
LocationManager alm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
return alm.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
public void toggleGPS() {
Intent gpsIntent = new Intent();
gpsIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
gpsIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(this, 0, gpsIntent, 0).send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
public void initConfig() {
String country = getResources().getConfiguration().locale.getCountry();
if (country.equals("CN")) {
AppContext.setLanguage(1);
} else {
AppContext.setLanguage(0);
}
SharedPreferences preferences = getSharedPreferences("Preferences_userinfo", Activity.MODE_APPEND);
int login_uid = preferences.getInt("login_uid", 0);
String login_token = preferences.getString("login_token", null);
AppContext.getInstance().setLogin_uid(login_uid);
AppContext.getInstance().setLogin_token(login_token);
}
private Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
return criteria;
}
public LocationListener locationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onLocationChanged(Location location) {
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
AppContext.getInstance().setLatitude(latitude);
AppContext.getInstance().setLongitude(longitude);
basicHandler.sendEmptyMessage(AppContext.NETWORK_LOCATE_SUCCESS);
}
System.out.println("-----------------------------network locate: latitude:" + latitude + ";longitude:" + longitude);
}
};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == open_location_network) {
networkLocat();
}
}
@SuppressWarnings("deprecation")
public void networkLocat() {
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
countryIso = tm.getNetworkCountryIso();
System.out.println("---------------- Country ISO ----------->>>>>>>>>>>" + countryIso);
if (countryIso != null && countryIso.equalsIgnoreCase("cn")) {
mLocationClient = new LocationClient( this );
mLocationClient.registerLocationListener( myListener );
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
option.setAddrType("all");
option.setCoorType("bd09ll");
option.setScanSpan(0);
option.disableCache(true);//禁止启用缓存定位
option.setPriority(LocationClientOption.NetWorkFirst);
mLocationClient.setLocOption(option);
if (mLocationClient != null && mLocationClient.isStarted()) {
mLocationClient.requestLocation();
} else{
mLocationClient.start();
mLocationClient.requestLocation();
}
} else {
if (!locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
if (alert == null)
alert = new AlertDialog.Builder(this).create();
alert.setCancelable(false);
if (!alert.isShowing()) {
alertIsShow = true;
alert.setTitle(getString(R.string.system_info));
alert.setMessage(getString(R.string.locate_error_tips));
alert.setButton(getString(R.string.confirm_ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
alertIsShow = false;
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), open_location_network);
}
});
alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
alertIsShow = false;
}
});
alert.show();
}
} else {
locationManager.requestLocationUpdates(bestProvider, 1000, 2, locationListener);
}
}
}
public class MyLocationListenner implements BDLocationListener {
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return ;
StringBuffer sb = new StringBuffer(256);
sb.append("time : ");
sb.append(location.getTime());
sb.append("\nlatitude : ");
sb.append(location.getLatitude());
sb.append("\nlontitude : ");
sb.append(location.getLongitude());
if (location.getLocType() == BDLocation.TypeGpsLocation){
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation){
sb.append("\naddr : ");
sb.append(location.getAddrStr());
}
latitude = location.getLatitude();
longitude = location.getLongitude();
System.out.println(sb.toString());
AppContext.getInstance().setLatitude(latitude);
AppContext.getInstance().setLongitude(longitude);
basicHandler.sendEmptyMessage(AppContext.NETWORK_LOCATE_SUCCESS);
}
public void onReceivePoi(BDLocation poiLocation) {
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import java.util.List;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.BottleTypeTable;
import com.outsourcing.bottle.domain.BottleTagEntry;
import com.outsourcing.bottle.domain.BottleTagInfo;
import com.outsourcing.bottle.domain.BottleTypeEntry;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
/**
*
* @author 06peng
*
*/
public class ThrowBottleSettingActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private final int init_bottle_info = 1;
public static final int activity_for_result_choose_friend = 2;
public static final int activity_for_result_bottle_tag = 3;
int count = 0;
private int bttype_id;
private double bt_geo_lng;
private double bt_geo_lat;
private String reference;
private BottleTypeEntry entry;
private List<BottleTagEntry> tagEntrys;
private BottleTagAdapter adapter;
private Handler handler;
private ImageView bottleImageView;
private ImageView backView;
private ImageButton confirmView;
private TextView descriptionView;
private TextView tipsView;
private EditText tagView;
private ImageButton wrapView;
private ListView tagListView;
private LinearLayout samecityLayout;
private TextView samecityView;
private ImageView samecityImage;
private LinearLayout sameareaLayout;
private TextView sameareaView;
private ImageView sameareaImage;
private LinearLayout genderLayout;
private TextView genderView;
private ImageView genderImage;
private LinearLayout ageLayout;
private TextView ageView;
private ImageView ageImage;
private LinearLayout pickLayout;
private TextView pickView;
private ImageView pickImage;
private LinearLayout forwardLayout;
private TextView forwardView;
private ImageView forwarImage;
private LinearLayout feedLayout;
private TextView feedView;
private ImageView feedImage;
private LinearLayout commentLayout;
private TextView commentView;
private ImageView commentImage;
private LinearLayout showaddressLayout;
private TextView showaddressView;
private ImageView showAddressImage;
private String[] choicesAge;
private String[] choicesGenger;
private String[] choicesSamearea;
private String[] choiceSamecity;
private String[] choicesFeed;
private String[] choicesPick;
private String[] choicesReply;
private String[] choicesForward;
private String[] choicesAddress;
private ImageLoader btConfigLoader;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.throw_bottle_setting);
btConfigLoader = new ImageLoader(this, AppContext.BOTTLE_CONFIG);
initBottleLocation();
initWidget();
networkLocat();
UICore.eventTask(this, this, init_bottle_info, getString(R.string.init_data), null);
}
private void initWidget() {
tagListView = (ListView) findViewById(R.id.throw_setting_tips_list);
tagListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
BottleTagEntry tag = tagEntrys.get(arg2);
if (tag != null) {
tagView.setText(tag.getContent());
tagView.setTag(tag.getTagid());
}
}
});
tagView = (EditText) findViewById(R.id.throw_setting_tag_edit);
wrapView = (ImageButton) findViewById(R.id.throw_setting_wrap);
wrapView.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
bottleImageView = (ImageView) findViewById(R.id.throw_setting_bottle_image);
confirmView = (ImageButton) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
descriptionView = (TextView) findViewById(R.id.throw_setting_bottle_desctiption);
tipsView = (TextView) findViewById(R.id.throw_setting_bottle_tips);
samecityLayout = (LinearLayout) findViewById(R.id.throw_setting_samecity_layout);
samecityLayout.setOnClickListener(this);
samecityView = (TextView) findViewById(R.id.throw_setting_samecity_require);
sameareaLayout = (LinearLayout) findViewById(R.id.throw_setting_samearea_layout);
sameareaLayout.setOnClickListener(this);
sameareaView = (TextView) findViewById(R.id.throw_setting_samearea_require);
genderLayout = (LinearLayout) findViewById(R.id.throw_setting_gender_layout);
genderLayout.setOnClickListener(this);
genderView = (TextView) findViewById(R.id.throw_setting_gender_require);
ageLayout = (LinearLayout) findViewById(R.id.throw_setting_age_layout);
ageLayout.setOnClickListener(this);
ageView = (TextView) findViewById(R.id.throw_setting_age_require);
pickLayout = (LinearLayout) findViewById(R.id.throw_setting_pick_layout);
pickLayout.setOnClickListener(this);
pickView = (TextView) findViewById(R.id.throw_setting_pick_enable);
forwardLayout = (LinearLayout) findViewById(R.id.throw_setting_spread_layout);
forwardLayout.setOnClickListener(this);
forwardView = (TextView) findViewById(R.id.throw_setting_spread_enable);
feedLayout = (LinearLayout) findViewById(R.id.throw_setting_feed_layout);
feedLayout.setOnClickListener(this);
feedView = (TextView) findViewById(R.id.throw_setting_feed);
commentLayout = (LinearLayout) findViewById(R.id.throw_setting_comment_layout);
commentLayout.setOnClickListener(this);
commentView = (TextView) findViewById(R.id.throw_setting_comment);
samecityImage = (ImageView) findViewById(R.id.samecity_image);
sameareaImage = (ImageView) findViewById(R.id.samearea_image);
genderImage = (ImageView) findViewById(R.id.samesex_image);
ageImage = (ImageView) findViewById(R.id.sameage_image);
pickImage = (ImageView) findViewById(R.id.allowpick_image);
forwarImage = (ImageView) findViewById(R.id.allowspread_image);
feedImage = (ImageView) findViewById(R.id.allowfeed_image);
commentImage = (ImageView) findViewById(R.id.allowreplay_image);
showaddressLayout = (LinearLayout) findViewById(R.id.throw_setting_showaddress_layout);
showaddressLayout.setOnClickListener(this);
showaddressView = (TextView) findViewById(R.id.throw_setting_showaddress_require);
showAddressImage = (ImageView) findViewById(R.id.showaddress_image);
showAddressImage.setBackgroundResource(R.drawable.set_samecity);
showaddressView.setTag(1);
}
private void initBottleLocation() {
Intent intent = getIntent();
bttype_id = intent.getIntExtra("bttype_id", 0);
bt_geo_lng = intent.getDoubleExtra("bt_geo_lng", 0);
bt_geo_lat = intent.getDoubleExtra("bt_geo_lat", 0);
reference = intent.getStringExtra("reference");
}
@Override
public void onClick(View v) {
if (v == wrapView) {
if (tagListView.isShown()) {
tagListView.setVisibility(View.GONE);
wrapView.setBackgroundResource(R.drawable.unwrap);
} else {
tagListView.setVisibility(View.VISIBLE);
wrapView.setBackgroundResource(R.drawable.wrap);
}
} else if (v == backView) {
finish();
} else if (v == confirmView) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle bundle = new Bundle();
bundle.putString("from_type", AppContext.SEND_BT);
getSettingParams(bundle);
intent.putExtras(bundle);
startActivity(intent);
} else if (v == samecityLayout) {
doSettingAction(samecityView, choiceSamecity, getString(R.string.throw_bottle_setting_samecity_require));
} else if (v == sameareaLayout) {
doSettingAction(sameareaView, choicesSamearea, getString(R.string.throw_bottle_setting_samearea_require));
} else if (v == genderLayout) {
doSettingAction(genderView, choicesGenger, getString(R.string.throw_bottle_setting_gender_norequire));
} else if (v == ageLayout) {
doSettingAction(ageView, choicesAge, getString(R.string.throw_bottle_setting_age_require));
} else if (v == pickLayout) {
doSettingAction(pickView, choicesPick, getString(R.string.throw_bottle_setting_pickenable));
} else if (v == forwardLayout) {
doSettingAction(forwardView, choicesForward, getString(R.string.throw_bottle_setting_forwardenable));
} else if (v == feedLayout) {
doSettingAction(feedView, choicesFeed, getString(R.string.throw_bottle_setting_feed));
} else if (v == commentLayout) {
doSettingAction(commentView, choicesReply, getString(R.string.throw_bottle_setting_comment));
} else if (v == showaddressLayout) {
doSettingAction(showaddressView, choicesAddress, getString(R.string.throw_bottle_setting_showaddress_require));
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_bottle_info:
initBottleType();
handler.sendEmptyMessage(init_bottle_info);
break;
default:
break;
}
}
private void initBottleType() {
getTagsList();
BottleTypeTable typeTable = new BottleTypeTable();
entry = typeTable.getBottleType(bttype_id);
choicesAge = new String[] {getString(R.string.throw_bottle_setting_age_lower16),
getString(R.string.throw_bottle_setting_age_between16_22),
getString(R.string.throw_bottle_setting_age_between23_30),
getString(R.string.throw_bottle_setting_age_between31_40),
getString(R.string.throw_bottle_setting_age_than41),
getString(R.string.throw_bottle_setting_age_same), getString(R.string.throw_bottle_setting_age_norequire)};
choicesGenger = new String[] {getString(R.string.throw_bottle_setting_gerder_same),
getString(R.string.throw_bottle_setting_gerder_different), getString(R.string.throw_bottle_setting_gender_norequire)};
choiceSamecity = new String[] {getString(R.string.throw_bottle_setting_samecity_same),
getString(R.string.throw_bottle_setting_samecity_norequire)};
choicesSamearea = new String[] {getString(R.string.throw_bottle_setting_samearea_same),
getString(R.string.throw_bottle_setting_samearea_norequire)};
choicesPick = new String[] {getString(R.string.throw_bottle_setting_pick_enable),
getString(R.string.throw_bottle_setting_pick_disable)};
choicesForward = new String[] {getString(R.string.throw_bottle_setting_forward_enable),
getString(R.string.throw_bottle_setting_forward_disable)};
choicesFeed = new String[] {getString(R.string.throw_bottle_setting_feed_public),
getString(R.string.throw_bottle_setting_feed_private)};
choicesReply = new String[] {getString(R.string.throw_bottle_setting_comment_public),
getString(R.string.throw_bottle_setting_comment_private)};
choicesAddress = new String[] {getString(R.string.throw_bottle_setting_showaddress_show),
getString(R.string.throw_bottle_setting_showaddress_no)};
}
private void getTagsList() {
String url = UrlConfig.get_bttags;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("bttypeid", String.valueOf(bttype_id));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
Gson gson = new Gson();
BottleTagInfo info = gson.fromJson(result, BottleTagInfo.class);
tagEntrys = info.getBttags_list();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void updateUI() {
if (tagEntrys != null && !tagEntrys.isEmpty()) {
tagListView.setVisibility(View.VISIBLE);
adapter = new BottleTagAdapter();
tagListView.setAdapter(adapter);
Utility.setListViewHeightBasedOnChildren(tagListView);
for (BottleTagEntry tag : tagEntrys) {
if (tag.getIs_default() == 1) {
tagView.setText(tag.getContent());
tagView.setTag(tag.getTagid());
}
}
}
String tips = "<font color=red>"+getString(R.string.throw_bottle_setting_tips)+"</font>";
if (AppContext.language == 1) {
descriptionView.setText(Html.fromHtml("<font color=#419AD9>"+entry.getBttype_name_cn() + ":" +"</font>" + entry.getBttype_desc_cn()));
tipsView.setText(Html.fromHtml(tips + entry.getBttype_tips_cn()));
} else {
descriptionView.setText(Html.fromHtml("<font color=#419AD9>"+entry.getBttype_name_en() + ":"+"</font>" + entry.getBttype_desc_en()));
tipsView.setText(Html.fromHtml(tips + entry.getBttype_tips_en()));
}
btConfigLoader.DisplayImage(entry.getBttype_sjwicon(), bottleImageView, R.drawable.bottle_type_1);
if (entry.getBttype_pick_show() == 1) {
pickLayout.setVisibility(View.VISIBLE);
} else {
pickLayout.setVisibility(View.GONE);
}
if (entry.getBttype_spread_show() == 1) {
forwardLayout.setVisibility(View.VISIBLE);
} else {
forwardLayout.setVisibility(View.GONE);
}
if (entry.getBttype_samecity_show() == 1) {
samecityLayout.setVisibility(View.VISIBLE);
} else {
samecityLayout.setVisibility(View.GONE);
}
if (entry.getBttype_samearea_show() == 1) {
sameareaLayout.setVisibility(View.VISIBLE);
} else {
sameareaLayout.setVisibility(View.GONE);
}
if (entry.getBttype_needage_show() == 1) {
ageLayout.setVisibility(View.VISIBLE);
} else {
ageLayout.setVisibility(View.GONE);
}
if (entry.getBttype_needsex_show() == 1) {
genderLayout.setVisibility(View.VISIBLE);
} else {
genderLayout.setVisibility(View.GONE);
}
if (entry.getBttype_otheruserfeed_show() == 1) {
feedLayout.setVisibility(View.VISIBLE);
} else {
feedLayout.setVisibility(View.GONE);
}
if (entry.getBttype_otheruserreply_show() == 1) {
commentLayout.setVisibility(View.VISIBLE);
} else {
commentLayout.setVisibility(View.VISIBLE);
}
}
public class BottleTagAdapter extends BaseAdapter {
@Override
public int getCount() {
return tagEntrys == null ? 0: tagEntrys.size();
}
@Override
public Object getItem(int position) {
return tagEntrys == null ? null : tagEntrys.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.simple_listitem, null);
}
TextView nameView = (TextView) convertView.findViewById(R.id.simple_listitem_name);
BottleTagEntry entry = tagEntrys.get(position);
if (entry != null) {
nameView.setText(entry.getContent());
}
return convertView;
}
}
private void doSettingAction(final TextView textView, final String[] actions, String title) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, actions);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(title);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
int value = -1;
if (which == actions.length - 1) {
value = 0;
} else {
value = which + 1;
}
textView.setText(actions[which]);
textView.setTag(value);
changeSettingImageView(textView);
}
});
builder.setNegativeButton(cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
private void getSettingParams(Bundle bundle) {
if (entry.getBttype_allow_pick() == 1) {
if (pickView.getTag() != null) {
int value = Integer.parseInt(pickView.getTag().toString());
bundle.putInt("bt_allowpick", value);
}
} else {
bundle.putInt("bt_allowpick", -1);
}
if (entry.getBttype_allow_spread() == 1) {
if (forwardView.getTag() != null) {
int value = Integer.parseInt(forwardView.getTag().toString());
bundle.putInt("bt_allowspread", value);
}
} else {
bundle.putInt("bt_allowspread", -1);
}
if (entry.getBttype_samecity_show() == 1) {
if (samecityView.getTag() != null) {
int value = Integer.parseInt(samecityView.getTag().toString());
bundle.putInt("bt_samecity", value);
}
} else {
bundle.putInt("bt_samecity", -1);
}
if (entry.getBttype_samearea_show() == 1) {
if (sameareaView.getTag() != null) {
int value = Integer.parseInt(sameareaView.getTag().toString());
bundle.putInt("bt_samearea", value);
}
} else {
bundle.putInt("bt_samearea", -1);
}
if (entry.getBttype_needage_show() == 1) {
if (ageView.getTag() != null) {
int value = Integer.parseInt(ageView.getTag().toString());
bundle.putInt("bt_age", value);
}
} else {
bundle.putInt("bt_age", -1);
}
if (entry.getBttype_needsex_show() == 1) {
if (genderView.getTag() != null) {
int value = Integer.parseInt(genderView.getTag().toString());
bundle.putInt("bt_sex", value);
}
} else {
bundle.putInt("bt_sex", -1);
}
if (entry.getBttype_otheruserfeed_show() == 1) {
if (feedView.getTag() != null) {
int value = Integer.parseInt(feedView.getTag().toString());
bundle.putInt("bt_showfeed", value);
}
} else {
bundle.putInt("bt_showfeed", -1);
}
if (entry.getBttype_otheruserreply_show() == 1) {
if (commentView.getTag() != null) {
int value = Integer.parseInt(commentView.getTag().toString());
bundle.putInt("bt_showreply", value);
}
} else {
bundle.putInt("bt_showreply", -1);
}
bundle.putString("bt_tagid", tagView.getTag().toString());
bundle.putString("bt_geo_reference", reference);
String showaddress = "0";
if (showaddressView.getTag() != null) {
showaddress = showaddressView.getTag().toString();
}
bundle.putString("bt_tag", tagView.getText().toString());
bundle.putString("bt_showaddress", showaddress);
bundle.putDouble("bt_geo_lat", bt_geo_lat);
bundle.putDouble("bt_geo_lng", bt_geo_lng);
bundle.putInt("bttype_id", bttype_id);
}
private void initSetting() {
ageView.setText(choicesAge[entry.getBttype_needage() == 0 ? choicesAge.length - 1 : entry.getBttype_needage() - 1]);
ageView.setTag(entry.getBttype_needage());
genderView.setText(choicesGenger[entry.getBttype_needsex() == 0 ? choicesGenger.length - 1 : entry.getBttype_needsex() - 1]);
genderView.setTag(entry.getBttype_needsex());
commentView.setText(choicesReply[entry.getBttype_otheruserreply() == 0 ? choicesReply.length - 1 : entry.getBttype_otheruserreply() - 1]);
commentView.setTag(entry.getBttype_otheruserreply());
feedView.setText(choicesFeed[entry.getBttype_otheruserfeed() == 0 ? choicesFeed.length - 1 : entry.getBttype_otheruserfeed() - 1]);
feedView.setTag(entry.getBttype_otheruserfeed());
forwardView.setText(choicesForward[entry.getBttype_allow_spread() == 0 ? choicesForward.length - 1 : entry.getBttype_allow_spread() - 1]);
forwardView.setTag(entry.getBttype_allow_spread());
pickView.setText(choicesPick[entry.getBttype_allow_pick() == 0 ? choicesPick.length - 1 : entry.getBttype_allow_pick() - 1]);
pickView.setTag(entry.getBttype_allow_pick());
sameareaView.setText(choicesSamearea[entry.getBttype_samearea() == 0 ? choicesSamearea.length - 1 : entry.getBttype_samearea() - 1]);
sameareaView.setTag(entry.getBttype_samearea());
samecityView.setText(choiceSamecity[entry.getBttype_samecity() == 0 ? choiceSamecity.length - 1: entry.getBttype_samecity() - 1]);
samecityView.setTag(entry.getBttype_samecity());
if (entry.getBttype_needage() == 0) {
ageImage.setBackgroundResource(R.drawable.set_sameage_gray);
} else {
ageImage.setBackgroundResource(R.drawable.set_sameage);
}
if (entry.getBttype_needsex() == 0) {
genderImage.setBackgroundResource(R.drawable.set_samesex_gray);
} else {
genderImage.setBackgroundResource(R.drawable.set_samesex);
}
if (entry.getBttype_otheruserreply() == 0) {
commentImage.setBackgroundResource(R.drawable.set_allowreply_gray);
} else {
commentImage.setBackgroundResource(R.drawable.set_allowreply);
}
if (entry.getBttype_otheruserfeed() == 0) {
feedImage.setBackgroundResource(R.drawable.set_allowfeed_gray);
} else {
feedImage.setBackgroundResource(R.drawable.set_allowfeed);
}
if (entry.getBttype_allow_spread() == 0) {
forwarImage.setBackgroundResource(R.drawable.set_allowspread_gray);
} else {
forwarImage.setBackgroundResource(R.drawable.set_allowspread);
}
if (entry.getBttype_allow_pick() == 0) {
pickImage.setBackgroundResource(R.drawable.set_allowpick_gray);
} else {
pickImage.setBackgroundResource(R.drawable.set_allowpick);
}
if (entry.getBttype_samearea() == 0) {
sameareaImage.setBackgroundResource(R.drawable.set_samearea_gray);
} else {
sameareaImage.setBackgroundResource(R.drawable.set_samearea);
}
if (entry.getBttype_samecity() == 0) {
samecityImage.setBackgroundResource(R.drawable.set_samecity_gray);
} else {
samecityImage.setBackgroundResource(R.drawable.set_samecity);
}
}
private void changeSettingImageView(TextView view) {
if (view == ageView) {
if (ageView.getTag() != null) {
int value = Integer.parseInt(ageView.getTag().toString());
if (value == 0) {
ageImage.setBackgroundResource(R.drawable.set_sameage_gray);
} else {
ageImage.setBackgroundResource(R.drawable.set_sameage);
}
}
} else if (view == genderView) {
if (entry.getBttype_needsex_show() == 1) {
if (genderView.getTag() != null) {
int value = Integer.parseInt(genderView.getTag().toString());
if (value == 0) {
genderImage.setBackgroundResource(R.drawable.set_samesex_gray);
} else {
genderImage.setBackgroundResource(R.drawable.set_samesex);
}
}
}
} else if (view == commentView) {
if (commentView.getTag() != null) {
int value = Integer.parseInt(commentView.getTag().toString());
if (value == 0) {
commentImage.setBackgroundResource(R.drawable.set_allowreply_gray);
} else {
commentImage.setBackgroundResource(R.drawable.set_allowreply);
}
}
} else if (view == feedView) {
if (feedView.getTag() != null) {
int value = Integer.parseInt(feedView.getTag().toString());
if (value == 0) {
feedImage.setBackgroundResource(R.drawable.set_allowfeed_gray);
} else {
feedImage.setBackgroundResource(R.drawable.set_allowfeed);
}
}
} else if (view == forwardView) {
if (forwardView.getTag() != null) {
int value = Integer.parseInt(forwardView.getTag().toString());
if (value == 0) {
forwarImage.setBackgroundResource(R.drawable.set_allowspread_gray);
} else {
forwarImage.setBackgroundResource(R.drawable.set_allowspread);
}
}
} else if (view == pickView) {
if (pickView.getTag() != null) {
int value = Integer.parseInt(pickView.getTag().toString());
if (value == 0) {
pickImage.setBackgroundResource(R.drawable.set_allowpick_gray);
} else {
pickImage.setBackgroundResource(R.drawable.set_allowpick);
}
}
} else if (view == sameareaView) {
if (sameareaView.getTag() != null) {
int value = Integer.parseInt(sameareaView.getTag().toString());
if (value == 0) {
sameareaImage.setBackgroundResource(R.drawable.set_samearea_gray);
} else {
sameareaImage.setBackgroundResource(R.drawable.set_samearea);
}
}
} else if (view == samecityView) {
if (samecityView.getTag() != null) {
int value = Integer.parseInt(samecityView.getTag().toString());
if (value == 0) {
samecityImage.setBackgroundResource(R.drawable.set_samecity_gray);
} else {
samecityImage.setBackgroundResource(R.drawable.set_samecity);
}
}
} else if (view == showaddressView) {
if (showaddressView.getTag() != null) {
int value = Integer.parseInt(showaddressView.getTag().toString());
if (value == 0) {
showAddressImage.setBackgroundResource(R.drawable.set_samecity_gray);
} else {
showAddressImage.setBackgroundResource(R.drawable.set_samecity);
}
}
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_bottle_info:
updateUI();
initSetting();
break;
default:
break;
}
return false;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SearchSchoolActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private EditText editSearchView;
private EditText editAddView;
private ImageView searchView;
private ImageView addView;
private ListView listView;
private RelativeLayout searchLayout;
private final int search_school = 1;
private final int error = 2;
private final int add_school = 3;
private Handler handler;
private List<String> schoolList;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.search_school);
handler = new Handler(this);
initWidget();
}
private void initWidget() {
editSearchView = (EditText) findViewById(R.id.search_school_edit);
editSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
if (editSearchView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return true;
}
UICore.eventTask(SearchSchoolActivity.this, SearchSchoolActivity.this, search_school, "search_school", editSearchView.getText().toString().trim());
}
return false;
}
});
editAddView = (EditText) findViewById(R.id.setting_school_add_edit);
editAddView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
if (editAddView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return true;
}
UICore.eventTask(SearchSchoolActivity.this, SearchSchoolActivity.this, add_school, "add_school", editAddView.getText().toString().trim());
}
return false;
}
});
searchView = (ImageView) findViewById(R.id.search_school_go);
searchView.setOnClickListener(this);
addView = (ImageView) findViewById(R.id.setting_school_add_iamge);
addView.setOnClickListener(this);
listView = (ListView) findViewById(R.id.search_school_list);
searchLayout = (RelativeLayout) findViewById(R.id.search_school_layout);
if (AppContext.language == 1) {
searchLayout.setVisibility(View.VISIBLE);
} else {
searchLayout.setVisibility(View.GONE);
listView.setVisibility(View.GONE);
}
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
String school = schoolList.get(arg2);
UICore.eventTask(SearchSchoolActivity.this, SearchSchoolActivity.this, add_school, "add_school", school);
}
});
}
public void back(View v) {
finish();
}
@Override
public void onClick(View v) {
if (v == searchView) {
if (editSearchView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return;
}
UICore.eventTask(this, this, search_school, "search_school", editSearchView.getText().toString().trim());
} else if (v == addView) {
if (editAddView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return;
}
UICore.eventTask(this, this, add_school, "add_school", editAddView.getText().toString().trim());
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case search_school:
if (schoolList!=null&&schoolList.size()>0) {
listView.setVisibility(View.VISIBLE);
SchoolAdapter adapter = new SchoolAdapter();
listView.setAdapter(adapter);
}
break;
case error:
onToast((String) msg.obj);
SearchSchoolActivity.this.finish();
break;
case add_school:
onToast((String) msg.obj);
Intent intent = new Intent(SearchSchoolActivity.this, SettingEducationActivity.class);
setResult(0,intent);
SearchSchoolActivity.this.finish();
break;
default:
break;
}
return false;
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case search_school:
searchSchool();
break;
case add_school:
addSchool((String) obj);
break;
default:
break;
}
}
private void searchSchool() {
String url = UrlConfig.search_school;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("keyword", editSearchView.getText().toString().trim());
paramsMap.put("page", "1");
paramsMap.put("count", "20");
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
if (resultObj.getInt("authok") == 0) {
Message msg = Message.obtain(handler, error, resultObj.getString("errmsg"));
handler.sendMessage(msg);
} else {
JSONArray array = object.getJSONArray("schools_list");
schoolList = new ArrayList<String>();
for (int i = 0;i < array.length();i++) {
JSONObject school = array.getJSONObject(i);
schoolList.add(school.getString("school"));
}
handler.sendEmptyMessage(search_school);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void addSchool(String school) {
String url = UrlConfig.add_school_info;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("school", school);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
if (resultObj.getInt("success") == 0) {
Message msg = Message.obtain(handler, error, resultObj.getString("errmsg"));
handler.sendMessage(msg);
} else {
getLoginUserInfo();
Message msg = Message.obtain(handler, error, resultObj.getString("successmsg"));
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
if (loginUserInfo.getResults().getAuthok() == 1) {
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class SchoolAdapter extends BaseAdapter {
@Override
public int getCount() {
return schoolList.size();
}
@Override
public Object getItem(int position) {
return schoolList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.setting_listitem, null);
}
TextView school = (TextView) convertView.findViewById(R.id.setting_listitem_name);
ImageView add = (ImageView) convertView.findViewById(R.id.setting_listitem_image);
add.setVisibility(View.GONE);
String str = schoolList.get(position);
if (str != null) {
school.setText(str);
}
return convertView;
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SettingPasswordActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private ImageView backView;
private ImageView confirmView;
private EditText oldView;
private EditText newView;
private EditText againView;
private Handler handler;
private final int set_password = 1;
private final int error = 2;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.setting_password);
handler = new Handler(this);
initWidget();
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
confirmView = (ImageView) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
oldView = (EditText) findViewById(R.id.setting_password_old);
newView = (EditText) findViewById(R.id.setting_password_new);
againView = (EditText) findViewById(R.id.setting_password_again);
againView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
if (oldView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_old_tips));
return true;
} else if (newView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_new_tips));
return true;
} else if (newView.getText().toString().trim().length() < 6) {
onToast(getString(R.string.setting_password_new_length_tips));
return true;
} else if (againView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_new_again_tips));
return true;
} else if (!newView.getText().toString().trim().equals(againView.getText().toString().trim())) {
onToast(getString(R.string.setting_password_new_again_error));
return true;
}
UICore.eventTask(SettingPasswordActivity.this, SettingPasswordActivity.this, set_password, "set_password", null);
}
return false;
}
});
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == confirmView) {
if (oldView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_old_tips));
return;
} else if (newView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_new_tips));
return;
} else if (newView.getText().toString().trim().length() < 6) {
onToast(getString(R.string.setting_password_new_length_tips));
return;
} else if (againView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_password_new_again_tips));
return;
} else if (!newView.getText().toString().trim().equals(againView.getText().toString().trim())) {
onToast(getString(R.string.setting_password_new_again_error));
return;
}
UICore.eventTask(this, this, set_password, "set_password", null);
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case error:
onToast((String) msg.obj);
break;
case set_password:
onToast((String) msg.obj);
finish();
break;
default:
break;
}
return false;
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case set_password:
setPassword();
break;
default:
break;
}
}
private void setPassword() {
String url = UrlConfig.set_password_info;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("oldpassword", oldView.getText().toString().trim());
paramsMap.put("newpassword", newView.getText().toString().trim());
paramsMap.put("repassword", againView.getText().toString().trim());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_password, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.outsourcing.bottle.R;
/**
*
* @author 06peng
*
*/
public final class LogoFragment extends Fragment {
int currentItem;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.logo_fragment, null);
ImageView logo = (ImageView) view.findViewById(R.id.logo);
Bundle bundle = getArguments();
if (bundle != null) {
currentItem = bundle.getInt("logo");
switch (currentItem) {
case 0:
logo.setImageResource(R.drawable.logo_new);
break;
case 1:
logo.setImageResource(R.drawable.splash_slide_1);
break;
case 2:
logo.setImageResource(R.drawable.splash_slide_2);
break;
case 3:
logo.setImageResource(R.drawable.splash_slide_3);
break;
case 4:
logo.setImageResource(R.drawable.splash_slide_4);
break;
default:
logo.setImageResource(R.drawable.logo_new);
break;
}
}
return view;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
* 瓶友等级
* @author 06peng
*
*/
public class BtFriendLevelActivity extends BasicActivity implements Callback, BasicUIEvent, OnClickListener {
private final int get_bt_friend_level_info = 1;
private final int upgrade_bt_friend_level = 2;
private final int error = 3;
private ImageView backView;
private ImageView homeView;
private Button upgradeBtn;
private WebView webView;
private TextView creditView;
private TextView ttCreditView;
private TextView levelView;
private Handler handler;
private int credit;
private int exp;
private int level;
private int ttcredit;
private int ttexp;
private String level_url;
private int show_upgrade;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.bt_friend_level);
initWidget();
UICore.eventTask(this, this, get_bt_friend_level_info, "", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
homeView = (ImageView) findViewById(R.id.topbar_home);
homeView.setOnClickListener(this);
upgradeBtn = (Button) findViewById(R.id.bt_friend_upgrade);
upgradeBtn.setOnClickListener(this);
webView = (WebView) findViewById(R.id.webView);
creditView = (TextView) findViewById(R.id.bt_friend_level_credit_and_experience_value);
ttCreditView = (TextView) findViewById(R.id.bt_friend_level_ttcredit_and_ttexperience_value);
levelView = (TextView) findViewById(R.id.bt_friend_level_value);
}
private void updateUI() {
try {
creditView.setText(credit + "/" + exp);
ttCreditView.setText(ttcredit + "/" + ttexp);
levelView.setText(level + "");
webView.loadUrl(level_url);
if (show_upgrade == 1) {
upgradeBtn.setVisibility(View.VISIBLE);
} else {
upgradeBtn.setVisibility(View.GONE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case get_bt_friend_level_info:
getBtLevelInfo();
handler.sendEmptyMessage(get_bt_friend_level_info);
break;
case upgrade_bt_friend_level:
upgradeUserLevel();
break;
default:
break;
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case get_bt_friend_level_info:
updateUI();
break;
case upgrade_bt_friend_level:
onToast(msg.obj.toString());
break;
case error:
onToast(msg.obj.toString());
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == homeView) {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
} else if (v == upgradeBtn) {
UICore.eventTask(this, this, upgrade_bt_friend_level, "", null);
}
}
private void getBtLevelInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_user_btlevel);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("user_btlevel");
credit = resultobj.getInt("credit");
exp = resultobj.getInt("exp");
level = resultobj.getInt("level");
level_url = resultobj.getString("level_url");
show_upgrade = resultobj.getInt("show_upgrade");
ttcredit = resultobj.getInt("ttcredit");
ttexp = resultobj.getInt("ttexp");
} catch (Exception e) {
e.printStackTrace();
}
}
private void upgradeUserLevel() {
String url = UrlConfig.btlevel_upgrade;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, upgrade_bt_friend_level, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.ExFeedEntry;
import com.outsourcing.bottle.domain.ExFeedPicEntry;
import com.outsourcing.bottle.domain.ExPicFeedEntry;
import com.outsourcing.bottle.domain.ExPicOuidInfoEntry;
import com.outsourcing.bottle.domain.ExPicSessionEntry;
import com.outsourcing.bottle.domain.ExchangePicInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.ui.fragment.ExchangeFragment;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.CustomPopupWindow;
import com.outsourcing.bottle.widget.TryRefreshableView;
public class ExchangePicDetailActivity extends BasicActivity implements
BasicUIEvent, Callback, OnClickListener {
private static final int EXEU_EXCHANGE_PIC_INFO = 0;
private static final int EXEU_EXCHANGE_PIC_INFO_FAILED = 1;
private static final int EXEU_INVISIBLE_PICEX_SUCCESS = 2;
private static final int EXEU_INVISIBLE_PICEX_FAILED = 3;
private static final int EXEU_REJECT_PICEX_SUCCESS = 4;
private static final int EXEU_REJECT_PICEX_FAILED = 5;
private static final int EXEU_VISIBLE_PICEX_SUCCESS = 6;
private static final int EXEU_VISIBLE_PICEX_FAILED = 7;
private static final int EXEU_REFRESH_PIC_INFO = 8;
private static final int EXEU_UNLIKE_OPERATION = 9;
private static final int EXEU_LIKE_OPERATION = 10;
private static final int EXEU_LIKE_OP_PICEX_SUCCESS = 11;
private static final int EXEU_LIKE_OP_PICEX_FAILED = 12;
private static final int EXEU_GET_MORE_PIC_INFO = 13;
private static final int INIT_HAS_EXS_ERROR = 14;
private static final int EXEU_GOTO_PROFILE = 15;
private static final int INIT_HAS_EXS_PROFILE = 16;
private static final int EXEU_GOTO_EXCHANGE = 17;
private static final int EXEU_DELETE_LOCATION_PIC_FEED = 18;
private static final int EXEU_DELETE_LOCATION_PIC_FEED_SUCCESS = 19;
private static final int EXEU_DELETE_LOCATION_FAILED = 20;
private static final int EXEU_DELETE_LOCATION_FEED = 21;
private static final int EXEU_SET_BTPIC_PAINT = 22;
private final int menu_uploadphoto = 105;
private final int menu_exprofile = 104;
private final int menu_exphoto = 103;
private final int menu_gainbt = 102;
private final int menu_sendbt = 101;
private final int user_baseinfo_notfull = 100;
private final int complete_info = 1;
private Handler handler;
private ImageView topbar_back;
private ImageView topbar_menu;
private View mLikeView;
private CustomPopupWindow mLikePopview;
private int page = 1, ouid;
private ExchangePicInfo mExPicInfo = null;
private ImageLoader imageLoader = null;
public int exsid;
private TryRefreshableView rv;
private LinearLayout ll_content;
private ScrollView sv;
private LinearLayout feed_comment;// 会话回复
// private ImageView messageView;
private LinearLayout bottomLayout;
private RemoteImageView avatarView;
private TextView contentView;
private TextView btnCount;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
private PushBroadcastReceiver receiver;
private PushNoticeInfo pushInfo;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.exchange_pic_root);
handler = new Handler(this);
page = getIntent().getIntExtra("page", 1);
ouid = getIntent().getIntExtra("ouid", 0);
imageLoader = new ImageLoader(this, AppContext.BottleTimelineIcon);
initLayout();
initLikePopupWindow();
initSateMenu();
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
}
private void initLayout() {
topbar_back = (ImageView) findViewById(R.id.topbar_back);
topbar_back.setOnClickListener(this);
topbar_menu = (ImageView) findViewById(R.id.topbar_menu);
topbar_menu.setVisibility(View.VISIBLE);
topbar_menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ExchangePicDetailActivity.this, HomeActivity.class);
intent.putExtra("currentItem", 0);
startActivity(intent);
finish();
}
});
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
avatarView = (RemoteImageView) findViewById(R.id.notice_avatar);
contentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
// messageView.setVisibility(View.VISIBLE);
// refresh_view = (ElasticScrollView) findViewById(R.id.refresh_view);
// refresh_view
// .setonRefreshListener(new ElasticScrollView.OnRefreshListener() {
//
//
// @Override
// public void onRefresh() {
// // new NewDataTask().execute();
// page = 1;
// UICore.eventTask(ExchangePicDetailActivity.this,
// ExchangePicDetailActivity.this, EXEU_REFRESH_PIC_INFO, null, null);
// }
// });
sv = (ScrollView) findViewById(R.id.trymySv);
rv = (TryRefreshableView) findViewById(R.id.trymyRV);
rv.mfooterView = (View) findViewById(R.id.tryrefresh_footer);
rv.sv = sv;
ll_content = (LinearLayout) findViewById(R.id.ll_content);
// 隐藏mfooterView
rv.mfooterViewText = (TextView) findViewById(R.id.tryrefresh_footer_text);
rv.mfooterViewText.setVisibility(View.INVISIBLE);
// 监听是否加载刷新
rv.setRefreshListener(new TryRefreshableView.RefreshListener() {
@Override
public void onRefresh() {
if (rv.mRefreshState == 4) {
page = 1;
UICore.eventTask(ExchangePicDetailActivity.this,
ExchangePicDetailActivity.this,
EXEU_REFRESH_PIC_INFO, null, null);
} else if (rv.mfooterRefreshState == 4) {
page++;
UICore.eventTask(ExchangePicDetailActivity.this,
ExchangePicDetailActivity.this,
EXEU_GET_MORE_PIC_INFO, null, null);
}
}
});
}
private void initSateMenu() {
SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu);
menu.setVisibility(View.VISIBLE);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile,
R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: // 扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(
ExchangePicDetailActivity.this,
ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: // 捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(
ExchangePicDetailActivity.this,
ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: // 交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(
ExchangePicDetailActivity.this,
ChooseFriendActivity.class);
exchangeInfoIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: // 交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable
.getLoginUserInfo(AppContext
.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(
ExchangePicDetailActivity.this,
ChooseFriendActivity.class);
exchangeFileIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
View view = null;
private int picid;
private void setViewValue() {
view = LayoutInflater.from(this).inflate(R.layout.exchange_pic_content, null);
RemoteImageView iv_ovatar = (RemoteImageView) view.findViewById(R.id.iv_author_photo);
TextView tv_onickname = (TextView) view.findViewById(R.id.tv_onickname);
ImageView bt_sex = (ImageView)view.findViewById(R.id.bt_sex);
TextView tv_oDoing = (TextView) view.findViewById(R.id.tv_odoing);
TextView tv_oLocation = (TextView) view.findViewById(R.id.tv_olocation);
Button bt_profile = (Button) view.findViewById(R.id.bt_profile);
Button bt_album = (Button) view.findViewById(R.id.bt_ex_photo);
Button bt_ExProfile = (Button) view.findViewById(R.id.bt_ex_profile);
bt_ExProfile.setText(TextUtil.R("exchange_bt_ex_profile"));
RemoteImageView iv_ovatar_2 = (RemoteImageView) view
.findViewById(R.id.iv_ex_pic_ovatar_2);
ImageView iv_ex_type = (ImageView) view.findViewById(R.id.iv_ex_type);
TextView tv_ex_feed = (TextView) view.findViewById(R.id.tv_ex_feed);
TextView tv_feed_time = (TextView) view.findViewById(R.id.tv_feed_time);
TextView tv_feed_num = (TextView) view
.findViewById(R.id.comments_ellipsis_text);
RemoteImageView iv_ovatar_right = (RemoteImageView) view
.findViewById(R.id.iv_ex_pic_ovatar_3);
Button bt_ex_comment = (Button) view
.findViewById(R.id.bt_exchange_comment);
Button bt_ex_reject = (Button) view
.findViewById(R.id.bt_exchange_reject);
Button bt_ex_visible = (Button) view
.findViewById(R.id.bt_exchange_visible);
Button bt_ex_invisible = (Button) view
.findViewById(R.id.bt_exchange_invisible);
View line_comments_ellipsis = (View) view
.findViewById(R.id.line_comments_ellipsis);
View line_exchange_comment = (View) view
.findViewById(R.id.line_exchange_comment);
RelativeLayout feed_comments_more = (RelativeLayout) view
.findViewById(R.id.feed_comments_more);
feed_comment = (LinearLayout) view
.findViewById(R.id.ll_feed_comment_layout);
final ExPicOuidInfoEntry exPicOuidEntry = mExPicInfo.getOuid_info();
iv_ovatar.setDefaultImage(R.drawable.avatar_default_small);
iv_ovatar.setImageUrl(exPicOuidEntry.getOavatar());
iv_ovatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", ouid);
startActivity(spaceIntent);
}
});
String onickname = null;
if (ouid!= AppContext.getInstance()
.getLogin_uid()) {
onickname ="<font color='#DA4A37'>"
+ exPicOuidEntry.getOnickname() + "</font>";
} else {
onickname = "<font color='#3F99D8'>"
+ exPicOuidEntry.getOnickname() + "</font>";
}
// String sex = exPicOuidEntry.getOsex() == 1 ? ("("
// + TextUtil.R("login_txt_register_male") + ")") : ("("
// + TextUtil.R("login_txt_register_female") + ")");
tv_onickname.setText(Html.fromHtml(onickname));
int sex_res = exPicOuidEntry.getOsex() == 1 ? R.drawable.male:R.drawable.female;
bt_sex.setBackgroundResource(sex_res);
if (null != exPicOuidEntry.getOdoing()
&& exPicOuidEntry.getOdoing().length() > 0) {
tv_oDoing.setVisibility(View.VISIBLE);
String commentMood = TextUtil.R("ex_comment_mood");
tv_oDoing.setText(commentMood+ TextUtil.htmlEncode(exPicOuidEntry.getOdoing()));
} else {
tv_oDoing.setVisibility(View.GONE);
}
if ((null != exPicOuidEntry.getOcountry() && exPicOuidEntry
.getOcountry().length() > 0)
|| (null != exPicOuidEntry.getOcity() && exPicOuidEntry
.getOcity().length() > 0)) {
tv_oLocation.setVisibility(View.VISIBLE);
tv_oLocation.setText(exPicOuidEntry.getOcountry()
+ exPicOuidEntry.getOcity());
} else {
tv_oLocation.setVisibility(View.GONE);
}
bt_profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
}
});
bt_ExProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
doExchange(ouid);
}
}
});
if (exPicOuidEntry.getOalbum_visible() == 1) {
bt_album.setBackgroundResource(R.drawable.btn_blue_try);
bt_album.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ExchangePicDetailActivity.this,
AlbumsActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
}
});
} else {
bt_album.setBackgroundResource(R.drawable.btn_gray_try);
bt_album.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ExchangePicDetailActivity.this.onToast(TextUtil
.R("exchange_feed_invisible_tips"));
}
});
}
final ExPicSessionEntry exSessionEntry = mExPicInfo.getExs_info();
iv_ovatar_2.setDefaultImage(R.drawable.avatar_default_small);
iv_ovatar_2.setImageUrl(exSessionEntry.getExs_avatar());
iv_ovatar_right.setDefaultImage(R.drawable.avatar_default_small);
iv_ovatar_right.setImageUrl(exSessionEntry.getExs_oavatar());
iv_ovatar_2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", exSessionEntry.getExs_uid());
startActivity(spaceIntent);
}
});
iv_ovatar_right.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", exSessionEntry.getExs_ouid());
startActivity(spaceIntent);
}
});
iv_ex_type.setImageResource(R.drawable.btn_exphoto);
String mSuccess = (exSessionEntry.getExs_success() == 1) ? ("<font color='#FF3333'>"
+ TextUtil.R("exchange_success") + "</font>")
: ("<font color='#DA4A37'>" + TextUtil.R("exchange_failed") + "</font>");
String nickName = null;
if (ouid!= AppContext.getInstance().getLogin_uid()) {
nickName ="<font color='#DA4A37'>"
+ exSessionEntry.getExs_nickname() + "</font>";
} else {
nickName = "<font color='#3F99D8'>"
+ exSessionEntry.getExs_nickname() + "</font>";
}
tv_ex_feed.setText(Html.fromHtml(nickName
+ exSessionEntry.getExs_firstfeed() + " " + mSuccess));
if (null != tv_feed_time && tv_feed_time.length() > 0) {
tv_feed_time.setVisibility(View.VISIBLE);
String time = "<font color='#000000'>" + " #"
+ exSessionEntry.getExs_firstfeedtime() + "</font>";
tv_feed_time.setText(Html.fromHtml(time));
} else {
tv_feed_time.setVisibility(View.GONE);
}
bt_ex_comment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent commentIntent = new Intent(
ExchangePicDetailActivity.this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLY_PICEX);
commentBundle.putString("reply_picex_type", "reply");
commentBundle.putInt("ouid", ouid);
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent, 0);
}
});
if (exSessionEntry.getExs_picex_rejectshow() == 1) {
bt_ex_reject.setVisibility(View.VISIBLE);
bt_ex_reject.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doRejectPicex(ouid, exSessionEntry.getExsid());
}
});
} else {
bt_ex_reject.setVisibility(View.GONE);
}
if (exSessionEntry.getExs_picex_visibleshow() == 1) {
bt_ex_visible.setVisibility(View.VISIBLE);
bt_ex_visible.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doVisiblePicex(ouid, exSessionEntry.getExsid());
}
});
} else {
bt_ex_visible.setVisibility(View.GONE);
}
if (exSessionEntry.getExs_picex_invisibleshow() == 1) {
bt_ex_invisible.setVisibility(View.VISIBLE);
bt_ex_invisible.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doInvisiblePicex(ouid, exSessionEntry.getExsid());
}
});
} else {
bt_ex_invisible.setVisibility(View.GONE);
}
/******************************* 留言分割线 ***********************************/
List<ExFeedPicEntry> mExFeedPicEntries = mExPicInfo.getExfeeds_list();
if (null != mExFeedPicEntries && mExFeedPicEntries.size() > 0) {
line_exchange_comment.setVisibility(View.VISIBLE);
line_comments_ellipsis.setVisibility(View.VISIBLE);
feed_comments_more.setVisibility(View.VISIBLE);
tv_feed_num.setText(mExPicInfo.getRscount()+" "
+ TextUtil.R("bottle_txt_comment_more"));
for (int i = 0; i < mExFeedPicEntries.size(); i++) {
final ExFeedPicEntry mExFeedPicEntry = mExFeedPicEntries.get(i);
View feed_child = LayoutInflater.from(this).inflate(
R.layout.exchange_comments_item, null);
if (i == (mExFeedPicEntries.size()-1)) {
View feed_avatar = (View) feed_child
.findViewById(R.id.line_exchange_feed);
feed_avatar.setVisibility(View.INVISIBLE);
}
TextView mFeedAvatar = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_nickname);
String feed_nickname = null;
if (mExFeedPicEntry.getExfeed_uid()!= AppContext.getInstance()
.getLogin_uid()) {
feed_nickname = (!TextUtils.isEmpty(mExFeedPicEntry.getExfeed_nickname())) ? ("<font color='#DA4A37'>"
+ mExFeedPicEntry.getExfeed_nickname()+ "</font>")
: "";
} else {
feed_nickname = (!TextUtils.isEmpty(mExFeedPicEntry.getExfeed_nickname())) ? ("<font color='#3F99D8'>"
+ mExFeedPicEntry.getExfeed_nickname() + "</font>")
: "";
}
mFeedAvatar.setText(Html.fromHtml(feed_nickname + " "
+ mExFeedPicEntry.getExfeed_content()));
TextView mFeedComment = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_content);
if (null != mExFeedPicEntry.getExfeed_comment()
&& mExFeedPicEntry.getExfeed_comment().length() > 0) {
String feed_content = mExFeedPicEntry.getExfeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(mExFeedPicEntry.getExfeed_comment()) + "</font>")
: TextUtil.htmlEncode(mExFeedPicEntry.getExfeed_comment());
mFeedComment.setVisibility(View.VISIBLE);
String commentTips = "<font color='#000000'>"
+ TextUtil.R("exchange_feed_comment_title")
+ "</font>";
mFeedComment.setText(Html.fromHtml(commentTips
+ feed_content));
} else {
mFeedComment.setVisibility(View.GONE);
}
TextView mFeedTime = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_time);
String commentTime = TextUtils.isEmpty(mExFeedPicEntry.getExfeed_time()) ? "" : ("#" + mExFeedPicEntry.getExfeed_time());
String commentLocation = TextUtils.isEmpty(mExFeedPicEntry.getExfeed_location()) ? "" : ("@" + mExFeedPicEntry.getExfeed_location());
mFeedTime.setText(commentTime + " " + commentLocation);
if (!TextUtils.isEmpty(mExFeedPicEntry.getExfeed_location())) {
mFeedTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mExFeedPicEntry.getLocation_delete_enable() == 1){
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",mExFeedPicEntry.getExfeed_lng());
intent.putExtra("latidute", mExFeedPicEntry.getExfeed_lat());
intent.putExtra("location", mExFeedPicEntry.getExfeed_location());
startActivity(intent);
} else {
UICore.eventTask(ExchangePicDetailActivity.this, ExchangePicDetailActivity.this, EXEU_DELETE_LOCATION_FEED, "", mExFeedPicEntry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",mExFeedPicEntry.getExfeed_lng());
intent.putExtra("latidute", mExFeedPicEntry.getExfeed_lat());
intent.putExtra("location", mExFeedPicEntry.getExfeed_location());
startActivity(intent);
}
});
builder.create().show();
}
}
});
}
RemoteImageView mFeedCommentAvatar = (RemoteImageView) feed_child
.findViewById(R.id.comment_profile_photo);
try {
mFeedCommentAvatar.setDefaultImage(R.drawable.avatar_default_small);
mFeedCommentAvatar.setImageUrl(mExFeedPicEntry.getExfeed_avatar());
} catch (Exception e) {
e.printStackTrace();
mFeedCommentAvatar.setImageResource(R.drawable.avatar_default_small);
}
mFeedCommentAvatar
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", mExFeedPicEntry.getExfeed_uid());
startActivity(spaceIntent);
}
});
RelativeLayout exFeedPicContent = (RelativeLayout) feed_child
.findViewById(R.id.rl_exchange_feed_type);
if (mExFeedPicEntry.getExfeed_type() == 1) {
exFeedPicContent.setVisibility(View.GONE);
} else {
if (null != mExFeedPicEntry.getExfeed_pic()
&& mExFeedPicEntry.getExfeed_pic().length() > 0) {
exFeedPicContent.setVisibility(View.VISIBLE);
RelativeLayout rl_bottle_content_photo = (RelativeLayout) feed_child
.findViewById(R.id.rl_bottle_content_photo);
LinearLayout ll_bottle_photo_locked = (LinearLayout) feed_child
.findViewById(R.id.ll_bottle_photo_locked);
Button comment_button_exchange = (Button) feed_child
.findViewById(R.id.comment_button_exchange);
LinearLayout comment_button_like = (LinearLayout) feed_child
.findViewById(R.id.comment_button_like);
if (mExFeedPicEntry.getExfeed_pic_locked() == 1) {
comment_button_like.setVisibility(View.GONE);
rl_bottle_content_photo.setVisibility(View.GONE);
ll_bottle_photo_locked.setVisibility(View.VISIBLE);
comment_button_exchange.setVisibility(View.VISIBLE);
comment_button_exchange
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentPhoto = new Intent(
ExchangePicDetailActivity.this,
ExpandEditActivity.class);
Bundle bundlePhoto = new Bundle();
bundlePhoto.putString(
"from_type",AppContext.REPLY_PICEX);
bundlePhoto.putString("reply_picex_type", "accept");
bundlePhoto.putInt("ouid",
mExFeedPicEntry
.getExfeed_uid());
intentPhoto.putExtras(bundlePhoto);
startActivityForResult(intentPhoto, 0);
}
});
} else {
ll_bottle_photo_locked.setVisibility(View.GONE);
comment_button_exchange.setVisibility(View.GONE);
rl_bottle_content_photo.setVisibility(View.VISIBLE);
comment_button_like.setVisibility(View.VISIBLE);
ImageView exFeedPicView = (ImageView) feed_child
.findViewById(R.id.photo);
imageLoader.DisplayImage(
mExFeedPicEntry.getExfeed_pic(),
exFeedPicView, R.drawable.album_nophoto);
exFeedPicView
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Status status = null;
if (mExFeedPicEntry.getExfeed_uid()==AppContext.getInstance().getLogin_uid()) {
//自己的照片
if (mExFeedPicEntry.getExfeed_pic_enabletuya() == 1 && mExFeedPicEntry.getExfeed_pic_allowtuya() == 1) {
status = Status.exchange_pic_feed_my_allowtuya_and_enabletuya;
} else if (mExFeedPicEntry.getExfeed_pic_enabletuya() == 2 && mExFeedPicEntry.getExfeed_pic_allowtuya() == 1 ) {
status = Status.exchange_pic_feed_my_allowtuya_and_not_enabletuya;
} else {
status = Status.exchange_pic_feed;
}
doPhotoAction(ouid,mExFeedPicEntry, status, exsid);
} else {
if (mExFeedPicEntry.getExfeed_pic_allowtuya() == 1) {
status = Status.exchange_pic_feed_other_allowtuya;
} else {
status = Status.exchange_pic_feed_other;
}
//别人的照片
doPhotoAction(ouid,mExFeedPicEntry,
status, exsid);
}
}
});
if (mExFeedPicEntry.getExfeed_like_enable() == 1) {
comment_button_like.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.photo_pill));
comment_button_like
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showInfoPopupWindow(
v,
mExFeedPicEntry
.getExfeed_picid(),
ouid, exSessionEntry
.getExsid());
}
});
} else {
comment_button_like
.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.photo_pill_dark));
}
ImageView mLikeIcon = (ImageView) feed_child
.findViewById(R.id.comment_button_like_icon);
switch (mExFeedPicEntry.getExfeed_pic_liked()) {
case 0:
mLikeIcon
.setImageResource(R.drawable.like_gray2);
break;
case 1:
mLikeIcon
.setImageResource(R.drawable.like_red2);
break;
case 2:
mLikeIcon
.setImageResource(R.drawable.like_black2);
break;
default:
break;
}
}
} else {
exFeedPicContent.setVisibility(View.GONE);
}
}
LinearLayout ll_exchange_feed_comment = (LinearLayout) feed_child
.findViewById(R.id.ll_exchange_feed_comment);
List<ExPicFeedEntry> exPicFeed = mExFeedPicEntry
.getExpicfeeds_list();
if (null != exPicFeed && exPicFeed.size() > 0) {
for (int j = 0; j < exPicFeed.size(); j++) {
final ExPicFeedEntry mExPicFeedEntry = exPicFeed.get(j);
View picFeedItem = LayoutInflater.from(this).inflate(
R.layout.exchange_pic_comments_item, null);
ImageView mLink = (ImageView) picFeedItem
.findViewById(R.id.iv_feed_comment_white);
switch (mExPicFeedEntry.getExpicfeed_type()) {
case 0:
mLink.setImageResource(R.drawable.feed_white);
break;
case 1:
mLink.setImageResource(R.drawable.feed_white);
break;
case 2:
mLink.setImageResource(R.drawable.like_red3);
break;
case 3:
mLink.setImageResource(R.drawable.like_black3);
break;
default:
mLink.setImageResource(R.drawable.feed_white);
break;
}
TextView picFeedNickname = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_nickname);
String picfeedex_content = mExPicFeedEntry.getExpicfeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_content()) + "</font>")
: TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_content());
String picFeedNameStr = null;
if (mExPicFeedEntry.getExpicfeed_uid() != AppContext.getInstance()
.getLogin_uid()) {
picFeedNameStr = (!TextUtils.isEmpty(mExPicFeedEntry.getExpicfeed_nickname())) ? ("<font color='#DA4A37'>"
+ mExPicFeedEntry.getExpicfeed_nickname() + "</font>"): "";
} else {
picFeedNameStr = (!TextUtils.isEmpty(mExPicFeedEntry.getExpicfeed_nickname())) ? ("<font color='#3F99D8'>"
+ mExPicFeedEntry.getExpicfeed_nickname() + "</font>"): "";
}
picFeedNickname.setText(Html.fromHtml(picFeedNameStr+ " "+ picfeedex_content));
TextView picComment = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_content);
if (!TextUtils.isEmpty(mExPicFeedEntry.getExpicfeed_comment())) {
picComment.setVisibility(View.VISIBLE);
String comment_title = "<font color='#000000'>"
+ TextUtil.R("exchange_feed_comment_title") + "</font>";
String feedex_content = mExPicFeedEntry.getExpicfeed_isnew()== 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_comment()) + "</font>")
: TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_comment());
picComment.setText(Html.fromHtml(comment_title
+ feedex_content));
} else {
picComment.setVisibility(View.GONE);
}
final String picCommentLocation = TextUtils.isEmpty(mExPicFeedEntry.getExpicfeed_location()) ? "" : ("@" + mExPicFeedEntry.getExpicfeed_location());
TextView picCommentTime = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_time);
if (!TextUtils.isEmpty(mExPicFeedEntry
.getExpicfeed_time())) {
picCommentTime.setText("#"+mExPicFeedEntry
.getExpicfeed_time()+picCommentLocation);
}
if (picCommentLocation.length()>0) {
picCommentTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(picCommentLocation.length()>0){
if(mExPicFeedEntry.getLocation_delete_enable_2() == 1){
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
mExPicFeedEntry.getExpicfeed_lng());
intent.putExtra("latidute",
mExPicFeedEntry.getExpicfeed_lat());
intent.putExtra(
"location",
mExPicFeedEntry.getExpicfeed_location());
startActivity(intent);
} else {
UICore.eventTask(ExchangePicDetailActivity.this, ExchangePicDetailActivity.this, EXEU_DELETE_LOCATION_PIC_FEED, "", mExPicFeedEntry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
mExPicFeedEntry.getExpicfeed_lng());
intent.putExtra("latidute",
mExPicFeedEntry.getExpicfeed_lat());
intent.putExtra(
"location",
mExPicFeedEntry.getExpicfeed_location());
startActivity(intent);
}
});
builder.create().show();
}
}
}
});
}
ll_exchange_feed_comment.addView(picFeedItem);
}
}
feed_comment.addView(feed_child);
}
} else {
line_exchange_comment.setVisibility(View.GONE);
line_comments_ellipsis.setVisibility(View.GONE);
feed_comments_more.setVisibility(View.GONE);
}
// refresh_view.addChild(view);
ll_content.addView(view);
rv.mfooterViewText.setVisibility(View.VISIBLE);
ServiceUtils.dout("CanvasHeight:" + CanvasHeight);
ServiceUtils.dout("ll_content.getHeight():" + ll_content.getHeight());
ServiceUtils.dout("ll_content.getLayoutParams().height:"
+ ll_content.getLayoutParams().height);
}
/** 喜欢pop */
private void initLikePopupWindow() {
LayoutInflater mLayoutInflater = LayoutInflater.from(this);
mLikeView = mLayoutInflater.inflate(R.layout.pop_bottle_like, null);
ImageView iv_unlike = (ImageView) mLikeView
.findViewById(R.id.iv_unlike);
ImageView iv_like = (ImageView) mLikeView.findViewById(R.id.iv_like);
iv_unlike.setOnClickListener(this);
iv_like.setOnClickListener(this);
mLikePopview = new CustomPopupWindow(mLikeView,
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mLikePopview.setBackgroundDrawable(getResources().getDrawable(
R.drawable.like_frame_right));
mLikePopview.setOutsideTouchable(true);
mLikePopview.update();
mLikePopview.setTouchable(true);
mLikePopview.setFocusable(true);
}
public void showInfoPopupWindow(View achorView, int picid, int ouid,
int exsid) {
this.ouid = ouid;
this.picid = picid;
this.exsid = exsid;
if (mLikePopview.isShowing()) {
mLikePopview.dismiss();
} else {
// mLikePopview.showAtLocation(achorView, Gravity.RIGHT, 0, 0);
mLikePopview.showAsDropDown(achorView, -160, -70);
}
}
public void doRejectPicex(int ouid, int exsid) {
this.ouid = ouid;
this.exsid = exsid;
UICore.eventTask(this, this, EXEU_REJECT_PICEX_SUCCESS, "", null);
}
private static enum Status{
exchange_pic_feed,
exchange_pic_feed_my_allowtuya_and_not_enabletuya,
exchange_pic_feed_my_allowtuya_and_enabletuya,
exchange_pic_feed_other,
exchange_pic_feed_other_allowtuya,
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case EXEU_EXCHANGE_PIC_INFO:
getExchangePic(ouid, page);
break;
case EXEU_INVISIBLE_PICEX_SUCCESS:
invisiblePicex(ouid);
break;
case EXEU_REJECT_PICEX_SUCCESS:
rejectPicex(ouid);
break;
case EXEU_VISIBLE_PICEX_SUCCESS:
visiblePicex(ouid);
break;
case EXEU_REFRESH_PIC_INFO:
refreshExchangePic(ouid, page);
break;
case EXEU_UNLIKE_OPERATION:
likeIOperationPicex(ouid, picid, 1);
break;
case EXEU_LIKE_OPERATION:
likeIOperationPicex(ouid, picid, 0);
break;
case EXEU_GET_MORE_PIC_INFO:
getMoreExchangePic(ouid, page);
break;
case EXEU_GOTO_EXCHANGE:
getHasExs(ouid);
break;
case EXEU_DELETE_LOCATION_PIC_FEED:
ExPicFeedEntry mExPicFeedEntry = (ExPicFeedEntry)obj;
deleteLocation(String.valueOf(mExPicFeedEntry.getLocation_objtype_2()),String.valueOf(mExPicFeedEntry.getLocation_objid_2()));
break;
case EXEU_DELETE_LOCATION_FEED:
ExFeedPicEntry objid2 = (ExFeedPicEntry)obj;
deleteLocation(String.valueOf(objid2.getLocation_objtype()),String.valueOf(objid2.getLocation_objid()));
break;
case EXEU_SET_BTPIC_PAINT:
int optype = (Integer)obj;
setExpicPaint(ouid, picid, optype);
break;
default:
break;
}
}
@Override
protected void onResume() {
super.onResume();
if (AppContext.getInstance().isFromExchangePicSession()) {
AppContext.getInstance().setFromExchangePicSession(false);
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
}
}
/**
*
* @param ouid
* @param picid
* @param optype 设置是否允许涂鸦。选择项:不允许(0)、允许(1)
*/
private void setExpicPaint(int ouid, int picid,int optype) {
StringBuffer url = new StringBuffer(UrlConfig.set_expic_paint);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&picid=" + picid);
url.append("&optype=" + optype);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int authok = resultObj.getInt("success");
if (authok == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, EXEU_EXCHANGE_PIC_INFO_FAILED, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, EXEU_SET_BTPIC_PAINT, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* @param objtype 要清除的位置的类型:选择项:(1)瓶子动态的位置信息、(2)交换动态留言的位置信息、(3)照片评论的位置信息、(4)私信的位置信息、(5)照片的位置信息
* @param objid objid
*/
private void deleteLocation(String objtype,String objid) {
StringBuffer url = new StringBuffer(UrlConfig.delete_location);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&objtype=" + objtype);
url.append("&objid=" + objid);
ServiceUtils.dout("deleteLocation url:" + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
ServiceUtils.dout("deleteLocation result:" + result);
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_PIC_FEED_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_FAILED, errmsg);
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void likeIOperationPicex(int ouid, int picid, int liketype) {
StringBuffer url = new StringBuffer(UrlConfig.likeop_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&picid=" + picid);
url.append("&liketype=" + liketype);
ServiceUtils.dout("likeIOperationPicex url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("likeIOperationPicex result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_LIKE_OP_PICEX_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_LIKE_OP_PICEX_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void visiblePicex(int ouid) {
StringBuffer url = new StringBuffer(UrlConfig.visible_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
ServiceUtils.dout("visiblePicex url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("visiblePicex result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_VISIBLE_PICEX_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_VISIBLE_PICEX_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void rejectPicex(int ouid) {
StringBuffer url = new StringBuffer(UrlConfig.reject_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
ServiceUtils.dout("rejectPicex url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("rejectPicex result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_REJECT_PICEX_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_REJECT_PICEX_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void doVisiblePicex(int ouid, int exsid) {
this.ouid = ouid;
this.exsid = exsid;
UICore.eventTask(this, this, EXEU_VISIBLE_PICEX_SUCCESS, "", null);
}
public void doExchange(int ouid) {
this.ouid = ouid;
UICore.eventTask(this, this, EXEU_GOTO_EXCHANGE, "has_exs", null);
}
private void getHasExs(int ouid) {
StringBuffer url = new StringBuffer(UrlConfig.get_has_exs);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int authok = resultObj.getInt("authok");
if (authok == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, INIT_HAS_EXS_ERROR,
errmsg);
handler.sendMessage(msg);
} else {
JSONObject hasExsObj = object.getJSONObject("has_exs");
int has_infoexs = hasExsObj.getInt("has_infoexs");
if (has_infoexs == 1) {
handler.sendEmptyMessage(EXEU_GOTO_PROFILE);
} else {
handler.sendEmptyMessage(INIT_HAS_EXS_PROFILE);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getExchangePic(int ouid, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=10");
url.append("&page=" + page);
url.append("&picfeedscount=5");
ServiceUtils.dout("getExchangePic url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getExchangePic results:" + results);
Gson gson = new Gson();
mExPicInfo = gson.fromJson(results, ExchangePicInfo.class);
if (mExPicInfo.getResults().getAuthok() == 1) {
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance().getLogin_uid());
if (null!=pushInfo) {
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
}
Message message = handler.obtainMessage(EXEU_EXCHANGE_PIC_INFO, mExPicInfo.getResults().getErrmsg());
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_EXCHANGE_PIC_INFO_FAILED, mExPicInfo.getResults().getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getMoreExchangePic(int ouid, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=10");
url.append("&page=" + page);
url.append("&picfeedscount=5");
ServiceUtils.dout("getExchangePic url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getExchangePic results:" + results);
Gson gson = new Gson();
mExPicInfo = gson.fromJson(results, ExchangePicInfo.class);
if (mExPicInfo.getResults().getAuthok() == 1) {
Message message = handler.obtainMessage(EXEU_GET_MORE_PIC_INFO,
mExPicInfo.getResults().getErrmsg());
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_EXCHANGE_PIC_INFO_FAILED, mExPicInfo.getResults()
.getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void doPhotoAction(final int ouid, final int picid,
final String pic_big, final String thumnail_pic, int type) {
if (type==2) {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = this.getResources().getStringArray(
R.array.exchange_pic_feed_other);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Photo
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(thumnail_pic);
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", pic_big);
bigPicIntent.putExtra("thumbnail", tempBytes);
ExchangePicDetailActivity.this.startActivity(bigPicIntent);
break;
case 1:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this, ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", picid);
startActivity(intent);
break;
case 2:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
AppContext.getInstance().setFromExchangeTime(true);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", picid);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
break;
case 3:
Intent friendIntent = new Intent(ExchangePicDetailActivity.this,ChooseFriendActivity.class);
friendIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE);
friendIntent.putExtra("picid",picid);
friendIntent.putExtra("pic_uid",ouid);
startActivityForResult(friendIntent, 0);
break;
case 4:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
}else {
final Context dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Photo
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(thumnail_pic);
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", pic_big);
bigPicIntent.putExtra("thumbnail", tempBytes);
ExchangePicDetailActivity.this.startActivity(bigPicIntent);
break;
case 1:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", picid);
startActivity(intent);
break;
case 2:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this,
ExpandEditActivity.class);
AppContext.getInstance().setFromExchangeTime(true);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", picid);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
break;
case 3:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
}
}
private void refreshExchangePic(int ouid, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=20");
url.append("&page=" + page);
url.append("&picfeedscount=5");
ServiceUtils.dout("getExchangePic url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getExchangePic results:" + results);
Gson gson = new Gson();
mExPicInfo = gson.fromJson(results, ExchangePicInfo.class);
if (mExPicInfo.getResults().getAuthok() == 1) {
Message message = handler.obtainMessage(EXEU_REFRESH_PIC_INFO,
mExPicInfo.getResults().getErrmsg());
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_EXCHANGE_PIC_INFO_FAILED, mExPicInfo.getResults()
.getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case EXEU_EXCHANGE_PIC_INFO:
ll_content.removeAllViews();
setViewValue();
pushNoticeUpdateUI();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
break;
case EXEU_REFRESH_PIC_INFO:
ServiceUtils.dout("refresh");
// refresh_view.removeChild(view);
ll_content.removeAllViews();
setViewValue();
rv.finishRefresh();
// refresh_view.onRefreshComplete();
break;
case EXEU_EXCHANGE_PIC_INFO_FAILED:
onToast((String) msg.obj);
break;
case EXEU_INVISIBLE_PICEX_SUCCESS:
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
case EXEU_INVISIBLE_PICEX_FAILED:
onToast((String) msg.obj);
break;
case EXEU_REJECT_PICEX_SUCCESS:
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
case EXEU_REJECT_PICEX_FAILED:
onToast((String) msg.obj);
break;
case EXEU_VISIBLE_PICEX_SUCCESS:
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
case EXEU_VISIBLE_PICEX_FAILED:
onToast((String) msg.obj);
break;
case EXEU_LIKE_OP_PICEX_FAILED:
onToast((String) msg.obj);
break;
case EXEU_LIKE_OP_PICEX_SUCCESS:
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
case EXEU_GET_MORE_PIC_INFO:
List<ExFeedPicEntry> mExFeedPicEntries = mExPicInfo
.getExfeeds_list();
if (null != mExFeedPicEntries && mExFeedPicEntries.size() > 0) {
setMoreFeed(mExFeedPicEntries);
} else {
onToast(TextUtil.R("no_more_data"));
}
rv.finishRefresh();
break;
case INIT_HAS_EXS_ERROR:
onToast((String)msg.obj);
break;
case EXEU_GOTO_PROFILE:
Intent intentExchangePro = new Intent(this,
ExchangeInfoDetailActivity.class);
intentExchangePro.putExtra("ouid", ouid);
intentExchangePro.putExtra("page", 1);
startActivity(intentExchangePro);
break;
case INIT_HAS_EXS_PROFILE:
Intent intentProfile = new Intent(this,
ExpandEditActivity.class);
Bundle bundleProfile = new Bundle();
bundleProfile.putString("from_type", AppContext.REPLY_INFOEX);
bundleProfile.putInt("ouid", ouid);
bundleProfile.putString("reply_infoex_type", "apply");
intentProfile.putExtras(bundleProfile);
startActivity(intentProfile);
break;
case user_baseinfo_notfull:
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
showChoseMes(userEntry.getBasicinfo_tip(), complete_info);
break;
case EXEU_DELETE_LOCATION_PIC_FEED_SUCCESS:
onToast((String)msg.obj);
page = 1;
UICore.eventTask(ExchangePicDetailActivity.this, ExchangePicDetailActivity.this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
case EXEU_DELETE_LOCATION_FAILED:
onToast((String)msg.obj);
break;
case EXEU_SET_BTPIC_PAINT:
onToast((String)msg.obj);
page = 1;
UICore.eventTask(this, this, EXEU_EXCHANGE_PIC_INFO, "", null);
break;
default:
break;
}
return false;
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
}
}
private void setMoreFeed(List<ExFeedPicEntry> mExFeedPicEntries) {
for (int i = 0; i < mExFeedPicEntries.size(); i++) {
final ExFeedPicEntry mExFeedPicEntry = mExFeedPicEntries.get(i);
View feed_child = LayoutInflater.from(this).inflate(
R.layout.exchange_comments_item, null);
TextView mFeedAvatar = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_nickname);
mFeedAvatar.setText(mExFeedPicEntry.getExfeed_nickname() + " "
+ mExFeedPicEntry.getExfeed_content());
TextView mFeedComment = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_content);
if (null != mExFeedPicEntry.getExfeed_comment()
&& mExFeedPicEntry.getExfeed_comment().length() > 0) {
mFeedComment.setVisibility(View.VISIBLE);
String commentTips = "<font color='#000000'>"
+ TextUtil.R("exchange_feed_comment_title") + ":"
+ "</font>";
String feed_content = mExFeedPicEntry.getExfeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(mExFeedPicEntry.getExfeed_comment()) + "</font>")
: TextUtil.htmlEncode(mExFeedPicEntry.getExfeed_comment());
mFeedComment.setText(Html.fromHtml(commentTips
+feed_content));
} else {
mFeedComment.setVisibility(View.GONE);
}
TextView mFeedTime = (TextView) feed_child
.findViewById(R.id.tv_feed_comment_time);
mFeedTime.setText(mExFeedPicEntry.getExfeed_time() + " "
+ mExFeedPicEntry.getExfeed_location());
if (!TextUtils.isEmpty(mExFeedPicEntry.getExfeed_location())) {
mFeedTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mExFeedPicEntry.getLocation_delete_enable() == 1) {
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
mExFeedPicEntry
.getExfeed_lng());
intent.putExtra(
"latidute",
mExFeedPicEntry
.getExfeed_lat());
intent.putExtra(
"location",
mExFeedPicEntry
.getExfeed_location());
startActivity(intent);
} else {
UICore.eventTask(
ExchangePicDetailActivity.this,
ExchangePicDetailActivity.this,
EXEU_DELETE_LOCATION_FEED,
"",
mExFeedPicEntry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
mExFeedPicEntry
.getExfeed_lng());
intent.putExtra("latidute",
mExFeedPicEntry
.getExfeed_lat());
intent.putExtra(
"location",
mExFeedPicEntry
.getExfeed_location());
startActivity(intent);
}
});
builder.create().show();
}
}
});
}
RemoteImageView mFeedCommentAvatar = (RemoteImageView) feed_child
.findViewById(R.id.comment_profile_photo);
try {
mFeedCommentAvatar.setDefaultImage(R.drawable.avatar_default_small);
mFeedCommentAvatar.setImageUrl(mExFeedPicEntry.getExfeed_avatar());
} catch (Exception e) {
e.printStackTrace();
mFeedCommentAvatar.setImageResource(R.drawable.avatar_default_small);
}
mFeedCommentAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(ExchangePicDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", mExFeedPicEntry.getExfeed_uid());
startActivity(spaceIntent);
}
});
RelativeLayout exFeedPicContent = (RelativeLayout) feed_child
.findViewById(R.id.rl_exchange_feed_type);
if (mExFeedPicEntry.getExfeed_type() == 1) {
exFeedPicContent.setVisibility(View.GONE);
} else {
if (null != mExFeedPicEntry.getExfeed_pic()
&& mExFeedPicEntry.getExfeed_pic().length() > 0) {
exFeedPicContent.setVisibility(View.VISIBLE);
RelativeLayout rl_bottle_content_photo = (RelativeLayout) feed_child
.findViewById(R.id.rl_bottle_content_photo);
LinearLayout ll_bottle_photo_locked = (LinearLayout) feed_child
.findViewById(R.id.ll_bottle_photo_locked);
Button comment_button_exchange = (Button) feed_child
.findViewById(R.id.comment_button_exchange);
LinearLayout comment_button_like = (LinearLayout) feed_child
.findViewById(R.id.comment_button_like);
if (mExFeedPicEntry.getExfeed_pic_locked() == 1) {
comment_button_like.setVisibility(View.GONE);
rl_bottle_content_photo.setVisibility(View.GONE);
ll_bottle_photo_locked.setVisibility(View.VISIBLE);
comment_button_exchange.setVisibility(View.VISIBLE);
comment_button_exchange
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentPhoto = new Intent(
ExchangePicDetailActivity.this,
ExpandEditActivity.class);
Bundle bundlePhoto = new Bundle();
bundlePhoto.putString("from_type",
AppContext.APPLY_PICEX);
bundlePhoto
.putInt("ouid", mExFeedPicEntry
.getExfeed_uid());
intentPhoto.putExtras(bundlePhoto);
startActivity(intentPhoto);
}
});
} else {
ll_bottle_photo_locked.setVisibility(View.GONE);
comment_button_exchange.setVisibility(View.GONE);
rl_bottle_content_photo.setVisibility(View.VISIBLE);
comment_button_like.setVisibility(View.VISIBLE);
ImageView exFeedPicView = (ImageView) feed_child
.findViewById(R.id.photo);
imageLoader.DisplayImage(
mExFeedPicEntry.getExfeed_pic(), exFeedPicView,
R.drawable.album_nophoto);
exFeedPicView
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(mExFeedPicEntry.getExfeed_pic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", mExFeedPicEntry.getExfeed_pic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
ExchangePicDetailActivity.this.startActivity(bigPicIntent);
}
});
if (mExFeedPicEntry.getExfeed_like_enable() == 1) {
comment_button_like
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showInfoPopupWindow(v,
mExFeedPicEntry
.getExfeed_picid(),
ouid, mExPicInfo
.getExs_info()
.getExsid());
}
});
} else {
comment_button_like.setBackgroundDrawable(null);
}
ImageView mLikeIcon = (ImageView) feed_child
.findViewById(R.id.comment_button_like_icon);
switch (mExFeedPicEntry.getExfeed_pic_liked()) {
case 0:
mLikeIcon.setImageResource(R.drawable.like_gray2);
break;
case 1:
mLikeIcon.setImageResource(R.drawable.like_red2);
break;
case 2:
mLikeIcon.setImageResource(R.drawable.like_black2);
break;
default:
break;
}
}
} else {
exFeedPicContent.setVisibility(View.GONE);
}
}
LinearLayout ll_exchange_feed_comment = (LinearLayout) feed_child
.findViewById(R.id.ll_exchange_feed_comment);
List<ExPicFeedEntry> exPicFeed = mExFeedPicEntry
.getExpicfeeds_list();
if (null != exPicFeed && exPicFeed.size() > 0) {
for (int j = 0; j < exPicFeed.size(); j++) {
final ExPicFeedEntry mExPicFeedEntry = exPicFeed.get(j);
View picFeedItem = LayoutInflater.from(this).inflate(
R.layout.exchange_pic_comments_item, null);
ImageView mLink = (ImageView) picFeedItem
.findViewById(R.id.iv_feed_comment_white);
switch (mExPicFeedEntry.getExpicfeed_type()) {
case 0:
mLink.setImageResource(R.drawable.feed_white);
break;
case 1:
mLink.setImageResource(R.drawable.feed_white);
break;
case 2:
mLink.setImageResource(R.drawable.like_red2);
break;
case 3:
mLink.setImageResource(R.drawable.like_black2);
break;
default:
mLink.setImageResource(R.drawable.feed_white);
break;
}
TextView picFeedNickname = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_nickname);
picFeedNickname.setText(mExPicFeedEntry
.getExpicfeed_nickname()
+ " "
+ mExPicFeedEntry.getExpicfeed_content());
TextView picComment = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_content);
if (null != mExPicFeedEntry.getExpicfeed_comment()
&& mExPicFeedEntry.getExpicfeed_comment().length() > 0) {
picComment.setVisibility(View.VISIBLE);
String comment_title = "<font color='#000000'>"
+ TextUtil.R("exchange_feed_comment_title")
+ ":" + "</font>";
String feedex_content = mExPicFeedEntry.getExpicfeed_isnew()== 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_comment()) + "</font>")
: TextUtil.htmlEncode(mExPicFeedEntry.getExpicfeed_comment());
picComment.setText(Html.fromHtml(comment_title
+ feedex_content));
} else {
picComment.setVisibility(View.GONE);
}
final String picCommentLocation = TextUtils.isEmpty(mExPicFeedEntry.getExpicfeed_location()) ? "" : ("@" + mExPicFeedEntry.getExpicfeed_location());
TextView picCommentTime = (TextView) picFeedItem
.findViewById(R.id.tv_feed_comment_time);
if (!TextUtils.isEmpty(mExPicFeedEntry
.getExpicfeed_time())) {
picCommentTime.setText("#"+mExPicFeedEntry
.getExpicfeed_time()+picCommentLocation);
}
if (picCommentLocation.length()>0) {
picCommentTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(picCommentLocation.length()>0){
if(mExPicFeedEntry.getLocation_delete_enable_2() == 1){
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
mExPicFeedEntry.getExpicfeed_lng());
intent.putExtra("latidute",
mExPicFeedEntry.getExpicfeed_lat());
intent.putExtra(
"location",
mExPicFeedEntry.getExpicfeed_location());
startActivity(intent);
} else {
UICore.eventTask(ExchangePicDetailActivity.this, ExchangePicDetailActivity.this, EXEU_DELETE_LOCATION_PIC_FEED, "", mExPicFeedEntry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
ExchangePicDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
mExPicFeedEntry.getExpicfeed_lng());
intent.putExtra("latidute",
mExPicFeedEntry.getExpicfeed_lat());
intent.putExtra(
"location",
mExPicFeedEntry.getExpicfeed_location());
startActivity(intent);
}
});
builder.create().show();
}
}
}
});
}
ll_exchange_feed_comment.addView(picFeedItem);
}
}
feed_comment.addView(feed_child);
}
}
public void doInvisiblePicex(int ouid, int exsid) {
this.ouid = ouid;
this.exsid = exsid;
UICore.eventTask(this, this, EXEU_INVISIBLE_PICEX_SUCCESS, "", null);
}
private void invisiblePicex(int ouid) {
StringBuffer url = new StringBuffer(UrlConfig.invisible_picex);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
ServiceUtils.dout("invisiblePicex url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("invisiblePicex result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_INVISIBLE_PICEX_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_INVISIBLE_PICEX_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onActivityResult(int arg0, int arg1, Intent data) {
super.onActivityResult(arg0, arg1, data);
// refresh_view.removeChild(view);
if (null!=data) {
if (data.getBooleanExtra("need_refresh", false)) {
page = 1;
UICore.eventTask(this, this, EXEU_REFRESH_PIC_INFO, "", null);
}
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.topbar_back:
finish();
break;
case R.id.iv_unlike:// 不喜欢
mLikePopview.dismiss();
UICore.eventTask(this, this, EXEU_UNLIKE_OPERATION, "", null);
break;
case R.id.iv_like:// 喜欢
mLikePopview.dismiss();
UICore.eventTask(this, this, EXEU_LIKE_OPERATION, "", null);
break;
// case R.id.notice_message_count:
// doMessageAction();
// break;
case R.id.notice_bottom_layout:
doFeedsAction();
break;
default:
break;
}
}
/***
* 最新的动态 :0 最新的动态:1 资料交换:2 照片交换:3
*
* @param mode
* @param type
* 1:我的照片 2.别人的照片
*/
public void doPhotoAction(final int ouid, final ExFeedPicEntry exfeedEntry , Status status,final int exsid) {
Context dialogContext = null;
ListAdapter adapter = null;
String[] choices = null;
AlertDialog.Builder builder = null;
switch (status) {
case exchange_pic_feed:
dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this, android.R.style.Theme_Light);
choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed);
adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", exfeedEntry.getExfeed_picid());
startActivity(intent);
break;
case 1:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", exfeedEntry.getExfeed_picid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
break;
case 2:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
break;
case exchange_pic_feed_my_allowtuya_and_enabletuya:
dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed_my_allowtuya_and_enabletuya);
adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", exfeedEntry.getExfeed_picid());
startActivity(intent);
break;
case 1:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", exfeedEntry.getExfeed_picid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
break;
case 2://涂鸦照片
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(exfeedEntry.getExfeed_pic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", exfeedEntry.getExfeed_pic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
bigPicIntent.putExtra("paintType", AppContext.PAINT_PICEX);
bigPicIntent.putExtra("ouid", ouid);
bigPicIntent.putExtra("picid", exfeedEntry.getExfeed_picid());
bigPicIntent.putExtra("return_type",ExchangePicDetailActivity.class.getSimpleName());
bigPicIntent.putExtra("isToDraw", true);
startActivity(bigPicIntent);
break;
case 3://允许涂鸦
doExpicPaint(ouid, exfeedEntry.getExfeed_picid(), 1, exsid);
break;
case 4:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
break;
case exchange_pic_feed_my_allowtuya_and_not_enabletuya:
dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed_my_allowtuya_and_not_enabletuya);
adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", exfeedEntry.getExfeed_picid());
startActivity(intent);
break;
case 1:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", exfeedEntry.getExfeed_picid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
break;
case 2://涂鸦照片
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(exfeedEntry.getExfeed_pic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", exfeedEntry.getExfeed_pic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
bigPicIntent.putExtra("paintType", AppContext.PAINT_PICEX);
bigPicIntent.putExtra("ouid", ouid);
bigPicIntent.putExtra("picid", exfeedEntry.getExfeed_picid());
bigPicIntent.putExtra("return_type",ExchangePicDetailActivity.class.getSimpleName());
bigPicIntent.putExtra("isToDraw", true);
startActivity(bigPicIntent);
break;
case 3://不允许涂鸦
doExpicPaint(ouid, exfeedEntry.getExfeed_picid(), 0, exsid);
break;
case 4:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
break;
case exchange_pic_feed_other:
dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed_other);
adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", exfeedEntry.getExfeed_picid());
startActivity(intent);
break;
case 1:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", exfeedEntry.getExfeed_picid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
break;
case 2://转发
Intent friendIntent = new Intent(ExchangePicDetailActivity.this,
ChooseFriendActivity.class);
friendIntent.putExtra("choose_friend_type",
AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE);
friendIntent.putExtra("picid", exfeedEntry.getExfeed_picid());
friendIntent.putExtra("pic_uid", ouid);
friendIntent.putExtra("return_type",ExchangePicDetailActivity.class.getSimpleName());
startActivity(friendIntent);
break;
case 3:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
break;
case exchange_pic_feed_other_allowtuya:
dialogContext = new ContextThemeWrapper(ExchangePicDetailActivity.this,
android.R.style.Theme_Light);
choices = ExchangePicDetailActivity.this.getResources().getStringArray(
R.array.exchange_pic_feed_other_allowtuya);
adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:// View Comment
Intent intent = new Intent(ExchangePicDetailActivity.this,
ExchangePicFeedDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("picid", exfeedEntry.getExfeed_picid());
startActivity(intent);
break;
case 1:// Comment
Intent commentIntent = new Intent(ExchangePicDetailActivity.this, ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLYPIC_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", exfeedEntry.getExfeed_picid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
break;
case 2://涂鸦照片
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(exfeedEntry.getExfeed_pic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(ExchangePicDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", exfeedEntry.getExfeed_pic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
bigPicIntent.putExtra("paintType", AppContext.PAINT_PICEX);
bigPicIntent.putExtra("ouid", exfeedEntry.getExfeed_uid());
bigPicIntent.putExtra("picid", exfeedEntry.getExfeed_picid());
bigPicIntent.putExtra("return_type",ExchangePicDetailActivity.class.getSimpleName());
bigPicIntent.putExtra("isToDraw", true);
startActivity(bigPicIntent);
break;
case 3:
Intent friendIntent = new Intent(ExchangePicDetailActivity.this,
ChooseFriendActivity.class);
friendIntent.putExtra("choose_friend_type",
AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE);
friendIntent.putExtra("return_type",ExchangePicDetailActivity.class.getSimpleName());
friendIntent.putExtra("picid", exfeedEntry.getExfeed_picid());
friendIntent.putExtra("pic_uid", ouid);
startActivity(friendIntent);
break;
case 4:// Cancel
break;
default:
break;
}
}
});
builder.create().show();
break;
default:
break;
}
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount + getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount + getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(ExchangePicDetailActivity.this, NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(ExchangePicDetailActivity.this, MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
Intent intent = new Intent(ExchangePicDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(1);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
Intent intent = new Intent(ExchangePicDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(0);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(ExchangePicDetailActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(ExchangePicDetailActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
Intent intent = new Intent(ExchangePicDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doExpicPaint(int ouid, int picid,int optype,int exsid){
this.ouid = ouid;
this.picid = picid;
this.exsid = exsid;
UICore.eventTask(this, this, EXEU_SET_BTPIC_PAINT, "", optype);
}
public void pushNoticeUpdateUI() {
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
contentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
avatarView.setDefaultImage(R.drawable.avatar_default_big);
avatarView.setImageUrl(message_avatar);
} else {
bottomLayout.setVisibility(View.GONE);
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.provider.MediaStore;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.AvatarEntry;
import com.outsourcing.bottle.domain.BottleFeedInfo;
import com.outsourcing.bottle.domain.FriendFeedEntry;
import com.outsourcing.bottle.domain.FriendFeedInfo;
import com.outsourcing.bottle.domain.FriendGroupEntry;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.ProfileEntry;
import com.outsourcing.bottle.domain.ProfileInfo;
import com.outsourcing.bottle.domain.ResponseResult;
import com.outsourcing.bottle.domain.SpaceBottleFeedEntry;
import com.outsourcing.bottle.domain.SpaceEntry;
import com.outsourcing.bottle.domain.SpaceInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
import com.outsourcing.bottle.widget.CustomListView;
/**
*
* @author 06peng
*
*/
@SuppressLint({ "ResourceAsColor", "ResourceAsColor", "ResourceAsColor" })
public class UserSpaceActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private final int get_space_info = 1;
private final int get_space_info_success = 2;
private final int cancel_friend = 3;
private final int cancel_friend_success = 4;
private final int set_friend_group = 5;
private final int set_friend_group_success = 6;
private final int error = 0;
private final int exchange_profile = 7;
private final int get_more_data = 9;
private final int check_friend_error = 10;
private final int add_friend_success = 11;
private final int get_newsfeeds = 12;
private final int get_bottlefeeds = 13;
private final int get_profile = 14;
private final int refresh_space_info = 15;
private final int set_blacklist = 16;
private final int set_default_avatar = 17;
private final int activity_result_camara_with_data = 1006;
private final int activity_result_pick_with_data = 18;
private final int set_avatar = 19;
private final int view_album_error = 20;
private final int user_baseinfo_notfull = 21;
private final int complete_info = 22;
private static final int EXEU_CHECK_FRIEND_FAILED = 23;
private static final int EXEU_CAN_NOT_ADD_FRIEND = 24;
private static final int EXEU_CHECK_FRIEND_SUCCESS = 25;
private static final int EXEU_CHECK_FRIEND = 26;
private static final int EXEU_ALLOW_ADD_FRIEND = 27;
private static final int activity_result_aviary = 28;
private int ouid;
private SpaceEntry entry; //用户空间信息
private List<AvatarEntry> avatarEntries; //用户头像列表
private ProfileEntry profileEntry; //用户档案
private List<SpaceBottleFeedEntry> bottleFeedList; //瓶子动态列表
private List<SpaceBottleFeedEntry> moreBottleFeedList;
private List<FriendFeedEntry> friendFeedList; //好友动态列表
private List<FriendFeedEntry> moreFriendFeedList;
private Handler handler;
private Bitmap bitmap; //用户头像
private int space_type;
private int info_visible;
private int refresh_type = 0; //1调用updateExchange //2调用updateAvatars
private AvatarEntry entry1;
private AvatarEntry entry2;
private AvatarEntry entry3;
private AvatarEntry entry4;
private Bitmap bitMap;
private File picFile;
public final static int REQUEST_WIDTH = 600;
private int avatarid;
private List<FriendGroupEntry> groupList;
private String[] groupNames;
private int groupItem;
private int groupId;
private int count = 10;
/**
* 底部按钮的点击类型0:newsfeeds;1:bottlefeeds;2:profile
*/
private int selectType = 0;
NewsFeedAdapter newsAdapter;
BottlesFeedAdapter bottlesAdapter;
/******* 用户资料 *********/
private ImageView backView;
private TextView titleText;
private TextView titleView;
private ImageView avatarView;
private TextView nicknameView;
private TextView memoView;
private ImageView sexView;
private TextView doingView;
private TextView addressView;
private ImageView homeView;
// private ImageView settingView;
private ImageView editMemoView;
/***** 设置用户头像 *******/
private RemoteImageView userAvatar1;
private ImageView userAvatarBg1;
private RemoteImageView userAvatar2;
private ImageView userAvatarBg2;
private RemoteImageView userAvatar3;
private ImageView userAvatarBg3;
private RemoteImageView userAvatar4;
private ImageView userAvatarBg4;
private ImageLoader loader;
/******** 交换档案后才能看到Ta的档案 *************/
private Button btnExchange;
private Button btnInfoExchange;
/******** 用户积分经验等级 *************/
private TextView tvCreateAndExp;
private TextView tvTTCreateAndTTExp;
private TextView tvLevel;
private Button upgrade;
/********* 添加好友、交换资料、交换照片、加入黑名单 **************/
private Button btnAddFriend;
private Button btnExProfile;
private Button btnExPhoto;
private Button btnBlacklist;
/********* 好友动态、瓶子动态、好友档案 **************/
private Button btnNewsfeeds;
private Button btnBottlefeeds;
private Button btnProfile;
private CustomListView listView;
// private ProgressBar progressBar;
// private TextView loadMoreView;
private View loadMoreView;
private ImageView menuView;
private int visibleLastIndex = 0; // 最后的可视项索引
public int visibleItemCount; // 当前窗口可见项总数
private View contentView;
private LinearLayout bodyLayout;
// private CustomScrollListView listView
private int newsfeedsPage = 1;
private int bottlefeedsPage = 1;
private String choices[];
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
loader = new ImageLoader(this, AppContext.BottleTimelineIcon);
setContentView(R.layout.user_space_scrollview);
ouid = getIntent().getIntExtra("ouid", 0);
initWidget();
initUserAvatars();
initUserIntegral();
initExchangeButton();
initFeeds();
UICore.eventTask(this, this, get_space_info, "get_space_info", null);
}
private void initWidget() {
homeView = (ImageView) findViewById(R.id.topbar_menu);
homeView.setOnClickListener(this);
menuView = (ImageView) findViewById(R.id.menu);
menuView.setOnClickListener(this);
// settingView = (ImageView) findViewById(R.id.topbar_setting);
// settingView.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.user_space_title);
titleView.setOnClickListener(this);
titleText = (TextView) findViewById(R.id.topbar_title);
listView = (CustomListView) findViewById(R.id.refresh_view);
listView.setonRefreshListener(new CustomListView.OnRefreshListener() {
@Override
public void onRefresh() {
UICore.eventTask(UserSpaceActivity.this, UserSpaceActivity.this, refresh_space_info, null, null);
}
});
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
BaseAdapter adapter = null;
if (selectType == 0) {
adapter = newsAdapter;
} else if (selectType == 1) {
adapter = bottlesAdapter;
}
if (adapter != null) {
int itemsLastIndex = adapter.getCount() + 2; // 数据集最后一项的索引
int lastIndex = itemsLastIndex + 1; // 加上底部的loadMoreView项 和 head项
System.out.println(">>>>>>>> itemsLastIndex:" + itemsLastIndex);
System.out.println(">>>>>>>> lastIndex" + lastIndex);
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && visibleLastIndex == lastIndex) {
// 如果是自动加载,可以在这里放置异步加载数据的代码
System.out.println(">>>>>>>> load more <<<<<<<<<");
loadMoreView.setVisibility(View.VISIBLE);
UICore.eventTask(UserSpaceActivity.this, UserSpaceActivity.this, get_more_data, null, null);
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
listView.setFirstVisiableItem(firstVisibleItem);
UserSpaceActivity.this.visibleItemCount = visibleItemCount;
visibleLastIndex = firstVisibleItem + visibleItemCount;
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
BaseAdapter adapter = null;
if (selectType == 0) {
adapter = newsAdapter;
} else if (selectType == 1) {
adapter = bottlesAdapter;
}
if (adapter != null) {
if (arg2 == adapter.getCount() + 2) {
return;
}
if (selectType == 0) {
choices = null;
final FriendFeedEntry entry = friendFeedList.get(arg2 - 2);
if (entry.getFeed_picid() != 0) {
if (entry.getFeed_picid() != 0 && entry.getFeed_related_uid() != 0) {
choices = new String[2];
choices[0] = getString(R.string.user_space_bottle_view_photo);
choices[1] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
} else if (entry.getFeed_picid() != 0) {
choices = new String[1];
choices[0] = getString(R.string.user_space_bottle_view_photo);
chooseAction(choices, entry);
} else if (entry.getFeed_related_uid() != 0) {
if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
choices = new String[1];
choices[0] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
}
}
} else {
if (entry.getFeed_related_uid() != 0) {
if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
choices = new String[1];
choices[0] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
}
}
}
} else if (selectType == 1) {
SpaceBottleFeedEntry entry = bottleFeedList.get(arg2 - 2);
Intent intent = new Intent(UserSpaceActivity.this, BottleSingleActivity.class);
intent.putExtra("btid", entry.getBtid());
startActivity(intent);
}
}
}
});
contentView = LayoutInflater.from(this).inflate(R.layout.user_space, null);
listView.addHeaderView(contentView);
loadMoreView = LayoutInflater.from(this).inflate(R.layout.refreshable_list_footer, null);
loadMoreView.setVisibility(View.GONE);
listView.addFooterView(loadMoreView);
bodyLayout = (LinearLayout) contentView.findViewById(R.id.user_space_bodylayout);
avatarView = (ImageView) contentView.findViewById(R.id.user_space_avatar);
avatarView.setOnClickListener(this);
nicknameView = (TextView) contentView.findViewById(R.id.user_space_nickname);
memoView = (TextView) contentView.findViewById(R.id.user_space_memo);
sexView = (ImageView) contentView.findViewById(R.id.user_space_sex);
doingView = (TextView) contentView.findViewById(R.id.user_space_doing);
addressView = (TextView) contentView.findViewById(R.id.user_space_address);
editMemoView = (ImageView) findViewById(R.id.user_space_edit_memo);
editMemoView.setOnClickListener(this);
btnExchange = (Button) contentView.findViewById(R.id.user_space_excange);
btnExchange.setOnClickListener(this);
}
private void initUserAvatars() {
userAvatar1 = (RemoteImageView) contentView.findViewById(R.id.user_space_useravatar1);
userAvatar1.setOnClickListener(this);
userAvatarBg1 = (ImageView) contentView.findViewById(R.id.user_space_useravatar_bg1);
userAvatar2 = (RemoteImageView) contentView.findViewById(R.id.user_space_useravatar2);
userAvatar2.setOnClickListener(this);
userAvatarBg2 = (ImageView) contentView.findViewById(R.id.user_space_useravatar_bg2);
userAvatar3 = (RemoteImageView) contentView.findViewById(R.id.user_space_useravatar3);
userAvatar3.setOnClickListener(this);
userAvatarBg3 = (ImageView) contentView.findViewById(R.id.user_space_useravatar_bg3);
userAvatar4 = (RemoteImageView) contentView.findViewById(R.id.user_space_useravatar4);
userAvatar4.setOnClickListener(this);
userAvatarBg4 = (ImageView) contentView.findViewById(R.id.user_space_useravatar_bg4);
}
private void initUserIntegral() {
tvCreateAndExp = (TextView) contentView.findViewById(R.id.user_info_credit_and_experience_value);
tvTTCreateAndTTExp = (TextView) contentView.findViewById(R.id.user_info_ttcredit_and_ttenperience_value);
tvLevel = (TextView) contentView.findViewById(R.id.user_info_level_value);
upgrade = (Button) contentView.findViewById(R.id.user_info_upgrade);
upgrade.setOnClickListener(this);
}
private void initExchangeButton() {
btnAddFriend = (Button) contentView.findViewById(R.id.user_space_addfriend);
btnAddFriend.setOnClickListener(this);
btnExProfile = (Button) contentView.findViewById(R.id.user_space_exprofile);
btnExProfile.setOnClickListener(this);
btnExPhoto = (Button) contentView.findViewById(R.id.user_space_exphoto);
btnExPhoto.setOnClickListener(this);
btnBlacklist = (Button) contentView.findViewById(R.id.user_space_blacklist);
btnBlacklist.setOnClickListener(this);
}
private void initFeeds() {
btnNewsfeeds = (Button) contentView.findViewById(R.id.user_space_newsfeeds);
btnNewsfeeds.setOnClickListener(this);
btnBottlefeeds = (Button) contentView.findViewById(R.id.user_space_bottlefeeds);
btnBottlefeeds.setOnClickListener(this);
btnProfile = (Button) contentView.findViewById(R.id.user_space_profile);
btnProfile.setOnClickListener(this);
}
private void updateUI() {
if (entry == null) {
return;
}
info_visible = entry.getInfo_visible();
space_type = entry.getSpace_type();
((LinearLayout) contentView.findViewById(R.id.user_space_layout)).setVisibility(View.VISIBLE);
updateUserBaseInfo();
if (space_type != 3) {
updateRelation();
}
updateIntegral();
updateExchange();
updateFeeds();
updateAvatarList();
}
private void updateUserBaseInfo() {
titleText.setText(entry.getNickname());
nicknameView.setText(entry.getNickname());
if (entry.getSex() == 1) {
sexView.setBackgroundResource(R.drawable.male);
} else if (entry.getSex() == 2) {
sexView.setBackgroundResource(R.drawable.female);
}
if (TextUtil.notEmpty(entry.getMemo())) {
((TextView) contentView.findViewById(R.id.user_space_memo)).setVisibility(View.VISIBLE);
memoView.setText("-" + entry.getMemo());
} else {
((TextView) contentView.findViewById(R.id.user_space_memo)).setVisibility(View.GONE);
memoView.setVisibility(View.GONE);
}
if (TextUtil.notEmpty(entry.getCity()) && TextUtil.notEmpty(entry.getCountry())) {
addressView.setVisibility(View.VISIBLE);
if (AppContext.language == 1) {
addressView.setText(getString(R.string.user_from) + entry.getCountry() + " " + entry.getCity());
} else {
addressView.setText(getString(R.string.user_from) + entry.getCity() + " " + entry.getCountry());
}
} else {
addressView.setVisibility(View.GONE);
}
String html = "<font color=black>"+getString(R.string.user_info_doing)+"</font>";
doingView.setText(Html.fromHtml(html + TextUtil.htmlEncode(entry.getDoing())));
if (bitmap != null) {
avatarView.setImageBitmap(bitmap);
}
if (info_visible == 1) {
btnExchange.setVisibility(View.GONE);
avatarView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
byte[] tempBytes = null;
try {
tempBytes = ServiceUtils.BitmapTobytes(bitmap);
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(UserSpaceActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", entry.getAvatar());
bigPicIntent.putExtra("thumbnail", tempBytes);
startActivity(bigPicIntent);
}
});
} else {
btnExchange.setVisibility(View.VISIBLE);
}
String type = null;
if (space_type == 0) {
type = getString(R.string.user_space_friend);
type = getString(R.string.user_space_friend) + "(" + entry.getGroupname() + ")";
} else if (space_type == 1) {
type = getString(R.string.user_space_btfriend);
titleView.setCompoundDrawables(null, null, null, null);
} else if (space_type == 2) {
type = getString(R.string.user_space_stranger);
titleView.setCompoundDrawables(null, null, null, null);
} else {
type = getString(R.string.user_space_my);
titleView.setCompoundDrawables(null, null, null, null);
}
titleView.setText(type);
if (space_type == 3) {
editMemoView.setVisibility(View.GONE);
// settingView.setVisibility(View.GONE);
} else {
editMemoView.setVisibility(View.VISIBLE);
// settingView.setVisibility(View.VISIBLE);
}
}
private void updateRelation() {
if (entry.getRelation_twitter() != null && !entry.getRelation_twitter().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_twitter_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_twitter_textview)).setText(entry.getRelation_twitter());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_twitter_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_facebook() != null && !entry.getRelation_facebook().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_facebook_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_facebook_textview)).setText(entry.getRelation_facebook());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_facebook_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_sina() != null && !entry.getRelation_sina().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_weibo_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_weibo_textview)).setText(entry.getRelation_sina());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_weibo_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_tqq() != null && !entry.getRelation_tqq().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_tencent_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_tencent_textview)).setText(entry.getRelation_tqq());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_tencent_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_renren() != null && !entry.getRelation_renren().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_renren_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_renren_textview)).setText(entry.getRelation_renren());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_renren_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_douban() != null && !entry.getRelation_douban().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_douban_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_douban_textview)).setText(entry.getRelation_douban());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_douban_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_qq() != null && !entry.getRelation_qq().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_qq_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_qq_textview)).setText(entry.getRelation_qq());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_qq_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_schoolmate() != null && !entry.getRelation_schoolmate().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_school_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_school_textview)).setText(entry.getRelation_schoolmate());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_school_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_sameresidecity() != null && !entry.getRelation_sameresidecity().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_samecity_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_samecity_textview)).setText(entry.getRelation_sameresidecity());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_samecity_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_samebirthcity() != null && !entry.getRelation_samebirthcity().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_samebirthcity_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_samebirthcity_textview)).setText(entry.getRelation_samebirthcity());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_samebirthcity_layout)).setVisibility(View.GONE);
}
if (entry.getRelation_sameworkcity() != null && !entry.getRelation_sameworkcity().equals("")) {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_sameworkcity_layout)).setVisibility(View.VISIBLE);
((TextView) contentView.findViewById(R.id.user_space_relation_sameworkcity_textview)).setText(entry.getRelation_sameworkcity());
} else {
((LinearLayout) contentView.findViewById(R.id.user_space_relation_sameworkcity_layout)).setVisibility(View.GONE);
}
}
private void updateAvatarList() {
int size = 0;
if (avatarEntries != null && !avatarEntries.isEmpty()) {
size = avatarEntries.size();
contentView.findViewById(R.id.user_space_useravatars_layout).setVisibility(View.VISIBLE);
} else {
contentView.findViewById(R.id.user_space_useravatars_layout).setVisibility(View.GONE);
}
if (size >= 1) {
entry1 = avatarEntries.get(0);
if (entry1 != null) {
contentView.findViewById(R.id.user_space_useravatar1_layout).setVisibility(View.VISIBLE);
if (entry1.getAvatar_mode() == 1) {
userAvatar1.setImageUrl(entry1.getAvatar_middlepic());
userAvatarBg1.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry1.getAvatar_mode() == 2) {
userAvatar1.setImageUrl(entry1.getAvatar_middlepic());
userAvatarBg1.setBackgroundResource(R.drawable.frame_avatar2_bg);
} else if (entry1.getAvatar_mode() == 3) {
userAvatar1.setImageResource(R.drawable.frame_avatar3_lock);
userAvatarBg1.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry1.getAvatar_mode() == 4) {
userAvatar1.setImageResource(R.drawable.frame_avatar4_add);
userAvatarBg1.setBackgroundResource(R.drawable.frame_avatar1_bg);
}
}
} else {
contentView.findViewById(R.id.user_space_useravatar1_layout).setVisibility(View.INVISIBLE);
}
if (size >= 2) {
entry2 = avatarEntries.get(1);
if (entry2 != null) {
contentView.findViewById(R.id.user_space_useravatar2_layout).setVisibility(View.VISIBLE);
if (entry2.getAvatar_mode() == 1) {
userAvatar2.setImageUrl(entry2.getAvatar_middlepic());
userAvatarBg2.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry2.getAvatar_mode() == 2) {
userAvatar2.setImageUrl(entry2.getAvatar_middlepic());
userAvatarBg2.setBackgroundResource(R.drawable.frame_avatar2_bg);
} else if (entry2.getAvatar_mode() == 3) {
userAvatar2.setImageResource(R.drawable.frame_avatar3_lock);
userAvatarBg2.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry2.getAvatar_mode() == 4) {
userAvatar2.setImageResource(R.drawable.frame_avatar4_add);
userAvatarBg2.setBackgroundResource(R.drawable.frame_avatar1_bg);
}
}
} else {
contentView.findViewById(R.id.user_space_useravatar2_layout).setVisibility(View.INVISIBLE);
}
if (size >= 3) {
entry3 = avatarEntries.get(2);
if (entry3 != null) {
contentView.findViewById(R.id.user_space_useravatar3_layout).setVisibility(View.VISIBLE);
if (entry3.getAvatar_mode() == 1) {
userAvatar3.setImageUrl(entry3.getAvatar_middlepic());
userAvatarBg3.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry3.getAvatar_mode() == 2) {
userAvatar3.setImageUrl(entry3.getAvatar_middlepic());
userAvatarBg3.setBackgroundResource(R.drawable.frame_avatar2_bg);
} else if (entry3.getAvatar_mode() == 3) {
userAvatar3.setImageResource(R.drawable.frame_avatar3_lock);
userAvatarBg3.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry3.getAvatar_mode() == 4) {
userAvatar3.setImageResource(R.drawable.frame_avatar4_add);
userAvatarBg3.setBackgroundResource(R.drawable.frame_avatar1_bg);
}
}
} else {
contentView.findViewById(R.id.user_space_useravatar3_layout).setVisibility(View.INVISIBLE);
}
if (size == 4) {
entry4 = avatarEntries.get(3);
if (entry4 != null) {
contentView.findViewById(R.id.user_space_useravatar4_layout).setVisibility(View.VISIBLE);
if (entry4.getAvatar_mode() == 1) {
userAvatar4.setImageUrl(entry4.getAvatar_middlepic());
userAvatarBg4.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry4.getAvatar_mode() == 2) {
userAvatar4.setImageUrl(entry4.getAvatar_middlepic());
userAvatarBg4.setBackgroundResource(R.drawable.frame_avatar2_bg);
} else if (entry4.getAvatar_mode() == 3) {
userAvatar4.setImageResource(R.drawable.frame_avatar3_lock);
userAvatarBg4.setBackgroundResource(R.drawable.frame_avatar1_bg);
} else if (entry4.getAvatar_mode() == 4) {
userAvatar4.setImageResource(R.drawable.frame_avatar4_add);
userAvatarBg4.setBackgroundResource(R.drawable.frame_avatar1_bg);
}
}
} else {
contentView.findViewById(R.id.user_space_useravatar4_layout).setVisibility(View.INVISIBLE);
}
}
private void updateIntegral() {
if (entry == null) {
return;
}
try {
tvCreateAndExp.setText(entry.getCredit() + "/" + entry.getExp());
tvTTCreateAndTTExp.setText(entry.getTtcredit() + "/" + entry.getTtexp());
tvLevel.setText(entry.getLevel());
} catch (Exception e) {
e.printStackTrace();
}
}
private void updateExchange() {
if (entry == null) {
return;
}
if (space_type != 3) {
btnAddFriend.setVisibility(View.VISIBLE);
if (entry.getFriend_show() == 0) {
btnAddFriend.setVisibility(View.GONE);
} else if (entry.getFriend_show() == 1) {
btnAddFriend.setBackgroundResource(R.drawable.btn_blue_try);
btnAddFriend.setText(getString(R.string.user_space_bottle_addfriend));
} else if (entry.getFriend_show() == 2) {
btnAddFriend.setBackgroundResource(R.drawable.btn_red_try);
btnAddFriend.setText(getString(R.string.user_space_bottle_addfriend));
} else {
btnAddFriend.setBackgroundResource(R.drawable.btn_gray_try);
btnAddFriend.setText(getString(R.string.user_space_bottle_delfriend));
}
btnExPhoto.setVisibility(View.VISIBLE);
if (entry.getPicex_show() == 0) {
btnExPhoto.setVisibility(View.GONE);
} else if (entry.getPicex_show() == 1) {
btnExPhoto.setBackgroundResource(R.drawable.btn_blue_try);
} else {
btnExPhoto.setBackgroundResource(R.drawable.btn_red_try);
}
btnExProfile.setVisibility(View.VISIBLE);
if (entry.getInfoex_show() == 0) {
btnExProfile.setVisibility(View.GONE);
} else if (entry.getInfoex_show() == 1) {
btnExProfile.setVisibility(View.VISIBLE);
btnExProfile.setBackgroundResource(R.drawable.btn_blue_try);
} else {
btnExProfile.setBackgroundResource(R.drawable.btn_red_try);
}
btnBlacklist.setVisibility(View.VISIBLE);
if (entry.getBlacklist_show() == 0) {
btnBlacklist.setVisibility(View.GONE);
} else if (entry.getBlacklist_show() == 1) {
btnBlacklist.setVisibility(View.VISIBLE);
btnBlacklist.setBackgroundResource(R.drawable.btn_gray_try);
btnBlacklist.setText(getString(R.string.user_space_bottle_addblacklist));
} else {
btnBlacklist.setBackgroundResource(R.drawable.button_black);
btnBlacklist.setText(getString(R.string.user_space_bottle_delblacklist));
}
}
}
@SuppressLint("ResourceAsColor")
private void updateFeeds() {
bodyLayout.removeAllViews();
if (space_type == 0 || space_type == 3) {
btnNewsfeeds.setVisibility(View.VISIBLE);
} else {
btnNewsfeeds.setVisibility(View.GONE);
}
if (selectType == 0) {
btnNewsfeeds.setBackgroundResource(R.drawable.botton_white);
btnNewsfeeds.setTextColor(R.color.gray);
btnBottlefeeds.setBackgroundResource(0);
btnBottlefeeds.setTextColor(Color.WHITE);
btnProfile.setTextColor(Color.WHITE);
btnProfile.setBackgroundResource(0);
newsAdapter = new NewsFeedAdapter();
listView.setAdapter(newsAdapter);
} else if (selectType == 1) {
btnNewsfeeds.setTextColor(Color.WHITE);
btnNewsfeeds.setBackgroundResource(0);
btnBottlefeeds.setBackgroundResource(R.drawable.botton_white);
btnBottlefeeds.setTextColor(R.color.gray);
btnProfile.setTextColor(Color.WHITE);
btnProfile.setBackgroundResource(0);
bottlesAdapter = new BottlesFeedAdapter();
listView.setAdapter(bottlesAdapter);
} else {
listView.setAdapter(new ProfileAdapter());
btnNewsfeeds.setBackgroundResource(0);
btnNewsfeeds.setTextColor(Color.WHITE);
btnBottlefeeds.setTextColor(Color.WHITE);
btnBottlefeeds.setBackgroundResource(0);
btnProfile.setBackgroundResource(R.drawable.botton_white);
btnProfile.setTextColor(R.color.gray);
updateProfile();
}
}
private void updateProfile() {
View view = LayoutInflater.from(this).inflate(R.layout.user_info_detail, null);
TextView hometownView = (TextView) view.findViewById(R.id.user_info_hometown);
TextView workcityView = (TextView) view.findViewById(R.id.user_info_workcity);
TextView residecityView = (TextView) view.findViewById(R.id.user_info_reside_city);
TextView birthdayView = (TextView) view.findViewById(R.id.user_info_birthday);
TextView bloodtypeView = (TextView) view.findViewById(R.id.user_info_blood_type);
TextView statusView = (TextView) view.findViewById(R.id.user_info_status);
TextView educationView = (TextView) view.findViewById(R.id.user_info_education_status);
TextView workView = (TextView) view.findViewById(R.id.user_info_company);
TextView schoolView = (TextView) view.findViewById(R.id.user_info_school);
TextView careerView = (TextView) view.findViewById(R.id.user_info_career);
btnInfoExchange = (Button) view.findViewById(R.id.user_info_excange);
btnInfoExchange.setOnClickListener(this);
if (profileEntry == null) {
return;
}
if (TextUtil.notEmpty(profileEntry.getResidecity())) {
((LinearLayout) view.findViewById(R.id.user_info_reside_city_layout)).setVisibility(View.VISIBLE);
residecityView.setText(profileEntry.getResidecity());
} else {
((LinearLayout) view.findViewById(R.id.user_info_reside_city_layout)).setVisibility(View.GONE);
}
if (profileEntry.getInfo_visible() == 0) {
btnInfoExchange.setVisibility(View.VISIBLE);
view.findViewById(R.id.user_info_detail_layout2).setVisibility(View.GONE);
} else {
btnInfoExchange.setVisibility(View.GONE);
view.findViewById(R.id.user_info_detail_layout2).setVisibility(View.VISIBLE);
if (TextUtil.notEmpty(profileEntry.getWorkcity())) {
((LinearLayout) view.findViewById(R.id.user_info_workcity_layout)).setVisibility(View.VISIBLE);
workcityView.setText(profileEntry.getWorkcity());
} else {
((LinearLayout) view.findViewById(R.id.user_info_workcity_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getHometown())) {
((LinearLayout) view.findViewById(R.id.user_info_hometown_layout)).setVisibility(View.VISIBLE);
hometownView.setText(profileEntry.getHometown());
} else {
((LinearLayout) view.findViewById(R.id.user_info_hometown_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getBirthday())) {
((LinearLayout) view.findViewById(R.id.user_info_birthday_layout)).setVisibility(View.VISIBLE);
birthdayView.setText(profileEntry.getBirthday());
} else {
((LinearLayout) view.findViewById(R.id.user_info_birthday_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getBlood())) {
((LinearLayout) view.findViewById(R.id.user_info_blood_type_layout)).setVisibility(View.VISIBLE);
bloodtypeView.setText(profileEntry.getBlood());
} else {
((LinearLayout) view.findViewById(R.id.user_info_blood_type_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getMarriagestatus())) {
((LinearLayout) view.findViewById(R.id.user_info_status_layout)).setVisibility(View.VISIBLE);
statusView.setText(profileEntry.getMarriagestatus());
} else {
((LinearLayout) view.findViewById(R.id.user_info_status_layout)).setVisibility(View.GONE);
}
// if (TextUtil.notEmpty(profileEntry.getResidecity())) {
// ((LinearLayout) findViewById(R.id.user_info_reside_city_layout)).setVisibility(View.VISIBLE);
// residecityView.setText(profileEntry.getResidecity());
// } else {
// ((LinearLayout) view.findViewById(R.id.user_info_reside_city_layout)).setVisibility(View.GONE);
// }
if (TextUtil.notEmpty(profileEntry.getEdustatus())) {
((LinearLayout) view.findViewById(R.id.user_info_education_status_layout)).setVisibility(View.VISIBLE);
educationView.setText(profileEntry.getEdustatus());
} else {
((LinearLayout) view.findViewById(R.id.user_info_education_status_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getCompany())) {
((LinearLayout) view.findViewById(R.id.user_info_company_layout)).setVisibility(View.VISIBLE);
workView.setText(profileEntry.getCompany());
} else {
((LinearLayout) view.findViewById(R.id.user_info_company_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getSchool())) {
((LinearLayout) view.findViewById(R.id.user_info_school_layout)).setVisibility(View.VISIBLE);
schoolView.setText(profileEntry.getSchool());
} else {
((LinearLayout) view.findViewById(R.id.user_info_school_layout)).setVisibility(View.GONE);
}
if (TextUtil.notEmpty(profileEntry.getCareer())) {
((LinearLayout) view.findViewById(R.id.user_info_career_layout)).setVisibility(View.VISIBLE);
careerView.setText(profileEntry.getCareer());
} else {
((LinearLayout) view.findViewById(R.id.user_info_career_layout)).setVisibility(View.GONE);
}
}
bodyLayout.addView(view);
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == homeView) {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
} else if (v == editMemoView) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.EDIT_MEMO);
extras.putString("memo", entry.getMemo());
extras.putInt("ouid", ouid);
intent.putExtras(extras);
startActivity(intent);
} else if (v == titleView) {
if (space_type == 0) {
doSelectGroupAction();
}
} else if (v == btnNewsfeeds) {
selectType = 0;
if (friendFeedList == null) {
UICore.eventTask(this, this, get_newsfeeds, "", null);
} else {
updateFeeds();
}
} else if (v == btnBottlefeeds) {
selectType = 1;
if (bottleFeedList == null) {
UICore.eventTask(this, this, get_bottlefeeds, "", null);
} else {
updateFeeds();
}
} else if (v == btnProfile) {
selectType = 2;
if (profileEntry == null) {
UICore.eventTask(this, this, get_profile, "", null);
} else {
updateFeeds();
}
} else if (v == menuView) {
doBlueJuhuaMenuAction();
}
// else if (v == settingView) {
// Intent intentSetting = new Intent(this, SettingActivity.class);
// startActivity(intentSetting);
// }
else if (v == btnExchange) {
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_INFOEX);
extras.putString("reply_infoex_type", "apply");
extras.putInt("ouid", ouid);
intent.putExtras(extras);
startActivity(intent);
}
} else if (v == btnInfoExchange) {
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_INFOEX);
extras.putString("reply_infoex_type", "apply");
extras.putInt("ouid", ouid);
intent.putExtras(extras);
startActivity(intent);
}
} else if (v == avatarView) {
if (entry.getInfo_visible() == 1) {
byte[] tempBytes = null;
try {
tempBytes = ServiceUtils.BitmapTobytes(bitmap);
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(this,PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", entry.getAvatar());
bigPicIntent.putExtra("thumbnail", tempBytes);
startActivity(bigPicIntent);
}
} else if (v == btnAddFriend) {
// if (entry.getFriend_show() == 1) {
// Intent intent = new Intent(this, ExpandEditActivity.class);
// Bundle extras = new Bundle();
// extras.putString("from_type", AppContext.APPLY_FRIEND);
// extras.putInt("ouid", ouid);
// intent.putExtras(extras);
// startActivity(intent);
// } else if (entry.getFriend_show() == 2) {
// refresh_type = 1;
// handler.sendEmptyMessage(add_friend_success);
// } else if (entry.getFriend_show() == 3) {
// showChoseMes(getString(R.string.user_space_delete_from_tips), cancel_friend);
// }
if (entry.getFriend_show() == 1 || entry.getFriend_show() == 2) {
UICore.eventTask(this, this, EXEU_CHECK_FRIEND, "", null);
} else {
showChoseMes(getString(R.string.user_space_delete_from_tips), cancel_friend);
}
} else if (v == btnExProfile) {
refresh_type = 1;
if (entry.getInfoex_show() == 1) {
Intent intent = new Intent(this, ExchangeInfoDetailActivity .class);
intent.putExtra("ouid", ouid);
intent.putExtra("page", 1);
startActivity(intent);
} else if (entry.getInfoex_show() == 2) {
Intent intentProfile = new Intent(this, ExpandEditActivity.class);
Bundle bundleProfile = new Bundle();
bundleProfile.putString("from_type", AppContext.REPLY_INFOEX);
bundleProfile.putInt("ouid", ouid);
bundleProfile.putString("reply_infoex_type", "apply");
intentProfile.putExtras(bundleProfile);
startActivity(intentProfile);
}
} else if (v == btnExPhoto) {
refresh_type = 1;
if (entry.getPicex_show() == 1) {
Intent intent = new Intent(this, ExchangePicDetailActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("page", 1);
startActivity(intent);
} else if (entry.getPicex_show() == 2) {
Intent intentPhoto = new Intent(this, ExpandEditActivity.class);
Bundle bundlePhoto = new Bundle();
bundlePhoto.putString("from_type", AppContext.APPLY_PICEX);
bundlePhoto.putInt("ouid", ouid);
intentPhoto.putExtras(bundlePhoto);
startActivity(intentPhoto);
}
} else if (v == btnBlacklist) {
refresh_type = 1;
if (entry.getBlacklist_show() == 1) {
UICore.eventTask(this, this, set_blacklist, "", 1);
} else if (entry.getBlacklist_show() == 2) {
UICore.eventTask(this, this, set_blacklist, "", 0);
}
} else if (v == userAvatar1) {
clickOnAvatarListEvent(entry1);
} else if (v == userAvatar2) {
clickOnAvatarListEvent(entry2);
} else if (v == userAvatar3) {
clickOnAvatarListEvent(entry3);
} else if (v == userAvatar4) {
clickOnAvatarListEvent(entry4);
} else if (v == upgrade) {
Intent intent = new Intent(this, BtFriendLevelActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
}
}
private void clickOnAvatarListEvent(AvatarEntry avatarEntry) {
refresh_type = 2;
if (space_type == 3) {
String choices[] = null;
if (avatarEntry != null && avatarEntry.getAvatar_mode() == 1) {
choices = new String[3];
choices[0] = getString(R.string.user_space_bottle_view_avatar);
choices[1] = getString(R.string.expand_edit_take_photo); // 拍照
choices[2] = getString(R.string.expand_edit_choose_photo); // 从相册中选择
} else if (avatarEntry != null && avatarEntry.getAvatar_mode() == 2){
choices = new String[4];
choices[0] = getString(R.string.user_space_bottle_view_avatar);
choices[1] = getString(R.string.user_space_bottle_set_default_avatar);
choices[2] = getString(R.string.expand_edit_take_photo); // 拍照
choices[3] = getString(R.string.expand_edit_choose_photo); // 从相册中选择
} else if (avatarEntry != null && avatarEntry.getAvatar_mode() == 4) {
choices = new String[2];
choices[0] = getString(R.string.expand_edit_take_photo);
choices[1] = getString(R.string.expand_edit_choose_photo);
} else {
choices = new String[2];
choices[0] = getString(R.string.expand_edit_take_photo);
choices[1] = getString(R.string.expand_edit_choose_photo);
}
chooseAction(choices, avatarEntry);
} else {
if (avatarEntry != null && avatarEntry.getAvatar_mode() == 3) {
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_INFOEX);
extras.putString("reply_infoex_type", "apply");
extras.putInt("ouid", ouid);
intent.putExtras(extras);
startActivity(intent);
}
} else {
gotoPhotoDetailActivity(avatarEntry);
}
}
}
private void gotoPhotoDetailActivity(AvatarEntry avatarEntry) {
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(avatarEntry.getAvatar_middlepic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.UserAvatarIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", avatarEntry.getAvatar_bigpic());
bigPicIntent.putExtra("thumbnail", tempBytes);
startActivity(bigPicIntent);
}
/***
* 好友申请前检测接口
*/
private void checkFriendApply() {
StringBuffer url = new StringBuffer(UrlConfig.check_friendapply);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
ServiceUtils.dout("CheckFriendApply url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("CheckFriendApply results:" + results.toString());
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int authok = resultObj.getInt("authok");
String errmsg = resultObj.getString("errmsg");
int check_result = resultObj.getInt("check_result");
String msg = resultObj.getString("msg");
if (authok == 1) {
Message message = null;
switch (check_result) {
case 0:
message = handler.obtainMessage(EXEU_CAN_NOT_ADD_FRIEND, msg);
handler.sendMessage(message);
break;
case 1:
message = handler.obtainMessage(EXEU_CHECK_FRIEND_SUCCESS, msg);
handler.sendMessage(message);
break;
case 2:
message = handler.obtainMessage(EXEU_ALLOW_ADD_FRIEND);
handler.sendMessage(message);
break;
default:
break;
}
} else {
Message message = handler.obtainMessage(EXEU_CHECK_FRIEND_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void cancelFriend() {
refresh_type = 1;
String url = UrlConfig.cancel_friend;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("ouid", String.valueOf(ouid));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("results");
if (resultobj.getInt("success") == 0) {
String errormsg = resultobj.getString("errmsg");
Message msg = Message.obtain(handler, error, errormsg);
handler.sendMessage(msg);
} else {
String successmsg = resultobj.getString("successmsg");
Message msg = Message.obtain(handler, cancel_friend_success, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setFriendGroup() {
String url = UrlConfig.set_friendgroup;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("ouid", String.valueOf(ouid));
paramsMap.put("groupid", String.valueOf(groupId));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("results");
if (resultobj.getInt("success") == 0) {
String errormsg = resultobj.getString("errmsg");
Message msg = Message.obtain(handler, error, errormsg);
handler.sendMessage(msg);
} else {
String successmsg = resultobj.getString("successmsg");
Message msg = Message.obtain(handler, set_friend_group_success, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setBlacklist(int optype) {
String url = UrlConfig.set_blacklist;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("ouid", String.valueOf(ouid));
paramsMap.put("optype", String.valueOf(optype));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("results");
if (resultobj.getInt("success") == 0) {
String errormsg = resultobj.getString("errmsg");
Message msg = Message.obtain(handler, error, errormsg);
handler.sendMessage(msg);
} else {
String successmsg = resultobj.getString("successmsg");
Message msg = Message.obtain(handler, set_blacklist, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setDefaultAvatar(int avatarid) {
String url = UrlConfig.set_default_avatar;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("ouid", String.valueOf(ouid));
paramsMap.put("avatarid", String.valueOf(avatarid));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("results");
if (resultobj.getInt("success") == 0) {
String errormsg = resultobj.getString("errmsg");
Message msg = Message.obtain(handler, error, errormsg);
handler.sendMessage(msg);
} else {
String successmsg = resultobj.getString("successmsg");
Message msg = Message.obtain(handler, set_default_avatar, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setAvatar() {
String url = UrlConfig.set_avatar;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("avatarid", String.valueOf(avatarid));
try {
HashMap<String, File> filesMap = new HashMap<String, File>();
if (picFile != null) {
filesMap.put("pic", picFile);
}
String result = HttpUtils.post(url, paramsMap, filesMap);
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_avatar, successmsg);
handler.sendMessage(msg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == cancel_friend) {
UICore.eventTask(this, this, cancel_friend, "cancel_friend", null);
} else if (what == exchange_profile) {
if (entry.getInfoex_show() == 1) {
Intent intent = new Intent(this, ExchangeInfoDetailActivity .class);
intent.putExtra("ouid", ouid);
intent.putExtra("page", 1);
startActivity(intent);
} else if (entry.getInfoex_show() == 2) {
Intent intentProfile = new Intent(this, ExpandEditActivity.class);
Bundle bundleProfile = new Bundle();
bundleProfile.putString("from_type", AppContext.REPLY_INFOEX);
bundleProfile.putInt("ouid", ouid);
bundleProfile.putString("reply_infoex_type", "apply");
intentProfile.putExtras(bundleProfile);
startActivity(intentProfile);
}
} else if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
}
}
/**
* 选择菜单 弹出框
* @param choices 显示的菜单
*/
public void chooseAction(String[] choices, final AvatarEntry avatarEntry) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doSelectChooseEvent(which, avatarEntry);
}
});
builder.create().show();
}
public void doSelectChooseEvent(int which, AvatarEntry avatarEntry) {
if (avatarEntry == null) {
return;
} else {
avatarid = avatarEntry.getAvatarid();
if (avatarEntry.getAvatar_mode() == 1) {
switch (which) {
case 0:
gotoPhotoDetailActivity(avatarEntry);
break;
case 1:
doTakePhoto();
break;
case 2:
doPickPhotoFromGallery();
break;
default:
break;
}
} else if (avatarEntry.getAvatar_mode() == 2) {
switch (which) {
case 0:
gotoPhotoDetailActivity(avatarEntry);
break;
case 1:
UICore.eventTask(this, this, set_default_avatar, "", avatarEntry.getAvatarid());
break;
case 2:
doTakePhoto();
break;
case 3:
doPickPhotoFromGallery();
break;
default:
break;
}
} else if (avatarEntry.getAvatar_mode() == 4) {
if (which == 0) {
doTakePhoto();
} else {
doPickPhotoFromGallery();
}
}
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case get_space_info:
getSpaceInfo();
if (entry != null) {
if (entry.getSpace_type() == 0 || entry.getSpace_type() == 3) {
selectType = 0;
} else {
selectType = 1;
}
if (selectType == 0) {
newsfeedsPage = 1;
getFriendFeeds();
} else if (selectType == 1) {
bottlefeedsPage = 1;
getBottleFeeds();
} else {
getUserProfile();
}
handler.sendEmptyMessage(get_space_info_success);
}
break;
case cancel_friend:
cancelFriend();
break;
case set_friend_group:
setFriendGroup();
break;
case get_more_data:
if (selectType == 0) {
newsfeedsPage++;
getMoreFriendFeeds();
} else if (selectType == 1) {
bottlefeedsPage++;
getMoreBottleFeeds();
}
break;
case get_newsfeeds:
getFriendFeeds();
handler.sendEmptyMessage(get_newsfeeds);
break;
case get_bottlefeeds:
getBottleFeeds();
handler.sendEmptyMessage(get_bottlefeeds);
break;
case get_profile:
getUserProfile();
handler.sendEmptyMessage(get_profile);
break;
case refresh_space_info:
getSpaceInfo();
if (selectType == 0) {
newsfeedsPage = 1;
getFriendFeeds();
} else if (selectType == 1) {
bottlefeedsPage = 1;
getBottleFeeds();
} else {
getUserProfile();
}
handler.sendEmptyMessage(get_space_info_success);
break;
case set_blacklist:
try {
int optype = Integer.parseInt(obj.toString());
setBlacklist(optype);
} catch (Exception e) {
e.printStackTrace();
}
break;
case set_avatar:
try {
setAvatar();
} catch (Exception e) {
e.printStackTrace();
}
break;
case set_default_avatar:
try {
setDefaultAvatar(Integer.parseInt(obj.toString()));
} catch (Exception e) {
e.printStackTrace();
}
break;
case EXEU_CHECK_FRIEND:
checkFriendApply();
break;
default:
break;
}
}
private void getSpaceInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_space_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
SpaceInfo info = gson.fromJson(result, SpaceInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
entry = info.getSpace_info();
avatarEntries = entry.getAvatars_list();
groupList = info.getGroups_list();
groupNames = new String[groupList.size() + 1];
groupNames[0] = getString(R.string.setting_group);
for (int i = 1;i < groupList.size() + 1;i++) {
groupNames[i] = groupList.get(i - 1).getGroupname();
}
bitmap = HttpUtils.getBitmapFromUrl(UserSpaceActivity.this, entry.getAvatar());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getUserProfile() {
StringBuffer url = new StringBuffer(UrlConfig.get_user_profile);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
ProfileInfo info = gson.fromJson(result, ProfileInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
profileEntry = info.getProfile_info();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getBottleFeeds() {
StringBuffer url = new StringBuffer(UrlConfig.get_user_btfeedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + bottlefeedsPage);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
BottleFeedInfo info = gson.fromJson(result, BottleFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
bottleFeedList = info.getBtfeeds_list();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getFriendFeeds() {
if (AppContext.getInstance().getLogin_uid() == ouid) {
ouid = AppContext.getInstance().getLogin_uid();
}
StringBuffer url = new StringBuffer(UrlConfig.get_user_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + newsfeedsPage);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
FriendFeedInfo info = gson.fromJson(result, FriendFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
friendFeedList = info.getFeeds_list();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getMoreBottleFeeds() {
StringBuffer url = new StringBuffer(UrlConfig.get_user_btfeedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + bottlefeedsPage);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
BottleFeedInfo info = gson.fromJson(result, BottleFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
moreBottleFeedList = info.getBtfeeds_list();
if (moreBottleFeedList != null && !moreBottleFeedList.isEmpty()) {
bottleFeedList.addAll(moreBottleFeedList);
}
handler.sendEmptyMessage(get_more_data);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getMoreFriendFeeds() {
StringBuffer url = new StringBuffer(UrlConfig.get_user_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + newsfeedsPage);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
FriendFeedInfo info = gson.fromJson(result, FriendFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
moreFriendFeedList = info.getFeeds_list();
if (moreFriendFeedList != null && !moreFriendFeedList.isEmpty()) {
friendFeedList.addAll(moreFriendFeedList);
}
handler.sendEmptyMessage(get_more_data);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void doSelectGroupAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, groupNames);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(getString(R.string.choose_friend_select_group));
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
groupItem = which;
if (which != 0) {
groupId = groupList.get(which - 1).getGroupid();
UICore.eventTask(UserSpaceActivity.this,
UserSpaceActivity.this, set_friend_group, "set_friend_group", null);
} else {
Intent intent = new Intent(UserSpaceActivity.this, ManagerGroupActivity.class);
startActivity(intent);
}
}
});
builder.setNegativeButton(cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case error:
onToast((String) msg.obj);
break;
case get_space_info_success:
updateUI();
listView.onRefreshComplete();
break;
case set_friend_group_success:
onToast((String) msg.obj);
titleView.setText(getString(R.string.user_space_friend) + "(" + groupNames[groupItem] + ")");
break;
case get_more_data:
loadMoreView.setVisibility(View.GONE);
// progressBar.setVisibility(View.GONE);
// loadMoreView.setText(getString(R.string.more_data));
if (selectType == 0) {
newsAdapter.notifyDataSetChanged();
listView.setSelection(newsAdapter.getCount() - count);
} else if (selectType == 1) {
bottlesAdapter.notifyDataSetChanged();
listView.setSelection(bottlesAdapter.getCount() - count);
}
break;
case cancel_friend_success:
onToast((String) msg.obj);
UICore.eventTask(this, this, refresh_space_info, "get_space_info", null);
break;
case add_friend_success:
UICore.eventTask(this, this, refresh_space_info, "get_space_info", null);
break;
case check_friend_error:
onToast((String) msg.obj);
break;
case refresh_space_info:
if (refresh_type == 1) {
updateExchange();
} else if (refresh_type == 2) {
updateAvatarList();
}
break;
case set_blacklist:
onToast((String) msg.obj);
UICore.eventTask(this, this, refresh_space_info, "get_space_info", null);
break;
case set_avatar:
onToast((String) msg.obj);
UICore.eventTask(this, this, get_space_info, "get_space_info", null);
break;
case view_album_error:
onToast(getString(R.string.exchange_feed_invisible_tips));
break;
case user_baseinfo_notfull:
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
showChoseMes(userEntry.getBasicinfo_tip(), complete_info);
break;
case set_default_avatar:
onToast((String) msg.obj);
UICore.eventTask(this, this, get_space_info, "get_space_info", null);
break;
case get_newsfeeds:
updateFeeds();
break;
case get_bottlefeeds:
updateFeeds();
break;
case get_profile:
updateFeeds();
break;
case EXEU_CHECK_FRIEND_FAILED:
onToast((String) msg.obj);
break;
case EXEU_CAN_NOT_ADD_FRIEND:
onToast((String) msg.obj);
break;
case EXEU_CHECK_FRIEND_SUCCESS:
onToast((String) msg.obj);
Intent userIntent = new Intent(this, UserSpaceActivity.class);
userIntent.putExtra("ouid", ouid);
startActivity(userIntent);
break;
case EXEU_ALLOW_ADD_FRIEND:
Intent applyIntent = new Intent(this, ExpandEditActivity.class);
Bundle bundleFriend = new Bundle();
bundleFriend.putString("from_type", AppContext.APPLY_FRIEND);
bundleFriend.putInt("ouid", ouid);
applyIntent.putExtras(bundleFriend);
startActivity(applyIntent);
break;
default:
break;
}
return false;
}
// public class NewsFeedsView extends LinearLayout {
//
// private View convertView;
// private FriendFeedEntry entry;
// private String choices[];
//
// public NewsFeedsView(Context context, FriendFeedEntry entry) {
// super(context);
// this.entry = entry;
// initWidget();
// addView(convertView);
// setOrientation(LinearLayout.VERTICAL);
// LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
// params.topMargin = 5;
// ImageView image = new ImageView(context);
// image.setBackgroundResource(R.drawable.line_gray);
// addView(image);
// }
//
// public NewsFeedsView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// private void initWidget() {
// try {
// convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.friend_feed_listitem, null);
// TextView content = (TextView) convertView.findViewById(R.id.feed_content);
// TextView timeView = (TextView) convertView.findViewById(R.id.feed_time);
// RemoteImageView avatar = (RemoteImageView) convertView.findViewById(R.id.avatar);
// RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.feed_image);
// ((ImageView) convertView.findViewById(R.id.iv_white)).setVisibility(View.GONE);
// if (entry != null) {
// avatar.setDefaultImage(R.drawable.avatar_default_big);
// avatar.setImagePath(entry.getFeed_avatar(), AppContext.UserAvatarIcon);
// String nickname = "<font color=#419AD9>"+entry.getFeed_nickname()+"</font>";
// content.setText(Html.fromHtml(nickname + " " + entry.getFeed_content()));
// timeView.setText((!TextUtils.isEmpty(entry.getFeed_time()))?("#"+entry.getFeed_time()):"");
// this.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// if (TextUtil.notEmpty(entry.getFeed_smallpic())) {
// if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
// choices = new String[2];
// choices[0] = getString(R.string.user_space_bottle_view_photo);
// choices[1] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
// chooseAction(choices, entry);
// }
// } else {
// if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
// choices = new String[1];
// choices[0] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
// chooseAction(choices, entry);
// }
// }
// }
// });
// if (TextUtil.notEmpty(entry.getFeed_smallpic())) {
// image.setDefaultImage(R.drawable.album_nophoto);
// image.setImagePath(entry.getFeed_smallpic(), AppContext.BottleTimelineIcon);
// image.setVisibility(View.VISIBLE);
// ((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.VISIBLE);
// } else {
// ((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.GONE);
// }
// avatar.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// Intent spaceIntent = new Intent(UserSpaceActivity.this, UserSpaceActivity.class);
// spaceIntent.putExtra("ouid", entry.getFeed_uid());
// startActivity(spaceIntent);
// }
// });
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
//
// }
public class NewsFeedAdapter extends BaseAdapter {
@Override
public int getCount() {
return friendFeedList == null ? 0 : friendFeedList.size();
}
@Override
public Object getItem(int position) {
return friendFeedList == null ? null : friendFeedList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// if (position == getCount() - 1) {
// View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.listfooter_more, null);
//// progressBar = (ProgressBar) view.findViewById(R.id.pull_to_refresh_progress);
// loadMoreView = (TextView) view.findViewById(R.id.load_more);
// if (getCount() >= count) {
// view.setVisibility(View.VISIBLE);
// } else {
// view.setVisibility(View.INVISIBLE);
// }
// return view;
// }
NewsFeedViewHolder holder = null;
if (convertView != null && convertView.getId() == R.id.friend_feed_listitem_layout) {
holder = (NewsFeedViewHolder) convertView.getTag();
} else {
holder = new NewsFeedViewHolder();
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.friend_feed_listitem, null);
holder.content = (TextView) convertView.findViewById(R.id.feed_content);
holder.timeView = (TextView) convertView.findViewById(R.id.feed_time);
holder.avatar = (RemoteImageView) convertView.findViewById(R.id.avatar);
holder.image = (RemoteImageView) convertView.findViewById(R.id.feed_image);
convertView.setTag(holder);
}
try {
final FriendFeedEntry entry = friendFeedList.get(position);
if (entry != null) {
holder.avatar.setDefaultImage(R.drawable.avatar_default_big);
holder.avatar.setImagePath(entry.getFeed_avatar());
String nickname = "<font color=#419AD9>"+entry.getFeed_nickname()+"</font>";
holder.content.setText(Html.fromHtml(nickname + " " + entry.getFeed_content()));
holder.timeView.setText((!TextUtils.isEmpty(entry.getFeed_time()))?("#"+entry.getFeed_time()):"");
if (TextUtil.notEmpty(entry.getFeed_smallpic())) {
loader.DisplayImage(entry.getFeed_smallpic(), holder.image, R.drawable.album_nophoto);
holder.image.setVisibility(View.VISIBLE);
((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.VISIBLE);
} else {
((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.GONE);
}
holder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(UserSpaceActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", entry.getFeed_uid());
startActivity(spaceIntent);
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
return convertView;
}
}
public static class NewsFeedViewHolder {
TextView content;
TextView timeView;
RemoteImageView avatar;
RemoteImageView image;
}
// public class BottleFeedsView extends LinearLayout {
//
// private View convertView;
// private SpaceBottleFeedEntry entry;
//
// public BottleFeedsView(Context context, SpaceBottleFeedEntry entry) {
// super(context);
// this.entry = entry;
// initWidget();
// setOrientation(LinearLayout.VERTICAL);
// addView(convertView);
// LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
// params.topMargin = 5;
// ImageView image = new ImageView(context);
// image.setBackgroundResource(R.drawable.line_gray);
// addView(image);
// }
//
// public BottleFeedsView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// private void initWidget() {
// try {
// convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.bottle_feed_listitem, null);
// TextView content = (TextView) convertView.findViewById(R.id.feed_content);
// TextView time_location = (TextView) convertView.findViewById(R.id.feed_time_location);
// RemoteImageView avatar = (RemoteImageView) convertView.findViewById(R.id.avatar);
// ((ImageView) convertView.findViewById(R.id.iv_white)).setVisibility(View.GONE);
// if (entry != null) {
// avatar.setDefaultImage(R.drawable.avatar_default_big);
// avatar.setImagePath(entry.getBtfeed_avatar(), AppContext.UserAvatarIcon);
// String nickname = "<font color=#666666>"+entry.getBtfeed_nickname()+"</font>";
// content.setText(Html.fromHtml(nickname + " " + entry.getBtfeed_content()));
// String time = (!TextUtils.isEmpty(entry.getBtfeed_time()))?("#"+entry.getBtfeed_time()):"";
// String location = (!TextUtils.isEmpty(entry.getBtfeed_location()))?("@"+entry.getBtfeed_location()):"";
// time_location.setText(Html.fromHtml(time + " " + location));
// }
// convertView.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(UserSpaceActivity.this, BottleSingleActivity.class);
// intent.putExtra("btid", entry.getBtid());
// startActivity(intent);
// }
// });
// avatar.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// Intent spaceIntent = new Intent(UserSpaceActivity.this, UserSpaceActivity.class);
// spaceIntent.putExtra("ouid", entry.getBtfeed_uid());
// startActivity(spaceIntent);
// }
// });
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// }
public class BottlesFeedAdapter extends BaseAdapter {
@Override
public int getCount() {
return bottleFeedList == null ? 0 : bottleFeedList.size();
}
@Override
public Object getItem(int position) {
return bottleFeedList == null ? 0 : bottleFeedList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// if (position == getCount() - 1) {
// View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.listfooter_more, null);
// progressBar = (ProgressBar) view.findViewById(R.id.pull_to_refresh_progress);
// loadMoreView = (TextView) view.findViewById(R.id.load_more);
// if (getCount() >= count) {
// view.setVisibility(View.VISIBLE);
// } else {
// view.setVisibility(View.INVISIBLE);
// }
// return view;
// }
BottlesFeedViewHolder holder = null;
if (convertView != null && convertView.getId() == R.id.bottle_feed_listitem_layout) {
holder = (BottlesFeedViewHolder) convertView.getTag();
} else {
holder = new BottlesFeedViewHolder();
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.bottle_feed_listitem, null);
holder.content = (TextView) convertView.findViewById(R.id.feed_content);
holder.time_location = (TextView) convertView.findViewById(R.id.feed_time_location);
holder.avatar = (RemoteImageView) convertView.findViewById(R.id.avatar);
convertView.setTag(holder);
}
try {
final SpaceBottleFeedEntry entry = bottleFeedList.get(position);
if (entry != null) {
holder.avatar.setDefaultImage(R.drawable.avatar_default_big);
holder.avatar.setImagePath(entry.getBtfeed_avatar());
String nickname = "<font color=#666666>"+entry.getBtfeed_nickname()+"</font>";
holder.content.setText(Html.fromHtml(nickname + " " + entry.getBtfeed_content()));
String time = (!TextUtils.isEmpty(entry.getBtfeed_time()))?("#"+entry.getBtfeed_time()):"";
String location = (!TextUtils.isEmpty(entry.getBtfeed_location()))?("@"+entry.getBtfeed_location()):"";
holder.time_location.setText(Html.fromHtml(time + " " + location));
}
holder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(UserSpaceActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", entry.getBtfeed_uid());
startActivity(spaceIntent);
}
});
} catch (Exception e) {
e.printStackTrace();
}
return convertView;
}
}
public static class BottlesFeedViewHolder {
TextView content;
TextView time_location;
RemoteImageView avatar;
}
public class ProfileAdapter extends BaseAdapter {
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return convertView;
}
}
/**
* 拍照获取图片
*
*/
protected void doTakePhoto() {
try {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
Uri pictureUri = Uri.fromFile(picFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
startActivityForResult(cameraIntent, activity_result_camara_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
/**
* 从本地手机中选择图片
*/
// private void doSelectImageFromLoacal(){
// Intent localIntent = new Intent();
// localIntent.setType("image/*");
// localIntent.setAction("android.intent.action.GET_CONTENT");
// Intent localIntent2 = Intent.createChooser(localIntent, getString(R.string.expand_edit_choose_photo));
// startActivityForResult(localIntent2, activity_result_pick_with_data);
// }
// 封装请求Gallery的intent
public Intent getPhotoPickIntent() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
// 请求Gallery程序
protected void doPickPhotoFromGallery() {
try {
// Launch picker to choose photo for selected contact
final Intent intent = getPhotoPickIntent();
startActivityForResult(intent, activity_result_pick_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
protected void doCropPhoto(File f) {
try {
// 启动gallery去剪辑这个照片
final Intent intent = getCropImageIntent(Uri.fromFile(f));
startActivityForResult(intent, activity_result_pick_with_data);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Constructs an intent for image cropping. 调用图片剪辑程序
*/
public Intent getCropImageIntent(Uri photoUri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap oldBitmap = bitMap;
switch (requestCode) {
case activity_result_pick_with_data: //从本地选择图片
if (data == null) {
return;
}
bitMap = data.getParcelableExtra("data");
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileOutputStream ous = new FileOutputStream(picFile);
bitMap.compress(Bitmap.CompressFormat.JPEG, 100, ous);
if ( !Utility.isExternalStorageAvilable() ) {
return;
}
Uri fileUri = Uri.fromFile(picFile);
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_AVATAR );
newIntent.setData( fileUri );
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + picFile.getAbsolutePath() ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
startActivityForResult(newIntent, activity_result_aviary );
} catch (Exception e) {
e.printStackTrace();
}
break;
case activity_result_camara_with_data: //拍照
if (picFile == null) {
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFileDir, "upload.jpeg");
}
doCropPhoto(picFile);
break;
case activity_result_aviary:
if (resultCode == RESULT_OK) {
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileInputStream in = new FileInputStream(picFile);
BitmapFactory.Options options1 = new BitmapFactory.Options();
options1.inPurgeable = true;
options1.inInputShareable = true;
options1.inSampleSize = 2;
try {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
} catch (Exception ex) {
ex.printStackTrace();
}
WeakReference<Bitmap> bitmapResult = new WeakReference<Bitmap>(BitmapFactory
.decodeStream(in, null, options1));
Bitmap bt = bitmapResult.get();
avatarView.setImageBitmap(bt);
UICore.eventTask(this, this, set_avatar, "set_avatar", null);
} catch (Exception e) {
e.printStackTrace();
} finally{
}
}
}
}
private void doBlueJuhuaMenuAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String choices[] = new String[] {getString(R.string.friend_myfriend), getString(R.string.more_message), getString(R.string.exchange_bt_album)};
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(getString(R.string.system_info));
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent intent = new Intent(UserSpaceActivity.this, FriendListActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
}
break;
case 1:
if (entry.getSendmsg_mode() == 0) {
Intent intent = new Intent(UserSpaceActivity.this, MessageListActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
} else if (entry.getSendmsg_mode() == 1) {
Intent intent = new Intent(UserSpaceActivity.this, ConversationListActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
} else {
}
break;
case 2:
if (entry.getAlbum_visible() == 1) {
Intent intent = new Intent(UserSpaceActivity.this, AlbumsActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
} else {
handler.sendEmptyMessage(view_album_error);
}
break;
default:
break;
}
}
});
builder.setNegativeButton(cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
/**
* 选择菜单 弹出框
* @param choices 显示的菜单
*/
public void chooseAction(final String[] choices, final FriendFeedEntry feedEntry) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doSelectChooseEvent(which, choices, feedEntry);
}
});
builder.create().show();
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
File uploadFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void doSelectChooseEvent(int which, String choics[], FriendFeedEntry feedEntry) {
if (feedEntry == null) {
return;
} else {
if (choics.length == 2) {
if (which == 0) {
Intent intent = new Intent(this, UserPhotoActivity.class);
intent.putExtra("picid", feedEntry.getFeed_picid());
startActivity(intent);
} else {
Intent intent = new Intent(this, UserSpaceActivity.class);
intent.putExtra("ouid", feedEntry.getFeed_related_uid());
startActivity(intent);
}
} else {
if (feedEntry.getFeed_related_uid() != 0) {
Intent intent = new Intent(this, UserSpaceActivity.class);
intent.putExtra("ouid", feedEntry.getFeed_related_uid());
startActivity(intent);
} else {
Intent intent = new Intent(this, UserPhotoActivity.class);
intent.putExtra("picid", feedEntry.getFeed_picid());
startActivity(intent);
}
}
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SettingContactActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private ImageView backView;
private ImageView confirmView;
private EditText mobileView;
private EditText qqView;
private EditText msnView;
private Handler handler;
private final int set_contact = 1;
private final int error = 2;
private final int get_contact_info = 3;
private String mobile;
private String msn;
private String qq;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.setting_contact);
handler = new Handler(this);
initWidget();
UICore.eventTask(this, this, get_contact_info, "get_contact_info", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
confirmView = (ImageView) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
mobileView = (EditText) findViewById(R.id.setting_contact_mobile);
qqView = (EditText) findViewById(R.id.setting_contact_qq);
qqView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
UICore.eventTask(SettingContactActivity.this, SettingContactActivity.this, set_contact, "set_contact", null);
}
return false;
}
});
msnView = (EditText) findViewById(R.id.setting_contact_msn);
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == confirmView) {
UICore.eventTask(this, this, set_contact, "set_contact", null);
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case error:
onToast((String) msg.obj);
break;
case set_contact:
onToast((String) msg.obj);
finish();
break;
case get_contact_info:
if (mobile != null) {
mobileView.setText(mobile);
}
if (msn != null) {
msnView.setText(msn);
}
if (qq != null) {
qqView.setText(qq);
}
break;
default:
break;
}
return false;
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case set_contact:
setContactInfo();
break;
case get_contact_info:
getContactInfo();
break;
default:
break;
}
}
private void setContactInfo() {
String url = UrlConfig.set_contact_info;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("mobile", mobileView.getText().toString().trim());
paramsMap.put("QQ", qqView.getText().toString().trim());
paramsMap.put("MSN", msnView.getText().toString().trim());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_contact, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getContactInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_contact_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("authok");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
JSONObject contactObj = object.getJSONObject("contact_info");
mobile = contactObj.getString("mobile");
msn = contactObj.getString("MSN");
qq = contactObj.getString("QQ");
handler.sendEmptyMessage(get_contact_info);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LanguageConfigTable;
import com.outsourcing.bottle.domain.FriendEntry;
import com.outsourcing.bottle.domain.FriendGroupEntry;
import com.outsourcing.bottle.domain.InitFriendInfo;
import com.outsourcing.bottle.domain.LanguageConfig;
import com.outsourcing.bottle.domain.ShowtipsEntry;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.StringUtil;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.CustomListView;
/**
*
* @author 06peng
*
*/
public class ChooseFriendActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private static final String TAG = ChooseFriendActivity.class.getSimpleName();
private final int init_friend_info = 1;
private final int init_friend_info_error = 2;
private final int load_more_datas = 3;
private final int init_has_exs = 4;
private final int init_has_exs_error = 5;
private final int refresh_friend = 6;
private final int init_friend_myfriend_no_data = 7;
private final int init_friend_btfriend_no_data = 8;
private final int recommend_photo = 9;
private final int error = 10;
private ImageView backView;
private TextView titleView;
private ImageButton confirmView;
private LinearLayout friendGroupLayout;
private TextView groupNameView;
private ViewHolder holder;
private List<FriendEntry> friendList;
private List<FriendGroupEntry> friendGroupList;
private FriendAdapter adapter;
private String[] groupNames;
private int groupItem;
private int chooseFriendType;
/**0:好友 1:瓶友*/
private int listType;
private int page = 1;
private int count = 20;
private int groupId;
private int ouid;
private int lastItem;
private CustomListView listView;
private ProgressBar progressBar;
private TextView loadMoreView;
private int pic_uid;
private int picid;
private int bottleId;
private int exchange_type;
private int select_mode;
private Handler handler;
private ShowtipsEntry show_config;
private View mheaderView;
private RelativeLayout mNoDataTipsLayout;
private TextView mNoDataTipsText1;
private TextView mNoDataTipsText2;
private Button mNoDataTipsButton;
private String return_type = "";
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.choose_friend);
chooseFriendType = getIntent().getIntExtra("choose_friend_type", 0);
picid = getIntent().getIntExtra("picid",0);
pic_uid = getIntent().getIntExtra("pic_uid",0);
bottleId = getIntent().getIntExtra("bttype_id", 0);
return_type = getIntent().getStringExtra("return_type");
if (chooseFriendType == AppContext.CHOOSE_FRIEND_THROWBOTTLE_TYPE) { //扔瓶子
listType = 0;
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE) {//交换资料
listType = 1;
exchange_type = 1;
select_mode = 0;
} else if(chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE) {//交换照片
listType = 1;
exchange_type = 0;
select_mode = 0;
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_BOTTLE_TYPE) {//转发瓶子给好友
listType = 0;
select_mode = 1;
groupId = -1;
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE) {//转发照片给好友
listType = 0;
select_mode = 0;
groupId = -1;
}
select_mode = getIntent().getIntExtra("select_mode", 0);
initWidget();
setUIbyType();
UICore.eventTask(this, this, init_friend_info, getString(R.string.init_data), null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
confirmView = (ImageButton) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.topbar_title);
titleView.setText(getString(R.string.choose_friend_select));
friendGroupLayout = (LinearLayout) findViewById(R.id.choose_friend_layout);
friendGroupLayout.setOnClickListener(this);
groupNameView = (TextView) findViewById(R.id.choose_friend_group_name);
listView = (CustomListView) findViewById(R.id.choose_friend_list);
listView.setonRefreshListener(new CustomListView.OnRefreshListener() {
@Override
public void onRefresh() {
page = 1;
UICore.eventTask(ChooseFriendActivity.this, ChooseFriendActivity.this, init_friend_info, null, null);
}
});
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (lastItem == adapter.getCount() - 1 && scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
page++;
progressBar.setVisibility(View.VISIBLE);
loadMoreView.setText(getString(R.string.load_more));
new Thread() {
@Override
public void run() {
loadMore();
}
}.start();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem - 2 + visibleItemCount;
}
});
if (chooseFriendType != AppContext.CHOOSE_FRIEND_THROWBOTTLE_TYPE) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
if (arg2 == adapter.getCount()) {
return;
}
FriendEntry entry = friendList.get(arg2 - 1);
if (entry.getButton_mode() == 5) {
Intent intent = new Intent(ChooseFriendActivity.this, ExpandEditActivity.class);
Bundle bundle = new Bundle();
bundle.putString("from_type", AppContext.FORWARPIC_PICEX);
bundle.putInt("picid", picid);
bundle.putInt("pic_uid", pic_uid);
bundle.putInt("fuid",entry.getUid());
bundle.putString("return_type",return_type );
intent.putExtras(bundle);
startActivity(intent);
finish();
}
}
});
}
// mheaderView = LayoutInflater.from(this).inflate(
// R.layout.friend_no_data_header, null);
mNoDataTipsLayout = (RelativeLayout)findViewById(R.id.rl_nodata_tip);
mNoDataTipsText1 = (TextView)findViewById(R.id.tv_nodata_tips);
mNoDataTipsText2 = (TextView)findViewById(R.id.tv_nodata_tips_2);
mNoDataTipsButton = (Button)findViewById(R.id.bt_nodata_try);
// listView.addHeaderView(mheaderView);
}
private void setUIbyType() {
if (chooseFriendType == AppContext.CHOOSE_FRIEND_THROWBOTTLE_TYPE) {
confirmView.setVisibility(View.VISIBLE);
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE) {
confirmView.setVisibility(View.GONE);
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_BOTTLE_TYPE) {
confirmView.setVisibility(View.VISIBLE);
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE) {
confirmView.setVisibility(View.GONE);
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE) {
confirmView.setVisibility(View.VISIBLE);
}
if (listType == 0) {
friendGroupLayout.setVisibility(View.VISIBLE);
} else {
friendGroupLayout.setVisibility(View.GONE);
}
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == confirmView) {//点击确定的时候,获取多选的好友
List<Integer> friendUids = new ArrayList<Integer>();
List<String> friendNicknames = new ArrayList<String>();
for (FriendEntry entry : friendList) {
if (entry.isSelected()) {
friendUids.add(entry.getUid());
friendNicknames.add(entry.getNickname());
}
}
if (friendUids.isEmpty()) {
onToast(getString(R.string.choose_friend_no_selected));
return;
} else {
int[] uids = new int[friendUids.size()];
for (int i = 0;i < friendUids.size();i++) {
uids[i] = friendUids.get(i);
}
String[] nicknames = new String[friendNicknames.size()];
friendNicknames.toArray(nicknames);
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
String fuids = StringUtil.intArraysToString(uids);
if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_BOTTLE_TYPE) {//转发瓶子
extras.putString("from_type", AppContext.FORWARD_BT);
extras.putInt("bttype_id", bottleId);
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE) {//转发照片
extras.putString("from_type", AppContext.FORWARD_PHOTO);
extras.putInt("picid", picid);
if (select_mode == 1) {
UICore.eventTask(this, this, recommend_photo, "", fuids);
return;
}
}
extras.putString("return_type",return_type );
extras.putString("fuids", fuids.substring(0, fuids.length()));
extras.putStringArray("nicknames", nicknames);
intent.putExtras(extras);
startActivity(intent);
finish();
}
} else if (v == friendGroupLayout) {
doSelectGroupAction();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_friend_info:
initFriendInfo();
break;
case load_more_datas:
loadMore();
break;
case init_has_exs:
getHasExs();
break;
case recommend_photo:
recommendPhoto(obj.toString());
break;
default:
break;
}
}
private void updateUI() {
if (friendList != null && !friendList.isEmpty()) {
adapter = new FriendAdapter();
listView.setAdapter(adapter);
}
if (chooseFriendType == AppContext.CHOOSE_FRIEND_THROWBOTTLE_TYPE) {
if (groupNames != null && groupNames.length > 0) {
groupNameView.setText("(" + groupNames[groupItem] + ")");
}
}
if (show_config.getShow_config() != null) {
findViewById(R.id.choose_friend_tips_layout).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.tv_profile_tips)).setText(getString(R.string.throw_bottle_setting_tips) + show_config.getShow_config());
} else {
findViewById(R.id.choose_friend_tips_layout).setVisibility(View.GONE);
}
listView.onRefreshComplete();
}
private void initFriendInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_selectusers);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&list_type=" + listType);
url.append("&count=" + count);
url.append("&page=" + page);
if (listType == 1) {
url.append("&exchange_type=" + exchange_type);
}
if (listType == 0) {
url.append("&groupid=" + groupId);
}
url.append("&select_mode=" + select_mode);
try {
String result = HttpUtils.doGet(url.toString());
Gson gson = new Gson();
InitFriendInfo friendGson = gson.fromJson(result, InitFriendInfo.class);
show_config = friendGson.getShow_config();
int authok = friendGson.getResults().getAuthok();
if (authok == 0) {
String errmsg = friendGson.getResults().getErrmsg();
Message msg = Message.obtain(handler, init_friend_info_error, errmsg);
handler.sendMessage(msg);
} else {
friendList = friendGson.getUsers_list();
friendGroupList = friendGson.getGroups_list();
if (friendGroupList != null && !friendGroupList.isEmpty()) {
groupNames = new String[friendGroupList.size() + 1];
groupNames[0] = getString(R.string.choose_friend_allgroups);
for (int i = 1;i < friendGroupList.size() + 1;i++) {
groupNames[i] = friendGroupList.get(i - 1).getGroupname();
}
if (friendList != null && !friendList.isEmpty()) {
handler.sendEmptyMessage(init_friend_info);
} else {
if (listType == 0) {
handler.sendEmptyMessage(init_friend_myfriend_no_data);
} else {
handler.sendEmptyMessage(init_friend_btfriend_no_data);
}
}
} else {
if (friendList != null && !friendList.isEmpty()) {
handler.sendEmptyMessage(init_friend_info);
} else {
if (listType == 0) {
handler.sendEmptyMessage(init_friend_myfriend_no_data);
} else {
handler.sendEmptyMessage(init_friend_btfriend_no_data);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void recommendPhoto(String fuids) {
String url = UrlConfig.recommend_photo;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("picid", String.valueOf(picid));
paramsMap.put("fuids", fuids);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
if (resultObj.getInt("success") == 1) {
Message msg = Message.obtain(handler, recommend_photo, resultObj.get("successmsg"));
handler.sendMessage(msg);
} else {
Message msg = Message.obtain(handler, recommend_photo, resultObj.get("errmsg"));
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void loadMore() {
StringBuffer url = new StringBuffer(UrlConfig.get_selectusers);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&list_type=" + listType);
url.append("&count=" + count);
url.append("&page=" + page);
if (listType == 1) {
url.append("&exchange_type=" + exchange_type);
}
if (listType == 0) {
url.append("&groupid=" + groupId);
}
url.append("&select_mode=" + select_mode);
try {
List<FriendEntry> moreDatas;
String result = HttpUtils.doGet(url.toString());
Gson gson = new Gson();
InitFriendInfo friendGson = gson.fromJson(result, InitFriendInfo.class);
show_config = friendGson.getShow_config();
int authok = friendGson.getResults().getAuthok();
if (authok == 0) {
String errmsg = friendGson.getResults().getErrmsg();
Message msg = Message.obtain(handler, init_friend_info_error, errmsg);
handler.sendMessage(msg);
} else {
moreDatas = friendGson.getUsers_list();
if (moreDatas != null) {
friendList.addAll(moreDatas);
}
handler.sendEmptyMessage(load_more_datas);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getHasExs() {
StringBuffer url = new StringBuffer(UrlConfig.get_has_exs);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
try {
String result = HttpUtils.doGet(url.toString());
ServiceUtils.dout(TAG +":"+ result);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int authok = resultObj.getInt("authok");
if (authok == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, init_has_exs_error, errmsg);
handler.sendMessage(msg);
} else {
JSONObject hasExsObj = object.getJSONObject("has_exs");
if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE) {
int has_infoexs = hasExsObj.getInt("has_infoexs");
if (has_infoexs == 1) {
Intent intent = new Intent(this, ExchangeInfoDetailActivity .class);
intent.putExtra("ouid", ouid);
startActivity(intent);
} else {
handler.sendEmptyMessage(init_has_exs);
}
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE) {
int has_picexs = hasExsObj.getInt("has_picexs");
if (has_picexs == 1) {
Intent intent = new Intent(this, ExchangePicDetailActivity.class);
intent.putExtra("ouid", ouid);
startActivity(intent);
} else {
handler.sendEmptyMessage(init_has_exs);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void doSelectGroupAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, groupNames);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(getString(R.string.choose_friend_select_group));
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
groupItem = which;
if (which != 0) {
groupId = friendGroupList.get(which - 1).getGroupid();
} else {
groupId = 0;
}
groupNameView.setText("(" + groupNames[groupItem] + ")");
UICore.eventTask(ChooseFriendActivity.this,
ChooseFriendActivity.this, init_friend_info,
getString(R.string.init_data), null);
}
});
builder.setNegativeButton(cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
public class FriendAdapter extends BaseAdapter {
@Override
public int getCount() {
return friendList == null ? 0 : friendList.size() + 1;
}
@Override
public Object getItem(int arg0) {
return friendList == null ? null : friendList.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int position, View convertView, ViewGroup arg2) {
if (position == getCount() - 1) {
View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.listfooter_more, null);
progressBar = (ProgressBar) view.findViewById(R.id.pull_to_refresh_progress);
loadMoreView = (TextView) view.findViewById(R.id.load_more);
return view;
}
if (convertView != null && convertView.getId() == R.id.choose_friend_listitem_layout) {
holder = (ViewHolder) convertView.getTag();
} else {
holder = new ViewHolder();
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.choose_friend_listitem, null);
holder.avatar = (RemoteImageView) convertView.findViewById(R.id.choose_friend_listitem_avatar);
holder.nickname = (TextView) convertView.findViewById(R.id.choose_friend_listitem_nickname);
holder.mSex = (ImageView)convertView.findViewById(R.id.bt_sex);
holder.memo = (TextView) convertView.findViewById(R.id.choose_friend_listitem_memo);
holder.address = (TextView) convertView.findViewById(R.id.choose_friend_listitem_address);
holder.mood = (TextView) convertView.findViewById(R.id.choose_friend_listitem_mood);
holder.isSelected = (Button) convertView.findViewById(R.id.choose_friend_listitem_isselected);
convertView.setTag(holder);
}
final FriendEntry entry = friendList.get(position);
if (entry != null) {
holder.nickname.setText(entry.getNickname());
int sex_res = entry.getSex() == 1 ? R.drawable.male:R.drawable.female;
holder.mSex.setBackgroundResource(sex_res);
holder.memo.setText(entry.getMemo());
String html = "<font color=black>"+getString(R.string.user_info_doing)+"</font>";
if (!TextUtils.isEmpty(entry.getDoing())) {
holder.mood.setText(Html.fromHtml(html + entry.getDoing()));
}else {
holder.mood.setVisibility(View.GONE);
}
if (entry.getCountry() != null && !entry.getCountry().equals("")) {
if (AppContext.language == 1) {
holder.address.setText(getString(R.string.user_from) + entry.getCountry() + "," + entry.getCity());
} else {
holder.address.setText(getString(R.string.user_from) + entry.getCity() + "," + entry.getCountry());
}
}
holder.avatar.setDefaultImage(R.drawable.avatar_default_big);
holder.avatar.setImageUrl(entry.getAvatar(), position, listView);
if (entry.getButton_mode() == 0) {//已经照片交换
holder.isSelected.setBackgroundResource(R.drawable.btn_blue_try);
holder.isSelected.setText(getString(R.string.exchange_bt_ex_photo));
holder.isSelected.setVisibility(View.VISIBLE);
holder.isSelected.setPadding(5, 5, 5, 5);
} else if (entry.getButton_mode() ==1) {//未照片交换(1)
holder.isSelected.setBackgroundResource(R.drawable.btn_red_try);
holder.isSelected.setText(getString(R.string.exchange_bt_ex_photo));
holder.isSelected.setVisibility(View.VISIBLE);
holder.isSelected.setPadding(5, 5, 5, 5);
} else if (entry.getButton_mode() == 2) {//已经资料交换(2)
holder.isSelected.setBackgroundResource(R.drawable.btn_blue_try);
holder.isSelected.setText(getString(R.string.exchange_bt_ex_profile));
holder.isSelected.setVisibility(View.VISIBLE);
holder.isSelected.setPadding(5, 5, 5, 5);
} else if (entry.getButton_mode() == 3) {//未资料交换(3)
holder.isSelected.setBackgroundResource(R.drawable.btn_red_try);
holder.isSelected.setText(getString(R.string.exchange_bt_ex_profile));
holder.isSelected.setVisibility(View.VISIBLE);
holder.isSelected.setPadding(5, 5, 5, 5);
} else if (entry.getButton_mode() == 4) {//多选(4)
holder.isSelected.setVisibility(View.VISIBLE);
if (entry.isSelected()) {
holder.isSelected.setBackgroundResource(R.drawable.select_red);
} else {
holder.isSelected.setBackgroundResource(R.drawable.select_gray);
}
} else if (entry.getButton_mode() == 5) {
holder.isSelected.setVisibility(View.GONE);
}
}
holder.isSelected.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (entry.getButton_mode() == 0) {//已经照片交换
Intent intent = new Intent(ChooseFriendActivity.this, ExchangePicDetailActivity.class);
intent.putExtra("ouid", entry.getUid());
intent.putExtra("page", 1);
startActivity(intent);
} else if (entry.getButton_mode() ==1) {//未照片交换(1)
Intent intentPhoto = new Intent(ChooseFriendActivity.this, ExpandEditActivity.class);
Bundle bundlePhoto = new Bundle();
bundlePhoto.putString("from_type", AppContext.APPLY_PICEX);
bundlePhoto.putInt("ouid", entry.getUid());
intentPhoto.putExtras(bundlePhoto);
startActivity(intentPhoto);
finish();
} else if (entry.getButton_mode() == 2) {//已经资料交换(2)
Intent intent = new Intent(ChooseFriendActivity.this, ExchangeInfoDetailActivity .class);
intent.putExtra("ouid", entry.getUid());
intent.putExtra("page", 1);
startActivity(intent);
} else if (entry.getButton_mode() == 3) {//未资料交换(3)
Intent intentProfile = new Intent(ChooseFriendActivity.this, ExpandEditActivity.class);
Bundle bundleProfile = new Bundle();
bundleProfile.putString("from_type", AppContext.REPLY_INFOEX);
bundleProfile.putInt("ouid", entry.getUid());
bundleProfile.putString("reply_infoex_type", "apply");
intentProfile.putExtras(bundleProfile);
startActivity(intentProfile);
finish();
} else if (entry.getButton_mode() == 4) {//多选(4)
Button view = (Button) v;
if (entry.isSelected()) {
view.setBackgroundResource(R.drawable.select_gray);
entry.setSelected(false);
} else {
view.setBackgroundResource(R.drawable.select_red);
entry.setSelected(true);
}
}
}
});
holder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (entry.getAvatar_click() == 1) {
Intent intent = new Intent(ChooseFriendActivity.this, UserSpaceActivity.class);
intent.putExtra("ouid", entry.getUid());
startActivity(intent);
}
}
});
return convertView;
}
}
public static class ViewHolder {
public ImageView mSex;
RemoteImageView avatar;
TextView nickname;
TextView memo;
TextView address;
TextView mood;
Button isSelected;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (AppContext.getInstance().isFromExchangeTimeToChangeFriend()) {
AppContext.getInstance().setFromExchangeTimeToChangeFriend(false);
}
if (AppContext.getInstance().isFromExchangeTime()) {
AppContext.getInstance().setFromExchangeTime(false);
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean handleMessage(Message msg) {
try {
LanguageConfigTable languageConfigTable = null;
LanguageConfig languageCon = null;
switch (msg.what) {
case init_friend_info:
mNoDataTipsLayout.setVisibility(View.GONE);
updateUI();
break;
case init_friend_info_error:
onToast((String) msg.obj);
break;
case load_more_datas:
adapter.notifyDataSetChanged();
progressBar.setVisibility(View.GONE);
loadMoreView.setText(getString(R.string.more_data));
break;
case init_has_exs:
if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE) {
Intent intent = new Intent(ChooseFriendActivity.this, ExpandEditActivity.class);
Bundle bundle = new Bundle();
bundle.putString("from_type", AppContext.REPLY_INFOEX);
bundle.putInt("ouid", ouid);
bundle.putString("reply_infoex_type", "apply");
bundle.putInt("ouid", ouid);
intent.putExtras(bundle);
startActivity(intent);
finish();
} else if (chooseFriendType == AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE) {
Intent intent = new Intent(ChooseFriendActivity.this, ExpandEditActivity.class);
Bundle bundle = new Bundle();
bundle.putString("from_type", AppContext.APPLY_PICEX);
bundle.putString("reply_picex_type", "apply");
bundle.putInt("ouid", ouid);
intent.putExtras(bundle);
startActivity(intent);
finish();
}
break;
case refresh_friend:
adapter.notifyDataSetChanged();
listView.onRefreshComplete();
break;
case init_has_exs_error:
onToast((String)msg.obj);
break;
case init_friend_myfriend_no_data:
mNoDataTipsLayout.setVisibility(View.VISIBLE);
languageConfigTable = new LanguageConfigTable();
languageCon = languageConfigTable.getBottleLanguageConfig();
String friendTips1 = null;
String friendTips2 = null;
if (AppContext.language == 1) {
friendTips1 = languageCon.getWithout_friend_tip_cn();
friendTips2 = languageCon.getWithout_friend_tip_2_cn();
}else {
friendTips1 = languageCon.getWithout_friend_tip_en();
friendTips2 = languageCon.getWithout_friend_tip_2_en();
}
mNoDataTipsText1.setText(friendTips1);
mNoDataTipsText2.setText(friendTips2);
mNoDataTipsButton.setText(TextUtil.R("friend_nodata_tip_bt_maybeknow"));
mNoDataTipsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View paramView) {
Intent intent = new Intent(ChooseFriendActivity.this, BindInviteActivity.class);
startActivity(intent);
}
});
break;
case init_friend_btfriend_no_data:
mNoDataTipsLayout.setVisibility(View.VISIBLE);
languageConfigTable = new LanguageConfigTable();
languageCon = languageConfigTable.getBottleLanguageConfig();
String btfriendTips1 = null;
String btfriendTips2 = null;
if (AppContext.language == 1) {
btfriendTips1 = languageCon.getWithout_btfriend_tip_cn();
btfriendTips2 = languageCon.getWithout_btfriend_tip_2_cn();
}else {
btfriendTips1 = languageCon.getWithout_btfriend_tip_en();
btfriendTips2 = languageCon.getWithout_btfriend_tip_2_en();
}
mNoDataTipsText1.setText(btfriendTips1);
mNoDataTipsText2.setText(btfriendTips2);
mNoDataTipsButton.setText(TextUtil.R("bottle_txt_title_gain"));
mNoDataTipsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View paramView) {
Intent tryIntent = new Intent(
ChooseFriendActivity.this,
ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
}
});
break;
case recommend_photo:
onToast((String) msg.obj);
finish();
break;
case error:
onToast((String) msg.obj);
break;
default:
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.List;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.hardware.Camera.Size;
import android.media.ExifInterface;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.Display;
import android.view.KeyEvent;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.util.AppContext;
/**
*
* @author 06peng
*
*/
public class CameraActivity extends Activity implements OnClickListener, Callback {
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
private Camera mCamera = null;
private boolean mPreviewRunning;
private int IMG_Width = 640;
private int IMG_Height = 480;
private int imageId = 0;
private WeakReference<Bitmap> bitmap;
private boolean isOnClick = false;
private String selectResolution = null;
private String wm = null;
private OrientationEventListener mOrientationListener;
private int mLastOrientation = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.cameralayout);
mSurfaceView = (SurfaceView) findViewById(R.id.camera);
mSurfaceView.setOnClickListener(this);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mOrientationListener = new OrientationEventListener(this) {
@Override
public void onOrientationChanged(int orientation) {
if (orientation != ORIENTATION_UNKNOWN) {
orientation += 90;
}
orientation = roundOrientation(orientation);
if (orientation != mLastOrientation) {
mLastOrientation = orientation;
}
}
};
mOrientationListener.enable();
}
protected void setDisplayOrientation(Camera camera, int angle) {
Method downPolymorphic;
try {
downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
if (downPolymorphic != null)
downPolymorphic.invoke(camera, new Object[] { angle });
} catch (Exception e) {
e.printStackTrace();
}
}
public int roundOrientation(int orientationInput) {
int orientation = orientationInput;
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
orientation = 0;
}
orientation = orientation % 360;
int retVal;
if (orientation < (0 * 90) + 45) {
retVal = 0;
} else if (orientation < (1 * 90) + 45) {
retVal = 90;
} else if (orientation < (2 * 90) + 45) {
retVal = 180;
} else if (orientation < (3 * 90) + 45) {
retVal = 270;
} else {
retVal = 0;
}
return retVal;
}
public static int getExifOrientation(String filepath) {
int degree = 0;
ExifInterface exif = null;
try {
exif = new ExifInterface(filepath);
} catch (IOException ex) {
ex.printStackTrace();
}
if (exif != null) {
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
if (orientation != -1) {
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
}
}
return degree;
}
public boolean onKeyDown(int keyCode, KeyEvent paramKeyEvent) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return onBackClick();
} else if (keyCode == KeyEvent.KEYCODE_CAMERA) {
try {
mCamera.takePicture(mShutterCallback, null, mPictureCallback);
} catch (Exception e) {
e.printStackTrace();
isOnClick = false;
} catch (Error ex) {
isOnClick = false;
}
}
return super.onKeyDown(keyCode, paramKeyEvent);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
public void onClick(View v) {
if (!isOnClick) {
isOnClick = true;
try {
mCamera.autoFocus(new AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
try {
mCamera.takePicture(mShutterCallback, null, mPictureCallback);
} catch (Exception e) {
e.printStackTrace();
isOnClick = false;
} catch (Error ex) {
isOnClick = false;
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
PictureCallback mPictureCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera1) {
InputStream in = null;
try {
if (data != null) {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "temp");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
File picFile = new File(pictureFileDir, "upload.jpeg");
if (!picFile.exists()) {
picFile.createNewFile();
}
FileOutputStream fos = new FileOutputStream(picFile);
fos.write(data);
fos.close();
in = new FileInputStream(picFile);
BitmapFactory.Options options1 = new BitmapFactory.Options();
options1.inPurgeable = true;
options1.inInputShareable = true;
options1.inSampleSize = 2;
try {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
} catch (Exception ex) {
ex.printStackTrace();
}
bitmap = new WeakReference<Bitmap>(Bitmap.createScaledBitmap(BitmapFactory
.decodeStream(in, null, options1), IMG_Width, IMG_Height, false));
Bitmap bt = bitmap.get();
int width = bt.getWidth();
int height = bt.getHeight();
Matrix matrix = new Matrix();
matrix.setRotate(mLastOrientation);
bitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(bt, 0, 0, width, height, matrix, true));
pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
if (!picFile.exists()) {
picFile.createNewFile();
}
fos = new FileOutputStream(picFile);
String pathName = picFile.getAbsolutePath();
if (null != wm && !"".equals(wm.trim())) {
bitmap = new WeakReference<Bitmap>(addWateMark(new WeakReference<Bitmap>(bitmap.get()).get(), wm));
bitmap.get().compress(Bitmap.CompressFormat.JPEG, 100, fos);
} else {
bitmap.get().compress(Bitmap.CompressFormat.JPEG, 100, fos);
}
fos.close();
bitmap.get().recycle();
bitmap = null;
System.gc();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
// 计算缩放比
int be = (int) (options.outHeight / (float) 200);
if (be <= 0)
be = 1;
options.inSampleSize = be * 2;
options1.inPurgeable = true;
options1.inInputShareable = true;
try {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
} catch (Exception ex) {
ex.printStackTrace();
}
bitmap = new WeakReference<Bitmap>(BitmapFactory.decodeFile(pathName, options)); // 此时返回bm为空
options.inJustDecodeBounds = false;
bitmap = new WeakReference<Bitmap>(BitmapFactory.decodeFile(pathName, options)); // 此时返回bm为空
if (mPreviewRunning) {
mCamera.stopPreview();
mPreviewRunning = false;
}
isOnClick = false;
setResult(1006);
finish();
}
} catch (Exception e) {
e.printStackTrace();
onBackClick();
} catch (Error e) {
e.printStackTrace();
onBackClick();
}
}
};
public Bitmap getRotatedImage(Bitmap original, int degrees) {
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
Bitmap rotated = Bitmap.createBitmap(original, 0, 0, original.getWidth(), original.getHeight(), matrix, true);
return rotated;
}
private Point screenResolution;
private Point cameraResolution;
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
WindowManager manager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenResolution = new Point(display.getWidth(), display.getHeight());
cameraResolution = getCameraResolution(parameters, screenResolution);
}
private Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) {
String previewSizeValueString = parameters.get("preview-size-values");
if (previewSizeValueString == null) {
previewSizeValueString = parameters.get("preview-size-value");
}
Point cameraResolution = null;
if (previewSizeValueString != null) {
cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
}
if (cameraResolution == null) {
cameraResolution = new Point((screenResolution.x >> 3) << 3, (screenResolution.y >> 3) << 3);
}
return cameraResolution;
}
private Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
int bestX = 0;
int bestY = 0;
int diff = Integer.MAX_VALUE;
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
previewSize = previewSize.trim();
int dimPosition = previewSize.indexOf('x');
if (dimPosition < 0) {
continue;
}
int newX;
int newY;
try {
newX = Integer.parseInt(previewSize.substring(0, dimPosition));
newY = Integer.parseInt(previewSize.substring(dimPosition + 1));
} catch (NumberFormatException nfe) {
continue;
}
int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y);
if (newDiff == 0) {
bestX = newX;
bestY = newY;
break;
} else if (newDiff < diff) {
bestX = newX;
bestY = newY;
diff = newDiff;
}
}
if (bestX > 0 && bestY > 0) {
return new Point(bestX, bestY);
}
return null;
}
ShutterCallback mShutterCallback = new ShutterCallback() {
public void onShutter() {
}
};
public Size getOptimalPreviewSize(List<Size> sizes, int w, int h) {
final double ASPECT_TOLERANCE = 0.05;
double targetRatio = (double) w / h;
if (sizes == null)
return null;
Size optimalSize = null;
double minDiff = Double.MAX_VALUE;
int targetHeight = h;
for (Size size : sizes) {
double ratio = (double) size.width / size.height;
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)
continue;
if (Math.abs(size.height - targetHeight) < minDiff) {
optimalSize = size;
minDiff = Math.abs(size.height - targetHeight);
}
}
if (optimalSize == null) {
minDiff = Double.MAX_VALUE;
for (Size size : sizes) {
if (Math.abs(size.height - targetHeight) < minDiff) {
optimalSize = size;
minDiff = Math.abs(size.height - targetHeight);
}
}
}
return optimalSize;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (mCamera != null) {
return;
}
if (!mPreviewRunning) {
mCamera = Camera.open();
try {
if (selectResolution == null) {
initFromCameraParameters(mCamera);
}
Parameters params = mCamera.getParameters();
params.setFocusMode(Parameters.FOCUS_MODE_AUTO);
params.setFlashMode(Parameters.FLASH_MODE_AUTO);
List<Size> list = params.getSupportedPictureSizes();
int w = 0;
int h = 0;
for (int i = 0; i < list.size(); i++) {
Size size = list.get(i);
if (size.width >= IMG_Width && size.height >= IMG_Height) {
if (w == 0) {
w = size.width;
h = size.height;
} else if (w > size.width && h > size.height) {
w = size.width;
h = size.height;
}
}
}
if (w == 0) {
Size size = list.get(0);
w = size.width;
h = size.height;
}
params.setPictureSize(w, h);
Pattern pa = Pattern.compile("x");
if (selectResolution != null) {
String[] s = pa.split(selectResolution);
cameraResolution = new Point(Integer.parseInt(s[0]), Integer.parseInt(s[1]));
}
params.setPreviewSize(cameraResolution.x, cameraResolution.y);
if (Integer.parseInt(Build.VERSION.SDK) >= 8) {
setDisplayOrientation(mCamera, mLastOrientation);
} else {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
params.set("orientation", "portrait");
params.set("rotation", mLastOrientation);
}
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
params.set("orientation", "landscape");
params.set("rotation", mLastOrientation);
}
}
params.setRotation(mLastOrientation);
mCamera.setParameters(params);
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
mPreviewRunning = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
protected void onDestroy() {
bitmapRecycle();
super.onDestroy();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
try {
if (mCamera != null) {
mCamera.stopPreview();
mPreviewRunning = false;
mCamera.release();
mCamera = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void bitmapRecycle() {
try {
if (bitmap != null && bitmap.get() != null && !bitmap.get().isRecycled()) {
bitmap.get().recycle();
System.gc();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (mCamera != null) {
mCamera.stopPreview();
mPreviewRunning = false;
mCamera.release();
mCamera = null;
}
}
}
protected boolean onBackClick() {
try {
Bundle bundle = new Bundle();
bundle.putInt("imageId", imageId);
Intent intent = getIntent();
intent.putExtras(bundle);
if (bitmap != null) {
setResult(1111, intent);
} else {
setResult(0, intent);
}
finish();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 添加水印
* @param str
* @param photo
*/
private Bitmap addWateMark(Bitmap photo, String str) {
if (null == photo || null == str || "".equals(str.trim()))
return null;
int width = photo.getWidth(), hight = photo.getHeight();
Bitmap icon = Bitmap.createBitmap(width, hight, Bitmap.Config.ARGB_8888); // 建立一个空的BItMap
Canvas canvas = new Canvas(icon);// 初始化画布绘制的图像到icon上
Paint photoPaint = new Paint(); // 建立画笔
photoPaint.setDither(true); // 获取跟清晰的图像采样
photoPaint.setFilterBitmap(true);// 过滤一些
Rect src = new Rect(0, 0, photo.getWidth(), photo.getHeight());// 创建一个指定的新矩形的坐标
Rect dst = new Rect(0, 0, width, hight);// 创建一个指定的新矩形的坐标
canvas.drawBitmap(photo, src, dst, photoPaint);// 将photo 缩放或则扩大到
// dst使用的填充区photoPaint
Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);// 设置画笔
textPaint.setTextSize(30.0f);// 字体大小
textPaint.setTypeface(Typeface.DEFAULT_BOLD);// 采用默认的宽度
textPaint.setColor(Color.RED);// 采用的颜色
canvas.drawText(str, 0, hight - 50, textPaint);
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
return icon;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.graphics.Bitmap;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.CustomZoomControls;
public class MapViewActivity extends BasicActivity implements BasicUIEvent,
Callback, OnClickListener {
private static final int EXEU_LOCATION = 0;
private static final int EXEU_MY_LOCATION = 1;
private static final int EXEU_LOCATION_FAILED = 2;
Handler handler;
ImageView topbar_back;
ImageView topbar_menu;
ImageView iv_map;
TextView tv_location;
ImageButton ib_location;
float longitude, latidute;
String location;
Bitmap bitmap = null;
private CustomZoomControls zoomControls;
private int zoom = 15;
private LocationManager locationManager;
private String bestProvider;
private Location locationResult;
/** 0:传过来的位置 1:我的位置 */
private int locationType = 0;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.map_view);
handler = new Handler(this);
longitude = getIntent().getFloatExtra("longitude", 0);
latidute = getIntent().getFloatExtra("latidute", 0);
location = getIntent().getStringExtra("location");
topbar_back = (ImageView) findViewById(R.id.topbar_back);
topbar_back.setOnClickListener(this);
topbar_menu = (ImageView) findViewById(R.id.topbar_menu);
topbar_menu.setVisibility(View.GONE);
iv_map = (ImageView) findViewById(R.id.iv_map);
tv_location = (TextView) findViewById(R.id.tv_location);
tv_location.setText(location);
tv_location.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locationType = 0;
UICore.eventTask(MapViewActivity.this, MapViewActivity.this,
EXEU_LOCATION, "", null);
}
});
ib_location = (ImageButton) findViewById(R.id.ib_location);
ib_location.setOnClickListener(this);
zoomControls = (CustomZoomControls) findViewById(R.id.zoomcontrols);
zoomControls.setOnZoomOutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
zoom -= 1;
if (locationType == 1) {
UICore.eventTask(MapViewActivity.this, MapViewActivity.this,
EXEU_MY_LOCATION, "", null);
} else {
UICore.eventTask(MapViewActivity.this,
MapViewActivity.this, EXEU_LOCATION, "", null);
}
}
});
zoomControls.setOnZoomInClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
zoom += 1;
if (locationType == 1) {
UICore.eventTask(MapViewActivity.this, MapViewActivity.this,
EXEU_MY_LOCATION, "", null);
} else {
UICore.eventTask(MapViewActivity.this,
MapViewActivity.this, EXEU_LOCATION, "", null);
}
}
});
UICore.eventTask(this, this, EXEU_LOCATION, "", null);
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case EXEU_LOCATION:
doLocation(latidute, longitude, zoom);
break;
case EXEU_MY_LOCATION:
locationCurrent();
break;
default:
break;
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
if (null != bitmap) {
bitmap.recycle();
bitmap = null;
}
}
private void doLocation(float latitude, float longitude, int zoom) {
String language = AppContext.language == 1?"zh":"en";
String url_map = UrlConfig.map_static_url + "?center=" + latidute + ","
+ longitude + "&zoom=" + zoom + "&size=" + CanvasWidth + "x"
+ (CanvasHeight-50-50)
+ "&sensor=false&language="+language+"&mobile=true&markers=color:red%7Clabel:C%7C"
+ latidute + "," + longitude;
ServiceUtils.dout(url_map);
bitmap = HttpUtils.getMapBitmapFromUrl(this, url_map);
if (null != bitmap) {
Message message = Message.obtain(handler);
message.what = EXEU_LOCATION;
handler.sendMessage(message);
}
}
private void locationCurrent() {
if (null!=locationResult) {
longitudeCurrent = locationResult.getLongitude();
latitudeCurrent = locationResult.getLatitude();
}else {
requestTelLocation();
}
if (longitudeCurrent>0&&latitudeCurrent>0) {
String language = AppContext.language == 1?"zh":"en";
String url_map = UrlConfig.map_static_url + "?center="
+ latitudeCurrent + ","
+ longitudeCurrent + "&zoom=" + zoom + "&size="
+ CanvasWidth + "x" + (CanvasHeight - 50-50)
+ "&sensor=false&language="+language+"&mobile=true&markers=color:red%7Clabel:C%7C"
+ latitudeCurrent + ","
+ longitudeCurrent;
ServiceUtils.dout(url_map);
bitmap = HttpUtils.getMapBitmapFromUrl(this, url_map);
if (null != bitmap) {
Message message = Message.obtain(handler);
message.what = EXEU_LOCATION;
handler.sendMessage(message);
}
}else {
Message message = Message.obtain(handler);
message.what = EXEU_LOCATION_FAILED;
handler.sendMessage(message);
}
}
private Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
return criteria;
}
LocationListener locationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onLocationChanged(Location location) {
}
};
private double longitudeCurrent;
private double latitudeCurrent;
private void requestLocation(JSONObject object) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.google.com/loc/json");
try {
StringEntity entity = new StringEntity(object.toString());
post.setEntity(entity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
HttpResponse resp = client.execute(post);
HttpEntity entity = resp.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(
entity.getContent()));
StringBuffer buffer = new StringBuffer();
String result = br.readLine();
while (result != null) {
buffer.append(result);
result = br.readLine();
}
JSONObject obj = new JSONObject(buffer.toString());
JSONObject locationObj = obj.getJSONObject("location");
latitudeCurrent = locationObj.getDouble("latitude");
longitudeCurrent = locationObj.getDouble("longitude");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
private void requestTelLocation() {
TelephonyManager mTelMan = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String operator = mTelMan.getNetworkOperator();
String mcc = operator.substring(0, 3);
String mnc = operator.substring(3);
GsmCellLocation location = (GsmCellLocation) mTelMan.getCellLocation();
int cid = location.getCid();
int lac = location.getLac();
JSONObject tower = new JSONObject();
try {
tower.put("cell_id", cid);
tower.put("location_area_code", lac);
tower.put("mobile_country_code", mcc);
tower.put("mobile_network_code", mnc);
} catch (JSONException e) {
e.printStackTrace();
}
JSONArray array = new JSONArray();
array.put(tower);
List<NeighboringCellInfo> list = mTelMan.getNeighboringCellInfo();
Iterator<NeighboringCellInfo> iter = list.iterator();
NeighboringCellInfo cellInfo;
JSONObject tempTower;
while (iter.hasNext()) {
cellInfo = iter.next();
tempTower = new JSONObject();
try {
tempTower.put("cell_id", cellInfo.getCid());
tempTower.put("location_area_code", cellInfo.getLac());
tempTower.put("mobile_country_code", mcc);
tempTower.put("mobile_network_code", mnc);
} catch (JSONException e) {
e.printStackTrace();
}
array.put(tempTower);
}
JSONObject object = createJSONObject("cell_towers", array);
requestLocation(object);
}
private JSONObject createJSONObject(String arrayName, JSONArray array) {
JSONObject object = new JSONObject();
try {
object.put("version", "1.1.0");
object.put("host", "maps.google.com");
object.put(arrayName, array);
} catch (JSONException e) {
e.printStackTrace();
}
return object;
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case EXEU_LOCATION:
iv_map.setImageBitmap(bitmap);
break;
case EXEU_LOCATION_FAILED:
onToast(TextUtil.R("location_error"));
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.topbar_back:
finish();
break;
case R.id.ib_location:
locationType = 1;
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
bestProvider = locationManager
.getBestProvider(getCriteria(), false);
if (bestProvider == null) {
bestProvider = LocationManager.NETWORK_PROVIDER;
}
locationManager.requestLocationUpdates(bestProvider, 2000, 0,
locationListener);
locationResult = locationManager.getLastKnownLocation(bestProvider);
UICore.eventTask(MapViewActivity.this, MapViewActivity.this,
EXEU_MY_LOCATION, "", null);
break;
default:
break;
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.EducationInfo;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.SchoolEntry;
import com.outsourcing.bottle.domain.SchoolInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SettingEducationActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private RelativeLayout statusLayout;
private TextView statusView;
private ImageView addView;
private EditText editView;
private ListView listView;
private final int init_school_info = 1;
private final int error = 2;
private final int set_school = 3;
private final int add_school = 4;
private final int delete_school = 5;
private Handler handler;
private List<SchoolEntry> schoolList;
private String status;
private String[] statuses;
private HashMap<String, String> paramsMap;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.setting_education);
handler = new Handler(this);
statuses = new String[] {
getString(R.string.setting_education_primary),
getString(R.string.setting_education_junior),
getString(R.string.setting_education_senior),
getString(R.string.setting_education_college),
getString(R.string.setting_education_graduated),
getString(R.string.setting_education_others) };
paramsMap = new HashMap<String, String>();
initWidget();
UICore.eventTask(this, this, init_school_info, "init_school_info", null);
}
private void initWidget() {
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 1) {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.GONE);
} else {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.VISIBLE);
((TextView)findViewById(R.id.tv_profile_tips)).setText(userEntry.getBasicinfo_tip());
}
RemoteImageView img_head = (RemoteImageView) findViewById(R.id.iv_author_photo);
String avatar = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid()).getAvatar();
if (TextUtil.notEmpty(avatar)) {
img_head.setDefaultImage(R.drawable.avatar_default_small);
img_head.setImageUrl(avatar);
}
statusLayout = (RelativeLayout) findViewById(R.id.setting_education_status_layout);
statusLayout.setOnClickListener(this);
statusView = (TextView) findViewById(R.id.setting_education_status_value);
addView = (ImageView) findViewById(R.id.setting_education_add);
addView.setOnClickListener(this);
editView = (EditText) findViewById(R.id.setting_education_edit);
editView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
if (editView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return true;
}
UICore.eventTask(SettingEducationActivity.this, SettingEducationActivity.this, add_school, "add_school", null);
}
return false;
}
});
listView = (ListView) findViewById(R.id.setting_education_list);
}
public void back(View v) {
finish();
}
public void confirm(View v) {
if (!paramsMap.containsKey("status")) {
onToast(getString(R.string.setting_education_status_error));
return;
}
UICore.eventTask(this, this, set_school, "set_school", null);
}
@Override
public void onClick(View v) {
if (v == statusLayout) {
doStatusAction();
} else if (v == addView) {
if (editView.getText().toString().trim().equals("")) {
onToast(getString(R.string.setting_school_search_error));
return;
}
UICore.eventTask(this, this, add_school, "add_school", null);
}
}
private void doStatusAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, statuses);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
int currentItem;
if (which == statuses.length) {
currentItem = 0;
} else {
currentItem = which + 1;
}
paramsMap.put("status", String.valueOf(currentItem));
statusView.setText(statuses[which]);
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_school_info:
initEducationInfo();
break;
case add_school:
addSchool();
break;
case delete_school:
deleteSchool((String) obj);
break;
case set_school:
setEducationInfo();
break;
default:
break;
}
}
private void addSchool() {
String url = UrlConfig.add_school_info;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("school", editView.getText().toString().trim());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
if (resultObj.getInt("success") == 0) {
Message msg = Message.obtain(handler, error, resultObj.getString("errmsg"));
handler.sendMessage(msg);
} else {
getLoginUserInfo();
Message msg = Message.obtain(handler, add_school, resultObj.getString("successmsg"));
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_school_info:
if (status != null) {
statusView.setText(status);
}
if (schoolList != null && !schoolList.isEmpty()) {
SchoolAdapter adapter = new SchoolAdapter();
listView.setAdapter(adapter);
}
break;
case error:
onToast((String) msg.obj);
break;
case add_school:
onToast((String) msg.obj);
UICore.eventTask(this, this, init_school_info, "init_school_info", null);
break;
case delete_school:
onToast((String) msg.obj);
UICore.eventTask(this, this, init_school_info, "init_school_info", null);
break;
case set_school:
onToast((String) msg.obj);
break;
default:
break;
}
return false;
}
private void initEducationInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_edu_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
SchoolInfo info = gson.fromJson(result, SchoolInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
EducationInfo eduInfo = info.getEdu_info();
status = eduInfo.getStatus();
schoolList = eduInfo.getMyschools_list();
handler.sendEmptyMessage(init_school_info);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void deleteSchool(String schoolid) {
String url = UrlConfig.delete_school_info;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("schoolid", schoolid);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
getLoginUserInfo();
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, delete_school, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setEducationInfo() {
String url = UrlConfig.set_edu_info;
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
getLoginUserInfo();
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_school, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
if (loginUserInfo.getResults().getAuthok() == 1) {
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class SchoolAdapter extends BaseAdapter {
@Override
public int getCount() {
return schoolList.size();
}
@Override
public Object getItem(int position) {
return schoolList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.setting_listitem, null);
}
TextView school = (TextView) convertView.findViewById(R.id.setting_listitem_name);
ImageView add = (ImageView) convertView.findViewById(R.id.setting_listitem_image);
final SchoolEntry entry = schoolList.get(position);
if (entry != null) {
school.setText(entry.getSchool());
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int schoolid = entry.getSchoolid();
UICore.eventTask(SettingEducationActivity.this,
SettingEducationActivity.this, delete_school, "delete_school", String.valueOf(schoolid));
}
});
}
return convertView;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 0) {
UICore.eventTask(this, this, init_school_info, "init_school_info", null);
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.CommentEntry;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PictrueInfo;
import com.outsourcing.bottle.domain.PictureEnrty;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.ImageThumbnail;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
import com.outsourcing.bottle.widget.CustomListView;
/**
*
* @author 06peng
*
*/
public class UserPhotoActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private ImageView backView;
private ImageView uploadView;
private View contentView;
private ImageView avatarView;
private TextView nicknameView;
private ImageView sexView;
private TextView memoView;
private TextView timeView;
private ImageView editView;
private ImageView deleteView;
private ImageView bigImageView;
private TextView commentView;
private TextView locateView;
private LinearLayout locateLayout;
private CustomListView listView;
private View loadMoreView;
private TextView titleView;
private int visibleLastIndex = 0; // 最后的可视项索引
public int visibleItemCount; // 当前窗口可见项总数
private int ouid;
private int picid;
private int selectedItem;
private final int init_pic_info = 1;
private final int error = 2;
private final int delete_pic = 3;
private final int get_more_pic = 4;
private int page = 1;
public static final int upload_photo_requestcode = 5;
public static final int reply_comment_requestcode = 6;
public static final int reply_or_update_photo_requestcode = 7;
private static final int TYPE_DTAIL_PHOTO = 7;
private static final int TYPE_COMMENT_PHOTO = 8;
private static final int EXEU_LIKE_OP_SUCCESS = 9;
private static final int EXEU_LIKE_OP_FAILED = 10;
private static final int EXEU_LIKE_OPERATION = 11;
// private static final int EXEU_UNLIKE_OPERATION = 12;
private static final int REQUESTCODE_FOR_DRAW = 13;
private static final int forward_photo_requestcode = 14;
private static final int EXEU_DELETE_LOCATION = 15;
private static final int EXEU_DELETE_LOCATION_SUCCESS = 16;
private static final int EXEU_DELETE_LOCATION_FAILED = 17;
private static final int EXEU_DELETE_LOCATION_ROOT = 18;
private static final int download_image = 19;
private final int user_baseinfo_notfull = 20;
private final int complete_info = 21;
private List<CommentEntry> commentList;
private PictureEnrty picEntry;
private Handler handler;
private Bitmap avatarBitmap;
private Bitmap imageBitmap;
private CommentAdapter adapter;
private ImageView homeView;
private Button bt_paint_photo;
private Button bt_forward;
private Button bt_comment;
private ImageView iv_like;
private RelativeLayout rl_button_like;
private final int menu_uploadphoto = 15;
private final int menu_exprofile = 14;
private final int menu_exphoto = 13;
private final int menu_gainbt = 12;
private final int menu_sendbt = 11;
private TextView albumTitleView;
private ImageLoader loader;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.user_photo_root);
handler = new Handler(this);
ouid = getIntent().getIntExtra("ouid", 0);
picid = getIntent().getIntExtra("picid", 0);
// albumId = getIntent().getIntExtra("albumid", 0);
loader = new ImageLoader(this, AppContext.BottleTimelineIcon);
initWidget();
initSateMenu();
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
}
private void initWidget() {
homeView = (ImageView) findViewById(R.id.topbar_home);
homeView.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
uploadView = (ImageView) findViewById(R.id.topbar_menu);
uploadView.setImageResource(R.drawable.uploadphoto);
uploadView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.topbar_title);
titleView.setVisibility(View.INVISIBLE);
listView = (CustomListView) findViewById(R.id.refresh_view);
listView.setonRefreshListener(new CustomListView.OnRefreshListener() {
@Override
public void onRefresh() {
page = 1;
UICore.eventTask(UserPhotoActivity.this, UserPhotoActivity.this, init_pic_info, null, null);
}
});
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (adapter != null) {
int itemsLastIndex = adapter.getCount() + 2; // 数据集最后一项的索引
int lastIndex = itemsLastIndex + 1; // 加上底部的loadMoreView项 和 head项
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && visibleLastIndex == lastIndex) {
// 如果是自动加载,可以在这里放置异步加载数据的代码
System.out.println(">>>>>>>> load more <<<<<<<<<");
loadMoreView.setVisibility(View.VISIBLE);
page++;
UICore.eventTask(UserPhotoActivity.this, UserPhotoActivity.this, get_more_pic, null, null);
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
listView.setFirstVisiableItem(firstVisibleItem);
UserPhotoActivity.this.visibleItemCount = visibleItemCount;
visibleLastIndex = firstVisibleItem + visibleItemCount;
}
});
contentView = LayoutInflater.from(this).inflate(R.layout.user_photo_detail, null);
listView.addHeaderView(contentView);
loadMoreView = LayoutInflater.from(this).inflate(R.layout.refreshable_list_footer, null);
loadMoreView.setVisibility(View.GONE);
listView.addFooterView(loadMoreView);
avatarView = (ImageView) contentView.findViewById(R.id.user_photo_detail_avatar);
nicknameView = (TextView) contentView.findViewById(R.id.user_photo_detail_nickname);
sexView = (ImageView) contentView.findViewById(R.id.user_photo_detail_sex);
memoView = (TextView) contentView.findViewById(R.id.user_photo_detail_memo);
timeView = (TextView) contentView.findViewById(R.id.user_photo_detail_time);
editView = (ImageView) contentView.findViewById(R.id.user_photo_detail_edit);
editView.setOnClickListener(this);
deleteView = (ImageView) contentView.findViewById(R.id.user_photo_detail_delete);
deleteView.setOnClickListener(this);
bigImageView = (ImageView) contentView.findViewById(R.id.user_photo_image);
bigImageView.setVisibility(View.GONE);
bigImageView.setOnClickListener(this);
commentView = (TextView) contentView.findViewById(R.id.user_photo_comment_textview);
albumTitleView = (TextView)contentView.findViewById(R.id.user_photo_album_title);
locateView = (TextView) contentView.findViewById(R.id.user_photo_locate_textview);
locateLayout = (LinearLayout) contentView.findViewById(R.id.user_photo_locate_layout);
locateLayout.setOnClickListener(this);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
selectedItem = arg2 - 2;
ArrayList<String> choiceList = new ArrayList<String>();
if (commentList.get(selectedItem).getComment_location() != null && !commentList.get(selectedItem).getComment_location().equals("")) {
choiceList.add(getString(R.string.bottle_txt_check_location));
}
if (commentList.get(selectedItem).getComment_uid() != AppContext.getInstance().getLogin_uid()) {
choiceList.add(getString(R.string.bottle_txt_reply_comment));
}
if (choiceList.size() > 0) {
String[] chooices = new String[choiceList.size()];
chooices = choiceList.toArray(chooices);
doMenuAction(chooices);
}
}
});
/******************新增组件**********************************/
bt_paint_photo = (Button)findViewById(R.id.user_paint_photo);
bt_paint_photo.setOnClickListener(this);
bt_forward = (Button)findViewById(R.id.bt_user_photo_forward);
bt_forward.setOnClickListener(this);
bt_comment = (Button)findViewById(R.id.bt_user_photo_comment);
bt_comment.setOnClickListener(this);
rl_button_like = (RelativeLayout)findViewById(R.id.rl_button_like);
rl_button_like.setOnClickListener(this);
iv_like = (ImageView)findViewById(R.id.comment_button_like_icon);
}
private void updateUI() {
if (picEntry == null) {
return;
}
uploadView.setVisibility(View.VISIBLE);
homeView.setVisibility(View.VISIBLE);
findViewById(R.id.user_photo_root_layout).setVisibility(View.VISIBLE);
((LinearLayout) contentView.findViewById(R.id.user_photo_detail_layout)).setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(picEntry.getAlbum_title())) {
albumTitleView.setVisibility(View.VISIBLE);
albumTitleView.setText(TextUtil.R("exchange_bt_album") +":"+ picEntry.getAlbum_title());
albumTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Intent intent = new Intent(UserPhotoActivity.this, AlbumsActivity.class);
// intent.putExtra("ouid", ouid);
// startActivity(intent);
Intent intent = new Intent(UserPhotoActivity.this, PhotosActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("albumid", picEntry.getAlbumid());
startActivity(intent);
}
});
} else {
albumTitleView.setVisibility(View.GONE);
}
nicknameView.setText(picEntry.getNickname());
if (!TextUtils.isEmpty(picEntry.getMemo())) {
memoView.setText(TextUtil.R("user_space_pic_memo")+":" + picEntry.getMemo());
memoView.setVisibility(View.VISIBLE);
} else {
memoView.setVisibility(View.GONE);
}
if (picEntry.getSex() == 1) {
sexView.setBackgroundResource(R.drawable.male);
} else if (picEntry.getSex() == 2) {
sexView.setBackgroundResource(R.drawable.female);
}
timeView.setText("#" + picEntry.getPic_time());
commentView.setText(TextUtil.R("exchange_feed_comment_title")+picEntry.getPic_desc());
if (picEntry.getPic_location() != null && !picEntry.getPic_location().equals("")) {
locateLayout.setVisibility(View.VISIBLE);
locateView.setText(picEntry.getPic_location());
locateView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(picEntry.getLocation_delete_enable() == 1){
final Context dialogContext = new ContextThemeWrapper(UserPhotoActivity.this, android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(UserPhotoActivity.this, MapViewActivity.class);
intent.putExtra("longitude", picEntry.getPic_lng());
intent.putExtra("latidute", picEntry.getPic_lat());
intent.putExtra("location",picEntry.getPic_location());
startActivity(intent);
} else {
UICore.eventTask(UserPhotoActivity.this, UserPhotoActivity.this, EXEU_DELETE_LOCATION_ROOT, "", picEntry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(UserPhotoActivity.this, android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent intent = new Intent(UserPhotoActivity.this, MapViewActivity.class);
intent.putExtra("longitude", picEntry.getPic_lng());
intent.putExtra("latidute", picEntry.getPic_lat());
intent.putExtra("location", picEntry.getPic_location());
startActivity(intent);
}
});
builder.create().show();
}
}
});
} else {
locateLayout.setVisibility(View.GONE);
}
if (picEntry.getOuid() == AppContext.getInstance().getLogin_uid()) {
editView.setVisibility(View.VISIBLE);
deleteView.setVisibility(View.VISIBLE);
uploadView.setVisibility(View.VISIBLE);
// bt_paint_photo.setVisibility(View.VISIBLE);
} else {
uploadView.setVisibility(View.GONE);
deleteView.setVisibility(View.GONE);
editView.setVisibility(View.GONE);
// bt_paint_photo.setVisibility(View.GONE);
}
adapter = new CommentAdapter();
listView.setAdapter(adapter);
if (picEntry.getPic_like_mode() == 0) {
rl_button_like.setVisibility(View.INVISIBLE);
} else if (picEntry.getPic_like_mode() == 1) {
iv_like.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.like_gray2));
} else if (picEntry.getPic_like_mode() == 2) {
iv_like.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.like_red2));
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_pic_info:
updateUI();
new Thread() {
public void run() {
downloadImage();
};
}.start();
listView.onRefreshComplete();
break;
case error:
onToast((String) msg.obj);
break;
case delete_pic:
onToast((String) msg.obj);
Intent intent = new Intent(this, PhotosActivity.class);
setResult(RESULT_OK, intent);
finish();
break;
case get_more_pic:
if (adapter != null) {
adapter.notifyDataSetChanged();
}
loadMoreView.setVisibility(View.GONE);
break;
case EXEU_LIKE_OP_SUCCESS:
onToast((String) msg.obj);
iv_like.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.like_red2));
rl_button_like.setOnClickListener(null);
// UICore.eventTask(this, this, init_pic_info, "", null);
break;
case EXEU_LIKE_OP_FAILED:
onToast((String) msg.obj);
// UICore.eventTask(this, this, init_pic_info, "", null);
break;
case EXEU_DELETE_LOCATION_SUCCESS:
onToast((String) msg.obj);
UICore.eventTask(UserPhotoActivity.this, UserPhotoActivity.this, init_pic_info, "", null);
break;
case EXEU_DELETE_LOCATION_FAILED:
onToast((String) msg.obj);
break;
case download_image:
Bitmap tempBP = (Bitmap) msg.obj;
findViewById(R.id.rl_bottle_content_photo).setVisibility(View.VISIBLE);
findViewById(R.id.pull_to_refresh_progress).setVisibility(View.GONE);
bigImageView.setVisibility(View.VISIBLE);
if (avatarBitmap != null) {
avatarView.setImageBitmap(avatarBitmap);
}
if (tempBP != null) {
bigImageView.setImageBitmap(tempBP);
}
break;
case user_baseinfo_notfull:
showChoseMes(getString(R.string.exchange_complete_profile_tips), complete_info);
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
}else if (v == homeView) {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
} else if (v == uploadView) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putString("upload_from", "photo_detail");
extras.putInt("albumid", picEntry.getAlbumid());
extras.putInt("ouid", picEntry.getOuid());
intent.putExtras(extras);
startActivity(intent);
} else if (v == locateLayout) {
Intent intent = new Intent(this, MapViewActivity.class);
intent.putExtra("longitude", picEntry.getPic_lng());
intent.putExtra("latidute", picEntry.getPic_lat());
intent.putExtra("location", picEntry.getPic_location());
startActivity(intent);
} else if (v == deleteView) {
showChoseMes(getString(R.string.photo_delte_confirm), delete_pic);
} else if (v == editView) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.EDIT_PHOTO);
extras.putInt("picid", picid);
extras.putString("photoname", picEntry.getPic_desc());
intent.putExtras(extras);
startActivityForResult(intent, reply_or_update_photo_requestcode);
}
// else if (v == replyView) {
// Intent intent = new Intent(this, ExpandEditActivity.class);
// Bundle extras = new Bundle();
// extras.putString("from_type", AppContext.REPLY_PHOTO);
// extras.putInt("picid", picid);
// intent.putExtras(extras);
// startActivityForResult(intent, reply_or_update_photo_requestcode);
// }
else if (v == bigImageView) {
if (picEntry.getPic_srcpicid()!=0) {
String choices[] = new String[2];
choices[0] = getString(R.string.user_space_pic_src);
choices[1] = getString(R.string.bottle_txt_feed_comment_tuya);
chooseAction(choices, TYPE_DTAIL_PHOTO);
} else {
byte[] tempBytes = null;
try {
tempBytes = ServiceUtils.BitmapTobytes(imageBitmap);
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", picEntry.getPic_url());
bigPicIntent.putExtra("thumbnail", tempBytes);
startActivity(bigPicIntent);
}
} else if (v == bt_paint_photo) {
if (imageBitmap == null) {
return;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] tempBytes = baos.toByteArray();
File file = Utility.getNextFileName();
FileOutputStream fs = null;
try {
fs = new FileOutputStream(file);
fs.write(tempBytes);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (null != fs) {
fs.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Uri fileUri = Uri.fromFile(file);
Intent newIntent = new Intent( UserPhotoActivity.this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_DRAW );
newIntent.setData( fileUri );
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + file.getAbsolutePath() ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
// mSessionId = StringUtils.getSha256( System.currentTimeMillis() + Utility.API_KEY );
// newIntent.putExtra( "output-hires-session-id", mSessionId );
// startActivity(newIntent);
startActivityForResult(newIntent, REQUESTCODE_FOR_DRAW);
overridePendingTransition(R.anim.translate_right_in, R.anim.translate_left_in);
} else if (v == bt_forward) {
if ( ouid == AppContext.getInstance().getLogin_uid()) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_forward_to_friend);
choices[1] = getString(R.string.bottle_txt_forward_to_platform);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent forwardIntent = new Intent(UserPhotoActivity.this, ChooseFriendActivity.class);
Bundle forwardBundle = new Bundle();
forwardBundle.putInt("choose_friend_type", AppContext.CHOOSE_FRIEND_FORWARD_PHOTO_TYPE);
forwardBundle.putInt("picid", picid);
forwardBundle.putInt("pic_uid", ouid);
forwardBundle.putInt("select_mode", 1);
forwardIntent.putExtras(forwardBundle);
startActivity(forwardIntent);
} else {
Intent intent = new Intent(UserPhotoActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.FORWARD_PHOTO);
extras.putInt("picid", picid);
intent.putExtras(extras);
startActivityForResult(intent, forward_photo_requestcode);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_forward_to_platform);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent intent = new Intent(UserPhotoActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.FORWARD_PHOTO);
extras.putInt("picid", picid);
intent.putExtras(extras);
startActivityForResult(intent, forward_photo_requestcode);
}
});
builder.create().show();
}
} else if (v == bt_comment) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_PHOTO);
extras.putInt("picid", picid);
intent.putExtras(extras);
startActivityForResult(intent, reply_or_update_photo_requestcode);
} else if (v == rl_button_like) {
UICore.eventTask(this, this, EXEU_LIKE_OPERATION, "", null);
}
}
@Override
public void doSelectChooseEvent(int which, int chooseType) {
if (chooseType == TYPE_DTAIL_PHOTO) {
switch (which) {
case 0:
Intent intent = new Intent(this, UserPhotoActivity.class);
intent.putExtra("picid", picEntry.getPic_srcpicid());
intent.putExtra("ouid", ouid);
startActivity(intent);
break;
case 1:
Intent bigPicIntent = new Intent(this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", picEntry.getPic_tuya_url());
startActivity(bigPicIntent);
break;
default:
break;
}
}else if (chooseType == TYPE_COMMENT_PHOTO) {
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_pic_info:
initPicInfo();
break;
case delete_pic:
deletePic();
break;
case get_more_pic:
getMoreComment();
break;
case EXEU_LIKE_OPERATION:
likeIOperationPicex(picid);
break;
case EXEU_DELETE_LOCATION:
CommentEntry mEntry = (CommentEntry)obj;
deleteLocation(String.valueOf(mEntry.getLocation_objtype_2()), String.valueOf(mEntry.getLocation_objid_2()));
break;
case EXEU_DELETE_LOCATION_ROOT:
PictureEnrty mPicEntry = (PictureEnrty)obj;
deleteLocation(String.valueOf(mPicEntry.getLocation_objtype()), String.valueOf(mPicEntry.getLocation_objid()));
break;
default:
break;
}
}
/**
*
* @param objtype 要清除的位置的类型:选择项:(1)瓶子动态的位置信息、(2)交换动态留言的位置信息、(3)照片评论的位置信息、(4)私信的位置信息、(5)照片的位置信息
* @param objid objid
*/
private void deleteLocation(String objtype,String objid) {
StringBuffer url = new StringBuffer(UrlConfig.delete_location);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&objtype=" + objtype);
url.append("&objid=" + objid);
ServiceUtils.dout("deleteLocation url:" + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
ServiceUtils.dout("deleteLocation result:" + result);
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_FAILED, errmsg);
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initPicInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_pic_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&picid=" + picid);
url.append("&count=20");
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
PictrueInfo info = gson.fromJson(result, PictrueInfo.class);
if (info.getResults().getAuthok() == 0) {
String errmsg = info.getResults().getErrmsg();
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
picEntry = info.getPic_info();
commentList = info.getComments_list();
handler.sendEmptyMessage(init_pic_info);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void downloadImage() {
avatarBitmap = HttpUtils.getBitmapFromUrl(UserPhotoActivity.this, picEntry.getAvatar());
imageBitmap = HttpUtils.getBitmapFromUrl(UserPhotoActivity.this, picEntry.getPic_url());
Bitmap tempBitmap = null;
if (null != imageBitmap && imageBitmap.getWidth() > CanvasWidth) {
float scale = ImageThumbnail.reckonThumbnail(
imageBitmap.getWidth(), imageBitmap.getHeight(), CanvasWidth - 20, 0);
tempBitmap = ImageThumbnail.PicZoom(imageBitmap,
(int) (imageBitmap.getWidth() / scale), (int) (imageBitmap.getHeight() / scale));
} else {
tempBitmap = imageBitmap;
}
Message message = handler.obtainMessage(download_image, tempBitmap);
handler.sendMessage(message);
}
private void getMoreComment() {
StringBuffer url = new StringBuffer(UrlConfig.get_pic_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&picid=" + picid);
url.append("&count=20");
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
PictrueInfo info = gson.fromJson(result, PictrueInfo.class);
if (info.getResults().getAuthok() == 0) {
String errmsg = info.getResults().getErrmsg();
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
List<CommentEntry> moreCommentList = info.getComments_list();
if (moreCommentList != null && !moreCommentList.isEmpty()) {
commentList.addAll(moreCommentList);
}
handler.sendEmptyMessage(get_more_pic);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void deletePic() {
String url = UrlConfig.delete_pic;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("picid", String.valueOf(picid));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result == null) {
return;
}
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, delete_pic, successmsg);
handler.sendMessage(msg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == delete_pic) {
UICore.eventTask(this, this, delete_pic, "delete_pic", null);
} else if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
}
}
public class CommentAdapter extends BaseAdapter {
@Override
public int getCount() {
return commentList == null ? 0 : commentList.size();
}
@Override
public Object getItem(int arg0) {
return commentList == null ? null : commentList.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.user_photo_comment_item, null);
}
RemoteImageView avatar = (RemoteImageView) convertView.findViewById(R.id.user_photo_comment_item_avatar);
TextView content = (TextView) convertView.findViewById(R.id.user_photo_comment_item_nameandcontent);
TextView time = (TextView) convertView.findViewById(R.id.user_photo_comment_item_timeandlocattion);
TextView reply = (TextView) convertView.findViewById(R.id.user_photo_comment_item_reply);
LinearLayout replyLayout = (LinearLayout) convertView.findViewById(R.id.user_photo_comment_item_reply_layout);
Button feed_reply_comment = (Button) convertView.findViewById(R.id.feed_reply_comment);
ImageView up = (ImageView) convertView.findViewById(R.id.user_photo_comment_item_up);
ImageView mfeedReplyPhoto = (ImageView) convertView.findViewById(R.id.photo);
RelativeLayout comment_content_photo = (RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo);
ImageView iv_feed_comment_love = (ImageView) convertView.findViewById(R.id.iv_feed_comment_love);
final CommentEntry entry = commentList.get(position);
if (entry != null) {
avatar.setDefaultImage(R.drawable.avatar_default_big);
avatar.setImageUrl(entry.getComment_avatar(), position, listView);
String nickName = null;
if (entry.getComment_uid() != AppContext.getInstance().getLogin_uid()) {
nickName = (!TextUtils.isEmpty(entry.getComment_nickname())) ? ("<font color='#DA4A37'>"
+ entry.getComment_nickname()+ "</font>") : "";
} else {
nickName = (!TextUtils.isEmpty(entry.getComment_nickname())) ? ("<font color='#3F99D8'>"
+ entry.getComment_nickname() + "</font>") : "";
}
if (TextUtil.notEmpty(entry.getComment_tuyapic_small())) {
loader.DisplayImage(entry.getComment_tuyapic_small(), mfeedReplyPhoto, R.drawable.album_nophoto);
}
content.setText(Html.fromHtml(nickName + " " + TextUtil.htmlEncode(entry.getComment_content())));
String timeStr = (!TextUtils.isEmpty(entry.getComment_time()))?("#"+entry.getComment_time()):"";
String location = (!TextUtils.isEmpty(entry.getComment_location()))?("@"+entry.getComment_location()):"";
time.setText(timeStr+ " " + location);
if (!TextUtils.isEmpty(location)) {
time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(entry.getLocation_delete_enable_2() == 1){
final Context dialogContext = new ContextThemeWrapper(
UserPhotoActivity.this, android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
dialog.dismiss();
Intent intent = new Intent(
UserPhotoActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
entry.getComment_lng());
intent.putExtra("latidute",
entry.getComment_lat());
intent.putExtra(
"location",
entry.getComment_location());
startActivity(intent);
} else {
UICore.eventTask(UserPhotoActivity.this, UserPhotoActivity.this, EXEU_DELETE_LOCATION, "", entry);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
UserPhotoActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
UserPhotoActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
entry.getComment_lng());
intent.putExtra("latidute",
entry.getComment_lat());
intent.putExtra(
"location",
entry.getComment_location());
startActivity(intent);
}
});
builder.create().show();
}
}
});
}
if (entry.getComment_type() == 1) {
iv_feed_comment_love.setVisibility(View.VISIBLE);
} else {
iv_feed_comment_love.setVisibility(View.GONE);
}
if (entry.getComment_replycomment() != null && !entry.getComment_replycomment().equals("")) {
up.setVisibility(View.VISIBLE);
replyLayout.setVisibility(View.VISIBLE);
reply.setText(entry.getComment_replycomment());
} else {
replyLayout.setVisibility(View.GONE);
up.setVisibility(View.GONE);
}
if (entry.getComment_uid() != AppContext.getInstance()
.getLogin_uid()&&entry.getComment_type() == 0) {
feed_reply_comment.setVisibility(View.VISIBLE);
feed_reply_comment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent commentIntent = new Intent(UserPhotoActivity.this,ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",AppContext.REPLY_COMMENT);
commentBundle.putString("return_type",UserPhotoActivity.class.getSimpleName());
commentBundle.putInt("commentid",entry.getCommentid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
}
});
}else {
feed_reply_comment.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(entry.getComment_tuyapic_small())) {
comment_content_photo.setVisibility(View.VISIBLE);
mfeedReplyPhoto.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View paramView) {
String choices[] = new String[2];
choices[0] = getString(R.string.user_space_pic_src);
choices[1] = getString(R.string.bottle_txt_feed_comment_tuya);
final Context dialogContext = new ContextThemeWrapper(UserPhotoActivity.this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
Intent intent = new Intent(UserPhotoActivity.this, UserPhotoActivity.class);
intent.putExtra("picid", entry.getComment_tuyapicid());
intent.putExtra("ouid", entry.getComment_uid());
startActivity(intent);
break;
case 1:
Intent bigPicIntent = new Intent(UserPhotoActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", entry.getComment_tuyapic_tuya());
startActivity(bigPicIntent);
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
});
}else {
comment_content_photo.setVisibility(View.GONE);
}
}
avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(UserPhotoActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", entry.getComment_uid());
startActivity(spaceIntent);
}
});
return convertView;
}
}
public static class ViewHolder {
ImageView avatar;
TextView content;
TextView time;
LinearLayout replyLayout;
TextView reply;
ImageView up;
}
@Override
protected void onResume() {
super.onResume();
if(AppContext.getInstance().isFromUserPhotoActivity()){
AppContext.getInstance().setFromUserPhotoActivity(false);
page = 1;
UICore.eventTask(this, this, init_pic_info, "", null);
}
}
@Override
protected void onActivityResult(int requestCode, int arg1, Intent intent) {
if (arg1 == RESULT_OK) {
if (null != intent) {
if (intent.getBooleanExtra("need_refresh", false)) {
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
}
}
if (requestCode == upload_photo_requestcode) {
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
} else if (requestCode == reply_comment_requestcode) {
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
} else if (requestCode == reply_or_update_photo_requestcode) {
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
} else if (requestCode == forward_photo_requestcode) {
UICore.eventTask(this, this, init_pic_info, "init_pic_info", null);
}
if (requestCode == REQUESTCODE_FOR_DRAW) {
Intent commentIntent = new Intent(this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.PAINT_PHOTO);
commentBundle.putInt("picid", picid);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
}
}
super.onActivityResult(requestCode, arg1, intent);
}
private void doMenuAction(String[] choices) {
final Context dialogContext = new ContextThemeWrapper(UserPhotoActivity.this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
CommentEntry entry = commentList.get(selectedItem);
switch (which) {
case 0:
Intent intent = new Intent(UserPhotoActivity.this, MapViewActivity.class);
if (entry.getComment_location() != null && !entry.getComment_location().equals("")) {
intent.putExtra("longitude", entry.getComment_lng());
intent.putExtra("latidute", entry.getComment_lat());
intent.putExtra("location", entry.getComment_location());
startActivity(intent);
} else if (entry.getCommentid() != AppContext.getInstance().getLogin_uid()) {
Intent reply_intent = new Intent(UserPhotoActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_COMMENT);
extras.putString("return_type", "userphotoactivity");
extras.putInt("commentid", entry.getCommentid());
reply_intent.putExtras(extras);
startActivityForResult(reply_intent, reply_comment_requestcode);
}
break;
case 1:
if (entry != null) {
Intent reply_intent = new Intent(UserPhotoActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.REPLY_COMMENT);
extras.putInt("commentid", entry.getCommentid());
reply_intent.putExtras(extras);
startActivityForResult(reply_intent, reply_comment_requestcode);
}
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
private void likeIOperationPicex(int picid) {
StringBuffer url = new StringBuffer(UrlConfig.like_photo);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&picid=" + picid);
ServiceUtils.dout("likeIOperationPicex url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("likeIOperationPicex result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_LIKE_OP_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_LIKE_OP_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
// View view = null;
// private View mLikeView;
// private CustomPopupWindow mLikePopview;
//
// /** 喜欢pop */
// private void initLikePopupWindow() {
//
// LayoutInflater mLayoutInflater = LayoutInflater.from(this);
// mLikeView = mLayoutInflater.inflate(R.layout.pop_bottle_like_left, null);
// ImageView iv_unlike = (ImageView) mLikeView
// .findViewById(R.id.iv_unlike);
// ImageView iv_like = (ImageView) mLikeView.findViewById(R.id.iv_like);
// iv_unlike.setOnClickListener(this);
// iv_like.setOnClickListener(this);
// mLikePopview = new CustomPopupWindow(mLikeView,
// LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// mLikePopview.setBackgroundDrawable(getResources().getDrawable(
// R.drawable.ic_launcher));
// mLikePopview.setOutsideTouchable(true);
// mLikePopview.update();
// mLikePopview.setTouchable(true);
// mLikePopview.setFocusable(true);
// }
//
// public void showInfoPopupWindow(View achorView, int picid) {
// this.picid = picid;
// if (mLikePopview.isShowing()) {
// mLikePopview.dismiss();
// } else {
// // mLikePopview.showAtLocation(achorView, Gravity.RIGHT, 0, 0);
// mLikePopview.showAsDropDown(achorView, 60, -60);
// }
// }
SatelliteMenu menu;
private void initSateMenu() {
if (menu == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.menu_layout);
menu = new SatelliteMenu(this);
// menu.setExpandDuration(500);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
menu.setTotalSpacingDegree(90.0f);
menu.setCloseItemsOnClick(true);
layout.addView(menu);
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
}
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: //扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(UserPhotoActivity.this, ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: //捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(UserPhotoActivity.this, ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: //交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(UserPhotoActivity.this, ChooseFriendActivity.class);
exchangeInfoIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: //交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(UserPhotoActivity.this, ChooseFriendActivity.class);
exchangeFileIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(UserPhotoActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.aviary.android.feather.library.utils.StringUtils;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.Utility;
import com.outsourcing.bottle.widget.crop.CropImage;
import com.outsourcing.bottle.widget.crop.CropImageView;
/**
*
* @author 06peng
*
*/
public class CropImageActivity extends BasicActivity {
private static final String TAG = CropImageActivity.class.getSimpleName();
private static final int RESULT_CROPIMAGE_WITH_DATA = 101;
private CropImageView mImageView;
private Bitmap mBitmap;
private CropImage mCrop;
/** session id for the hi-res post processing */
private String mSessionId;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.crop_view);
init();
}
String path = null;
private void init() {
path = getIntent().getStringExtra("path");
Log.d("may", "path=" + path);
// mBitmap = BitmapFactory.decodeFile(path);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
options.inInputShareable = true;
options.inSampleSize = 5;
try {
if (android.os.Build.VERSION.SDK_INT < 11) {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options, true);
}
} catch (Exception ex) {
ex.printStackTrace();
}
FileInputStream fin = null;
try {
fin = new FileInputStream(path);
mBitmap = BitmapFactory.decodeStream(fin, null, options);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally{
if (null != fin) {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
mImageView = (CropImageView) findViewById(R.id.image);
mImageView.setImageBitmap(mBitmap);
mImageView.setImageBitmapResetBase(mBitmap, true);
mCrop = new CropImage(this, mImageView, true, 600, 600);
mCrop.crop(mBitmap);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
File uploadFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
}
return super.onKeyDown(keyCode, event);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.cancel:
mCrop.cropCancel();
break;
// case R.id.crop:
// mCrop.crop(mBitmap);
// break;
case R.id.save:
// inputDialog();
String cacheDir = android.os.Environment.getExternalStorageDirectory()+ "/" + AppContext.SD_PATH + "/upload";
saveBitmap(cacheDir,mCrop.cropAndSave(mBitmap));
File file = new File(cacheDir,"upload.jpeg");
if (null != file) {
Uri fileUri = Uri.fromFile(file);
startFeather(fileUri);
}
// finish();
break;
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RESULT_CROPIMAGE_WITH_DATA) {
if (resultCode == RESULT_OK) {
finish();
}else {
File uploadFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
finish();
}
}
};
String mOutputFilePath;
/**
* Once you've chosen an image you can start the feather activity
*
* @param uri
*/
private void startFeather( Uri uri ) {
if ( !Utility.isExternalStorageAvilable() ) {
return;
}
// create a temporary file where to store the resulting image
File file = Utility.getNextFileName();
if ( null != file ) {
mOutputFilePath = file.getAbsolutePath();
} else {
new AlertDialog.Builder( this ).setTitle( android.R.string.dialog_alert_title ).setMessage( "Failed to create a new File" )
.show();
return;
}
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_EDIT );
// set the source image uri
newIntent.setData( uri );
// pass the required api_key and secret ( see
// http://developers.aviary.com/ )
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + mOutputFilePath ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.PNG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
// you can pass the maximum allowed image size, otherwise feather will determine
// the max size based on the device memory
// Here we're passing the current display size as max image size because after
// the execution of Aviary we're saving the HI-RES image so we don't need a big
// image for the preview
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
// Enable/disable the default borders for the effects
newIntent.putExtra( "effect-enable-borders", true );
mSessionId = StringUtils.getSha256( System.currentTimeMillis() + Utility.API_KEY );
Log.d( TAG, "session: " + mSessionId + ", size: " + mSessionId.length() );
newIntent.putExtra( "output-hires-session-id", mSessionId );
startActivityForResult(newIntent, RESULT_CROPIMAGE_WITH_DATA);
}
public void saveBitmap(String dir,Bitmap bmp) {
File file = new File(dir);
String path = null;
if (!file.exists())
file.mkdirs();
try {
path = file.getPath() + "/upload.jpeg";
FileOutputStream fileOutputStream = new FileOutputStream(path);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
/**
*
* @author 06peng
*
*/
public class SetAvatarAndNameActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private final int set_avatar_nickname = 1;
private final int error = 2;
private final int activity_result_aviary = 3;
private Bitmap bitMap;
private File picFile;
private boolean hasImage;
private final int activity_result_camara_with_data = 1006;
private final int activity_result_pick_with_data = 18;
private Handler handler;
private RelativeLayout layout;
private ImageView avatarView;
private EditText nameView;
private Button button;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.register_setavatar_nickname);
initWidget();
}
private void initWidget() {
layout = (RelativeLayout) findViewById(R.id.splash_image_layout);
layout.setOnClickListener(this);
avatarView = (ImageView) findViewById(R.id.splash_image);
nameView = (EditText) findViewById(R.id.splash_set_edit);
button = (Button) findViewById(R.id.splash_set_button);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == layout) {
doPickPhotoAction();
} else if (v == button) {
if (nameView.getText().toString().trim().equals("")) {
onToast(getString(R.string.login_txt_register_set_username_error));
return;
} else if (!hasImage) {
onToast(getString(R.string.login_txt_register_set_avatar_error));
return;
}
UICore.eventTask(this, this, set_avatar_nickname, "", null);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
} else if (keyCode == KeyEvent.KEYCODE_HOME) {
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case set_avatar_nickname:
setAvatarAndNickName();
break;
default:
break;
}
}
private void setAvatarAndNickName() {
String url = UrlConfig.set_avatar_nickname;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("nickname", nameView.getText().toString().trim());
try {
HashMap<String, File> filesMap = new HashMap<String, File>();
if (picFile != null) {
filesMap.put("pic", picFile);
}
String result = HttpUtils.post(url, paramsMap, filesMap);
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_avatar_nickname, successmsg);
handler.sendMessage(msg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case set_avatar_nickname:
Intent intent = new Intent(this, HomeActivity.class);
startActivity(intent);
break;
case error:
onToast(msg.obj.toString());
break;
default:
break;
}
return false;
}
/**
* 拍照获取图片
*
*/
protected void doTakePhoto() {
try {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
Uri pictureUri = Uri.fromFile(picFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
startActivityForResult(cameraIntent, activity_result_camara_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
/**
* 从本地手机中选择图片
*/
// private void doSelectImageFromLoacal(){
// Intent localIntent = new Intent();
// localIntent.setType("image/*");
// localIntent.setAction("android.intent.action.GET_CONTENT");
// Intent localIntent2 = Intent.createChooser(localIntent, getString(R.string.expand_edit_choose_photo));
// startActivityForResult(localIntent2, activity_result_pick_with_data);
// }
// 封装请求Gallery的intent
public Intent getPhotoPickIntent() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
// 请求Gallery程序
protected void doPickPhotoFromGallery() {
try {
// Launch picker to choose photo for selected contact
final Intent intent = getPhotoPickIntent();
startActivityForResult(intent, activity_result_pick_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
protected void doCropPhoto(File f) {
try {
// 启动gallery去剪辑这个照片
final Intent intent = getCropImageIntent(Uri.fromFile(f));
startActivityForResult(intent, activity_result_pick_with_data);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Constructs an intent for image cropping. 调用图片剪辑程序
*/
public Intent getCropImageIntent(Uri photoUri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap oldBitmap = bitMap;
switch (requestCode) {
case activity_result_pick_with_data: //从本地选择图片
if (data == null) {
return;
}
bitMap = data.getParcelableExtra("data");
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileOutputStream ous = new FileOutputStream(picFile);
bitMap.compress(Bitmap.CompressFormat.JPEG, 100, ous);
if ( !Utility.isExternalStorageAvilable() ) {
return;
}
Uri fileUri = Uri.fromFile(picFile);
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_AVATAR );
newIntent.setData( fileUri );
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + picFile.getAbsolutePath() ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
startActivityForResult(newIntent, activity_result_aviary );
if (oldBitmap != null && !oldBitmap.isRecycled()) {
oldBitmap.recycle();
oldBitmap = null;
}
} catch (Exception e) {
e.printStackTrace();
}
break;
case activity_result_camara_with_data: //拍照
if (picFile == null) {
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFileDir, "upload.jpeg");
}
doCropPhoto(picFile);
break;
case activity_result_aviary:
if (resultCode == RESULT_OK) {
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileInputStream in = new FileInputStream(picFile);
BitmapFactory.Options options1 = new BitmapFactory.Options();
options1.inPurgeable = true;
options1.inInputShareable = true;
options1.inSampleSize = 2;
try {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
} catch (Exception ex) {
ex.printStackTrace();
}
WeakReference<Bitmap> bitmapResult = new WeakReference<Bitmap>(BitmapFactory
.decodeStream(in, null, options1));
Bitmap bt = bitmapResult.get();
findViewById(R.id.splash_image_camera).setVisibility(View.GONE);
avatarView.setImageBitmap(bt);
hasImage = true;
} catch (Exception e) {
e.printStackTrace();
} finally{
}
}
break;
}
}
private void doPickPhotoAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String[] choices;
choices = new String[2];
choices[0] = getString(R.string.expand_edit_take_photo); // 拍照
choices[1] = getString(R.string.expand_edit_choose_photo); // 从相册中选择
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.expand_edit_photo_title);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_MOUNTED)) {// 判断是否有SD卡
doTakePhoto();// 用户点击了从照相机获取
}
break;
case 1:
doPickPhotoFromGallery();// 从相册中去获取
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (bitMap != null && !bitMap.isRecycled()) {
bitMap.recycle();
bitMap = null;
hasImage = false;
File uploadFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.MessageEntry;
import com.outsourcing.bottle.domain.MessageInfo;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.CustomListView;
/**
*
* @author 06peng
*
*/
public class MessageListActivity extends BasicActivity implements Callback, OnClickListener {
private ImageView backView;
private ImageView moreView;
// private ImageView noticeView;
// private LinearLayout messageCountLayout;
// private TextView countView;
private CustomListView listView;
private int visibleLastIndex = 0; // 最后的可视项索引
public int visibleItemCount; // 当前窗口可见项总数
private View loadMoreView;
private LinearLayout bottomLayout;
private ImageView avatarView;
private TextView contentView;
private TextView btnCount;
// private ImageView messageView;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
private PushNoticeInfo pushInfo;
private final int init_message_info = 1;
private final int error = 2;
private final int user_baseinfo_notfull = 3;
private final int complete_info = 4;
private final int more = 5;
private final int refresh = 6;
private int page = 1;
private final int menu_uploadphoto = 15;
private final int menu_exprofile = 14;
private final int menu_exphoto = 13;
private final int menu_gainbt = 12;
private final int menu_sendbt = 11;
private Handler handler;
private ImageLoader userImageLoader;
private List<MessageEntry> messageList;
private MessageAdapter adapter;
private PushBroadcastReceiver receiver;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.message_list);
handler = new Handler(this);
userImageLoader = new ImageLoader(this, AppContext.UserAvatarIcon);
initWidget();
initSateMenu();
UICore.eventTask(this, this, init_message_info, "init_message_info", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
moreView = (ImageView) findViewById(R.id.topbar_menu);
moreView.setOnClickListener(this);
// noticeView = (ImageView) findViewById(R.id.topbar_notice);
// noticeView.setOnClickListener(this);
// messageCountLayout = (LinearLayout) findViewById(R.id.notice_layout);
// messageCountLayout.setVisibility(View.GONE);
// countView = (TextView) findViewById(R.id.notice_count);
listView = (CustomListView) findViewById(R.id.notice_list);
loadMoreView = LayoutInflater.from(this).inflate(R.layout.refreshable_list_footer, null);
loadMoreView.setVisibility(View.GONE);
listView.addFooterView(loadMoreView);
listView.setonRefreshListener(new CustomListView.OnRefreshListener() {
@Override
public void onRefresh() {
page = 1;
new Thread() {
public void run() {
refresh();
};
}.start();
}
});
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
int itemsLastIndex = adapter.getCount() + 1; // 数据集最后一项的索引
int lastIndex = itemsLastIndex + 1; // 加上底部的loadMoreView项 和 head项
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && visibleLastIndex == lastIndex) {
// 如果是自动加载,可以在这里放置异步加载数据的代码
loadMoreView.setVisibility(View.VISIBLE);
page++;
new Thread() {
@Override
public void run() {
loadMoreMessageInfo();
}
}.start();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
listView.setFirstVisiableItem(firstVisibleItem);
MessageListActivity.this.visibleItemCount = visibleItemCount;
visibleLastIndex = firstVisibleItem + visibleItemCount;
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
if (arg2 == adapter.getCount() + 1) {
return;
}
Intent intent = new Intent(MessageListActivity.this, ConversationListActivity.class);
intent.putExtra("ouid", messageList.get(arg2 - 1).getUid());
startActivity(intent);
}
});
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
avatarView = (ImageView) findViewById(R.id.notice_avatar);
contentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
// messageView.setVisibility(View.VISIBLE);
}
private void updateUI() {
pushNoticeUpdateUI();
if (messageList != null && !messageList.isEmpty()) {
adapter = new MessageAdapter();
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == moreView) {
Intent intent = new Intent(MessageListActivity.this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
finish();
}
// else if (v == noticeView) {
// Intent intent = new Intent(this, NoticeListActivity.class);
// startActivity(intent);
// }
// else if (v == messageView) {
// doMessageAction();
// }
else if (v == bottomLayout) {
doFeedsAction();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_message_info:
updateUI();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
break;
case user_baseinfo_notfull:
showChoseMes(getString(R.string.exchange_complete_profile_tips), complete_info);
break;
case error:
onToast((String) msg.obj);
break;
case more:
adapter.notifyDataSetChanged();
loadMoreView.setVisibility(View.GONE);
break;
case refresh:
adapter.notifyDataSetChanged();
listView.onRefreshComplete();
break;
default:
break;
}
return false;
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_message_info:
initMessageInfo();
break;
default:
break;
}
}
private void initMessageInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_mymessage_sessionslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&count=" + 20);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
MessageInfo info = gson.fromJson(result, MessageInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
getPushNotice();
messageList = info.getMessage_sessions_list();
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance().getLogin_uid());
if (null!=pushInfo) {
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
}
handler.sendEmptyMessage(init_message_info);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getPushNotice() {
StringBuffer url = new StringBuffer(UrlConfig.push_notice);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
if (resultObj.getInt("authok") == 1) {
JSONObject pushObj = obj.getJSONObject("push_notice");
PushNoticeInfoTable table = new PushNoticeInfoTable();
PushNoticeInfo pushInfo = new PushNoticeInfo();
table.clearTable();
pushInfo.setMessage_avatar(pushObj.getString("message_avatar"));
pushInfo.setMessage_content(pushObj.getString("message_content"));
pushInfo.setNew_btfeed_count(pushObj.getInt("new_btfeed_count"));
pushInfo.setNew_exfeed_count(pushObj.getInt("new_exfeed_count"));
pushInfo.setNew_message_count(pushObj.getInt("new_message_count"));
pushInfo.setNew_notice_count(pushObj.getInt("new_notice_count"));
pushInfo.setNew_maybeknow_count(pushObj.getInt("new_maybeknow_count"));
table.savePushNoticeInfo(pushInfo, AppContext.getInstance().getLogin_uid());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void refresh() {
StringBuffer url = new StringBuffer(UrlConfig.get_mymessage_sessionslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&count=" + 20);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
MessageInfo info = gson.fromJson(result, MessageInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
messageList = info.getMessage_sessions_list();
handler.sendEmptyMessage(refresh);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void loadMoreMessageInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_mymessage_sessionslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&count=" + 20);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
MessageInfo info = gson.fromJson(result, MessageInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
List<MessageEntry> moreList = info.getMessage_sessions_list();
if (moreList != null) {
messageList.addAll(moreList);
}
handler.sendEmptyMessage(more);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class MessageAdapter extends BaseAdapter {
@Override
public int getCount() {
return messageList.size();
}
@Override
public Object getItem(int arg0) {
return messageList.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ViewHolder holder;
if (arg1 != null && arg1.getId() == R.id.message_list_item_layout) {
holder = (ViewHolder) arg1.getTag();
} else {
arg1 = LayoutInflater.from(getApplicationContext()).inflate(R.layout.message_list_item, null);
holder = new ViewHolder();
holder.avatarView = (RemoteImageView) arg1.findViewById(R.id.notice_item_avatar);
holder.nameView = (TextView) arg1.findViewById(R.id.notice_item_name);
holder.timeView = (TextView) arg1.findViewById(R.id.notice_item_time);
holder.contentView = (TextView) arg1.findViewById(R.id.notice_item_content);
arg1.setTag(holder);
}
final MessageEntry entry = messageList.get(arg0);
if (entry != null) {
holder.avatarView.setDefaultImage(R.drawable.avatar_default_big);
holder.avatarView.setImageUrl(entry.getAvatar(), arg0, listView);
holder.nameView.setText(entry.getNickname());
holder.timeView.setText(entry.getMessage_time());
if (entry.getIsnew() == 1) {
holder.timeView.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.star), null);
} else {
holder.timeView.setCompoundDrawables(null, null, null, null);
}
holder.contentView.setText(Html.fromHtml(entry.getIsnew() == 1 ? "<font color=red>"+TextUtil.htmlEncode(entry.getContent())+"</font>" : TextUtil.htmlEncode(entry.getContent())));
holder.avatarView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(MessageListActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", entry.getUid());
startActivity(spaceIntent);
}
});
}
return arg1;
}
}
public static class ViewHolder {
RemoteImageView avatarView;
TextView nameView;
TextView timeView;
TextView contentView;
}
private void initSateMenu() {
SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu);
menu.setVisibility(View.VISIBLE);
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: //扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(MessageListActivity.this, ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: //捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(MessageListActivity.this, ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: //交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(MessageListActivity.this, ChooseFriendActivity.class);
exchangeInfoIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: //交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(MessageListActivity.this, ChooseFriendActivity.class);
exchangeFileIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(MessageListActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
}
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount + getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount + getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(MessageListActivity.this, NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(MessageListActivity.this, MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
Intent intent = new Intent(MessageListActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(1);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
Intent intent = new Intent(MessageListActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(0);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(MessageListActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(MessageListActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
Intent intent = new Intent(MessageListActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
});
builder.create().show();
}
public void pushNoticeUpdateUI() {
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
contentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
userImageLoader.DisplayImage(message_avatar, avatarView, R.drawable.avatar_default_big);
} else {
bottomLayout.setVisibility(View.GONE);
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.GroupEntry;
import com.outsourcing.bottle.domain.GroupInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class ManagerGroupActivity extends BasicActivity implements
BasicUIEvent, OnClickListener, Callback, OnEditorActionListener {
private final int init_group_info = 1;
private final int init_group_info_success = 2;
private final int error = 3;
private final int set_group = 4;
private final int set_group_success = 5;
private Handler handler;
private List<GroupEntry> groupList;
private EditText[] editView = new EditText[8];
private ImageView[] confirmView = new ImageView[8];
private ImageView backView;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.manager_group);
handler = new Handler(this);
initWidget();
UICore.eventTask(this, this, init_group_info, "init_group_info", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
editView[0] = (EditText) findViewById(R.id.setting_group_edit1);
editView[1] = (EditText) findViewById(R.id.setting_group_edit2);
editView[2] = (EditText) findViewById(R.id.setting_group_edit3);
editView[3] = (EditText) findViewById(R.id.setting_group_edit4);
editView[4] = (EditText) findViewById(R.id.setting_group_edit5);
editView[5] = (EditText) findViewById(R.id.setting_group_edit6);
editView[6] = (EditText) findViewById(R.id.setting_group_edit7);
editView[7] = (EditText) findViewById(R.id.setting_group_edit8);
editView[0].setOnEditorActionListener(this);
editView[1].setOnEditorActionListener(this);
editView[2].setOnEditorActionListener(this);
editView[3].setOnEditorActionListener(this);
editView[4].setOnEditorActionListener(this);
editView[5].setOnEditorActionListener(this);
editView[6].setOnEditorActionListener(this);
editView[7].setOnEditorActionListener(this);
confirmView[0] = (ImageView) findViewById(R.id.setting_group_confirm1);
confirmView[1] = (ImageView) findViewById(R.id.setting_group_confirm2);
confirmView[2] = (ImageView) findViewById(R.id.setting_group_confirm3);
confirmView[3] = (ImageView) findViewById(R.id.setting_group_confirm4);
confirmView[4] = (ImageView) findViewById(R.id.setting_group_confirm5);
confirmView[5] = (ImageView) findViewById(R.id.setting_group_confirm6);
confirmView[6] = (ImageView) findViewById(R.id.setting_group_confirm7);
confirmView[7] = (ImageView) findViewById(R.id.setting_group_confirm8);
confirmView[0].setOnClickListener(this);
confirmView[1].setOnClickListener(this);
confirmView[2].setOnClickListener(this);
confirmView[3].setOnClickListener(this);
confirmView[4].setOnClickListener(this);
confirmView[5].setOnClickListener(this);
confirmView[6].setOnClickListener(this);
confirmView[7].setOnClickListener(this);
}
private void updateUI() {
try {
if (groupList != null && !groupList.isEmpty()) {
editView[0].setText(groupList.get(0).getGroup());
editView[1].setText(groupList.get(1).getGroup());
editView[2].setText(groupList.get(2).getGroup());
editView[3].setText(groupList.get(3).getGroup());
editView[4].setText(groupList.get(4).getGroup());
editView[5].setText(groupList.get(5).getGroup());
editView[6].setText(groupList.get(6).getGroup());
editView[7].setText(groupList.get(7).getGroup());
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_group_info_success:
updateUI();
break;
case error:
onToast((String) msg.obj);
break;
case set_group_success:
onToast((String) msg.obj);
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == confirmView[0]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(0).getGroupid());
params[1] = editView[0].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[1]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(1).getGroupid());
params[1] = editView[1].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[2]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(2).getGroupid());
params[1] = editView[2].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[3]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(3).getGroupid());
params[1] = editView[3].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[4]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(4).getGroupid());
params[1] = editView[4].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[5]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(5).getGroupid());
params[1] = editView[5].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[6]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(6).getGroupid());
params[1] = editView[6].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
} else if (v == confirmView[7]) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(7).getGroupid());
params[1] = editView[7].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_group_info:
initGroupInfo();
break;
case set_group:
String[] params = (String[]) obj;
setGroup(params[0], params[1]);
break;
default:
break;
}
}
private void initGroupInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_groups_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
GroupInfo info = gson.fromJson(result, GroupInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info
.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
groupList = info.getMygroups_list();
handler.sendEmptyMessage(init_group_info_success);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setGroup(String groupId, String groupName) {
String url = UrlConfig.set_groupname;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid",
String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("groupid", groupId);
paramsMap.put("groupname", groupName);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultobj = obj.getJSONObject("results");
if (resultobj.getInt("success") == 0) {
String errormsg = resultobj.getString("errmsg");
Message msg = Message.obtain(handler, error, errormsg);
handler.sendMessage(msg);
} else {
String successmsg = resultobj.getString("successmsg");
Message msg = Message.obtain(handler, set_group_success,
successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (v == editView[0]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(0).getGroupid());
params[1] = editView[0].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[1]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(1).getGroupid());
params[1] = editView[1].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[2]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(2).getGroupid());
params[1] = editView[2].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[3]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(3).getGroupid());
params[1] = editView[3].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[4]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(4).getGroupid());
params[1] = editView[4].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[5]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(5).getGroupid());
params[1] = editView[2].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[6]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(6).getGroupid());
params[1] = editView[6].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
} else if (v == editView[7]) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
String[] params = new String[2];
params[0] = String.valueOf(groupList.get(7).getGroupid());
params[1] = editView[7].getText().toString().trim();
UICore.eventTask(this, this, set_group, "set_group", params);
}
}
return false;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class ForgetPasswordActivity extends BasicActivity implements BasicUIEvent, OnClickListener {
private final int reset = 1;
private final int reset_success = 2;
private final int reset_error = 3;
private ImageView close;
private EditText emailView;
private Button resetView;
private String email;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.forget_password);
initWidget();
}
private void initWidget() {
close = (ImageView) findViewById(R.id.close);
close.setOnClickListener(this);
emailView = (EditText) findViewById(R.id.forget_password_email);
emailView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
checkReset();
}
return false;
}
});
resetView = (Button) findViewById(R.id.forget_password_reset);
resetView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == close) {
finish();
} else if (v == resetView) {
checkReset();
}
}
private void checkReset() {
email = emailView.getText().toString().trim();
if (email.equals("")) {
onToast(getString(R.string.login_txt_reset_error));
return;
} else if (!TextUtil.isValidEmail(email)) {
onToast(getString(R.string.login_txt_register_error_email));
return;
}
UICore.eventTask(this, this, reset, getString(R.string.init_data), null);
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case reset:
reset();
break;
default:
break;
}
}
private void reset() {
String url = UrlConfig.reset_password;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("email", email);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int sucess = resultObj.getInt("success");
if (sucess == 1) {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, reset_success, successmsg);
handler.sendMessage(msg);
} else {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, reset_error, errmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case reset_success:
onToast((String) msg.obj);
break;
case reset_error:
onToast((String) msg.obj);
break;
default:
break;
}
}
};
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.AlbumEntry;
import com.outsourcing.bottle.domain.AlbumListInfo;
import com.outsourcing.bottle.domain.FriendEntry;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.ElasticScrollView;
import com.outsourcing.bottle.widget.ElasticScrollView.OnRefreshListener;
import com.outsourcing.bottle.widget.ElasticScrollView.OnScrollChangeBottom;
/**
*
* @author 06peng
*
*/
public class AlbumsActivity extends BasicActivity implements OnClickListener, Callback {
private ImageView backView;
private ImageView addView;
private TextView titleView;
private ImageView avatarView;
private TextView nicknameView;
private ImageView sexView;
private TextView memoView;
private TextView doingView;
private TextView addressView;
private GridView gridView;
private ElasticScrollView elasticScrollView;
private View contentView;
private int ouid;
private int count = 10;
private final int init_album_info = 1;
private final int error = 2;
private final int delete_album = 3;
private final int user_baseinfo_notfull = 4;
private final int complete_info = 5;
private final int get_more_album = 6;
public static final int add_album_requestcode = 7;
public static final int update_album_requestcode = 8;
public static final int upload_photo_requestcode = 9;
private Handler handler;
private List<AlbumEntry> albumList;
private FriendEntry friendEntry;
private Bitmap bitmap;
private int selectedIndex;
private final int menu_uploadphoto = 15;
private final int menu_exprofile = 14;
private final int menu_exphoto = 13;
private final int menu_gainbt = 12;
private final int menu_sendbt = 11;
private int page = 1;
private ImageView homeView;
private AlbumAdapter adapter;
private LinearLayout bottomLayout;
private ImageView bottomAvatarView;
private TextView bottomContentView;
private TextView btnCount;
// private ImageView messageView;
private ImageLoader loader;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
private PushBroadcastReceiver receiver;
private PushNoticeInfo pushInfo;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.album_elastic_scrolll);
loader = new ImageLoader(this, AppContext.BottleTimelineIcon);
handler = new Handler(this);
ouid = getIntent().getIntExtra("ouid", 0);
initWidget();
initSateMenu();
UICore.eventTask(this, this, init_album_info, "init_album_info", null);
}
private void initWidget() {
homeView = (ImageView) findViewById(R.id.topbar_home);
homeView.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
addView = (ImageView) findViewById(R.id.topbar_menu);
addView.setOnClickListener(this);
addView.setImageResource(R.drawable.add_white);
titleView = (TextView) findViewById(R.id.topbar_title);
titleView.setVisibility(View.VISIBLE);
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
bottomAvatarView = (ImageView) findViewById(R.id.notice_avatar);
bottomContentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
elasticScrollView = (ElasticScrollView) findViewById(R.id.refresh_view);
elasticScrollView.setonRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
page = 1;
UICore.eventTask(AlbumsActivity.this, AlbumsActivity.this, init_album_info, null, null);
}
});
elasticScrollView.setonScrollChangeListener(new OnScrollChangeBottom() {
@Override
public void onScrollBottom() {
page++;
UICore.eventTask(AlbumsActivity.this, AlbumsActivity.this, get_more_album, null, null);
}
});
contentView = LayoutInflater.from(this).inflate(R.layout.user_albums, null);
elasticScrollView.addChild(contentView);
avatarView = (ImageView) contentView.findViewById(R.id.user_album_avatar);
nicknameView = (TextView) contentView.findViewById(R.id.user_album_nickname);
sexView = (ImageView) contentView.findViewById(R.id.user_album_sex);
memoView = (TextView) contentView.findViewById(R.id.user_album_memo);
doingView = (TextView) contentView.findViewById(R.id.user_album_doing);
addressView = (TextView) contentView.findViewById(R.id.user_album_address);
gridView = (GridView) contentView.findViewById(R.id.user_album_grid);
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
selectedIndex = arg2;
if (ouid == AppContext.getInstance().getLogin_uid()
&& albumList.get(selectedIndex).getAlbum_picnum() == 0) {
doChooseAction();
} else {
Intent intent = new Intent(AlbumsActivity.this, PhotosActivity.class);
intent.putExtra("ouid", ouid);
intent.putExtra("albumid", albumList.get(selectedIndex).getAlbum_id());
startActivity(intent);
}
}
});
}
private void updateUI() {
homeView.setVisibility(View.VISIBLE);
addView.setVisibility(View.VISIBLE);
findViewById(R.id.album_scrollview_layout).setVisibility(View.VISIBLE);
if (friendEntry != null) {
nicknameView.setText(friendEntry.getNickname());
if (friendEntry.getSex() == 1) {
sexView.setBackgroundResource(R.drawable.male);
} else if (friendEntry.getSex() == 2) {
sexView.setBackgroundResource(R.drawable.female);
}
if (TextUtil.notEmpty(friendEntry.getMemo())) {
memoView.setText("-" + friendEntry.getMemo());
memoView.setVisibility(View.VISIBLE);
} else {
memoView.setVisibility(View.GONE);
}
String html = "<font color=black>"+getString(R.string.user_info_doing)+"</font>";
doingView.setText(Html.fromHtml(html + friendEntry.getDoing()));
if (TextUtil.notEmpty(friendEntry.getCity() )&& TextUtil.notEmpty(friendEntry.getCountry())) {
addressView.setVisibility(View.VISIBLE);
if (AppContext.language == 1) {
addressView.setText(getString(R.string.user_from) + friendEntry.getCountry() + " " + friendEntry.getCity());
} else {
addressView.setText(getString(R.string.user_from) + friendEntry.getCity() + " " + friendEntry.getCountry());
}
} else {
addressView.setVisibility(View.GONE);
}
if (bitmap != null) {
avatarView.setImageBitmap(bitmap);
}
titleView.setText(friendEntry.getNickname() + getString(R.string.album_who));
}
if (ouid == AppContext.getInstance().getLogin_uid()) {
addView.setVisibility(View.VISIBLE);
} else {
addView.setVisibility(View.GONE);
}
if (albumList != null && !albumList.isEmpty()) {
adapter = new AlbumAdapter();
gridView.setAdapter(adapter);
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_album_info:
updateUI();
if (adapter != null && adapter.getCount() >= count) {
elasticScrollView.setMoreCount(true);
} else {
elasticScrollView.setMoreCount(false);
}
elasticScrollView.onRefreshComplete();
pushNoticeUpdateUI();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
break;
case error:
onToast((String) msg.obj);
break;
case delete_album:
onToast((String) msg.obj);
UICore.eventTask(this, this, init_album_info, "init_album_info", null);
break;
case user_baseinfo_notfull:
showChoseMes(getString(R.string.exchange_complete_profile_tips), complete_info);
break;
case get_more_album:
adapter.notifyDataSetChanged();
elasticScrollView.onScrollChangeComplete();
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == homeView) {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
}else if (v == addView) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.ADD_ALBUM);
intent.putExtras(extras);
startActivityForResult(intent, add_album_requestcode);
}
// else if (v == messageView) {
// doMessageAction();
// }
else if (v == bottomLayout) {
doFeedsAction();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_album_info:
initAlbums();
break;
case delete_album:
deleteAlbum();
break;
case get_more_album:
getMoreAlbums();
default:
break;
}
}
private void initAlbums() {
StringBuffer url = new StringBuffer(UrlConfig.get_albums_list);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
AlbumListInfo info = gson.fromJson(result, AlbumListInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance().getLogin_uid());
if (pushInfo != null) {
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
}
albumList = info.getAlbums_list();
friendEntry = info.getUser_info();
bitmap = HttpUtils.getBitmapFromUrl(AlbumsActivity.this, friendEntry.getAvatar());
handler.sendEmptyMessage(init_album_info);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getMoreAlbums() {
StringBuffer url = new StringBuffer(UrlConfig.get_albums_list);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&ouid=" + ouid);
url.append("&count=" + count);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
AlbumListInfo info = gson.fromJson(result, AlbumListInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
List<AlbumEntry> moreAlbumList = info.getAlbums_list();
if (moreAlbumList != null && !moreAlbumList.isEmpty()) {
albumList.addAll(moreAlbumList);
}
handler.sendEmptyMessage(get_more_album);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void deleteAlbum() {
String url = UrlConfig.delete_album;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("albumid", String.valueOf(albumList.get(selectedIndex).getAlbum_id()));
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, delete_album, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class AlbumAdapter extends BaseAdapter {
@Override
public int getCount() {
return albumList.size();
}
@Override
public Object getItem(int arg0) {
return albumList.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ViewHolder holder;
if (arg1 == null) {
arg1 = LayoutInflater.from(getApplicationContext()).inflate(R.layout.user_album_item, null);
holder = new ViewHolder();
holder.image = (ImageView) arg1.findViewById(R.id.album_image);
holder.title = (TextView) arg1.findViewById(R.id.album_title);
holder.count = (TextView) arg1.findViewById(R.id.album_count);
arg1.setTag(holder);
} else {
holder = (ViewHolder) arg1.getTag();
}
AlbumEntry entry = albumList.get(arg0);
if (entry != null) {
loader.DisplayImage(entry.getAlbum_cover(), holder.image, R.drawable.album_nophoto);
holder.title.setText(entry.getAlbum_title());
holder.count.setText(entry.getAlbum_picnum() + "");
}
return arg1;
}
}
public static class ViewHolder {
TextView title;
TextView count;
ImageView image;
}
private void doChooseAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String[] choices;
choices = new String[3];
choices[0] = getString(R.string.album_upload_photo);
choices[1] = getString(R.string.album_edit);
choices[2] = getString(R.string.album_delete);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
Intent intent = new Intent(AlbumsActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", albumList.get(selectedIndex).getAlbum_id());
extras.putString("upload_from", "album");
intent.putExtras(extras);
startActivityForResult(intent, upload_photo_requestcode);
break;
case 1:
Intent intent2 = new Intent(AlbumsActivity.this, ExpandEditActivity.class);
Bundle extras2 = new Bundle();
extras2.putString("from_type", AppContext.EDIT_ALBUM);
extras2.putInt("albumid", albumList.get(selectedIndex).getAlbum_id());
extras2.putString("albumname", albumList.get(selectedIndex).getAlbum_title());
extras2.putString("album_from", "album");
intent2.putExtras(extras2);
startActivityForResult(intent2, update_album_requestcode);
break;
case 2:
showChoseMes(getString(R.string.album_delete_confirm), delete_album);
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
SatelliteMenu menu;
private void initSateMenu() {
if (menu == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.menu_layout);
menu = new SatelliteMenu(this);
// menu.setExpandDuration(500);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
menu.setTotalSpacingDegree(90.0f);
menu.setCloseItemsOnClick(true);
layout.addView(menu);
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
}
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: //扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(AlbumsActivity.this, ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: //捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(AlbumsActivity.this, ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: //交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(AlbumsActivity.this, ChooseFriendActivity.class);
exchangeInfoIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: //交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(AlbumsActivity.this, ChooseFriendActivity.class);
exchangeFileIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(AlbumsActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
} else if (what == delete_album) {
UICore.eventTask(this, this, delete_album, "delete_album", null);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == add_album_requestcode) {
UICore.eventTask(this, this, init_album_info, "init_album_info", null);
} else if (requestCode == update_album_requestcode) {
UICore.eventTask(this, this, init_album_info, "init_album_info", null);
} else if (requestCode == upload_photo_requestcode) {
UICore.eventTask(this, this, init_album_info, "init_album_info", null);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount + getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount + getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(AlbumsActivity.this, NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(AlbumsActivity.this, MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
Intent intent = new Intent(AlbumsActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(1);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
Intent intent = new Intent(AlbumsActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(0);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(AlbumsActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(AlbumsActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
Intent intent = new Intent(AlbumsActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
});
builder.create().show();
}
public void pushNoticeUpdateUI() {
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
bottomContentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
loader.DisplayImage(message_avatar, bottomAvatarView, R.drawable.avatar_default_big);
} else {
bottomLayout.setVisibility(View.GONE);
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class LoginActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private final int login = 1;
private final int login_success = 2;
private final int login_error = 3;
private EditText accountView;
private EditText passwordView;
private Button loginView;
private ImageView close;
private ImageView forget;
private String username;
private String password;
private String deviceId;
private TelephonyManager tm;
private Handler handler;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.login);
initWidget();
tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
deviceId = tm.getDeviceId();
networkLocat();
}
private void initWidget() {
accountView = (EditText) findViewById(R.id.login_account);
passwordView = (EditText) findViewById(R.id.login_password);
passwordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
checkLogin();
}
return false;
}
});
close = (ImageView) findViewById(R.id.close);
close.setOnClickListener(this);
forget = (ImageView) findViewById(R.id.login_forget);
forget.setOnClickListener(this);
loginView = (Button) findViewById(R.id.login);
loginView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == forget) {
Intent intent = new Intent(this, ForgetPasswordActivity.class);
startActivity(intent);
} else if (v == close) {
finish();
} else if (v == loginView) {
checkLogin();
}
}
private void checkLogin() {
username = accountView.getText().toString().trim();
password = passwordView.getText().toString().trim();
if (username.equals("")) {
onToast(getString(R.string.login_txt_register_error_account));
return;
}
if (password.equals("")) {
onToast(getString(R.string.login_txt_reset_error));
return;
}
UICore.eventTask(this, this, login, getString(R.string.init_data), null);
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case login:
login();
break;
default:
break;
}
}
private void login() {
String url = UrlConfig.login;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("username", username);
paramsMap.put("password", password);
paramsMap.put("device_token", deviceId);
paramsMap.put("device_type", android.os.Build.MODEL);
paramsMap.put("device_provider", android.os.Build.PRODUCT);
paramsMap.put("device_version", android.os.Build.VERSION.RELEASE);
paramsMap.put("lat", String.valueOf(AppContext.getInstance().getLatitude()));
paramsMap.put("lng", String.valueOf(AppContext.getInstance().getLongitude()));
if (countryIso != null && countryIso.equalsIgnoreCase("cn")) {
paramsMap.put("location_mode", "1");
} else {
paramsMap.put("location_mode", "0");
}
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int login_uid = resultObj.getInt("login_uid");
if (login_uid != 0) {
String login_token = resultObj.getString("login_token");
AppContext.getInstance().setLogin_uid(login_uid);
AppContext.getInstance().setLogin_token(login_token);
SharedPreferences preferences = getSharedPreferences("Preferences_userinfo", Activity.MODE_APPEND);
Editor editor = preferences.edit();
editor.putInt("login_uid", login_uid);
editor.putString("login_token", login_token);
editor.commit();
handler.sendEmptyMessage(login_success);
} else {
String errmsg = resultObj.getString("errmsg");
Message message = Message.obtain(handler, login_error, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case login_success:
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(intent);
LoginActivity.this.finish();
break;
case login_error:
onToast((String) msg.obj);
break;
default:
break;
}
return false;
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.Calendar;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.BasicInfoEntry;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.domain.UserBasicInfo;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SettingBasicActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private final int init_basic_info = 1;
private final int error = 2;
private final int result_code_residecity = 3;
private final int result_code_birthcity = 4;
private final int result_code_workcity = 5;
private final int set_basic_info = 6;
private final int result_code_career = 7;
private Handler handler;
private int mYear;
private int mMonth;
private int mDay;
private BasicInfoEntry entry;
private LoginUserInfoEntry userEntry;
private String[] status;
private String[] bloor = new String[] {"AB", "A", "B", "O"};
private HashMap<String, String> paramsMap;
private EditText nameView;
private RelativeLayout resideLayout;
private TextView resideView;
private RelativeLayout birthcityLayout;
private TextView birthcityView;
private RelativeLayout workcityLayout;
private TextView workcityView;
private RelativeLayout birthdayLayout;
private TextView birthdayView;
private RelativeLayout careerLayout;
private TextView careerView;
private RelativeLayout statusLayout;
private TextView statusView;
private RelativeLayout bloorLayout;
private TextView bloorView;
private ImageView backView;
private ImageView confirmView;
private TextView loginAccountView;
private TextView loginEmailView;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.setting_basic);
handler = new Handler(this);
initWidget();
Calendar time = Calendar.getInstance();
mYear = time.get(Calendar.YEAR);
mMonth = time.get(Calendar.MONTH);
mDay = time.get(Calendar.DAY_OF_MONTH);
status = new String[] { getString(R.string.setting_basic_status_single),
getString(R.string.setting_basic_status_nosingle) };
paramsMap = new HashMap<String, String>();
UICore.eventTask(this, this, init_basic_info, "init_basic_info", null);
}
private void initWidget() {
LoginUserInfoTable table = new LoginUserInfoTable();
userEntry = table.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 1) {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.GONE);
} else {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.VISIBLE);
((TextView)findViewById(R.id.tv_profile_tips)).setText(userEntry.getBasicinfo_tip());
}
RemoteImageView img_head = (RemoteImageView) findViewById(R.id.iv_author_photo);
String avatar = table.getLoginUserInfo(AppContext.getInstance().getLogin_uid()).getAvatar();
if (TextUtil.notEmpty(avatar)) {
img_head.setDefaultImage(R.drawable.avatar_default_small);
img_head.setImageUrl(avatar);
}
nameView = (EditText) findViewById(R.id.setting_basic_name);
nameView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
UICore.eventTask(SettingBasicActivity.this, SettingBasicActivity.this, set_basic_info, "set_basic_info", null);
}
return false;
}
});
resideLayout = (RelativeLayout) findViewById(R.id.setting_basic_reside_layout);
resideLayout.setOnClickListener(this);
resideView = (TextView) findViewById(R.id.setting_basic_reside_value);
birthcityLayout = (RelativeLayout) findViewById(R.id.setting_basic_birthcity_layout);
birthcityLayout.setOnClickListener(this);
birthcityView = (TextView) findViewById(R.id.setting_basic_birthcity_value);
workcityLayout = (RelativeLayout) findViewById(R.id.setting_basic_workcity_layout);
workcityLayout.setOnClickListener(this);
workcityView = (TextView) findViewById(R.id.setting_basic_workcity_value);
birthdayLayout = (RelativeLayout) findViewById(R.id.setting_basic_birthday_layout);
birthdayLayout.setOnClickListener(this);
birthdayView = (TextView) findViewById(R.id.setting_basic_birthday_value);
careerLayout = (RelativeLayout) findViewById(R.id.setting_basic_career_layout);
careerLayout.setOnClickListener(this);
careerView = (TextView) findViewById(R.id.setting_basic_career_value);
statusLayout = (RelativeLayout) findViewById(R.id.setting_basic_status_layout);
statusLayout.setOnClickListener(this);
statusView = (TextView) findViewById(R.id.setting_basic_status_value);
bloorLayout = (RelativeLayout) findViewById(R.id.setting_basic_bloor_layout);
bloorLayout.setOnClickListener(this);
bloorView = (TextView) findViewById(R.id.setting_basic_bloor_value);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
confirmView = (ImageView) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
loginAccountView = (TextView) findViewById(R.id.setting_basic_username_value);
loginEmailView = (TextView) findViewById(R.id.setting_basic_email_value);
}
private Dialog createTimePickerDialog(){
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
}
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear + 1;
mDay = dayOfMonth;
paramsMap.put("birthyear", String.valueOf(mYear));
paramsMap.put("birthmonth", String.valueOf(mMonth));
paramsMap.put("birthday", String.valueOf(mDay));
String date = mYear + "-" + (mMonth < 10 ? "0" : "") + mMonth + '-' + (mDay < 10 ? "0" : "") + mDay;
updateToDisplay(date);
}
};
//更新时间
private void updateToDisplay(String date) {
birthdayView.setText(date);
}
private void updateUI() {
findViewById(R.id.setting_basic_layout).setVisibility(View.VISIBLE);
LoginUserInfoTable table = new LoginUserInfoTable();
userEntry = table.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 1) {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.GONE);
} else {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.tv_profile_tips)).setText(userEntry.getBasicinfo_tip());
}
if (entry != null) {
if (TextUtil.notEmpty(entry.getNickname())) {
((RelativeLayout) findViewById(R.id.setting_basic_name_layout)).setVisibility(View.GONE);
} else {
((RelativeLayout) findViewById(R.id.setting_basic_name_layout)).setVisibility(View.VISIBLE);
}
if (AppContext.language == 1) {
resideView.setText(entry.getResidecountry()+" " + entry.getBirthprovince()+" " + entry.getResidecity());
birthcityView.setText(entry.getBirthcountry()+" " + entry.getBirthprovince()+" " + entry.getBirthcity());
workcityView.setText(entry.getWorkcountry()+" " + entry.getWorkprovince()+" " + entry.getWorkcity());
} else {
resideView.setText(entry.getResidecity()+" " + entry.getBirthprovince()+" " + entry.getResidecountry());
birthcityView.setText(entry.getBirthcity()+" " + entry.getBirthprovince()+" " + entry.getBirthcountry());
workcityView.setText(entry.getWorkcity()+" " + entry.getWorkprovince()+" " + entry.getWorkcountry());
}
careerView.setText(entry.getCareer_subclass());
if (entry.getMarry() == 1) {
statusView.setText(getString(R.string.setting_basic_status_single));
} else if (entry.getMarry() == 2) {
statusView.setText(getString(R.string.setting_basic_status_nosingle));
}
bloorView.setText(entry.getBlood());
birthdayView.setText(entry.getBirthyear() + "-"
+ (entry.getBirthmonth() < 10 ? "0" : "") + entry.getBirthmonth() + '-'
+ (entry.getBirthday() < 10 ? "0" : "") + entry.getBirthday());
loginAccountView.setText(entry.getLogin_user());
loginEmailView.setText(entry.getLogin_email());
}
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == confirmView) {
UICore.eventTask(this, this, set_basic_info, "set_basic_info", null);
} else if (v == birthdayLayout) {
createTimePickerDialog().show();
} else if (v == birthcityLayout) {
Intent intent = new Intent(this, SearchCityActivity.class);
intent.putExtra("resultCode", result_code_birthcity);
intent.putExtra("title", getString(R.string.setting_select_birthcity));
startActivityForResult(intent, result_code_birthcity);
} else if (v == resideLayout) {
Intent intent = new Intent(this, SearchCityActivity.class);
intent.putExtra("resultCode", result_code_residecity);
intent.putExtra("title", getString(R.string.setting_select_residecity));
startActivityForResult(intent, result_code_residecity);
} else if (v == workcityLayout) {
Intent intent = new Intent(this, SearchCityActivity.class);
intent.putExtra("resultCode", result_code_workcity);
intent.putExtra("title", getString(R.string.setting_select_workcity));
startActivityForResult(intent, result_code_workcity);
} else if (v == statusLayout) {
doStatusAction();
} else if (v == bloorLayout) {
doBloorAction();
} else if (v == careerLayout) {
Intent intent = new Intent(this, SelectCareerActivity.class);
intent.putExtra("resultCode", result_code_career);
startActivityForResult(intent, result_code_career);
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case error:
onToast((String) msg.obj);
break;
case init_basic_info:
updateUI();
break;
case set_basic_info:
UICore.eventTask(this, this, init_basic_info, "init_basic_info", null);
onToast((String) msg.obj);
break;
default:
break;
}
return false;
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_basic_info:
initBasicInfo();
break;
case set_basic_info:
setBasicInfo();
break;
default:
break;
}
}
private void initBasicInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_basic_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
UserBasicInfo info = gson.fromJson(result, UserBasicInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
entry = info.getBasic_info();
handler.sendEmptyMessage(init_basic_info);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setBasicInfo() {
String url = UrlConfig.set_basic_info;
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
if (TextUtil.notEmpty(entry.getNickname())) {
paramsMap.put("nickname", entry.getNickname());
} else {
paramsMap.put("nickname", nameView.getText().toString().trim());
}
if (!paramsMap.containsKey("residecountry")) {
paramsMap.put("residecountry", entry.getResidecountry());
}
if (!paramsMap.containsKey("birthcountry")) {
paramsMap.put("birthcountry", entry.getBirthcountry());
}
if (!paramsMap.containsKey("workcountry")) {
paramsMap.put("workcountry", entry.getWorkcountry());
}
if (!paramsMap.containsKey("resideprovince")) {
paramsMap.put("resideprovince", entry.getResideprovince());
}
if (!paramsMap.containsKey("birthprovince")) {
paramsMap.put("birthprovince", entry.getBirthprovince());
}
if (!paramsMap.containsKey("workprovince")) {
paramsMap.put("workprovince", entry.getWorkprovince());
}
if (!paramsMap.containsKey("residecity")) {
paramsMap.put("residecity", entry.getResidecity());
}
if (!paramsMap.containsKey("birthcity")) {
paramsMap.put("birthcity", entry.getBirthcity());
}
if (!paramsMap.containsKey("workcity")) {
paramsMap.put("workcity", entry.getWorkcity());
}
if (!paramsMap.containsKey("birthyear")) {
paramsMap.put("birthyear", String.valueOf(entry.getBirthyear()));
}
if (!paramsMap.containsKey("birthmonth")) {
paramsMap.put("birthmonth", String.valueOf(entry.getBirthmonth()));
}
if (!paramsMap.containsKey("birthday")) {
paramsMap.put("birthday", String.valueOf(entry.getBirthday()));
}
if (!paramsMap.containsKey("career_class")) {
paramsMap.put("career_class", entry.getCareer_class());
}
if (!paramsMap.containsKey("career_subclass")) {
paramsMap.put("career_subclass", entry.getCareer_subclass());
}
if (!paramsMap.containsKey("career_classid")) {
paramsMap.put("career_classid", String.valueOf(entry.getCareer_classid()));
}
if (!paramsMap.containsKey("career_subclassid")) {
paramsMap.put("career_subclassid", String.valueOf(entry.getCareer_subclassid()));
}
if (!paramsMap.containsKey("marry")) {
paramsMap.put("marry", String.valueOf(entry.getMarry()));
}
if (!paramsMap.containsKey("blood")) {
paramsMap.put("blood", entry.getBlood());
}
if (!paramsMap.containsKey("residecityid")) {
paramsMap.put("residecityid", String.valueOf(entry.getResidecityid()));
}
if (!paramsMap.containsKey("birthcityid")) {
paramsMap.put("birthcityid", String.valueOf(entry.getBirthcityid()));
}
if (!paramsMap.containsKey("workcityid")) {
paramsMap.put("workcityid", String.valueOf(entry.getWorkcityid()));
}
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
getLoginUserInfo();
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_basic_info, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
if (loginUserInfo.getResults().getAuthok() == 1) {
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data == null) {
return;
}
if (resultCode != result_code_career) {
String city = data.getStringExtra("city");
String province = data.getStringExtra("province");
String country = data.getStringExtra("country");
int cityid = data.getIntExtra("cityid", 0);
if (country != null) {
if (resultCode == result_code_residecity) {
paramsMap.put("residecountry", country);
} else if (resultCode == result_code_birthcity) {
paramsMap.put("birthcountry", country);
} else {
paramsMap.put("workcountry", country);
}
}
if (province != null) {
if (resultCode == result_code_residecity) {
paramsMap.put("resideprovince", province);
} else if (resultCode == result_code_birthcity) {
paramsMap.put("birthprovince", province);
} else {
paramsMap.put("workprovince", province);
}
}
if (city != null) {
if (resultCode == result_code_residecity) {
paramsMap.put("residecity", city);
paramsMap.put("residecityid", String.valueOf(cityid));
} else if (resultCode == result_code_birthcity) {
paramsMap.put("birthcity", city);
paramsMap.put("birthcityid", String.valueOf(cityid));
} else {
paramsMap.put("workcity", city);
paramsMap.put("workcityid", String.valueOf(cityid));
}
}
switch (resultCode) {
case result_code_residecity:
paramsMap.put("residecityid", String.valueOf(cityid));
if (AppContext.language == 1) {
resideView.setText(country + province + city);
} else {
resideView.setText(city + province + country);
}
break;
case result_code_birthcity:
paramsMap.put("birthcityid", String.valueOf(cityid));
if (AppContext.language == 1) {
birthcityView.setText(country + province + city);
} else {
birthcityView.setText(city + province + country);
}
break;
case result_code_workcity:
paramsMap.put("workcityid", String.valueOf(cityid));
if (AppContext.language == 1) {
workcityView.setText(country + province + city);
} else {
workcityView.setText(city + province + country);
}
break;
}
} else {
String career_class = data.getStringExtra("career_class");
String career_subclass = data.getStringExtra("career_subclass");
int career_classid = data.getIntExtra("career_classid", 0);
int career_subclassid = data.getIntExtra("career_subclassid", 0);
paramsMap.put("career_class", career_class);
paramsMap.put("career_subclass", career_subclass);
paramsMap.put("career_classid", String.valueOf(career_classid));
paramsMap.put("career_subclassid", String.valueOf(career_subclassid));
careerView.setText(career_subclass);
}
}
private void doStatusAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, status);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
paramsMap.put("marry", String.valueOf(which + 1));
statusView.setText(status[which]);
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
private void doBloorAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, bloor);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
paramsMap.put("blood", bloor[which]);
bloorView.setText(bloor[which]);
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.json.JSONObject;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.aviary.android.feather.library.media.ExifInterfaceWrapper;
import com.aviary.android.feather.library.moa.MoaHD;
import com.aviary.android.feather.library.moa.MoaHD.Error;
import com.aviary.android.feather.library.providers.FeatherContentProvider;
import com.aviary.android.feather.library.providers.FeatherContentProvider.ActionsDbColumns.Action;
import com.aviary.android.feather.library.utils.DecodeUtils;
import com.aviary.android.feather.library.utils.IOUtils;
import com.aviary.android.feather.library.utils.ImageLoader.ImageSizes;
import com.aviary.android.feather.library.utils.StringUtils;
import com.aviary.android.feather.library.utils.SystemUtils;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.BottleTypeTable;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.BottleFeedListEntry;
import com.outsourcing.bottle.domain.BottleFeedListInfo;
import com.outsourcing.bottle.domain.BottleFeedLocationEntry;
import com.outsourcing.bottle.domain.BottleFeedLocationInfo;
import com.outsourcing.bottle.domain.BottleInfo;
import com.outsourcing.bottle.domain.BottleInfoEntry;
import com.outsourcing.bottle.domain.BottleLikeEntry;
import com.outsourcing.bottle.domain.BottleLikeListInfo;
import com.outsourcing.bottle.domain.BottleTypeEntry;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
import com.outsourcing.bottle.widget.CustomGridView;
import com.outsourcing.bottle.widget.CustomPopupWindow;
import com.outsourcing.bottle.widget.ElasticScrollView;
import com.outsourcing.bottle.widget.TryRefreshableView;
@TargetApi(8)
public class BottleDetailActivity extends BasicActivity implements
BasicUIEvent, OnClickListener, Callback {
private static final String TAG = BottleDetailActivity.class.getSimpleName();
private static final int EXEU_GET_BOTTLE_INFO = 0;
private static final int EXEU_GET_BOTTLE_INFO_FAILED = 1;
private static final int EXEU_BOTTLE_FEEDLIST = 2;
private static final int EXEU_BOTTLE_LIKELIST = 3;
private static final int EXEU_GET_DATA_ERROR = 4;
private static final int EXEU_REFRESH_CONTENT = 5;
private static final int EXEU_BOTTLE_LOAD_MAP = 6;
private static final int EXEU_GET_LOCATION_LIST = 7;
private static final int EXEU_GET_BOTTLE_PRIV_OPERATION = 8;
private static final int EXEU_SEND_BOTTLE_PRIV_SUCCESS = 9;
private static final int EXEU_SEND_BOTTLE_PRIV_SUCCESS_NOT_ENABLE = 10;
private static final int EXEU_SEND_BOTTLE_PRIV_FAILED = 11;
private static final int EXEU_LIKE_OPERATION = 12;
private static final int EXEU_UNLIKE_OPERATION = 13;
private static final int EXEU_LIKE_OPERATION_FAILED = 14;
private static final int EXEU_REFRESH_BOTTLE_LIST = 15;
private static final int EXEU_GET_MORE_CONTENT = 16;
private static final int EXEU_GET_DATA_NOTHING = 17;
private final int throw_bottle_init_location = 18;
private static final int EXEU_DELETE_LOCATION = 19;
View mContentView = null;
ElasticScrollView elasticScrollView = null;
private RelativeLayout rl_bt_detail_content;
private LinearLayout ll_botle_scrfeed = null;
private ImageView iv_back;
private ImageView iv_menu;
private ImageView iv_avater;
private ImageView iv_bottle_type;
private TextView tv_nickname;
private TextView tv_tag;
private TextView tv_location;
private TextView tv_distance;
private TextView tv_copy;
private TextView tv_mood;
private Button bt_drawing;
private Button bt_allow_draw;
private Button bt_comment;
private Button bt_copy;
private Button bt_forward;
private LinearLayout rl_like;
private ImageView iv_like_icon;
private ImageView iv_map;
private ImageView iv_like;
private TextView tv_message;
private ImageView iv_photo;
// ListView listView;
private CustomGridView like_grid;
private LinearLayout mFeedCommentContent;
private RelativeLayout rl_button_like = null;
CustomPopupWindow mLikePopview;
private Handler handler = null;
private List<BottleLikeEntry> mLikeEntries = null;
private List<BottleFeedListEntry> mListEntries = null;
private List<BottleFeedLocationEntry> mLocationEntries = null;
private GridLikeAdapter gridAdapter = null;
private int btId;
private int btTypeId;
private BottleTypeEntry entry;
/**
* 1.LikeList 2.Location
*/
private int type;
private int page = 1;
private float bottle_lat, bottle_lon;
private Bitmap bitmap = null;
private BottleInfoEntry bottleInfoEntry = null;
private ImageLoader imageLoader = null;
private ImageLoader btConfigLoader;
private RelativeLayout rl_bottle_content_photo;
private LinearLayout ll_botle_op_location;
private LinearLayout ll_bottle_photo_locked;
private TextView like_num;
// private ImageView messageView;
private TryRefreshableView rv;
private LinearLayout ll_content;
private ScrollView sv;
private LinearLayout ll_bottle_location;
private String location = "";
private int likeType;
private final int menu_uploadphoto = 105;
private final int menu_exprofile = 104;
private final int menu_exphoto = 103;
private final int menu_gainbt = 102;
private final int menu_sendbt = 101;
private final int user_baseinfo_notfull = 100;
private LinearLayout bottomLayout;
private RemoteImageView avatarView;
private TextView contentView;
private TextView btnCount;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
private PushBroadcastReceiver receiver;
private PushNoticeInfo pushInfo;
String mOutputFilePath;
/** session id for the hi-res post processing */
private String mSessionId;
private static final int ACTION_REQUEST_FEATHER = 100;
private static final int EXEU_SET_BTPIC_PAINT_SUCCESS = 101;
private static final int EXEU_DELETE_LOCATION_SUCCESS = 102;
private static final int EXEU_DELETE_LOCATION_FAILED = 103;
private static final int EXEU_REFRESH_FEED_LIST = 104;
private static final int EXEU_REFRESH_LOCATION_LIST = 105;
private Uri fileUri;
int imageWidth, imageHeight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bottle_detail);
DisplayMetrics metrics = getResources().getDisplayMetrics();
imageWidth = (int) ( (float) metrics.widthPixels / 1.5 );
imageHeight = (int) ( (float) metrics.heightPixels / 1.5 );
btId = getIntent().getIntExtra("btid", 0);
type = getIntent().getIntExtra("type", 0);
handler = new Handler(this);
imageLoader = new ImageLoader(this, AppContext.BottleTimelineIcon);
btConfigLoader = new ImageLoader(this, AppContext.BOTTLE_CONFIG);
initLayout();
initLikePopup();
initSateMenu();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
UICore.eventTask(this, BottleDetailActivity.this, EXEU_GET_BOTTLE_INFO, "", null);
}
@Override
protected void onResume() {
super.onResume();
if (AppContext.getInstance().isBottleDetailActNeedRefresh()) {
AppContext.getInstance().setBottleDetailActNeedRefresh(false);
page = 1;
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_GET_BOTTLE_INFO, "", null);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case EXEU_BOTTLE_FEEDLIST:
// getBottleFeedList(btId, page);
break;
case EXEU_BOTTLE_LIKELIST:
getBottleLikesList(btId, page);
break;
case EXEU_GET_BOTTLE_INFO:
getBottleInfo(btId);
switch (type) {
case 1:
getBottleLikesList(btId, page);
getBottleFeedList(btId, page);
break;
case 2:
getFeedLocationList(page);
break;
default:
break;
}
break;
case EXEU_REFRESH_CONTENT:
getBottleInfo(btId);
switch (type) {
case 1:
getBottleLikesList(btId, page);
getBottleFeedList(btId, page);
break;
case 2:
getFeedLocationList(page);
break;
default:
break;
}
break;
case EXEU_BOTTLE_LOAD_MAP:
String language = AppContext.language == 1?"zh":"en";
String url_map = UrlConfig.map_static_url
+ "?center="
+ bottle_lat
+ ","
+ bottle_lon
+ "&zoom=15&language="+language+"&size="
+ CanvasWidth
+ "x"
+ (CanvasHeight > 790 ? 120 : (CanvasHeight / 5))
+ "&sensor=false&mobile=true&markers=color:red%7Clabel:C%7C"
+ bottle_lat + "," + bottle_lon;
ServiceUtils.dout(url_map);
bitmap = HttpUtils.getBitmapFromUrl(this, url_map);
if (null != bitmap) {
Message message = Message.obtain(handler);
message.what = EXEU_BOTTLE_LOAD_MAP;
handler.sendMessage(message);
}
break;
case EXEU_GET_BOTTLE_PRIV_OPERATION:
getSendSingleBtPriv(btTypeId, btId);
break;
case EXEU_LIKE_OPERATION:
likeOperation(btId, likeType);
break;
case EXEU_UNLIKE_OPERATION:
likeOperation(btId, likeType);
break;
case EXEU_REFRESH_BOTTLE_LIST:
refreshBottleLikesList(btId);
break;
case EXEU_SET_BTPIC_PAINT_SUCCESS:
int optype = (Integer)obj;
setBtpicPaint(btId, optype);
break;
case EXEU_GET_MORE_CONTENT:
getMoreBottleFeedList(btId, page);
break;
case throw_bottle_init_location:
Object idObj = obj;
networkLocat();
Message msg = Message.obtain(handler, throw_bottle_init_location, idObj);
handler.sendMessage(msg);
break;
case EXEU_DELETE_LOCATION:
BottleFeedListEntry message = (BottleFeedListEntry)obj;
deleteLocation(String.valueOf(message.getLocation_objtype()), String.valueOf(message.getLocation_objid()));
break;
case EXEU_REFRESH_FEED_LIST:
refreshBottleFeedList(btId, 1);
break;
case EXEU_REFRESH_LOCATION_LIST:
refreshBottleLocationList(btId,1);
break;
default:
break;
}
}
private void refreshBottleLocationList(int btId2, int i) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_feedslocation);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=10");
url.append("&page=" + page);
ServiceUtils.dout("refreshBottleLocationList url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("refreshBottleLocationList results:"
+ results.toString());
Gson gson = new Gson();
BottleFeedLocationInfo bottleFeedLocationInfo = gson.fromJson(
results, BottleFeedLocationInfo.class);
if (bottleFeedLocationInfo.getResults().getAuthok() == 1) {
mLocationEntries = bottleFeedLocationInfo
.getBtfeedslocation_list();
Message message = handler.obtainMessage(EXEU_REFRESH_LOCATION_LIST,
bottleInfoEntry);
handler.sendMessage(message);
} else {
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
}
private void refreshBottleFeedList(int btId2, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=14");
url.append("&page=" + page);
ServiceUtils.dout("refreshBottleFeedList url: " + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
ServiceUtils.dout("refreshBottleFeedList results:" + result.toString());
Gson gson = new Gson();
BottleFeedListInfo bottleFeedListInfo = gson.fromJson(result,
BottleFeedListInfo.class);
if (bottleFeedListInfo.getResults().getAuthok() == 1) {
mListEntries = bottleFeedListInfo.getBtfeeds_list();
if (null != mListEntries && mListEntries.size() > 0) {
Message message = Message.obtain(handler);
message.what = EXEU_REFRESH_FEED_LIST;
handler.sendMessage(message);
} else {
}
} else {
Message message = handler.obtainMessage(EXEU_GET_DATA_ERROR,
bottleFeedListInfo.getResults().getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
}
/** 获取扔瓶子的权限 */
public void getSendSingleBtPriv(int btTypeId, int btId) {
StringBuffer url = new StringBuffer(UrlConfig.get_sendsinglebt_priv);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&bttypeid=" + btTypeId);
ServiceUtils.dout("sendsingleBT private url:" + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("getsendsinglebt_priv result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int authok = resultObj.getInt("authok");
String errmsg = resultObj.getString("errmsg");
if (authok == 1) {
JSONObject privObj = obj.getJSONObject("sendsinglebt_priv");
int enable = privObj.getInt("enable");
String reason = privObj.getString("reason");
if (enable == 1) {
Bundle bundle = new Bundle();
bundle.putInt("type", btTypeId);
bundle.putInt("btid", btId);
bundle.putString("reason", reason);
Message message = handler
.obtainMessage(EXEU_SEND_BOTTLE_PRIV_SUCCESS);
message.setData(bundle);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_SEND_BOTTLE_PRIV_SUCCESS_NOT_ENABLE,
reason);
handler.sendMessage(message);
}
} else {
Message message = handler.obtainMessage(
EXEU_SEND_BOTTLE_PRIV_FAILED, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initLayout() {
iv_back = (ImageView) findViewById(R.id.topbar_back);
iv_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
iv_menu = (ImageView) findViewById(R.id.topbar_menu);
iv_menu.setVisibility(View.INVISIBLE);
if (type == 1) {
iv_menu.setImageResource(R.drawable.menu_location);
} else if (type == 2) {
iv_menu.setImageResource(R.drawable.menu_feed);
}
iv_menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (type == 1) {
Intent bottleDetailIntent = new Intent(
BottleDetailActivity.this,
BottleDetailActivity.class);
bottleDetailIntent.putExtra("btid", btId);
bottleDetailIntent.putExtra("type", 2);// 2,location
startActivity(bottleDetailIntent);
} else if (type == 2) {
Intent bottleDetailIntent = new Intent(
BottleDetailActivity.this,
BottleDetailActivity.class);
bottleDetailIntent.putExtra("btid", btId);
bottleDetailIntent.putExtra("type", 1);// 2,location
startActivity(bottleDetailIntent);
}
}
});
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
avatarView = (RemoteImageView) findViewById(R.id.notice_avatar);
contentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
mContentView = LayoutInflater.from(this).inflate(
R.layout.bottle_detail_content, null);
rl_bt_detail_content = (RelativeLayout) mContentView
.findViewById(R.id.rl_bt_detail_content);
rl_bt_detail_content.setVisibility(View.INVISIBLE);
iv_avater = (ImageView) mContentView.findViewById(R.id.iv_author_photo);
iv_bottle_type = (ImageView) mContentView
.findViewById(R.id.iv_bottle_type);
tv_nickname = (TextView) mContentView.findViewById(R.id.tv_nickname);
tv_tag = (TextView) mContentView.findViewById(R.id.tv_tag);
tv_copy = (TextView) mContentView.findViewById(R.id.tv_copy_info);
tv_message = (TextView) mContentView.findViewById(R.id.tv_doing);
tv_mood = (TextView) mContentView.findViewById(R.id.tv_mood);
ll_bottle_location = (LinearLayout) mContentView
.findViewById(R.id.ll_bottle_location);
tv_location = (TextView) mContentView.findViewById(R.id.tv_location);
tv_distance = (TextView) mContentView.findViewById(R.id.tv_distance);
ll_botle_op_location = (LinearLayout)mContentView.findViewById(R.id.ll_botle_op_location);
ll_botle_scrfeed = (LinearLayout)mContentView.findViewById(R.id.ll_botle_scrfeed);
rl_bottle_content_photo = (RelativeLayout) mContentView
.findViewById(R.id.rl_bottle_content_photo);
ll_bottle_photo_locked = (LinearLayout) mContentView
.findViewById(R.id.ll_bottle_photo_locked);
iv_photo = (ImageView) mContentView.findViewById(R.id.photo);
bt_drawing = (Button)mContentView.findViewById(R.id.bt_drawing);
bt_allow_draw = (Button)mContentView.findViewById(R.id.bt_allow_draw);
bt_comment = (Button) mContentView.findViewById(R.id.bt_bottle_comment);
bt_comment.setOnClickListener(this);
bt_copy = (Button) mContentView.findViewById(R.id.bt_bottle_copy);
bt_forward = (Button) mContentView.findViewById(R.id.bt_bottle_forward);
rl_like = (LinearLayout) mContentView
.findViewById(R.id.comment_button_like);
rl_button_like = (RelativeLayout) mContentView
.findViewById(R.id.rl_button_like);
iv_like_icon = (ImageView) mContentView
.findViewById(R.id.comment_button_like_icon);
like_num = (TextView) mContentView
.findViewById(R.id.comment_button_like_text);
iv_map = (ImageView) mContentView.findViewById(R.id.iv_map);
// iv_map.setOnClickListener(this);
switch (type) {
case 1:
rl_like.setVisibility(View.VISIBLE);
iv_map.setVisibility(View.GONE);
break;
case 2:
rl_like.setVisibility(View.GONE);
iv_map.setVisibility(View.VISIBLE);
break;
default:
break;
}
iv_like = (ImageView) mContentView
.findViewById(R.id.comment_button_like_icon);
iv_like.setBackgroundResource(R.drawable.like_red2);
// listView = (ListView) mContentView.findViewById(R.id.list_view);
like_grid = (CustomGridView) mContentView.findViewById(R.id.like_grid);
// elasticScrollView.addChild(mContentView);
like_grid.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
BottleLikeEntry btLike = (BottleLikeEntry) gridAdapter.getItem(position);
Intent spaceIntent = new Intent(BottleDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", btLike.getLike_uid());
startActivity(spaceIntent);
}
});
mFeedCommentContent = (LinearLayout) mContentView
.findViewById(R.id.ll_feed_comment_content);
sv = (ScrollView) findViewById(R.id.trymySv);
rv = (TryRefreshableView) findViewById(R.id.trymyRV);
rv.mfooterView = (View) findViewById(R.id.tryrefresh_footer);
rv.sv = sv;
ll_content = (LinearLayout) findViewById(R.id.ll_content);
// 隐藏mfooterView
rv.mfooterViewText = (TextView) findViewById(R.id.tryrefresh_footer_text);
rv.mfooterViewText.setVisibility(View.INVISIBLE);
// 监听是否加载刷新
rv.setRefreshListener(new TryRefreshableView.RefreshListener() {
@Override
public void onRefresh() {
if (rv.mRefreshState == 4) {
page = 1;
UICore.eventTask(BottleDetailActivity.this,
BottleDetailActivity.this, EXEU_REFRESH_CONTENT,
null, null);
} else if (rv.mfooterRefreshState == 4) {
rv.mfooterViewText.setVisibility(View.VISIBLE);
page++;
UICore.eventTask(BottleDetailActivity.this,
BottleDetailActivity.this, EXEU_GET_MORE_CONTENT,
null, null);
}
}
});
ll_content.addView(mContentView);
}
private void initLikePopup() {
LayoutInflater mLayoutInflater = LayoutInflater.from(this);
View mLikeView = mLayoutInflater.inflate(R.layout.pop_bottle_like_left,
null);
ImageView iv_unlike = (ImageView) mLikeView
.findViewById(R.id.iv_unlike);
ImageView iv_like = (ImageView) mLikeView.findViewById(R.id.iv_like);
iv_unlike.setOnClickListener(this);
iv_like.setOnClickListener(this);
mLikePopview = new CustomPopupWindow(mLikeView,
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mLikePopview.setBackgroundDrawable(getResources().getDrawable(
R.drawable.like_frame_left));
mLikePopview.setOutsideTouchable(true);
mLikePopview.update();
mLikePopview.setTouchable(true);
mLikePopview.setFocusable(true);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_unlike:// 不喜欢
mLikePopview.dismiss();
likeType = 2;
UICore.eventTask(this, this, EXEU_UNLIKE_OPERATION, "", null);
break;
case R.id.iv_like:// 喜欢
mLikePopview.dismiss();
likeType = 1;
UICore.eventTask(this, this, EXEU_LIKE_OPERATION, "", null);
break;
case R.id.topbar_back:
finish();
break;
case R.id.rl_button_like:
showInfoPopupWindow(v);
break;
case R.id.bt_bottle_comment:
Intent commentIntent = new Intent(this, ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type", AppContext.REPLY_BT);
commentBundle.putInt("bttype_id", btId);
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent, 0);
break;
case R.id.bt_bottle_copy:
Intent copyIntent = new Intent(this, ExpandEditActivity.class);
Bundle copyBundle = new Bundle();
copyBundle.putString("from_type", AppContext.COPYMANUAL_BT);
copyBundle.putInt("bttype_id", btId);
copyIntent.putExtras(copyBundle);
startActivityForResult(copyIntent, 0);
break;
case R.id.bt_bottle_forward:
final Context dialogContext = new ContextThemeWrapper(BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = BottleDetailActivity.this.getString(R.string.bottle_txt_forward_to_friend);
choices[1] = BottleDetailActivity.this.getString(R.string.bottle_txt_forward_to_platform);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent forwardIntent = new Intent(BottleDetailActivity.this, ChooseFriendActivity.class);
Bundle forwardBundle = new Bundle();
forwardBundle.putInt("choose_friend_type", AppContext.CHOOSE_FRIEND_FORWARD_BOTTLE_TYPE);
forwardBundle.putInt("bttype_id", btId);
forwardBundle.putString("return_type", BottleDetailActivity.class.getSimpleName());
forwardIntent.putExtras(forwardBundle);
startActivity(forwardIntent);
} else {
Intent forwardIntent = new Intent(BottleDetailActivity.this, ExpandEditActivity.class);
Bundle forwardBundle = new Bundle();
forwardBundle.putString("from_type", AppContext.TRANSMIT_BT);
forwardBundle.putInt("bttype_id", btId);
forwardIntent.putExtras(forwardBundle);
startActivityForResult(forwardIntent, 0);
}
}
});
builder.create().show();
break;
// case R.id.iv_map:
// Intent intent = new Intent(this,MapViewActivity.class);
// intent.putExtra("longitude", latidute);
// intent.putExtra("latidute", longitude);
// intent.putExtra("location", bottleInfoEntry.getBt_location());
// break;
// case R.id.notice_message_count:
// doMessageAction();
// break;
default:
break;
}
}
/**
* Once you've chosen an image you can start the feather activity
*
* @param uri
*/
private void startFeather( Uri uri ) {
Log.d( TAG, "uri: " + uri );
// first check the external storage availability
if ( !Utility.isExternalStorageAvilable() ) {
// showDialog( EXTERNAL_STORAGE_UNAVAILABLE );
return;
}
// create a temporary file where to store the resulting image
File file = Utility.getNextFileName();
if ( null != file ) {
mOutputFilePath = file.getAbsolutePath();
} else {
new AlertDialog.Builder( this ).setTitle( android.R.string.dialog_alert_title ).setMessage( "Failed to create a new File" )
.show();
return;
}
// Create the intent needed to start feather
Intent newIntent = new Intent( this, CropImage2Activity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_DRAW );
// set the source image uri
newIntent.setData( uri );
// pass the required api_key and secret ( see
// http://developers.aviary.com/ )
newIntent.putExtra( "API_KEY", Utility.API_KEY );
// pass the uri of the destination image file (optional)
// This will be the same uri you will receive in the onActivityResult
newIntent.putExtra( "output", Uri.parse( "file://" + mOutputFilePath ) );
// format of the destination image (optional)
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name() );
// output format quality (optional)
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
// If you want to disable the external effects
// newIntent.putExtra( Constants.EXTRA_EFFECTS_ENABLE_EXTERNAL_PACKS, false );
// If you want to disable the external effects
// newIntent.putExtra( Constants.EXTRA_STICKERS_ENABLE_EXTERNAL_PACKS, false );
// enable fast rendering preview
// newIntent.putExtra( Constants.EXTRA_EFFECTS_ENABLE_FAST_PREVIEW, true );
// you can force feather to display only a certain ( see FilterLoaderFactory#Filters )
// you can omit this if you just wanto to display the default tools
/*
* newIntent.putExtra( "tools-list", new String[] { FilterLoaderFactory.Filters.ENHANCE.name(),
* FilterLoaderFactory.Filters.EFFECTS.name(), FilterLoaderFactory.Filters.STICKERS.name(),
* FilterLoaderFactory.Filters.ADJUST.name(), FilterLoaderFactory.Filters.CROP.name(),
* FilterLoaderFactory.Filters.BRIGHTNESS.name(), FilterLoaderFactory.Filters.CONTRAST.name(),
* FilterLoaderFactory.Filters.SATURATION.name(), FilterLoaderFactory.Filters.SHARPNESS.name(),
* FilterLoaderFactory.Filters.DRAWING.name(), FilterLoaderFactory.Filters.TEXT.name(),
* FilterLoaderFactory.Filters.MEME.name(), FilterLoaderFactory.Filters.RED_EYE.name(),
* FilterLoaderFactory.Filters.WHITEN.name(), FilterLoaderFactory.Filters.BLEMISH.name(),
* FilterLoaderFactory.Filters.COLORTEMP.name(), } );
*/
// you want the result bitmap inline. (optional)
// newIntent.putExtra( Constants.EXTRA_RETURN_DATA, true );
// you want to hide the exit alert dialog shown when back is pressed
// without saving image first
// newIntent.putExtra( Constants.EXTRA_HIDE_EXIT_UNSAVE_CONFIRMATION, true );
// -- VIBRATION --
// Some aviary tools use the device vibration in order to give a better experience
// to the final user. But if you want to disable this feature, just pass
// any value with the key "tools-vibration-disabled" in the calling intent.
// This option has been added to version 2.1.5 of the Aviary SDK
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
// you can pass the maximum allowed image size, otherwise feather will determine
// the max size based on the device memory
// Here we're passing the current display size as max image size because after
// the execution of Aviary we're saving the HI-RES image so we don't need a big
// image for the preview
max_size = (int) ( (double) max_size / 0.8 );
Log.d( TAG, "max-image-size: " + max_size );
newIntent.putExtra( "max-image-size", max_size );
// Enable/disable the default borders for the effects
newIntent.putExtra( "effect-enable-borders", true );
// You need to generate a new session id key to pass to Aviary feather
// this is the key used to operate with the hi-res image ( and must be unique for every new instance of Feather )
// The session-id key must be 64 char length
mSessionId = StringUtils.getSha256( System.currentTimeMillis() + Utility.API_KEY );
Log.d( TAG, "session: " + mSessionId + ", size: " + mSessionId.length() );
newIntent.putExtra( "output-hires-session-id", mSessionId );
// ..and start feather
startActivityForResult( newIntent, ACTION_REQUEST_FEATHER );
}
private void showInfoPopupWindow(View achorView) {
if (mLikePopview.isShowing()) {
mLikePopview.dismiss();
} else {
// mLikePopview.showAtLocation(achorView, Gravity.RIGHT, 0, 0);
mLikePopview.showAsDropDown(achorView, 60, -60);
}
}
/**
* 喜欢瓶子的操作
*
* @param btId
* 瓶子ID
* @param likeType
* 喜欢or不喜欢 <---> 1 or 2
*/
private void likeOperation(int btId, int likeType) {
StringBuffer url = new StringBuffer(UrlConfig.likeop_bt);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&liketype=" + likeType);
ServiceUtils.dout("likeOperation url:" + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
ServiceUtils.dout("likeOperation result:" + results);
if (null != results) {
JSONObject obj = new JSONObject(results);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
Message message = null;
if (success == 1) {
switch (likeType) {
case 1:
message = handler.obtainMessage(EXEU_LIKE_OPERATION,
successmsg);
handler.sendMessage(message);
break;
case 2:
message = handler.obtainMessage(EXEU_UNLIKE_OPERATION,
successmsg);
handler.sendMessage(message);
break;
default:
break;
}
} else {
message = handler.obtainMessage(EXEU_LIKE_OPERATION_FAILED,
errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getBottleLikesList(int btId, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_likeslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=10");
url.append("&page=" + page);
ServiceUtils.dout("getBottleLikesList url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getBottleLikesList results:" + results);
Gson gson = new Gson();
BottleLikeListInfo btLikeInfo = gson.fromJson(results,
BottleLikeListInfo.class);
if (btLikeInfo.getResults().getAuthok() == 1) {
mLikeEntries = btLikeInfo.getBtlikes_list();
// if (null != mLikeEntries && mLikeEntries.size() > 0) {
// Message message = Message.obtain(handler);
// message.what = EXEU_BOTTLE_LIKELIST;
// handler.sendMessage(message);
// }
} else {
// Message message = handler.obtainMessage(EXEU_GET_DATA_ERROR,
// btLikeInfo.getResults().getErrmsg());
// handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
// Message message = Message.obtain(handler);
// message.what = EXEU_GET_BOTTLE_INFO_FAILED;
// handler.sendMessage(message);
}
}
private void refreshBottleLikesList(int btId) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_likeslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=14");
url.append("&page=1");
ServiceUtils.dout("refreshBottleLikesList url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("refreshBottleLikesList results:" + results);
Gson gson = new Gson();
BottleLikeListInfo btLikeInfo = gson.fromJson(results,
BottleLikeListInfo.class);
if (btLikeInfo.getResults().getAuthok() == 1) {
mLikeEntries = btLikeInfo.getBtlikes_list();
Message message = Message.obtain(handler);
message.what = EXEU_REFRESH_BOTTLE_LIST;
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(EXEU_GET_DATA_ERROR,
btLikeInfo.getResults().getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
// Message message = Message.obtain(handler);
// message.what = EXEU_GET_BOTTLE_INFO_FAILED;
// handler.sendMessage(message);
}
}
private void getBottleFeedList(int btId, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=14");
url.append("&page=" + page);
ServiceUtils.dout("getBottleFeedList url: " + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
ServiceUtils.dout("getBottleFeedList results:" + result.toString());
Gson gson = new Gson();
BottleFeedListInfo bottleFeedListInfo = gson.fromJson(result,
BottleFeedListInfo.class);
if (bottleFeedListInfo.getResults().getAuthok() == 1) {
mListEntries = bottleFeedListInfo.getBtfeeds_list();
if (null != mListEntries && mListEntries.size() > 0) {
Message message = Message.obtain(handler);
message.what = EXEU_BOTTLE_FEEDLIST;
handler.sendMessage(message);
} else {
}
} else {
Message message = handler.obtainMessage(EXEU_GET_DATA_ERROR,
bottleFeedListInfo.getResults().getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
}
private void getMoreBottleFeedList(int btId, int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=10");
url.append("&page=" + page);
ServiceUtils.dout("getMoreBottleFeedList url: " + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
ServiceUtils.dout("getMoreBottleFeedList results:"
+ result.toString());
Gson gson = new Gson();
BottleFeedListInfo bottleFeedListInfo = gson.fromJson(result,
BottleFeedListInfo.class);
if (bottleFeedListInfo.getResults().getAuthok() == 1) {
mListEntries = bottleFeedListInfo.getBtfeeds_list();
if (null != mListEntries && mListEntries.size() > 0) {
Message message = Message.obtain(handler);
message.what = EXEU_GET_MORE_CONTENT;
handler.sendMessage(message);
} else {
Message message = handler
.obtainMessage(EXEU_GET_DATA_NOTHING);
handler.sendMessage(message);
}
} else {
Message message = handler.obtainMessage(EXEU_GET_DATA_ERROR,
bottleFeedListInfo.getResults().getErrmsg());
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
}
private void getFeedLocationList(int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_bt_feedslocation);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
url.append("&count=10");
url.append("&page=" + page);
ServiceUtils.dout("getFeedLocationList url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getFeedLocationList results:"
+ results.toString());
Gson gson = new Gson();
BottleFeedLocationInfo bottleFeedLocationInfo = gson.fromJson(
results, BottleFeedLocationInfo.class);
if (bottleFeedLocationInfo.getResults().getAuthok() == 1) {
mLocationEntries = bottleFeedLocationInfo
.getBtfeedslocation_list();
Message message = handler.obtainMessage(EXEU_GET_LOCATION_LIST,
bottleInfoEntry);
handler.sendMessage(message);
} else {
}
} catch (Exception e) {
e.printStackTrace();
Message message = Message.obtain(handler);
message.what = EXEU_GET_BOTTLE_INFO_FAILED;
handler.sendMessage(message);
}
}
private void getBottleInfo(int btId) {
StringBuffer url = new StringBuffer(UrlConfig.get_btinfo);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btId);
ServiceUtils.dout("getBottleInfo url: " + url.toString());
try {
String results = HttpUtils.doGet(url.toString());
if (results == null) {
return;
}
ServiceUtils.dout("getBottleInfo results:" + results.toString());
Gson gson = new Gson();
BottleInfo bottleInfo = gson.fromJson(results, BottleInfo.class);
if (bottleInfo.getResults().getAuthok() == 1) {
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance()
.getLogin_uid());
if (null != pushInfo) {
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
}
bottleInfoEntry = bottleInfo.getBtinfo();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setViewValue(final BottleInfoEntry bottleInfoEntry) {
rl_bt_detail_content.setVisibility(View.VISIBLE);
try {
Bitmap bitMap = HttpUtils.getBitmapFromUrl(this,
bottleInfoEntry.getBt_avatar());
Drawable drawable = new BitmapDrawable(bitMap);
iv_avater.setBackgroundDrawable(drawable);
iv_avater.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(BottleDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", bottleInfoEntry.getBt_uid());
startActivity(spaceIntent);
}
});
try {
BottleTypeTable btt = new BottleTypeTable();
entry = btt.getBottleType(bottleInfoEntry.getBttypeid());
btConfigLoader.DisplayImage(entry.getBttype_sjwicon(), iv_bottle_type, R.drawable.bottle_type_1);
} catch (Exception e) {
e.printStackTrace();
iv_bottle_type.setImageResource(R.drawable.bottle_type_1);
}
iv_bottle_type.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
btTypeId = bottleInfoEntry.getBttypeid();
UICore.eventTask(BottleDetailActivity.this,
BottleDetailActivity.this,
EXEU_GET_BOTTLE_PRIV_OPERATION, "", null);
}
});
String nickName = null;
if (bottleInfoEntry.getBt_uid() != AppContext.getInstance().getLogin_uid()) {
nickName = (!TextUtils.isEmpty(bottleInfoEntry.getBt_nickname())) ? ("<font color='#DA4A37'>"
+ bottleInfoEntry.getBt_nickname() + "</font>") : "";
} else {
nickName = (!TextUtils.isEmpty(bottleInfoEntry.getBt_nickname())) ? ("<font color='#3F99D8'>"
+ bottleInfoEntry.getBt_nickname() + "</font>") : "";
}
tv_nickname.setText(Html.fromHtml(nickName + bottleInfoEntry.getBt_feed()));
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_tag())) {
tv_tag.setVisibility(View.VISIBLE);
String locationTips = "<font color='#DA4A37'>"
+ TextUtil.R("bottle_txt_location_tips") + "</font>";
tv_tag.setText(Html.fromHtml(locationTips
+ bottleInfoEntry.getBt_tag()));
tv_tag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude",
bottleInfoEntry.getBt_lng());
intent.putExtra("latidute", bottleInfoEntry.getBt_lat());
intent.putExtra("location",
bottleInfoEntry.getBt_location());
startActivity(intent);
}
});
} else {
tv_tag.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_copy_info())) {
tv_copy.setVisibility(View.VISIBLE);
String commentTips = "<font color='#DA4A37'>"
+ TextUtil.R("bottle_txt_forward_tips") + "</font>";
tv_copy.setText(Html.fromHtml(commentTips
+ TextUtil.htmlEncode(bottleInfoEntry.getBt_copy_info())));
} else {
tv_copy.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_content())) {
tv_message.setVisibility(View.VISIBLE);
String messageTips = "<font color='#DA4A37'>"
+ TextUtil.R("bottle_txt_copy_tips") + "</font>";
tv_message
.setText(Html.fromHtml(messageTips
+ TextUtil.htmlEncode(bottleInfoEntry
.getBt_content())));
} else {
tv_message.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_doing())) {
tv_mood.setVisibility(View.VISIBLE);
String moodTips = "<font color='#DA4A37'>"
+ TextUtil.R("bottle_txt_mood_tips") + "</font>";
tv_mood.setText(Html.fromHtml(moodTips
+ TextUtil.htmlEncode(bottleInfoEntry.getBt_doing())));
} else {
tv_mood.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_location())) {
String time = (!TextUtils.isEmpty(bottleInfoEntry.getBt_time())) ? ( "#" + bottleInfoEntry.getBt_time()) : "";
ll_bottle_location.setVisibility(View.VISIBLE);
tv_location.setText(time + bottleInfoEntry.getBt_location());
// tv_location.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// Intent bottleDetailIntent = new Intent(
// BottleDetailActivity.this,
// BottleDetailActivity.class);
// bottleDetailIntent.putExtra("btid", btId);
// bottleDetailIntent.putExtra("type", 2);// 1,LikeList2,location
// startActivity(bottleDetailIntent);
// }
// });
tv_distance.setText(TextUtil.R("bottle_txt_comment_distance")+" "+bottleInfoEntry.getBt_opdistance());
} else {
ll_bottle_location.setVisibility(View.GONE);
}
/**************************瓶子传递动态***********************/
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_opfeed())) {
ll_botle_op_location.setVisibility(View.VISIBLE);
findViewById(R.id.line_feed).setVisibility(View.VISIBLE);
RemoteImageView mOpAvatar = (RemoteImageView) mContentView.findViewById(R.id.bt_opavatar);
try {
mOpAvatar.setDefaultImage(R.drawable.avatar_default_small);
mOpAvatar.setImageUrl(bottleInfoEntry.getBt_opavatar());
mOpAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(BottleDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", bottleInfoEntry.getBt_opuid());
startActivity(spaceIntent);
}
});
} catch (Exception e) {
e.printStackTrace();
mOpAvatar.setImageResource(R.drawable.avatar_default_small);
}
String onickName = (!TextUtils.isEmpty(bottleInfoEntry.getBt_opnickname())) ? ("<font color='#3F99D8'>"
+ bottleInfoEntry.getBt_opnickname() + "</font>")
: "";
String otime = (!TextUtils.isEmpty(bottleInfoEntry.getBt_optime())) ? ("#" + bottleInfoEntry.getBt_optime()) : "";
TextView mopfeedContent = (TextView)mContentView.findViewById(R.id.tv_feed_content);
mopfeedContent.setText(Html.fromHtml(onickName + TextUtil.htmlEncode(bottleInfoEntry.getBt_opfeed())));
TextView mOp_location = (TextView)mContentView.findViewById(R.id.tv_oplocation);
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_oplocation())) {
mOp_location.setVisibility(View.VISIBLE);
mOp_location.setText(otime + bottleInfoEntry.getBt_oplocation());
} else {
mOp_location.setVisibility(View.GONE);
}
} else {
ll_botle_op_location.setVisibility(View.GONE);
}
/**************************从哪个瓶子复制而来***********************/
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_srcfeed())) {
ll_botle_scrfeed.setVisibility(View.VISIBLE);
findViewById(R.id.line_feed).setVisibility(View.VISIBLE);
RemoteImageView bt_srcavatar = (RemoteImageView) mContentView.findViewById(R.id.bt_scravatar);
bt_srcavatar.setDefaultImage(R.drawable.avatar_default_small);
bt_srcavatar.setImageUrl(bottleInfoEntry.getBt_srcavatar());
String srcnickName = (!TextUtils.isEmpty(bottleInfoEntry.getBt_srcnickname())) ? ("<font color='#3F99D8'>"
+ bottleInfoEntry.getBt_srcnickname() + "</font>") : "";
TextView tv_srcfeed = (TextView)mContentView.findViewById(R.id.tv_srcfeed);
tv_srcfeed.setText(Html.fromHtml(srcnickName + bottleInfoEntry.getBt_srcfeed()));
String srctime = (!TextUtils.isEmpty(bottleInfoEntry.getBt_srctime())) ? ("#" + bottleInfoEntry.getBt_srctime()) : "";
TextView tv_srclocation = (TextView)mContentView.findViewById(R.id.tv_srclocation);
tv_srclocation.setText(srctime + bottleInfoEntry.getBt_srclocation());
ll_botle_scrfeed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showSrcFeedDialog(bottleInfoEntry);
}
});
} else {
ll_botle_scrfeed.setVisibility(View.GONE);
}
if (bottleInfoEntry.getBt_pic_locked() == 1) {
rl_bottle_content_photo.setVisibility(View.GONE);
ll_bottle_photo_locked.setVisibility(View.VISIBLE);
} else {
ll_bottle_photo_locked.setVisibility(View.GONE);
if (!TextUtils.isEmpty(bottleInfoEntry.getBt_smallpic())) {
rl_bottle_content_photo.setVisibility(View.VISIBLE);
findViewById(R.id.ll_layout_drawing).setVisibility(View.VISIBLE);
ServiceUtils.dout(TAG + " rl_bottle_content_photo:"+bottleInfoEntry.getBt_smallpic());
imageLoader.DisplayImage(bottleInfoEntry.getBt_smallpic(),
iv_photo, R.drawable.album_nophoto);
iv_photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(bottleInfoEntry.getBt_smallpic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(BottleDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", bottleInfoEntry.getBt_bigpic());
bigPicIntent.putExtra("thumbnail", tempBytes);
BottleDetailActivity.this.startActivity(bigPicIntent);
}
});
if (bottleInfoEntry.getBt_allow_tuya() == 1) {
findViewById(R.id.ll_layout_drawing).setVisibility(View.VISIBLE);
bt_drawing.setVisibility(View.VISIBLE);
bt_drawing.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = imageLoader.fileCache.getFile(bottleInfoEntry.getBt_smallpic());
byte[] tempBytes = null;
try {
tempBytes = ServiceUtils.readStream(new FileInputStream(file));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(BottleDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", bottleInfoEntry.getBt_bigpic());
bigPicIntent.putExtra("thumbnail", tempBytes);
bigPicIntent.putExtra("paintType", AppContext.PAINT_BT);
bigPicIntent.putExtra("return_type", BottleDetailActivity.class.getSimpleName());
bigPicIntent.putExtra("btid", btId);
bigPicIntent.putExtra("isToDraw", true);
startActivity(bigPicIntent);
}
});
}else {
bt_drawing.setVisibility(View.GONE);
}
if (bottleInfoEntry.getBt_enable_tuya()== 0) {
bt_allow_draw.setVisibility(View.GONE);
}else {
findViewById(R.id.ll_layout_drawing).setVisibility(View.VISIBLE);
bt_allow_draw.setVisibility(View.VISIBLE);
if (bottleInfoEntry.getBt_enable_tuya()== 1) {
bt_allow_draw.setText(TextUtil.R("bottle_txt_allow_draw"));
bt_allow_draw.setBackgroundResource(R.drawable.btn_red_try);
bt_allow_draw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UICore.eventTask(BottleDetailActivity.this, BottleDetailActivity.this, EXEU_SET_BTPIC_PAINT_SUCCESS, "", 1);
}
});
}else {
bt_allow_draw.setText(TextUtil.R("bottle_txt_not_allow_draw"));
bt_allow_draw.setBackgroundResource(R.drawable.btn_gray_try);
bt_allow_draw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UICore.eventTask(BottleDetailActivity.this, BottleDetailActivity.this, EXEU_SET_BTPIC_PAINT_SUCCESS, "", 0);
}
});
}
}
} else {
rl_bottle_content_photo.setVisibility(View.GONE);
findViewById(R.id.ll_layout_drawing).setVisibility(View.GONE);
}
}
if (type == 1) {
if (bottleInfoEntry.getBt_showaddress() == 0) {
iv_menu.setVisibility(View.INVISIBLE);
}else {
iv_menu.setVisibility(View.VISIBLE);
}
rl_like.setVisibility(View.VISIBLE);
iv_map.setVisibility(View.GONE);
switch (bottleInfoEntry.getBt_liked()) {
case 0:
iv_like_icon.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.like_gray2));
break;
case 1:
iv_like_icon.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.like_red2));
break;
case 2:
iv_like_icon.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.like_black2));
break;
default:
break;
}
if (bottleInfoEntry.getBt_like_enable() == 1) {
like_num.setTextColor(BottleDetailActivity.this.getResources().getColor(R.color.gray));
rl_button_like.setBackgroundDrawable(BottleDetailActivity.this.getResources().getDrawable(R.drawable.photo_pill));
rl_button_like.setOnClickListener(this);
} else {
like_num.setTextColor(BottleDetailActivity.this.getResources().getColor(R.color.white));
rl_button_like.setBackgroundDrawable(BottleDetailActivity.this.getResources().getDrawable(R.drawable.photo_pill_dark));
}
} else if (type == 2) {
iv_menu.setVisibility(View.VISIBLE);
rl_like.setVisibility(View.GONE);
iv_map.setVisibility(View.VISIBLE);
bottle_lat = bottleInfoEntry.getBt_lat();
bottle_lon = bottleInfoEntry.getBt_lng();
location = bottleInfoEntry.getBt_location();
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_BOTTLE_LOAD_MAP, null, null);
}
if (bottleInfoEntry.getBt_allow_spread() == 1) {
bt_forward.setVisibility(View.VISIBLE);
bt_forward.setOnClickListener(this);
} else {
bt_forward.setVisibility(View.GONE);
}
if (bottleInfoEntry.getBt_copy_enable() == 1) {
bt_copy.setVisibility(View.VISIBLE);
bt_copy.setOnClickListener(this);
} else {
bt_copy.setVisibility(View.GONE);
}
if (null != mLikeEntries && mLikeEntries.size() > 0) {
like_num.setText(mLikeEntries.size() + "");
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void showSrcFeedDialog(final BottleInfoEntry bottleInfoEntry) {
String[] choices = new String[]{TextUtil.R("bottle_txt_feed_single"),TextUtil.R("bottle_txt_feed_location")};
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(BottleDetailActivity.this, BottleSingleActivity.class);
intent.putExtra("btid", bottleInfoEntry.getBt_srcbtid());
startActivity(intent);
} else {
dialog.dismiss();
Intent intent = new Intent(BottleDetailActivity.this,MapViewActivity.class);
intent.putExtra("longitude",bottleInfoEntry.getBt_srclng());
intent.putExtra("latidute",bottleInfoEntry.getBt_srclat());
intent.putExtra("location",bottleInfoEntry.getBt_srclocation());
startActivity(intent);
}
}
});
builder.create().show();
}
/**
* 设置瓶子照片涂鸦权限接口
* @param btid 瓶子ID
* @param optype 设置是否允许涂鸦。选择项:不允许(0)、允许(1)
*/
public void setBtpicPaint(int btid,int optype) {
this.btId = btid;
StringBuffer url = new StringBuffer(UrlConfig.set_btpic_paint);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&btid=" + btid);
url.append("&optype=" + optype);
ServiceUtils.dout("setBtpicPaint url:" + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
ServiceUtils.dout("setBtpicPaint result:" + result);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int authok = resultObj.getInt("success");
if (authok == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, EXEU_GET_DATA_ERROR, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, EXEU_SET_BTPIC_PAINT_SUCCESS, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setFeedLikeLayout(List<BottleFeedListEntry> mListEntries) {
if (null != mFeedCommentContent) {
mFeedCommentContent.removeAllViews();
}
View convertView = null;
if (null != mListEntries && mListEntries.size() > 0) {
for (int i = 0; i < mListEntries.size(); i++) {
final BottleFeedListEntry message = mListEntries.get(i);
convertView = LayoutInflater.from(this).inflate(
R.layout.bottle_comment_list_detail_item, null);
RemoteImageView mAuthorView = (RemoteImageView) convertView
.findViewById(R.id.comment_profile_photo);
mAuthorView.setDefaultImage(R.drawable.avatar_default_small);
mAuthorView.setImageUrl(message.getFeed_avatar());
mAuthorView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(BottleDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", message.getFeed_uid());
startActivity(spaceIntent);
}
});
ImageView mLink = (ImageView) convertView
.findViewById(R.id.iv_feed_comment_white);
TextView mfeedContent = (TextView) convertView
.findViewById(R.id.tv_comment_feed_content);
TextView mfeedReplyComment = (TextView) convertView
.findViewById(R.id.tv_comment_feed_reply);
ImageView mfeedReplyPhoto = (ImageView) convertView
.findViewById(R.id.photo);
Button feed_reply_comment = (Button) convertView
.findViewById(R.id.feed_reply_comment);
TextView mfeedTime = (TextView) convertView
.findViewById(R.id.tv_comment_feed_time);
RelativeLayout comment_content_photo = (RelativeLayout) convertView
.findViewById(R.id.rl_bottle_content_photo);
ServiceUtils.dout(TAG + " message.getFeed_avatar():"
+ message.getFeed_avatar());
String nickName = null;
if (message.getFeed_uid() != AppContext.getInstance()
.getLogin_uid()) {
nickName = (!TextUtils.isEmpty(message.getFeed_nickname())) ? ("<font color='#DA4A37'>"
+ message.getFeed_nickname() + "</font>")
: "";
} else {
nickName = (!TextUtils.isEmpty(message.getFeed_nickname())) ? ("<font color='#3F99D8'>"
+ message.getFeed_nickname() + "</font>")
: "";
}
String time = (message.getFeed_time() != null && message
.getFeed_time().length() > 0) ? ("<font color='#666666'>"
+ " #" + message.getFeed_time() + "</font>")
: "";
final String location = (message.getFeed_location() != null && message
.getFeed_location().trim().length() > 0) ? ("<font color='#666666'>"
+ " @" + message.getFeed_location() + "</font>")
: "";
String feed_content = message.getFeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(message.getFeed_content()) + "</font>")
: TextUtil.htmlEncode(message.getFeed_content());
mfeedContent.setText(Html.fromHtml(nickName + " "
+ feed_content));
mfeedTime.setText(Html.fromHtml(time + location));
mfeedTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(location.length()>0){
if(message.getLocation_delete_enable() == 1){
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
} else {
UICore.eventTask(BottleDetailActivity.this, BottleDetailActivity.this, EXEU_DELETE_LOCATION, "", message);
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
}
}
});
builder.create().show();
}
}
}
});
if (message.getFeed_type() == 1) {
comment_content_photo.setVisibility(View.VISIBLE);
mfeedReplyComment.setVisibility(View.VISIBLE);
mfeedReplyPhoto.setVisibility(View.VISIBLE);
if (message.getFeed_uid() != AppContext.getInstance()
.getLogin_uid()) {
feed_reply_comment.setVisibility(View.VISIBLE);
}else {
feed_reply_comment.setVisibility(View.GONE);
}
mLink.setVisibility(View.GONE);
mfeedContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (message.getFeed_uid() != AppContext
.getInstance().getLogin_uid()) {
if ((!TextUtils.isEmpty(location))
&& (!TextUtils.isEmpty(message
.getFeed_content()))) {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_reply_comment);
choices[1] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent commentIntent = new Intent(
BottleDetailActivity.this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle
.putString(
"from_type",
AppContext.REPLY_COMMENT);
commentBundle
.putString(
"return_type",
"bottledetailactivity");
commentBundle
.putInt("commentid",
message.getCommentid());
commentIntent
.putExtras(commentBundle);
startActivityForResult(
commentIntent,
0);
} else {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
}
}
});
builder.create().show();
} else if (!TextUtils.isEmpty(location)) {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra("location",
message.getFeed_location());
startActivity(intent);
}
});
builder.create().show();
} else if (!TextUtils.isEmpty(message
.getFeed_content())) {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_reply_comment);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent commentIntent = new Intent(
BottleDetailActivity.this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle
.putString(
"from_type",
AppContext.REPLY_COMMENT);
commentBundle
.putInt("commentid",
message.getCommentid());
commentIntent
.putExtras(commentBundle);
startActivityForResult(
commentIntent, 0);
}
});
builder.create().show();
}
} else {
if (!TextUtils.isEmpty(location)) {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra("location",
message.getFeed_location());
startActivity(intent);
}
});
builder.create().show();
}
}
}
});
if (!TextUtils.isEmpty(message.getFeed_replycomment())) {
mfeedReplyComment.setVisibility(View.VISIBLE);
mfeedReplyComment.setText(message
.getFeed_replycomment());
} else {
mfeedReplyComment.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(message.getFeed_commentpic())) {
comment_content_photo.setVisibility(View.VISIBLE);
mfeedReplyPhoto.setVisibility(View.VISIBLE);
imageLoader.DisplayImage(message.getFeed_commentpic(),
mfeedReplyPhoto, R.drawable.album_nophoto);
mfeedReplyPhoto
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(message
.getFeed_commentpic_tuya())) {
showCommentPicFeedDialog(message);
} else {
byte[] tempBytes = null;
try {
String filename = ServiceUtils
.convertUrlToFileName(message
.getFeed_commentpic());
tempBytes = ServiceUtils
.readStream(new FileInputStream(
new File(
android.os.Environment
.getExternalStorageDirectory()
+ "/"
+ AppContext.BottleTimelineIcon
+ "/"
+ filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(
BottleDetailActivity.this,
PhotoDetailActivity.class);
bigPicIntent
.putExtra(
"pic_big",
message.getFeed_commentpic_big());
bigPicIntent.putExtra("thumbnail",
tempBytes);
BottleDetailActivity.this
.startActivity(bigPicIntent);
}
}
});
} else {
comment_content_photo.setVisibility(View.GONE);
mfeedReplyPhoto.setVisibility(View.GONE);
}
feed_reply_comment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent commentIntent = new Intent(BottleDetailActivity.this,ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",AppContext.REPLY_COMMENT);
commentBundle.putString("return_type","bottledetailactivity");
commentBundle.putInt("commentid",message.getCommentid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
}
});
} else {
comment_content_photo.setVisibility(View.GONE);
mfeedReplyComment.setVisibility(View.GONE);
mfeedReplyPhoto.setVisibility(View.GONE);
feed_reply_comment.setVisibility(View.GONE);
mLink.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(location)) {
mfeedContent
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent bottleDetailIntent = new Intent(
BottleDetailActivity.this,
BottleDetailActivity.class);
bottleDetailIntent.putExtra("btid",
btId);
bottleDetailIntent.putExtra("type", 2);// 1,LikeList2,location
startActivity(bottleDetailIntent);
}
});
}
}
mFeedCommentContent.addView(convertView);
mFeedCommentContent.invalidate();
}
}
}
private void showCommentPicFeedDialog(final BottleFeedListEntry message) {
String[] choices = new String[]{TextUtil.R("bottle_txt_feed_comment_pic"),TextUtil.R("bottle_txt_feed_comment_tuya")};
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(message.getFeed_commentpic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(BottleDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", message.getFeed_commentpic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
BottleDetailActivity.this.startActivity(bigPicIntent);
} else {
Intent bigPicIntent = new Intent(BottleDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", message.getFeed_commentpic_tuya());
BottleDetailActivity.this.startActivity(bigPicIntent);
}
}
});
builder.create().show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (null != intent) {
if (intent.getBooleanExtra("need_refresh", false)) {
page = 1;
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_GET_BOTTLE_INFO, "", null);
}
}
if ( resultCode == RESULT_OK ) {
switch ( requestCode ) {
case ACTION_REQUEST_FEATHER:
// send a notification to the media scanner
updateMedia( mOutputFilePath );
// update the preview with the result
loadAsync( intent.getData() );
// onSaveCompleted( mOutputFilePath );
/************正常保存*************/
if ( null != mSessionId ) {
deleteSession( mSessionId );
}
mSessionId = null;
/*************************/
mOutputFilePath = null;
break;
}
} else if ( resultCode == RESULT_CANCELED ) {
switch ( requestCode ) {
case ACTION_REQUEST_FEATHER:
// feather was cancelled without saving.
// we need to delete the entire session
if ( null != mSessionId ) deleteSession( mSessionId );
// delete the result file, if exists
if ( mOutputFilePath != null ) {
deleteFileNoThrow( mOutputFilePath );
mOutputFilePath = null;
}
break;
}
}
}
/**
* Load the incoming Image
*
* @param uri
*/
private void loadAsync( final Uri uri ) {
Log.i( TAG, "loadAsync: " + uri );
Drawable toRecycle = iv_photo.getDrawable();
if ( toRecycle != null && toRecycle instanceof BitmapDrawable ) {
if ( ( (BitmapDrawable) iv_photo.getDrawable() ).getBitmap() != null )
( (BitmapDrawable) iv_photo.getDrawable() ).getBitmap().recycle();
}
iv_photo.setImageDrawable( null );
fileUri = null;
DownloadAsync task = new DownloadAsync();
task.execute( uri );
}
class DownloadAsync extends AsyncTask<Uri, Void, Bitmap> implements OnCancelListener {
ProgressDialog mProgress;
private Uri mUri;
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgress = new ProgressDialog( BottleDetailActivity.this );
mProgress.setIndeterminate( true );
mProgress.setCancelable( true );
mProgress.setMessage( "Loading image..." );
mProgress.setOnCancelListener( this );
mProgress.show();
}
@Override
protected Bitmap doInBackground( Uri... params ) {
mUri = params[0];
Bitmap bitmap = null;
// while ( mImageContainer.getWidth() < 1 ) {
// try {
// Thread.sleep( 1 );
// } catch ( InterruptedException e ) {
// e.printStackTrace();
// }
// }
//
// final int w = mImageContainer.getWidth();
// Log.d( TAG, "width: " + w );
ImageSizes sizes = new ImageSizes();
bitmap = DecodeUtils.decode( BottleDetailActivity.this, mUri, imageWidth, imageHeight, sizes );
return bitmap;
}
@Override
protected void onPostExecute( Bitmap result ) {
super.onPostExecute( result );
if ( mProgress.getWindow() != null ) {
mProgress.dismiss();
}
if ( result != null ) {
setImageURI( mUri, result );
} else {
Toast.makeText( BottleDetailActivity.this, "Failed to load image " + mUri, Toast.LENGTH_SHORT ).show();
}
}
@Override
public void onCancel( DialogInterface dialog ) {
Log.i( TAG, "onProgressCancel" );
this.cancel( true );
}
@Override
protected void onCancelled() {
super.onCancelled();
Log.i( TAG, "onCancelled" );
}
}
/**
* lo-res process completed, ask the user if wants to process also the hi-res image
*
* @param filepath
* lo-res file name ( in case we want to delete it )
*/
private void onSaveCompleted( final String filepath ) {
if ( mSessionId != null ) {
DialogInterface.OnClickListener yesListener = new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dialog, int which ) {
if ( null != mSessionId ) {
processHD( mSessionId );
}
mSessionId = null;
}
};
DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dialog, int which ) {
if ( null != mSessionId ) {
deleteSession( mSessionId );
}
if ( !isFinishing() ) {
dialog.dismiss();
}
mSessionId = null;
}
};
Dialog dialog = new AlertDialog.Builder( this ).setTitle( "HiRes" )
.setMessage( "A low-resolution image was created. Do you want to save the hi-res image too?" )
.setPositiveButton( android.R.string.yes, yesListener ).setNegativeButton( android.R.string.no, noListener )
.setCancelable( false ).create();
dialog.show();
}
}
/**
* Start the hi-res image processing.
*
*/
private void processHD( final String session_name ) {
Log.i( TAG, "processHD: " + session_name );
// get a new file for the hi-res file
File destination = Utility.getNextFileName();
try {
if ( destination == null || !destination.createNewFile() ) {
Log.e( TAG, "Failed to create a new file" );
return;
}
} catch ( IOException e ) {
Log.e( TAG, e.getMessage() );
Toast.makeText( this, e.getLocalizedMessage(), Toast.LENGTH_SHORT ).show();
return;
}
String error = null;
// Now we need to fetch the session information from the content provider
FeatherContentProvider.SessionsDbColumns.Session session = null;
Uri sessionUri = FeatherContentProvider.SessionsDbColumns.getContentUri( session_name );
// this query will return a cursor with the informations about the given session
Cursor cursor = getContentResolver().query( sessionUri, null, null, null, null );
if ( null != cursor ) {
session = FeatherContentProvider.SessionsDbColumns.Session.Create( cursor );
cursor.close();
}
if ( null != session ) {
// Print out the session informations
Log.d( TAG, "session.id: " + session.id ); // session _id
Log.d(TAG, "session.name: " + session.session ); // session name
Log.d( TAG, "session.ctime: " + session.ctime ); // creation time
Log.d( TAG, "session.file_name: " + session.file_name ); // original file, it is the same you passed in the
// startActivityForResult Intent
// Now, based on the session information we need to retrieve
// the list of actions to apply to the hi-res image
Uri actionsUri = FeatherContentProvider.ActionsDbColumns.getContentUri( session.session );
// this query will return the list of actions performed on the original file, during the FeatherActivity session.
// Now you can apply each action to the hi-res image to replicate the same result on the bigger image
cursor = getContentResolver().query( actionsUri, null, null, null, null );
if ( null != cursor ) {
// If the cursor is valid we will start a new asynctask process to query the cursor
// and apply all the actions in a queue
HDAsyncTask task = new HDAsyncTask( Uri.parse( session.file_name ), destination.getAbsolutePath(), session_name );
task.execute( cursor );
} else {
error = "Failed to retrieve the list of actions!";
}
} else {
error = "Failed to retrieve the session informations";
}
if ( null != error ) {
Toast.makeText( this, error, Toast.LENGTH_LONG ).show();
}
}
/**
* AsyncTask for Hi-Res image processing
*
* @author alessandro
*
*/
private class HDAsyncTask extends AsyncTask<Cursor, Integer, MoaHD.Error> {
Uri uri_;
String dstPath_;
ProgressDialog progress_;
String session_;
ExifInterfaceWrapper exif_;
/**
* Initialize the HiRes async task
*
* @param source
* - source image file
* @param destination
* - destination image file
* @param session_id
* - the session id used to retrieve the list of actions
*/
public HDAsyncTask( Uri source, String destination, String session_id ) {
uri_ = source;
dstPath_ = destination;
session_ = session_id;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progress_ = new ProgressDialog( BottleDetailActivity.this );
progress_.setIndeterminate( true );
progress_.setTitle( "Processing Hi-res image" );
progress_.setMessage( "Loading image..." );
progress_.setProgressStyle( ProgressDialog.STYLE_SPINNER );
progress_.setCancelable( false );
progress_.show();
}
@Override
protected void onProgressUpdate( Integer... values ) {
super.onProgressUpdate( values );
final int index = values[0];
final int total = values[1];
String message = "";
if ( index == -1 )
message = "Saving image...";
else
message = "Applying action " + ( index + 1 ) + " of " + ( total );
progress_.setMessage( message );
Log.d( TAG, index + "/" + total + ", message: " + message );
}
@Override
protected Error doInBackground( Cursor... params ) {
Cursor cursor = params[0];
MoaHD.Error result = Error.UnknownError;
if ( null != cursor ) {
// Initialize the class to perform HD operations
MoaHD moa = new MoaHD();
// try to load the source image
result = loadImage( moa );
Log.d( TAG, "moa.load: " + result.name() );
// if image is loaded
if ( result == Error.NoError ) {
final int total_actions = cursor.getCount();
Log.d( TAG, "total actions: " + total_actions );
if ( cursor.moveToFirst() ) {
// get the total number of actions in the queue
// we're adding also the 'load' and the 'save' action to the total count
// now for each action in the given cursor, apply the action to
// the MoaHD instance
do {
// send a progress notification to the progressbar dialog
publishProgress( cursor.getPosition(), total_actions );
// load the action from the current cursor
Action action = Action.Create( cursor );
if ( null != action ) {
Log.d( TAG, "executing: " + action.id + "(" + action.session_id + " on " + action.ctime + ") = "
+ action.getActions() );
// apply a list of actions to the current image
moa.applyActions( action.getActions() );
} else {
Log.e( TAG, "Woa, something went wrong! Invalid action returned" );
}
// move the cursor to next position
} while ( cursor.moveToNext() );
}
// at the end of all the operations we need to save
// the modified image to a new file
publishProgress( -1, -1 );
result = moa.save( dstPath_ );
Log.d( TAG, "moa.save: " + result.name() );
if ( result != Error.NoError ) {
Log.e( TAG, "failed to save the image to " + dstPath_ );
}
// ok, now we can save the source image EXIF tags
// to the new image
if ( null != exif_ ) {
saveExif( exif_, dstPath_ );
}
} else {
Log.e( TAG, "Failed to load file" );
}
cursor.close();
// and unload the current bitmap. Note that you *MUST* call this method to free the memory allocated with the load
// method
result = moa.unload();
Log.d( TAG, "moa.unload: " + result.name() );
// finally dispose the moahd instance
moa.dispose();
}
return result;
}
/**
* Save the Exif tags to the new image
*
* @param originalExif
* @param filename
*/
private void saveExif( ExifInterfaceWrapper originalExif, String filename ) {
// ok, now we can save back the EXIF tags
// to the new file
ExifInterfaceWrapper newExif = null;
try {
newExif = new ExifInterfaceWrapper( dstPath_ );
} catch ( IOException e ) {
e.printStackTrace();
}
if ( null != newExif && null != originalExif ) {
originalExif.copyTo( newExif );
// this should be changed because the editor already rotate the image
newExif.setAttribute( ExifInterfaceWrapper.TAG_ORIENTATION, "0" );
// let's update the software tag too
newExif.setAttribute( ExifInterfaceWrapper.TAG_SOFTWARE, "Aviary " + FeatherActivity.SDK_VERSION );
// ...and the modification date
newExif.setAttribute( ExifInterfaceWrapper.TAG_DATETIME, ExifInterfaceWrapper.formatDate( new Date() ) );
try {
newExif.saveAttributes();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
@Override
protected void onPostExecute( MoaHD.Error result ) {
super.onPostExecute( result );
if ( progress_.getWindow() != null ) {
progress_.dismiss();
}
// in case we had an error...
if ( result != Error.NoError ) {
Toast.makeText( BottleDetailActivity.this, "There was an error: " + result.name(), Toast.LENGTH_SHORT ).show();
return;
}
// finally notify the MediaScanner of the new generated file
updateMedia( dstPath_ );
// now ask the user if he want to see the saved image
new AlertDialog.Builder( BottleDetailActivity.this ).setTitle( "File saved" )
.setMessage( "File saved in " + dstPath_ + ". Do you want to see the HD file?" )
.setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dialog, int which ) {
Intent intent = new Intent( Intent.ACTION_VIEW );
String filepath = dstPath_;
if ( !filepath.startsWith( "file:" ) ) {
filepath = "file://" + filepath;
}
intent.setDataAndType( Uri.parse( filepath ), "image/jpeg" );
startActivity( intent );
}
} ).setNegativeButton( android.R.string.no, null ).show();
// we don't need the session anymore, now we can delete it.
Log.d( TAG, "delete session: " + session_ );
deleteSession( session_ );
}
private Error loadImage( MoaHD moa ) {
MoaHD.Error result = Error.UnknownError;
final String srcPath = IOUtils.getRealFilePath( BottleDetailActivity.this, uri_ );
if ( srcPath != null ) {
// Let's try to load the EXIF tags from
// the source image
try {
exif_ = new ExifInterfaceWrapper( srcPath );
} catch ( IOException e ) {
e.printStackTrace();
}
result = moa.load( srcPath );
} else {
if ( SystemUtils.isHoneyComb() ) {
InputStream stream = null;
try {
stream = getContentResolver().openInputStream( uri_ );
} catch ( Exception e ) {
result = Error.FileNotFoundError;
e.printStackTrace();
}
if ( stream != null ) {
try {
result = moa.load( stream );
} catch ( Exception e ) {
result = Error.DecodeError;
}
} else {
Log.e( TAG, "stream is null!" );
}
} else {
ParcelFileDescriptor fd = null;
try {
fd = getContentResolver().openFileDescriptor( uri_, "r" );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
result = Error.FileNotFoundError;
}
if ( null != fd ) {
result = moa.load( fd.getFileDescriptor() );
}
}
}
return result;
}
}
/**
* Given an Uri load the bitmap into the current ImageView and resize it to fit the image container size
*
* @param uri
*/
private boolean setImageURI( final Uri uri, final Bitmap bitmap ) {
Log.d(TAG, "image size: " + bitmap.getWidth() + "x" + bitmap.getHeight() );
iv_photo.setImageBitmap( bitmap );
iv_photo.setBackgroundDrawable( null );
fileUri = uri;
return true;
}
/**
* We need to notify the MediaScanner when a new file is created. In this way all the gallery applications will be notified too.
*
* @param file
*/
private void updateMedia( String filepath ) {
Log.i(TAG, "updateMedia: " + filepath );
MediaScannerConnection.scanFile( getApplicationContext(), new String[] { filepath }, null, null );
}
/**
* Delete a file without throwing any exception
*
* @param path
* @return
*/
private boolean deleteFileNoThrow( String path ) {
File file;
try {
file = new File( path );
} catch ( NullPointerException e ) {
return false;
}
if ( file.exists() ) {
return file.delete();
}
return false;
}
/**
* Delete the session and all it's actions. We do not need it anymore.<br />
* Note that this is optional. All old sessions are automatically removed in Feather.
*
* @param session_id
*/
private void deleteSession( final String session_id ) {
Uri uri = FeatherContentProvider.SessionsDbColumns.getContentUri( session_id );
getContentResolver().delete( uri, null, null );
}
private void setFeedLocationLayout(
List<BottleFeedLocationEntry> mLocationEntries) {
if (null != mFeedCommentContent) {
mFeedCommentContent.removeAllViews();
}
View convertView = null;
if (null != mLocationEntries && mLocationEntries.size() > 0) {
for (int i = 0; i < mLocationEntries.size(); i++) {
final BottleFeedLocationEntry message = mLocationEntries.get(i);
convertView = LayoutInflater.from(this).inflate(
R.layout.bottle_comment_list_detail_item, null);
RelativeLayout feed_item_comment = (RelativeLayout) convertView
.findViewById(R.id.feed_item_comment);
RemoteImageView mAuthorView = (RemoteImageView) convertView
.findViewById(R.id.comment_profile_photo);
ImageView mLink = (ImageView) convertView
.findViewById(R.id.iv_feed_comment_white);
mLink.setImageResource(R.drawable.feed_gray);
mLink.setVisibility(View.VISIBLE);
TextView mfeedContent = (TextView) convertView
.findViewById(R.id.tv_comment_feed_content);
TextView mfeedReplyComment = (TextView) convertView
.findViewById(R.id.tv_comment_feed_reply);
TextView mfeedTime = (TextView) convertView
.findViewById(R.id.tv_comment_feed_time);
mfeedReplyComment.setVisibility(View.GONE);
Button feed_reply_comment = (Button) convertView
.findViewById(R.id.feed_reply_comment);
feed_reply_comment.setVisibility(View.GONE);
RelativeLayout comment_content_photo = (RelativeLayout) convertView
.findViewById(R.id.rl_bottle_content_photo);
comment_content_photo.setVisibility(View.GONE);
mAuthorView.setDefaultImage(R.drawable.avatar_default_small);
mAuthorView.setImageUrl(message.getFeed_avatar());
mAuthorView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(BottleDetailActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", message.getFeed_uid());
startActivity(spaceIntent);
}
});
String nickName = null;
if (message.getFeed_uid() != AppContext.getInstance()
.getLogin_uid()) {
nickName = (message.getFeed_nickname() != null && message
.getFeed_nickname().length() > 0) ? ("<font color='#DA4A37'>"
+ message.getFeed_nickname() + "</font>")
: "";
} else {
nickName = (message.getFeed_nickname() != null && message
.getFeed_nickname().length() > 0) ? ("<font color='#3F99D8'>"
+ message.getFeed_nickname() + "</font>")
: "";
}
String time = (message.getFeed_time() != null && message
.getFeed_time().length() > 0) ? ("<font color='#666666'>"
+ " #" + message.getFeed_time() + "</font>")
: "";
final String location = (message.getFeed_location() != null && message
.getFeed_location().trim().length() > 0) ? ("<font color='#666666'>"
+ " @" + message.getFeed_location() + "</font>")
: "";
String feed_content = message.getFeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(message.getFeed_content()) + "</font>")
: TextUtil.htmlEncode(message.getFeed_content());
mfeedContent.setText(Html.fromHtml(nickName + " "
+ feed_content));
mfeedTime.setText(Html.fromHtml(time + location));
if (!TextUtils.isEmpty(location)) {
mfeedTime.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(location.length()>0){
if(message.getLocation_delete_enable() == 1){
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
} else {
UICore.eventTask(BottleDetailActivity.this, BottleDetailActivity.this, EXEU_DELETE_LOCATION, "", message.getLocation_objid());
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
}
}
});
builder.create().show();
}
}
}
});
}
mFeedCommentContent.addView(convertView);
mFeedCommentContent.invalidate();
}
}
}
@Override
public boolean handleMessage(Message msg) {
try {
switch (msg.what) {
case EXEU_BOTTLE_FEEDLIST:
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
setViewValue(bottleInfoEntry);
if (mLikeEntries != null && mLikeEntries.size() > 0) {
gridAdapter = new GridLikeAdapter(this, mLikeEntries);
like_grid.setAdapter(gridAdapter);
}
setFeedLikeLayout(mListEntries);
rv.mfooterViewText.setVisibility(View.VISIBLE);
rv.finishRefresh();
break;
case EXEU_BOTTLE_LIKELIST:
gridAdapter = new GridLikeAdapter(this, mLikeEntries);
like_grid.setAdapter(gridAdapter);
break;
case EXEU_GET_BOTTLE_INFO:
setViewValue((BottleInfoEntry) msg.obj);
break;
case EXEU_GET_BOTTLE_INFO_FAILED:
this.onToast(TextUtil.R("error_data"));
break;
case EXEU_GET_DATA_ERROR:
this.onToast((String) msg.obj);
break;
case EXEU_SET_BTPIC_PAINT_SUCCESS:
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_REFRESH_BOTTLE_LIST, "", null);
break;
case EXEU_REFRESH_CONTENT:
ll_content.removeAllViews();
setViewValue(bottleInfoEntry);
gridAdapter = new GridLikeAdapter(this, mLikeEntries);
like_grid.setAdapter(gridAdapter);
setFeedLikeLayout(mListEntries);
// elasticScrollView.onRefreshComplete();
// elasticScrollView.invalidate();
ll_content.addView(mContentView);
rv.finishRefresh();
break;
case EXEU_BOTTLE_LOAD_MAP:
iv_map.setImageBitmap(bitmap);
iv_map.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra("longitude", bottle_lon);
intent.putExtra("latidute", bottle_lat);
intent.putExtra("location", location);
startActivity(intent);
}
});
break;
case EXEU_GET_LOCATION_LIST:
setViewValue((BottleInfoEntry) msg.obj);
setFeedLocationLayout(mLocationEntries);
rv.finishRefresh();
break;
case EXEU_SEND_BOTTLE_PRIV_SUCCESS:
final Bundle bundle = msg.getData();
try {
BottleTypeTable table = new BottleTypeTable();
BottleTypeEntry bottleEntry = table.getBottleType(bundle.getInt("type"));
int locationSelect = bottleEntry.getBttype_location_select();
String[] choices = new String[2];
if (locationSelect > 1) {
choices[0] = getString(R.string.choose_location_here_throw);
choices[1] = getString(R.string.choose_location_search_throw);
} else {
choices = new String[1];
choices[0] = getString(R.string.choose_location_here_throw);
}
chooseAction(choices, locationSelect , bundle.getInt("type"));
} catch (Exception e) {
e.printStackTrace();
}
break;
case EXEU_SEND_BOTTLE_PRIV_SUCCESS_NOT_ENABLE:
onToast((String) msg.obj);
break;
case EXEU_SEND_BOTTLE_PRIV_FAILED:
onToast((String) msg.obj);
break;
case EXEU_LIKE_OPERATION_FAILED:
onToast((String) msg.obj);
break;
case EXEU_LIKE_OPERATION:
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_REFRESH_BOTTLE_LIST, "", null);
break;
case EXEU_UNLIKE_OPERATION:
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_REFRESH_BOTTLE_LIST, "", null);
break;
case EXEU_REFRESH_BOTTLE_LIST:
ServiceUtils.dout(TAG + " EXEU_REFRESH_BOTTLE_LIST :"
+ mLikeEntries.size());
if (likeType == 1) {
iv_like_icon.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.like_red2));
} else if (likeType == 2) {
iv_like_icon.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.like_black2));
}
rl_button_like.setOnClickListener(null);
gridAdapter = new GridLikeAdapter(this, mLikeEntries);
like_grid.setAdapter(gridAdapter);
break;
case EXEU_GET_DATA_NOTHING:
rv.mfooterViewText.setVisibility(View.INVISIBLE);
onToast(TextUtil.R("no_more_data"));
rv.finishRefresh();
break;
case EXEU_GET_MORE_CONTENT:
setMoreFeeds(mListEntries);
rv.finishRefresh();
break;
case throw_bottle_init_location:
// try {
// int bottleid = Integer.parseInt(msg.obj.toString());
// Intent intent2 = new Intent(this, ThrowBottleSettingActivity.class);
// intent2.putExtra("bttype_id", bottleid);
// intent2.putExtra("bt_geo_lng", longitude);
// intent2.putExtra("bt_geo_lat", latitude);
// startActivity(intent2);
// } catch (Exception e) {
// e.printStackTrace();
// }
break;
case EXEU_DELETE_LOCATION_SUCCESS:
if (!TextUtils.isEmpty((String) msg.obj)) {
onToast((String) msg.obj);
}
switch (type) {
case 1:
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_REFRESH_FEED_LIST, "", null);
break;
case 2:
UICore.eventTask(this, BottleDetailActivity.this,
EXEU_REFRESH_LOCATION_LIST, "", null);
break;
default:
break;
}
break;
case EXEU_DELETE_LOCATION_FAILED:
onToast((String) msg.obj);
break;
case EXEU_REFRESH_FEED_LIST:
setFeedLikeLayout(mListEntries);
break;
case EXEU_REFRESH_LOCATION_LIST:
setFeedLocationLayout(mLocationEntries);
break;
default:
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
private void setMoreFeeds(List<BottleFeedListEntry> mListEntries2) {
for (int i = 0; i < mListEntries2.size(); i++) {
final BottleFeedListEntry message = mListEntries2.get(i);
View convertView = LayoutInflater.from(this).inflate(
R.layout.bottle_comment_list_detail_item, null);
RemoteImageView mAuthorView = (RemoteImageView) convertView
.findViewById(R.id.comment_profile_photo);
mAuthorView.setDefaultImage(R.drawable.avatar_default_small);
mAuthorView.setImageUrl(message.getFeed_avatar());
ImageView mLink = (ImageView) convertView
.findViewById(R.id.iv_feed_comment_white);
TextView mfeedContent = (TextView) convertView
.findViewById(R.id.tv_comment_feed_content);
TextView mfeedTime = (TextView) convertView
.findViewById(R.id.tv_comment_feed_time);
TextView mfeedReplyComment = (TextView) convertView
.findViewById(R.id.tv_comment_feed_reply);
ImageView mfeedReplyPhoto = (ImageView) convertView
.findViewById(R.id.photo);
Button feed_reply_comment = (Button) convertView
.findViewById(R.id.feed_reply_comment);
RelativeLayout comment_content_photo = (RelativeLayout) convertView
.findViewById(R.id.rl_bottle_content_photo);
ServiceUtils.dout(TAG + " message.getFeed_avatar():"
+ message.getFeed_avatar());
String nickName = null;
if (message.getFeed_uid() != AppContext.getInstance()
.getLogin_uid()) {
nickName = (message.getFeed_nickname() != null && message
.getFeed_nickname().length() > 0) ? ("<font color='#DA4A37'>"
+ message.getFeed_nickname() + "</font>")
: "";
} else {
nickName = (message.getFeed_nickname() != null && message
.getFeed_nickname().length() > 0) ? ("<font color='#3F99D8'>"
+ message.getFeed_nickname() + "</font>")
: "";
}
String time = (message.getFeed_time() != null && message
.getFeed_time().length() > 0) ? ("<font color='#666666'>"
+ " #" + message.getFeed_time() + "</font>") : "";
String location = (message.getFeed_location() != null && message
.getFeed_location().trim().length() > 0) ? ("<font color='#666666'>"
+ " @" + message.getFeed_location() + "</font>")
: "";
String feed_content = message.getFeed_isnew() == 1 ? ("<font color='#DA4A37'>"
+ TextUtil.htmlEncode(message.getFeed_content()) + "</font>")
: TextUtil.htmlEncode(message.getFeed_content());
mfeedContent.setText(Html.fromHtml(nickName + feed_content));
mfeedTime.setText(Html.fromHtml(time + location));
mfeedTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(message.getLocation_delete_enable() == 1){
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[2];
choices[0] = getString(R.string.bottle_txt_check_location);
choices[1] = getString(R.string.bottle_txt_clean_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
} else {
UICore.eventTask(BottleDetailActivity.this, BottleDetailActivity.this, EXEU_DELETE_LOCATION, "", message.getLocation_objid());
}
}
});
builder.create().show();
} else {
final Context dialogContext = new ContextThemeWrapper(
BottleDetailActivity.this,
android.R.style.Theme_Light);
String[] choices = new String[1];
choices[0] = getString(R.string.bottle_txt_check_location);
final ListAdapter adapter = new ArrayAdapter<String>(
dialogContext,
android.R.layout.simple_list_item_1,
choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(
adapter,
-1,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
MapViewActivity.class);
intent.putExtra(
"longitude",
message.getFeed_lng());
intent.putExtra(
"latidute",
message.getFeed_lat());
intent.putExtra(
"location",
message.getFeed_location());
startActivity(intent);
}
}
});
builder.create().show();
}
}
});
if (message.getFeed_type() == 1) {
comment_content_photo.setVisibility(View.VISIBLE);
mfeedReplyComment.setVisibility(View.VISIBLE);
mfeedReplyPhoto.setVisibility(View.VISIBLE);
feed_reply_comment.setVisibility(View.VISIBLE);
mLink.setVisibility(View.GONE);
if (null != message.getFeed_replycomment()
&& message.getFeed_replycomment().length() > 0) {
mfeedReplyComment.setVisibility(View.VISIBLE);
mfeedReplyComment.setText(message.getFeed_replycomment());
} else {
mfeedReplyComment.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(message.getFeed_commentpic())) {
comment_content_photo.setVisibility(View.VISIBLE);
mfeedReplyPhoto.setVisibility(View.VISIBLE);
imageLoader.DisplayImage(message.getFeed_commentpic(),
mfeedReplyPhoto, R.drawable.avatar_default_small);
mfeedReplyPhoto
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
byte[] tempBytes = null;
try {
String filename = ServiceUtils.convertUrlToFileName(message.getFeed_commentpic());
tempBytes = ServiceUtils.readStream(new FileInputStream(new File(
android.os.Environment.getExternalStorageDirectory() + "/" + AppContext.BottleTimelineIcon + "/" + filename)));
} catch (Exception e) {
e.printStackTrace();
}
Intent bigPicIntent = new Intent(BottleDetailActivity.this, PhotoDetailActivity.class);
bigPicIntent.putExtra("pic_big", message.getFeed_commentpic_big());
bigPicIntent.putExtra("thumbnail", tempBytes);
BottleDetailActivity.this.startActivity(bigPicIntent);
}
});
} else {
comment_content_photo.setVisibility(View.GONE);
mfeedReplyPhoto.setVisibility(View.GONE);
}
feed_reply_comment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent commentIntent = new Intent(BottleDetailActivity.this,ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",AppContext.REPLY_COMMENT);
commentBundle.putString("return_type","bottledetailactivity");
commentBundle.putInt("commentid",message.getCommentid());
commentIntent.putExtras(commentBundle);
startActivityForResult(commentIntent,0);
}
});
} else {
comment_content_photo.setVisibility(View.GONE);
mfeedReplyComment.setVisibility(View.GONE);
mfeedReplyPhoto.setVisibility(View.GONE);
feed_reply_comment.setVisibility(View.GONE);
mLink.setVisibility(View.VISIBLE);
}
mFeedCommentContent.addView(convertView);
mFeedCommentContent.invalidate();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (null != bitmap) {
bitmap.recycle();
bitmap = null;
}
try {
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class GridLikeAdapter extends BaseAdapter {
private Context context;
private List<BottleLikeEntry> arrayList;
public GridLikeAdapter(Context context, List<BottleLikeEntry> arrayList) {
this.context = context;
this.arrayList = arrayList;
}
@Override
public int getCount() {
return (null != arrayList && arrayList.size() > 0) ? arrayList.size() : 0;
}
@Override
public Object getItem(int position) {
return (null != arrayList && arrayList.size() > 0) ? arrayList.get(position) : null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.bottle_like_avatar_listitem, null);
holder.mheadView = (RemoteImageView) convertView.findViewById(R.id.head_photo);
holder.mLikeView = (ImageView) convertView.findViewById(R.id.like_photo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
BottleLikeEntry item = (BottleLikeEntry) getItem(position);
// holder.mheadView.setDefaultImage(R.drawable.avatar_default_small);
// holder.mheadView.setImageUrl(item.getLike_avatar(),
// AppContext.BottleTimelineIcon, position, like_grid);
holder.mheadView.setDefaultImage(R.drawable.avatar_default_small);
holder.mheadView.setImageUrl(item.getLike_avatar());
switch (item.getLike_type()) {
case 1:// 喜欢
holder.mLikeView.setImageResource(R.drawable.like_red2);
break;
case 2:// 不喜欢
holder.mLikeView.setImageResource(R.drawable.like_black2);
break;
default:
holder.mLikeView.setVisibility(View.GONE);
break;
}
return convertView;
}
class ViewHolder {
RemoteImageView mheadView;
ImageView mLikeView;
}
}
private void initSateMenu() {
SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu);
menu.setVisibility(View.VISIBLE);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: // 扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(
BottleDetailActivity.this,
ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: // 捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(
BottleDetailActivity.this,
ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: // 交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(
BottleDetailActivity.this,
ChooseFriendActivity.class);
exchangeInfoIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: // 交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable
.getLoginUserInfo(AppContext
.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(
BottleDetailActivity.this,
ChooseFriendActivity.class);
exchangeFileIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(BottleDetailActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount
+ getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount
+ getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(
BottleDetailActivity.this,
NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(
BottleDetailActivity.this,
MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
Intent intent = new Intent(BottleDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(1);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
Intent intent = new Intent(BottleDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(0);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(BottleDetailActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(BottleDetailActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
Intent intent = new Intent(BottleDetailActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
});
builder.create().show();
}
public void pushNoticeUpdateUI() {
// if (newMessageCount + newNoticeCount > 0) {
// messageView.setImageResource(R.drawable.bottom_menu_notice_red);
// } else {
// messageView.setImageResource(R.drawable.bottom_menu_notice_yellow);
// }
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
contentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
avatarView.setDefaultImage(R.drawable.avatar_default_big);
avatarView.setImageUrl(message_avatar);
} else {
bottomLayout.setVisibility(View.GONE);
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
private void chooseAction(String[] choices, final int locationSelected, final int bottleId) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent2 = new Intent(BottleDetailActivity.this, ThrowBottleSettingActivity.class);
intent2.putExtra("bttype_id", bottleId);
intent2.putExtra("bt_geo_lng", AppContext.getInstance().getLongitude());
intent2.putExtra("bt_geo_lat", AppContext.getInstance().getLatitude());
startActivity(intent2);
} else {
Intent intent = new Intent(BottleDetailActivity.this, ChooseLocationTabsActivity.class);
intent.putExtra("type", "throw");
intent.putExtra("bottleId", bottleId);
intent.putExtra("locationSelect", locationSelected);
startActivity(intent);
}
}
});
builder.create().show();
}
/**
*
* @param objtype 要清除的位置的类型:选择项:(1)瓶子动态的位置信息、(2)交换动态留言的位置信息、(3)照片评论的位置信息、(4)私信的位置信息、(5)照片的位置信息
* @param objid objid
*/
private void deleteLocation(String objtype,String objid) {
StringBuffer url = new StringBuffer(UrlConfig.delete_location);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&objtype=" + objtype);
url.append("&objid=" + objid);
ServiceUtils.dout("deleteLocation url:" + url.toString());
try {
String result = HttpUtils.doGet(url.toString());
ServiceUtils.dout("deleteLocation result:" + result);
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
String errmsg = resultObj.getString("errmsg");
String successmsg = resultObj.getString("successmsg");
if (success == 1) {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_SUCCESS, successmsg);
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(
EXEU_DELETE_LOCATION_FAILED, errmsg);
handler.sendMessage(message);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.SplashActivity;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.OtherConfigTable;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.OtherConfigEntry;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.ActivityManager;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.GetFileSize;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
/**
*
* @author 06peng
*
*/
public class SettingActivity extends BasicActivity implements BasicUIEvent, OnClickListener {
private final int logout = 1;
private final int logout_success = 2;
private final int logout_error = 3;
private final int activity_result_camara_with_data = 1006;
private final int activity_result_pick_with_data = 5;
private final int set_avatar = 6;
private final int set_avatar_success = 7;
private final int set_avatar_error = 8;
private final int init_login_userinfo = 9;
private final int activity_result_aviary = 10;
private ImageView backView;
private ImageView avatarView;
private Button logoutView;
private Bitmap bitMap;
private File picFile;
public final static int REQUEST_WIDTH = 600;
private RelativeLayout avatarLayout;
private RelativeLayout doingLayout;
private RelativeLayout passwordLayout;
private RelativeLayout basicLayout;
// private RelativeLayout contactLayout;
private RelativeLayout educationLayout;
private RelativeLayout workLayout;
private RelativeLayout groupLayout;
private RelativeLayout feedbackLayout;
// private RelativeLayout noticeLayout;
// private RelativeLayout notive_voiceLayout;
// private RelativeLayout vibrationLayout;
// private ImageView noticeView;
// private ImageView notive_voiceView;
// private ImageView vibrationView;
private LoginUserInfoEntry userEntry;
private OtherConfigEntry ocEntry;
static final int targetBytes = 65000;
static final int targetShortSide = 400;
static final int targetLongSide = 480;
private WeakReference<Bitmap> bitmapResult = null;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.setting);
initWidget();
UICore.eventTask(this, this, init_login_userinfo, "init_login_info", null);
}
private void initLoginUserInfo() {
LoginUserInfoTable userTable = new LoginUserInfoTable();
userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry != null) {
bitMap = HttpUtils.getBitmapFromUrl(this, userEntry.getAvatar());
} else {
getLoginUserInfo();
if (userEntry != null) {
bitMap = HttpUtils.getBitmapFromUrl(this, userEntry.getAvatar());
}
}
OtherConfigTable ot = new OtherConfigTable();
ocEntry = ot.getBottleOtherConfig();
handler.sendEmptyMessage(init_login_userinfo);
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
if (null != loginUserInfo && null != loginUserInfo.getResults() && loginUserInfo.getResults().getAuthok() == 1) {
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
userEntry = loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initWidget() {
LoginUserInfoTable userTable = new LoginUserInfoTable();
userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 1) {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.GONE);
} else {
((LinearLayout) findViewById(R.id.setting_basic_tips_layout)).setVisibility(View.VISIBLE);
((TextView)findViewById(R.id.tv_profile_tips)).setText(userEntry.getBasicinfo_tip());
}
RemoteImageView img_head = (RemoteImageView) findViewById(R.id.iv_author_photo);
String avatar = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid()).getAvatar();
if (TextUtil.notEmpty(avatar)) {
img_head.setDefaultImage(R.drawable.avatar_default_small);
img_head.setImageUrl(avatar);
}
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
logoutView = (Button) findViewById(R.id.logout);
logoutView.setOnClickListener(this);
avatarView = (ImageView) findViewById(R.id.setting_avatar_image);
avatarLayout = (RelativeLayout) findViewById(R.id.setting_avatar_layout);
avatarLayout.setOnClickListener(this);
doingLayout = (RelativeLayout) findViewById(R.id.setting_mood_layout);
doingLayout.setOnClickListener(this);
passwordLayout = (RelativeLayout) findViewById(R.id.setting_password_layout);
passwordLayout.setOnClickListener(this);
basicLayout = (RelativeLayout) findViewById(R.id.setting_basic_profile_layout);
basicLayout.setOnClickListener(this);
// contactLayout = (RelativeLayout) findViewById(R.id.setting_contact_layout);
// contactLayout.setOnClickListener(this);
educationLayout = (RelativeLayout) findViewById(R.id.setting_education_layout);
educationLayout.setOnClickListener(this);
workLayout = (RelativeLayout) findViewById(R.id.setting_work_layout);
workLayout.setOnClickListener(this);
groupLayout = (RelativeLayout) findViewById(R.id.setting_friend_group_layout);
groupLayout.setOnClickListener(this);
feedbackLayout = (RelativeLayout) findViewById(R.id.setting_feed_layout);
feedbackLayout.setOnClickListener(this);
// noticeLayout = (RelativeLayout) findViewById(R.id.setting_notification_layout);
// noticeLayout.setOnClickListener(this);
// notive_voiceLayout = (RelativeLayout) findViewById(R.id.setting_sound_layout);
// notive_voiceLayout.setOnClickListener(this);
// vibrationLayout = (RelativeLayout) findViewById(R.id.setting_vibration_layout);
// vibrationLayout.setOnClickListener(this);
// noticeView = (ImageView) findViewById(R.id.setting_notification_image);
// notive_voiceView = (ImageView) findViewById(R.id.setting_sound_image);
// vibrationView = (ImageView) findViewById(R.id.setting_vibration_image);
RelativeLayout about_us = (RelativeLayout)findViewById(R.id.setting_aboutus_layout);
about_us.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent= new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.mobibottle.com");
intent.setData(content_url);
startActivity(intent);
}
});
// SharedPreferences preferences = getSharedPreferences("Preferences_config", Activity.MODE_APPEND);
// int notice = preferences.getInt("notice", 1);
// int notice_voice = preferences.getInt("notice_voice", 1);
// int vibration = preferences.getInt("vibration", 1);
// if (notice == 1) {
// noticeView.setBackgroundResource(R.drawable.select_red);
// } else {
// noticeView.setBackgroundResource(R.drawable.select_gray);
// }
// if (notice_voice == 1) {
// notive_voiceView.setBackgroundResource(R.drawable.select_red);
// } else {
// notive_voiceView.setBackgroundResource(R.drawable.select_gray);
// }
// if (vibration == 1) {
// vibrationView.setBackgroundResource(R.drawable.select_red);
// } else {
// vibrationView.setBackgroundResource(R.drawable.select_gray);
// }
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case logout:
logout();
break;
case set_avatar:
setAvatar();
break;
case init_login_userinfo:
initLoginUserInfo();
break;
default:
break;
}
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == logoutView) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.setting_islogout));
builder.setPositiveButton(getString(R.string.confirm_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
UICore.eventTask(SettingActivity.this, SettingActivity.this, logout, "logout", null);
}
});
builder.setNegativeButton(getString(R.string.confirm_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
} else if (v == avatarLayout) {
doPickPhotoAction();
} else if (v == groupLayout) {
Intent intent = new Intent(this, ManagerGroupActivity.class);
startActivity(intent);
} else if (v == basicLayout) {
Intent intent = new Intent(this, SettingBasicActivity.class);
startActivity(intent);
} else if (v == passwordLayout) {
Intent intent = new Intent(this, SettingPasswordActivity.class);
startActivity(intent);
}
// else if (v == contactLayout) {
// Intent intent = new Intent(this, SettingContactActivity.class);
// startActivity(intent);
// }
else if (v == educationLayout) {
Intent intent = new Intent(this, SettingEducationActivity.class);
startActivity(intent);
} else if (v == workLayout) {
Intent intent = new Intent(this, SettingCompanyActivity.class);
startActivity(intent);
} else if (v == doingLayout) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.SET_DOING);
intent.putExtras(extras);
startActivity(intent);
} else if (v == feedbackLayout) {
Intent intent = new Intent(this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.SEND_MESSAGE);
extras.putInt("ouid", ocEntry.getFeedback_uid());
intent.putExtras(extras);
startActivity(intent);
}
// else if (v == noticeLayout) {
// SharedPreferences preferences = getSharedPreferences("Preferences_config", Activity.MODE_APPEND);
// int notice = preferences.getInt("notice", 1);
// if (notice == 1) {
// PushService.actionStop(getApplicationContext());
// saveConfig("notice", 0);
// noticeView.setBackgroundResource(R.drawable.select_gray);
// } else {
// PushService.actionStart(getApplicationContext());
// saveConfig("notice", 1);
// noticeView.setBackgroundResource(R.drawable.select_red);
// }
// } else if (v == notive_voiceLayout) {
// SharedPreferences preferences = getSharedPreferences("Preferences_config", Activity.MODE_APPEND);
// int notice_voice = preferences.getInt("notice_voice", 1);
// if (notice_voice == 1) {
// saveConfig("notice_voice", 0);
// notive_voiceView.setBackgroundResource(R.drawable.select_gray);
// } else {
// saveConfig("notice_voice", 1);
// notive_voiceView.setBackgroundResource(R.drawable.select_red);
// }
// } else if (v == vibrationLayout) {
// SharedPreferences preferences = getSharedPreferences("Preferences_config", Activity.MODE_APPEND);
// int vibration = preferences.getInt("vibration", 1);
// if (vibration == 1) {
// saveConfig("vibration", 0);
// vibrationView.setBackgroundResource(R.drawable.select_gray);
// } else {
// saveConfig("vibration", 1);
// vibrationView.setBackgroundResource(R.drawable.select_red);
// }
// }
}
// private void saveConfig(String type, int value) {
// SharedPreferences preferences = getSharedPreferences("Preferences_config", Activity.MODE_APPEND);
// Editor editor = preferences.edit();
// editor.putInt(type, value);
// editor.commit();
// }
private void logout() {
String url = UrlConfig.logout;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, logout_error, errmsg);
handler.sendMessage(msg);
} else {
AppContext.getInstance().setLogin_uid(0);
AppContext.getInstance().setLogin_token(null);
SharedPreferences preferences = getSharedPreferences("Preferences_userinfo", Activity.MODE_APPEND);
Editor editor = preferences.edit();
editor.putInt("login_uid", 0);
editor.putString("login_token", null);
editor.commit();
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, logout_success, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setAvatar() {
String url = UrlConfig.set_avatar;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
try {
HashMap<String, File> filesMap = new HashMap<String, File>();
if (picFile != null) {
filesMap.put("pic", picFile);
}
GetFileSize g = new GetFileSize();
System.out.println(">>>>>>>>avatar size:" + g.FormetFileSize(g.getFileSizes(picFile)));
String result = HttpUtils.post(url, paramsMap, filesMap);
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, set_avatar_error, errmsg);
handler.sendMessage(msg);
} else {
getLoginUserInfo();
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, set_avatar_success, successmsg);
handler.sendMessage(msg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void doPickPhotoAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String[] choices;
choices = new String[2];
choices[0] = getString(R.string.expand_edit_take_photo); // 拍照
choices[1] = getString(R.string.expand_edit_choose_photo); // 从相册中选择
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.expand_edit_photo_title);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_MOUNTED)) {// 判断是否有SD卡
doTakePhoto();// 用户点击了从照相机获取
}
break;
case 1:
doPickPhotoFromGallery();// 从相册中去获取
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
/**
* 拍照获取图片
*
*/
protected void doTakePhoto() {
try {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
Uri pictureUri = Uri.fromFile(picFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
startActivityForResult(cameraIntent, activity_result_camara_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
/**
* 从本地手机中选择图片
*/
// private void doSelectImageFromLoacal(){
// Intent localIntent = new Intent();
// localIntent.setType("image/*");
// localIntent.setAction("android.intent.action.GET_CONTENT");
// Intent localIntent2 = Intent.createChooser(localIntent, getString(R.string.expand_edit_choose_photo));
// startActivityForResult(localIntent2, activity_result_pick_with_data);
// }
// 封装请求Gallery的intent
public Intent getPhotoPickIntent() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
// 请求Gallery程序
protected void doPickPhotoFromGallery() {
try {
// Launch picker to choose photo for selected contact
final Intent intent = getPhotoPickIntent();
startActivityForResult(intent, activity_result_pick_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
protected void doCropPhoto(File f) {
try {
// 启动gallery去剪辑这个照片
final Intent intent = getCropImageIntent(Uri.fromFile(f));
startActivityForResult(intent, activity_result_pick_with_data);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Constructs an intent for image cropping. 调用图片剪辑程序
*/
public Intent getCropImageIntent(Uri photoUri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 320);
intent.putExtra("outputY", 320);
intent.putExtra("return-data", true);
return intent;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case activity_result_pick_with_data: //从本地选择图片
if (data == null) {
return;
}
bitMap = data.getParcelableExtra("data");
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileOutputStream ous = new FileOutputStream(picFile);
bitMap.compress(Bitmap.CompressFormat.JPEG, 100, ous);
if ( !Utility.isExternalStorageAvilable() ) {
return;
}
Uri fileUri = Uri.fromFile(picFile);
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_AVATAR );
newIntent.setData( fileUri );
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + picFile.getAbsolutePath() ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
startActivityForResult(newIntent, activity_result_aviary );
} catch (Exception e) {
e.printStackTrace();
}finally{
if (null != bitMap && !bitMap.isRecycled()) {
bitMap.recycle();
bitMap = null;
}
}
break;
case activity_result_aviary:
if (resultCode == RESULT_OK) {
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
FileInputStream in = new FileInputStream(picFile);
BitmapFactory.Options options1 = new BitmapFactory.Options();
options1.inPurgeable = true;
options1.inInputShareable = true;
options1.inSampleSize = 2;
try {
BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
} catch (Exception ex) {
ex.printStackTrace();
}
bitmapResult = new WeakReference<Bitmap>(BitmapFactory
.decodeStream(in, null, options1));
Bitmap bt = bitmapResult.get();
avatarView.setImageBitmap(bt);
UICore.eventTask(SettingActivity.this, SettingActivity.this, set_avatar, "set_avatar", null);
} catch (Exception e) {
e.printStackTrace();
} finally{
// if (null!= bitmapResult && null != bitmapResult.get() && !bitmapResult.get().isRecycled()) {
// bitmapResult.get().recycle();
// bitmapResult = null;
// }
}
}
break;
case activity_result_camara_with_data: //拍照
if (picFile == null) {
File pictureFile = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFile, "upload.jpeg");
}
doCropPhoto(picFile);
break;
}
}
protected void onDestroy() {
super.onDestroy();
try {
File uploadFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
if (bitmapResult.get() != null && !bitmapResult.get().isRecycled()) {
bitmapResult.get().recycle();
bitmapResult = null;
}
} catch (Exception e) {
e.printStackTrace();
}
};
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case logout_error:
onToast((String) msg.obj);
break;
case logout_success:
onToast((String) msg.obj);
ActivityManager.finishAll();
AppContext.getInstance().setCurrentItem(1); //
Intent intent = new Intent(SettingActivity.this, SplashActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("init", true);
startActivity(intent);
break;
case set_avatar_error:
onToast((String) msg.obj);
break;
case set_avatar_success:
onToast((String) msg.obj);
break;
case init_login_userinfo:
avatarView.setImageBitmap(bitMap);
if (userEntry != null) {
((TextView) findViewById(R.id.setting_doing_value)).setText(userEntry.getDoing());
}
break;
default:
break;
}
}
};
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.PlatformBindConfig;
import com.outsourcing.bottle.util.ServiceUtils;
/**
*
* @author 06peng
*
*/
@SuppressLint("SetJavaScriptEnabled")
public class WebViewActivity extends Activity {
private WebView webView;
private int index;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
index = 0;
getWindow().requestFeature(Window.FEATURE_PROGRESS); //设置Activity显示进度条
setContentView(R.layout.oauth_webview);
webView = (WebView)this.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
WebViewActivity.this.setProgress(newProgress * 100);
}
});
Bundle extras = getIntent().getExtras();
String url = "";
if (extras != null) {
if (extras.containsKey("url")) {
url = extras.getString("url");
if (ServiceUtils.isConnectInternet(this)) {
webView.loadUrl(url);
} else {
Toast.makeText(this, "网络连接失败", Toast.LENGTH_LONG).show();
return;
}
}
}
webView.addJavascriptInterface(new JavaScriptInterface(), "Methods");
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
System.out.println(">>>>>>>>>>>>>>>>>>url:" + url);
if (index <= 1) {
/**豆瓣*/
if (url.indexOf(PlatformBindConfig.Callback + "/?oauth_token=") != -1) {
index ++;
// String oauthToken = url.substring(url.indexOf("/?oauth_token=") + 14, url.length());
Intent intent = new Intent();
intent.setAction("oauth_verifier");
Bundle extras = new Bundle();
intent.putExtras(extras);
sendBroadcast(intent);
WebViewActivity.this.finish();
return;
}
/**腾讯*/
if (url.contains("code=") && url.contains("&openid=") && url.contains("&openkey=")) {
index ++;
String code = url.substring(url.indexOf("code=") + 5, url.indexOf("&openid="));
String openid = url.substring(url.indexOf("&openid=") + 8, url.indexOf("&openkey="));
String openkey = url.substring(url.indexOf("&openkey=") + 9, url.length());
if (!code.equals("")) {
Intent intent = new Intent();
intent.setAction("oauth_verifier");
Bundle extras = new Bundle();
extras.putString("code", code);
extras.putString("openid", openid);
extras.putString("openkey", openkey);
intent.putExtras(extras);
sendBroadcast(intent);
WebViewActivity.this.finish();
return;
}
}
/**人人或新浪*/
if (url.contains("code=")) {
index ++;
String code = url.substring(url.indexOf("code=") + 5, url.length());
if (!code.equals("")) {
Intent intent = new Intent();
intent.setAction("oauth_verifier");
Bundle extras = new Bundle();
extras.putString("code", code);
intent.putExtras(extras);
sendBroadcast(intent);
WebViewActivity.this.finish();
return;
}
}
/**QQ或Facebook*/
if (url.contains("#access_token=") || url.contains("&expires_in=")) {
index ++;
String accessToken = url.substring(url.indexOf("#access_token=") + 14, url.indexOf("&expires_in="));
String expires = url.substring(url.indexOf("&expires_in=") + 12, url.length());
System.out.println(accessToken);
System.out.println(expires);
if (!accessToken.equals("")) {
Intent intent = new Intent();
intent.setAction("oauth_verifier");
Bundle extras = new Bundle();
extras.putString("accessToken", accessToken);
extras.putString("expires", expires);
intent.putExtras(extras);
sendBroadcast(intent);
WebViewActivity.this.finish();
return;
}
}
}
}
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl("javascript:window.Methods.getHTML('<div>'+document.getElementById('oauth_pin').innerHTML+'</div>');");
super.onPageFinished(view, url);
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (webView.canGoBack()) {
webView.goBack();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
class JavaScriptInterface {
public void getHTML(String html) {
System.out.println(html);
String pin = getPin(html);
// 这里就获取到了我们想要的pin码
// 这个pin码就是oauth_verifier值,用来进一步获取Access Token和Access Secret用
System.out.println("pin:" + pin);
Intent intent = new Intent();
intent.setAction("oauth_verifier");
Bundle extras = new Bundle();
extras.putString("pin", pin);
intent.putExtras(extras);
sendBroadcast(intent);
WebViewActivity.this.finish();
}
}
public String getPin(String html) {
String ret = "";
String regEx = "[0-9]{7}";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(html);
boolean result = m.find();
if (result) {
ret = m.group(0);
}
return ret;
}
}
| Java |
package com.outsourcing.bottle.ui;
import org.json.JSONObject;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class MoreActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
private final int get_more_user_info = 1;
private RelativeLayout homeLayout;
private RelativeLayout friendFeedLayout;
private RelativeLayout inviteLayout;
// private RelativeLayout myspaceLayout;
private RelativeLayout myablumsLayout;
private RelativeLayout settingLayout;
private RelativeLayout notificationLayout;
private RelativeLayout messageLayout;
private RelativeLayout myfriendLayout;
private RelativeLayout maybekwonLayout;
private ImageView backView;
private ImageView homeView;
private Button notificationCount;
private Button messageCount;
private Button friendfeedsCount;
private Button maybekwonCount;
private int new_feedcount;
private int new_msgcount;
private int new_maybeknowcount;
private int new_noticecount;
private Handler handler;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
handler = new Handler(this);
setContentView(R.layout.more);
initWidget();
UICore.eventTask(this, this, get_more_user_info, "", null);
}
@Override
protected void onResume() {
super.onResume();
}
private void updateUI() {
if (new_msgcount > 0) {
messageCount.setVisibility(View.VISIBLE);
messageCount.setText(new_msgcount + "");
} else {
messageCount.setVisibility(View.GONE);
}
if (new_noticecount > 0) {
notificationCount.setVisibility(View.VISIBLE);
notificationCount.setText(new_noticecount + "");
} else {
notificationCount.setVisibility(View.GONE);
}
if (new_maybeknowcount > 0) {
maybekwonCount.setVisibility(View.VISIBLE);
maybekwonCount.setText(new_maybeknowcount + "");
} else {
maybekwonCount.setVisibility(View.GONE);
}
if (new_feedcount > 0) {
friendfeedsCount.setVisibility(View.VISIBLE);
friendfeedsCount.setText(new_feedcount + "");
} else {
friendfeedsCount.setVisibility(View.GONE);
}
}
private void initWidget() {
homeLayout = (RelativeLayout) findViewById(R.id.more_home_layout);
homeLayout.setOnClickListener(this);
friendFeedLayout = (RelativeLayout) findViewById(R.id.more_friends_feed_layout);
friendFeedLayout.setOnClickListener(this);
friendfeedsCount = (Button) findViewById(R.id.more_friendfeeds_count);
inviteLayout = (RelativeLayout) findViewById(R.id.more_bind_invite_layout);
inviteLayout.setOnClickListener(this);
// myspaceLayout = (RelativeLayout) findViewById(R.id.more_myspace_layout);
// myspaceLayout.setOnClickListener(this);
myablumsLayout = (RelativeLayout) findViewById(R.id.more_albums_layout);
myablumsLayout.setOnClickListener(this);
settingLayout = (RelativeLayout) findViewById(R.id.more_setting_layout);
settingLayout.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
homeView = (ImageView) findViewById(R.id.topbar_menu);
homeView.setOnClickListener(this);
notificationLayout = (RelativeLayout) findViewById(R.id.more_notification_layout);
notificationLayout.setOnClickListener(this);
notificationCount = (Button) findViewById(R.id.more_notification_count);
messageLayout = (RelativeLayout) findViewById(R.id.more_message_layout);
messageLayout.setOnClickListener(this);
messageCount = (Button) findViewById(R.id.more_message_count);
myfriendLayout = (RelativeLayout) findViewById(R.id.more_myfriend_layout);
myfriendLayout.setOnClickListener(this);
maybekwonLayout = (RelativeLayout) findViewById(R.id.more_maybekown_layout);
maybekwonLayout.setOnClickListener(this);
maybekwonCount = (Button) findViewById(R.id.more_maybekown_count);
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == settingLayout) {
Intent settingIntent = new Intent(this, SettingActivity.class);
startActivity(settingIntent);
} else if (v == inviteLayout) {
Intent intent = new Intent(this, BindInviteActivity.class);
startActivity(intent);
} else if (v == homeLayout) {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
}
// else if (v == myspaceLayout) {
// Intent intent = new Intent(this, UserSpaceActivity.class);
// intent.putExtra("ouid", AppContext.getInstance().getLogin_uid());
// startActivity(intent);
// }
else if (v == friendFeedLayout) {
Intent intent = new Intent(this, FriendFeedActivity.class);
startActivity(intent);
} else if (v == myablumsLayout) {
Intent intent = new Intent(this, AlbumsActivity.class);
intent.putExtra("ouid", AppContext.getInstance().getLogin_uid());
startActivity(intent);
} else if (v == homeView) {
Intent intent = new Intent(MoreActivity.this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
finish();
} else if (v == notificationLayout) {
Intent intent = new Intent(this, NoticeListActivity.class);
startActivity(intent);
} else if (v == messageLayout) {
Intent intent = new Intent(this, MessageListActivity.class);
startActivity(intent);
} else if (v == myfriendLayout) {
Intent intent = new Intent(this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGoToMyfriend(true);
startActivity(intent);
} else if (v == maybekwonLayout) {
Intent intent = new Intent(this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case get_more_user_info:
getMoreUserInfo();
handler.sendEmptyMessage(get_more_user_info);
break;
default:
break;
}
}
private void getMoreUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_more_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("more_info");
new_feedcount = resultObj.getInt("new_feedcount");
new_msgcount = resultObj.getInt("new_msgcount");
new_maybeknowcount = resultObj.getInt("new_maybeknowcount");
new_noticecount = resultObj.getInt("new_noticecount");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case get_more_user_info:
updateUI();
break;
default:
break;
}
return false;
}
}
| Java |
package com.outsourcing.bottle.ui;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.BottleTypeTable;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.domain.BottleTypeEntry;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class BottleTipsActivity extends BasicActivity implements BasicUIEvent {
private final int init_tips = 1;
private int bottleId;
private String gainbt_msg;
private Bitmap avatarBitmap;
private ImageView bottleIconView;
private ImageView userAvatarView;
private TextView tipsView;
private Button gotitView;
private ImageLoader btConfigLoader;
private BottleTypeEntry entry;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.bottle_tips);
bottleId = getIntent().getIntExtra("bottleId", 0);
gainbt_msg = getIntent().getStringExtra("gainbt_msg");
initWidget();
btConfigLoader = new ImageLoader(this, AppContext.BOTTLE_CONFIG);
UICore.eventTask(this, this, init_tips, "init_tips", null);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
} else if (keyCode == KeyEvent.KEYCODE_HOME) {
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_tips:
initTips();
handler.sendEmptyMessage(init_tips);
break;
default:
break;
}
}
private void initWidget() {
bottleIconView = (ImageView) findViewById(R.id.bottle_tips_image);
userAvatarView = (ImageView) findViewById(R.id.bottle_tips_avatar);
tipsView = (TextView) findViewById(R.id.bottle_tips);
gotitView = (Button) findViewById(R.id.bottle_tips_gotit);
gotitView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(BottleTipsActivity.this, HomeActivity.class);
intent.putExtra("need_refresh", true);
startActivity(intent);
BottleTipsActivity.this.finish();
}
});
}
private void initTips() {
BottleTypeTable btt = new BottleTypeTable();
entry = btt.getBottleType(bottleId);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
String avatar = userEntry.getAvatar();
avatarBitmap = HttpUtils.getBitmapFromUrl(this, avatar);
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case init_tips:
try {
if (entry != null) {
btConfigLoader.DisplayImage(entry.getBttype_sjwicon(), bottleIconView, R.drawable.bottle_type_1);
}
if (avatarBitmap != null) {
userAvatarView.setImageBitmap(avatarBitmap);
}
tipsView.setText(gainbt_msg);
} catch (Exception e) {
e.printStackTrace();
}
break;
default:
break;
}
}
};
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.List;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.ui.fragment.BottleFragment;
import com.outsourcing.bottle.ui.fragment.ExchangeFragment;
import com.outsourcing.bottle.ui.fragment.FriendFragment;
import com.outsourcing.bottle.util.ActivityManager;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BottleService;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.widget.ViewPagerIndicator;
public class HomeActivity extends BasicActivity implements Callback, OnClickListener {
private final int user_baseinfo_notfull = 0;
private final int complete_info = 1;
private final int menu_uploadphoto = 5;
private final int menu_exprofile = 4;
private final int menu_exphoto = 3;
private final int menu_gainbt = 2;
private final int menu_sendbt = 1;
private ImageView backView;
private ImageButton menuView;
public TextView titleView;
private ImageView spaceView;
public PagerAdapter mPagerAdapter;
public ViewPager mViewPager;
public ViewPagerIndicator mIndicator;
private Handler handler;
public BottleFragment bottleFragment;
public ExchangeFragment exchangeFragment;
public FriendFragment friendFragment;
private LinearLayout bottomLayout;
private ImageView avatarView;
private TextView contentView;
private TextView btnCount;
// private ImageView messageView;
private ImageLoader userImageLoader;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
SatelliteMenu menu;
public int exchange_item;
public int bottle_item;
public int friend_item;
public String[] exchange_choices;
public String[] bottle_choices;
public String[] friend_choices;
private ServiceConnection conn;
private PushBroadcastReceiver receiver;
private PushNoticeInfo pushInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handler = new Handler(this);
userImageLoader = new ImageLoader(this, AppContext.UserAvatarIcon);
setContentView(R.layout.home_pager);
if (!AppContext.FIRTH_INIT) {
AppContext.getInstance().setCurrentItem(1);
}
conn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
}
};
Intent intent = new Intent(this, BottleService.class);
startService(intent);
bindService(intent, conn, Context.BIND_AUTO_CREATE);
initLayout();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
//网络定位
networkLocat();
}
@Override
protected void onResume() {
super.onResume();
int currentItem = 0;
currentItem = AppContext.getInstance().getCurrentItem();
boolean needRefresh = getIntent().getBooleanExtra("need_refresh", false);
if (needRefresh) {
switch (currentItem) {
case 0:
exchangeFragment.init = false;
break;
case 1:
bottleFragment.init = false;
break;
case 2:
friendFragment.init = false;
break;
default:
break;
}
}
mViewPager.setCurrentItem(currentItem);
AppContext.FIRTH_INIT = true;
try {
pushNoticeUpdateUI();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initLayout() {
mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), this);
mPagerAdapter.addFragment(getString(R.string.public_txt_exchange), ExchangeFragment.class, null);
mPagerAdapter.addFragment(getString(R.string.public_txt_bottle), BottleFragment.class, null);
mPagerAdapter.addFragment(getString(R.string.public_txt_btfriend), FriendFragment.class, null);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setOffscreenPageLimit(0);
mViewPager.setAdapter(mPagerAdapter);
mIndicator = (ViewPagerIndicator) findViewById(R.id.indicator);
mViewPager.setOnPageChangeListener(mIndicator);
mIndicator.setContext(this);
mIndicator.init(AppContext.getInstance().getCurrentItem(), mPagerAdapter.getCount(), mPagerAdapter);
Resources res = getResources();
Drawable prev = res.getDrawable(R.drawable.arrow_left);
Drawable next = res.getDrawable(R.drawable.arrow_right);
mIndicator.setTextColor(Color.WHITE);
mIndicator.setArrows(prev, next);
mIndicator.setOnClickListener(new OnIndicatorClickListener());
if (menu == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.menu_layout);
menu = new SatelliteMenu(this);
// menu.setExpandDuration(500);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
menu.setTotalSpacingDegree(90.0f);
menu.setCloseItemsOnClick(true);
layout.addView(menu);
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
}
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: //扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(HomeActivity.this, ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: //捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(HomeActivity.this, ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: //交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(HomeActivity.this, ChooseFriendActivity.class);
exchangeInfoIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
AppContext.getInstance().setFromExchangeTimeToChangeFriend(true);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: //交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(HomeActivity.this, ChooseFriendActivity.class);
exchangeFileIntent.putExtra("choose_friend_type", AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
AppContext.getInstance().setFromExchangeTimeToChangeFriend(true);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(HomeActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
menuView = (ImageButton) findViewById(R.id.topbar_menu);
menuView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.topbar_title);
spaceView = (ImageView) findViewById(R.id.topbar_space);
spaceView.setOnClickListener(this);
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
avatarView = (ImageView) findViewById(R.id.notice_avatar);
contentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
}
@Override
public void sysMesPositiveButtonEvent(int what) {
if (what == complete_info) {
Intent intent = new Intent(this, SettingActivity.class);
startActivity(intent);
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case user_baseinfo_notfull:
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
showChoseMes(userEntry.getBasicinfo_tip(), complete_info);
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
if (mIndicator.mCurItem == 0) {
exchangeFragment.doGetExTimeline_Refresh();
} else if (mIndicator.mCurItem == 1) {
bottleFragment.doGetBottleTimeline_Refresh();
} else if (mIndicator.mCurItem == 2) {
friendFragment.doGetBTfriendList_Refresh();
}
} else if (v == menuView) {
Intent intent = new Intent(this, MoreActivity.class);
startActivity(intent);
}
// else if (v == messageView) {
// doMessageAction();
// }
else if (v == bottomLayout) {
doFeedsAction();
} else if (v == spaceView) {
Intent intent = new Intent(this, UserSpaceActivity.class);
intent.putExtra("ouid", AppContext.getInstance().getLogin_uid());
startActivity(intent);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// moveTaskToBack(true);
showExitTips();
return true;
} else if (keyCode == KeyEvent.KEYCODE_HOME) {
moveTaskToBack(true);
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
public void showExitTips() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.logout_home));
builder.setPositiveButton(getString(R.string.confirm_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
doExit();
ActivityManager.finishAll();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
dialog.dismiss();
// moveTaskToBack(true);
}
});
builder.setNegativeButton(getString(R.string.confirm_cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
public void doExit() {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(R.string.app_name);
nm.cancel(R.drawable.logo + 1);
stopService(new Intent(this, BottleService.class));
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount + getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount + getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(HomeActivity.this, NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(HomeActivity.this, MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
mViewPager.setCurrentItem(1);
bottleFragment.doGetBottleTimeline_Refresh();
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
mViewPager.setCurrentItem(0);
exchangeFragment.doGetExTimeline_Refresh();
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(HomeActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(HomeActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
AppContext.getInstance().setGotoMaybeKown(true);
mViewPager.setCurrentItem(2);
}
}
});
builder.create().show();
}
/***
* 最新的动态 :0
最新的瓶子:1
收到的瓶子:2
扔出的瓶子:3
* @param mode
*/
public void doBottleMenuAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
bottle_choices = this.getResources().getStringArray(R.array.bottle_menu_item);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, bottle_choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
bottle_item = which;
titleView.setText(bottle_choices[which]);
bottleFragment.doMenuItemSelect(which);
}
});
builder.create().show();
}
/***
* 最新的动态 :0
最新的动态:1
资料交换:2
照片交换:3
* @param mode
*/
public void doExchangeMenuAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
exchange_choices = this.getResources().getStringArray(R.array.exchange_menu_item);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, exchange_choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
exchange_item = which;
titleView.setText(exchange_choices[which]);
exchangeFragment.doMenuItemSelect(which);
}
});
builder.create().show();
}
/***
* 我的好友
* 可能认识的人
* @param mode
*/
public void doBTFriendMenuAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
friend_choices = this.getResources().getStringArray(
R.array.friend_menu_item);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, friend_choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
friend_item = which;
titleView.setText(friend_choices[which]);
friendFragment.doMenuItemSelect(which);
}
});
builder.create().show();
}
public void doBTFriendMenuAction2() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
friend_choices = this.getResources().getStringArray(
R.array.friend_menu_item2);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, friend_choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
titleView.setText(friend_choices[which]);
friend_item = which;
friendFragment.doMenuItemSelect2(which);
}
});
builder.create().show();
}
class OnIndicatorClickListener implements ViewPagerIndicator.OnClickListener {
@Override
public void onCurrentClicked(View v) {
switch (mIndicator.mCurItem) {
case 0:
doExchangeMenuAction();
break;
case 1:
doBottleMenuAction();
break;
case 2:
if (friendFragment.getState() == FriendFragment.EXEU_GET_MYFRIEND_LIST_MORE
|| friendFragment.getState() == FriendFragment.EXEU_GET_MYFRIEND_LIST) {
friendFragment.doSelectGroupAction();
} else if (friendFragment.getState() == FriendFragment.EXEU_GET_MAYBEKONW_LIST
|| friendFragment.getState() == FriendFragment.EXEU_GET_MAYBEKONW_LIST_MORE){
doBTFriendMenuAction2();
} else {
doBTFriendMenuAction();
}
break;
default:
break;
}
}
@Override
public void onNextClicked(View v) {
mViewPager.setCurrentItem(Math.min(mPagerAdapter.getCount() - 1, mIndicator.getCurrentPosition() + 1));
}
@Override
public void onPreviousClicked(View v) {
mViewPager.setCurrentItem(Math.max(0, mIndicator.getCurrentPosition() - 1));
}
}
class PagerAdapter extends FragmentPagerAdapter implements
ViewPagerIndicator.PageInfoProvider {
private Context mContext;
private final ArrayList<FragmentInfo> fragments = new ArrayList<FragmentInfo>();
private ArrayList<Fragment> mfragments = new ArrayList<Fragment>();
protected final class FragmentInfo {
private final String tag;
@SuppressWarnings("unused")
private final Class<?> clss;
private final Bundle args;
protected FragmentInfo(String _tag, Class<?> _class, Bundle _args) {
tag = _tag;
clss = _class;
args = _args;
}
}
public PagerAdapter(FragmentManager fm, Context context) {
super(fm);
this.mContext = context;
}
public void addFragment(String tag, Class<?> clss, Bundle args) {
FragmentInfo fragmentInfo = new FragmentInfo(tag, clss, args);
fragments.add(fragmentInfo);
Fragment fragment = Fragment.instantiate(mContext, clss.getName(), fragmentInfo.args);
mfragments.add(fragment);
if (clss.getName().equals(BottleFragment.class.getName())) {
bottleFragment = (BottleFragment) fragment;
} else if (clss.getName().equals(ExchangeFragment.class.getName())) {
exchangeFragment = (ExchangeFragment) fragment;
} else if (clss.getName().equals(FriendFragment.class.getName())) {
friendFragment = (FriendFragment) fragment;
}
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// super.destroyItem(container, position, object);
}
@Override
public Fragment getItem(int pos) {
return mfragments.get(pos);
}
@Override
public int getCount() {
return fragments.size();
}
@Override
public String getTitle(int pos) {
return fragments.get(pos).tag;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (conn != null) {
unbindService(conn);
}
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void pushNoticeUpdateUI() {
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance().getLogin_uid());
if (pushInfo != null){
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
}
// if (newMessageCount + newNoticeCount > 0) {
// messageView.setImageResource(R.drawable.bottom_menu_notice_red);
// } else {
// messageView.setImageResource(R.drawable.bottom_menu_notice_yellow);
// }
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
contentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
userImageLoader.DisplayImage(message_avatar, avatarView, R.drawable.avatar_default_big);
} else {
bottomLayout.setVisibility(View.GONE);
NotificationManager mNotifMan = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mNotifMan.cancelAll();
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
newMaybeKownCount = bundle.getInt("newMaybeKownCount");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.HashMap;
import oauth.facebook.AsyncFacebookRunner;
import oauth.facebook.BaseRequestListener;
import oauth.facebook.DialogError;
import oauth.facebook.Facebook;
import oauth.facebook.Facebook.DialogListener;
import oauth.facebook.FacebookError;
import oauth.facebook.SessionEvents;
import oauth.facebook.SessionEvents.AuthListener;
import oauth.facebook.Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.aviary.android.feather.library.media.ExifInterfaceWrapper;
import com.aviary.android.feather.library.moa.MoaHD;
import com.aviary.android.feather.library.moa.MoaHD.Error;
import com.aviary.android.feather.library.providers.FeatherContentProvider;
import com.aviary.android.feather.library.providers.FeatherContentProvider.ActionsDbColumns.Action;
import com.aviary.android.feather.library.utils.IOUtils;
import com.aviary.android.feather.library.utils.StringUtils;
import com.aviary.android.feather.library.utils.SystemUtils;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.BottleTypeTable;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.OtherConfigTable;
import com.outsourcing.bottle.db.PlatformAccountTable;
import com.outsourcing.bottle.domain.BottleTypeEntry;
import com.outsourcing.bottle.domain.LocationEntry;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.OtherConfigEntry;
import com.outsourcing.bottle.domain.PlatformAccount;
import com.outsourcing.bottle.domain.PlatformBindConfig;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.oauth.OAuth;
import com.outsourcing.bottle.ui.fragment.BottleFragment;
import com.outsourcing.bottle.ui.fragment.ExchangeFragment;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageThumbnail;
import com.outsourcing.bottle.util.SubmitTask;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
/**
*
* @author 06peng
*
*/
public class ExpandEditActivity extends BasicActivity implements BasicUIEvent, OnClickListener, Callback {
public final int init_loginuser_info = 1;
public final int activity_result_camara_with_data = 1006;
public final int activity_result_pick_with_data = 1008;
public final int activity_result_cropimage_with_data = 1007;
public final int activity_result_aviary_with_data = 1009;
public final int send_bt = 4;
public final int send_bt_error = 5;
public final int send_bt_success = 6;
public final int locate = 7;
public final int do_success = 8;
public final int error = 9;
public final int replay_bt = 10;
public final int copy_mauaul_bt = 11;
public final int transmit_bt = 12;
public final int reply_infoex = 13;
public final int apply_picex = 14;
public final int reply_picex = 15;
public final int replypic_picex = 16;
public final int forwardpic_picex = 17;
public final int reply_photo = 18;
public final int reply_comment = 19;
public final int apply_friend = 20;
public final int send_message = 21;
public final int add_album = 22;
public final int edit_album = 23;
public final int upload_photo = 24;
public final int edit_memo = 25;
public final int set_doing = 26;
public final int edit_photo = 27;
public final int forward_bt = 36;
public final int forward_photo = 37;
public final int paint_bt = 38;
public final int paint_picex = 39;
public final int paint_photo = 40;
private final int oauth_tritter = 28;
private final int oauth_facebook = 29;
private final int oauth_weibo = 30;
private final int oauth_tencent = 31;
private final int oauth_renren = 32;
private final int oauth_douban = 33;
private final int oauth_qq = 34;
public static final int oauth_bind = 35;
private ImageView backView;
private TextView titleView;
private ImageButton confirmView;
private ImageView lockView;
private ImageView locateView;
private TextView locationView;
private EditText editView;
private ImageView uploadpicView;
private ImageView twitterView;
private ImageView facebookView;
private ImageView weiboView;
private ImageView tentcentView;
private ImageView doubanView;
private ImageView renrenView;
private ImageView qqView;
private LinearLayout platformLayout;
private RelativeLayout updatepicLayout;
private LinearLayout locateLayout;
private Bundle bundle;
private String fromType;
private int bttype_id;
private String fuids;
private double bt_geo_lng;
private double bt_geo_lat;
private String bt_geo_reference;
private BottleTypeEntry entry;
private LoginUserInfoEntry userEntry;
/** 回应资料交换:apply发起资料交换; reply回应资料交换 */
private String reply_infoex_type;
/** 回应照片交换:reply回应照片交换; accept接受照片交换两个功能。 */
private String reply_picex_type;
private int ouid;
public int picid;
private int pic_uid;
private int fuid;
private int commentid;
public int albumid;
private String albumname;
private String photoname;
private String memo;
/** 上传照片 的来源页面 album相册上传;photos相册查看上传;photo_detail相片查看上传 */
private String upload_from;
/** 编辑相册的来源页面 ablum、photos */
private String album_from;
private boolean bind_twitter;
private boolean bind_facebook;
private boolean bind_weibo;
private boolean bind_tencent;
private boolean bind_douban;
private boolean bind_renren;
private boolean bind_qq;
private boolean isLock;
public OAuth oauth;
private String platform;
public static final String CALLBACKURL = "app:authorize";
private boolean isGoOAuth;
private File picFile;
private Uri photoUri;
private boolean hasImage;
private final static int REQUEST_WIDTH = 1000;
private WeakReference<Bitmap> bitmapWeak;
private LocationEntry myLocation;
private boolean isLocate;
private OtherConfigEntry ocEntry;
static final int targetBytes = 65000;
static final int targetShortSide = 400;
static final int targetLongSide = 480;
private static final String TAG = ExpandEditActivity.class.getSimpleName();
private boolean isNeedUpdate = false;
private String return_type = "";
private Handler handler;
private Facebook mFacebook;
private AsyncFacebookRunner mAsyncRunner;
private SessionListener mSessionListener = new SessionListener();
private String mSessionId = null;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.expand_edit);
handler = new Handler(this);
if (ocEntry == null) {
OtherConfigTable ot = new OtherConfigTable(this);
ocEntry = ot.getBottleOtherConfig();
}
bundle = getIntent().getExtras();
if (bundle != null) {
fromType = bundle.getString("from_type");
initBottleLocation(bundle);
if (entry == null) {
BottleTypeTable btt = new BottleTypeTable(this);
entry = btt.getBottleType(bttype_id);
}
if (userEntry == null) {
LoginUserInfoTable userTable = new LoginUserInfoTable(this);
userEntry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
}
initWidget();
if (fromType.equals(AppContext.SEND_BT)) {
initSendBt();
} else if (fromType.equals(AppContext.REPLY_BT)) {
initReplayBottle();
} else if (fromType.equals(AppContext.COPYMANUAL_BT)) {
initCopyMaunalBottle();
} else if (fromType.equals(AppContext.TRANSMIT_BT)) {
initTransmitBottle();
} else if (fromType.equals(AppContext.REPLY_INFOEX)) {
/** 回应资料交换:apply发起资料交换; replay回应资料交换 */
reply_infoex_type = bundle.getString("reply_infoex_type");
initReplayInfoex();
} else if (fromType.equals(AppContext.APPLY_PICEX)) {
initApplyPicx();
} else if (fromType.equals(AppContext.REPLY_PICEX)) {
reply_picex_type = bundle.getString("reply_picex_type");
initReplayPicx();
} else if (fromType.equals(AppContext.REPLYPIC_PICEX)) {
initReplyPicPicex();
} else if (fromType.equals(AppContext.FORWARPIC_PICEX)) {
initForwardPicPicex();
} else if (fromType.equals(AppContext.REPLY_PHOTO)) {
initReplyPhoto();
} else if (fromType.equals(AppContext.REPLY_COMMENT)) {
initReplyComment();
} else if (fromType.equals(AppContext.APPLY_FRIEND)) {
initApplyFriend();
} else if (fromType.equals(AppContext.SEND_MESSAGE)) {
initSendMessage();
} else if (fromType.equals(AppContext.ADD_ALBUM)) {
initAddAlbum();
} else if (fromType.equals(AppContext.EDIT_ALBUM)) {
initEditAlbum();
} else if (fromType.equals(AppContext.UPLOAD_PHOTO)) {
initUploadPhoto();
} else if (fromType.equals(AppContext.EDIT_PHOTO)) {
initEditPhoto();
} else if (fromType.equals(AppContext.EDIT_MEMO)) {
initEditMemo();
} else if (fromType.equals(AppContext.SET_DOING)) {
initDoing();
} else if (fromType.equals(AppContext.PAINT_BT)) {
initPaintBt();
} else if (fromType.equals(AppContext.PAINT_PICEX)) {
initPaintPicex();
} else if (fromType.equals(AppContext.PAINT_PHOTO)) {
initPaintPhoto();
} else if (fromType.equals(AppContext.FORWARD_PHOTO)) {
initForwardPhoto();
} else if (fromType.equals(AppContext.FORWARD_BT)) {
initForwardBt();
}
}
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.topbar_title);
confirmView = (ImageButton) findViewById(R.id.topbar_confirm);
confirmView.setOnClickListener(this);
lockView = (ImageView) findViewById(R.id.expand_lock);
lockView.setOnClickListener(this);
locateView = (ImageView) findViewById(R.id.expand_locate);
locationView = (TextView) findViewById(R.id.expand_location);
locateLayout = (LinearLayout) findViewById(R.id.expand_locate_layout);
locateLayout.setOnClickListener(this);
uploadpicView = (ImageView) findViewById(R.id.uploadpic);
uploadpicView.setOnClickListener(this);
twitterView = (ImageView) findViewById(R.id.expand_twitter);
twitterView.setOnClickListener(this);
facebookView = (ImageView) findViewById(R.id.expand_facebook);
facebookView.setOnClickListener(this);
weiboView = (ImageView) findViewById(R.id.expand_weibo);
weiboView.setOnClickListener(this);
tentcentView = (ImageView) findViewById(R.id.expand_tencent);
tentcentView.setOnClickListener(this);
doubanView = (ImageView) findViewById(R.id.expand_douban);
doubanView.setOnClickListener(this);
renrenView = (ImageView) findViewById(R.id.expand_renren);
renrenView.setOnClickListener(this);
qqView = (ImageView) findViewById(R.id.expand_qq);
qqView.setOnClickListener(this);
editView = (EditText) findViewById(R.id.expand_edit);
platformLayout = (LinearLayout) findViewById(R.id.platform_layout);
updatepicLayout = (RelativeLayout) findViewById(R.id.uploadpic_layout);
if (userEntry == null) {
return;
}
if (userEntry.getTwitterok() == 1) {
bind_twitter = true;
twitterView.setBackgroundResource(R.drawable.edit_ico_twitter);
}
if (userEntry.getFacebookok() == 1) {
bind_facebook = true;
facebookView.setBackgroundResource(R.drawable.edit_ico_facebook);
}
if (userEntry.getDoubanok() == 1) {
bind_douban = true;
doubanView.setBackgroundResource(R.drawable.edit_ico_douban);
}
if (userEntry.getQqok() == 1) {
bind_qq = true;
qqView.setBackgroundResource(R.drawable.edit_ico_qq);
}
if (userEntry.getTqqok() == 1) {
bind_tencent = true;
tentcentView.setBackgroundResource(R.drawable.edit_ico_tqq);
}
if (userEntry.getSinaok() == 1) {
bind_weibo = true;
weiboView.setBackgroundResource(R.drawable.edit_ico_weibo);
}
if (userEntry.getRenrenok() == 1) {
bind_renren = true;
renrenView.setBackgroundResource(R.drawable.edit_ico_renren);
}
editView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
confirm();
}
return false;
}
});
}
private void initBottleLocation(Bundle bundle) {
bttype_id = bundle.getInt("bttype_id");
bt_geo_lng = bundle.getDouble("bt_geo_lng", 0);
bt_geo_lat = bundle.getDouble("bt_geo_lat", 0);
bt_geo_reference = bundle.getString("bt_geo_reference");
}
private void initLocateTextView() {
if (AppContext.auto_locate) {
//网络定位
networkLocat();
locationView.setText("正在定位中...");
}
}
private void initReplayBottle() {
bttype_id = bundle.getInt("bttype_id");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_reply_bt));
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
updatepicLayout.setVisibility(View.VISIBLE);
initLocateTextView();
}
private void initSendBt() {
if (entry.getBttype_pic_show() == 1) {
uploadpicView.setVisibility(View.VISIBLE);
} else {
uploadpicView.setVisibility(View.GONE);
}
if (entry.getBttype_spread_show() == 1) {
platformLayout.setVisibility(View.VISIBLE);
} else {
platformLayout.setVisibility(View.GONE);
}
String bottlename = null;
if (AppContext.language == 1) {
bottlename = entry.getBttype_name_cn();
} else {
bottlename = entry.getBttype_name_en();
}
titleView.setText(getString(R.string.expand_edit_sendbt_title1) + " "+ bottlename);
if (AppContext.language == 1) {
editView.setHint(entry.getBttype_tips_cn());
} else {
editView.setHint(entry.getBttype_tips_en());
}
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
updatepicLayout.setVisibility(View.VISIBLE);
}
private void initCopyMaunalBottle() {
bttype_id = bundle.getInt("bttype_id");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_copymanual_bt));
editView.setHint(getString(R.string.expand_edit_tips_copymanual_bt));
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
updatepicLayout.setVisibility(View.GONE);
}
private void initTransmitBottle() {
bttype_id = bundle.getInt("bttype_id");
titleView.setText(getString(R.string.expand_edit_title_transmit_bt));
editView.setHint(getString(R.string.expand_edit_tips_transmit_bt));
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.VISIBLE);
updatepicLayout.setVisibility(View.GONE);
}
private void initForwardBt(){
bttype_id = bundle.getInt("bttype_id");
fuids = bundle.getString("fuids");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_forward_bt));
editView.setHint(getString(R.string.expand_edit_tips_forward_bt));
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
updatepicLayout.setVisibility(View.GONE);
locateLayout.setVisibility(View.GONE);
}
private void initReplayInfoex() {
ouid = bundle.getInt("ouid");
platformLayout.setVisibility(View.GONE);
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
if (reply_infoex_type.equals("apply")) {
titleView.setText(getString(R.string.expand_edit_title_reply_infoex));
editView.setHint(getString(R.string.expand_edit_tips_reply_infoex));
} else {
titleView.setText(getString(R.string.expand_edit_title_replay));
}
initLocateTextView();
}
private void initApplyPicx() {
ouid = bundle.getInt("ouid");
updatepicLayout.setVisibility(View.VISIBLE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
titleView.setText(getString(R.string.expand_edit_title_apply_picex));
editView.setHint(getString(R.string.expand_edit_tips_reply_infoex2));
initLocateTextView();
}
private void initReplayPicx() {
ouid = bundle.getInt("ouid");
if (reply_picex_type.equals("reply")) {
titleView.setText(getString(R.string.expand_edit_title_replay));
} else {
titleView.setText(getString(R.string.expand_edit_title_apply_picex));
editView.setHint(getString(R.string.expand_edit_tips_reply_photo));
}
updatepicLayout.setVisibility(View.VISIBLE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initReplyPicPicex() {
ouid = bundle.getInt("ouid");
picid = bundle.getInt("picid");
titleView.setText(getString(R.string.expand_edit_title_replay));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initForwardPicPicex() {
picid = bundle.getInt("picid");
pic_uid = bundle.getInt("pic_uid");
fuid = bundle.getInt("fuid");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_replay));
editView.setHint(getString(R.string.expand_edit_tips_reply_tofriend));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initReplyPhoto() {
picid = bundle.getInt("picid");
titleView.setText(getString(R.string.expand_edit_title_replay));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initReplyComment() {
commentid = bundle.getInt("commentid");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_tips_reply_commen));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initApplyFriend() {
ouid = bundle.getInt("ouid");
titleView.setText(getString(R.string.expand_edit_tips_apply_friend));
editView.setHint(getString(R.string.expand_edit_tips_reply_infoex));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initSendMessage() {
ouid = bundle.getInt("ouid");
titleView.setText(getString(R.string.expand_edit_tips_send_message));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initAddAlbum() {
titleView.setText(getString(R.string.expand_edit_title_add_album));
editView.setHint(getString(R.string.expand_edit_tips_add_album));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
}
private void initEditAlbum() {
albumid = bundle.getInt("albumid");
albumname = bundle.getString("albumname");
album_from = bundle.getString("album_from");
titleView.setText(getString(R.string.expand_edit_title_edit_album));
editView.setText(albumname);
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
}
private void initUploadPhoto() {
albumid = bundle.getInt("albumid");
ouid = bundle.getInt("ouid");
upload_from = bundle.getString("upload_from");
titleView.setText(getString(R.string.expand_edit_title_upload_photo));
editView.setHint(getString(R.string.expand_edit_tips_upload_photo));
updatepicLayout.setVisibility(View.VISIBLE);
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.GONE);
initLocateTextView();
}
private void initEditPhoto() {
picid = bundle.getInt("picid");
photoname = bundle.getString("photoname");
titleView.setText(getString(R.string.expand_edit_title_edit_photo));
editView.setText(photoname);
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
}
private void initEditMemo() {
ouid = bundle.getInt("ouid");
memo = bundle.getString("memo");
titleView.setText(getString(R.string.expand_edit_title_edit_memo));
editView.setText(memo);
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
}
private void initDoing() {
titleView.setText(getString(R.string.expand_edit_title_setmood));
editView.setHint(getString(R.string.expand_edit_tips_setmood));
updatepicLayout.setVisibility(View.GONE);
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.GONE);
}
private void initForwardPhoto(){
picid = bundle.getInt("picid");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_forward_photo));
editView.setHint(getString(R.string.expand_edit_tips_forward_photo));
locateView.setVisibility(View.GONE);
locationView.setVisibility(View.GONE);
platformLayout.setVisibility(View.VISIBLE);
updatepicLayout.setVisibility(View.GONE);
}
private void initPaintBt(){
return_type = bundle.getString("return_type");
bttype_id = bundle.getInt("bttype_id");
titleView.setText(getString(R.string.expand_edit_title_paint_bt));
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.VISIBLE);
updatepicLayout.setVisibility(View.GONE);
uploadpicView.setVisibility(View.GONE);
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFileDir, "upload.jpeg");
}
private void initPaintPicex(){
ouid = bundle.getInt("ouid");
picid = bundle.getInt("picid");
return_type = bundle.getString("return_type");
titleView.setText(getString(R.string.expand_edit_title_paint_bt));
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.VISIBLE);
updatepicLayout.setVisibility(View.GONE);
uploadpicView.setVisibility(View.GONE);
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFileDir, "upload.jpeg");
}
private void initPaintPhoto(){
picid = bundle.getInt("picid");
titleView.setText(getString(R.string.expand_edit_title_paint_bt));
locateView.setVisibility(View.VISIBLE);
locationView.setVisibility(View.VISIBLE);
platformLayout.setVisibility(View.VISIBLE);
updatepicLayout.setVisibility(View.GONE);
uploadpicView.setVisibility(View.GONE);
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
picFile = new File(pictureFileDir, "upload.jpeg");
}
@Override
public void onClick(View v) {
if (v == backView) {
AppContext.getInstance().setFromBottleTime(false);
AppContext.getInstance().setFromExchangeTime(false);
finish();
} else if (v == lockView) {
if (isLock) {
isLock = false;
lockView.setBackgroundResource(R.drawable.unlock);
} else {
isLock = true;
lockView.setBackgroundResource(R.drawable.lock);
bind_twitter = false;
twitterView.setBackgroundResource(R.drawable.edit_ico_twitter_gray);
bind_facebook = false;
facebookView.setBackgroundResource(R.drawable.edit_ico_facebook_gray);
bind_weibo = false;
weiboView.setBackgroundResource(R.drawable.edit_ico_weibo_gray);
bind_tencent = false;
tentcentView.setBackgroundResource(R.drawable.edit_ico_tqq_gray);
bind_douban = false;
doubanView.setBackgroundResource(R.drawable.edit_ico_douban_gray);
bind_renren = false;
renrenView.setBackgroundResource(R.drawable.edit_ico_renren_gray);
bind_qq = false;
qqView.setBackgroundResource(R.drawable.edit_ico_qq_gray);
}
} else if (v == twitterView) {
if (isLock) {
return;
}
if (ocEntry.getTwitter_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getTwitterok() == 1) {
if (bind_twitter) {
bind_twitter = false;
twitterView.setBackgroundResource(R.drawable.edit_ico_twitter_gray);
} else {
bind_twitter = true;
twitterView.setBackgroundResource(R.drawable.edit_ico_twitter);
}
} else {
UICore.eventTask(this, this, oauth_tritter, "", null);
}
} else if (v == facebookView) {
if (isLock) {
return;
}
if (ocEntry.getFacebook_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getFacebookok() == 1) {
if (bind_facebook) {
bind_facebook = false;
facebookView.setBackgroundResource(R.drawable.edit_ico_facebook_gray);
} else {
bind_facebook = true;
facebookView.setBackgroundResource(R.drawable.edit_ico_facebook);
}
} else {
isGoOAuth = true;
platform = PlatformBindConfig.Facebook;
mFacebook = new Facebook(PlatformBindConfig.Facebook_AppID);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
SessionEvents.addAuthListener(new SampleAuthListener());
SessionEvents.addAuthListener(mSessionListener);
mFacebook.authorize((BasicActivity) AppContext.getContext(), new String[] {}, new LoginDialogListener());
// UICore.eventTask(this, this, oauth_facebook, "", null);
}
} else if (v == weiboView) {
if (isLock) {
return;
}
if (ocEntry.getWeibo_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getSinaok() == 1) {
if (bind_weibo) {
bind_weibo = false;
weiboView.setBackgroundResource(R.drawable.edit_ico_weibo_gray);
} else {
bind_weibo = true;
weiboView.setBackgroundResource(R.drawable.edit_ico_weibo);
}
} else {
UICore.eventTask(this, this, oauth_weibo, "", null);
}
} else if (v == tentcentView) {
if (isLock) {
return;
}
if (ocEntry.getTencent_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getTqqok() == 1) {
if (bind_tencent) {
bind_tencent = false;
tentcentView.setBackgroundResource(R.drawable.edit_ico_tqq_gray);
} else {
bind_tencent = true;
tentcentView.setBackgroundResource(R.drawable.edit_ico_tqq);
}
} else {
UICore.eventTask(this, this, oauth_tencent, "", null);
}
} else if (v == doubanView) {
if (isLock) {
return;
}
if (ocEntry.getDouban_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getDoubanok() == 1) {
if (bind_douban) {
bind_douban = false;
doubanView.setBackgroundResource(R.drawable.edit_ico_douban_gray);
} else {
bind_douban = true;
doubanView.setBackgroundResource(R.drawable.edit_ico_douban);
}
} else {
UICore.eventTask(this, this, oauth_douban, "", null);
}
} else if (v == renrenView) {
if (isLock) {
return;
}
if (ocEntry.getRenren_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getRenrenok() == 1) {
if (bind_renren) {
bind_renren = false;
renrenView.setBackgroundResource(R.drawable.edit_ico_renren_gray);
} else {
bind_renren = true;
renrenView.setBackgroundResource(R.drawable.edit_ico_renren);
}
} else {
UICore.eventTask(this, this, oauth_renren, "", null);
}
} else if (v == qqView) {
if (isLock) {
return;
}
if (ocEntry.getQq_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (userEntry.getQqok() == 1) {
if (bind_qq) {
bind_qq = false;
qqView.setBackgroundResource(R.drawable.edit_ico_qq_gray);
} else {
bind_qq = true;
qqView.setBackgroundResource(R.drawable.edit_ico_qq);
}
} else {
UICore.eventTask(this, this, oauth_qq, "", null);
}
} else if (v == locateLayout) {
if (isLock) {
return;
}
if (isLocate) {
locateView.setBackgroundResource(R.drawable.locate_gray);
locationView.setText("");
isLocate = false;
AppContext.auto_locate = false;
} else {
AppContext.auto_locate = true;
initLocateTextView();
// UICore.eventTask(this, this, locate, "locate", null);
}
} else if (v == uploadpicView) {
doPickPhotoAction();
} else if (v == confirmView) {
confirm();
}
}
private void confirm() {
isNeedUpdate = true;
if (editView.getText().toString().trim().equals("")) {
isNeedUpdate = false;
onToast(getString(R.string.expand_edit_comment_must));
return;
} else if (editView.getText().toString().length() < 2) {
isNeedUpdate = false;
onToast(getString(R.string.expand_edit_comment_error));
return;
}
if (fromType.equals(AppContext.SEND_BT)) { // 扔瓶子
if (entry.getBttype_pic_must() == 1) {
if (!hasImage) {
onToast(getString(R.string.expand_edit_pic_must));
return;
}
}
sendBt();
} else if (fromType.equals(AppContext.REPLY_BT)) { // 回复瓶子
replay_bt();
} else if (fromType.equals(AppContext.COPYMANUAL_BT)) {// 手动传递瓶子
copymanual_bt();
} else if (fromType.equals(AppContext.TRANSMIT_BT)) { // 转发瓶子
if (bind_douban || bind_facebook || bind_qq || bind_renren
|| bind_tencent || bind_twitter || bind_weibo) {
transmitBt();
} else {
onToast(getString(R.string.expand_edit_forward_must));
}
} else if (fromType.equals(AppContext.REPLY_INFOEX)) { // 回应资料交换
// 包含了:回应资料交换、发起资料交换两个功能。
replyInfoex();
} else if (fromType.equals(AppContext.APPLY_PICEX)) { // 发起照片交换
if (!hasImage) {
onToast(getString(R.string.expand_edit_pic_must));
return;
}
applyPicex();
} else if (fromType.equals(AppContext.REPLY_PICEX)) { // 回应照片交换
// 包含了回应照片交换、接受照片交换两个功能。
if (reply_picex_type.equals("accept")) {
if (!hasImage) {
onToast(getString(R.string.expand_edit_pic_must));
return;
}
}
replyPicex();
} else if (fromType.equals(AppContext.REPLYPIC_PICEX)) { // 回应照片交换中的照片
replyPicPicex();
} else if (fromType.equals(AppContext.FORWARPIC_PICEX)) { // 转发照片交换中的照片
forwardPicPicex();
} else if (fromType.equals(AppContext.REPLY_PHOTO)) { // 评论相册照片
replyPhoto();
} else if (fromType.equals(AppContext.REPLY_COMMENT)) { // 回复评论
replyComment();
} else if (fromType.equals(AppContext.APPLY_FRIEND)) { // 申请好友
applyFriend();
} else if (fromType.equals(AppContext.SEND_MESSAGE)) { // 发送私信
sendMessage();
} else if (fromType.equals(AppContext.ADD_ALBUM)) { // 添加相册
addAlbum();
} else if (fromType.equals(AppContext.EDIT_ALBUM)) { // 编辑相册
editAlbum();
} else if (fromType.equals(AppContext.UPLOAD_PHOTO)) { // 上传照片
if (!hasImage) {
onToast(getString(R.string.expand_edit_pic_must));
return;
}
uploadPhoto();
} else if (fromType.equals(AppContext.EDIT_PHOTO)) { // 编辑照片
editPhoto();
} else if (fromType.equals(AppContext.EDIT_MEMO)) { // 编辑备注
editMemo();
} else if (fromType.equals(AppContext.SET_DOING)) { // 编辑心情
setDoing();
} else if (fromType.equals(AppContext.FORWARD_BT)) {
forwardBt();
} else if (fromType.equals(AppContext.FORWARD_PHOTO)) {
forwardPhoto();
} else if (fromType.equals(AppContext.PAINT_BT)) {
paintBt();
} else if (fromType.equals(AppContext.PAINT_PICEX)) {
paintPicex();
} else if (fromType.equals(AppContext.PAINT_PHOTO)) {
paintPhoto();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case send_bt:
sendBt();
break;
case init_loginuser_info:
getLoginUserInfo();
break;
case locate:
locate();
handler.sendEmptyMessage(locate);
break;
case replay_bt:
replay_bt();
break;
case copy_mauaul_bt:
copymanual_bt();
break;
case transmit_bt:
transmitBt();
break;
case reply_infoex:
replyInfoex();
break;
case reply_picex:
replyPicex();
break;
case apply_picex:
applyPicex();
break;
case replypic_picex:
replyPicPicex();
break;
case forwardpic_picex:
forwardPicPicex();
break;
case reply_photo:
replyPhoto();
break;
case reply_comment:
replyComment();
break;
case apply_friend:
applyFriend();
break;
case send_message:
sendMessage();
break;
case add_album:
addAlbum();
break;
case edit_album:
editAlbum();
break;
case upload_photo:
uploadPhoto();
break;
case edit_photo:
editPhoto();
break;
case edit_memo:
editMemo();
break;
case set_doing:
setDoing();
break;
case forward_bt:
forwardBt();
break;
case forward_photo:
forwardPhoto();
break;
case paint_bt:
paintBt();
break;
case paint_picex:
paintPicex();
break;
case paint_photo:
paintPhoto();
break;
case oauth_douban:
isGoOAuth = true;
platform = PlatformBindConfig.Douban;
oauth = new OAuth(this, handler, platform, PlatformBindConfig.Douban_AppKey,
PlatformBindConfig.Douban_AppSecret);
oauth.requestAccessToken(CALLBACKURL, PlatformBindConfig.Douban_Request_Token,
PlatformBindConfig.Douban_Access_Token, PlatformBindConfig.Douban_Authorize);
break;
case oauth_facebook:
PlatformAccount account = (PlatformAccount) obj;
checkBind(account);
break;
case oauth_qq:
isGoOAuth = true;
platform = PlatformBindConfig.QQ;
oauth = new OAuth(this, handler, platform);
oauth.requestAccessTokenForOAuth2(PlatformBindConfig.QQ_Authorize);
break;
case oauth_renren:
isGoOAuth = true;
platform = PlatformBindConfig.Renren;
oauth = new OAuth(this, handler, platform);
oauth.requestAccessTokenForOAuth2(PlatformBindConfig.Renren_Authorize);
break;
case oauth_tencent:
isGoOAuth = true;
platform = PlatformBindConfig.Tencent;
oauth = new OAuth(this, handler, platform);
oauth.requestAccessTokenForOAuth2(PlatformBindConfig.Tencent_Authorize_2);
break;
case oauth_tritter:
isGoOAuth = true;
platform = PlatformBindConfig.Twitter;
oauth = new OAuth(this, handler, PlatformBindConfig.Twitter,
PlatformBindConfig.Twitter_ConsumerKey, PlatformBindConfig.Twitter_ConsumerSecret);
oauth.requestAcccessTokenForTwitter();
break;
case oauth_weibo:
isGoOAuth = true;
platform = PlatformBindConfig.Sina;
oauth = new OAuth(this, handler, platform);
oauth.requestAccessTokenForOAuth2(PlatformBindConfig.Sina_Authorize2);
break;
default:
break;
}
}
private void paintPhoto() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.PAINT_PHOTO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("picid", String.valueOf(picid));
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
private void paintPicex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.PAINT_PICEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
paramsMap.put("picid", String.valueOf(picid));
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
private void paintBt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.PAINT_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("btid", String.valueOf(bttype_id));
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
private void forwardPhoto() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.FORWARD_PHOTO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
paramsMap.put("picid", String.valueOf(picid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
private void forwardBt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.FORWARD_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("btid", String.valueOf(bttype_id));
paramsMap.put("fuids", String.valueOf(fuids));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
if (isGoOAuth) {
// initPlatform();
isGoOAuth = false;
AppContext.getInstance().setOAUTH_TYPE(-1);
UICore.eventTask(this, this, init_loginuser_info, "get_logininfo", null);
}
}
private void initPlatform() {
int type = AppContext.getInstance().getOAUTH_TYPE();
System.out.println("open_type:" + type);
if (type == 0) {
bind_qq = true;
qqView.setBackgroundResource(R.drawable.edit_ico_qq);
} else if (type == 1) {
bind_weibo = true;
weiboView.setBackgroundResource(R.drawable.edit_ico_weibo);
} else if (type == 2) {
bind_tencent = true;
tentcentView.setBackgroundResource(R.drawable.edit_ico_tqq);
} else if (type == 3) {
bind_renren = true;
renrenView.setBackgroundResource(R.drawable.edit_ico_renren);
} else if (type == 4) {
bind_douban = true;
doubanView.setBackgroundResource(R.drawable.edit_ico_douban);
} else if (type == 5) {
bind_twitter = true;
twitterView.setBackgroundResource(R.drawable.edit_ico_twitter);
} else if (type == 6) {
bind_facebook = true;
facebookView.setBackgroundResource(R.drawable.edit_ico_facebook);
}
}
private void doPickPhotoAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String[] choices;
choices = new String[2];
choices[0] = getString(R.string.expand_edit_take_photo); // 拍照
choices[1] = getString(R.string.expand_edit_choose_photo); // 从相册中选择
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.expand_edit_photo_title);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_MOUNTED)) {// 判断是否有SD卡
doTakePhoto();// 用户点击了从照相机获取
}
break;
case 1:
doCropPhoto();// 从相册中去获取
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
/**
* 拍照获取图片
*
*/
protected void doTakePhoto() {
try {
File uploadFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (!uploadFileDir.exists()) {
uploadFileDir.mkdirs();
}
picFile = new File(uploadFileDir, "upload.jpeg");
if (!picFile.exists()) {
picFile.createNewFile();
}
photoUri = Uri.fromFile(picFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(cameraIntent, activity_result_camara_with_data);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 从本地手机中选择图片
*/
public void doSelectImageFromLoacal() {
Intent localIntent = new Intent();
localIntent.setType("image/*");
localIntent.setAction("android.intent.action.GET_CONTENT");
Intent localIntent2 = Intent.createChooser(localIntent, getString(R.string.expand_edit_choose_photo));
startActivityForResult(localIntent2, activity_result_pick_with_data);
}
// 封装请求Gallery的intent
// public Intent getPhotoPickIntent() {
// Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
// intent.setType("image/*");
// intent.putExtra("crop", "true");
// intent.putExtra("aspectX", 1);
// intent.putExtra("aspectY", 1);
// intent.putExtra("outputX", 480);
// intent.putExtra("outputY", 480);
// intent.putExtra("noFaceDetection", "true");
// intent.putExtra("scaleUpIfNeeded", "true");
// intent.putExtra("return-data", true);
// return intent;
// }
// 请求Gallery程序
// protected void doPickPhotoFromGallery() {
// try {
// // Launch picker to choose photo for selected contact
// final Intent intent = getPhotoPickIntent();
// startActivityForResult(intent, activity_result_pick_with_data);
// } catch (ActivityNotFoundException e) {
// e.printStackTrace();
// }
// }
protected void doCropPhoto() {
try {
File pictureFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
if (!picFile.exists()) {
picFile.createNewFile();
}
photoUri = Uri.fromFile(picFile);
final Intent intent = getCropImageIntent();
startActivityForResult(intent, activity_result_cropimage_with_data);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Constructs an intent for image cropping. 调用图片剪辑程序
*/
public Intent getCropImageIntent() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 600);
intent.putExtra("outputY", 600);
intent.putExtra("noFaceDetection", true);
intent.putExtra("scale", true);
intent.putExtra("return-data", false);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
return intent;
}
private void cropImageUriByTakePhoto() {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 600);
intent.putExtra("outputY", 600);
intent.putExtra("scale", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
intent.putExtra("return-data", false);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
intent.putExtra("noFaceDetection", true); // no face detection
startActivityForResult(intent, activity_result_cropimage_with_data);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case activity_result_pick_with_data: // 从本地选择图片
if (data == null) {
return;
}
Uri uri = data.getData();
ContentResolver resolver = getContentResolver();
try {
InputStream inputStream1 = resolver.openInputStream(uri);
InputStream inputStream2 = resolver.openInputStream(uri);
Bitmap bitmapDecode = ImageThumbnail.decodeStream(inputStream1, inputStream2, REQUEST_WIDTH);
if (bitmapDecode.getWidth() > REQUEST_WIDTH) {
bitmapWeak = new WeakReference<Bitmap>(ImageThumbnail.getCompressBmp(bitmapDecode, REQUEST_WIDTH, true));
} else {
bitmapWeak = new WeakReference<Bitmap>(bitmapDecode);
}
File pictureFileDir = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
if (!pictureFileDir.exists()) {
pictureFileDir.mkdirs();
}
picFile = new File(pictureFileDir, "upload.jpeg");
if (!picFile.exists()) {
picFile.createNewFile();
}
FileOutputStream ous = new FileOutputStream(picFile);
bitmapWeak.get().compress(Bitmap.CompressFormat.JPEG, 100, ous);
} catch (Exception e) {
e.printStackTrace();
}
break;
case activity_result_camara_with_data: // 拍照
try {
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
cropImageUriByTakePhoto();
// if (picFile != null && picFile.length() > 0) {
// InputStream inputStream1 = new FileInputStream(picFile);
// InputStream inputStream2 = new FileInputStream(picFile);
// Bitmap bitmapDecode = ImageThumbnail.decodeStream(inputStream1, inputStream2, REQUEST_WIDTH);
// if (bitmapDecode.getWidth() > REQUEST_WIDTH) {
// bitmapWeak = new WeakReference<Bitmap>(ImageThumbnail.getCompressBmp(bitmapDecode, REQUEST_WIDTH, true));
// } else {
// bitmapWeak = new WeakReference<Bitmap>(bitmapDecode);
// }
// Intent intent = new Intent(this, CropImageActivity.class);
// intent.putExtra("path", picFile.getAbsolutePath());
// startActivityForResult(intent, activity_result_cropimage_with_data);
// }
} catch (Exception e) {
e.printStackTrace();
}
break;
case activity_result_cropimage_with_data:
try {
if (photoUri != null) {
// bitmapWeak = new WeakReference<Bitmap>(decodeUriAsBitmap(photoUri));
// FileOutputStream out = new FileOutputStream(picFile);
// if (bitmapWeak.get().compress(Bitmap.CompressFormat.JPEG, 80, out)) {
// out.flush();
// out.close();
// }
startFeather();
}
} catch (Exception e) {
e.printStackTrace();
}
break;
case activity_result_aviary_with_data:
try {
if (picFile.exists()) {
File file = Utility.getNextFileName();
updateMedia(file.getAbsolutePath());
if (photoUri != null) {
Bitmap bitmap = decodeUriAsBitmap(photoUri);
uploadpicView.setImageBitmap(bitmap);
hasImage = true;
}
// if ( null != mSessionId ) {
// processHD( mSessionId );
// }
// mSessionId = null;
// InputStream in = new FileInputStream(picFile);
// BitmapFactory.Options options1 = new BitmapFactory.Options();
// options1.inPurgeable = true;
// options1.inInputShareable = true;
// options1.inSampleSize = 1;
// try {
// BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options1, true);
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// bitmapWeak = new WeakReference<Bitmap>(BitmapFactory.decodeStream(in, null, options1));
// uploadpicView.setImageBitmap(bitmapWeak.get());
// hasImage = true;
//
// FileOutputStream out = new FileOutputStream(picFile);
// if (bitmapWeak.get().compress(Bitmap.CompressFormat.PNG, 50, out)) {
// out.flush();
// out.close();
// }
}
} catch (Exception e) {
e.printStackTrace();
}
break;
}
}
/**
* We need to notify the MediaScanner when a new file is created. In this way all the gallery applications will be notified too.
*
* @param file
*/
private void updateMedia( String filepath ) {
Log.i( TAG, "updateMedia: " + filepath );
MediaScannerConnection.scanFile( getApplicationContext(), new String[] { filepath }, null, null );
}
/**
* Start the hi-res image processing.
*
*/
public void processHD( final String session_name ) {
Log.i( TAG, "processHD: " + session_name );
// get a new file for the hi-res file
File destination = new File(
Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH+"/upload/", "upload.jpeg");
String error = null;
// Now we need to fetch the session information from the content provider
FeatherContentProvider.SessionsDbColumns.Session session = null;
Uri sessionUri = FeatherContentProvider.SessionsDbColumns.getContentUri( session_name );
// this query will return a cursor with the informations about the given session
Cursor cursor = getContentResolver().query( sessionUri, null, null, null, null );
if ( null != cursor ) {
session = FeatherContentProvider.SessionsDbColumns.Session.Create( cursor );
cursor.close();
}
if ( null != session ) {
// Print out the session informations
Log.d( TAG, "session.id: " + session.id ); // session _id
Log.d( TAG, "session.name: " + session.session ); // session name
Log.d( TAG, "session.ctime: " + session.ctime ); // creation time
Log.d( TAG, "session.file_name: " + session.file_name ); // original file, it is the same you passed in the
// startActivityForResult Intent
// Now, based on the session information we need to retrieve
// the list of actions to apply to the hi-res image
Uri actionsUri = FeatherContentProvider.ActionsDbColumns.getContentUri( session.session );
// this query will return the list of actions performed on the original file, during the FeatherActivity session.
// Now you can apply each action to the hi-res image to replicate the same result on the bigger image
cursor = getContentResolver().query( actionsUri, null, null, null, null );
if ( null != cursor ) {
// If the cursor is valid we will start a new asynctask process to query the cursor
// and apply all the actions in a queue
HDAsyncTask task = new HDAsyncTask( Uri.parse( session.file_name ), destination.getAbsolutePath(), session_name );
task.execute( cursor );
} else {
error = "Failed to retrieve the list of actions!";
}
} else {
error = "Failed to retrieve the session informations";
}
if ( null != error ) {
Toast.makeText( this, error, Toast.LENGTH_LONG ).show();
}
}
/**
* 扔瓶子
*/
private void sendBt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.SEND_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
if (entry.getBttype_allow_spread() == 1) {
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
}
paramsMap.put("bttype_id", String.valueOf(bttype_id));
if (bt_geo_lng == 0.0) {
bt_geo_lng = AppContext.getInstance().getLongitude();
}
if (bt_geo_lat == 0.0) {
bt_geo_lat = AppContext.getInstance().getLatitude();
}
System.out.println("expandedit: bt_geo_lat:" + bt_geo_lat + ";bt_geo_lng:" + bt_geo_lng);
paramsMap.put("bt_geo_lng", String.valueOf(bt_geo_lng == 0.0 ? 0 : bt_geo_lng));
paramsMap.put("bt_geo_lat", String.valueOf(bt_geo_lat == 0.0 ? 0 : bt_geo_lat));
paramsMap.put("bt_geo_reference", bt_geo_reference == null ? "" : bt_geo_reference);
paramsMap.put("bt_tagid", bundle.getString("bt_tagid"));
paramsMap.put("bt_showaddress", bundle.getString("bt_showaddress"));
paramsMap.put("bt_tag", bundle.getString("bt_tag"));
if (bundle.containsKey("bt_samecity")) {
paramsMap.put("bt_samecity", String.valueOf(bundle.getInt("bt_samecity")));
}
if (bundle.containsKey("bt_samearea")) {
paramsMap.put("bt_samearea", String.valueOf(bundle.getInt("bt_samearea")));
}
if (bundle.containsKey("bt_sex")) {
paramsMap.put("bt_sex", String.valueOf(bundle.getInt("bt_sex")));
}
if (bundle.containsKey("bt_age")) {
paramsMap.put("bt_age", String.valueOf(bundle.getInt("bt_age")));
}
if (bundle.containsKey("bt_allowpick")) {
paramsMap.put("bt_allowpick", String.valueOf(bundle.getInt("bt_allowpick")));
}
if (bundle.containsKey("bt_allowspread")) {
paramsMap.put("bt_allowspread", String.valueOf(bundle.getInt("bt_allowspread")));
}
if (bundle.containsKey("bt_showreply")) {
paramsMap.put("bt_showreply", String.valueOf(bundle.getInt("bt_showreply")));
}
if (bundle.containsKey("bt_showfeed")) {
paramsMap.put("bt_showfeed", String.valueOf(bundle.getInt("bt_showfeed")));
}
if (bundle.containsKey("bt_fuids")) {
paramsMap.put("bt_fuids", String.valueOf(bundle.getString("bt_fuids")));
}
try {
SubmitTask st = null;
if (hasImage) {
st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} else {
st = new SubmitTask(this, handler, paramsMap);
st.execute();
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 回应瓶子
private void replay_bt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLY_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("btid", String.valueOf(bttype_id));
try {
locateParams(paramsMap);
SubmitTask st = null;
if (hasImage) {
st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} else {
st = new SubmitTask(this, handler, paramsMap);
st.execute();
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 手动传递瓶子
private void copymanual_bt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.COPYMANUAL_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("btid", String.valueOf(bttype_id));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 转发瓶子
private void transmitBt() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.TRANSMIT_BT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
if (bind_twitter) {
paramsMap.put("fw_twitter", "1");
}
if (bind_facebook) {
paramsMap.put("fw_facebook", "1");
}
if (bind_douban) {
paramsMap.put("fw_douban", "1");
}
if (bind_qq) {
paramsMap.put("fw_qq", "1");
}
if (bind_renren) {
paramsMap.put("fw_renren", "1");
}
if (bind_weibo) {
paramsMap.put("fw_sina", "1");
}
if (bind_tencent) {
paramsMap.put("fw_tqq", "1");
}
paramsMap.put("btid", String.valueOf(bttype_id));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 回复交换资料
private void replyInfoex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLY_INFOEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 发起照片交换
private void applyPicex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.APPLY_PICEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 回应照片交换、接受照片交换
private void replyPicex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLY_PICEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
locateParams(paramsMap);
SubmitTask st = null;
if (reply_picex_type.equals("apply")) {
st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} else {
if (hasImage) {
st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} else {
st = new SubmitTask(this, handler, paramsMap);
st.execute();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 回应照片交换中的照片
private void replyPicPicex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLYPIC_PICEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
paramsMap.put("picid", String.valueOf(picid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 转发照片交换中的照片
private void forwardPicPicex() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.FORWARPIC_PICEX);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("picid", String.valueOf(picid));
paramsMap.put("pic_uid", String.valueOf(pic_uid));
paramsMap.put("fuid", String.valueOf(fuid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 评论相册照片
private void replyPhoto() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLY_PHOTO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("picid", String.valueOf(picid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 评论相册照片
private void replyComment() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.REPLY_COMMENT);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("commentid", String.valueOf(commentid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 申请好友
private void applyFriend() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.APPLY_FRIEND);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 发送私信
private void sendMessage() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.SEND_MESSAGE);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 添加相册
private void addAlbum() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.ADD_ALBUM);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 编辑相册
private void editAlbum() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.EDIT_ALBUM);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("albumid", String.valueOf(albumid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 上传照片
private void uploadPhoto() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.UPLOAD_PHOTO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("albumid", String.valueOf(albumid));
try {
locateParams(paramsMap);
SubmitTask st = new SubmitTask(this, handler, paramsMap, picFile);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 编辑照片
private void editPhoto() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.EDIT_PHOTO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("picid", String.valueOf(picid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 设置备注
private void editMemo() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.EDIT_MEMO);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
paramsMap.put("ouid", String.valueOf(ouid));
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
// 设置心情
private void setDoing() {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("form_type", AppContext.SET_DOING);
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("message", editView.getText().toString().trim());
try {
SubmitTask st = new SubmitTask(this, handler, paramsMap);
st.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
private void locateParams(HashMap<String, String> paramsMap) {
if (isLocate) {
if (myLocation != null) {
paramsMap.put("geo_lng", String.valueOf(myLocation.getLongitude()));
paramsMap.put("geo_lat", String.valueOf(myLocation.getLatitude()));
paramsMap.put("geo_country", myLocation.getCountry());
paramsMap.put("geo_city", myLocation.getCity());
paramsMap.put("geo_area", myLocation.getArea());
paramsMap.put("geo_location", myLocation.getAddress());
}
}
}
private void locate() {
myLocation = new LocationEntry();
myLocation.setLatitude(AppContext.getInstance().getLatitude());
myLocation.setLongitude(AppContext.getInstance().getLongitude());
String params = String.valueOf(AppContext.getInstance().getLatitude()) + "," + String.valueOf(AppContext.getInstance().getLongitude());
String language = AppContext.language == 1 ? "zh" : "en";
String url = "http://www.mobibottle.com/openapi/geocode_offset.json?" +
"latlng="+params+"&sensor=true&language=" + language + "&login_uid=" + AppContext.getInstance().getLogin_uid();
try {
String result = HttpUtils.doGet(url);
JSONObject object = new JSONObject(result);
JSONArray arrays = object.getJSONArray("results");
for (int i = 0; i < arrays.length(); i++) {
JSONObject jsonObject = arrays.getJSONObject(i);
if (jsonObject != null) {
JSONArray addressArrays = jsonObject.getJSONArray("address_components");
for (int j = 0; j < addressArrays.length(); j++) {
JSONObject obj = addressArrays.getJSONObject(j);
JSONArray typeArray = obj.getJSONArray("types");
for (int k = 0; k < typeArray.length(); k++) {
String typename = typeArray.getString(k);
if (typename.equals("locality")) {
myLocation.setCity(obj.getString("long_name"));
} else if (typename.equals("administrative_area_level_1")) {
myLocation.setProvince(obj.getString("long_name"));
} else if (typename.equals("country")) {
myLocation.setCountry(obj.getString("long_name"));
}
}
}
myLocation.setAddress(jsonObject.getString("formatted_address"));
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
userEntry = loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
AppContext.getInstance().setFromExchangeTime(false);
AppContext.getInstance().setFromExchangeTimeToChangeFriend(false);
AppContext.getInstance().setFromBottleTime(false);
}
return super.onKeyUp(keyCode, event);
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (OAuth.reciver != null) {
unregisterReceiver(OAuth.reciver);
}
File uploadFileDir = new File(Environment.getExternalStorageDirectory() + "/" + AppContext.SD_PATH, "upload");
File file = new File(uploadFileDir, "upload.jpeg");
if (file.exists()) {
file.delete();
}
if (bitmapWeak != null && !bitmapWeak.get().isRecycled()) {
bitmapWeak.get().recycle();
bitmapWeak = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
try {
switch (msg.what) {
case send_bt_error:
onToast((String) msg.obj);
break;
case send_bt_success:
Object[] objs = (Object[]) msg.obj;
onToast((String) objs[0]);
Intent intent = new Intent(ExpandEditActivity.this, BottleTipsActivity.class);
intent.putExtra("type", "throw");
intent.putExtra("bottleId", Integer.parseInt(objs[1].toString()) == 0 ? bttype_id : Integer.parseInt(objs[1].toString()));
intent.putExtra("gainbt_msg", objs[2].toString());
startActivity(intent);
break;
case locate:
if (myLocation != null && myLocation.getAddress() != null) {
isLocate = true;
locateView.setBackgroundResource(R.drawable.locate_blue);
locationView.setText(myLocation.getAddress());
}
break;
case do_success:
onToast((String) msg.obj);
if (fromType.equals(AppContext.REPLY_BT)
|| fromType.equals(AppContext.COPYMANUAL_BT)
|| fromType.equals(AppContext.TRANSMIT_BT)) {
if (AppContext.getInstance().isFromBottleTime()) {
if (isNeedUpdate) {
finish();
} else {
AppContext.getInstance().setFromBottleTime(false);
finish();
}
} else if (!TextUtils.isEmpty(return_type) && return_type.equals(BottleSingleActivity.class.getSimpleName())) {
Intent successIntent = new Intent(ExpandEditActivity.this, BottleSingleActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(0, successIntent);
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, BottleDetailActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(0, successIntent);
}
// successIntent.putExtra("need_refresh", true);
// successIntent.putExtra("btid",bttype_id);
// successIntent.putExtra("type", 1);
} else if (fromType.equals(AppContext.REPLY_INFOEX)) {
Intent successIntent = new Intent(ExpandEditActivity.this, ExchangeInfoDetailActivity.class);
successIntent.putExtra("ouid", ouid);
startActivity(successIntent);
} else if (fromType.equals(AppContext.REPLY_PICEX)) {
if (AppContext.getInstance().isFromExchangeTime()) {
if (isNeedUpdate) {
finish();
} else {
AppContext.getInstance().setFromExchangeTime(false);
finish();
}
} else if (AppContext.getInstance().isFromExchangeTimeToChangeFriend()) {
if (isNeedUpdate) {
AppContext.getInstance().setCurrentItem(0);
finish();
} else {
AppContext.getInstance().setFromExchangeTimeToChangeFriend(false);
finish();
}
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, ExchangePicDetailActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(0, successIntent);
}
} else if (fromType.equals(AppContext.APPLY_PICEX)) {
Intent successIntent = new Intent(ExpandEditActivity.this, ExchangePicDetailActivity.class);
successIntent.putExtra("ouid", ouid);
startActivity(successIntent);
} else if (fromType.equals(AppContext.REPLYPIC_PICEX)
|| fromType.equals(AppContext.FORWARPIC_PICEX)) {
if (AppContext.getInstance().isFromExchangeTime()) {
if (isNeedUpdate) {
finish();
} else {
AppContext.getInstance().setFromExchangeTime(false);
finish();
}
} else if (AppContext.getInstance().isFromExchangePicDetail()) {
if (isNeedUpdate) {
finish();
} else {
AppContext.getInstance().setFromExchangePicDetail(false);
finish();
}
} else if (!TextUtils.isEmpty(return_type) && return_type.equals(ExchangePicDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setFromExchangePicSession(true);
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, ExchangePicFeedDetailActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(0, successIntent);
}
} else if (fromType.equals(AppContext.REPLY_PHOTO)
|| fromType.equals(AppContext.EDIT_PHOTO)) {
Intent successIntent = new Intent(ExpandEditActivity.this, UserPhotoActivity.class);
setResult(RESULT_OK, successIntent);
} else if (fromType.equals(AppContext.FORWARD_PHOTO)) {
if (return_type != null && return_type.equals(ExchangePicDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setFromExchangePicSession(true);
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, UserPhotoActivity.class);
setResult(RESULT_OK, successIntent);
}
}else if (fromType.equals(AppContext.SEND_MESSAGE)) {
Intent intentMessage = new Intent(ExpandEditActivity.this, ConversationListActivity.class);
intentMessage.putExtra("ouid", ouid);
startActivity(intentMessage);
} else if (fromType.equals(AppContext.SET_DOING)) {
Intent intentSetting = new Intent(ExpandEditActivity.this, SettingActivity.class);
startActivity(intentSetting);
} else if (fromType.equals(AppContext.ADD_ALBUM)) {
Intent successIntent = new Intent(ExpandEditActivity.this, AlbumsActivity.class);
setResult(RESULT_OK, successIntent);
} else if (fromType.equals(AppContext.EDIT_ALBUM)) {
if (album_from != null && album_from.equals("album")) {
Intent successIntent = new Intent(ExpandEditActivity.this, AlbumsActivity.class);
setResult(RESULT_OK, successIntent);
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, PhotosActivity.class);
setResult(RESULT_OK, successIntent);
}
} else if (fromType.equals(AppContext.UPLOAD_PHOTO)) {
if (upload_from != null) {
if (upload_from.equals("album")) {
Intent successIntent = new Intent(ExpandEditActivity.this, AlbumsActivity.class);
setResult(RESULT_OK, successIntent);
} else if (upload_from.equals("photos")) {
Intent successIntent = new Intent(ExpandEditActivity.this, PhotosActivity.class);
setResult(RESULT_OK, successIntent);
} else if (upload_from.equals("photo_detail")) {
Intent successIntent = new Intent(ExpandEditActivity.this, PhotosActivity.class);
successIntent.putExtra("albumid", albumid);
successIntent.putExtra("ouid", ouid);
startActivity(successIntent);
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, AlbumsActivity.class);
successIntent.putExtra("ouid", ouid);
startActivity(successIntent);
}
} else {
Intent successIntent = new Intent(ExpandEditActivity.this, AlbumsActivity.class);
successIntent.putExtra("ouid", ouid);
startActivity(successIntent);
}
} else if (fromType.equals(AppContext.REPLY_COMMENT)) {
if (return_type != null && return_type.equals(UserPhotoActivity.class.getSimpleName())) {
Intent successIntent = new Intent(ExpandEditActivity.this, UserPhotoActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(RESULT_OK, successIntent);
} else if (return_type.equals("bottledetailactivity")) {
Intent successIntent = new Intent(ExpandEditActivity.this, BottleDetailActivity.class);
successIntent.putExtra("need_refresh", isNeedUpdate);
setResult(0, successIntent);
}
} else if (fromType.equals(AppContext.PAINT_BT)) {
if (return_type != null && return_type.equals(BottleDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setBottleDetailActNeedRefresh(true);
} else if (return_type != null && return_type.equals(BottleFragment.class.getSimpleName())) {
AppContext.getInstance().setFromBottleTime(true);
} else if (return_type != null && return_type.equals(BottleSingleActivity.class.getSimpleName())) {
AppContext.getInstance().setFromBottleSingle(true);
}
} else if (fromType.equals(AppContext.PAINT_PICEX)) {
if (return_type != null && return_type.equals(ExchangePicFeedDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setFromExchangePicDetail(true);
} else if (return_type != null && return_type.equals(ExchangeFragment.class.getSimpleName())) {
AppContext.getInstance().setFromExchangeTime(true);
} else if (return_type != null && return_type.equals(ExchangePicDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setFromExchangePicSession(true);
}
} else if (fromType.equals(AppContext.PAINT_PHOTO)) {
AppContext.getInstance().setFromUserPhotoActivity(true);
} else if (fromType.equals(AppContext.FORWARD_BT)) {
if (return_type != null && return_type.equals(BottleSingleActivity.class.getSimpleName())) {
AppContext.getInstance().setFromBottleSingle(true);
} else if (return_type != null && return_type.equals(BottleDetailActivity.class.getSimpleName())) {
AppContext.getInstance().setBottleDetailActNeedRefresh(true);
} else if (return_type != null && return_type.equals(BottleFragment.class.getSimpleName())) {
AppContext.getInstance().setFromBottleTime(true);
}
}
finish();
break;
case error:
onToast((String) msg.obj);
break;
case AppContext.oauth_bind:
initPlatform();
break;
case oauth_facebook:
PlatformAccount account = (PlatformAccount) msg.obj;
UICore.eventTask(ExpandEditActivity.this, ExpandEditActivity.this, oauth_facebook, "", account);
break;
default:
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
@Override
public void locateSuccess() {
super.locateSuccess();
UICore.eventTask(this, this, locate, null, null);
}
public class SampleAuthListener implements AuthListener {
public void onAuthSucceed() {
System.out.println("You have logged in! ");
}
public void onAuthFail(String error) {
System.out.println("Login Failed: " + error);
}
}
public class SampleRequestListener extends BaseRequestListener {
public void onComplete(final String response, final Object state) {
try {
PlatformAccount account = new PlatformAccount();
Log.d("Facebook-Example", "Response: " + response.toString());
JSONObject json = Util.parseJson(response);
account.setAccessToken(mFacebook.getAccessToken());
if (json.has("name")) {
account.setNickName(json.getString("name"));
}
account.setOpenAvatar("https://graph.facebook.com/"+json.getString("id")+"/picture?type=large");
account.setOpenExpire(String.valueOf(mFacebook.getAccessExpires()));
account.setOpenType(6);
account.setOpenUid(json.getString("id"));
PlatformAccountTable paTable = new PlatformAccountTable();
paTable.save(account);
if (account.getOpenUid() != null && !account.getOpenUid().equals("")) {
Message msg = Message.obtain(handler, oauth_facebook, account);
handler.sendMessage(msg);
}
} catch (JSONException e) {
Log.w("Facebook-Example", "JSON Error in response");
} catch (FacebookError e) {
Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
}
}
}
private final class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
SessionEvents.onLoginSuccess();
}
public void onFacebookError(FacebookError error) {
SessionEvents.onLoginError(error.getMessage());
}
public void onError(DialogError error) {
SessionEvents.onLoginError(error.getMessage());
}
public void onCancel() {
SessionEvents.onLoginError("Action Canceled");
}
}
private class SessionListener implements AuthListener {
public void onAuthSucceed() {
mAsyncRunner.request("me", new SampleRequestListener());
}
public void onAuthFail(String error) {
}
}
private void checkBind(PlatformAccount account) {
String url = UrlConfig.check_bind;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("open_type", String.valueOf(account.getOpenType()));
paramsMap.put("access_token", account.getAccessToken());
paramsMap.put("token_secret", account.getTokenSecret());
paramsMap.put("nickname", account.getNickName());
paramsMap.put("open_uid", account.getOpenUid());
paramsMap.put("open_sex", String.valueOf(account.getOpenSex()));
paramsMap.put("open_expire", account.getOpenExpire());
paramsMap.put("open_avatar", account.getOpenAvatar());
paramsMap.put("device_token", AppContext.getInstance().getDeviceId());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
JSONObject object = new JSONObject(result);
if (object.has("results")) {
final JSONObject resultObj = object.getJSONObject("results");
System.out.println(resultObj);
int isbind = resultObj.getInt("isbind");
if (AppContext.getInstance().getLogin_uid() != 0 && AppContext.getInstance().getLogin_token() != null) {
if (isbind == 1) {
if (account.getOpenType() > 0) {
AppContext.getInstance().setOAUTH_TYPE(account.getOpenType());
handler.sendEmptyMessage(AppContext.oauth_bind);
} else {
AppContext.getInstance().setOAUTH_TYPE(-1);
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
* AsyncTask for Hi-Res image processing
*
* @author alessandro
*
*/
private class HDAsyncTask extends AsyncTask<Cursor, Integer, MoaHD.Error> {
Uri uri_;
String dstPath_;
ProgressDialog progress_;
String session_;
ExifInterfaceWrapper exif_;
/**
* Initialize the HiRes async task
*
* @param source
* - source image file
* @param destination
* - destination image file
* @param session_id
* - the session id used to retrieve the list of actions
*/
public HDAsyncTask( Uri source, String destination, String session_id ) {
uri_ = source;
dstPath_ = destination;
session_ = session_id;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progress_ = new ProgressDialog(ExpandEditActivity.this );
progress_.setIndeterminate( true );
progress_.setTitle( "Processing image" );
progress_.setMessage( "Loading image..." );
progress_.setProgressStyle( ProgressDialog.STYLE_SPINNER );
progress_.setCancelable( false );
progress_.show();
}
@Override
protected void onProgressUpdate( Integer... values ) {
super.onProgressUpdate( values );
final int index = values[0];
final int total = values[1];
String message = "";
if ( index == -1 )
message = "Saving image...";
else{
// message = "Applying action " + ( index + 1 ) + " of " + ( total );
message = "Saving image...";
}
progress_.setMessage( message );
Log.d(TAG, index + "/" + total + ", message: " + message );
}
@Override
protected Error doInBackground( Cursor... params ) {
Cursor cursor = params[0];
MoaHD.Error result = Error.UnknownError;
if ( null != cursor ) {
// Initialize the class to perform HD operations
MoaHD moa = new MoaHD();
// try to load the source image
result = loadImage( moa );
Log.d( TAG, "moa.load: " + result.name() );
// if image is loaded
if ( result == Error.NoError ) {
final int total_actions = cursor.getCount();
Log.d(TAG, "total actions: " + total_actions );
if ( cursor.moveToFirst() ) {
// get the total number of actions in the queue
// we're adding also the 'load' and the 'save' action to the total count
// now for each action in the given cursor, apply the action to
// the MoaHD instance
do {
// send a progress notification to the progressbar dialog
publishProgress( cursor.getPosition(), total_actions );
// load the action from the current cursor
Action action = Action.Create( cursor );
if ( null != action ) {
Log.d(TAG, "executing: " + action.id + "(" + action.session_id + " on " + action.ctime + ") = "
+ action.getActions() );
// apply a list of actions to the current image
moa.applyActions( action.getActions() );
} else {
Log.e(TAG, "Woa, something went wrong! Invalid action returned" );
}
// move the cursor to next position
} while ( cursor.moveToNext() );
}
// at the end of all the operations we need to save
// the modified image to a new file
publishProgress( -1, -1 );
result = moa.save( dstPath_ );
Log.d( TAG, "moa.save: " + result.name() );
if ( result != Error.NoError ) {
Log.e( TAG, "failed to save the image to " + dstPath_ );
}
// ok, now we can save the source image EXIF tags
// to the new image
if ( null != exif_ ) {
saveExif( exif_, dstPath_ );
}
} else {
Log.e(TAG, "Failed to load file" );
}
cursor.close();
// and unload the current bitmap. Note that you *MUST* call this method to free the memory allocated with the load
// method
result = moa.unload();
Log.d( TAG, "moa.unload: " + result.name() );
// finally dispose the moahd instance
moa.dispose();
}
return result;
}
/**
* Save the Exif tags to the new image
*
* @param originalExif
* @param filename
*/
private void saveExif( ExifInterfaceWrapper originalExif, String filename ) {
// ok, now we can save back the EXIF tags
// to the new file
ExifInterfaceWrapper newExif = null;
try {
newExif = new ExifInterfaceWrapper( dstPath_ );
} catch ( IOException e ) {
e.printStackTrace();
}
if ( null != newExif && null != originalExif ) {
originalExif.copyTo( newExif );
// this should be changed because the editor already rotate the image
newExif.setAttribute( ExifInterfaceWrapper.TAG_ORIENTATION, "0" );
// let's update the software tag too
newExif.setAttribute( ExifInterfaceWrapper.TAG_SOFTWARE, "Aviary " + FeatherActivity.SDK_VERSION );
// ...and the modification date
newExif.setAttribute( ExifInterfaceWrapper.TAG_DATETIME, ExifInterfaceWrapper.formatDate( new Date() ) );
try {
newExif.saveAttributes();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}
@Override
protected void onPostExecute( MoaHD.Error result ) {
super.onPostExecute( result );
if ( progress_.getWindow() != null ) {
progress_.dismiss();
}
// in case we had an error...
if ( result != Error.NoError ) {
Toast.makeText( ExpandEditActivity.this, "There was an error: " + result.name(), Toast.LENGTH_SHORT ).show();
return;
}
// finally notify the MediaScanner of the new generated file
updateMedia( dstPath_ );
// // now ask the user if he want to see the saved image
// new AlertDialog.Builder( ExpandEditActivity.this ).setTitle( "File saved" )
// .setMessage( "File saved in " + dstPath_ + ". Do you want to see the HD file?" )
// .setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick( DialogInterface dialog, int which ) {
//
// Intent intent = new Intent( Intent.ACTION_VIEW );
//
// String filepath = dstPath_;
// if ( !filepath.startsWith( "file:" ) ) {
// filepath = "file://" + filepath;
// }
// intent.setDataAndType( Uri.parse( filepath ), "image/jpeg" );
// startActivity( intent );
//
// }
// } ).setNegativeButton( android.R.string.no, null ).show();
// we don't need the session anymore, now we can delete it.
Log.d( TAG, "delete session: " + session_ );
deleteSession( session_ );
}
private Error loadImage( MoaHD moa ) {
MoaHD.Error result = Error.UnknownError;
final String srcPath = IOUtils.getRealFilePath( ExpandEditActivity.this, uri_ );
if ( srcPath != null ) {
// Let's try to load the EXIF tags from
// the source image
try {
exif_ = new ExifInterfaceWrapper( srcPath );
} catch ( IOException e ) {
e.printStackTrace();
}
result = moa.load( srcPath );
} else {
if ( SystemUtils.isHoneyComb() ) {
InputStream stream = null;
try {
stream = getContentResolver().openInputStream( uri_ );
} catch ( Exception e ) {
result = Error.FileNotFoundError;
e.printStackTrace();
}
if ( stream != null ) {
try {
result = moa.load( stream );
} catch ( Exception e ) {
result = Error.DecodeError;
}
} else {
Log.e( TAG, "stream is null!" );
}
} else {
ParcelFileDescriptor fd = null;
try {
fd = getContentResolver().openFileDescriptor( uri_, "r" );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
result = Error.FileNotFoundError;
}
if ( null != fd ) {
result = moa.load( fd.getFileDescriptor() );
}
}
}
return result;
}
}
/**
* Delete the session and all it's actions. We do not need it anymore.<br />
* Note that this is optional. All old sessions are automatically removed in Feather.
*
* @param session_id
*/
private void deleteSession( final String session_id ) {
Uri uri = FeatherContentProvider.SessionsDbColumns.getContentUri( session_id );
getContentResolver().delete( uri, null, null );
}
private Bitmap decodeUriAsBitmap(Uri uri) {
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
return bitmap;
}
private void startFeather() {
if ( !Utility.isExternalStorageAvilable() ) {
return;
}
if (photoUri == null) {
new AlertDialog.Builder( this ).setTitle( android.R.string.dialog_alert_title ).setMessage( "Failed to create a new File" ).show();
return;
}
Intent newIntent = new Intent(this, FeatherActivity.class);
newIntent.putExtra("From_Type", Constants.ACTIVITY_EDIT);
newIntent.setData(photoUri);
newIntent.putExtra("API_KEY", Utility.API_KEY);
newIntent.putExtra("output", photoUri);
newIntent.putExtra(Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.JPEG.name());
newIntent.putExtra(Constants.EXTRA_OUTPUT_QUALITY, 100);
newIntent.putExtra(Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true);
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int max_size = Math.min(metrics.widthPixels, metrics.heightPixels);
max_size = (int) ((double) max_size / 0.8);
newIntent.putExtra("max-image-size", max_size);
newIntent.putExtra("effect-enable-borders", true);
mSessionId = StringUtils.getSha256(System.currentTimeMillis() + Utility.API_KEY);
Log.d(TAG, "session: " + mSessionId + ", size: " + mSessionId.length());
newIntent.putExtra("output-hires-session-id", mSessionId);
startActivityForResult(newIntent, activity_result_aviary_with_data);
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ZoomControls;
import com.aviary.android.feather.Constants;
import com.aviary.android.feather.FeatherActivity;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BottleApplication;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.util.Utility;
import com.outsourcing.bottle.widget.ImageZoomView;
import com.outsourcing.bottle.widget.SimpleZoomListener;
import com.outsourcing.bottle.widget.ZoomState;
/**
* 查看图片 双手触摸放大缩小,单手拖放
* @author 06peng
*
*/
public class PhotoDetailActivity extends BasicActivity implements OnClickListener, Callback {
private String mPicPath = null;
private ImageView bt_back = null;
private ImageView bt_save = null;
private Bitmap bmp;
private byte[] tempBytes;
private Bitmap tempBmp;
/**是否点击涂鸦进来此页面的*/
private boolean isToDraw;
/**从哪个界面进来的涂鸦照片*/
private String mPaintType;
/**瓶子ID*/
private int btid;
private String return_type;
/**照片ID*/
private int picId;
/**交换会话中 对方的id*/
private int ouid;
private ImageZoomView mZoomView;
private ZoomState mZoomState;
private SimpleZoomListener mZoomListener;
private final static int download_pic = 1;
private final static int to_draw_pic = 2;
private static final int RESULT_DRAW_IMAGE = 3;
private Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showimageview);
handler = new Handler(this);
Intent intent = getIntent();
mPicPath = intent.getStringExtra("pic_big");
tempBytes = intent.getByteArrayExtra("thumbnail");
isToDraw = intent.getBooleanExtra("isToDraw", false);
mPaintType = intent.getStringExtra("paintType");
btid = intent.getIntExtra("btid", 0);
return_type = intent.getStringExtra("return_type");
picId = intent.getIntExtra("picid", 0);
ouid = intent.getIntExtra("ouid", 0);
bt_back = (ImageView) findViewById(R.id.topbar_back);
bt_save = (ImageView) findViewById(R.id.topbar_confirm);
bt_back.setOnClickListener(this);
bt_save.setOnClickListener(this);
mZoomView = (ImageZoomView) findViewById(R.id.zoomView);
if (tempBytes != null) {
tempBmp = ServiceUtils.bytesToBitmap(tempBytes);
} else {
tempBmp = ServiceUtils.drawableToBitmap(getResources().getDrawable(R.drawable.album_nophoto));
}
if (tempBmp != null) {
mZoomView.setImageBitmap(tempBmp);
mZoomView.invalidateImage();
}
if (mPicPath != null) {
DownloadImgTask task = new DownloadImgTask();
task.execute(mPicPath);
mZoomView.setPorterDuffMode(true);
mZoomView.setLoading(true);
mZoomView.setProgress(0);
mZoomView.invalidate();
}
}
@Override
public void onClick(View v) {
if (v == bt_back) {
finish();
} else if (v == bt_save) {
UICore.eventTask(this, this, download_pic, "download_pic", null);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case download_pic:
downloadImage();
break;
default:
break;
}
}
private void downloadImage() {
ServiceUtils.downLoadImage(mPicPath, AppContext.SD_PATH + "/download");
if (isToDraw) {
Message msg = Message.obtain(handler);
msg.what = to_draw_pic ;
msg.obj = AppContext.SD_PATH + "/download/"+mPicPath;
handler.sendMessage(msg);
}else {
handler.sendEmptyMessage(download_pic);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (bmp != null)
bmp.recycle();
mZoomView.setOnTouchListener(null);
if (mZoomState != null) {
mZoomState.deleteObservers();
}
}
private void resetZoomState() {
mZoomState.setPanX(0.5f);
mZoomState.setPanY(0.5f);
mZoomState.setZoom(1f);
mZoomState.notifyObservers();
}
public class DownloadImgTask extends AsyncTask<String, Float, Bitmap> {
private static final String TAG = "DownloadImgTask";
/** 下载准备工作。在UI线程中调用。 */
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
}
/** 执行下载。在背景线程调用。 */
protected Bitmap doInBackground(String... params) {
Bitmap bmp = null;
bmp = ((BottleApplication)PhotoDetailActivity.this.getApplication()).getLruImageCache().get(params[0]);
if (null != bmp) {
if (isToDraw) {
try {
File file = Utility.getNextFileName();
FileOutputStream fs = new FileOutputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
fs.write(baos.toByteArray());
baos.close();
fs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return bmp;
} else {
Log.i(TAG, "doInBackground:" + params[0]);
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
InputStream is = null;
ByteArrayOutputStream baos = null;
try {
HttpResponse httpResponse = httpClient.execute(httpGet);
printHttpResponse(httpResponse);
HttpEntity httpEntity = httpResponse.getEntity();
long length = httpEntity.getContentLength();
Log.i(TAG, "content length=" + length);
is = httpEntity.getContent();
if (is != null) {
baos = new ByteArrayOutputStream();
byte[] buf = new byte[128];
int read = -1;
int count = 0;
while ((read = is.read(buf)) != -1) {
baos.write(buf, 0, read);
count += read;
publishProgress(count * 1.0f / length);
}
Log.i(TAG, "count=" + count + " length=" + length);
byte[] data = baos.toByteArray();
if (isToDraw) {
File file = Utility.getNextFileName();
FileOutputStream fs = new FileOutputStream(file);
fs.write(data);
fs.close();
}
Bitmap bit = BitmapFactory.decodeByteArray(data, 0, data.length);
((BottleApplication)PhotoDetailActivity.this.getApplication()).getLruImageCache().put(params[0], bit);
return bit;
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (baos != null) {
baos.close();
}
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
/** 更新下载进度。在UI线程调用。onProgressUpdate */
protected void onProgressUpdate(Float... progress) {
// LogOut.out(this, "onProgressUpdate");
mZoomView.setProgress(progress[0]);
}
/** 通知下载任务完成。在UI线程调用。 */
protected void onPostExecute(Bitmap bit) {
Log.i(TAG, "onPostExecute");
mZoomView.setPorterDuffMode(false);
mZoomView.setLoading(false);
mZoomView.setImageBitmap(bit);
mZoomView.setImage(bit);
mZoomState = new ZoomState();
mZoomView.setZoomState(mZoomState);
mZoomListener = new SimpleZoomListener();
mZoomListener.setZoomState(mZoomState);
mZoomView.setOnTouchListener(mZoomListener);
ZoomControls zoomCtrl = (ZoomControls) findViewById(R.id.zoomCtrl);
zoomCtrl.setOnZoomInClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
float z = mZoomState.getZoom() + 0.25f;
mZoomState.setZoom(z);
mZoomState.notifyObservers();
}
});
zoomCtrl.setOnZoomOutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
float z = mZoomState.getZoom() - 0.25f;
mZoomState.setZoom(z);
mZoomState.notifyObservers();
}
});
resetZoomState();
if (isToDraw) {
Message msg = Message.obtain(handler);
msg.what = to_draw_pic ;
// msg.obj = AppContext.SD_PATH + "/download/"+mPicPath;
handler.sendMessage(msg);
}
}
protected void onCancelled() {
Log.i(TAG, "DownloadImgTask cancel...");
super.onCancelled();
}
private void printHttpResponse(HttpResponse httpResponse) {
Header[] headerArr = httpResponse.getAllHeaders();
for (int i = 0; i < headerArr.length; i++) {
Header header = headerArr[i];
Log.i(TAG, "name[" + header.getName() + "]value[" + header.getValue() + "]");
}
HttpParams params = httpResponse.getParams();
Log.i(TAG, String.valueOf(params));
Log.i(TAG, String.valueOf(httpResponse.getLocale()));
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case download_pic:
onToast("Download Finish!");
break;
case to_draw_pic:
File resultfile = Utility.getNextFileName();
Uri fileUri = Uri.fromFile(resultfile);
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.putExtra( "From_Type", Constants.ACTIVITY_DRAW );
newIntent.setData( fileUri );
newIntent.putExtra( "API_KEY", Utility.API_KEY );
newIntent.putExtra( "output", Uri.parse( "file://" + resultfile.getAbsolutePath() ) );
newIntent.putExtra( Constants.EXTRA_OUTPUT_FORMAT, Bitmap.CompressFormat.PNG.name() );
newIntent.putExtra( Constants.EXTRA_OUTPUT_QUALITY, 100 );
newIntent.putExtra( Constants.EXTRA_TOOLS_DISABLE_VIBRATION, true );
final DisplayMetrics metrics = new DisplayMetrics();
((Activity)this).getWindowManager().getDefaultDisplay().getMetrics( metrics );
int max_size = Math.min( metrics.widthPixels, metrics.heightPixels );
max_size = (int) ( (double) max_size / 0.8 );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
// mSessionId = StringUtils.getSha256( System.currentTimeMillis() + Utility.API_KEY );
// newIntent.putExtra( "output-hires-session-id", mSessionId );
startActivityForResult(newIntent, RESULT_DRAW_IMAGE);
overridePendingTransition(R.anim.translate_right_in, R.anim.translate_left_in);
break;
default:
break;
}
return false;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == RESULT_DRAW_IMAGE ) {
File file = Utility.getNextFileName();
updateMedia( file.getAbsolutePath() );
if (null != mPaintType) {
if (mPaintType.equals(AppContext.PAINT_BT)) {
Intent commentIntent = new Intent(this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.PAINT_BT);
commentBundle.putInt("bttype_id", btid);
commentBundle.putString("return_type", return_type);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
}else if (mPaintType.equals(AppContext.PAINT_PICEX)) {
Intent commentIntent = new Intent(this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.PAINT_PICEX);
commentBundle.putInt("ouid", ouid);
commentBundle.putInt("picid", picId);
commentBundle.putString("return_type", return_type);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
}else if (mPaintType.equals(AppContext.PAINT_PHOTO)) {
Intent commentIntent = new Intent(this,
ExpandEditActivity.class);
Bundle commentBundle = new Bundle();
commentBundle.putString("from_type",
AppContext.PAINT_PHOTO);
commentBundle.putInt("picid", picId);
commentIntent.putExtras(commentBundle);
startActivity(commentIntent);
}
}
}
}
finish();
}
private void updateMedia( String filepath ) {
MediaScannerConnection.scanFile( getApplicationContext(), new String[] { filepath }, null, null );
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.PlatformAccountTable;
import com.outsourcing.bottle.domain.LocationEntry;
import com.outsourcing.bottle.domain.PlatformAccount;
import com.outsourcing.bottle.domain.PlatformBindConfig;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.LocationUtil;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class BindLoginActivity extends BasicActivity implements BasicUIEvent, OnClickListener {
private final int login = 1;
private final int bind_success = 2;
private final int bind_error = 3;
private String platform;
private String openuid;
private PlatformAccount platformAccount;
private ImageView platformView;
private TextView nickNameTextView;
private TextView platformTextView;
private Button bindView;
private Button hasAccountView;
private EditText accountView;
private EditText passwordView;
private ImageView close;
private String username;
private String password;
private String deviceId;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.bind_login);
try {
platform = getIntent().getStringExtra("platform");
openuid = getIntent().getStringExtra("openuid");
PlatformAccountTable pat = new PlatformAccountTable();
platformAccount = pat.getPlatformAccount(PlatformBindConfig.getOpenType(platform), openuid);
initWidget();
TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
deviceId = tm.getDeviceId();
networkLocat();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initWidget() {
platformView = (ImageView) findViewById(R.id.bind_login_platform);
nickNameTextView = (TextView) findViewById(R.id.bind_login_nickname);
nickNameTextView.setText(getString(R.string.login_txt_hello) + "," + platformAccount.getNickName());
platformTextView = (TextView) findViewById(R.id.bind_login_platform_text);
if (platform.equals(PlatformBindConfig.Sina)) {
platformView.setBackgroundResource(R.drawable.ico_weibo);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_weibo));
} else if (platform.equals(PlatformBindConfig.Douban)) {
platformView.setBackgroundResource(R.drawable.ico_douban);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_douban));
} else if (platform.equals(PlatformBindConfig.Tencent)) {
platformView.setBackgroundResource(R.drawable.ico_tqq);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_tencent));
} else if (platform.equals(PlatformBindConfig.QQ)) {
platformView.setBackgroundResource(R.drawable.ico_qq);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_qq));
} else if (platform.equals(PlatformBindConfig.Renren)) {
platformView.setBackgroundResource(R.drawable.ico_renren);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_renren));
} else if (platform.equals(PlatformBindConfig.Twitter)) {
platformView.setBackgroundResource(R.drawable.ico_twitter);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_twitter));
} else {
platformView.setBackgroundResource(R.drawable.ico_facebook);
platformTextView.setText(getString(R.string.login_txt_bind_connect) + getString(R.string.login_txt_facebook));
}
bindView = (Button) findViewById(R.id.bind_login_bind);
bindView.setOnClickListener(this);
hasAccountView = (Button) findViewById(R.id.bind_login_bindaccount);
hasAccountView.setOnClickListener(this);
accountView = (EditText) findViewById(R.id.bind_login_account);
passwordView = (EditText) findViewById(R.id.bind_login_password);
passwordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
checkLogin();
}
return false;
}
});
close = (ImageView) findViewById(R.id.close);
close.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == bindView) {
checkLogin();
} else if (v == hasAccountView) {
Intent intent = new Intent(this, BindRegisterActivity.class);
intent.putExtra("platform", platform);
intent.putExtra("openuid", openuid);
startActivity(intent);
finish();
} else if (v == close) {
finish();
}
}
private void checkLogin() {
username = accountView.getText().toString().trim();
password = passwordView.getText().toString().trim();
if (username.equals("")) {
onToast(getString(R.string.login_txt_register_error_account));
return;
}
if (password.equals("")) {
onToast(getString(R.string.login_txt_reset_error));
return;
}
UICore.eventTask(this, this, login, getString(R.string.init_data), null);
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case login:
login();
break;
default:
break;
}
}
private void login() {
LocationUtil locationUtil = new LocationUtil(this);
LocationEntry entry = locationUtil.locate();
String url = UrlConfig.bind_login;
HashMap<String, String> paramMaps = new HashMap<String, String>();
paramMaps.put("username", username);
paramMaps.put("password", password);
paramMaps.put("open_type", String.valueOf(platformAccount.getOpenType()));
paramMaps.put("access_token", platformAccount.getAccessToken());
paramMaps.put("token_secret", platformAccount.getTokenSecret());
paramMaps.put("nickname", platformAccount.getNickName());
paramMaps.put("open_uid", platformAccount.getOpenUid());
paramMaps.put("open_sex", String.valueOf(platformAccount.getOpenSex()));
paramMaps.put("open_expire", platformAccount.getOpenExpire());
paramMaps.put("open_avatar", platformAccount.getOpenAvatar());
paramMaps.put("device_token", deviceId);
paramMaps.put("device_type", android.os.Build.MODEL);
paramMaps.put("device_provider", android.os.Build.HARDWARE);
paramMaps.put("device_version", android.os.Build.VERSION.RELEASE);
paramMaps.put("lat", String.valueOf(entry.getLatitude()));
paramMaps.put("lng", String.valueOf(entry.getLongitude()));
if (countryIso != null && countryIso.equalsIgnoreCase("cn")) {
paramMaps.put("location_mode", "1");
} else {
paramMaps.put("location_mode", "0");
}
try {
String result = HttpUtils.doPost(this, url, paramMaps);
if (result != null) {
JSONObject obj = new JSONObject(result);
JSONObject resultObj = obj.getJSONObject("results");
int login_uid = resultObj.getInt("login_uid");
if (login_uid != 0) {
String login_token = resultObj.getString("login_token");
AppContext.getInstance().setLogin_uid(login_uid);
AppContext.getInstance().setLogin_token(login_token);
SharedPreferences preferences = getSharedPreferences("Preferences_userinfo", Activity.MODE_APPEND);
Editor editor = preferences.edit();
editor.putInt("login_uid", login_uid);
editor.putString("login_token", login_token);
editor.commit();
handler.sendEmptyMessage(bind_success);
} else {
String errmsg = resultObj.getString("errmsg");
Message message = Message.obtain(handler, bind_error, errmsg);
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case bind_success:
Intent intent = new Intent(BindLoginActivity.this, HomeActivity.class);
startActivity(intent);
BindLoginActivity.this.finish();
break;
case bind_error:
onToast((String) msg.obj);
break;
default:
break;
}
}
};
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.HashMap;
import java.util.List;
import oauth.facebook.AsyncFacebookRunner;
import oauth.facebook.BaseRequestListener;
import oauth.facebook.DialogError;
import oauth.facebook.Facebook;
import oauth.facebook.Facebook.DialogListener;
import oauth.facebook.FacebookError;
import oauth.facebook.SessionEvents;
import oauth.facebook.SessionEvents.AuthListener;
import oauth.facebook.Util;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.OtherConfigTable;
import com.outsourcing.bottle.db.PlatformAccountTable;
import com.outsourcing.bottle.domain.FriendEntry;
import com.outsourcing.bottle.domain.InitFriendInfo;
import com.outsourcing.bottle.domain.LoginUserInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.OtherConfigEntry;
import com.outsourcing.bottle.domain.PlatformAccount;
import com.outsourcing.bottle.domain.PlatformBindConfig;
import com.outsourcing.bottle.domain.ResponseResult;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.oauth.OAuth;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.ElasticScrollView;
/**
*
* @author 06peng
*
*/
public class BindInviteActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private LoginUserInfoEntry entry;
private final int init_loginuser_info = 1;
private final int error = 2;
private final int invite_or_syncfriends = 3;
private final int cancel_bind = 5;
private final int cancel_bind_success = 6;
private final int do_success = 7;
private final int search_friend = 8;
private RelativeLayout twitterLayout;
private RelativeLayout facebookLayout;
private RelativeLayout weiboLayout;
private RelativeLayout tencentLayout;
private RelativeLayout renrenLayout;
private RelativeLayout doubanLayout;
private RelativeLayout qqLayout;
private ImageView backView;
private EditText searchEdit;
private ElasticScrollView elasticScrollView;
private View contentView;
private LinearLayout bodyLayout;
private List<FriendEntry> friendList;
private Handler handler;
private String platform;
private boolean isGoOAuth;
private OtherConfigEntry ocEntry;
public static final String CALLBACKURL = "app:authorize";
private final int oauth_tritter =28;
private final int oauth_facebook = 29;
private final int oauth_weibo = 30;
private final int oauth_tencent = 31;
private final int oauth_renren = 32;
private final int oauth_douban = 33;
private final int oauth_qq = 34;
private final int oauth_bind = 35;
private Facebook mFacebook;
private AsyncFacebookRunner mAsyncRunner;
private SessionListener mSessionListener = new SessionListener();
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.bind_invite);
handler = new Handler(this);
initWidget();
initBindUI();
OtherConfigTable ot = new OtherConfigTable();
ocEntry = ot.getBottleOtherConfig();
}
private void initWidget() {
elasticScrollView = (ElasticScrollView) findViewById(R.id.refresh_view);
contentView = LayoutInflater.from(this).inflate(R.layout.bind_invite_content, null);
elasticScrollView.addChild(contentView);
bodyLayout = (LinearLayout) contentView.findViewById(R.id.bind_invite_bodylayout);
twitterLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_twitter_layout);
twitterLayout.setOnClickListener(this);
facebookLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_facebook_layout);
facebookLayout.setOnClickListener(this);
weiboLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_weibo_layout);
weiboLayout.setOnClickListener(this);
tencentLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_tencent_layout);
tencentLayout.setOnClickListener(this);
renrenLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_renren_layout);
renrenLayout.setOnClickListener(this);
doubanLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_douban_layout);
doubanLayout.setOnClickListener(this);
qqLayout = (RelativeLayout) contentView.findViewById(R.id.bind_invite_qq_layout);
qqLayout.setOnClickListener(this);
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
searchEdit = (EditText) contentView.findViewById(R.id.bind_invite_search_edit);
searchEdit.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (!searchEdit.getText().toString().trim().equals("")) {
UICore.eventTask(BindInviteActivity.this, BindInviteActivity.this, search_friend, "", null);
}
return false;
}
});
}
private void initBindUI() {
if (entry == null) {
LoginUserInfoTable userTable = new LoginUserInfoTable();
entry = userTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
}
if (entry != null) {
if (entry.getTwitterok() == 1) {
((ImageView) findViewById(R.id.bind_invite_twitter_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_twitter_binded)).setVisibility(View.GONE);
}
if (entry.getFacebookok() == 1) {
((ImageView) findViewById(R.id.bind_invite_facebook_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_facebook_binded)).setVisibility(View.GONE);
}
if (entry.getSinaok() == 1) {
((ImageView) findViewById(R.id.bind_invite_weibo_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_weibo_binded)).setVisibility(View.GONE);
}
if (entry.getTqqok() == 1) {
((ImageView) findViewById(R.id.bind_invite_tencent_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_tencent_binded)).setVisibility(View.GONE);
}
if (entry.getRenrenok() == 1) {
((ImageView) findViewById(R.id.bind_invite_renren_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_renren_binded)).setVisibility(View.GONE);
}
if (entry.getDoubanok() == 1) {
((ImageView) findViewById(R.id.bind_invite_douban_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_douban_binded)).setVisibility(View.GONE);
}
if (entry.getQqok() == 1) {
((ImageView) findViewById(R.id.bind_invite_qq_binded)).setVisibility(View.VISIBLE);
} else {
((ImageView) findViewById(R.id.bind_invite_qq_binded)).setVisibility(View.GONE);
}
}
}
@Override
public void onClick(View v) {
if (v == twitterLayout) {
if (ocEntry.getTwitter_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getTwitterok() == 1) {
doChoseItemAction(getString(R.string.login_txt_twitter), 5);
} else {
UICore.eventTask(this, this, oauth_tritter, "", null);
}
} else if (v == facebookLayout) {
if (ocEntry.getFacebook_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getFacebookok() == 1) {
doChoseItemAction(getString(R.string.login_txt_facebook), 6);
} else {
isGoOAuth = true;
platform = PlatformBindConfig.Facebook;
mFacebook = new Facebook(PlatformBindConfig.Facebook_AppID);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
SessionEvents.addAuthListener(new SampleAuthListener());
SessionEvents.addAuthListener(mSessionListener);
mFacebook.authorize((BasicActivity) AppContext.getContext(), new String[] {}, new LoginDialogListener());
}
} else if (v == weiboLayout) {
if (ocEntry.getWeibo_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getSinaok() == 1) {
doChoseItemAction(getString(R.string.login_txt_weibo), 1);
} else {
UICore.eventTask(this, this, oauth_weibo, "", null);
}
} else if (v == tencentLayout) {
if (ocEntry.getTencent_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getTqqok() == 1) {
doChoseItemAction(getString(R.string.login_txt_tencent), 2);
} else {
UICore.eventTask(this, this, oauth_tencent, "", null);
}
} else if (v == renrenLayout) {
if (ocEntry.getRenren_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getRenrenok() == 1) {
doChoseItemAction(getString(R.string.login_txt_renren), 3);
} else {
UICore.eventTask(this, this, oauth_renren, "", null);
}
} else if (v == doubanLayout) {
if (ocEntry.getDouban_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getDoubanok() == 1) {
doChoseItemAction(getString(R.string.login_txt_douban), 4);
} else {
UICore.eventTask(this, this, oauth_douban, "", null);
}
} else if (v == qqLayout) {
if (ocEntry.getQq_enable() == 0) {
onToast(getString(R.string.platform_error));
return;
}
if (entry.getQqok() == 1) {
doChoseItemAction(getString(R.string.login_txt_qq), 0);
} else {
UICore.eventTask(this, this, oauth_qq, "", null);
}
} else if (v == backView) {
finish();
}
}
private void getLoginUserInfo() {
StringBuffer url = new StringBuffer(UrlConfig.get_loginuser_info);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result == null) {
return;
}
Gson gson = new Gson();
LoginUserInfo loginUserInfo = gson.fromJson(result, LoginUserInfo.class);
LoginUserInfoTable loginUserInfoTable = new LoginUserInfoTable();
if (null != loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid())) {
loginUserInfoTable.deleteLoginUserInfoById(AppContext.getInstance().getLogin_uid());
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
} else {
loginUserInfoTable.saveLoginUserInfo(loginUserInfo
.getLoginuser_info(), AppContext.getInstance().getLogin_uid());
}
entry = loginUserInfoTable.getLoginUserInfo(AppContext.getInstance().getLogin_uid());
handler.sendEmptyMessage(init_loginuser_info);
} catch (Exception e) {
e.printStackTrace();
}
}
private void syncFirendsOrBind(String url, String openType) {
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("open_type", openType);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, do_success, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void cancelBind(String openType) {
String url = UrlConfig.open_unbind;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("open_type", openType);
try {
String result = HttpUtils.doPost(this, url, paramsMap);
if (result != null) {
JSONObject object = new JSONObject(result);
JSONObject resultObj = object.getJSONObject("results");
int success = resultObj.getInt("success");
if (success == 0) {
String errmsg = resultObj.getString("errmsg");
Message msg = Message.obtain(handler, error, errmsg);
handler.sendMessage(msg);
} else {
String successmsg = resultObj.getString("successmsg");
Message msg = Message.obtain(handler, cancel_bind_success, successmsg);
handler.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void search() {
StringBuffer url = new StringBuffer(UrlConfig.search_users_list);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&keyword=" + searchEdit.getText().toString().trim());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
InitFriendInfo info = gson.fromJson(result, InitFriendInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
friendList = info.getUsers_list();
}
handler.sendEmptyMessage(search_friend);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_loginuser_info:
initBindUI();
break;
case error:
onToast((String) msg.obj);
break;
case do_success:
onToast((String) msg.obj);
break;
case cancel_bind_success:
onToast((String) msg.obj);
UICore.eventTask(this, this, init_loginuser_info, "get_logininfo", null);
break;
case oauth_facebook:
PlatformAccount account = (PlatformAccount) msg.obj;
UICore.eventTask(BindInviteActivity.this, BindInviteActivity.this, oauth_facebook, "", account);
break;
case oauth_bind:
UICore.eventTask(this, this, init_loginuser_info, "get_logininfo", null);
break;
case search_friend:
bodyLayout.removeAllViews();
if (friendList != null && !friendList.isEmpty()) {
for (FriendEntry entry : friendList) {
FriendView view = new FriendView(this, entry);
bodyLayout.addView(view);
}
}
break;
default:
break;
}
return false;
}
@Override
protected void onResume() {
super.onResume();
if (isGoOAuth) {
AppContext.getInstance().setOAUTH_TYPE(-1);
isGoOAuth = false;
UICore.eventTask(this, this, init_loginuser_info, "get_logininfo", null);
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_loginuser_info:
getLoginUserInfo();
break;
case invite_or_syncfriends:
String[] params = (String[]) obj;
syncFirendsOrBind(params[0], params[1]);
break;
case cancel_bind:
cancelBind((String)obj);
break;
case oauth_douban:
isGoOAuth = true;
platform = PlatformBindConfig.Douban;
OAuth oauth = new OAuth(this, handler, platform, PlatformBindConfig.Douban_AppKey,
PlatformBindConfig.Douban_AppSecret);
oauth.requestAccessToken(CALLBACKURL, PlatformBindConfig.Douban_Request_Token,
PlatformBindConfig.Douban_Access_Token, PlatformBindConfig.Douban_Authorize);
break;
case oauth_facebook:
PlatformAccount account = (PlatformAccount) obj;
checkBind(account);
break;
case oauth_qq:
isGoOAuth = true;
platform = PlatformBindConfig.QQ;
OAuth oauth2 = new OAuth(this, handler, platform);
oauth2.requestAccessTokenForOAuth2(PlatformBindConfig.QQ_Authorize);
break;
case oauth_renren:
platform = PlatformBindConfig.Renren;
OAuth oauth3 = new OAuth(this, handler, platform);
oauth3.requestAccessTokenForOAuth2(PlatformBindConfig.Renren_Authorize);
break;
case oauth_tencent:
isGoOAuth = true;
platform = PlatformBindConfig.Tencent;
OAuth oauth4 = new OAuth(this, handler, platform);
oauth4.requestAccessTokenForOAuth2(PlatformBindConfig.Tencent_Authorize_2);
break;
case oauth_tritter:
isGoOAuth = true;
platform = PlatformBindConfig.Twitter;
OAuth oauth5 = new OAuth(this, handler, PlatformBindConfig.Twitter,
PlatformBindConfig.Twitter_ConsumerKey, PlatformBindConfig.Twitter_ConsumerSecret);
oauth5.requestAcccessTokenForTwitter();
break;
case oauth_weibo:
isGoOAuth = true;
platform = PlatformBindConfig.Sina;
OAuth oauth6 = new OAuth(this, handler, platform);
oauth6.requestAccessTokenForOAuth2(PlatformBindConfig.Sina_Authorize2);
break;
case search_friend:
search();
break;
default:
break;
}
}
private void doChoseItemAction(String bind, final int openType) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
String cancel = getString(R.string.bt_title_back);
String[] choices;
choices = new String[3];
choices[0] = getString(R.string.bind_invate_send_invate);
choices[1] = getString(R.string.bind_invate_sync_friends);
String cancelBind = null;
if (AppContext.language == 1) {
cancelBind = bind + "绑定";
} else {
cancelBind = bind;
}
choices[2] = getString(R.string.bind_invate_cancel_bind) + cancelBind;
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
switch (which) {
case 0:
String[] params = new String[]{ UrlConfig.open_invite, String.valueOf(openType) };
UICore.eventTask(BindInviteActivity.this, BindInviteActivity.this, invite_or_syncfriends, "open_invite", params);
break;
case 1:
String[] params2 = new String[]{ UrlConfig.open_syncfriends, String.valueOf(openType) };
UICore.eventTask(BindInviteActivity.this, BindInviteActivity.this, invite_or_syncfriends, "syncfriends", params2);
break;
case 2:
UICore.eventTask(BindInviteActivity.this, BindInviteActivity.this, cancel_bind, "cancel_bind", String.valueOf(openType));
break;
}
}
});
builder.setNegativeButton(cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (OAuth.reciver != null) {
unregisterReceiver(OAuth.reciver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class SampleAuthListener implements AuthListener {
public void onAuthSucceed() {
System.out.println("You have logged in! ");
}
public void onAuthFail(String error) {
System.out.println("Login Failed: " + error);
}
}
public class SampleRequestListener extends BaseRequestListener {
public void onComplete(final String response, final Object state) {
try {
PlatformAccount account = new PlatformAccount();
Log.d("Facebook-Example", "Response: " + response.toString());
JSONObject json = Util.parseJson(response);
account.setAccessToken(mFacebook.getAccessToken());
if (json.has("name")) {
account.setNickName(json.getString("name"));
}
account.setOpenAvatar("https://graph.facebook.com/"+json.getString("id")+"/picture?type=large");
account.setOpenExpire(String.valueOf(mFacebook.getAccessExpires()));
account.setOpenType(6);
account.setOpenUid(json.getString("id"));
PlatformAccountTable paTable = new PlatformAccountTable();
paTable.save(account);
if (account.getOpenUid() != null && !account.getOpenUid().equals("")) {
Message msg = Message.obtain(handler, oauth_facebook, account);
handler.sendMessage(msg);
}
} catch (JSONException e) {
Log.w("Facebook-Example", "JSON Error in response");
} catch (FacebookError e) {
Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
}
}
}
private final class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
SessionEvents.onLoginSuccess();
}
public void onFacebookError(FacebookError error) {
SessionEvents.onLoginError(error.getMessage());
}
public void onError(DialogError error) {
SessionEvents.onLoginError(error.getMessage());
}
public void onCancel() {
SessionEvents.onLoginError("Action Canceled");
}
}
private class SessionListener implements AuthListener {
public void onAuthSucceed() {
mAsyncRunner.request("me", new SampleRequestListener());
}
public void onAuthFail(String error) {
}
}
private void checkBind(PlatformAccount account) {
String url = UrlConfig.check_bind;
HashMap<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("login_uid", String.valueOf(AppContext.getInstance().getLogin_uid()));
paramsMap.put("login_token", AppContext.getInstance().getLogin_token());
paramsMap.put("open_type", String.valueOf(account.getOpenType()));
paramsMap.put("access_token", account.getAccessToken());
paramsMap.put("token_secret", account.getTokenSecret());
paramsMap.put("nickname", account.getNickName());
paramsMap.put("open_uid", account.getOpenUid());
paramsMap.put("open_sex", String.valueOf(account.getOpenSex()));
paramsMap.put("open_expire", account.getOpenExpire());
paramsMap.put("open_avatar", account.getOpenAvatar());
paramsMap.put("device_token", AppContext.getInstance().getDeviceId());
try {
String result = HttpUtils.doPost(this, url, paramsMap);
JSONObject object = new JSONObject(result);
if (object.has("results")) {
final JSONObject resultObj = object.getJSONObject("results");
System.out.println(resultObj);
int isbind = resultObj.getInt("isbind");
if (AppContext.getInstance().getLogin_uid() != 0 && AppContext.getInstance().getLogin_token() != null) {
if (isbind == 1) {
if (account.getOpenType() > 0) {
AppContext.getInstance().setOAUTH_TYPE(account.getOpenType());
handler.sendEmptyMessage(oauth_bind);
} else {
AppContext.getInstance().setOAUTH_TYPE(-1);
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public class FriendView extends LinearLayout {
private View convertView;
private FriendEntry entry;
public FriendView(Context context, FriendEntry entry) {
super(context);
this.entry = entry;
initWidget();
setOrientation(LinearLayout.VERTICAL);
addView(convertView);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.topMargin = 5;
ImageView image = new ImageView(context);
image.setBackgroundResource(R.drawable.line_gray);
addView(image);
}
public FriendView(Context context, AttributeSet attrs) {
super(context, attrs);
}
private void initWidget() {
try {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.user_space_header, null);
RemoteImageView avatarView = (RemoteImageView) convertView.findViewById(R.id.user_space_avatar);
TextView nicknameView = (TextView) convertView.findViewById(R.id.user_space_nickname);
TextView memoView = (TextView) convertView.findViewById(R.id.user_space_memo);
ImageView sexView = (ImageView) convertView.findViewById(R.id.user_space_sex);
TextView doingView = (TextView) convertView.findViewById(R.id.user_space_doing);
TextView addressView = (TextView) convertView.findViewById(R.id.user_space_address);
nicknameView.setText(entry.getNickname());
if (entry.getSex() == 1) {
sexView.setBackgroundResource(R.drawable.male);
} else if (entry.getSex() == 2) {
sexView.setBackgroundResource(R.drawable.female);
}
if (TextUtil.notEmpty(entry.getMemo())) {
((TextView) convertView.findViewById(R.id.user_space_memo)).setVisibility(View.VISIBLE);
memoView.setText("-" + entry.getMemo());
} else {
((TextView) convertView.findViewById(R.id.user_space_memo)).setVisibility(View.GONE);
memoView.setVisibility(View.GONE);
}
if (TextUtil.notEmpty(entry.getCity()) && TextUtil.notEmpty(entry.getCountry())) {
addressView.setVisibility(View.VISIBLE);
if (AppContext.language == 1) {
addressView.setText(getString(R.string.user_from) + entry.getCountry() + " " + entry.getCity());
} else {
addressView.setText(getString(R.string.user_from) + entry.getCity() + " " + entry.getCountry());
}
} else {
addressView.setVisibility(View.GONE);
}
String html = "<font color=black>"+getString(R.string.user_info_doing)+"</font>";
doingView.setText(Html.fromHtml(html + entry.getDoing()));
avatarView.setDefaultImage(R.drawable.avatar_default_big);
avatarView.setImagePath(entry.getAvatar());
avatarView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(BindInviteActivity.this, UserSpaceActivity.class);
intent.putExtra("ouid", entry.getUid());
startActivity(intent);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.List;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.CareerEntry;
import com.outsourcing.bottle.domain.CareerInfo;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.BasicUIEvent;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.UICore;
/**
*
* @author 06peng
*
*/
public class SelectCareerActivity extends BasicActivity implements BasicUIEvent, Callback, OnClickListener {
private final int init_career_list = 1;
private final int error = 2;
private Handler handler;
private ImageView backView;
private ExpandableListView listView;
private List<CareerEntry> careerList;
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.select_career);
handler = new Handler(this);
initWidget();
UICore.eventTask(this, this, init_career_list, "init_career_list", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
listView = (ExpandableListView) findViewById(R.id.select_career_expand_list);
listView.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Intent intent = new Intent(SelectCareerActivity.this, SettingBasicActivity.class);
intent.putExtra("career_class", careerList.get(groupPosition).getCareer_class());
intent.putExtra("career_subclass", careerList.get(groupPosition).getSubcareers_list().get(childPosition).getCareer_subclass());
intent.putExtra("career_classid", careerList.get(groupPosition).getCareer_classid());
intent.putExtra("career_subclassid", careerList.get(groupPosition).getSubcareers_list().get(childPosition).getCareer_subclassid());
setResult(getIntent().getIntExtra("resultCode", 0), intent);
finish();
return false;
}
});
}
private void initCareers() {
StringBuffer url = new StringBuffer(UrlConfig.get_careers_list);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
CareerInfo info = gson.fromJson(result, CareerInfo.class);
if (info.getResults().getAuthok() == 0) {
Message msg = Message.obtain(handler, error, info.getResults().getErrmsg());
handler.sendMessage(msg);
} else {
careerList = info.getCareers_list();
handler.sendEmptyMessage(init_career_list);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case init_career_list:
initCareers();
break;
default:
break;
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case init_career_list:
CareerAdapter adapter = new CareerAdapter();
listView.setAdapter(adapter);
break;
case error:
onToast((String) msg.obj);
break;
default:
break;
}
return false;
}
public class CareerAdapter extends BaseExpandableListAdapter {
@Override
public Object getChild(int groupPosition, int childPosition) {
return careerList == null ? null : careerList.get(groupPosition)
.getSubcareers_list().get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.simple_listitem2, null);
}
TextView name = (TextView) convertView.findViewById(R.id.simple_listitem_name);
name.setText(careerList.get(groupPosition).getSubcareers_list().get(childPosition).getCareer_subclass());
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return careerList == null ? 0 : careerList.get(groupPosition).getSubcareers_list().size();
}
@Override
public Object getGroup(int groupPosition) {
return careerList == null ? null : careerList.get(groupPosition);
}
@Override
public int getGroupCount() {
return careerList == null ? 0 : careerList.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.simple_listitem2, null);
}
TextView name = (TextView) convertView.findViewById(R.id.simple_listitem_name);
name.setText(careerList.get(groupPosition).getCareer_class());
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
}
| Java |
package com.outsourcing.bottle.ui;
import java.util.ArrayList;
import java.util.List;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.text.Html;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ext.SatelliteMenu;
import android.view.ext.SatelliteMenu.SateliteClickedListener;
import android.view.ext.SatelliteMenuItem;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
import com.outsourcing.bottle.db.LoginUserInfoTable;
import com.outsourcing.bottle.db.PushNoticeInfoTable;
import com.outsourcing.bottle.domain.FriendFeedEntry;
import com.outsourcing.bottle.domain.FriendFeedInfo;
import com.outsourcing.bottle.domain.LoginUserInfoEntry;
import com.outsourcing.bottle.domain.PushNoticeInfo;
import com.outsourcing.bottle.domain.ResponseResult;
import com.outsourcing.bottle.domain.UrlConfig;
import com.outsourcing.bottle.remoteimage.RemoteImageView;
import com.outsourcing.bottle.util.AppContext;
import com.outsourcing.bottle.util.HttpUtils;
import com.outsourcing.bottle.util.ImageLoader;
import com.outsourcing.bottle.util.ServiceUtils;
import com.outsourcing.bottle.util.TextUtil;
import com.outsourcing.bottle.util.UICore;
import com.outsourcing.bottle.widget.CustomListView;
/**
*
* @author 06peng
*
*/
public class FriendFeedActivity extends BasicActivity implements
OnClickListener, Callback, OnScrollListener {
private static final int INIT_FRIEND_FEED = 0;
private static final int GET_MORE_DATA = 1;
private static final int ERROR = 2;
private static final String TAG = FriendFeedActivity.class.getSimpleName();
private static final int EXEU_GET_FRIEND_NOTHING = 3;
private final int user_baseinfo_notfull = 4;
private final int complete_info = 5;
private ImageView backView;
private ImageView addView;
private TextView titleView;
private CustomListView refreshView;
private final int menu_uploadphoto = 15;
private final int menu_exprofile = 14;
private final int menu_exphoto = 13;
private final int menu_gainbt = 12;
private final int menu_sendbt = 11;
private ImageLoader imageLoader;
private Handler handler;
private int page = 1;
private List<FriendFeedEntry> friendFeedList;
private FriendFeedAdapter friendAdapter = null;
private int visibleLastIndex = 0; // 最后的可视项索引
public int visibleItemCount; // 当前窗口可见项总数
private View loadMoreView;
// private ImageView messageView;
private LinearLayout bottomLayout;
private ImageView avatarView;
private TextView contentView;
private TextView btnCount;
private int newNoticeCount;
private int newMessageCount;
private int newBottleFeedCount;
private int newExchangeFeedCount;
private int newMaybeKownCount;
private String message_content;
private String message_avatar;
private ImageLoader userImageLoader;
private PushBroadcastReceiver receiver;
private PushNoticeInfo pushInfo;
private String choices[];
@Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.friend_feeds_layout);
handler = new Handler(this);
imageLoader = new ImageLoader(this, AppContext.BottleTimelineIcon);
userImageLoader = new ImageLoader(this, AppContext.UserAvatarIcon);
initWidget();
initSateMenu();
UICore.eventTask(this, this, INIT_FRIEND_FEED, "", null);
}
private void initWidget() {
backView = (ImageView) findViewById(R.id.topbar_back);
backView.setOnClickListener(this);
addView = (ImageView) findViewById(R.id.topbar_menu);
addView.setOnClickListener(this);
titleView = (TextView) findViewById(R.id.topbar_title);
titleView.setVisibility(View.VISIBLE);
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
refreshView = (CustomListView) findViewById(R.id.list_view);
refreshView.setonRefreshListener(new CustomListView.OnRefreshListener() {
@Override
public void onRefresh() {
page = 1;
UICore.eventTask(FriendFeedActivity.this, FriendFeedActivity.this, INIT_FRIEND_FEED, null, null);
}
});
loadMoreView = LayoutInflater.from(this).inflate(R.layout.refreshable_list_footer, null);
loadMoreView.setVisibility(View.GONE);
refreshView.addFooterView(loadMoreView);
refreshView.setOnScrollListener(this);
refreshView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
if (arg2 == friendAdapter.getCount() + 1) {
return;
}
choices = null;
final FriendFeedEntry entry = friendFeedList.get(arg2 - 1);
if (entry.getFeed_picid() != 0) {
if (entry.getFeed_picid() != 0 && entry.getFeed_related_uid() != 0) {
choices = new String[2];
choices[0] = getString(R.string.user_space_bottle_view_photo);
choices[1] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
} else if (entry.getFeed_picid() != 0) {
choices = new String[1];
choices[0] = getString(R.string.user_space_bottle_view_photo);
chooseAction(choices, entry);
} else if (entry.getFeed_related_uid() != 0) {
if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
choices = new String[1];
choices[0] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
}
}
} else {
if (entry.getFeed_related_uid() != 0) {
if (TextUtil.notEmpty(entry.getFeed_related_nickname())) {
choices = new String[1];
choices[0] = getString(R.string.user_info_view) + entry.getFeed_related_nickname() + getString(R.string.user_info_space);
chooseAction(choices, entry);
}
}
}
}
});
bottomLayout = (LinearLayout) findViewById(R.id.notice_bottom_layout);
bottomLayout.setOnClickListener(this);
avatarView = (ImageView) findViewById(R.id.notice_avatar);
contentView = (TextView) findViewById(R.id.notice_text);
btnCount = (TextView) findViewById(R.id.notice_number);
// messageView = (ImageView) findViewById(R.id.notice_message_count);
// messageView.setOnClickListener(this);
// messageView.setVisibility(View.VISIBLE);
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case INIT_FRIEND_FEED:
friendAdapter = new FriendFeedAdapter();
refreshView.setAdapter(friendAdapter);
pushNoticeUpdateUI();
receiver = new PushBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("push");
registerReceiver(receiver, filter);
break;
case ERROR:
onToast((String) msg.obj);
break;
case GET_MORE_DATA:
friendAdapter.notifyDataSetChanged();
// refreshView.onRefreshComplete();
break;
case user_baseinfo_notfull:
showChoseMes(getString(R.string.exchange_complete_profile_tips),
complete_info);
break;
case EXEU_GET_FRIEND_NOTHING:
loadMoreView.setVisibility(View.GONE);
break;
default:
break;
}
return false;
}
@Override
public void onClick(View v) {
if (v == backView) {
finish();
} else if (v == addView) {
// Intent intent = new Intent(this, MoreActivity.class);
// startActivity(intent);
Intent intent = new Intent(FriendFeedActivity.this, HomeActivity.class);
intent.putExtra("currentItem", 1);
startActivity(intent);
finish();
}
// else if (v == messageView) {
// doMessageAction();
// }
else if (v == bottomLayout) {
doFeedsAction();
}
}
@Override
public void execute(int mes, Object obj) {
switch (mes) {
case INIT_FRIEND_FEED:
getFriendFeeds(page);
break;
case GET_MORE_DATA:
getMoreFriendFeeds(page);
break;
default:
break;
}
}
private void getFriendFeeds(int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_my_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&count=" + 20);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
FriendFeedInfo info = gson.fromJson(result, FriendFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
friendFeedList = info.getFeeds_list();
PushNoticeInfoTable table = new PushNoticeInfoTable();
pushInfo = table.getPushNoticeInfo(AppContext.getInstance().getLogin_uid());
if (null!=pushInfo) {
newBottleFeedCount = pushInfo.getNew_btfeed_count();
newExchangeFeedCount = pushInfo.getNew_exfeed_count();
newMessageCount = pushInfo.getNew_message_count();
newNoticeCount = pushInfo.getNew_notice_count();
message_content = pushInfo.getMessage_content();
message_avatar = pushInfo.getMessage_avatar();
newMaybeKownCount = pushInfo.getNew_maybeknow_count();
}
Message message = Message.obtain(handler);
message.what = INIT_FRIEND_FEED;
handler.sendMessage(message);
} else {
Message message = handler.obtainMessage(ERROR, info.getResults().getErrmsg());
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getMoreFriendFeeds(int page) {
StringBuffer url = new StringBuffer(UrlConfig.get_my_feedslist);
url.append("?clitype=2");
url.append("&language=" + AppContext.language);
url.append("&login_uid=" + AppContext.getInstance().getLogin_uid());
url.append("&login_token=" + AppContext.getInstance().getLogin_token());
url.append("&count=" + 20);
url.append("&page=" + page);
try {
String result = HttpUtils.doGet(url.toString());
if (result != null) {
Gson gson = new Gson();
FriendFeedInfo info = gson.fromJson(result, FriendFeedInfo.class);
ResponseResult res = info.getResults();
if (res.getAuthok() == 1) {
List<FriendFeedEntry> moreFriendFeedList = info.getFeeds_list();
if (moreFriendFeedList != null && !moreFriendFeedList.isEmpty()) {
friendFeedList.addAll(moreFriendFeedList);
handler.sendEmptyMessage(GET_MORE_DATA);
} else {
Message message = handler.obtainMessage(EXEU_GET_FRIEND_NOTHING);
handler.sendMessage(message);
}
} else {
Message message = handler.obtainMessage(ERROR, info.getResults().getErrmsg());
handler.sendMessage(message);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
class ViewHolder {
RemoteImageView avatar;
TextView content;
TextView timeView;
ImageView image;
int flag = -1;
}
ViewHolder holder = null;
public class FriendFeedAdapter extends BaseAdapter {
// private String choices[];
@Override
public int getCount() {
return friendFeedList == null ? 0 : friendFeedList.size();
}
@Override
public Object getItem(int position) {
return friendFeedList == null ? null : friendFeedList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null
|| ((ViewHolder) convertView.getTag()).flag != position) {
holder = new ViewHolder();
holder.flag = position;
convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.friend_feed, null);
holder.content = (TextView) convertView.findViewById(R.id.feed_content);
holder.timeView = (TextView) convertView.findViewById(R.id.feed_time);
holder.avatar = (RemoteImageView) convertView.findViewById(R.id.avatar);
holder.image = (ImageView) convertView.findViewById(R.id.feed_image);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final FriendFeedEntry entry = friendFeedList.get(position);
if (entry != null) {
ServiceUtils.dout(TAG + " entry.getFeed_avatar():" + entry.getFeed_avatar());
holder.avatar.setDefaultImage(R.drawable.avatar_default_big);
holder.avatar.setImageUrl(entry.getFeed_avatar());
String nickname = "<font color=#419AD9>" + entry.getFeed_nickname() + "</font>";
holder.content.setText(Html.fromHtml(nickname + " " + (entry.getIsnew() == 1 ? "<font color=red>" + TextUtil.htmlEncode(entry.getFeed_content()) + "</font>" : TextUtil.htmlEncode(entry.getFeed_content()))));
holder.timeView.setText(entry.getFeed_time());
if (TextUtil.notEmpty(entry.getFeed_smallpic())) {
imageLoader.DisplayImage(entry.getFeed_smallpic(), holder.image, R.drawable.album_nophoto);
holder.image.setVisibility(View.VISIBLE);
((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.VISIBLE);
} else {
((RelativeLayout) convertView.findViewById(R.id.rl_bottle_content_photo)).setVisibility(View.GONE);
}
holder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent spaceIntent = new Intent(FriendFeedActivity.this, UserSpaceActivity.class);
spaceIntent.putExtra("ouid", entry.getFeed_uid());
startActivity(spaceIntent);
}
});
}
return convertView;
}
}
private void initSateMenu() {
SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu);
menu.setVisibility(View.VISIBLE);
if (CanvasWidth >= 480) {
menu.setSatelliteDistance(200);
} else {
menu.setSatelliteDistance(100);
}
List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
items.add(new SatelliteMenuItem(menu_exprofile, R.drawable.menu_exprofile));
items.add(new SatelliteMenuItem(menu_exphoto, R.drawable.menu_exphoto));
items.add(new SatelliteMenuItem(menu_gainbt, R.drawable.menu_gainbt));
items.add(new SatelliteMenuItem(menu_sendbt, R.drawable.menu_sendbt));
items.add(new SatelliteMenuItem(menu_uploadphoto, R.drawable.menu_uploadphoto));
menu.addItems(items);
menu.setOnItemClickedListener(new SateliteClickedListener() {
public void eventOccured(int id) {
switch (id) {
case menu_sendbt: // 扔瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent throwIntent = new Intent(
FriendFeedActivity.this,
ChooseBottleActivity.class);
throwIntent.putExtra("type", "throw");
startActivity(throwIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_gainbt: // 捞瓶子
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent tryIntent = new Intent(
FriendFeedActivity.this,
ChooseBottleActivity.class);
tryIntent.putExtra("type", "try");
startActivity(tryIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exphoto: // 交换照片
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent exchangeInfoIntent = new Intent(
FriendFeedActivity.this,
ChooseFriendActivity.class);
exchangeInfoIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_PHOTO_TYPE);
startActivity(exchangeInfoIntent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_exprofile: // 交换资料
new Thread() {
public void run() {
try {
Thread.sleep(500);
LoginUserInfoTable userTable = new LoginUserInfoTable();
LoginUserInfoEntry userEntry = userTable
.getLoginUserInfo(AppContext
.getInstance().getLogin_uid());
if (userEntry.getBasicinfo_fullfill() == 0) {
handler.sendEmptyMessage(user_baseinfo_notfull);
} else {
Intent exchangeFileIntent = new Intent(
FriendFeedActivity.this,
ChooseFriendActivity.class);
exchangeFileIntent
.putExtra(
"choose_friend_type",
AppContext.CHOOSE_FRIEND_EXCHANGE_INFO_TYPE);
startActivity(exchangeFileIntent);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
case menu_uploadphoto:
new Thread() {
public void run() {
try {
Thread.sleep(500);
Intent intent = new Intent(FriendFeedActivity.this, ExpandEditActivity.class);
Bundle extras = new Bundle();
extras.putString("from_type", AppContext.UPLOAD_PHOTO);
extras.putInt("albumid", 0);
extras.putInt("ouid", AppContext.getInstance().getLogin_uid());
intent.putExtras(extras);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
break;
default:
break;
}
}
});
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
refreshView.setFirstVisiableItem(firstVisibleItem);
this.visibleItemCount = visibleItemCount;
visibleLastIndex = firstVisibleItem + visibleItemCount;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
int itemsLastIndex = friendAdapter.getCount() + 1; // 数据集最后一项的索引
int lastIndex = itemsLastIndex + 1; // 加上底部的loadMoreView项 和 head项
ServiceUtils.dout(TAG + " visibleLastIndex:" + visibleLastIndex);
ServiceUtils.dout(TAG + " lastIndex:" + lastIndex);
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE
&& visibleLastIndex == lastIndex) {
// 如果是自动加载,可以在这里放置异步加载数据的代码
loadMoreView.setVisibility(View.VISIBLE);
page++;
UICore.eventTask(FriendFeedActivity.this, FriendFeedActivity.this, GET_MORE_DATA, null, null);
}
}
public void doMessageAction() {
final Context dialogContext = new ContextThemeWrapper(this,
android.R.style.Theme_Light);
String[] choices = new String[2];
if (newNoticeCount > 0) {
choices[0] = newNoticeCount + getString(R.string.bottle_txt_notice_list);
} else {
choices[0] = getString(R.string.bottle_txt_notice_list);
}
if (newMessageCount > 0) {
choices[1] = newMessageCount + getString(R.string.bottle_txt_message_list);
} else {
choices[1] = getString(R.string.bottle_txt_message_list);
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == 0) {
Intent intent = new Intent(FriendFeedActivity.this, NoticeListActivity.class);
startActivity(intent);
} else {
Intent intent = new Intent(FriendFeedActivity.this, MessageListActivity.class);
startActivity(intent);
}
}
});
builder.create().show();
}
public void doFeedsAction() {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final List<String> choices = new ArrayList<String>();
if (newBottleFeedCount > 0) {
choices.add(newBottleFeedCount + getString(R.string.bottle_txt_new_bottle_feed));
}
if (newExchangeFeedCount > 0) {
choices.add(newExchangeFeedCount + getString(R.string.bottle_txt_new_exchange_feed));
}
if (newNoticeCount > 0) {
choices.add(newNoticeCount + getString(R.string.bottle_txt_notice_list));
}
if (newMessageCount > 0) {
choices.add(newMessageCount + getString(R.string.bottle_txt_message_list));
}
if (newMaybeKownCount > 0) {
choices.add(newMaybeKownCount + getString(R.string.bottle_txt_new_maybe_kown));
}
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_bottle_feed)) != -1) {
Intent intent = new Intent(FriendFeedActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(1);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_exchange_feed)) != -1) {
Intent intent = new Intent(FriendFeedActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(0);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_notice_list)) != -1) {
Intent intent = new Intent(FriendFeedActivity.this, NoticeListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_message_list)) != -1) {
Intent intent = new Intent(FriendFeedActivity.this, MessageListActivity.class);
startActivity(intent);
} else if (choices.get(which).indexOf(getString(R.string.bottle_txt_new_maybe_kown)) != -1) {
Intent intent = new Intent(FriendFeedActivity.this, HomeActivity.class);
AppContext.getInstance().setCurrentItem(2);
AppContext.getInstance().setGotoMaybeKown(true);
startActivity(intent);
}
}
});
builder.create().show();
}
public void pushNoticeUpdateUI() {
if (newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount > 0) {
bottomLayout.setVisibility(View.VISIBLE);
contentView.setText(message_content);
btnCount.setText(newBottleFeedCount + newExchangeFeedCount + newMessageCount + newNoticeCount + newMaybeKownCount + "");
userImageLoader.DisplayImage(message_avatar, avatarView, R.drawable.avatar_default_big);
} else {
bottomLayout.setVisibility(View.GONE);
}
}
public class PushBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
newBottleFeedCount = bundle.getInt("bottle_feed_count");
newExchangeFeedCount = bundle.getInt("exchange_feed_count");
newMessageCount = bundle.getInt("message_count");
newNoticeCount = bundle.getInt("notice_count");
message_content = bundle.getString("message_content");
message_avatar = bundle.getString("message_avatar");
newMaybeKownCount = bundle.getInt("maybe_kown_count");
pushNoticeUpdateUI();
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (receiver != null) {
unregisterReceiver(receiver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 选择菜单 弹出框
* @param choices 显示的菜单
*/
public void chooseAction(final String[] choices, final FriendFeedEntry feedEntry) {
final Context dialogContext = new ContextThemeWrapper(this, android.R.style.Theme_Light);
final ListAdapter adapter = new ArrayAdapter<String>(dialogContext,
android.R.layout.simple_list_item_1, choices);
final AlertDialog.Builder builder = new AlertDialog.Builder(
dialogContext);
builder.setTitle(R.string.system_info);
builder.setSingleChoiceItems(adapter, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doSelectChooseEvent(which, choices, feedEntry);
}
});
builder.create().show();
}
public void doSelectChooseEvent(int which, String choics[], FriendFeedEntry feedEntry) {
if (feedEntry == null) {
return;
} else {
if (choics.length == 2) {
if (which == 0) {
Intent intent = new Intent(this, UserPhotoActivity.class);
intent.putExtra("picid", feedEntry.getFeed_picid());
startActivity(intent);
} else {
Intent intent = new Intent(this, UserSpaceActivity.class);
intent.putExtra("ouid", feedEntry.getFeed_related_uid());
startActivity(intent);
}
} else {
if (feedEntry.getFeed_related_uid() != 0) {
Intent intent = new Intent(this, UserSpaceActivity.class);
intent.putExtra("ouid", feedEntry.getFeed_related_uid());
startActivity(intent);
} else {
Intent intent = new Intent(this, UserPhotoActivity.class);
intent.putExtra("picid", feedEntry.getFeed_picid());
startActivity(intent);
}
}
}
}
}
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.