本文整理汇总了Java中org.thoughtcrime.securesms.database.DraftDatabase类的典型用法代码示例。如果您正苦于以下问题:Java DraftDatabase类的具体用法?Java DraftDatabase怎么用?Java DraftDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DraftDatabase类属于org.thoughtcrime.securesms.database包,在下文中一共展示了DraftDatabase类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDraftFromDatabase
import org.thoughtcrime.securesms.database.DraftDatabase; //导入依赖的package包/类
private void initializeDraftFromDatabase() {
new AsyncTask<Void, Void, List<Draft>>() {
@Override
protected List<Draft> doInBackground(Void... params) {
MasterCipher masterCipher = new MasterCipher(masterSecret);
DraftDatabase draftDatabase = DatabaseFactory.getDraftDatabase(ConversationActivity.this);
List<Draft> results = draftDatabase.getDrafts(masterCipher, threadId);
draftDatabase.clearDrafts(threadId);
return results;
}
@Override
protected void onPostExecute(List<Draft> drafts) {
for (Draft draft : drafts) {
try {
if (draft.getType().equals(Draft.TEXT)) {
composeText.setText(draft.getValue());
} else if (draft.getType().equals(Draft.LOCATION)) {
attachmentManager.setLocation(masterSecret, SignalPlace.deserialize(draft.getValue()), getCurrentMediaConstraints());
} else if (draft.getType().equals(Draft.IMAGE)) {
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE);
} else if (draft.getType().equals(Draft.AUDIO)) {
setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO);
} else if (draft.getType().equals(Draft.VIDEO)) {
setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO);
}
} catch (IOException e) {
Log.w(TAG, e);
}
}
updateToggleButtonState();
}
}.execute();
}
示例2: initializeDraftFromDatabase
import org.thoughtcrime.securesms.database.DraftDatabase; //导入依赖的package包/类
private void initializeDraftFromDatabase() {
new AsyncTask<Void, Void, List<Draft>>() {
@Override
protected List<Draft> doInBackground(Void... params) {
MasterCipher masterCipher = new MasterCipher(masterSecret);
DraftDatabase draftDatabase = DatabaseFactory.getDraftDatabase(ConversationActivity.this);
List<Draft> results = draftDatabase.getDrafts(masterCipher, threadId);
draftDatabase.clearDrafts(threadId);
return results;
}
@Override
protected void onPostExecute(List<Draft> drafts) {
for (Draft draft : drafts) {
// Location-TODO
// try {
if (draft.getType().equals(Draft.TEXT)) {
composeText.setText(draft.getValue());
// Location-TODO
// } else if (draft.getType().equals(Draft.LOCATION)) {
// attachmentManager.setLocation(masterSecret, SignalPlace.deserialize(draft.getValue()), getCurrentMediaConstraints());
} else if (draft.getType().equals(Draft.IMAGE)) {
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE);
} else if (draft.getType().equals(Draft.AUDIO)) {
setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO);
} else if (draft.getType().equals(Draft.VIDEO)) {
setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO);
}
// Location-TODO
// } catch (IOException e) {
// Log.w(TAG, e);
// }
}
updateToggleButtonState();
}
}.execute();
}
示例3: initializeDraftFromDatabase
import org.thoughtcrime.securesms.database.DraftDatabase; //导入依赖的package包/类
private void initializeDraftFromDatabase() {
new AsyncTask<Void, Void, List<Draft>>() {
@Override
protected List<Draft> doInBackground(Void... params) {
MasterCipher masterCipher = new MasterCipher(masterSecret);
DraftDatabase draftDatabase = DatabaseFactory.getDraftDatabase(ConversationActivity.this);
List<Draft> results = draftDatabase.getDrafts(masterCipher, threadId);
draftDatabase.clearDrafts(threadId);
return results;
}
@Override
protected void onPostExecute(List<Draft> drafts) {
boolean nativeEmojiSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
Context context = ConversationActivity.this;
for (Draft draft : drafts) {
if (draft.getType().equals(Draft.TEXT) && !nativeEmojiSupported) {
composeText.setText(Emoji.getInstance(context).emojify(draft.getValue(),
new Emoji.InvalidatingPageLoadedListener(composeText)),
TextView.BufferType.SPANNABLE);
} else if (draft.getType().equals(Draft.TEXT)) {
composeText.setText(draft.getValue());
} else if (draft.getType().equals(Draft.IMAGE)) {
addAttachmentImage(Uri.parse(draft.getValue()));
} else if (draft.getType().equals(Draft.AUDIO)) {
addAttachmentAudio(Uri.parse(draft.getValue()));
} else if (draft.getType().equals(Draft.VIDEO)) {
addAttachmentVideo(Uri.parse(draft.getValue()));
}
}
}
}.execute();
}