本文整理汇总了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);
}
}
}