I'm writing a custom list field, but it doesn't not work when i invoke invalidate method. The screen is always empty, while the data of list field is not null or empty!
Please help me figure out the problem.
Thank you in advance
public class FileListField extends ListField implements ListFieldCallback{
private static final Bitmap fileBitmap = Bitmap.getBitmapResource("document.png");
private static final Bitmap dirBitmap = Bitmap.getBitmapResource("emty_folder.png");
private static final Bitmap addBitmap = Bitmap.getBitmapResource("svn_added.png");
private static final Bitmap delBitmap = Bitmap.getBitmapResource("svn_deleted.png");
private static final Bitmap modBitmap = Bitmap.getBitmapResource("svn_modified.png");
private static final Bitmap novBitmap = Bitmap.getBitmapResource("svn_noversion.png");
private static final Bitmap norBitmap = Bitmap.getBitmapResource("svn_normal.png");
//static Bitmap dowBitmap = Bitmap.getBitmapResource("svn_added.png");
private BigVector bv;
public FileListField(){
super();
bv = new BigVector();
setCallback(this);
}
public void setFileModelVector(BigVector fileModelVector){
bv.removeAll();
bv.addElements(fileModelVector.getContiguousArray());
invalidate();
System.out.println("ISSSSSSSSSSSSSS CALLLLLLLLLLINNNNNNNG?");
System.out.println("DISSSPATH?"+UiApplication.isEventDispatchThread());
// invalidateRange(0, bv.size()-1);
// FileModel[] fileModelArr = new FileModel[fileModelVector.size()];
// for(int i=0;i<fileModelVector.size();i++)
// fileModelArr[i] = (FileModel)fileModelVector.elementAt(i);
// set(fileModelArr);
}
public BigVector getFileModelVector(){
// BigVector bv = new BigVector();
// for(int i=0;i<this.getSize();i++)
// bv.addElement(get(this, i));
return bv;
}
public void set(Object[] or){
}
public Object get(ListField list, int index){
return bv.elementAt(index);
}
public int getSize(){
return bv.size();
}
public int indexOfList(ListField listField, String prefix, int start) {
return getSelectedIndex();
}
public int getPreferredWidth(ListField listField) {
return Display.getWidth();
}
public void drawListRow(ListField listField, Graphics graphics
, int index, int y, int width){
System.out.println("DRWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
FileModel fileModel = (FileModel)get(listField, index);
if(fileModel.isFile())
graphics.drawBitmap(0, y, width, fileBitmap.getHeight()
, fileBitmap, 0, 0);
else
graphics.drawBitmap(0, y, width, dirBitmap.getHeight()
, dirBitmap, 0, 0);
switch(fileModel.getStatus()){
case FileModel.ADD_STATUS:
graphics.drawBitmap(0, y, width, addBitmap.getHeight()
, addBitmap, 0, 0);
break;
case FileModel.DEL_STATUS:
graphics.drawBitmap(0, y, width,delBitmap.getHeight()
, delBitmap, 0, 0);
break;
case FileModel.MOD_STATUS:
graphics.drawBitmap(0, y, width, modBitmap.getHeight()
, modBitmap, 0, 0);
break;
case FileModel.DOW_STATUS:
break;
case FileModel.NOR_STATUS:
graphics.drawBitmap(0, y, width, norBitmap.getHeight()
, norBitmap, 0, 0);
break;
default:
graphics.drawBitmap(0, y, width, novBitmap.getHeight()
, novBitmap, 0, 0);
break;
}
graphics.drawText(fileModel.getName(), fileBitmap.getWidth(), y);
}
}