本文整理匯總了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();
}