Exemple #1
0
 /**
  * 获取已读新闻ID
  *
  * @return 格式:id1,id2,id3,...,idn
  */
 public static String getReadNewsIds() {
   Json[] queryRead = Db.queryRead();
   String string = "";
   for (int i = 0; i < queryRead.length; i++) {
     string += queryRead[i].getString("newsid") + ",";
   }
   return string;
 }
Exemple #2
0
 /**
  * 查看是否已踩
  *
  * @param newsid
  * @return true--空
  */
 public static boolean getCai(String newsid) {
   return TextUtils.isEmpty(Db.getFirst("select value from kv where key='" + newsid + "_cai'"));
 }
Exemple #3
0
 /**
  * 设置已读新闻ID
  *
  * @param newsid
  */
 public static void setReadNewsIds(String newsid) {
   if (!Db.findFromRead(newsid)) {
     Db.insertIntoRead(newsid);
   }
 }
Exemple #4
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
      convertView = inflater.inflate(R.layout.xlistview_item, null);
      convertView.setTag(position);
    }
    Json item = data[position];
    aq = new AQuery(convertView);

    // 查询数据是否已读,设置文字颜色
    if (Db.findFromRead(item.getString("newsid"))) {
      aq.id(R.id.news_content)
          .textColor(context.getResources().getColor(R.color.news_content_read));
    } else {
      aq.id(R.id.news_content).textColor(context.getResources().getColor(R.color.news_content));
    }

    aq.id(R.id.main_layout).tag(item);

    aq.id(R.id.main_layout)
        .clicked(
            new OnClickListener() {

              @Override
              public void onClick(View v) {

                MainActivity.check_mask = false;
                Json item = (Json) v.getTag();
                Intent intent = new Intent(context, ContentActivity.class);
                // 在本地记录为已浏览
                //				if (TextUtils.isEmpty(Db.getValue(item.getString("url")
                //						+ "read", "1"))) {
                //					Db.setValue(item.getString("url") + "read", "1");
                //				}
                //				 添加至已读表
                //				BaseTools.setReadNewsIds(item.getString("newsid"));

                intent.putExtra("url", item.getString("url"));
                intent.putExtra("json", item.toString());
                intent.putExtra("back", 1);
                context.startActivity(intent);
                context.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
                new Handler()
                    .postDelayed(
                        new Runnable() {
                          @Override
                          public void run() {
                            notifyDataSetChanged();
                          }
                        },
                        1000);
                // St.onEvent(context, "点击新闻",
                //		item.getString("title").replace("&nbsp;", " "),
                //		item.getString("url"));// 统计-----------------------
              }
            });
    if (WebClient.getAPNType(context) != -1) { // 网络是否可用
      // .image(item.getString("image"));
      // aq.id(R.id.news_image).image(bm)
      aq.id(R.id.news_image).image(R.drawable.defaultpic);
      ImageLoader.image(aq.id(R.id.news_image).getImageView(), item.getString("image"));
    } else {
      aq.id(R.id.news_image).image(R.drawable.defaultpic);
    }
    aq.id(R.id.news_content).text(item.getString("title").replace("&nbsp;", " "));
    // 显示日期或穿越标记
    if (((TimeModeAP) context).getTimeModeAP()) {
      aq.id(R.id.news_time).background(R.drawable.item_time_travel);
    } else {
      aq.id(R.id.news_time).text(tranTime(St.getDate(item.getString("addtime"))));
    }

    ArrayList<Json> list = new ArrayList<Json>();
    for (int i = 0; i < data.length; i++) {
      list.add(data[i]);
    }
    data = list.toArray(new Json[data.length]);
    setNewData(data);
    return convertView;
  }