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));
}
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;
}
Aggregations