Skip to content

Commit 74e68bf

Browse files
author
Roland Matusinka
committed
TwoWay-View library update > Merge pull request lucasr#214 (orientation change fix) to local repository.
Initial handling of configuration changes (screen orientation change)
1 parent b1fd773 commit 74e68bf

18 files changed

+496
-540
lines changed

core/src/main/AndroidManifest.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
Copyright (C) 2012 Lucas Rocha
43
54
Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,14 +14,16 @@
1514
limitations under the License.
1615
-->
1716

18-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19-
package="org.lucasr.twowayview"
20-
android:versionCode="1"
21-
android:versionName="Alpha 1" >
17+
<manifest
18+
package="org.lucasr.twowayview"
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:versionCode="1"
21+
android:versionName="Alpha 1">
2222

23-
<uses-sdk android:minSdkVersion="4"
24-
android:targetSdkVersion="16" />
23+
<uses-sdk
24+
android:minSdkVersion="4"
25+
android:targetSdkVersion="16" />
2526

26-
<application/>
27+
<application />
2728

2829
</manifest>

core/src/main/java/org/lucasr/twowayview/ClickItemTouchListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void onTouchEvent(RecyclerView recyclerView, MotionEvent event) {
4949
}
5050

5151
abstract boolean performItemClick(RecyclerView parent, View view, int position, long id);
52+
5253
abstract boolean performItemLongClick(RecyclerView parent, View view, int position, long id);
5354

5455
private class ItemClickGestureDetector extends GestureDetectorCompat {

core/src/main/java/org/lucasr/twowayview/ItemClickSupport.java

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,8 @@
66
import android.view.View;
77

88
public class ItemClickSupport {
9-
/**
10-
* Interface definition for a callback to be invoked when an item in the
11-
* RecyclerView has been clicked.
12-
*/
13-
public interface OnItemClickListener {
14-
/**
15-
* Callback method to be invoked when an item in the RecyclerView
16-
* has been clicked.
17-
*
18-
* @param parent The RecyclerView where the click happened.
19-
* @param view The view within the RecyclerView that was clicked
20-
* @param position The position of the view in the adapter.
21-
* @param id The row id of the item that was clicked.
22-
*/
23-
void onItemClick(RecyclerView parent, View view, int position, long id);
24-
}
25-
26-
/**
27-
* Interface definition for a callback to be invoked when an item in the
28-
* RecyclerView has been clicked and held.
29-
*/
30-
public interface OnItemLongClickListener {
31-
/**
32-
* Callback method to be invoked when an item in the RecyclerView
33-
* has been clicked and held.
34-
*
35-
* @param parent The RecyclerView where the click happened
36-
* @param view The view within the RecyclerView that was clicked
37-
* @param position The position of the view in the list
38-
* @param id The row id of the item that was clicked
39-
*
40-
* @return true if the callback consumed the long click, false otherwise
41-
*/
42-
boolean onItemLongClick(RecyclerView parent, View view, int position, long id);
43-
}
44-
459
private final RecyclerView mRecyclerView;
4610
private final TouchListener mTouchListener;
47-
4811
private OnItemClickListener mItemClickListener;
4912
private OnItemLongClickListener mItemLongClickListener;
5013

@@ -55,30 +18,6 @@ private ItemClickSupport(RecyclerView recyclerView) {
5518
recyclerView.addOnItemTouchListener(mTouchListener);
5619
}
5720

58-
/**
59-
* Register a callback to be invoked when an item in the
60-
* RecyclerView has been clicked.
61-
*
62-
* @param listener The callback that will be invoked.
63-
*/
64-
public void setOnItemClickListener(OnItemClickListener listener) {
65-
mItemClickListener = listener;
66-
}
67-
68-
/**
69-
* Register a callback to be invoked when an item in the
70-
* RecyclerView has been clicked and held.
71-
*
72-
* @param listener The callback that will be invoked.
73-
*/
74-
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
75-
if (!mRecyclerView.isLongClickable()) {
76-
mRecyclerView.setLongClickable(true);
77-
}
78-
79-
mItemLongClickListener = listener;
80-
}
81-
8221
public static ItemClickSupport addTo(RecyclerView recyclerView) {
8322
ItemClickSupport itemClickSupport = from(recyclerView);
8423
if (itemClickSupport == null) {
@@ -110,6 +49,65 @@ public static ItemClickSupport from(RecyclerView recyclerView) {
11049
return (ItemClickSupport) recyclerView.getTag(R.id.twowayview_item_click_support);
11150
}
11251

52+
/**
53+
* Register a callback to be invoked when an item in the
54+
* RecyclerView has been clicked.
55+
*
56+
* @param listener The callback that will be invoked.
57+
*/
58+
public void setOnItemClickListener(OnItemClickListener listener) {
59+
mItemClickListener = listener;
60+
}
61+
62+
/**
63+
* Register a callback to be invoked when an item in the
64+
* RecyclerView has been clicked and held.
65+
*
66+
* @param listener The callback that will be invoked.
67+
*/
68+
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
69+
if (!mRecyclerView.isLongClickable()) {
70+
mRecyclerView.setLongClickable(true);
71+
}
72+
73+
mItemLongClickListener = listener;
74+
}
75+
76+
/**
77+
* Interface definition for a callback to be invoked when an item in the
78+
* RecyclerView has been clicked.
79+
*/
80+
public interface OnItemClickListener {
81+
/**
82+
* Callback method to be invoked when an item in the RecyclerView
83+
* has been clicked.
84+
*
85+
* @param parent The RecyclerView where the click happened.
86+
* @param view The view within the RecyclerView that was clicked
87+
* @param position The position of the view in the adapter.
88+
* @param id The row id of the item that was clicked.
89+
*/
90+
void onItemClick(RecyclerView parent, View view, int position, long id);
91+
}
92+
93+
/**
94+
* Interface definition for a callback to be invoked when an item in the
95+
* RecyclerView has been clicked and held.
96+
*/
97+
public interface OnItemLongClickListener {
98+
/**
99+
* Callback method to be invoked when an item in the RecyclerView
100+
* has been clicked and held.
101+
*
102+
* @param parent The RecyclerView where the click happened
103+
* @param view The view within the RecyclerView that was clicked
104+
* @param position The position of the view in the list
105+
* @param id The row id of the item that was clicked
106+
* @return true if the callback consumed the long click, false otherwise
107+
*/
108+
boolean onItemLongClick(RecyclerView parent, View view, int position, long id);
109+
}
110+
113111
private class TouchListener extends ClickItemTouchListener {
114112
TouchListener(RecyclerView recyclerView) {
115113
super(recyclerView);

0 commit comments

Comments
 (0)