久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        • <bdo id='I1RAH'></bdo><ul id='I1RAH'></ul>

        <legend id='I1RAH'><style id='I1RAH'><dir id='I1RAH'><q id='I1RAH'></q></dir></style></legend>

        <small id='I1RAH'></small><noframes id='I1RAH'>

      1. <i id='I1RAH'><tr id='I1RAH'><dt id='I1RAH'><q id='I1RAH'><span id='I1RAH'><b id='I1RAH'><form id='I1RAH'><ins id='I1RAH'></ins><ul id='I1RAH'></ul><sub id='I1RAH'></sub></form><legend id='I1RAH'></legend><bdo id='I1RAH'><pre id='I1RAH'><center id='I1RAH'></center></pre></bdo></b><th id='I1RAH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='I1RAH'><tfoot id='I1RAH'></tfoot><dl id='I1RAH'><fieldset id='I1RAH'></fieldset></dl></div>
        <tfoot id='I1RAH'></tfoot>
      2. BottomSheetDialogFragment - 聽用戶事件解除

        BottomSheetDialogFragment - listen to dismissed by user event(BottomSheetDialogFragment - 聽用戶事件解除)
          <tbody id='xtdtE'></tbody>
          <i id='xtdtE'><tr id='xtdtE'><dt id='xtdtE'><q id='xtdtE'><span id='xtdtE'><b id='xtdtE'><form id='xtdtE'><ins id='xtdtE'></ins><ul id='xtdtE'></ul><sub id='xtdtE'></sub></form><legend id='xtdtE'></legend><bdo id='xtdtE'><pre id='xtdtE'><center id='xtdtE'></center></pre></bdo></b><th id='xtdtE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xtdtE'><tfoot id='xtdtE'></tfoot><dl id='xtdtE'><fieldset id='xtdtE'></fieldset></dl></div>

            <small id='xtdtE'></small><noframes id='xtdtE'>

          1. <legend id='xtdtE'><style id='xtdtE'><dir id='xtdtE'><q id='xtdtE'></q></dir></style></legend>
          2. <tfoot id='xtdtE'></tfoot>

              • <bdo id='xtdtE'></bdo><ul id='xtdtE'></ul>
                • 本文介紹了BottomSheetDialogFragment - 聽用戶事件解除的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如何收聽 BottomSheetDialogFragment 的最終解除?我只想在最終解雇時保存用戶更改...

                  How can I listen to a FINAL dismissal of a BottomSheetDialogFragment? I want to save user changes on the final dismissal only...

                  我嘗試了以下操作:

                  方法一

                  只有在通過向下滑動對話框(不是在后按或觸摸外部)關閉對話框時才會觸發

                  This only fires, if the dialog is dismissed by swiping it down (not on back press or on touch outside)

                  @Override
                  public Dialog onCreateDialog(Bundle savedInstanceState)
                  {
                      Dialog d = super.onCreateDialog(savedInstanceState);
                      d.setOnShowListener(new DialogInterface.OnShowListener() {
                          @Override
                          public void onShow(DialogInterface dialog) {
                  
                              BottomSheetDialog d = (BottomSheetDialog) dialog;   
                              FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
                  
                              BottomSheetBehavior behaviour = BottomSheetBehavior.from(bottomSheet);
                              behaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
                              behaviour.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
                                  @Override
                                  public void onStateChanged(@NonNull View bottomSheet, int newState) {
                                      if (newState == BottomSheetBehavior.STATE_HIDDEN)
                                      {
                                          // Bottom Sheet was dismissed by user! But this is only fired, if dialog is swiped down! Not if touch outside dismissed the dialog or the back button
                                          Toast.makeText(MainApp.get(), "HIDDEN", Toast.LENGTH_SHORT).show();
                                          dismiss();
                                      }
                                  }
                  
                                  @Override
                                  public void onSlide(@NonNull View bottomSheet, float slideOffset) {
                  
                                  }
                              });
                          }
                      });
                      return d;
                  }
                  

                  方法二

                  這讓我無法區分最終解雇和來自屏幕旋轉或活動娛樂的解雇...

                  This does not allow me to distinguish between a final dismissal and one that is coming from a screen rotation or activity recreation...

                   @Override
                  public void onDismiss(DialogInterface dialog)
                  {
                      super.onDismiss(dialog);
                      // this works fine but fires one time too often for my use case, it fires on screen rotation as well, although this is a temporarily dismiss only
                      Toast.makeText(MainApp.get(), "DISMISSED", Toast.LENGTH_SHORT).show();
                  }
                  

                  問題

                  如何收聽表明用戶已完成對話的事件?

                  How can I listen to an event that indicates, that the user has finished the dialog?

                  推薦答案

                  雖然關于 SO 的所有類似問題都建議使用 onDismiss 我認為以下是正確的解決方案:

                  Although all similar questions on SO suggest using onDismiss I think following is the correct solution:

                  @Override
                  public void onCancel(DialogInterface dialog)
                  {
                      super.onCancel(dialog);
                      Toast.makeText(MainApp.get(), "CANCEL", Toast.LENGTH_SHORT).show();
                  }
                  

                  如果發生以下情況,則會觸發:

                  This fires if:

                  * the user presses back
                  * the user presses outside of the dialog
                  

                  這不會觸發:

                  * on screen rotation and activity recreation
                  

                  解決方案

                  結合 onCancelBottomSheetBehavior.BottomSheetCallback.onStateChanged,如下所示:

                  Combine onCancel and BottomSheetBehavior.BottomSheetCallback.onStateChanged like following:

                  public class Dailog extends BottomSheetDialogFragment
                  {
                      @Override
                      public void onCancel(DialogInterface dialog)
                      {
                          super.onCancel(dialog);
                          handleUserExit();
                      }
                  
                      @Override
                      public Dialog onCreateDialog(Bundle savedInstanceState)
                      {
                          Dialog d = super.onCreateDialog(savedInstanceState);
                          d.setOnShowListener(new DialogInterface.OnShowListener() {
                              @Override
                              public void onShow(DialogInterface dialog) {
                                  BottomSheetDialog d = (BottomSheetDialog) dialog;
                                  FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);
                                  BottomSheetBehavior behaviour = BottomSheetBehavior.from(bottomSheet);
                                  behaviour.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
                                      @Override
                                      public void onStateChanged(@NonNull View bottomSheet, int newState) {
                                          if (newState == BottomSheetBehavior.STATE_HIDDEN)
                                          {
                                              handleUserExit();
                                              dismiss();
                                          }
                                      }
                  
                                      @Override
                                      public void onSlide(@NonNull View bottomSheet, float slideOffset) {
                  
                                      }
                                  });
                              }
                          });
                          return d;
                      }
                  
                      private void handleUserExit()
                      {
                          Toast.makeText(MainApp.get(), "TODO - SAVE data or similar", Toast.LENGTH_SHORT).show();
                      }
                  }
                  

                  這篇關于BottomSheetDialogFragment - 聽用戶事件解除的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                    <i id='M50Tp'><tr id='M50Tp'><dt id='M50Tp'><q id='M50Tp'><span id='M50Tp'><b id='M50Tp'><form id='M50Tp'><ins id='M50Tp'></ins><ul id='M50Tp'></ul><sub id='M50Tp'></sub></form><legend id='M50Tp'></legend><bdo id='M50Tp'><pre id='M50Tp'><center id='M50Tp'></center></pre></bdo></b><th id='M50Tp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='M50Tp'><tfoot id='M50Tp'></tfoot><dl id='M50Tp'><fieldset id='M50Tp'></fieldset></dl></div>

                        <legend id='M50Tp'><style id='M50Tp'><dir id='M50Tp'><q id='M50Tp'></q></dir></style></legend>
                            <bdo id='M50Tp'></bdo><ul id='M50Tp'></ul>
                          • <small id='M50Tp'></small><noframes id='M50Tp'>

                              <tbody id='M50Tp'></tbody>
                          • <tfoot id='M50Tp'></tfoot>

                            主站蜘蛛池模板: 国产极品91 | 国产一二区视频 | 国内精品久久久久久久影视简单 | 在线成人精品视频 | 久久综合久久综合久久综合 | 午夜精品久久久久久久久久久久久 | 亚洲精品视频免费 | 日韩不卡视频在线观看 | 九色综合网 | 成在线人视频免费视频 | 国产男女猛烈无遮掩视频免费网站 | aaa一区| 大象视频一区二区 | 1级毛片| 在线观看国产视频 | 国产视频第一页 | 9久9久9久女女女九九九一九 | 精品99在线 | 一二区视频 | 九九九视频精品 | 亚洲一二三区免费 | 国产精品永久免费 | 麻豆一区二区三区 | 日本视频在线播放 | 日韩高清一区 | 日韩精品一区二区三区 | 99re视频在线 | 一级a性色生活片久久毛片 一级特黄a大片 | 欧洲色 | 一区二区免费看 | 久久精品视频在线播放 | 91精品久久久久久久 | 日本黄视频在线观看 | 男女国产视频 | 久久国内精品 | 国产精品一区二区三区四区 | 亚洲成人国产精品 | 国产探花在线精品一区二区 | 国产精品久久久亚洲 | 国产成人一区二区三区电影 | 国产精品亚洲欧美日韩一区在线 |