package com.ld.secret.dom;
import com.ld.secret.ui.utils.Global;
import android.content.ContentValues;
import android.database.Cursor;
import android.provider.CallLog;
/*
* My call log
*/
public class MyCallLog extends MyData {
public String numbertype;
public int _new; // 1 or 0
public long duration; // in seconds
public String numberlabel;
public String name;
public String number;
public String type;
public long date; // in miliseconds from epoch
public MyCallLog() {}
public MyCallLog(Cursor cursor) {
id = cursor.getLong(cursor.getColumnIndex("_id"));
numbertype = cursor.getString(cursor.getColumnIndex("numbertype"));
numbertype = cursor.getString(cursor.getColumnIndex("numbertype"));
numberlabel = cursor.getString(cursor.getColumnIndex("numberlabel"));
name = cursor.getString(cursor.getColumnIndex("name"));
number = cursor.getString(cursor.getColumnIndex("number"));
type = cursor.getString(cursor.getColumnIndex("type"));
_new = cursor.getInt(cursor.getColumnIndex("new"));
date = cursor.getLong(cursor.getColumnIndex("date"));
duration = cursor.getLong(cursor.getColumnIndex("duration"));
}
@Override
public void hide() {
Global.cr.delete(CallLog.Calls.CONTENT_URI, "_id = " + id, null);
}
@Override
public void restore() {
Global.cr.insert(CallLog.Calls.CONTENT_URI, getContentValues());
}
private ContentValues getContentValues() {
ContentValues values = new ContentValues();
values.put("numbertype", numbertype);
values.put("new", _new);
values.put("duration", duration);
values.put("_id", id);
values.put("numberlabel", numberlabel);
values.put("name", name);
values.put("number", number);
values.put("type", type);
values.put("date", date);
return values;
}
@Override
public String toString() {
return "MyCallLog [_new=" + _new + ", date=" + date + ", duration="
+ duration + ", name=" + name + ", number=" + number
+ ", numberlabel=" + numberlabel + ", numbertype=" + numbertype
+ ", _id = " + id + ", type=" + type + "]";
}
}
|