コード例 #1
0
  @Override
  protected void onReceive(InputStream is) throws Exception {
    HashMap<String, String> header = getResponseHeader();
    String value = header.get("content-length");
    HLog.d(TAG, "value.length()=" + Integer.valueOf(value));

    String xml = ToolsUtil.InputStreamToString(is);
    HLog.d(TAG, "parser=" + xml);
    is = ToolsUtil.StringToInputStream(xml);

    if (value != null && Integer.valueOf(value) > 2) {
      SAXParserFactory parserFactory = SAXParserFactory.newInstance();
      SAXParser saxParser = parserFactory.newSAXParser();
      saxParser.parse(is, this.mHandler);
    }
  }
コード例 #2
0
  public void updataDB(HSms sms, HSmsApplication application) {
    HLog.i("updata buffer list--------------------->>>");
    mDatabase = mDbOpenHelper.getWritableDatabase();
    // String where = ADDRESS + "=" + sms.address;
    String where = ID + "=" + sms.threadid;
    Cursor cursor = mDatabase.query(TABLE_NAME, null, where, null, null, null, null);
    int len = sms.address.split(",").length;
    if (cursor.getCount() > 0) { // 旧信息
      cursor.moveToFirst();
      String where1 = ID + "=" + sms.threadid;
      HThread model = getHThread(cursor);
      String count = cursor.getString(cursor.getColumnIndex(COUNT));
      String noReadSmsCount = cursor.getString(cursor.getColumnIndex(NOREADCOUNT));
      String type = model.type;
      mDatabase.delete(TABLE_NAME, where1, null);
      ContentValues values = getValue(model);

      if (!sms.type.equals("3")) {
        values.put(TYPE, type);
      } else {
        values.put(TYPE, sms.type);
      }

      values.put(ADDRESS, sms.address);
      values.put(READ, sms.read);
      values.put(BODY, sms.body);
      values.put(NOREADCOUNT, String.valueOf(Integer.parseInt(noReadSmsCount) + 1));
      if (!sms.type.equals("3")) {
        values.put(COUNT, String.valueOf(Integer.parseInt(count) + len));
      }
      values.put(TIME, Long.parseLong(sms.time));
      mDatabase.insert(TABLE_NAME, null, values);
    } else { // 新信息
      HAddressBookManager abm = new HAddressBookManager(application);
      HThread thread = new HThread(application);
      thread.address = sms.address;
      thread.sms.body = sms.body;
      thread.count = "1";
      thread.sms.threadid = sms.threadid;
      thread.name = abm.getNameByNumber(sms.address);
      thread.type = sms.type;
      thread.sms.read = sms.read;
      if (!thread.type.equals("3")) {
        thread.count = String.valueOf(len);
      }
      Bitmap headBp = null;
      if (thread.name.split(",").length == 1) {
        headBp = abm.getContactPhoto(thread.name, thread.address);
      }
      thread.headbm = headBp;
      thread.mark = "0";
      thread.sms.time = sms.time;
      ContentValues cv = getValue(thread);
      mDatabase.insert(TABLE_NAME, null, cv);
    }
    cursor.close();
    mDatabase.close();
  }