Search in sources :

Example 1 with DiscoveryInfoCache

use of com.xabber.android.data.database.realm.DiscoveryInfoCache in project xabber-android by redsolution.

the class EntityCapsCache method addDiscoverInfoByNodePersistent.

@Override
public void addDiscoverInfoByNodePersistent(final String nodeVer, final DiscoverInfo info) {
    final long startTime = System.currentTimeMillis();
    if (nodeVer == null || info == null) {
        return;
    }
    // TODO: 13.03.18 ANR - WRITE
    Realm realm = RealmManager.getInstance().getNewRealm();
    realm.beginTransaction();
    DiscoveryInfoCache discoveryInfoCache = new DiscoveryInfoCache(nodeVer, info);
    realm.copyToRealmOrUpdate(discoveryInfoCache);
    realm.commitTransaction();
    realm.close();
    LogManager.d("REALM", Thread.currentThread().getName() + " save discover info: " + (System.currentTimeMillis() - startTime));
}
Also used : DiscoveryInfoCache(com.xabber.android.data.database.realm.DiscoveryInfoCache) Realm(io.realm.Realm)

Example 2 with DiscoveryInfoCache

use of com.xabber.android.data.database.realm.DiscoveryInfoCache in project xabber-android by redsolution.

the class EntityCapsCache method lookup.

@Override
public DiscoverInfo lookup(String nodeVer) {
    Realm realm = RealmManager.getInstance().getNewRealm();
    DiscoveryInfoCache discoveryInfoCache = realm.where(DiscoveryInfoCache.class).equalTo(DiscoveryInfoCache.Fields.NODE_VER, nodeVer).findFirst();
    DiscoverInfo discoverInfo = null;
    if (discoveryInfoCache != null) {
        discoverInfo = realm.copyFromRealm(discoveryInfoCache).getDiscoveryInfo();
    }
    realm.close();
    return discoverInfo;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) DiscoveryInfoCache(com.xabber.android.data.database.realm.DiscoveryInfoCache) Realm(io.realm.Realm)

Aggregations

DiscoveryInfoCache (com.xabber.android.data.database.realm.DiscoveryInfoCache)2 Realm (io.realm.Realm)2 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)1