Skip to content

Commit 8397549

Browse files
committed
Get layout direction without using resources
1 parent c0ecce5 commit 8397549

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.rubensousa.gravitysnaphelper;
22

33

4+
import android.os.Build;
45
import android.support.annotation.NonNull;
56
import android.support.v7.widget.LinearLayoutManager;
67
import android.support.v7.widget.OrientationHelper;
@@ -56,9 +57,11 @@ public GravityDelegate(int gravity, boolean enableSnapLast,
5657

5758
public void attachToRecyclerView(@NonNull RecyclerView recyclerView) {
5859
if (recyclerView != null) {
59-
if (gravity == Gravity.START || gravity == Gravity.END) {
60+
if ((gravity == Gravity.START || gravity == Gravity.END)
61+
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
6062
isRtlHorizontal
61-
= recyclerView.getContext().getResources().getBoolean(R.bool.is_rtl);
63+
= recyclerView.getContext().getResources().getConfiguration()
64+
.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
6265
}
6366
if (listener != null) {
6467
recyclerView.addOnScrollListener(mScrollListener);

gravitysnaphelper/src/main/res/values-ldrtl/attrs.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

gravitysnaphelper/src/main/res/values/attrs.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

gravitysnaphelper/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)