Esempio n. 1
0
  private void favoriteDao(NewsListEntity entity, long news_id) {
    if (NicesDBHelper.queryIsFavorite(String.valueOf(news_id))) {
      Toast.makeText(getActivity(), "已收藏", Toast.LENGTH_SHORT).show();
    } else {
      String title = entity.title;
      String image = entity.images.get(0);
      String id = String.valueOf(news_id);

      LogUtil.LogMsg_I(title);
      LogUtil.LogMsg_I(image);
      LogUtil.LogMsg_I(id);

      if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(title) && !TextUtils.isEmpty(image)) {
        NicesDBHelper.insertFavoriteContent(id, title, image, "cjj");
        Toast.makeText(getActivity(), "添加收藏成功", Toast.LENGTH_SHORT).show();
      } else {
        Toast.makeText(getActivity(), "添加收藏失败", Toast.LENGTH_SHORT).show();
      }
    }
  }