public void detele(String flag, String stationName) { db = listHelper.getWritableDatabase(); db.execSQL( "delete * from " + ListHelper.TABLENAME + " where flag=?,stationName=?", new String[] {flag, stationName}); db.close(); }
public static List<String> getMessageFieldNames( Descriptor descriptor, Map<String, String> fieldNameTranslations) { Function<FieldDescriptor, String> fieldTransformer = getFieldTransformerFor(fieldNameTranslations); return ListHelper.filter( Lists.transform(descriptor.getFields(), fieldTransformer), Predicates.<String>notNull()); }
/** * flag有三种:<br> * "stationNameList":you known what I mean<br> * "" */ public void add(String flag, String stationName, String listJson) { db = listHelper.getWritableDatabase(); values = new ContentValues(); values.put("flag", flag); values.put("stationName", stationName); values.put("Info", listJson); db.insert(ListHelper.TABLENAME, null, values); db.close(); }
@Test public void populateGroupNameTest() { ListProp listProp1 = List.createPublic(client, sgp.groupId, "SGP List", User.SUPER_USER); ListProp listProp2 = List.createPublic(client, kl.groupId, "KL List", User.SUPER_USER); java.util.List<ListProp> listProps = new ArrayList<>(); listProps.add(listProp1); listProps.add(listProp2); ListHelper.populateGroupName(client, listProps); assertEquals("Singapore", listProp1.groupName); assertEquals("KL", listProp2.groupName); }
public List<String> getOrderCodeNameList(String stationName) { db = listHelper.getReadableDatabase(); cursor = db.rawQuery( "select Info from " + ListHelper.TABLENAME + " where flag=?,stationName=?", new String[] {orderCodeList, stationName}); cursor.moveToFirst(); String info = cursor.getString(cursor.getColumnIndex("Info")); cursor.close(); List<String> list = new ArrayList<String>(); try { ja = new JSONArray(info); for (int i = 0; i < ja.length(); i++) { list.add(ja.get(i).toString()); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (isModeNew) { switch (item.getItemId()) { case R.id.auto: Cursor c = getContentResolver() .query( DBContract.PartTable.CONTENT_URI, new String[] {DBContract.PartTable.KEY_NAME}, DBContract.PartTable.KEY_DUTY + "=" + String.valueOf(mSpApp.getInt("Duty", 0)), null, null); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { if (!mArrayList.contains(c.getString(0))) { mArrayList.add(c.getString(0)); } } c.close(); mListHelper.notifyDataSetChanged(); break; case R.id.save: if (mWagonEdit.getText().toString().isEmpty()) { Toast.makeText(this, "未填写车号", Toast.LENGTH_LONG).show(); } else if (mModelEdit.getText().toString().isEmpty()) { Toast.makeText(this, "未填写型号", Toast.LENGTH_LONG).show(); } else if (mPlatformEdit.getText().toString().isEmpty()) { Toast.makeText(this, "未填写台号", Toast.LENGTH_LONG).show(); } else if (mArrayList.isEmpty()) { Toast.makeText(this, "未添加部件", Toast.LENGTH_LONG).show(); } else { ContentValues cv_task = new ContentValues(); cv_task.put(DBContract.TaskTable.KEY_DUTY, mSpApp.getInt("Duty", 0)); cv_task.put(DBContract.TaskTable.KEY_USER, mSpApp.getInt("User", 0)); cv_task.put(DBContract.TaskTable.KEY_MODEL, mModelEdit.getText().toString()); cv_task.put(DBContract.TaskTable.KEY_WAGON, mWagonEdit.getText().toString()); cv_task.put(DBContract.TaskTable.KEY_PLATFORM, mPlatformEdit.getText().toString()); cv_task.put(DBContract.TaskTable.KEY_DATE, (String) mDateText.getText()); mTaskID = Integer.parseInt( getContentResolver() .insert(DBContract.TaskTable.CONTENT_URI, cv_task) .getLastPathSegment()); ContentValues cv_content = new ContentValues(); cv_content.put(DBContract.ContentTable.KEY_TASK, mTaskID); cv_content.put(DBContract.ContentTable.KEY_FAULT, ""); cv_content.put(DBContract.ContentTable.KEY_IMAGE, ""); for (String s : mArrayList) { cv_content.put(DBContract.ContentTable.KEY_PART, s); getContentResolver().insert(DBContract.ContentTable.CONTENT_URI, cv_content); } this.finish(); } break; } } else { ContentValues cv = new ContentValues(); switch (item.getItemId()) { case R.id.check: cv.put(DBContract.TaskTable.KEY_STATUS, 1); break; case R.id.uncheck: cv.put(DBContract.TaskTable.KEY_STATUS, 0); break; } getContentResolver() .update(DBContract.TaskTable.CONTENT_URI, cv, "_id=" + String.valueOf(mTaskID), null); this.finish(); } return true; }
@Nullable public static <T> T last(@NonNull final T[] objects) { return ListHelper.last(list(objects)); }
public static <T> boolean contains(@NonNull final T[] objects, @NonNull final T object) { return ListHelper.contains(list(objects), object); }