Android Open Source - dNote D M Memo List






From Project

Back to project page dNote.

License

The source code is released under:

GNU General Public License

If you think the Android project dNote 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.digutsoft.note.classes;
// www.j a va 2 s .  co  m
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.digutsoft.note.DMMemoView;
import com.digutsoft.note.R;

import java.util.ArrayList;

public class DMMemoList {
    public int mId;
    public String mMemoTitle, mMemoContent;
    public boolean mCheckedStatus;

    public DMMemoList(int id, String memoTitle, String memoContent, boolean checkedStatus) {
        mId = id;
        mMemoTitle = memoTitle;
        mMemoContent = memoContent;
        mCheckedStatus = checkedStatus;
    }

    public static class DMMemoListViewHolder {
        CheckBox checkBox;
        TextView textView;
    }

    public static class DMMemoListAdapter extends BaseAdapter {

        Context mContext;
        ArrayList<DMMemoList> alMemoList;

        SharedPreferences sharedPreferences;
        boolean isCheckboxEnabled;

        final int _8dp;

        public DMMemoListAdapter(Context mContext, ArrayList<DMMemoList> alMemoList) {
            this.mContext = mContext;
            this.alMemoList = alMemoList;

            sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
            isCheckboxEnabled = sharedPreferences.getBoolean("st_use_checklist", false);

            final float scale = mContext.getResources().getDisplayMetrics().density;
            _8dp = (int) (8 * scale + 0.5f);
        }

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

        @Override
        public Object getItem(int position) {
            return alMemoList.get(position);
        }

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

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            final DMMemoListViewHolder memoListViewHolder;
            if (convertView == null) {
                LayoutInflater layoutInflater = LayoutInflater.from(mContext);
                convertView = layoutInflater.inflate(R.layout.list_memo, parent, false);

                memoListViewHolder = new DMMemoListViewHolder();
                memoListViewHolder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox);
                memoListViewHolder.textView = (TextView) convertView.findViewById(R.id.textView);

                convertView.setTag(memoListViewHolder);
            } else {
                memoListViewHolder = (DMMemoListViewHolder) convertView.getTag();
            }

            DMMemoList list = alMemoList.get(position);

            if (list != null) {
                if (isCheckboxEnabled) {
                    memoListViewHolder.checkBox.setChecked(alMemoList.get(position).mCheckedStatus);
                    memoListViewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                            DMMemoTools.checkMemo(mContext, DMMemoView.mCategoryName, DMMemoView.getMemoId(position), b);
                        }
                    });
                } else {
                    memoListViewHolder.checkBox.setVisibility(View.GONE);
                    memoListViewHolder.textView.setPadding(_8dp, 0, _8dp, 0);
                }
                memoListViewHolder.textView.setText(alMemoList.get(position).mMemoTitle);
            }

            return convertView;
        }
    }
}




Java Source Code List

android.support.v4.preference.PreferenceFragment.java
android.support.v4.preference.PreferenceManagerCompat.java
android.support.v4.preferencefragment.BuildConfig.java
android.support.v4.preferencefragment.BuildConfig.java
com.digutsoft.note.DMCategoryManager.java
com.digutsoft.note.DMMain.java
com.digutsoft.note.DMMemoView.java
com.digutsoft.note.DMNewNote.java
com.digutsoft.note.DMSaveFromWear.java
com.digutsoft.note.DMSaveFrom.java
com.digutsoft.note.DMSettingsFragment.java
com.digutsoft.note.DMSettings.java
com.digutsoft.note.DMSplash.java
com.digutsoft.note.DMWearVoiceAction.java
com.digutsoft.note.DrawerMenuList.java
com.digutsoft.note.NavigationDrawerFragment.java
com.digutsoft.note.classes.DMDatabaseHelper.java
com.digutsoft.note.classes.DMMemoList.java
com.digutsoft.note.classes.DMMemoTools.java