Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
0f02b39b
Commit
0f02b39b
authored
Dec 04, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add listener
parent
e4fddf8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
RealmModelListAdapter.java
...at/rocket/android/realm_helper/RealmModelListAdapter.java
+20
-1
No files found.
realm-helpers/src/main/java/chat/rocket/android/realm_helper/RealmModelListAdapter.java
View file @
0f02b39b
...
...
@@ -16,9 +16,14 @@ public abstract class RealmModelListAdapter<T extends RealmObject, VM,
RealmModelListAdapter
<
T
,
VM
,
VH
>
getNewInstance
(
Context
context
);
}
public
interface
OnItemClickListener
<
VM
>
{
void
onItemClick
(
VM
model
);
}
protected
final
LayoutInflater
inflater
;
private
RealmListObserver
<
T
>
realmListObserver
;
private
List
<
VM
>
adapterData
;
private
OnItemClickListener
<
VM
>
onItemClickListener
;
protected
RealmModelListAdapter
(
Context
context
)
{
this
.
inflater
=
LayoutInflater
.
from
(
context
);
...
...
@@ -64,7 +69,17 @@ public abstract class RealmModelListAdapter<T extends RealmObject, VM,
}
@Override
public
void
onBindViewHolder
(
VH
holder
,
int
position
)
{
holder
.
bind
(
getItem
(
position
));
VM
model
=
getItem
(
position
);
holder
.
itemView
.
setTag
(
model
);
holder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
VM
model2
=
(
VM
)
(
view
.
getTag
());
if
(
model2
!=
null
&&
onItemClickListener
!=
null
)
{
onItemClickListener
.
onItemClick
(
model2
);
}
}
});
holder
.
bind
(
model
);
}
@Override
public
int
getItemCount
()
{
...
...
@@ -85,4 +100,8 @@ public abstract class RealmModelListAdapter<T extends RealmObject, VM,
notifyDataSetChanged
();
}
}
public
void
setOnItemClickListener
(
OnItemClickListener
<
VM
>
onItemClickListener
)
{
this
.
onItemClickListener
=
onItemClickListener
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment