title: issue while hiding a View on ViewPager's fragment
body: <p>am trying to hide and show a View when imageView is being  tapped , i have 3 fragments  in my ViewPager  so the problem is that when am on my first View and i tap the imageView it works fine (my View got hided) but when am on Fragment no. 2 or three and i tap on the imageView it never hides the View its only working on my first fragment , this is my code :</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private static int[] imageArray;
  
      static ImageLoader imageLoader;
      static ArrayList&lt;String&gt; urlArray;
      static DisplayImageOptions options;
      static ProgressBar spinner;
  
      static PhotoViewAttacher mAttacher;
      static Boolean isToolBarShown = true;
  
      static Button nextButton , previousButton;
  
      static ViewPager viewPager ;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          urlArray = new ArrayList&lt;&gt;();
  
          urlArray.add("http://i.imgur.com/uLRgvM8.png");
          urlArray.add("http://i.imgur.com/LUuJ4FO.png");
          urlArray.add("http://i.imgur.com/7SSBNBA.jpg");
  
  
          // Create global configuration and initialize ImageLoader with this config
          DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                  .cacheInMemory(true)
                  .imageScaleType(ImageScaleType.EXACTLY)
                  .displayer(new FadeInBitmapDisplayer(300)).build();
  
          ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                  getApplicationContext())
                  .defaultDisplayImageOptions(defaultOptions)
                  .memoryCache(new WeakMemoryCache()).build();
  
          ImageLoader.getInstance().init(config);
  
  
          imageLoader = ImageLoader.getInstance();
          options = new DisplayImageOptions.Builder().cacheInMemory(true)
                  .cacheOnDisk(true)
                  .resetViewBeforeLoading(true).build();
  
  //initialize image view
          ImageView imageView = (ImageView) findViewById(R.id.imageView);
  
          ImageFragmentPagerAdapter imageFragmentPagerAdapter = new ImageFragmentPagerAdapter(getSupportFragmentManager());
           viewPager = (ViewPager) findViewById(R.id.pager);
  
          viewPager.setOffscreenPageLimit(1);
  
  
          viewPager.setAdapter(imageFragmentPagerAdapter);
      }
  
  
  
  
  
  
  
      public static class ImageFragmentPagerAdapter extends FragmentPagerAdapter {
          public ImageFragmentPagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public int getCount() {
              return urlArray.size();
          }
  
          @Override
          public Fragment getItem(int position) {
              //SwipeFragment fragment = new SwipeFragment();
              return SwipeFragment.newInstance(position);
          }
  
      }
  
      public static class SwipeFragment extends Fragment {
  
          private int position;
          private ImageView imageView;
          private RelativeLayout relativeLayout;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              final View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
  
              imageView = (ImageView) swipeView.findViewById(R.id.imageView);
              spinner = (ProgressBar) swipeView.findViewById(R.id.spinner);
              relativeLayout = (RelativeLayout) swipeView.findViewById(R.id.tool_bar);
              Bundle bundle = getArguments();
              nextButton = (Button)swipeView.findViewById(R.id.next_button);
              previousButton = (Button)swipeView.findViewById(R.id.button_previous);
  
              position = bundle.getInt("position");
  
              Toast.makeText(getContext(),"NEW PAGE CALLED",Toast.LENGTH_SHORT).show();
              if (isToolBarShown){
  
                  relativeLayout.setVisibility(View.VISIBLE);
              }else {
  
                  relativeLayout.setVisibility(View.GONE);
              }
              mAttacher = new PhotoViewAttacher(imageView);
  
  
  
  //            viewPager.OnPageChangeListener(new ViewPager.OnPageChangeListener() {
  //                @Override
  //                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  //
  //
  //                }
  //
  //                @Override
  //                public void onPageSelected(int position) {
  //
  //                    loadImageView(position,imageView);
  //
  //                }
  //
  //                @Override
  //                public void onPageScrollStateChanged(int state) {
  //
  //                }
  //            });
  
              previousButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      viewPager.setCurrentItem(viewPager.getCurrentItem()-1,true);
                  }
  
              });
  
              nextButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      viewPager.setCurrentItem(viewPager.getCurrentItem()+1,true);
                  }
  
              });
  
              return swipeView;
          }
  
  
  
  
  
          public void loadImageView(int position, final ImageView imageView ){
  
              imageLoader.displayImage(urlArray.get(position), imageView, options, new ImageLoadingListener() {
                  @Override
                  public void onLoadingStarted(String imageUri, View view) {
  
                  }
  
                  @Override
                  public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
  
  
                      spinner.setVisibility(View.GONE);
                  }
  
                  @Override
                  public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
  
                       mAttacher = new PhotoViewAttacher(imageView);
  
                      mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
                          @Override
                          public void onViewTap(View view, float x, float y) {
  
                              if (view == imageView){
                                  if (relativeLayout.getVisibility() == View.VISIBLE){
  
                                      isToolBarShown = false;
                                      relativeLayout.setVisibility(View.GONE);
  
                                  }else {
  
                                      isToolBarShown = true;
                                      relativeLayout.setVisibility(View.VISIBLE);
                                  }
  
                                  Log.d("OOPS","WHAT THE.., WHAT IS WRONG HERE");
                              }
  
                          }
                      });
  
  
                      if(mAttacher!=null){
                          mAttacher.update();
                      }else{
                          mAttacher = new PhotoViewAttacher(imageView);
                      }
  
  
                      spinner.setVisibility(View.GONE);
                  }
  
                  @Override
                  public void onLoadingCancelled(String imageUri, View view) {
  
  
                      spinner.setVisibility(View.GONE);
                  }
              }, new ImageLoadingProgressListener() {
                  @Override
                  public void onProgressUpdate(String imageUri, View view, int current, int total) {
  
                      spinner.setVisibility(View.VISIBLE);
                      spinner.setProgress((current*100)/total);
  
  
                  }
              });
  
          }
  
  
  
          static SwipeFragment newInstance(int position) {
              SwipeFragment swipeFragment = new SwipeFragment();
              Bundle bundle = new Bundle();
              bundle.putInt("position", position);
              swipeFragment.setArguments(bundle);
              return swipeFragment;
          }
  
  
          @Override
          public void setUserVisibleHint(boolean isVisibleToUser) {
              super.setUserVisibleHint(isVisibleToUser);
              if (isVisibleToUser) {
                  // load data here
  //                if (getView() != null) {
  //                    isViewShown = true;
  //                    // fetchdata() contains logic to show data when page is selected mostly asynctask to fill the data
  //                    loadImageView(position , imageView);
  //                } else {
  //                    isViewShown = false;
  //                }
              }
          }
  
  
  
  
  
  }}
  </code></pre>
  
  <p>am trying to hide and show the <code>RelativeView</code> , if anybody knows whats wrong or missing in my code then please do correct me </p>