use of fr.neamar.kiss.db.ShortcutRecord in project KISS by Neamar.
the class LoadShortcutsPojos method doInBackground.
@Override
protected ArrayList<ShortcutsPojo> doInBackground(Void... arg0) {
List<ShortcutRecord> records = DBHelper.getShortcuts(context);
ArrayList<ShortcutsPojo> pojos = new ArrayList<>();
for (ShortcutRecord shortcutRecord : records) {
ShortcutsPojo pojo = createPojo(shortcutRecord.name);
pojo.packageName = shortcutRecord.packageName;
pojo.resourceName = shortcutRecord.iconResource;
pojo.intentUri = shortcutRecord.intentUri;
if (shortcutRecord.icon_blob != null) {
pojo.icon = BitmapFactory.decodeByteArray(shortcutRecord.icon_blob, 0, shortcutRecord.icon_blob.length);
}
pojos.add(pojo);
}
return pojos;
}
use of fr.neamar.kiss.db.ShortcutRecord in project KISS by Neamar.
the class DataHandler method addShortcut.
public void addShortcut(ShortcutsPojo shortcut) {
ShortcutRecord record = new ShortcutRecord();
record.name = shortcut.name;
record.iconResource = shortcut.resourceName;
record.packageName = shortcut.packageName;
record.intentUri = shortcut.intentUri;
if (shortcut.icon != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
shortcut.icon.compress(CompressFormat.PNG, 100, baos);
record.icon_blob = baos.toByteArray();
}
DBHelper.insertShortcut(this.context, record);
if (this.getShortcutsProvider() != null) {
this.getShortcutsProvider().reload();
}
Toast.makeText(context, R.string.shortcut_added, Toast.LENGTH_SHORT).show();
}
Aggregations