Android Open Source - treedo Item Adapter






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;
/*  w  ww  .j  av a  2  s  . co m*/
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by martin on 1/3/15.
 */
public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> {
    private final Context mContext;
    private Item mItem;
    OnFolderClickedListener mOnFolderClickedListener;
    private boolean mGrabable;

    public ItemAdapter(Context context, Item item) {
        mItem = item;
        mContext = context;
    }

    public void setOnFolderClickedListener(OnFolderClickedListener onFolderClickedListener) {
        mOnFolderClickedListener = onFolderClickedListener;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public ItemView2 mItemView;
        public ViewHolder(ItemView2 itemView) {
            super(itemView);
            mItemView = itemView;
        }
    }
    @Override
    public ItemAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemView2 itemView = (ItemView2)LayoutInflater.from(mContext).inflate(R.layout.item_view_2, null);
        return new ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final ItemAdapter.ViewHolder holder, int position) {
        Item item = mItem.children.get(position);
        holder.mItemView.cancelTranslation();
        holder.mItemView.setItem(item);
        holder.mItemView.setGrabable(mGrabable);
        holder.mItemView.setListener(new ItemView2.Listener() {

            @Override
            public void onArrowClicked() {
                mOnFolderClickedListener.onFolderClicked(holder.mItemView.getItem());
            }
        });

    }

    @Override
    public int getItemCount() {
        return mItem.children.size();
    }

    public void add(Item item) {
        mItem.children.add(item);
        notifyDataSetChanged();
    }

    public abstract static class OnFolderClickedListener {
        public abstract void onFolderClicked(Item item);
    }

    public void setGrablable(boolean grabable) {
        mGrabable = grabable;
        notifyDataSetChanged();
    }
}




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