本文整理汇总了Java中net.oschina.app.bean.Notice类的典型用法代码示例。如果您正苦于以下问题:Java Notice类的具体用法?Java Notice怎么用?Java Notice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Notice类属于net.oschina.app.bean包,在下文中一共展示了Notice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserNotice
import net.oschina.app.bean.Notice; //导入依赖的package包/类
/**
* 获取用户通知信息
* @param uid
* @return
* @throws AppException
*/
public static Notice getUserNotice(AppContext appContext, int uid) throws AppException {
Map<String,Object> params = new HashMap<String,Object>();
params.put("uid", uid);
try{
return Notice.parse(_post(appContext, URLs.USER_NOTICE, params, null));
}catch(Exception e){
if(e instanceof AppException)
throw (AppException)e;
throw AppException.network(e);
}
}
示例2: sendBroadCast
import net.oschina.app.bean.Notice; //导入依赖的package包/类
/**
* 发送通知广播
*
* @param context
* @param notice
*/
public static void sendBroadCast(Context context, Notice notice) {
if (!((AppContext) context.getApplicationContext()).isLogin()
|| notice == null)
return;
Intent intent = new Intent("net.oschina.app.action.APPWIDGET_UPDATE");
intent.putExtra("atmeCount", notice.getAtmeCount());
intent.putExtra("msgCount", notice.getMsgCount());
intent.putExtra("reviewCount", notice.getReviewCount());
intent.putExtra("newFansCount", notice.getNewFansCount());
context.sendBroadcast(intent);
}
示例3: sendBroadCast
import net.oschina.app.bean.Notice; //导入依赖的package包/类
/**
* 发送通知广播
* @param context
* @param notice
*/
public static void sendBroadCast(Context context, Notice notice){
if(!((AppContext)context.getApplicationContext()).isLogin() || notice==null) return;
Intent intent = new Intent("net.oschina.app.action.APPWIDGET_UPDATE");
intent.putExtra("atmeCount", notice.getAtmeCount());
intent.putExtra("msgCount", notice.getMsgCount());
intent.putExtra("reviewCount", notice.getReviewCount());
intent.putExtra("newFansCount", notice.getNewFansCount());
context.sendBroadcast(intent);
}
示例4: initSoftwareCatalogListView
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initSoftwareCatalogListView()
{
lvSoftwareCatalogAdapter = new ListViewSoftwareCatalogAdapter(this, lvSoftwareCatalogData, R.layout.softwarecatalog_listitem);
mlvSoftwareCatalog = (ListView)findViewById(R.id.frame_software_listview_catalog);
mlvSoftwareCatalog.setAdapter(lvSoftwareCatalogAdapter);
mlvSoftwareCatalog.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView name = (TextView)view.findViewById(R.id.softwarecatalog_listitem_name);
SoftwareType type = (SoftwareType)name.getTag();
if(type == null) return;
if(type.tag > 0){
curTitleLV1 = type.name;
mTitle.setText(curTitleLV1);
//加载二级分类
curScreen = SCREEN_TAG;
mScrollLayout.scrollToScreen(curScreen);
loadLvSoftwareCatalogData(type.tag, mSoftwareTagHandler, UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG);
}
}
});
mSoftwareCatalogHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
SoftwareCatalogList list = (SoftwareCatalogList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvSoftwareCatalogData.clear();//先清除原有数据
lvSoftwareCatalogData.addAll(list.getSoftwareTypelist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
break;
}
lvSoftwareCatalogAdapter.notifyDataSetChanged();
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(SoftwareLib.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
((AppException)msg.obj).makeToast(SoftwareLib.this);
}
}
};
}
示例5: initSoftwareTagListView
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initSoftwareTagListView()
{
lvSoftwareTagAdapter = new ListViewSoftwareCatalogAdapter(this, lvSoftwareTagData, R.layout.softwarecatalog_listitem);
mlvSoftwareTag = (ListView)findViewById(R.id.frame_software_listview_tag);
mlvSoftwareTag.setAdapter(lvSoftwareTagAdapter);
mlvSoftwareTag.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView name = (TextView)view.findViewById(R.id.softwarecatalog_listitem_name);
SoftwareType type = (SoftwareType)name.getTag();
if(type == null) return;
if(type.tag > 0){
mTitle.setText(type.name);
//加载软件列表
curScreen = SCREEN_SOFTWARE;
mScrollLayout.scrollToScreen(curScreen);
curSearchTag = type.tag;
loadLvSoftwareTagData(curSearchTag, 0, mSoftwareHandler, UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG);
}
}
});
mSoftwareTagHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
SoftwareCatalogList list = (SoftwareCatalogList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvSoftwareTagData.clear();//先清除原有数据
lvSoftwareTagData.addAll(list.getSoftwareTypelist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
break;
}
lvSoftwareTagAdapter.notifyDataSetChanged();
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(SoftwareLib.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
((AppException)msg.obj).makeToast(SoftwareLib.this);
}
}
};
}
示例6: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData()
{
mFriendHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
FriendList list = (FriendList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvSumData = msg.what;
lvFriendData.clear();//先清除原有数据
lvFriendData.addAll(list.getFriendlist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvSumData += msg.what;
if(lvFriendData.size() > 0){
for(Friend friend1 : list.getFriendlist()){
boolean b = false;
for(Friend friend2 : lvFriendData){
if(friend1.getUserid() == friend2.getUserid()){
b = true;
break;
}
}
if(!b) lvFriendData.add(friend1);
}
}else{
lvFriendData.addAll(list.getFriendlist());
}
break;
}
if(msg.what < 20){
curLvDataState = UIHelper.LISTVIEW_DATA_FULL;
lvFriendAdapter.notifyDataSetChanged();
lvFriend_foot_more.setText(R.string.load_full);
}else if(msg.what == 20){
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvFriendAdapter.notifyDataSetChanged();
lvFriend_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(UserFriend.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvFriend_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(UserFriend.this);
}
if(lvFriendData.size()==0){
curLvDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvFriend_foot_more.setText(R.string.load_empty);
}
lvFriend_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH){
mlvFriend.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
mlvFriend.setSelection(0);
}else if(msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG){
mlvFriend.onRefreshComplete();
mlvFriend.setSelection(0);
}
}
};
this.loadLvFriendData(curLvCatalog,0,mFriendHandler,UIHelper.LISTVIEW_ACTION_INIT);
}
示例7: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData()
{
mSearchHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
SearchList list = (SearchList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvSumData = msg.what;
lvSearchData.clear();//先清除原有数据
lvSearchData.addAll(list.getResultlist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvSumData += msg.what;
if(lvSearchData.size() > 0){
for(Result res1 : list.getResultlist()){
boolean b = false;
for(Result res2 : lvSearchData){
if(res1.getObjid() == res2.getObjid()){
b = true;
break;
}
}
if(!b) lvSearchData.add(res1);
}
}else{
lvSearchData.addAll(list.getResultlist());
}
break;
}
if(msg.what < 20){
curLvDataState = UIHelper.LISTVIEW_DATA_FULL;
lvSearchAdapter.notifyDataSetChanged();
lvSearch_foot_more.setText(R.string.load_full);
}else if(msg.what == 20){
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvSearchAdapter.notifyDataSetChanged();
lvSearch_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(Search.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvSearch_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(Search.this);
}
if(lvSearchData.size()==0){
curLvDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvSearch_foot_more.setText(R.string.load_empty);
}
lvSearch_foot_progress.setVisibility(View.GONE);
if(msg.arg1 != UIHelper.LISTVIEW_ACTION_SCROLL){
mlvSearch.setSelection(0);//返回头部
}
}
};
}
示例8: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData()
{
mFavoriteHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
FavoriteList list = (FavoriteList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvSumData = msg.what;
lvFavoriteData.clear();//先清除原有数据
lvFavoriteData.addAll(list.getFavoritelist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvSumData += msg.what;
if(lvFavoriteData.size() > 0){
for(Favorite fav1 : list.getFavoritelist()){
boolean b = false;
for(Favorite fav2 : lvFavoriteData){
if(fav1.objid == fav2.objid){
b = true;
break;
}
}
if(!b) lvFavoriteData.add(fav1);
}
}else{
lvFavoriteData.addAll(list.getFavoritelist());
}
break;
}
if(msg.what < 20){
curLvDataState = UIHelper.LISTVIEW_DATA_FULL;
lvFavoriteAdapter.notifyDataSetChanged();
lvFavorite_foot_more.setText(R.string.load_full);
}else if(msg.what == 20){
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvFavoriteAdapter.notifyDataSetChanged();
lvFavorite_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(UserFavorite.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvFavorite_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(UserFavorite.this);
}
if(lvFavoriteData.size()==0){
curLvDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvFavorite_foot_more.setText(R.string.load_empty);
}
lvFavorite_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH){
mlvFavorite.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
mlvFavorite.setSelection(0);
}else if(msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG){
mlvFavorite.onRefreshComplete();
mlvFavorite.setSelection(0);
}
}
};
this.loadLvFavoriteData(curFavoriteCatalog,0,mFavoriteHandler,UIHelper.LISTVIEW_ACTION_INIT);
}
示例9: lvActiveHandleMessage
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void lvActiveHandleMessage(Message msg){
if(msg.what >= 0){
UserInformation uinfo = (UserInformation)msg.obj;
Notice notice = uinfo.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvActiveSumData = msg.what;
lvActiveData.clear();//先清除原有数据
lvActiveData.addAll(uinfo.getActivelist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvActiveSumData += msg.what;
if(lvActiveData.size() > 0){
for(Active active1 : uinfo.getActivelist()){
boolean b = false;
for(Active active2 : lvActiveData){
if(active1.getId() == active2.getId()){
b = true;
break;
}
}
if(!b) lvActiveData.add(active1);
}
}else{
lvActiveData.addAll(uinfo.getActivelist());
}
break;
}
if(msg.what<_pageSize){
curLvActiveDataState = UIHelper.LISTVIEW_DATA_FULL;
lvActiveAdapter.notifyDataSetChanged();
lvActive_foot_more.setText(R.string.load_full);
}
else if(msg.what == _pageSize){
curLvActiveDataState = UIHelper.LISTVIEW_DATA_MORE;
lvActiveAdapter.notifyDataSetChanged();
lvActive_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(msg.obj != null){
UIHelper.sendBroadCast(UserCenter.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
curLvActiveDataState = UIHelper.LISTVIEW_DATA_MORE;
lvActive_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(UserCenter.this);
}
if(lvActiveData.size()==0){
curLvActiveDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvActive_foot_more.setText(R.string.load_empty);
}
lvActive_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH){
mLvActive.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
mLvActive.setSelection(0);
}else if(msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG){
mLvActive.setSelection(0);
}
}
示例10: lvBlogHandleMessage
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void lvBlogHandleMessage(Message msg){
if(msg.what >= 0){
BlogList bloglist = (BlogList)msg.obj;
Notice notice = bloglist.getNotice();
//显示用户博客数量
String tabBlogText = String.format("博客(%d)", bloglist.getBlogsCount());
mTabBlog.setText(tabBlogText);
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
case UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG:
lvBlogSumData = msg.what;
lvBlogData.clear();//先清除原有数据
lvBlogData.addAll(bloglist.getBloglist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvBlogSumData += msg.what;
if(lvBlogData.size() > 0){
for(Blog blog1 : bloglist.getBloglist()){
boolean b = false;
for(Blog blog2 : lvBlogData){
if(blog1.getId() == blog2.getId()){
b = true;
break;
}
}
if(!b) lvBlogData.add(blog1);
}
}else{
lvBlogData.addAll(bloglist.getBloglist());
}
break;
}
if(msg.what<_pageSize){
curLvBlogDataState = UIHelper.LISTVIEW_DATA_FULL;
lvBlogAdapter.notifyDataSetChanged();
lvBlog_foot_more.setText(R.string.load_full);
}
else if(msg.what == _pageSize){
curLvBlogDataState = UIHelper.LISTVIEW_DATA_MORE;
lvBlogAdapter.notifyDataSetChanged();
lvBlog_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(msg.obj != null){
UIHelper.sendBroadCast(UserCenter.this, notice);
}
}
else if(msg.what == -1){
//有异常--显示加载出错 & 弹出错误消息
curLvBlogDataState = UIHelper.LISTVIEW_DATA_MORE;
lvBlog_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(UserCenter.this);
}
if(lvBlogData.size()==0){
curLvBlogDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvBlog_foot_more.setText(R.string.load_empty);
}
lvBlog_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH){
mLvBlog.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
mLvBlog.setSelection(0);
}else if(msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG){
mLvBlog.setSelection(0);
}
}
示例11: frameActiveBtnOnClick
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void frameActiveBtnOnClick(Button btn, int catalog, int action) {
if (btn == framebtn_Active_lastest)
framebtn_Active_lastest.setEnabled(false);
else
framebtn_Active_lastest.setEnabled(true);
if (btn == framebtn_Active_atme)
framebtn_Active_atme.setEnabled(false);
else
framebtn_Active_atme.setEnabled(true);
if (btn == framebtn_Active_comment)
framebtn_Active_comment.setEnabled(false);
else
framebtn_Active_comment.setEnabled(true);
if (btn == framebtn_Active_myself)
framebtn_Active_myself.setEnabled(false);
else
framebtn_Active_myself.setEnabled(true);
if (btn == framebtn_Active_message)
framebtn_Active_message.setEnabled(false);
else
framebtn_Active_message.setEnabled(true);
// 是否处理通知信息
if (btn == framebtn_Active_atme && bv_atme.isShown()) {
action = UIHelper.LISTVIEW_ACTION_REFRESH;
this.isClearNotice = true;
this.curClearNoticeType = Notice.TYPE_ATME;
} else if (btn == framebtn_Active_comment && bv_review.isShown()) {
action = UIHelper.LISTVIEW_ACTION_REFRESH;
this.isClearNotice = true;
this.curClearNoticeType = Notice.TYPE_COMMENT;
} else if (btn == framebtn_Active_message && bv_message.isShown()) {
action = UIHelper.LISTVIEW_ACTION_REFRESH;
this.isClearNotice = true;
this.curClearNoticeType = Notice.TYPE_MESSAGE;
}
// 非留言展示动态列表
if (btn != framebtn_Active_message) {
lvActive.setVisibility(View.VISIBLE);
lvMsg.setVisibility(View.GONE);
curActiveCatalog = catalog;
loadLvActiveData(curActiveCatalog, 0, lvActiveHandler, action);
} else {
lvActive.setVisibility(View.GONE);
lvMsg.setVisibility(View.VISIBLE);
loadLvMsgData(0, lvMsgHandler, action);
}
}
示例12: getLvHandler
import net.oschina.app.bean.Notice; //导入依赖的package包/类
/**
* 获取listview的初始化Handler
*
* @param lv
* @param adapter
* @return
*/
private Handler getLvHandler(final PullToRefreshListView lv,
final BaseAdapter adapter, final TextView more,
final ProgressBar progress, final int pageSize) {
return new Handler() {
public void handleMessage(Message msg) {
if (msg.what >= 0) {
// listview数据处理
Notice notice = handleLvData(msg.what, msg.obj, msg.arg2,
msg.arg1);
if (msg.what < pageSize) {
lv.setTag(UIHelper.LISTVIEW_DATA_FULL);
adapter.notifyDataSetChanged();
more.setText(R.string.load_full);
} else if (msg.what == pageSize) {
lv.setTag(UIHelper.LISTVIEW_DATA_MORE);
adapter.notifyDataSetChanged();
more.setText(R.string.load_more);
// 特殊处理-热门动弹不能翻页
if (lv == lvTweet) {
TweetList tlist = (TweetList) msg.obj;
if (lvTweetData.size() == tlist.getTweetCount()) {
lv.setTag(UIHelper.LISTVIEW_DATA_FULL);
more.setText(R.string.load_full);
}
}
}
// 发送通知广播
if (notice != null) {
UIHelper.sendBroadCast(lv.getContext(), notice);
}
// 是否清除通知信息
if (isClearNotice) {
ClearNotice(curClearNoticeType);
isClearNotice = false;// 重置
curClearNoticeType = 0;
}
} else if (msg.what == -1) {
// 有异常--显示加载出错 & 弹出错误消息
lv.setTag(UIHelper.LISTVIEW_DATA_MORE);
more.setText(R.string.load_error);
((AppException) msg.obj).makeToast(Main.this);
}
if (adapter.getCount() == 0) {
lv.setTag(UIHelper.LISTVIEW_DATA_EMPTY);
more.setText(R.string.load_empty);
}
progress.setVisibility(ProgressBar.GONE);
mHeadProgress.setVisibility(ProgressBar.GONE);
if (msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH) {
lv.onRefreshComplete(getString(R.string.pull_to_refresh_update)
+ new Date().toLocaleString());
lv.setSelection(0);
} else if (msg.arg1 == UIHelper.LISTVIEW_ACTION_CHANGE_CATALOG) {
lv.onRefreshComplete();
lv.setSelection(0);
}
}
};
}
示例13: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData(){
lvQuestionHandler = new Handler()
{
public void handleMessage(Message msg)
{
if(msg.what >= 0){
headButtonSwitch(DATA_LOAD_COMPLETE);
PostList list = (PostList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
lvQuestionSumData = msg.what;
lvQuestionData.clear();//先清除原有数据
lvQuestionData.addAll(list.getPostlist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvQuestionSumData += msg.what;
if(lvQuestionData.size() > 0){
for(Post p1 : list.getPostlist()){
boolean b = false;
for(Post p2 : lvQuestionData){
if(p1.getId() == p2.getId() && p1.getAuthorId() == p2.getAuthorId()){
b = true;
break;
}
}
if(!b) lvQuestionData.add(p1);
}
}else{
lvQuestionData.addAll(list.getPostlist());
}
break;
}
if(msg.what < 20){
lvQuestion.setTag(UIHelper.LISTVIEW_DATA_FULL);
lvQuestionAdapter.notifyDataSetChanged();
lvQuestion_foot_more.setText(R.string.load_full);
}else if(msg.what == 20){
lvQuestion.setTag(UIHelper.LISTVIEW_DATA_MORE);
lvQuestionAdapter.notifyDataSetChanged();
lvQuestion_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(QuestionTag.this, notice);
}
}
else if(msg.what == -1){
headButtonSwitch(DATA_LOAD_FAIL);
//有异常--显示加载出错 & 弹出错误消息
lvQuestion.setTag(UIHelper.LISTVIEW_DATA_MORE);
lvQuestion_foot_more.setText(R.string.load_error);
((AppException)msg.obj).makeToast(QuestionTag.this);
}
if(lvQuestionData.size()==0){
lvQuestion.setTag(UIHelper.LISTVIEW_DATA_EMPTY);
lvQuestion_foot_more.setText(R.string.load_empty);
}
lvQuestion_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH){
lvQuestion.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
lvQuestion.setSelection(0);
}
}
};
this.loadLvQuestionData(curTag, 0, lvQuestionHandler, UIHelper.LISTVIEW_ACTION_INIT);
}
示例14: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData()
{
mHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what >= 0){
CommentList list = (CommentList)msg.obj;
Notice notice = list.getNotice();
//处理listview数据
switch (msg.arg1) {
case UIHelper.LISTVIEW_ACTION_INIT:
case UIHelper.LISTVIEW_ACTION_REFRESH:
lvSumData = msg.what;
lvCommentData.clear();//先清除原有数据
lvCommentData.addAll(list.getCommentlist());
break;
case UIHelper.LISTVIEW_ACTION_SCROLL:
lvSumData += msg.what;
if(lvCommentData.size() > 0){
for(Comment com1 : list.getCommentlist()){
boolean b = false;
for(Comment com2 : lvCommentData){
if(com1.getId() == com2.getId() && com1.getAuthorId() == com2.getAuthorId()){
b = true;
break;
}
}
if(!b) lvCommentData.add(com1);
}
}else{
lvCommentData.addAll(list.getCommentlist());
}
break;
}
if(msg.what < 20){
curLvDataState = UIHelper.LISTVIEW_DATA_FULL;
lvCommentAdapter.notifyDataSetChanged();
lvComment_foot_more.setText(R.string.load_full);
}else if(msg.what == 20){
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvCommentAdapter.notifyDataSetChanged();
lvComment_foot_more.setText(R.string.load_more);
}
//发送通知广播
if(notice != null){
UIHelper.sendBroadCast(MessageDetail.this, notice);
}
}
else if(msg.what == -1){
//有异常--也显示更多 & 弹出错误消息
curLvDataState = UIHelper.LISTVIEW_DATA_MORE;
lvComment_foot_more.setText(R.string.load_more);
((AppException)msg.obj).makeToast(MessageDetail.this);
}
if(lvCommentData.size()==0){
curLvDataState = UIHelper.LISTVIEW_DATA_EMPTY;
lvComment_foot_more.setText(R.string.load_empty);
}
lvComment_foot_progress.setVisibility(View.GONE);
if(msg.arg1 == UIHelper.LISTVIEW_ACTION_REFRESH)
mLvComment.onRefreshComplete(getString(R.string.pull_to_refresh_update) + new Date().toLocaleString());
}
};
this.loadLvCommentData(curFriendId,curCatalog,0,mHandler,UIHelper.LISTVIEW_ACTION_INIT);
}
示例15: initData
import net.oschina.app.bean.Notice; //导入依赖的package包/类
private void initData()
{
mHandler = new Handler()
{
public void handleMessage(Message msg) {
headButtonSwitch(DATA_LOAD_COMPLETE);
if(msg.what == 1)
{
mTitle.setText(postDetail.getTitle());
mAuthor.setText(postDetail.getAuthor());
mPubDate.setText(StringUtils.friendly_time(postDetail.getPubDate()));
mCommentCount.setText(postDetail.getAnswerCount()+"回/"+postDetail.getViewCount()+"阅");
//是否收藏
if(postDetail.getFavorite() == 1)
mFavorite.setImageResource(R.drawable.widget_bar_favorite2);
else
mFavorite.setImageResource(R.drawable.widget_bar_favorite);
//显示评论数
if(postDetail.getAnswerCount() > 0){
bv_comment.setText(postDetail.getAnswerCount()+"");
bv_comment.show();
}else{
bv_comment.setText("");
bv_comment.hide();
}
//显示标签
String tags = getPostTags(postDetail.getTags());
String body = UIHelper.WEB_STYLE + postDetail.getBody() + tags + "<div style=\"margin-bottom: 80px\" />";
//读取用户设置:是否加载文章图片--默认有wifi下始终加载图片
boolean isLoadImage;
AppContext ac = (AppContext)getApplication();
if(AppContext.NETTYPE_WIFI == ac.getNetworkType()){
isLoadImage = true;
}else{
isLoadImage = ac.isLoadImage();
}
if(isLoadImage){
body = body.replaceAll("(<img[^>]*?)\\s+width\\s*=\\s*\\S+","$1");
body = body.replaceAll("(<img[^>]*?)\\s+height\\s*=\\s*\\S+","$1");
// 添加点击图片放大支持
body = body.replaceAll("(<img[^>]+src=\")(\\S+)\"",
"$1$2\" onClick=\"javascript:mWebViewImageListener.onImageClick('$2')\"");
}else{
body = body.replaceAll("<\\s*img\\s+([^>]*)\\s*>","");
}
mWebView.loadDataWithBaseURL(null, body, "text/html", "utf-8",null);
mWebView.setWebViewClient(UIHelper.getWebViewClient());
//发送通知广播
if(msg.obj != null){
UIHelper.sendBroadCast(QuestionDetail.this, (Notice)msg.obj);
}
}
else if(msg.what == 0)
{
headButtonSwitch(DATA_LOAD_FAIL);
UIHelper.ToastMessage(QuestionDetail.this, R.string.msg_load_is_null);
}
else if(msg.what == -1 && msg.obj != null)
{
headButtonSwitch(DATA_LOAD_FAIL);
((AppException)msg.obj).makeToast(QuestionDetail.this);
}
}
};
initData(postId, false);
}