Android Open Source - AndroidSwipeLayout Cursor Swipe Adapter






From Project

Back to project page AndroidSwipeLayout.

License

The source code is released under:

MIT License

If you think the Android project AndroidSwipeLayout 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.daimajia.swipe.adapters;
//from www  .  ja v a 2 s .  com
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;

import java.util.List;

public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {

    private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);

    protected CursorSwipeAdapter(Context context, Cursor c, boolean autoRequery) {
        super(context, c, autoRequery);
    }

    protected CursorSwipeAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        boolean convertViewIsNull = convertView == null;
        View v = super.getView(position, convertView, parent);
        if(convertViewIsNull){
            mItemManger.initialize(v, position);
        }else{
            mItemManger.updateConvertView(v, position);
        }
        return v;
    }

    @Override
    public void openItem(int position) {
        mItemManger.openItem(position);
    }

    @Override
    public void closeItem(int position) {
        mItemManger.closeItem(position);
    }

    @Override
    public void closeAllExcept(SwipeLayout layout) {
        mItemManger.closeAllExcept(layout);
    }

    @Override
    public List<Integer> getOpenItems() {
        return mItemManger.getOpenItems();
    }

    @Override
    public List<SwipeLayout> getOpenLayouts() {
        return mItemManger.getOpenLayouts();
    }

    @Override
    public void removeShownLayouts(SwipeLayout layout) {
        mItemManger.removeShownLayouts(layout);
    }

    @Override
    public boolean isOpen(int position) {
        return mItemManger.isOpen(position);
    }

    @Override
    public SwipeItemMangerImpl.Mode getMode() {
        return mItemManger.getMode();
    }

    @Override
    public void setMode(SwipeItemMangerImpl.Mode mode) {
        mItemManger.setMode(mode);
    }
}




Java Source Code List

com.daimajia.swipe.SimpleSwipeListener.java
com.daimajia.swipe.SwipeLayout.java
com.daimajia.swipe.adapters.ArraySwipeAdapter.java
com.daimajia.swipe.adapters.BaseSwipeAdapter.java
com.daimajia.swipe.adapters.CursorSwipeAdapter.java
com.daimajia.swipe.adapters.SimpleCursorSwipeAdapter.java
com.daimajia.swipe.implments.SwipeItemMangerImpl.java
com.daimajia.swipe.interfaces.SwipeAdapterInterface.java
com.daimajia.swipe.interfaces.SwipeItemMangerInterface.java
com.daimajia.swipedemo.GridViewExample.java
com.daimajia.swipedemo.ListViewExample.java
com.daimajia.swipedemo.MyActivity.java
com.daimajia.swipedemo.NestedExample.java
com.daimajia.swipedemo.adapter.ArraySwipeAdapterSample.java
com.daimajia.swipedemo.adapter.GridViewAdapter.java
com.daimajia.swipedemo.adapter.ListViewAdapter.java