當前位置: 首頁>>代碼示例>>Java>>正文


Java WindowManager.BadTokenException方法代碼示例

本文整理匯總了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.");
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:MaterialDialog.java

示例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;
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:10,代碼來源:CrashHandler.java

示例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();
    }
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:12,代碼來源:Dialog.java

示例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;
}
 
開發者ID:ArtifexSoftware,項目名稱:mupdf-android-viewer-nui,代碼行數:15,代碼來源:ProofActivity.java

示例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();
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:37,代碼來源:PW_AlertMessage.java

示例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);
        }
    }
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:42,代碼來源:IAct_Chat.java


注:本文中的android.view.WindowManager.BadTokenException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。