Android Open Source - androiDB Table Adapter






From Project

Back to project page androiDB.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project androiDB 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

/*
 *    Copyright 2010, Matthias Brandt/*w  w w.j a v  a  2  s  .c o m*/

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package de.splitstudio.androidb;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public abstract class TableAdapter<T extends Table> extends BaseAdapter {

  private final List<T> tables;

  private final int layout_id;

  public TableAdapter(List<T> tables, Context context, int layout_id) {
    this.tables = tables;
    this.layout_id = layout_id;
    Table.openOrCreateDB(context);
  }

  public int getCount() {
    return tables.size();
  }

  public T getItem(int index) {
    return tables.get(index);
  }

  public long getItemId(int index) {
    return getItem(index).getId();
  }

  public View getView(int position, View convertView, ViewGroup parent) {
    View v;
    if (convertView == null) {
      v = newView(position, parent);
    } else {
      v = convertView;
    }
    bindView(v, getItem(position));
    return v;
  }

  public abstract void bindView(final View view, final T table);

  public View newView(final int position, final ViewGroup parent) {
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View v = inflater.inflate(layout_id, parent, false);
    bindView(v, getItem(position));
    return v;
  }

}




Java Source Code List

de.splitstudio.androidb.Metadata.java
de.splitstudio.androidb.SqlType.java
de.splitstudio.androidb.TableAdapter.java
de.splitstudio.androidb.Table.java
de.splitstudio.androidb.TypeMapper.java
de.splitstudio.androidb.annotation.ColumnHelper.java
de.splitstudio.androidb.annotation.Column.java
de.splitstudio.androidb.annotation.TableMetaData.java
de.splitstudio.androidb.util.ReflectionHelper.java