Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Game Client Android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
25
Issues
25
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Akamu
Game Client Android
Commits
934f4830
Commit
934f4830
authored
Sep 22, 2020
by
Antonia Wüst
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
#12
parent
280db5c5
Pipeline
#1978
failed with stages
in 3 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
app/src/main/java/de/akamu/tudarmstadt/features/questionpools/QuestionPoolsAdapter.kt
...udarmstadt/features/questionpools/QuestionPoolsAdapter.kt
+17
-9
No files found.
app/src/main/java/de/akamu/tudarmstadt/features/questionpools/QuestionPoolsAdapter.kt
View file @
934f4830
...
...
@@ -16,14 +16,20 @@ import de.akamu.tudarmstadt.model.Pool
import
de.akamu.tudarmstadt.util.SortOrder
class
QuestionPoolsAdapter
(
var
pools
:
ArrayList
<
Pool
>,
var
mQuestionPoolOnClickHandler
:
QuestionPoolOnClickHandler
)
:
RecyclerView
.
Adapter
<
QuestionPoolsAdapter
.
QuestionPoolsViewHolder
>()
{
class
QuestionPoolsAdapter
(
var
pools
:
ArrayList
<
Pool
>,
var
mQuestionPoolOnClickHandler
:
QuestionPoolOnClickHandler
)
:
RecyclerView
.
Adapter
<
QuestionPoolsAdapter
.
QuestionPoolsViewHolder
>()
{
private
var
selectedPools
:
ArrayList
<
Pool
>
=
pools
.
filter
{
p
->
p
.
isSelected
}
as
ArrayList
<
Pool
>
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
QuestionPoolsViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
item_question_pools
,
parent
,
false
)
view
.
isFocusable
=
true
return
QuestionPoolsViewHolder
(
view
)
}
...
...
@@ -36,9 +42,9 @@ class QuestionPoolsAdapter(var pools: ArrayList<Pool>, var mQuestionPoolOnClickH
}
fun
sort
(
order
:
SortOrder
):
Boolean
{
return
when
(
order
)
{
return
when
(
order
)
{
SortOrder
.
ALPHABETIC
->
{
pools
.
sortWith
(
compareBy
{
it
.
name
})
pools
.
sortWith
(
compareBy
{
it
.
name
})
notifyDataSetChanged
()
true
}
...
...
@@ -66,7 +72,8 @@ class QuestionPoolsAdapter(var pools: ArrayList<Pool>, var mQuestionPoolOnClickH
fun
onExpandOrCollapseCard
()
}
inner
class
QuestionPoolsViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnClickListener
{
inner
class
QuestionPoolsViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnClickListener
{
lateinit
var
mPool
:
Pool
var
qpCardView
:
CardView
?
=
null
...
...
@@ -77,14 +84,14 @@ class QuestionPoolsAdapter(var pools: ArrayList<Pool>, var mQuestionPoolOnClickH
var
qpButtonExpand
:
ImageButton
?
=
null
private
var
isExpanded
:
Boolean
=
false
private
var
selectedPools
:
ArrayList
<
Pool
>
=
arrayListOf
()
init
{
qpCardView
=
itemView
.
findViewById
(
cardView_item_question_pool
)
qpName
=
itemView
.
findViewById
(
textView_item_question_pool_name
)
qpInfo
=
itemView
.
findViewById
(
textView_item_question_pool_expanded
)
qpImage
=
itemView
.
findViewById
(
imageView_item_question_pool
)
qpButtonAddOrRemove
=
itemView
.
findViewById
(
sparkButton_item_question_pool_add_or_remove
)
qpButtonAddOrRemove
=
itemView
.
findViewById
(
sparkButton_item_question_pool_add_or_remove
)
qpButtonExpand
=
itemView
.
findViewById
(
imageButton_item_question_pool_expand
)
qpCardView
?.
setOnClickListener
(
this
)
...
...
@@ -93,13 +100,13 @@ class QuestionPoolsAdapter(var pools: ArrayList<Pool>, var mQuestionPoolOnClickH
qpName
?.
isSelected
=
true
selectedPools
.
addAll
(
pools
)
}
override
fun
onClick
(
v
:
View
?)
{
if
(
v
?.
id
==
cardView_item_question_pool
||
v
?.
id
==
imageButton_item_question_pool_expand
)
{
val
deg
=
if
(
qpButtonExpand
?.
rotation
==
180f
)
0f
else
180f
qpButtonExpand
?.
animate
()
?.
rotation
(
deg
)
?.
interpolator
=
AccelerateDecelerateInterpolator
()
qpButtonExpand
?.
animate
()
?.
rotation
(
deg
)
?.
interpolator
=
AccelerateDecelerateInterpolator
()
if
(!
isExpanded
)
{
qpInfo
?.
visibility
=
View
.
VISIBLE
qpInfo
?.
text
=
pools
[
adapterPosition
].
name
...
...
@@ -116,6 +123,7 @@ class QuestionPoolsAdapter(var pools: ArrayList<Pool>, var mQuestionPoolOnClickH
mPool
.
isSelected
=
true
selectedPools
.
add
(
mPool
)
mQuestionPoolOnClickHandler
.
onAddOrRemovePool
(
selectedPools
)
}
else
{
mPool
.
isSelected
=
false
selectedPools
.
remove
(
mPool
)
...
...
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