How to Disable Navigation Drawer for specific fragments

1 . Create an interface first

public interface DrawerLocker {
    public void setDrawerEnabled(boolean enabled);
}


2. Implement interface on Activity that’s has navigation drawer / Container Activity

public class MainActivity extends Activity implements DrawerLocker {

    public void setDrawerEnabled(boolean enabled) {
        int lockMode = enabled ? DrawerLayout.LOCK_MODE_UNLOCKED :
                                 DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
        drawer.setDrawerLockMode(lockMode);
        toggle.setDrawerIndicatorEnabled(enabled);
    }

    ...
}

3. Cast that interface on you specific fragments

((DrawerLocker) getActivity()).setDrawerEnabled(false);

 

Advertisements

RecyclerView OnTouch Listener

1. implements RecyclerView.OnItemTouchListener
2. final GestureDetector mGestureDetector = new GestureDetector(getActivity().getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {

@Override public boolean onSingleTapUp(MotionEvent e) {
return true;
}

});

3. mRecyclerView.addOnItemTouchListener(
new OrderFoodTypeFragment(getActivity().getApplicationContext(), new OrderFoodTypeFragment.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {

clickPosition =position;

}
})
);

 

http://sapandiwakar.in/recycler-view-item-click-handler/