diff --git a/app/build.gradle b/app/build.gradle index 7206f5e..dbb2221 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,6 +27,8 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.support:recyclerview-v7:28.0.0' + implementation 'com.android.support:design:27.0.0' + api project(':library') // implementation 'com.github.JarvisGG:NestedTouchScrollingLayout:v1.1.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b0fbc9a..6f2c1cd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,8 @@ + + \ No newline at end of file diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/AppbarLayoutActivity.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/AppbarLayoutActivity.java new file mode 100644 index 0000000..7fdf3b3 --- /dev/null +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/AppbarLayoutActivity.java @@ -0,0 +1,248 @@ +package jarvis.com.nestedtouchscrollinglayout; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.os.Bundle; +import android.support.annotation.ColorInt; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import jarvis.com.library.NestedTouchScrollingLayout; + +/** + * @author yyf @ Zhihu Inc. + * @since 12-05-2018 + */ +public class AppbarLayoutActivity extends BaseActivity { + private int mContainerItemsCount = 20; + private int mInnerItemsCount = 30; + + public static int mHalfWindowHeight = 400; // dp + + public static int mVelocityYBound = 1300; + + private RecyclerView mContainerRecycler; + + private NestedTouchScrollingLayout mNestedTouchScrollingLayout; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_applayout); + + findViewById(R.id.btn_open).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mNestedTouchScrollingLayout.expand(); + } + }); + + mContainerRecycler = findViewById(R.id.container_rv); + mContainerRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); + mContainerRecycler.setAdapter(new InnerAdapter(this, 0x9966CC)); + mContainerRecycler.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDraw(c, parent, state); + } + + @Override + public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDrawOver(c, parent, state); + } + + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + outRect.bottom = 30; + } + }); + + mNestedTouchScrollingLayout = findViewById(R.id.wrapper); + mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() { + @Override + public void onNestChildScrollChange(float deltaY) { + + } + + @Override + public void onNestChildScrollRelease(final float deltaY, final int velocityY) { + int totalYRange = mNestedTouchScrollingLayout.getMeasuredHeight(); + + int helfLimit = (totalYRange - DisplayUtils.dpToPixel(AppbarLayoutActivity.this, mHalfWindowHeight)) / 2; + + int hideLimit = totalYRange - DisplayUtils.dpToPixel(AppbarLayoutActivity.this, mHalfWindowHeight) / 2; + + int helfHeight = totalYRange - DisplayUtils.dpToPixel(AppbarLayoutActivity.this, mHalfWindowHeight); + + if (velocityY > mVelocityYBound && velocityY > 0) { + if (Math.abs(deltaY) > helfHeight) { + mNestedTouchScrollingLayout.hiden(); + } else { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(AppbarLayoutActivity.this,400)); + } + } else if (velocityY < -mVelocityYBound && velocityY < 0) { + if (Math.abs(deltaY) < helfHeight) { + mNestedTouchScrollingLayout.expand(); + } else { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(AppbarLayoutActivity.this,400)); + } + } else { + if (Math.abs(deltaY) > hideLimit) { + mNestedTouchScrollingLayout.hiden(); + } else if (Math.abs(deltaY) > helfLimit) { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(AppbarLayoutActivity.this, 400)); + } else { + mNestedTouchScrollingLayout.expand(); + } + } + } + + @Override + public void onFingerUp(float velocityY) { + + } + + @Override + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { + + } + }); + + mNestedTouchScrollingLayout.setSheetDirection(NestedTouchScrollingLayout.SheetDirection.BOTTOM); + mNestedTouchScrollingLayout + .post(new Runnable() { + @Override + public void run() { + mNestedTouchScrollingLayout.recover(mNestedTouchScrollingLayout.getMeasuredHeight(), null, 0); + } + }); + } + + class ContainerAdapter extends RecyclerView.Adapter { + + private Context mContext; + private LayoutInflater mInflater; + + public ContainerAdapter(Context context) { + this.mContext = context; + this.mInflater = LayoutInflater.from(mContext); + } + + @NonNull + @Override + public AppbarLayoutActivity.ContainerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = mInflater.inflate(R.layout.recycer_item, viewGroup, false); + return new AppbarLayoutActivity.ContainerViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull AppbarLayoutActivity.ContainerViewHolder containerViewHolder, int i) { + containerViewHolder.mRecycler.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + switch (i % 5) { + case 0: + containerViewHolder.mRecycler.setAdapter(new AppbarLayoutActivity.InnerAdapter(mContext, 0xFFCCFF)); + break; + case 1: + containerViewHolder.mRecycler.setAdapter(new AppbarLayoutActivity.InnerAdapter(mContext, 0x9966CC)); + break; + case 2: + containerViewHolder.mRecycler.setAdapter(new AppbarLayoutActivity.InnerAdapter(mContext, 0x33FF33)); + break; + case 3: + containerViewHolder.mRecycler.setAdapter(new AppbarLayoutActivity.InnerAdapter(mContext, 0x33FFFF)); + break; + case 4: + containerViewHolder.mRecycler.setAdapter(new AppbarLayoutActivity.InnerAdapter(mContext, 0xFFFF00)); + break; + default: + break; + } + + containerViewHolder.mRecycler.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDraw(c, parent, state); + } + + @Override + public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDrawOver(c, parent, state); + } + + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + outRect.bottom = 10; + } + }); + + } + + @Override + public int getItemCount() { + return mContainerItemsCount; + } + } + + class ContainerViewHolder extends RecyclerView.ViewHolder { + + public RecyclerView mRecycler; + + public ContainerViewHolder(@NonNull View itemView) { + super(itemView); + mRecycler = itemView.findViewById(R.id.recycler_id); + } + } + + + + public class InnerAdapter extends RecyclerView.Adapter { + + private Context mContext; + private LayoutInflater mInflater; + private @ColorInt + int mBgColor; + + public InnerAdapter(Context context, @ColorInt int color) { + mContext = context; + mInflater = LayoutInflater.from(mContext); + mBgColor = color; + } + + @NonNull + @Override + public AppbarLayoutActivity.InnerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = mInflater.inflate(R.layout.main_item, viewGroup, false); + return new AppbarLayoutActivity.InnerViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull AppbarLayoutActivity.InnerViewHolder innerViewHolder, int i) { + innerViewHolder.tv.setText("Jarvis ----> " + i); + } + + @Override + public int getItemCount() { + return mInnerItemsCount; + } + } + + public class InnerViewHolder extends RecyclerView.ViewHolder { + + public TextView tv; + + public InnerViewHolder(@NonNull View itemView) { + super(itemView); + tv = itemView.findViewById(R.id.main_tv); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/BottomSheetActivity.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/BottomSheetActivity.java new file mode 100644 index 0000000..c034b1a --- /dev/null +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/BottomSheetActivity.java @@ -0,0 +1,251 @@ +package jarvis.com.nestedtouchscrollinglayout; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.os.Bundle; +import android.support.annotation.ColorInt; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import jarvis.com.library.NestedTouchScrollingLayout; + +/** + * @author yyf @ Zhihu Inc. + * @since 12-04-2018 + */ + +public class BottomSheetActivity extends BaseActivity { + + private int mContainerItemsCount = 20; + private int mInnerItemsCount = 30; + + public static int mHalfWindowHeight = 400; // dp + + public static int mVelocityYBound = 1300; + + private RecyclerView mContainerRecycler; + + private NestedTouchScrollingLayout mNestedTouchScrollingLayout; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_bottom); + + findViewById(R.id.btn_open).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mNestedTouchScrollingLayout.expand(); + } + }); + + mContainerRecycler = findViewById(R.id.container_rv); + mContainerRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); + mContainerRecycler.setAdapter(new InnerAdapter(this, 0x9966CC)); + mContainerRecycler.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDraw(c, parent, state); + } + + @Override + public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDrawOver(c, parent, state); + } + + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + outRect.bottom = 30; + } + }); + + mNestedTouchScrollingLayout = findViewById(R.id.wrapper); + mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() { + @Override + public void onNestChildScrollChange(float deltaY) { + + } + + @Override + public void onNestChildScrollRelease(final float deltaY, final int velocityY) { + int totalYRange = mNestedTouchScrollingLayout.getMeasuredHeight(); + + int helfLimit = (totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, mHalfWindowHeight)) / 2; + + int hideLimit = totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, mHalfWindowHeight) / 2; + + int helfHeight = totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, mHalfWindowHeight); + + if (velocityY > mVelocityYBound && velocityY > 0) { + if (Math.abs(deltaY) > helfHeight) { + mNestedTouchScrollingLayout.hiden(); + } else { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this,400)); + } + } else if (velocityY < -mVelocityYBound && velocityY < 0) { + if (Math.abs(deltaY) < helfHeight) { + mNestedTouchScrollingLayout.expand(); + } else { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this,400)); + } + } else { + if (Math.abs(deltaY) > hideLimit) { + mNestedTouchScrollingLayout.hiden(); + } else if (Math.abs(deltaY) > helfLimit) { + mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this, 400)); + } else { + mNestedTouchScrollingLayout.expand(); + } + } + } + + @Override + public void onFingerUp(float velocityY) { + + } + + @Override + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { + + } + }); + + mNestedTouchScrollingLayout.setSheetDirection(NestedTouchScrollingLayout.SheetDirection.BOTTOM); + mNestedTouchScrollingLayout + .post(new Runnable() { + @Override + public void run() { + mNestedTouchScrollingLayout.recover(mNestedTouchScrollingLayout.getMeasuredHeight(), null, 0); + } + }); + } + + class ContainerAdapter extends RecyclerView.Adapter { + + private Context mContext; + private LayoutInflater mInflater; + + public ContainerAdapter(Context context) { + this.mContext = context; + this.mInflater = LayoutInflater.from(mContext); + } + + @NonNull + @Override + public ContainerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = mInflater.inflate(R.layout.recycer_item, viewGroup, false); + return new ContainerViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ContainerViewHolder containerViewHolder, int i) { + containerViewHolder.mRecycler.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + switch (i % 5) { + case 0: + containerViewHolder.mRecycler.setAdapter(new InnerAdapter(mContext, 0xFFCCFF)); + break; + case 1: + containerViewHolder.mRecycler.setAdapter(new InnerAdapter(mContext, 0x9966CC)); + break; + case 2: + containerViewHolder.mRecycler.setAdapter(new InnerAdapter(mContext, 0x33FF33)); + break; + case 3: + containerViewHolder.mRecycler.setAdapter(new InnerAdapter(mContext, 0x33FFFF)); + break; + case 4: + containerViewHolder.mRecycler.setAdapter(new InnerAdapter(mContext, 0xFFFF00)); + break; + default: + break; + } + + containerViewHolder.mRecycler.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDraw(c, parent, state); + } + + @Override + public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDrawOver(c, parent, state); + } + + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.getItemOffsets(outRect, view, parent, state); + outRect.bottom = 10; + } + }); + + } + + @Override + public int getItemCount() { + return mContainerItemsCount; + } + } + + class ContainerViewHolder extends RecyclerView.ViewHolder { + + public RecyclerView mRecycler; + + public ContainerViewHolder(@NonNull View itemView) { + super(itemView); + mRecycler = itemView.findViewById(R.id.recycler_id); + } + } + + + + public class InnerAdapter extends RecyclerView.Adapter { + + private Context mContext; + private LayoutInflater mInflater; + private @ColorInt + int mBgColor; + + public InnerAdapter(Context context, @ColorInt int color) { + mContext = context; + mInflater = LayoutInflater.from(mContext); + mBgColor = color; + } + + @NonNull + @Override + public InnerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = mInflater.inflate(R.layout.main_item, viewGroup, false); + return new InnerViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull InnerViewHolder innerViewHolder, int i) { + innerViewHolder.tv.setText("Jarvis ----> " + i); + } + + @Override + public int getItemCount() { + return mInnerItemsCount; + } + } + + public class InnerViewHolder extends RecyclerView.ViewHolder { + + public TextView tv; + + public InnerViewHolder(@NonNull View itemView) { + super(itemView); + tv = itemView.findViewById(R.id.main_tv); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/DisplayUtils.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/DisplayUtils.java new file mode 100644 index 0000000..694b20d --- /dev/null +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/DisplayUtils.java @@ -0,0 +1,97 @@ +package jarvis.com.nestedtouchscrollinglayout; + +import android.content.Context; +import android.content.res.Resources; +import android.util.TypedValue; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.ViewConfiguration; + +/** + * @author yyf @ Zhihu Inc. + * @since 12-05-2018 + */ +public class DisplayUtils { + + public static int getScreenWidthPixels(final Context pContext) { + if (pContext == null) { + return 0; + } + + return pContext.getResources().getDisplayMetrics().widthPixels; + } + + public static int getScreenHeightPixels(final Context pContext) { + if (pContext == null) { + return 0; + } + + return pContext.getResources().getDisplayMetrics().heightPixels; + } + + + public static int getActionBarHeightPixels(final Context pContext) { + final TypedValue typedValue = new TypedValue(); + + if (pContext != null && pContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { + return TypedValue.complexToDimensionPixelSize(typedValue.data, pContext.getResources().getDisplayMetrics()); + } + + return 0; + } + + public static boolean hasNavigationBar(final Context pContext) { + final int id = pContext.getResources().getIdentifier("config_showNavigationBar", "bool", "android"); + + if (id > 0) { + return pContext.getResources().getBoolean(id); + } else { + return !ViewConfiguration.get(pContext).hasPermanentMenuKey() && !KeyCharacterMap.deviceHasKey(KeyEvent + .KEYCODE_BACK); + } + } + + public static int getNavigationBarHeight(final Context pContext) { + if (!DisplayUtils.hasNavigationBar(pContext)) { + return 0; + } + + final Resources resources = pContext.getResources(); + + final int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + + if (resourceId > 0) { + return resources.getDimensionPixelSize(resourceId); + } + + return 0; + } + + public static int pixelToDp(final Context pContext, final float pPixels) { + if (pContext == null) { + return 0; + } + + final float density = pContext.getResources().getDisplayMetrics().density; + + return (int) ((pPixels / density) + 0.5); + } + + public static int dpToPixel(final Context pContext, final float pDp) { + if (pContext == null) { + return 0; + } + + final float density = pContext.getResources().getDisplayMetrics().density; + + return (int) ((pDp * density) + 0.5f); + } + + public static int spToPixel(final Context pContext, final float pSp) { + if (pContext == null) { + return 0; + } + + return (int) (pSp * pContext.getResources().getDisplayMetrics().scaledDensity + 0.5f); + } +} \ No newline at end of file diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/MainActivity.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/MainActivity.java index 81213fd..fe245b6 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/MainActivity.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/MainActivity.java @@ -20,7 +20,9 @@ public class MainActivity extends BaseActivity { Class[] demoClasses = new Class[] { RecyclerViewActivity.class, WebViewActivity.class, - ViewPagerActivity.class + ViewPagerActivity.class, + BottomSheetActivity.class, + AppbarLayoutActivity.class }; private RecyclerView mRecycler; diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/RecyclerViewActivity.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/RecyclerViewActivity.java index ff0d771..c9aed4c 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/RecyclerViewActivity.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/RecyclerViewActivity.java @@ -12,6 +12,7 @@ import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -83,7 +84,7 @@ public void onFingerUp(float velocityY) { } @Override - public void onNestChildHorizationScroll(boolean show) { + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { } }); diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewActivity.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewActivity.java index 0ebfe1e..f25d4b2 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewActivity.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewActivity.java @@ -5,6 +5,7 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; +import android.view.MotionEvent; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -54,7 +55,7 @@ public void onFingerUp(float velocityY) { } @Override - public void onNestChildHorizationScroll(boolean show) { + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { } }); diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/BaseChildFragment.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/BaseChildFragment.java index 775a40c..fc0be6a 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/BaseChildFragment.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/BaseChildFragment.java @@ -6,6 +6,7 @@ import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import jarvis.com.library.NestedTouchScrollingLayout; @@ -51,7 +52,7 @@ public void onFingerUp(float velocityY) { } @Override - public void onNestChildHorizationScroll(boolean show) { + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { } }); diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/RecyclerViewFragment.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/RecyclerViewFragment.java index 477c927..172c6ed 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/RecyclerViewFragment.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/RecyclerViewFragment.java @@ -11,6 +11,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -72,7 +73,7 @@ public void onFingerUp(float velocityY) { } @Override - public void onNestChildHorizationScroll(boolean show) { + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { } }); diff --git a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/WebViewFragment.java b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/WebViewFragment.java index 52602be..a48a344 100644 --- a/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/WebViewFragment.java +++ b/app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/WebViewFragment.java @@ -8,6 +8,7 @@ import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.webkit.WebResourceError; @@ -70,7 +71,7 @@ public void onFingerUp(float velocityY) { } @Override - public void onNestChildHorizationScroll(boolean show) { + public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) { } }); diff --git a/app/src/main/res/layout/activity_applayout.xml b/app/src/main/res/layout/activity_applayout.xml new file mode 100644 index 0000000..d6fc949 --- /dev/null +++ b/app/src/main/res/layout/activity_applayout.xml @@ -0,0 +1,77 @@ + + + + + +