Android Open Source - KeepMySecret Data Entry Adapter






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.adapters;
/* ww w. j  a va2 s.  c o  m*/
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import keepmysecretapp.app.com.keepmysecretapp.R;
import keepmysecretapp.app.com.keepmysecretapp.activities.edit.EditEntryActivity;
import keepmysecretapp.app.com.keepmysecretapp.db.EntryType;
import keepmysecretapp.app.com.keepmysecretapp.other.Constants;
import keepmysecretapp.app.com.keepmysecretapp.tables.DataTable;
import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry;

public class DataEntryAdapter extends BaseAdapter {

    private static ArrayList<ListEntry> listDataEntries;

    private LayoutInflater mInflater;
    private Context context;
    ListEntry parent;

    public DataEntryAdapter(Context groupsFragment, ArrayList entriesList, ListEntry parent) {
        this.parent = parent;
        listDataEntries = entriesList;
        context = groupsFragment;
        mInflater = LayoutInflater.from(groupsFragment);
    }

    @Override
    public int getCount() {
        if (listDataEntries != null)
            return listDataEntries.size();

        return 0;
    }

    @Override
    public Object getItem(int position) {
        if (listDataEntries != null)
            return listDataEntries.get(position);
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.entry_item, null);
            holder = new ViewHolder();
            holder.name = (TextView) convertView.findViewById(R.id.textEntryName);
            holder.describe = (TextView)convertView.findViewById(R.id.entryDescribe);
            holder.groupID = (TextView)convertView.findViewById(R.id.entry_id_hidden);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.name.setText(listDataEntries.get(position).getName());
        holder.describe.setText(listDataEntries.get(position).getDescribe());
        holder.groupID.setText(listDataEntries.get(position).getGroupID() + "");

        setDataEntryListener(convertView, listDataEntries.get(position));

        return convertView;
    }

    private void setDataEntryListener(View view, final ListEntry entry) {

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent toEntry = new Intent(context, EditEntryActivity.class);
                toEntry.putExtra(Constants.ENTRY_TYPE, EntryType.DATA.getName());

                toEntry.putExtra(Constants.ARG_PARENT_NAME, parent.getName());
                toEntry.putExtra(Constants.ARG_PARENT_ID, parent.getID());

                toEntry.putExtra(DataTable.KEY_ID, entry.getID());
                toEntry.putExtra(DataTable.KEY_ENTRY_NAME, entry.getName());
                toEntry.putExtra(DataTable.KEY_ENTRY_PASSWORD, entry.getPassword());
                toEntry.putExtra(DataTable.KEY_ENTRY_DESCRIBE, entry.getDescribe());
                toEntry.putExtra(DataTable.KEY_ENTRY_GROUP_ID, entry.getGroupID());
                toEntry.putExtra(Constants.ENTRY_TITLE, entry.getName());

                context.startActivity(toEntry);
            }
        });

    }

    public static class ViewHolder {
        TextView name;
        TextView describe;
        TextView groupID;
    }

}




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