proof of concept / use app drawer edge-width
This commit is contained in:
parent
2730a3420b
commit
d57ef6e0f7
2 changed files with 43 additions and 19 deletions
|
@ -459,10 +459,17 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
|
||||
|
||||
private class RecyclerViewOnGestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||
private int minLeftEdgeDistance = 100;
|
||||
private int minLeftEdgeDistance = -1;
|
||||
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||
if(minLeftEdgeDistance == -1) { // if not initialized
|
||||
// TODO check if tablet..
|
||||
// TODO if tablet, use 0 as minLeftEdgeDistance.. right?
|
||||
minLeftEdgeDistance = ((NewsReaderListActivity) getActivity()).getEdgeSizeOfDrawer();
|
||||
Log.d(TAG, "" + minLeftEdgeDistance);
|
||||
}
|
||||
|
||||
if (mMarkAsReadWhileScrollingEnabled &&
|
||||
e1.getX() > minLeftEdgeDistance && // only if gesture starts a bit away from left window edge
|
||||
(e2.getY() - e1.getY()) < 0) { // and if swipe direction is upwards
|
||||
|
|
|
@ -223,24 +223,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
drawerLayout.addDrawerListener(drawerToggle);
|
||||
|
||||
try {
|
||||
// increase the size of the drag margin to prevent starting a star swipe when
|
||||
// trying to open the drawer.
|
||||
Field mDragger = drawerLayout.getClass().getDeclaredField(
|
||||
"mLeftDragger");
|
||||
mDragger.setAccessible(true);
|
||||
ViewDragHelper draggerObj = (ViewDragHelper) mDragger
|
||||
.get(drawerLayout);
|
||||
|
||||
Field mEdgeSize = draggerObj.getClass().getDeclaredField(
|
||||
"mEdgeSize");
|
||||
mEdgeSize.setAccessible(true);
|
||||
int edge = mEdgeSize.getInt(draggerObj);
|
||||
|
||||
mEdgeSize.setInt(draggerObj, edge * 3);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
adjustEdgeSizeOfDrawer();
|
||||
}
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
@ -258,6 +241,40 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
updateButtonLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the "pull to open drawer" area by three.
|
||||
* This method should be called only once!
|
||||
*/
|
||||
private void adjustEdgeSizeOfDrawer() {
|
||||
try {
|
||||
// increase the size of the drag margin to prevent starting a star swipe when
|
||||
// trying to open the drawer.
|
||||
Field mDragger = drawerLayout.getClass().getDeclaredField("mLeftDragger");
|
||||
mDragger.setAccessible(true);
|
||||
ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(drawerLayout);
|
||||
Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize");
|
||||
mEdgeSize.setAccessible(true);
|
||||
int edge = mEdgeSize.getInt(draggerObj);
|
||||
mEdgeSize.setInt(draggerObj, edge * 3);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Setting edge width of drawer failed..", e);
|
||||
}
|
||||
}
|
||||
|
||||
public int getEdgeSizeOfDrawer() {
|
||||
try {
|
||||
Field mDragger = drawerLayout.getClass().getDeclaredField("mLeftDragger");
|
||||
mDragger.setAccessible(true);
|
||||
ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(drawerLayout);
|
||||
Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize");
|
||||
mEdgeSize.setAccessible(true);
|
||||
return mEdgeSize.getInt(draggerObj);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to get edge size of drawer", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private void showTapLogoToSyncShowcaseView() {
|
||||
getSlidingListFragment().showTapLogoToSyncShowcaseView();
|
||||
|
|
Loading…
Reference in a new issue