package tmi.li.txwidgets.txbtry;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.util.Log;
import tmi.li.txwidgets.Widget;
public class TxBtryWidget extends Widget {
private static final String TAG = "tmi.li.txwidgets.txbtry.TxBtryWidget";
private Context context;
public String _percent;
public String _resttime;
public String _time;
public String _plug;
public String _temp;
public String _format;
public TxBtryWidget(Context context) {
this.context = context;
}
public boolean save() {
DBAdapter db = new DBAdapter(context);
db.insertWidget(this);
db.close();
return true;
}
public boolean update() {
DBAdapter db = new DBAdapter(context);
boolean test = db.updateWidget(this);
db.close();
return test;
}
public void deleteWidget() {
DBAdapter db = new DBAdapter(context);
db.deleteWidget(this);
db.close();
}
public boolean load(int id){
try {
DBAdapter db = new DBAdapter(context);
Cursor s = db.getWidget(id);
_id = s.getInt(0);
_flcolor = s.getString(1);
_ftcolor = s.getString(2);
_fbcolor = s.getString(3);
_bcolor = s.getString(4);
_percent = s.getString(5);
_resttime = s.getString(6);
_time = s.getString(7);
_plug = s.getString(8);
_temp = s.getString(9);
_format = s.getString(10);
s.close();
db.close();
return true;
}catch(SQLException e) {
//e.printStackTrace();
return false;
}
catch(Exception e){
return false;
}
}
public ContentValues getValues() {
ContentValues values = new ContentValues();
values.put(DBAdapter.ID, _id);
values.put(DBAdapter.FLCOLOR, _flcolor);
values.put(DBAdapter.FTCOLOR, _ftcolor);
values.put(DBAdapter.FBCOLOR, _fbcolor);
values.put(DBAdapter.BCOLOR, _bcolor);
values.put(DBAdapter.PERCENT, _percent);
values.put(DBAdapter.RTIME, _resttime);
values.put(DBAdapter.TIME, _time);
values.put(DBAdapter.PLUG, _plug);
values.put(DBAdapter.TEMP, _temp);
values.put(DBAdapter.FORMAT, _format);
return values;
}
public void logWidget() {
Log.d(TAG, "id\t=>\t"+_id);
Log.d(TAG, "FLCOLOR\t=>\t"+_flcolor);
Log.d(TAG, "FTCOLOR\t=>\t"+_ftcolor);
Log.d(TAG, "FBCOLOR\t=>\t"+_fbcolor);
Log.d(TAG, "BCOLOR\t=>\t"+_bcolor);
Log.d(TAG, "PERCENT\t=>\t"+_percent);
Log.d(TAG, "RTIME\t=>\t"+_resttime);
Log.d(TAG, "TIME\t=>\t"+_time);
Log.d(TAG, "PLUG\t=>\t"+_plug);
Log.d(TAG, "TEMP\t=>\t"+_temp);
Log.d(TAG, "FORMAT\t=>\t"+_format);
}
}
|