Android Open Source - KeepMySecret Group 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;
//w  w  w.j a  v  a  2s .co 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.presentation.EntryPresentActivity;
import keepmysecretapp.app.com.keepmysecretapp.db.EntryType;
import keepmysecretapp.app.com.keepmysecretapp.other.Constants;
import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry;

public class GroupEntryAdapter extends BaseAdapter {
    private static ArrayList<ListEntry> listGroupEntries;

    private LayoutInflater mInflater;
    private Context context;

    public GroupEntryAdapter(Context groupsFragment, ArrayList groupList) {
        listGroupEntries = groupList;
        context = groupsFragment;
        mInflater = LayoutInflater.from(groupsFragment);
    }

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

        return 0;
    }

    @Override
    public Object getItem(int position) {
        if (listGroupEntries != null)
            return listGroupEntries.get(0);
        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.id = (TextView)convertView.findViewById(R.id.entry_id_hidden);
            holder.describe = (TextView)convertView.findViewById(R.id.entryDescribe);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.name.setText(listGroupEntries.get(position).getName());
        holder.describe.setText(listGroupEntries.get(position).getDescribe());
        holder.id.setText(listGroupEntries.get(position).getID() + "");
        setGroupEntryListener(convertView, holder.name.getText().toString(), Integer.parseInt(holder.id.getText().toString()));

        return convertView;
    }

    private void setGroupEntryListener(View view, final String entryName, final int id) {

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent toEntry = new Intent(context, EntryPresentActivity.class);
                toEntry.putExtra(Constants.ENTRY_TITLE, entryName);
                toEntry.putExtra(Constants.ENTRY_ID, id);
                toEntry.putExtra(Constants.ENTRY_TYPE, EntryType.DATA.toString());
                context.startActivity(toEntry);
            }
        });

    }

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

}




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