Skip to content

Commit

Permalink
Merge pull request #14 from rubensousa/visibility
Browse files Browse the repository at this point in the history
Allow extending from DpadRecyclerView
  • Loading branch information
rubensousa authored Dec 10, 2022
2 parents 04d35ad + c7b1505 commit c63456a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 1.0.0-alpha02

- Allow extending from `DpadRecyclerView`
- Removed `RecyclerView.canScrollHorizontally` and `RecyclerView.canScrollVertically` since they're not used and clients can create them themselves

# 1.0.0-alpha01

- Initial alpha release
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ A RecyclerView built for Android TV as a replacement for Leanback's BaseGridView
## Install

```groovy
implementation 'com.rubensousa.dpadrecyclerview:dpadrecyclerview:1.0.0-alpha01'
implementation 'com.rubensousa.dpadrecyclerview:dpadrecyclerview:1.0.0-alpha02'
// Optional Espresso test extensions
androidTestImplementation 'com.rubensousa.dpadrecyclerview:dpadrecyclerview-testing:1.0.0-alpha01'
androidTestImplementation 'com.rubensousa.dpadrecyclerview:dpadrecyclerview-testing:1.0.0-alpha02'
```

## Feature comparison with Leanback's BaseGridView
Expand Down
2 changes: 1 addition & 1 deletion dpadrecyclerview-testing/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
LIBRARY_VERSION=1.0.0-alpha01
LIBRARY_VERSION=1.0.0-alpha02
LIBRARY_GROUP=com.rubensousa.dpadrecyclerview
LIBRARY_ARTIFACT=dpadrecyclerview-testing
# POM info
Expand Down
2 changes: 1 addition & 1 deletion dpadrecyclerview/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
LIBRARY_VERSION=1.0.0-alpha01
LIBRARY_VERSION=1.0.0-alpha02
LIBRARY_GROUP=com.rubensousa.dpadrecyclerview
LIBRARY_ARTIFACT=dpadrecyclerview
# POM info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import androidx.recyclerview.widget.RecyclerView
* To scroll manually to any given item,
* check [setSelectedPosition], [setSelectedPositionSmooth] and other related methods.
*/
class DpadRecyclerView @JvmOverloads constructor(
open class DpadRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = R.attr.dpadRecyclerViewStyle
Expand All @@ -62,20 +62,20 @@ class DpadRecyclerView @JvmOverloads constructor(
delegate.init(context, attrs)
}

override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
final override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
return false
}

@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(e: MotionEvent?): Boolean {
final override fun onTouchEvent(e: MotionEvent?): Boolean {
return false
}

override fun hasOverlappingRendering(): Boolean {
final override fun hasOverlappingRendering(): Boolean {
return delegate.hasOverlappingRendering()
}

override fun dispatchKeyEvent(event: KeyEvent): Boolean {
final override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (keyInterceptListener?.onInterceptKeyEvent(event) == true) {
return true
}
Expand All @@ -85,64 +85,68 @@ class DpadRecyclerView @JvmOverloads constructor(
return unhandledKeyListener?.onUnhandledKey(event) == true
}

override fun dispatchGenericFocusedEvent(event: MotionEvent): Boolean {
final override fun dispatchGenericFocusedEvent(event: MotionEvent): Boolean {
if (motionInterceptListener?.onInterceptMotionEvent(event) == true) {
return true
}
return super.dispatchGenericFocusedEvent(event)
}

override fun setLayoutManager(layout: LayoutManager?) {
final override fun setLayoutManager(layout: LayoutManager?) {
super.setLayoutManager(layout)
delegate.setLayoutManager(layout)
}

override fun focusSearch(focused: View?, direction: Int): View? {
final override fun focusSearch(focused: View?, direction: Int): View? {
return delegate.focusSearch(focused, direction)
}

override fun focusSearch(direction: Int): View? {
final override fun focusSearch(direction: Int): View? {
return delegate.focusSearch(direction) ?: super.focusSearch(direction)
}

override fun onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
final override fun onFocusChanged(
gainFocus: Boolean,
direction: Int,
previouslyFocusedRect: Rect?
) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect)
delegate.onFocusChanged(gainFocus)
}

override fun onRequestFocusInDescendants(
final override fun onRequestFocusInDescendants(
direction: Int,
previouslyFocusedRect: Rect?
): Boolean {
return delegate.onRequestFocusInDescendants(direction, previouslyFocusedRect)
}

override fun removeView(view: View) {
final override fun removeView(view: View) {
delegate.removeView(view)
super.removeView(view)
delegate.setRemoveViewFinished()
}

override fun removeViewAt(index: Int) {
final override fun removeViewAt(index: Int) {
delegate.removeViewAt(index)
super.removeViewAt(index)
delegate.setRemoveViewFinished()
}

override fun getChildDrawingOrder(childCount: Int, i: Int): Int {
final override fun getChildDrawingOrder(childCount: Int, i: Int): Int {
return delegate.getChildDrawingOrder(childCount, i)
}

override fun onRtlPropertiesChanged(layoutDirection: Int) {
final override fun onRtlPropertiesChanged(layoutDirection: Int) {
super.onRtlPropertiesChanged(layoutDirection)
delegate.onRtlPropertiesChanged()
}

override fun smoothScrollBy(dx: Int, dy: Int) {
final override fun smoothScrollBy(dx: Int, dy: Int) {
delegate.smoothScrollBy(dx, dy)
}

override fun smoothScrollBy(dx: Int, dy: Int, interpolator: Interpolator?) {
final override fun smoothScrollBy(dx: Int, dy: Int, interpolator: Interpolator?) {
delegate.smoothScrollBy(dx, dy, interpolator)
}

Expand Down Expand Up @@ -607,11 +611,3 @@ class DpadRecyclerView @JvmOverloads constructor(
}

}

fun RecyclerView.canScrollHorizontally(): Boolean {
return layoutManager?.canScrollVertically() == true
}

fun RecyclerView.canScrollVertically(): Boolean {
return layoutManager?.canScrollVertically() == true
}

0 comments on commit c63456a

Please sign in to comment.