title: Fragment Back Press ,Loading back Fragment
body: <p>I have Fragment A which contains two button (Let say ButtonA and ButtonB), while pressing the ButtonB i am loading the fragment B (fragment B contains 1 Button, Let say Button C),while pressing button C ,the pop window is going to appear.</p>
  
  <p>The problem I am facing now , when i back press then popwindow is disapperaing but loading Fragment A.</p>
  
  <p>Actually I need when popwindow is showing in fragment B ,and user press back button then ,pop window should only disappear and it remain still in Fragment B ,not go to fragment A.</p>
  
  <p>what i did , from the fragment B i had created one interface and pass the Popwindow instance in an Activity , and from the activity i am dismissing the popwindow.</p>
  
  <pre><code> @Override
      public void onHandleRequest(PopupWindow popupWindow, PopupWindow backpopwindow, String fragmentName) {
          if(fragmentName !=null){
              this.fragmentName=fragmentName;
            if(popupWindow!=null){
                this.popupWindow=popupWindow;
                this.backpopwindow=backpopwindow;
  
            }
          }
  
  
  
  @Override
      public void onBackPressed() {
          super.onBackPressed();
  
          if(popupWindow!=null &amp;&amp; popupWindow.isShowing()){
              popupWindow.dismiss();
              backpopwindow.dismiss();
          }
  }
  </code></pre>
  
  <p>In My Fragment Class :</p>
  
  <pre><code>public interface OnHandleCallBack{
          public void onHandleRequest(PopupWindow popupWindow,PopupWindow backpopwindow,String fragmentName);
      }
  
  public void showPopup(View view, Context context,ArrayList&lt;String&gt; arrayList) {
  
          if(popupWindow!=null &amp;&amp; popupWindow.isShowing()){
              popupWindow.dismiss();
          }
  
          mLayoutManager.setScrollEnabled(false);
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          //Making transparent layout
  
          final View popupView1  = inflater.inflate(R.layout.transparent_layout,
                  (ViewGroup) view.findViewById(R.id.transprent));
  
          popupWindow1 = new PopupWindow(popupView1, WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT);
          popupWindow1.showAtLocation(popupView1, Gravity.CENTER, 0 , 0);
          popupWindow1.setBackgroundDrawable(new BitmapDrawable());
          popupWindow1.setOutsideTouchable(true);
          popupWindow1.showAsDropDown(popupView1, 0, 0);
  
          final View popupView  = inflater.inflate(R.layout.my_order_truck_popup_win,
                  (ViewGroup) view.findViewById(R.id.popup_win));
  
          RecyclerView mRecyclerView = (RecyclerView) popupView.findViewById(R.id.truck_recyler_id);
          TextView textView=(TextView) popupView.findViewById(R.id.txt_truck);
          RelativeLayout cancl_rl=(RelativeLayout)popupView.findViewById(R.id.rl_cncl);
          textView.setText(context.getResources().getString(R.string.trucks));
          Config.colorFont(context,null,textView,null);
          popupView.setAnimation(AnimationUtils.loadAnimation(context, R.anim.pop_up_window));
  
          /********* Here is my PopUp window ********/
          Float m=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300, getResources().getDisplayMetrics());
          int m1=Math.round(m);
          popupWindow = new PopupWindow(popupView,m1,WindowManager.LayoutParams.WRAP_CONTENT);
  
          popupWindow.showAtLocation(popupView, Gravity.CENTER, 0 , 0);
          popupWindow.setBackgroundDrawable(new BitmapDrawable());
          popupWindow.setOutsideTouchable(true);
  
          MyOrderPopUPAdapter mAdapter = new MyOrderPopUPAdapter(context, arrayList);
          LinearLayoutManager LayoutManager = new LinearLayoutManager(context);
          mRecyclerView.setLayoutManager(LayoutManager);
          mRecyclerView.setItemAnimator(new DefaultItemAnimator());
          mRecyclerView.setAdapter(mAdapter);
          onHandleCallBack.onHandleRequest(popupWindow,popupWindow1,"orderfragment");
  
          popupWindow1.setTouchInterceptor(new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  popupWindow.dismiss();
                  popupWindow1.dismiss();
                  mLayoutManager.setScrollEnabled(true);
                  return true;
              }
          });
  
  
  
          cancl_rl.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  popupWindow.dismiss();
                  popupWindow1.dismiss();
                  mLayoutManager.setScrollEnabled(true);
  
              }
          });
  
          popupWindow.showAsDropDown(popupView, 0, 0);
      }
  
  @Override
      public void onAttach(Context context) {
          super.onAttach(context);
          try {
              onHandleCallBack = (OnHandleCallBack)context;
  
          } catch (ClassCastException e) {
              throw new ClassCastException(context.toString()
                      + " must implement onHandleCallBack");
          }
      }
  </code></pre>