本文整理匯總了Java中android.view.WindowManager.BadTokenException方法的典型用法代碼示例。如果您正苦於以下問題:Java WindowManager.BadTokenException方法的具體用法?Java WindowManager.BadTokenException怎麽用?Java WindowManager.BadTokenException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.WindowManager
的用法示例。
在下文中一共展示了WindowManager.BadTokenException方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: show
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
@UiThread
public void show() {
try {
super.show();
} catch (WindowManager.BadTokenException e) {
throw new DialogException("Bad window token, you cannot show a dialog before an Activity is created or after it's hidden.");
}
}
示例2: causedByBadWindowToken
import android.view.WindowManager; //導入方法依賴的package包/類
private static boolean causedByBadWindowToken(Throwable e) {
while (e != null) {
if (e instanceof WindowManager.BadTokenException) {
return true;
}
e = e.getCause();
}
return false;
}
示例3: show
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
public AlertDialog show() {
try {
AlertDialog dialog = create();
dialog.setOnDismissListener(mOnDismissListener);
dialog.show();
return dialog;
} catch (WindowManager.BadTokenException ignored) {
return create();
}
}
示例4: createAndShowWaitSpinner
import android.view.WindowManager; //導入方法依賴的package包/類
private static ProgressDialog createAndShowWaitSpinner(Context mContext)
{
ProgressDialog dialog = new ProgressDialog(mContext);
try {
dialog.show();
}
catch (WindowManager.BadTokenException e) {
}
dialog.setCancelable(false);
dialog.setIndeterminate(true);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setContentView(R.layout.wait_spinner);
return dialog;
}
示例5: show
import android.view.WindowManager; //導入方法依賴的package包/類
@UiThread
static void show(@NonNull Activity activity, @NonNull IE_Message message) throws WindowManager.BadTokenException {
PW_AlertMessage alert = PW_AlertMessage._CurrentVisible;
if (alert != null) {
if(alert._MessageID == message.conversation_message_id) { //Already displaying that message
alert.bindMessage(message);
alert.abortFadeOut();
alert.getContentView().postDelayed(alert._FadeOutAfterTOT, AUTO_FADE_OUT_DELAY);
return;
}
if(activity == alert.getActivity()) {
alert.fadeOut();
} else {
alert.dismissAllowingStateLoss();
}
}
alert = new PW_AlertMessage(activity);
alert.bindMessage(message);
int top_offset_fix = 0;
View decorView = activity.getWindow().getDecorView();
if (decorView instanceof ViewGroup) {
ViewGroup decorViewGroup = (ViewGroup) decorView;
if (decorViewGroup.getChildCount() == 1) {
top_offset_fix = decorViewGroup.getChildAt(0).getPaddingTop();
}
}
alert.showAtLocation(activity.getWindow().getDecorView(), Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, top_offset_fix);
PW_AlertMessage._CurrentVisible = alert;
alert.getContentView().postDelayed(alert._FadeOutAfterTOT, AUTO_FADE_OUT_DELAY);
MediaPlayer mp = MediaPlayer.create(activity, R.raw.notif_2);
mp.setOnCompletionListener(mp1 -> {
mp1.reset();
mp1.release();
});
mp.start();
}
示例6: onNewSocketMessages
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
public void onNewSocketMessages(@NonNull ArrayList<IE_Message> messages) {
final ArrayList<IE_Message> new_messages = new ArrayList<>(this._ChatList);
IE_Message otherConversationMessage = null;
//noinspection Convert2streamapi
for(IE_Message newMsg : messages) {
if(newMsg.conversation_id == this._ConversationID) { //Filter by conversation_id
if(! new_messages.contains(newMsg)) { //Avoid duplicates;
new_messages.add(newMsg);
}
} else {
if(otherConversationMessage == null || otherConversationMessage.conversation_message_id < newMsg.conversation_message_id) {
otherConversationMessage = newMsg;
}
}
}
if(otherConversationMessage != null) {
try {
PW_AlertMessage.show(this, otherConversationMessage);
} catch (WindowManager.BadTokenException ignored) { }
}
Collections.sort(new_messages, (m1, m2) -> (int) (m2.conversation_message_id - m1.conversation_message_id));//Sorting by conversation_message_id DESC
IU_NullSafe.post(this._ListRecyclerView, () -> {
boolean scrollToBottom = this._LinearLayoutManager != null && this._LinearLayoutManager.findFirstCompletelyVisibleItemPosition() == 0;
this._ChatList = new_messages;
this._Adapter.notifyDataSetChanged();
if (scrollToBottom) {
this._LinearLayoutManager.scrollToPosition(0);
}
});
if(new_messages.size() != 0) {
IE_Message last = new_messages.get(0);
if (last.isNotSeen()) {
this.sendSeen(last.conversation_message_id);
}
}
}