Android Open Source - treedo Item View2






From Project

Back to project page treedo.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Everyone is permitted to copy and distribute verbatim or modified copies of this license document, ...

If you think the Android project treedo 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.mbonnin.treedo;
/*from  ww  w . jav  a2 s .  c o m*/
import android.content.Context;
import android.media.Image;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.ImageView;

/**
 * Created by martin on 1/3/15.
 */
public class ItemView2 extends FrameLayout {
    private static final String TAG = "ItemView2";
    private Item mItem;
    public ImageView mHandle;
    public CheckBox mCheckBox;
    public ImageView mFolder;
    public ItemEditText mEditText;
    public ImageView mArrow;
    private Listener mListener;

    public ItemView2(Context context) {
        super(context);
    }

    public ItemView2(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ItemView2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mHandle = (ImageView)findViewById(R.id.handle);
        mCheckBox = (CheckBox)findViewById(R.id.checkbox);
        mFolder = (ImageView)findViewById(R.id.folder);
        mEditText = (ItemEditText)findViewById(R.id.edit_text);
        mArrow = (ImageView)findViewById(R.id.arrow);
    }

    public void cancelTranslation() {
        Log.e(TAG, "cancelTranslation is not implemented");
    }

    public void setItem(Item item) {
        this.mItem = item;
        if (item.isAFolder) {
            mCheckBox.setVisibility(GONE);
            mFolder.setVisibility(VISIBLE);
            if (item.isTrash) {
                mFolder.setImageResource(R.drawable.trash);
            } else {
                mFolder.setImageResource(R.drawable.folder);
            }
            mArrow.setVisibility(VISIBLE);
            mEditText.setFocusable(false);

            setClickable(true);
            setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mListener.onArrowClicked();
                }
            });
        } else {
            mCheckBox.setVisibility(VISIBLE);
            mCheckBox.setChecked(item.checked);
            mFolder.setVisibility(GONE);
            mArrow.setVisibility(GONE);
            mEditText.setFocusable(true);

            setClickable(false);
            setOnClickListener(null);
        }
        mEditText.setText(item.text);
    }

    public void setListener(Listener listener) {
        mListener = listener;
    }

    public Item getItem() {
        return mItem;
    }

    public void setGrabable(boolean grabable) {
        mHandle.setVisibility(grabable ? View.VISIBLE : View.GONE);
    }

    public abstract static class Listener {
        public abstract void onArrowClicked();
    }
}




Java Source Code List

com.mbonnin.treedo.ApplicationTest.java
com.mbonnin.treedo.BackupAdapter.java
com.mbonnin.treedo.BackupManager.java
com.mbonnin.treedo.Database.java
com.mbonnin.treedo.DialogBuilder.java
com.mbonnin.treedo.ItemAdapter.java
com.mbonnin.treedo.ItemDecorator.java
com.mbonnin.treedo.ItemEditText.java
com.mbonnin.treedo.ItemListView.java
com.mbonnin.treedo.ItemView2.java
com.mbonnin.treedo.ItemView.java
com.mbonnin.treedo.Item.java
com.mbonnin.treedo.MainActivity.java
com.mbonnin.treedo.ObservableScrollView.java
com.mbonnin.treedo.ProgressBar.java
com.mbonnin.treedo.SpacerView.java
com.mbonnin.treedo.TypeSpinnerAdapter.java
com.mbonnin.treedo.Utils.java