Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.secretsaver;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ListView;
- import android.widget.SimpleAdapter;
- import android.widget.TextView;
- import android.widget.Toast;
- import java.util.HashMap;
- public class MainActivity extends AppCompatActivity {
- TextView id;
- Intent intent;
- EditText password;
- Button saveBtn;
- EditText secret;
- protected void onCreate(Bundle paramBundle) {
- super.onCreate(paramBundle);
- setContentView(2131296284);
- ((ListView)findViewById(2131165302)).setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> param1AdapterView, View param1View, int param1Int, long param1Long) {
- MainActivity mainActivity2 = MainActivity.this;
- mainActivity2.intent = new Intent(mainActivity2, DetailsActivity.class);
- String str = ((HashMap)param1AdapterView.getAdapter().getItem(param1Int)).get("id").toString();
- MainActivity.this.intent.putExtra("id", str);
- MainActivity mainActivity1 = MainActivity.this;
- mainActivity1.startActivity(mainActivity1.intent);
- }
- });
- DbHandler dbHandler = new DbHandler(this);
- dbHandler.deleteAll();
- dbHandler.insertRaw("7GfNMAzV9Q52dxEfH20hXheSWgEssLS6pzG+orQsuXXa+mGxQ6Lm/E4sMKPuDIG6");
- updateList();
- this.secret = (EditText)findViewById(2131165301);
- this.password = (EditText)findViewById(2131165279);
- this.id = (TextView)findViewById(2131165256);
- this.saveBtn = (Button)findViewById(2131165219);
- this.saveBtn.setOnClickListener(new View.OnClickListener() {
- public void onClick(View param1View) {
- String str1 = MainActivity.this.secret.getText().toString();
- String str2 = MainActivity.this.password.getText().toString();
- (new DbHandler(MainActivity.this)).insertSecret(str1, str2);
- Toast.makeText(MainActivity.this.getApplicationContext(), "Secret Saved Successfully", 0).show();
- MainActivity.this.updateList();
- }
- });
- }
- protected void updateList() { ((ListView)findViewById(2131165302)).setAdapter(new SimpleAdapter(this, (new DbHandler(this)).getSecrets(), 2131296286, new String[] { "id", "secret" }, new int[] { 2131165256, 2131165301 })); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement