private CustomEngine getData() { CustomEngine data = new CustomEngine(); data.setName(mEditTextName.getText().toString()); data.setUpload_url(mEditTextUrl.getText().toString()); data.setPost_file_key(mEditTextFileKey.getText().toString()); data.setResult_open_action(mSpinner.getSelectedItemPosition()); if (!URLUtil.isNetworkUrl(data.getUpload_url())) { data.setUpload_url("http://" + data.getUpload_url()); } data.post_text_key.clear(); data.post_text_value.clear(); data.post_text_type.clear(); for (int i = 0; i < mRecyclerView.getChildCount(); i++) { View view = mRecyclerView.getChildAt(i); if (view == null) continue; EditText key = (EditText) view.findViewById(R.id.editText_key); EditText value = (EditText) view.findViewById(R.id.editText_value); if (key != null && value != null) { data.post_text_key.add(key.getEditableText().toString()); data.post_text_value.add(value.getEditableText().toString()); data.post_text_type.add(0); } } return data; }
private void modify() { SQLiteDatabase db = mDbHelper.getReadableDatabase(); CustomEngineParcelable parcelable = new CustomEngineParcelable(); parcelable.data = getData(); ContentValues values = new ContentValues(); values.put(CustomEngineTable.COLUMN_DATA, ParcelableUtils.marshall(parcelable)); String selection = CustomEngineTable.COLUMN_ID + " LIKE ?"; String[] selectionArgs = {String.valueOf(mItem.getId())}; db.update(CustomEngineTable.TABLE_NAME, values, selection, selectionArgs); mItem.setName(parcelable.data.getName()); mItem.setUpload_url(parcelable.data.getUpload_url()); mItem.setPost_file_key(parcelable.data.getPost_file_key()); mItem.setResult_open_action(parcelable.data.getResult_open_action()); mItem.post_text_key = parcelable.data.post_text_key; mItem.post_text_value = parcelable.data.post_text_value; mItem.post_text_type = parcelable.data.post_text_type; EditSitesActivity.getAdapter(this).notifyItemChanged(mLocation); }