Tag Archives: bug

Android : compatibility between ViewPager and SlidingMenu

You already may have encountered “bug” by using a Viewpager and a SlidingMenu at the same time :

this bug is simply while sliding viewpager… the sliding menu “takes” the event.

 

How to fix it?

In fact, it is very simple. First of all, make an object (your fragment, activity…), create a method which will take one integer (native one, not the Object ;p )

In it, you can simply check if the index is equal to 0 (or the maximum if you were using a right menu >> according to your code, but here, I will only make it compatible with left. Add now a simple if else statement. If the index is 0 then enable the menu, otherwise disable it.

For example:


public class SlidingViewPagerFragmentActivity extends SlidingFragmentActivity{
  public void setViewPagerSelected(int index){
    //in this example, I also check for the screen
    //which is currently selected
    if(index == 0 && this.findViewById(R.id.mobile) != null){
      this.getSlidingMenu().setSlidingEnabled(true);
    }else{
      this.getSlidingMenu().setSlidingEnabled(false);
    }
  }
}

Now that we have a perfectly working checking method, you can now implements a OnPageChangeListener in your activity/fragment/whatever… (from the …view.ViewPager package)

Once done, you will have to override the onPageSelected(int index) method. In this one, call your Object which manage the SlidingMenu (in my own code, I made an object override SherlockFragmentActivity, implements the first method in it and then, my activities simply override my Activity with this method. And to finish (last little thing), register your Object in the :
yourpager.setOnPageChangeListener()
//note that if you use the ViewPagerIndicator, you will have to register your Object
//in the indicator ;)

For instance (in a SherlockFragment):


public class FragmentExample extends SherlockFragment{
  @Override
  public void onPageSelected(int index) {
    if(getSherlockActivity() instanceof SlidingViewPagerFragmentActivity){
      ((SlidingViewPagerFragmentActivity)getSherlockActivity()).setViewPagerSelected(index);
    }
  }
}

And voila 😉

Android : external sdcard to the internal one !

Here we are! The Galaxy S3 is a great device but … the external sd (up to 64GB) IS NOT used per default to store Android/data when you want to use external storage to store data. It is here that the application I developed can help you!

If your device is rooted, you can now swap the internal and external sdcard forever (in fact at every boot) or until the phone reboot

Does it work with every devices? In fact, it was made to be installed and used on a Galaxy S3 but the trick used in the app can be modify to work with … every devices which embed 2 sdcard (internal & external)

To manage these features :

  1. you can update the configuration list directly from the internet
  2. you can set your own configuration (only 1 at this time)
  3. you do not know what device represent your physical sdcard? no problem, you can directly from the application check every device on the phone/tablet and choose the correct one and it will edit the custom paramter !
  4. you do not know what to do? you can send the list provided, and/or your build.prop (the build.prop will help me to create new configuration for everyone when they download the updated configuration list)

You can download and install directly from this link (the store one will soon arrive)

http://www.codlab.eu/Internal2External.apk