Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
vocabulary_notebook
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
254957f2
authored
Sep 08, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring
parent
9d2a7e51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
54 deletions
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.java
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/res/layout/list_item.xml → app/src/main/res/layout/word_item.xml
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.java
deleted
100644 → 0
View file @
9d2a7e51
package
com
.
paktalin
.
vocabularynotebook
;
import
android.support.annotation.NonNull
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
com.paktalin.vocabularynotebook.pojo.WordItemPojo
;
import
java.util.List
;
public
class
VocabularyAdapter
extends
RecyclerView
.
Adapter
<
VocabularyAdapter
.
ViewHolder
>
{
private
static
final
String
TAG
=
"VN/"
+
VocabularyAdapter
.
class
.
getSimpleName
();
private
List
<
WordItemPojo
>
wordItems
;
public
VocabularyAdapter
(
List
<
WordItemPojo
>
wordItems
)
{
this
.
wordItems
=
wordItems
;
Log
.
d
(
TAG
,
"wordItems: "
+
wordItems
);
}
@NonNull
@Override
public
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
View
view
=
LayoutInflater
.
from
(
parent
.
getContext
())
.
inflate
(
R
.
layout
.
list_item
,
parent
,
false
);
return
new
ViewHolder
(
view
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
ViewHolder
holder
,
int
position
)
{
WordItemPojo
item
=
wordItems
.
get
(
position
);
Log
.
d
(
TAG
,
"bind item: "
+
item
);
holder
.
tvWord
.
setText
(
item
.
getWord
());
holder
.
tvTranslation
.
setText
(
item
.
getTranslation
());
}
@Override
public
int
getItemCount
()
{
return
wordItems
.
size
();
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvWord
,
tvTranslation
;
ViewHolder
(
View
itemView
)
{
super
(
itemView
);
tvWord
=
itemView
.
findViewById
(
R
.
id
.
tvWord
);
tvTranslation
=
itemView
.
findViewById
(
R
.
id
.
tvTranslation
);
}
}
}
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
0 → 100644
View file @
254957f2
package
com.paktalin.vocabularynotebook
import
android.support.v7.widget.RecyclerView
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
com.paktalin.vocabularynotebook.pojo.WordItemPojo
class
VocabularyAdapter
(
private
val
wordItems
:
List
<
WordItemPojo
>)
:
RecyclerView
.
Adapter
<
VocabularyAdapter
.
ViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
word_item
,
parent
,
false
)
return
ViewHolder
(
view
)
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
val
item
=
wordItems
[
position
]
holder
.
tvWord
.
text
=
item
.
word
holder
.
tvTranslation
.
text
=
item
.
translation
}
override
fun
getItemCount
():
Int
{
return
wordItems
.
size
}
inner
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
var
tvWord
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
tvWord
)
var
tvTranslation
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
tvTranslation
)
}
companion
object
{
private
val
TAG
=
"VN/"
+
VocabularyAdapter
::
class
.
java
.
simpleName
}
}
\ No newline at end of file
app/src/main/res/layout/
list
_item.xml
→
app/src/main/res/layout/
word
_item.xml
View file @
254957f2
File moved
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