@Override public void onClick(View inButton) { boolean isErr = false; if (mTitle.getText().toString().length() == 0) { mTitle.setError("Required"); mTitle.setEms(10); isErr = true; } if (mDesc.getText().toString().length() == 0) { mDesc.setActivated(true); mDesc.setError("Required"); isErr = true; } if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE); else if (inButton.getId() == mAvail.getId()) startActivity(new Intent(this, CheckActivity.class)); else if (inButton.getId() == mBack.getId()) finish(); else if (inButton.getId() == mSub.getId()) { AlertDialog.Builder al = new AlertDialog.Builder(this); if (isErr) return; else al.setTitle("Continue?") .setIcon(R.drawable.ornament) .setMessage("Your listing is going to be submitted to your chosen category.") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) { payment = new ArrayList<String>(); if (mCard.isChecked()) payment.add("Card"); if (mCheck.isChecked()) payment.add("Check"); if (mOnline.isChecked()) payment.add("Online"); if (mCash.isChecked()) payment.add("Cash"); // Toast.makeText(getApplicationContext(), payment.toString(), // Toast.LENGTH_LONG).show(); Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.putExtra("Payment", payment); intent.putExtra("Category", mChosenCategory); intent.putExtra("Title", mTitle.getText().toString()); intent.putExtra("Price", mPrice.getText().toString()); intent.putExtra("Description", mDesc.getText().toString()); intent.putExtra("Location", mLocation.getText().toString()); intent.putExtra("Photo", jpegData); startActivity(intent); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) {} }) .show(); } else startActivityForResult( new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(getResources().getColor(R.color.holo_blue_bright)); } listmain = new ArrayList<ConRecItem>(); tm = (EditText) findViewById(R.id.setext); final RecycleItemClickListener itemClickListener = new RecycleItemClickListener() { @Override public void onItemClick(View view, int position) { switch (position) { default: Intent intent = new Intent(searchActivity.this, conActivity.class); Data data = new Data(); File fl = new File("/storage/sdcard0/M++/data/slist.txt"); String spos = data.getData(fl, position + 1); int pos = Integer.valueOf(spos); intent.putExtra("pos", pos); startActivity(intent); break; } } }; int displayWidth = 0; int displayHeight = 0; DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); displayWidth = displayMetrics.widthPixels; displayHeight = displayMetrics.heightPixels; final int rpos = displayWidth / 320; listmain = new ArrayList<ConRecItem>(); ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler); recyclerView.setLayoutManager( new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL)); recyclerView.setAdapter(adapter); tm.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) { // TODO: Implement this method } @Override public void onTextChanged(CharSequence p1, int p2, int p3, int p4) { // TODO: Implement this method } @Override public void afterTextChanged(Editable edit) { // TODO listmain = new ArrayList<ConRecItem>(); System.out.println("okokok"); File fs = new File("/storage/sdcard0/M++/data/fs_con.txt"); File fl = new File("/storage/sdcard0/M++/data/slist.txt"); String text = tm.getText().toString(); if (fs.exists()) { listmain = new ArrayList<ConRecItem>(); if (fl.exists()) { fl.delete(); } try { fl.createNewFile(); String reg = ".*" + text + ".*"; FileReader fr = new FileReader(fs); BufferedReader br = new BufferedReader(fr); String temp = null; String s = ""; while ((temp = br.readLine()) != null) { s += temp + "\n"; } String[] ss = s.split("\n"); for (int i = 0; i <= ss.length; i++) { try { if (ss[10 * i].matches(reg)) { ConRecItem p = new ConRecItem(ss[10 * i + 1], ss[10 * i]); listmain.add(p); String spos = String.valueOf(i); Data data = new Data(); data.writeData(fl, spos + "\n", false); } } catch (ArrayIndexOutOfBoundsException e) { } } ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler); recyclerView.setLayoutManager( new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL)); recyclerView.setAdapter(adapter); } catch (Exception e) { e.printStackTrace(); } } }; }); }
public void onClick(View v) { ContentResolver cr = getContentResolver(); switch (v.getId()) { // 전부 읽기 case R.id.readall: Cursor cursor = cr.query(Uri.parse(WORDURI), null, null, null, null); String Result = ""; while (cursor.moveToNext()) { String eng = cursor.getString(0); String han = cursor.getString(1); Result += (eng + " = " + han + "\n"); } if (Result.length() == 0) { mText.setText("Empyt Set"); } else { mText.setText(Result); } cursor.close(); break; // 하나만 읽기 case R.id.readone: Cursor cursor2 = cr.query(Uri.parse(WORDURI + "/boy"), null, null, null, null); String Result2 = ""; if (cursor2.moveToFirst()) { String eng = cursor2.getString(0); String han = cursor2.getString(1); Result2 += (eng + " = " + han + "\n"); } if (Result2.length() == 0) { mText.setText("Empyt Set"); } else { mText.setText(Result2); } cursor2.close(); break; // 삽입 case R.id.insert: ContentValues row = new ContentValues(); row.put("eng", "school"); row.put("han", "학교"); cr.insert(Uri.parse(WORDURI), row); mText.setText("Insert Success"); break; // 삭제 case R.id.delete: cr.delete(Uri.parse(WORDURI), null, null); mText.setText("Delete Success"); break; // 수정 case R.id.update: ContentValues row2 = new ContentValues(); row2.put("han", "핵교"); cr.update(Uri.parse(WORDURI + "/school"), row2, null, null); mText.setText("Update Success"); break; } }