Android Open Source - KeepMySecret Entry Present Fragment






From Project

Back to project page KeepMySecret.

License

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.

Java Source Code

package keepmysecretapp.app.com.keepmysecretapp.fragments.presentation;
/* w ww .j ava2 s .c o  m*/
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import keepmysecretapp.app.com.keepmysecretapp.R;
import keepmysecretapp.app.com.keepmysecretapp.activities.creation.CreateNewEntryActivity;
import keepmysecretapp.app.com.keepmysecretapp.adapters.DataEntryAdapter;
import keepmysecretapp.app.com.keepmysecretapp.dao.Dao;
import keepmysecretapp.app.com.keepmysecretapp.dao.EntryDao;
import keepmysecretapp.app.com.keepmysecretapp.db.DbContext;
import keepmysecretapp.app.com.keepmysecretapp.db.EntryType;
import keepmysecretapp.app.com.keepmysecretapp.other.Constants;
import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry;

public class EntryPresentFragment extends Fragment {

    private ListView entriesList;
    private Button createEntryButton;
    private static String tag = "entryPresent";
    private static ListEntry parent;

    public static EntryPresentFragment newInstance(ListEntry entry) {
        EntryPresentFragment.parent = entry;
        parent = entry;
        Log.d(tag, "Current parrent: " + parent);
        EntryPresentFragment fragment = new EntryPresentFragment();
        return fragment;
    }

    public EntryPresentFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable
    ViewGroup container, @Nullable Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_present_entries, container, false);
        ArrayList<ListEntry> entries = getEntryList();

        entriesList = (ListView) rootView.findViewById(R.id.EntriesList);
        entriesList.setAdapter(new DataEntryAdapter(getActivity(), entries, parent));

        createEntryButton = (Button) rootView.findViewById(R.id.addEntryButton);
        initListener(createEntryButton);

        return rootView;
    }

    private void initListener(Button button) {

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent toCreate = new Intent(getActivity(), CreateNewEntryActivity.class);
                toCreate.putExtra(Constants.ENTRY_TYPE, EntryType.DATA.getName());
                toCreate.putExtra(Constants.ARG_PARENT_NAME, parent.getName());
                startActivity(toCreate);
            }
        });
    }

    public ArrayList<ListEntry> getEntryList() {

        DbContext dbContext = DbContext.getInstance(getActivity());
        Dao dao = new EntryDao(dbContext, parent.getID());

        ArrayList<ListEntry> retList = new ArrayList<ListEntry>();

        List<Object> entries = dao.getAllEntries();

        for (Object entry : entries) {
            retList.add((ListEntry) entry);
        }

        return retList;
    }
}




Java Source Code List

keepmysecretapp.app.com.keepmysecretapp.ApplicationTest.java
keepmysecretapp.app.com.keepmysecretapp.activities.MainActivity.java
keepmysecretapp.app.com.keepmysecretapp.activities.creation.CreateNewEntryActivity.java
keepmysecretapp.app.com.keepmysecretapp.activities.edit.EditEntryActivity.java
keepmysecretapp.app.com.keepmysecretapp.activities.presentation.EntryPresentActivity.java
keepmysecretapp.app.com.keepmysecretapp.adapters.DataEntryAdapter.java
keepmysecretapp.app.com.keepmysecretapp.adapters.GroupEntryAdapter.java
keepmysecretapp.app.com.keepmysecretapp.dao.Dao.java
keepmysecretapp.app.com.keepmysecretapp.dao.EntryDao.java
keepmysecretapp.app.com.keepmysecretapp.dao.GroupDao.java
keepmysecretapp.app.com.keepmysecretapp.db.DbContext.java
keepmysecretapp.app.com.keepmysecretapp.db.EntryType.java
keepmysecretapp.app.com.keepmysecretapp.fragments.creation.CreateDataEntryFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.creation.CreateGroupFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.dialogs.GeneratePasswordDialog.java
keepmysecretapp.app.com.keepmysecretapp.fragments.edit.EditDataFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.edit.EditGroupFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.other.NavigationDrawerFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.other.SideLogic.java
keepmysecretapp.app.com.keepmysecretapp.fragments.presentation.EntryPresentFragment.java
keepmysecretapp.app.com.keepmysecretapp.fragments.presentation.TextKeeperFragment.java
keepmysecretapp.app.com.keepmysecretapp.other.Constants.java
keepmysecretapp.app.com.keepmysecretapp.other.Tools.java
keepmysecretapp.app.com.keepmysecretapp.tables.AuthTable.java
keepmysecretapp.app.com.keepmysecretapp.tables.DataTable.java
keepmysecretapp.app.com.keepmysecretapp.tables.GroupTable.java
keepmysecretapp.app.com.keepmysecretapp.tables.QueryTable.java
keepmysecretapp.app.com.keepmysecretapp.types.CopyTextButtonListener.java
keepmysecretapp.app.com.keepmysecretapp.types.GenerateButtonListener.java
keepmysecretapp.app.com.keepmysecretapp.types.ListEntry.java