Search in sources :

Example 1 with NestedMap

use of com.xabber.android.data.entity.NestedMap in project xabber-android by redsolution.

the class GroupManager method onLoad.

@Override
public void onLoad() {
    final NestedMap<GroupConfiguration> groupConfigurations = new NestedMap<GroupConfiguration>();
    Cursor cursor = GroupTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                GroupConfiguration rosterConfiguration = new GroupConfiguration();
                rosterConfiguration.setExpanded(GroupTable.isExpanded(cursor));
                rosterConfiguration.setShowOfflineMode(GroupTable.getShowOfflineMode(cursor));
                groupConfigurations.put(GroupTable.getAccount(cursor), GroupTable.getGroup(cursor), rosterConfiguration);
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    Application.getInstance().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            onLoaded(groupConfigurations);
        }
    });
}
Also used : NestedMap(com.xabber.android.data.entity.NestedMap) Cursor(android.database.Cursor)

Example 2 with NestedMap

use of com.xabber.android.data.entity.NestedMap in project xabber-android by redsolution.

the class ChatManager method onLoad.

@Override
public void onLoad() {
    final Set<BaseEntity> privateChats = new HashSet<BaseEntity>();
    final NestedMap<Boolean> notifyVisible = new NestedMap<Boolean>();
    final NestedMap<ShowMessageTextInNotification> showText = new NestedMap<>();
    final NestedMap<Boolean> makeVibro = new NestedMap<Boolean>();
    final NestedMap<Uri> sounds = new NestedMap<Uri>();
    final NestedMap<Boolean> suppress100 = new NestedMap<Boolean>();
    Cursor cursor;
    cursor = PrivateChatTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                privateChats.add(new BaseEntity(PrivateChatTable.getAccount(cursor), PrivateChatTable.getUser(cursor)));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    cursor = NotifyVisibleTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                notifyVisible.put(NotifyVisibleTable.getAccount(cursor), NotifyVisibleTable.getUser(cursor), NotifyVisibleTable.getValue(cursor));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    cursor = ShowTextTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                showText.put(ShowTextTable.getAccount(cursor), ShowTextTable.getUser(cursor), ShowTextTable.getValue(cursor));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    cursor = VibroTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                makeVibro.put(VibroTable.getAccount(cursor), VibroTable.getUser(cursor), VibroTable.getValue(cursor));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    cursor = SoundTable.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                sounds.put(SoundTable.getAccount(cursor), SoundTable.getUser(cursor), SoundTable.getValue(cursor));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    cursor = Suppress100Table.getInstance().list();
    try {
        if (cursor.moveToFirst()) {
            do {
                makeVibro.put(Suppress100Table.getAccount(cursor), Suppress100Table.getUser(cursor), Suppress100Table.getValue(cursor));
            } while (cursor.moveToNext());
        }
    } finally {
        cursor.close();
    }
    Application.getInstance().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            onLoaded(privateChats, notifyVisible, showText, makeVibro, sounds, suppress100);
        }
    });
}
Also used : BaseEntity(com.xabber.android.data.entity.BaseEntity) NestedMap(com.xabber.android.data.entity.NestedMap) Cursor(android.database.Cursor) Uri(android.net.Uri) HashSet(java.util.HashSet)

Aggregations

Cursor (android.database.Cursor)2 NestedMap (com.xabber.android.data.entity.NestedMap)2 Uri (android.net.Uri)1 BaseEntity (com.xabber.android.data.entity.BaseEntity)1 HashSet (java.util.HashSet)1