public static ListResponsReview getAll(int moviesId) { List<ReviewModel> reviewModelList = new ArrayList<>(); ListResponsReview listResponsReview = new ListResponsReview(); try { List<ReviewModel> list = runtimeExceptionDao.queryForAll(); for (ReviewModel reviewModel : list) { if (reviewModel.getMovieId().equals(String.valueOf(moviesId))) { reviewModelList.add(reviewModel); } } listResponsReview.setResults(reviewModelList); } catch (Exception e) { e.printStackTrace(); } return listResponsReview; }
public boolean verificaLogin() { boolean cadastrado = false; RuntimeExceptionDao<Usuario, Integer> usrDao = getHelper().getUsuarioRuntimeExceptionDao(); usrDao.create(new Usuario("user1", "1234")); List<Usuario> usrs = usrDao.queryForAll(); // Log.d("demo", usrs.toString()); for (Usuario u : usrs) { // Log.d("demo", u.login); // Log.d("demo", etLogin.getText().toString()); if (u.login.equals(etLogin.getText().toString()) && u.senha.equals(etSenha.getText().toString())) { cadastrado = true; } } return cadastrado; }
@Override public List<Role> getAll() { return db.queryForAll(); }
private void callsTunnel() { Cursor cursor = null; String calls_id = null; // 数据处理标记,存入SharedPreferences try { RuntimeExceptionDao<CallsStructure, Long> dao = QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO(); cursor = getContentResolver() .query( CallsContentObserver.CALLS_URI, null, "_id > ?", new String[] { sharedPreferences.getString(CallsContentObserver.CALLS_FLAG_ID, "0") }, CallLog.Calls._ID + " ASC"); while (cursor.moveToNext()) { calls_id = cursor.getString(cursor.getColumnIndex(CallLog.Calls._ID)); int type = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE)); String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)); String name = Contacts.lookupPersonName( getApplicationContext(), number, cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME))); long duration = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DURATION)); DateTime ddate = new DateTime(cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE))); CallsStructure structure = new CallsStructure( MobileNetType.getPhoneType(getApplicationContext()), MobileNetType.getMobileTypeValue(getApplicationContext()), name, number, type, CallDropCause.UNKNOW.toString(), duration, ddate); dao.create(structure); } } catch (Exception e) { Log.w(TAG, "未能处理当前通话记录数据", e); } finally { try { if (null != cursor) cursor.close(); } catch (Exception e) { } if (!Strings.isEmpty(calls_id)) sharedPreferences.edit().putString(CallsContentObserver.CALLS_FLAG_ID, calls_id).commit(); } try { RuntimeExceptionDao<CallCauseCache, Long> dao = QualityApplication.getApplication(this).getDatabaseHelper().getCallCauseCacheDAO(); RuntimeExceptionDao<CallsStructure, Long> callDao = QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO(); List<CallCauseCache> caches = dao.queryForAll(); // 遍历 if (null != caches && caches.size() > 0) { for (CallCauseCache cache : caches) { CallsStructure struct = callDao .queryBuilder() .orderBy("ddate", false) .where() .eq("ddate", cache.getDdate()) .queryForFirst(); if (null != struct) { // 更新断开原因 struct.setCause(cache.getCause()); callDao.update(struct); // 删除 dao.deleteById(cache.getId()); } } } } catch (Exception e) { Log.d(TAG, "更新通话断开原因时出现异常"); } sendMessage(PhoneStateService.OBSERVER_INSTALL, PhoneStateService.OBSERVER_INSTALL_CALLS); }