package fr.nelaupe.spreedsheet;

import android.app.Activity;
import android.os.Bundle;

import org.fluttercode.datafactory.impl.DataFactory;

import fr.nelaupe.spreadsheetlib.SpreadSheetView;

public class MainActivity extends Activity {

    private long start;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        start = System.currentTimeMillis();

        setContentView(R.layout.activity_main);

        SpreadSheetView spreadSheetView = (SpreadSheetView) findViewById(R.id.spread_sheet);
        initSpreadSheet(spreadSheetView);
        spreadSheetView.invalidate();
    }

    protected void initSpreadSheet(SpreadSheetView spreadSheetView) {
        for (int i = 0; i < 30; i++) {
            spreadSheetView.getAdaptor().add(generateDummyData(i));
        }
    }

    protected Person generateDummyData(int i) {
        return new Person(i, new DataFactory());
    }

    @Override
    protected void onResume() {
        super.onResume();

        long diff = System.currentTimeMillis() - start;
        System.out.println("TIME TO LOAD : " + diff);
    }

}

@@ -74,73 +74,387 @@
 oid.
-os.Bundle;%0A%0Aimport org.fluttercode.datafactory.impl.DataFactory;%0A
+content.Context;%0Aimport android.os.Bundle;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.widget.CheckBox;%0Aimport android.widget.TextView;%0A%0Aimport org.fluttercode.datafactory.impl.DataFactory;%0A%0Aimport fr.nelaupe.spreadsheetlib.AnnotationFields;%0Aimport fr.nelaupe.spreadsheetlib.SimpleTextAdaptor;%0Aimport fr.nelaupe.spreadsheetlib.SpreadSheetAdaptor;
 %0Aimp
@@ -874,24 +874,25 @@
 sheet);%0A
+%0A
         
 initSpre
@@ -887,156 +887,133 @@
     
-initSpreadSheet(spreadSheetView);%0A        spreadSheetView.invalidate();%0A    %7D%0A%0A    protected void initSpreadSheet(SpreadSheetView spreadSheetView) %7B
+PersonAdaptor personAdaptor = new PersonAdaptor(this);%0A        spreadSheetView.setAdaptor(personAdaptor.with(Person.class));%0A
 %0A   
@@ -1125,16 +1125,55 @@
        %7D
+%0A%0A        spreadSheetView.invalidate();
 %0A    %7D%0A%0A
@@ -1178,23 +1178,21 @@
 %0A%0A    pr
-otec
+iva
 te
-d
  Person 
@@ -1464,10 +1464,1053 @@
 %0A    %7D%0A%0A
+    private View inflateTextView(String text) %7B%0A        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);%0A        View view = inflater.inflate(R.layout.cell_textview, null, false);%0A%0A        TextView textView = (TextView) view.findViewById(R.id.text);%0A        textView.setText(text);%0A%0A        return view;%0A    %7D%0A%0A    private View inflateCheckbox(Boolean bool) %7B%0A        CheckBox checkBox = new CheckBox(MainActivity.this);%0A        checkBox.setChecked(bool);%0A        checkBox.setEnabled(false);%0A        return checkBox;%0A    %7D%0A%0A    private class PersonAdaptor extends SimpleTextAdaptor%3CPerson%3E %7B%0A%0A        public PersonAdaptor(Context context) %7B%0A            super(context);%0A        %7D%0A%0A        @Override%0A        public View getCellView(AnnotationFields cell, Object object) %7B%0A            if (object.getClass().equals(Boolean.class)) %7B%0A                return inflateCheckbox((Boolean) object);%0A            %7D else %7B%0A                return inflateTextView(object.toString());%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Update example with custom adaptor