recycleしすぎてた?
[ofnhwx.olib.git] / src / jp / gr / java_conf / ofnhwx / olib / base / BaseCursorAdapter.java
blob2296efc155eb0d4a29701ab5022b115cdd312cce
1 package jp.gr.java_conf.ofnhwx.olib.base;
3 import android.content.Context;
4 import android.database.Cursor;
5 import android.support.v4.widget.SimpleCursorAdapter;
6 import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
8 /**
9 * {@link SimpleCursorAdapter}のもと.
10 * <table>
11 * <tr><td>・コンストラクタで{@link #setViewBinder(ViewBinder)}の実行</td></tr>
12 * <tr><td>・{@link #swapCursor(Cursor)}で{@link #onSetColumns(Cursor)}を呼出し</td></tr>
13 * </table>
14 * @author yuta
16 public abstract class BaseCursorAdapter extends SimpleCursorAdapter implements ViewBinder {
18 /**
19 * {@link #swapCursor(Cursor)}から呼出し.項目の列取得などが可能.
20 * @param c 新しいカーソル.
22 protected abstract void onSetColumns(Cursor c);
24 public BaseCursorAdapter(Context context, int layout, String[] from, int[] to, int flags) {
25 super(context, layout, null, from, to, flags);
26 setViewBinder(this);
29 @Override
30 public Cursor swapCursor(Cursor c) {
31 if (c == null) {
32 return super.swapCursor(c);
33 } else {
34 Cursor result = super.swapCursor(c);
35 onSetColumns(c);
36 return result;