Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. package com.example.secretsaver;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.view.View;
  7. import android.widget.AdapterView;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.ListView;
  11. import android.widget.SimpleAdapter;
  12. import android.widget.TextView;
  13. import android.widget.Toast;
  14. import java.util.HashMap;
  15.  
  16. public class MainActivity extends AppCompatActivity {
  17. TextView id;
  18.  
  19. Intent intent;
  20.  
  21. EditText password;
  22.  
  23. Button saveBtn;
  24.  
  25. EditText secret;
  26.  
  27. protected void onCreate(Bundle paramBundle) {
  28. super.onCreate(paramBundle);
  29. setContentView(2131296284);
  30. ((ListView)findViewById(2131165302)).setOnItemClickListener(new AdapterView.OnItemClickListener() {
  31. public void onItemClick(AdapterView<?> param1AdapterView, View param1View, int param1Int, long param1Long) {
  32. MainActivity mainActivity2 = MainActivity.this;
  33. mainActivity2.intent = new Intent(mainActivity2, DetailsActivity.class);
  34. String str = ((HashMap)param1AdapterView.getAdapter().getItem(param1Int)).get("id").toString();
  35. MainActivity.this.intent.putExtra("id", str);
  36. MainActivity mainActivity1 = MainActivity.this;
  37. mainActivity1.startActivity(mainActivity1.intent);
  38. }
  39. });
  40. DbHandler dbHandler = new DbHandler(this);
  41. dbHandler.deleteAll();
  42. dbHandler.insertRaw("7GfNMAzV9Q52dxEfH20hXheSWgEssLS6pzG+orQsuXXa+mGxQ6Lm/E4sMKPuDIG6");
  43. updateList();
  44. this.secret = (EditText)findViewById(2131165301);
  45. this.password = (EditText)findViewById(2131165279);
  46. this.id = (TextView)findViewById(2131165256);
  47. this.saveBtn = (Button)findViewById(2131165219);
  48. this.saveBtn.setOnClickListener(new View.OnClickListener() {
  49. public void onClick(View param1View) {
  50. String str1 = MainActivity.this.secret.getText().toString();
  51. String str2 = MainActivity.this.password.getText().toString();
  52. (new DbHandler(MainActivity.this)).insertSecret(str1, str2);
  53. Toast.makeText(MainActivity.this.getApplicationContext(), "Secret Saved Successfully", 0).show();
  54. MainActivity.this.updateList();
  55. }
  56. });
  57. }
  58.  
  59. protected void updateList() { ((ListView)findViewById(2131165302)).setAdapter(new SimpleAdapter(this, (new DbHandler(this)).getSecrets(), 2131296286, new String[] { "id", "secret" }, new int[] { 2131165256, 2131165301 })); }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement