コード例 #1
0
ファイル: HomeFragment.java プロジェクト: rain2372/nices
  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();
      }
    }
  }
コード例 #2
0
ファイル: HomeFragment.java プロジェクト: rain2372/nices
    @Override
    protected ArrayList<NewsListEntity> doInBackground(String... params) {
      ArrayList<NewsListEntity> list = NicesDBHelper.queryNewsList(params[0]);
      Log.i("cjj", "today = " + params[0]);
      if (ListUtils.isEmpty(list)) {
        Calendar calendar = Calendar.getInstance();

        String yesterday = mSimpleDateFormat.format(calendar.getTime());
        Log.i("cjj", "yesterday = " + yesterday);
        list = NicesDBHelper.queryNewsList(yesterday);
      }

      if (ListUtils.isEmpty(list)) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, -1);

        String dayBeforeYesterday = mSimpleDateFormat.format(calendar.getTime());
        Log.i("cjj", "daybeforeyesterday = " + dayBeforeYesterday);
        list = NicesDBHelper.queryNewsList(dayBeforeYesterday);
      }
      return list;
    }
コード例 #3
0
ファイル: HomeFragment.java プロジェクト: rain2372/nices
 @Override
 protected ArrayList<NewsListEntity> doInBackground(String... params) {
   String time = params[0];
   ArrayList<NewsListEntity> list_old = NicesDBHelper.queryNewsList(time);
   return list_old;
 }