Android Open Source - KnowledgeBase Edit Activity






From Project

Back to project page KnowledgeBase.

License

The source code is released under:

MIT License

If you think the Android project KnowledgeBase listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.martin.knowledgebase;
/*from   w  ww . j a  v  a  2  s  .  c om*/
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.RelativeLayout;

import java.util.ArrayList;


public class EditActivity extends Activity {

    private EditText mTitle, mText;
    private Snackbar mSnackbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);
        mTitle = (EditText) findViewById(R.id.etTitle);
        mText = (EditText) findViewById(R.id.etText);
        mSnackbar = new Snackbar((RelativeLayout) findViewById(R.id.snackbar), "Title and/or text missing", this);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_edit, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_done) {
            if (!mTitle.getText().toString().contentEquals("") && !mText.getText().toString().contentEquals("")) {
                ArrayList<Entry> entries = PlainStorage.getInstance().getmEntries();
                entries.add(new Entry(mTitle.getText().toString(), mText.getText().toString(), Util.getCurrentDate()));
                PlainStorage.getInstance().setmEntries(entries);
                finish();
            } else {
                mSnackbar.show();
            }
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

com.martin.knowledgebase.ConversionTest.java
com.martin.knowledgebase.EditActivity.java
com.martin.knowledgebase.EncryptionTest.java
com.martin.knowledgebase.EntryTest.java
com.martin.knowledgebase.Entry.java
com.martin.knowledgebase.LoginActivity.java
com.martin.knowledgebase.MainActivity.java
com.martin.knowledgebase.PlainStorage.java
com.martin.knowledgebase.Snackbar.java
com.martin.knowledgebase.Util.java
com.tozny.crypto.android.AesCbcWithIntegrity.java