Android Open Source - SecNote Note Adapter






From Project

Back to project page SecNote.

License

The source code is released under:

Apache License

If you think the Android project SecNote 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 com.baraccasoftware.securenotes.widget;
/*from   w ww.  j a v  a  2 s  .c  om*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.baraccasoftware.securenotes.app.R;
import com.baraccasoftware.securenotes.object.ImageLoader;
import com.baraccasoftware.securenotes.object.Note;

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

/**
 * Created by angelo on 24/02/14.
 */
public class NoteAdapter extends BaseAdapter {

    private class ViewHolder{
        public TextView nome;
        public TextView desc;
        public ImageView image;
    }

    private Context mContext;
    private ArrayList<Note> mData;
    private LayoutInflater mLayoutInflater;
    private ViewHolder mViewHolder;
    ImageLoader mImgLoader;

    public NoteAdapter(Context context, ArrayList<Note> data) {
        this.mData = data;
        this.mContext = context;
        this.mLayoutInflater = (LayoutInflater)
                this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.mImgLoader = new ImageLoader(mContext);

    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

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

    public int getItemId(Object item){
        return mData.indexOf(item);
    }

    public void addItem(Object item){
        mData.add((Note)item);
    }

    public void addItem(int id,Object item){
        mData.add(id,(Note)item);
    }

    public void removeItem(Object item){
        mData.remove(item);

    }

    public void removeItem(int position){
        mData.remove(mData.get(position));

    }

    public  void addAll(List<Note> notes){
        mData.addAll(notes);
    }

    public ArrayList<Note> getAllNotes(){
        return mData;
    }




    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        mViewHolder = null;
        Note note = (Note) getItem(i);
        //get Texts
        String title = note.getmName();
        String text = note.getmDesc();
        //check if only image
        boolean onlyImage = title.equals("") && text.equals("");
        //check if there is image
        boolean isImage = note.getmImage().length > 1;
        mViewHolder = new ViewHolder();
        if(isImage) {

            if(onlyImage){
                //solo img
                view = mLayoutInflater.inflate(R.layout.layout_note_only_img, null);

            }else{
                view = mLayoutInflater.inflate(R.layout.layout_note_img_text, null);
                mViewHolder.nome = (TextView) view.findViewById(R.id.textView_Nome);
                mViewHolder.desc = (TextView) view.findViewById(R.id.textView_Desc);
                setText(note);
            }

            mViewHolder.image = (ImageView) view.findViewById(R.id.imageView1_listnotes);
            mImgLoader.loadBitmap(note, mViewHolder.image,onlyImage);
            view.setTag(mViewHolder);


        }else{
            view = mLayoutInflater.inflate(R.layout.layout_note_text, null);
            mViewHolder.nome = (TextView) view.findViewById(R.id.textView_Nome);
            mViewHolder.desc = (TextView) view.findViewById(R.id.textView_Desc);
            setText(note);
            view.setTag(mViewHolder);

        }
        return view;
    }

    private void setText(Note note){
        mViewHolder.nome.setText(note.getmName());
        if(note.getmName().equals("") && !note.getmDesc().equals("")){
            mViewHolder.nome.setText(note.getmDesc());
        }else{
            mViewHolder.desc.setText(note.getmDesc());
        }
    }
}




Java Source Code List

com.baraccasoftware.securenotes.app.ExportDialogFragment.java
com.baraccasoftware.securenotes.app.ImportDialogFragment.java
com.baraccasoftware.securenotes.app.InfoActivity.java
com.baraccasoftware.securenotes.app.InfoFragment.java
com.baraccasoftware.securenotes.app.LockedAppFragment.java
com.baraccasoftware.securenotes.app.LogInFragment.java
com.baraccasoftware.securenotes.app.MainActivity.java
com.baraccasoftware.securenotes.app.NoteDetailActivity.java
com.baraccasoftware.securenotes.app.NoteDetailFragment.java
com.baraccasoftware.securenotes.app.NoteListActivity.java
com.baraccasoftware.securenotes.app.NoteListFragment.java
com.baraccasoftware.securenotes.app.RegisterFragment.java
com.baraccasoftware.securenotes.app.SetPasswordFragment.java
com.baraccasoftware.securenotes.app.SettingsActivity.java
com.baraccasoftware.securenotes.app.SettingsFragment.java
com.baraccasoftware.securenotes.exception.LoadBitmapException.java
com.baraccasoftware.securenotes.object.ActivityUtilityInterface.java
com.baraccasoftware.securenotes.object.BitmapUtility.java
com.baraccasoftware.securenotes.object.Crypto.java
com.baraccasoftware.securenotes.object.DAO.java
com.baraccasoftware.securenotes.object.Encryptor.java
com.baraccasoftware.securenotes.object.ImageLoader.java
com.baraccasoftware.securenotes.object.NoteUtility.java
com.baraccasoftware.securenotes.object.Note.java
com.baraccasoftware.securenotes.object.PBKDF2Encryptor.java
com.baraccasoftware.securenotes.object.PasswordPreference.java
com.baraccasoftware.securenotes.object.SecureDatabaseHelper.java
com.baraccasoftware.securenotes.widget.NoteAdapter.java
com.baraccasoftware.securenotes.widget.SlidingDrawer.java
com.baraccasoftware.securenotes.widget.SwipeDismissListViewTouchListener.java
com.baraccasoftware.securenotes.widget.UndoBarController.java