Search in sources :

Example 1 with ShortcutRecord

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;
}
Also used : ShortcutRecord(fr.neamar.kiss.db.ShortcutRecord) ShortcutsPojo(fr.neamar.kiss.pojo.ShortcutsPojo) ArrayList(java.util.ArrayList)

Example 2 with ShortcutRecord

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();
}
Also used : ShortcutRecord(fr.neamar.kiss.db.ShortcutRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ShortcutRecord (fr.neamar.kiss.db.ShortcutRecord)2 ShortcutsPojo (fr.neamar.kiss.pojo.ShortcutsPojo)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1