久久久久久久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 - 聽(tīng)用戶(hù)事件解除

        BottomSheetDialogFragment - listen to dismissed by user event(BottomSheetDialogFragment - 聽(tīng)用戶(hù)事件解除)
          <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 - 聽(tīng)用戶(hù)事件解除的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  如何收聽(tīng) BottomSheetDialogFragment 的最終解除?我只想在最終解雇時(shí)保存用戶(hù)更改...

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

                  我嘗試了以下操作:

                  方法一

                  只有在通過(guò)向下滑動(dòng)對(duì)話(huà)框(不是在后按或觸摸外部)關(guān)閉對(duì)話(huà)框時(shí)才會(huì)觸發(fā)

                  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;
                  }
                  

                  方法二

                  這讓我無(wú)法區(qū)分最終解雇和來(lái)自屏幕旋轉(zhuǎn)或活動(dòng)娛樂(lè)的解雇...

                  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();
                  }
                  

                  問(wèn)題

                  如何收聽(tīng)表明用戶(hù)已完成對(duì)話(huà)的事件?

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

                  推薦答案

                  雖然關(guān)于 SO 的所有類(lèi)似問(wèn)題都建議使用 onDismiss 我認(rèn)為以下是正確的解決方案:

                  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();
                  }
                  

                  如果發(fā)生以下情況,則會(huì)觸發(fā):

                  This fires if:

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

                  這不會(huì)觸發(fā):

                  * on screen rotation and activity recreation
                  

                  解決方案

                  結(jié)合 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();
                      }
                  }
                  

                  這篇關(guān)于BottomSheetDialogFragment - 聽(tīng)用戶(hù)事件解除的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶(hù)的當(dāng)前位置)
                  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(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動(dòng)期間獲取當(dāng)前位置)
                  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视频网 | 国产精品久久久久久久粉嫩 | 久久久久国产一区二区三区四区 | 国产精品不卡 | 国产视频1| 91传媒在线播放 | 日韩欧美1区2区 | 亚洲精品1区 | 欧美精品一区二区三区在线 | 色婷婷亚洲一区二区三区 | 国产精品99久久久久久久vr | 国产精品久久国产精品 | 久久国产精品视频 | 99re热精品视频 | 亚洲成人精品久久久 | 国产精品成人一区二区三区 | 欧美一级艳情片免费观看 | av在线免费观看网址 | 九九伊人sl水蜜桃色推荐 | 一级毛片视频在线观看 | 精品久久久久久久久久久久久久 | 韩日一区二区 | 99久久久久 | 91人人澡人人爽 | 国内精品视频在线 | 精品久久久久一区二区国产 | 午夜影院在线观看视频 | 欧美久久免费观看 | 婷婷综合网 | 欧美精品一区二区在线观看 | 成人欧美一区二区 |