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.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; } }