Back to project page KeepMySecret.
The source code is released under:
GNU General Public License
If you think the Android project KeepMySecret listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package keepmysecretapp.app.com.keepmysecretapp.activities.creation; /* w ww .java 2s .c om*/ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.util.Log; import android.view.View; import android.widget.ImageView; import keepmysecretapp.app.com.keepmysecretapp.R; import keepmysecretapp.app.com.keepmysecretapp.activities.MainActivity; import keepmysecretapp.app.com.keepmysecretapp.activities.presentation.EntryPresentActivity; import keepmysecretapp.app.com.keepmysecretapp.dao.Dao; import keepmysecretapp.app.com.keepmysecretapp.dao.GroupDao; import keepmysecretapp.app.com.keepmysecretapp.db.DbContext; import keepmysecretapp.app.com.keepmysecretapp.db.EntryType; import keepmysecretapp.app.com.keepmysecretapp.fragments.creation.CreateDataEntryFragment; import keepmysecretapp.app.com.keepmysecretapp.fragments.creation.CreateGroupFragment; import keepmysecretapp.app.com.keepmysecretapp.other.Constants; import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry; public class CreateNewEntryActivity extends FragmentActivity { private static final String tag = "CreateNewEntryActivity"; private ImageView mBackButton; private ListEntry currentParentGroupEntry; private String actionType; private String groupName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create); mBackButton = (ImageView) findViewById(R.id.toMainActivityButton); actionType = getIntent().getStringExtra(Constants.ENTRY_TYPE); if (actionType.equals(EntryType.GROUPS.getName())) { getBackButtonListenerGroup(mBackButton); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container_create_activity, new CreateGroupFragment()).commit(); } if (actionType.equals(EntryType.DATA.getName())) { groupName = getIntent().getStringExtra(Constants.ARG_PARENT_NAME); DbContext context = DbContext.getInstance(CreateNewEntryActivity.this); Dao dao = new GroupDao(context); ListEntry entry = new ListEntry(); entry.setName(groupName); currentParentGroupEntry = (ListEntry) dao.read(entry); Log.d("currentParentGroupEntry", currentParentGroupEntry.toString()); getBackButtonListenerData(mBackButton); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.container_create_activity, CreateDataEntryFragment.newInstance(groupName)).commit(); } } private void getBackButtonListenerGroup(ImageView button) { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent toMain = new Intent(CreateNewEntryActivity.this, MainActivity.class); startActivity(toMain); } }); } private void getBackButtonListenerData(ImageView button) { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent toEntries = new Intent(CreateNewEntryActivity.this, EntryPresentActivity.class); toEntries.putExtra(Constants.ENTRY_TITLE, currentParentGroupEntry.getName()); toEntries.putExtra(Constants.ENTRY_TYPE, EntryType.DATA.getName()); toEntries.putExtra(Constants.ENTRY_ID, currentParentGroupEntry.getID()); startActivity(toEntries); } }); } }