Exemplo n.º 1
0
 /**
  * 用户博客列表
  *
  * @param authoruid
  * @param pageIndex
  * @return
  * @throws AppException
  */
 public BlogList getUserBlogList(
     int authoruid, String authorname, int pageIndex, boolean isRefresh) throws AppException {
   BlogList list = null;
   String key =
       "userbloglist_"
           + authoruid
           + "_"
           + (URLEncoder.encode(authorname))
           + "_"
           + loginUid
           + "_"
           + pageIndex
           + "_"
           + PAGE_SIZE;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       list =
           ApiClient.getUserBlogList(this, authoruid, authorname, loginUid, pageIndex, PAGE_SIZE);
       if (list != null && pageIndex == 0) {
         Notice notice = list.getNotice();
         list.setNotice(null);
         list.setCacheKey(key);
         saveObject(list, key);
         list.setNotice(notice);
       }
     } catch (AppException e) {
       list = (BlogList) readObject(key);
       if (list == null) throw e;
     }
   } else {
     list = (BlogList) readObject(key);
     if (list == null) list = new BlogList();
   }
   return list;
 }
 /**
  * 下载图片-可指定显示图片的高宽
  *
  * @param url
  * @param width
  * @param height
  */
 private Bitmap downloadBitmap(String url, int width, int height) {
   Bitmap bitmap = null;
   try {
     // http加载图片
     bitmap = ApiClient.getNetBitmap(url);
     if (width > 0 && height > 0) {
       // 指定显示图片的高宽
       bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
     }
     // 放入缓存
     cache.put(url, new SoftReference<Bitmap>(bitmap));
   } catch (AppException e) {
     e.printStackTrace();
   }
   return bitmap;
 }
Exemplo n.º 3
0
 /**
  * 获取用户信息个人专页(包含该用户的动态信息以及个人信息)
  *
  * @param uid 自己的uid
  * @param hisuid 被查看用户的uid
  * @param hisname 被查看用户的用户名
  * @param pageIndex 页面索引
  * @return
  * @throws AppException
  */
 public UserInformation getInformation(
     int uid, int hisuid, String hisname, int pageIndex, boolean isRefresh) throws AppException {
   String _hisname = "";
   if (!StringUtils.isEmpty(hisname)) {
     _hisname = hisname;
   }
   UserInformation userinfo = null;
   String key =
       "userinfo_"
           + uid
           + "_"
           + hisuid
           + "_"
           + (URLEncoder.encode(hisname))
           + "_"
           + pageIndex
           + "_"
           + PAGE_SIZE;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       userinfo = ApiClient.information(this, uid, hisuid, _hisname, pageIndex, PAGE_SIZE);
       if (userinfo != null && pageIndex == 0) {
         Notice notice = userinfo.getNotice();
         userinfo.setNotice(null);
         userinfo.setCacheKey(key);
         saveObject(userinfo, key);
         userinfo.setNotice(notice);
       }
     } catch (AppException e) {
       userinfo = (UserInformation) readObject(key);
       if (userinfo == null) throw e;
     }
   } else {
     userinfo = (UserInformation) readObject(key);
     if (userinfo == null) userinfo = new UserInformation();
   }
   return userinfo;
 }
Exemplo n.º 4
0
 /**
  * 读取帖子详情
  *
  * @param post_id
  * @return
  * @throws ApiException
  */
 public Post getPost(int post_id, boolean isRefresh) throws AppException {
   Post post = null;
   String key = "post_" + post_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       post = ApiClient.getPostDetail(this, post_id);
       if (post != null) {
         Notice notice = post.getNotice();
         post.setNotice(null);
         post.setCacheKey(key);
         saveObject(post, key);
         post.setNotice(notice);
       }
     } catch (AppException e) {
       post = (Post) readObject(key);
       if (post == null) throw e;
     }
   } else {
     post = (Post) readObject(key);
     if (post == null) post = new Post();
   }
   return post;
 }
Exemplo n.º 5
0
 /**
  * 留言列表
  *
  * @param pageIndex
  * @return
  * @throws AppException
  */
 public MessageList getMessageList(int pageIndex, boolean isRefresh) throws AppException {
   MessageList list = null;
   String key = "messagelist_" + loginUid + "_" + pageIndex + "_" + PAGE_SIZE;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       list = ApiClient.getMessageList(this, loginUid, pageIndex, PAGE_SIZE);
       if (list != null && pageIndex == 0) {
         Notice notice = list.getNotice();
         list.setNotice(null);
         list.setCacheKey(key);
         saveObject(list, key);
         list.setNotice(notice);
       }
     } catch (AppException e) {
       list = (MessageList) readObject(key);
       if (list == null) throw e;
     }
   } else {
     list = (MessageList) readObject(key);
     if (list == null) list = new MessageList();
   }
   return list;
 }
Exemplo n.º 6
0
 /**
  * 获取动弹详情
  *
  * @param tweet_id
  * @return
  * @throws AppException
  */
 public Tweet getTweet(int tweet_id, boolean isRefresh) throws AppException {
   Tweet tweet = null;
   String key = "tweet_" + tweet_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       tweet = ApiClient.getTweetDetail(this, tweet_id);
       if (tweet != null) {
         Notice notice = tweet.getNotice();
         tweet.setNotice(null);
         tweet.setCacheKey(key);
         saveObject(tweet, key);
         tweet.setNotice(notice);
       }
     } catch (AppException e) {
       tweet = (Tweet) readObject(key);
       if (tweet == null) throw e;
     }
   } else {
     tweet = (Tweet) readObject(key);
     if (tweet == null) tweet = new Tweet();
   }
   return tweet;
 }
Exemplo n.º 7
0
 /**
  * 软件详情
  *
  * @param soft_id
  * @return
  * @throws AppException
  */
 public Software getSoftware(String ident, boolean isRefresh) throws AppException {
   Software soft = null;
   String key = "software_" + (URLEncoder.encode(ident));
   if (isNetworkConnected() && (isCacheDataFailure(key) || isRefresh)) {
     try {
       soft = ApiClient.getSoftwareDetail(this, ident);
       if (soft != null) {
         Notice notice = soft.getNotice();
         soft.setNotice(null);
         soft.setCacheKey(key);
         saveObject(soft, key);
         soft.setNotice(notice);
       }
     } catch (AppException e) {
       soft = (Software) readObject(key);
       if (soft == null) throw e;
     }
   } else {
     soft = (Software) readObject(key);
     if (soft == null) soft = new Software();
   }
   return soft;
 }
Exemplo n.º 8
0
 /**
  * 软件分类列表
  *
  * @param tag 第一级:0 第二级:tag
  * @return
  * @throws AppException
  */
 public SoftwareCatalogList getSoftwareCatalogList(int tag) throws AppException {
   SoftwareCatalogList list = null;
   String key = "softwarecataloglist_" + tag;
   if (isNetworkConnected() && isCacheDataFailure(key)) {
     try {
       list = ApiClient.getSoftwareCatalogList(this, tag);
       if (list != null) {
         Notice notice = list.getNotice();
         list.setNotice(null);
         list.setCacheKey(key);
         saveObject(list, key);
         list.setNotice(notice);
       }
     } catch (AppException e) {
       list = (SoftwareCatalogList) readObject(key);
       if (list == null) throw e;
     }
   } else {
     list = (SoftwareCatalogList) readObject(key);
     if (list == null) list = new SoftwareCatalogList();
   }
   return list;
 }
Exemplo n.º 9
0
 /**
  * 新闻详情
  *
  * @param news_id
  * @return
  * @throws ApiException
  */
 public News getNews(int news_id, boolean isRefresh) throws AppException {
   News news = null;
   String key = "news_" + news_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       news = ApiClient.getNewsDetail(this, news_id);
       if (news != null) {
         Notice notice = news.getNotice();
         news.setNotice(null);
         news.setCacheKey(key);
         saveObject(news, key);
         news.setNotice(notice);
       }
     } catch (AppException e) {
       news = (News) readObject(key);
       if (news == null) throw e;
     }
   } else {
     news = (News) readObject(key);
     if (news == null) news = new News();
   }
   return news;
 }
Exemplo n.º 10
0
 /**
  * 我的个人资料
  *
  * @param isRefresh 是否主动刷新
  * @return
  * @throws AppException
  */
 public MyInformation getMyInformation(boolean isRefresh) throws AppException {
   MyInformation myinfo = null;
   String key = "myinfo_" + loginUid;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       myinfo = ApiClient.myInformation(this, loginUid);
       if (myinfo != null && myinfo.getName().length() > 0) {
         Notice notice = myinfo.getNotice();
         myinfo.setNotice(null);
         myinfo.setCacheKey(key);
         saveObject(myinfo, key);
         myinfo.setNotice(notice);
       }
     } catch (AppException e) {
       myinfo = (MyInformation) readObject(key);
       if (myinfo == null) throw e;
     }
   } else {
     myinfo = (MyInformation) readObject(key);
     if (myinfo == null) myinfo = new MyInformation();
   }
   return myinfo;
 }
Exemplo n.º 11
0
 /**
  * 博客详情
  *
  * @param blog_id
  * @return
  * @throws AppException
  */
 public Blog getBlog(int blog_id, boolean isRefresh) throws AppException {
   Blog blog = null;
   String key = "blog_" + blog_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       blog = ApiClient.getBlogDetail(this, blog_id);
       if (blog != null) {
         Notice notice = blog.getNotice();
         blog.setNotice(null);
         blog.setCacheKey(key);
         saveObject(blog, key);
         blog.setNotice(notice);
       }
     } catch (AppException e) {
       blog = (Blog) readObject(key);
       if (blog == null) throw e;
     }
   } else {
     blog = (Blog) readObject(key);
     if (blog == null) blog = new Blog();
   }
   return blog;
 }
Exemplo n.º 12
0
 /**
  * Tag相关帖子列表
  *
  * @param tag
  * @param pageIndex
  * @return
  * @throws ApiException
  */
 public PostList getPostListByTag(String tag, int pageIndex, boolean isRefresh)
     throws AppException {
   PostList list = null;
   String key = "postlist_" + (URLEncoder.encode(tag)) + "_" + pageIndex + "_" + PAGE_SIZE;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       list = ApiClient.getPostListByTag(this, tag, pageIndex, PAGE_SIZE);
       if (list != null && pageIndex == 0) {
         Notice notice = list.getNotice();
         list.setNotice(null);
         list.setCacheKey(key);
         saveObject(list, key);
         list.setNotice(notice);
       }
     } catch (AppException e) {
       list = (PostList) readObject(key);
       if (list == null) throw e;
     }
   } else {
     list = (PostList) readObject(key);
     if (list == null) list = new PostList();
   }
   return list;
 }
Exemplo n.º 13
0
 /**
  * 软件分类的软件列表
  *
  * @param searchTag 从softwarecatalog_list获取的tag
  * @param pageIndex
  * @return
  * @throws AppException
  */
 public SoftwareList getSoftwareTagList(int searchTag, int pageIndex, boolean isRefresh)
     throws AppException {
   SoftwareList list = null;
   String key = "softwaretaglist_" + searchTag + "_" + pageIndex + "_" + PAGE_SIZE;
   if (isNetworkConnected() && (isCacheDataFailure(key) || isRefresh)) {
     try {
       list = ApiClient.getSoftwareTagList(this, searchTag, pageIndex, PAGE_SIZE);
       if (list != null && pageIndex == 0) {
         Notice notice = list.getNotice();
         list.setNotice(null);
         list.setCacheKey(key);
         saveObject(list, key);
         list.setNotice(notice);
       }
     } catch (AppException e) {
       list = (SoftwareList) readObject(key);
       if (list == null) throw e;
     }
   } else {
     list = (SoftwareList) readObject(key);
     if (list == null) list = new SoftwareList();
   }
   return list;
 }
Exemplo n.º 14
0
 /**
  * 删除博客评论
  *
  * @param uid 登录用户的uid
  * @param blogid 博客id
  * @param replyid 评论id
  * @param authorid 评论发表者的uid
  * @param owneruid 博客作者uid
  * @return
  * @throws AppException
  */
 public Result delBlogComment(int uid, int blogid, int replyid, int authorid, int owneruid)
     throws AppException {
   return ApiClient.delBlogComment(this, uid, blogid, replyid, authorid, owneruid);
 }
Exemplo n.º 15
0
 /**
  * 删除评论
  *
  * @param id 表示被评论对应的某条新闻,帖子,动弹的id 或者某条消息的 friendid
  * @param catalog 表示该评论所属什么类型:1新闻 2帖子 3动弹 4动态&留言
  * @param replyid 表示被回复的单个评论id
  * @param authorid 表示该评论的原始作者id
  * @return
  * @throws AppException
  */
 public Result delComment(int id, int catalog, int replyid, int authorid) throws AppException {
   return ApiClient.delComment(this, id, catalog, replyid, authorid);
 }
Exemplo n.º 16
0
 /**
  * 删除博客
  *
  * @param uid 登录用户的uid
  * @param authoruid 博客作者uid
  * @param id 博客id
  * @return
  * @throws AppException
  */
 public Result delBlog(int uid, int authoruid, int id) throws AppException {
   return ApiClient.delBlog(this, uid, authoruid, id);
 }
Exemplo n.º 17
0
 /**
  * 转发留言
  *
  * @param uid 登录用户uid
  * @param receiver 接受者的用户名
  * @param content 消息内容,注意不能超过250个字符
  * @return
  * @throws AppException
  */
 public Result forwardMessage(int uid, String receiver, String content) throws AppException {
   return ApiClient.forwardMessage(this, uid, receiver, content);
 }
Exemplo n.º 18
0
 /**
  * 清空通知消息
  *
  * @param uid
  * @param type 1:@我的信息 2:未读消息 3:评论个数 4:新粉丝个数
  * @return
  * @throws AppException
  */
 public Result noticeClear(int uid, int type) throws AppException {
   return ApiClient.noticeClear(this, uid, type);
 }
Exemplo n.º 19
0
 /**
  * 获取用户通知信息
  *
  * @param uid
  * @return
  * @throws AppException
  */
 public Notice getUserNotice(int uid) throws AppException {
   return ApiClient.getUserNotice(this, uid);
 }
Exemplo n.º 20
0
 /**
  * 更新用户头像
  *
  * @param portrait 新上传的头像
  * @return
  * @throws AppException
  */
 public Result updatePortrait(File portrait) throws AppException {
   return ApiClient.updatePortrait(this, loginUid, portrait);
 }
Exemplo n.º 21
0
 /**
  * 发表博客评论
  *
  * @param blog 博客id
  * @param uid 登陆用户的uid
  * @param content 评论内容
  * @param reply_id 评论id
  * @param objuid 被评论的评论发表者的uid
  * @return
  * @throws AppException
  */
 public Result replyBlogComment(int blog, int uid, String content, int reply_id, int objuid)
     throws AppException {
   return ApiClient.replyBlogComment(this, blog, uid, content, reply_id, objuid);
 }
Exemplo n.º 22
0
 /**
  * 用户删除收藏
  *
  * @param uid 用户UID
  * @param objid 比如是新闻ID 或者问答ID 或者动弹ID
  * @param type 1:软件 2:话题 3:博客 4:新闻 5:代码
  * @return
  * @throws AppException
  */
 public Result delFavorite(int uid, int objid, int type) throws AppException {
   return ApiClient.delFavorite(this, uid, objid, type);
 }
Exemplo n.º 23
0
 /** 用户注销 */
 public void Logout() {
   ApiClient.cleanCookie();
   this.cleanCookie();
   this.login = false;
   this.loginUid = 0;
 }
Exemplo n.º 24
0
 /**
  * 用户登录验证
  *
  * @param account
  * @param pwd
  * @return
  * @throws AppException
  */
 public User loginVerify(String account, String pwd) throws AppException {
   return ApiClient.login(this, account, pwd);
 }
Exemplo n.º 25
0
 /**
  * 发表评论
  *
  * @param catalog 1新闻 2帖子 3动弹 4动态
  * @param id 某条新闻,帖子,动弹的id
  * @param uid 用户uid
  * @param content 发表评论的内容
  * @param isPostToMyZone 是否转发到我的空间 0不转发 1转发
  * @return
  * @throws AppException
  */
 public Result pubComment(int catalog, int id, int uid, String content, int isPostToMyZone)
     throws AppException {
   return ApiClient.pubComment(this, catalog, id, uid, content, isPostToMyZone);
 }
Exemplo n.º 26
0
 /**
  * 发表博客评论
  *
  * @param blog 博客id
  * @param uid 登陆用户的uid
  * @param content 评论内容
  * @return
  * @throws AppException
  */
 public Result pubBlogComment(int blog, int uid, String content) throws AppException {
   return ApiClient.pubBlogComment(this, blog, uid, content);
 }
Exemplo n.º 27
0
 /**
  * 发送留言
  *
  * @param uid 登录用户uid
  * @param receiver 接受者的用户id
  * @param content 消息内容,注意不能超过250个字符
  * @return
  * @throws AppException
  */
 public Result pubMessage(int uid, int receiver, String content) throws AppException {
   return ApiClient.pubMessage(this, uid, receiver, content);
 }
Exemplo n.º 28
0
 /**
  * @param id 表示被评论的某条新闻,帖子,动弹的id 或者某条消息的 friendid
  * @param catalog 表示该评论所属什么类型:1新闻 2帖子 3动弹 4动态
  * @param replyid 表示被回复的单个评论id
  * @param authorid 表示该评论的原始作者id
  * @param uid 用户uid 一般都是当前登录用户uid
  * @param content 发表评论的内容
  * @return
  * @throws AppException
  */
 public Result replyComment(
     int id, int catalog, int replyid, int authorid, int uid, String content) throws AppException {
   return ApiClient.replyComment(this, id, catalog, replyid, authorid, uid, content);
 }
Exemplo n.º 29
0
 /**
  * 更新用户之间关系(加关注、取消关注)
  *
  * @param uid 自己的uid
  * @param hisuid 对方用户的uid
  * @param newrelation 0:取消对他的关注 1:关注他
  * @return
  * @throws AppException
  */
 public Result updateRelation(int uid, int hisuid, int newrelation) throws AppException {
   return ApiClient.updateRelation(this, uid, hisuid, newrelation);
 }
Exemplo n.º 30
0
 /**
  * 删除留言
  *
  * @param uid 登录用户uid
  * @param friendid 留言者id
  * @return
  * @throws AppException
  */
 public Result delMessage(int uid, int friendid) throws AppException {
   return ApiClient.delMessage(this, uid, friendid);
 }