本文整理汇总了Java中com.couchbase.lite.Revision类的典型用法代码示例。如果您正苦于以下问题:Java Revision类的具体用法?Java Revision怎么用?Java Revision使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Revision类属于com.couchbase.lite包,在下文中一共展示了Revision类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvatar
import com.couchbase.lite.Revision; //导入依赖的package包/类
private Bitmap getAvatar() {
Document doc = mDatabase.getDocument(CONTACT_INFO_DOCUMENT_ID);
Revision rev = doc.getCurrentRevision();
Attachment att = rev.getAttachment("avatar.jpg");
if (att != null) {
try {
InputStream is = att.getContent();
BufferedInputStream bif = new BufferedInputStream(is);
return BitmapFactory.decodeStream(bif);
} catch (CouchbaseLiteException e) {
Log.e(TAG, "Cannot load attachment", e);
}
return null;
}
return null;
}
示例2: findCommonAncestorOf
import com.couchbase.lite.Revision; //导入依赖的package包/类
@Override
public String findCommonAncestorOf(RevisionInternal rev, List<String> revIDs) {
long generation = Revision.generationFromRevID(rev.getRevID());
if (generation <= 1 || (revIDs == null || revIDs.size() == 0))
return null;
Collections.sort(revIDs, new Comparator<String>() {
@Override
public int compare(String id1, String id2) {
// descending order of generation
return RevisionInternal.CBLCompareRevIDs(id2, id1);
}
});
Document doc = getDocument(rev.getDocID());
if (doc == null)
return null;
String commonAncestor = null;
try {
for (String possibleRevID : revIDs) {
if (Revision.generationFromRevID(possibleRevID) <= generation) {
try {
if (doc.selectRevID(possibleRevID, false))
commonAncestor = possibleRevID;
} catch (ForestException e) {
Log.i(TAG, "Error in Document.selectRevID() revID=%s", e, possibleRevID);
}
if (commonAncestor != null)
break;
}
}
} finally {
doc.free();
}
return commonAncestor;
}