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
9b0bdf06
authored
Sep 08, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved WordItem from java to kotlin
parent
53ae3ce5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
87 deletions
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.java
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
app/src/main/java/com/paktalin/vocabularynotebook/activities/WordItemInfoActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
9b0bdf06
...
...
@@ -27,8 +27,8 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>,
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
val
wordItem
=
wordItems
[
position
]
holder
.
tvWord
.
text
=
wordItem
.
pojo
.
word
holder
.
tvTranslation
.
text
=
wordItem
.
pojo
.
translation
holder
.
tvWord
.
text
=
wordItem
.
pojo
!!
.
word
holder
.
tvTranslation
.
text
=
wordItem
.
pojo
!!
.
translation
holder
.
itemView
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
itemView
.
setOnLongClickListener
{
deleteWordItem
(
position
);
true
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.java
deleted
100644 → 0
View file @
53ae3ce5
package
com
.
paktalin
.
vocabularynotebook
;
import
android.support.annotation.NonNull
;
import
android.util.Log
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.firebase.firestore.DocumentReference
;
import
com.google.firebase.firestore.FirebaseFirestore
;
import
java.io.Serializable
;
public
class
WordItem
implements
Serializable
{
private
static
final
String
TAG
=
"VN/"
+
WordItem
.
class
.
getSimpleName
();
public
static
class
WordItemPojo
implements
Serializable
{
private
String
word
,
translation
;
public
WordItemPojo
(
String
word
,
String
translation
)
{
this
.
word
=
word
;
this
.
translation
=
translation
;
}
public
String
getWord
()
{
return
word
;
}
public
void
setWord
(
String
word
)
{
this
.
word
=
word
;
}
public
String
getTranslation
()
{
return
translation
;
}
public
void
setTranslation
(
String
translation
)
{
this
.
translation
=
translation
;
}
}
private
String
id
;
private
String
vocabularyId
;
private
WordItemPojo
pojo
;
public
WordItem
(
String
word
,
String
translation
,
String
id
,
String
vocabularyId
)
{
this
.
pojo
=
new
WordItemPojo
(
word
,
translation
);
this
.
vocabularyId
=
vocabularyId
;
this
.
id
=
id
;
}
public
void
delete
()
{
FirebaseFirestore
.
getInstance
().
collection
(
"vocabularies"
).
document
(
vocabularyId
)
.
collection
(
"words"
).
document
(
id
).
delete
()
.
addOnSuccessListener
(
new
OnSuccessListener
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
aVoid
)
{
Log
.
i
(
TAG
,
"Successfully deleted word with id "
+
id
);
}
}).
addOnFailureListener
(
new
OnFailureListener
()
{
@Override
public
void
onFailure
(
@NonNull
Exception
e
)
{
Log
.
w
(
TAG
,
"deleteWordWithId "
+
id
+
":failure"
,
e
.
fillInStackTrace
());
}
});
}
public
WordItemPojo
getPojo
()
{
return
pojo
;
}
public
void
setPojo
(
WordItemPojo
pojo
)
{
this
.
pojo
=
pojo
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
0 → 100644
View file @
9b0bdf06
package
com.paktalin.vocabularynotebook
import
android.util.Log
import
com.google.android.gms.tasks.OnFailureListener
import
com.google.android.gms.tasks.OnSuccessListener
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.FirebaseFirestore
import
java.io.Serializable
class
WordItem
(
word
:
String
,
translation
:
String
,
var
id
:
String
?,
private
val
vocabularyId
:
String
)
:
Serializable
{
var
pojo
:
WordItemPojo
?
=
null
class
WordItemPojo
(
var
word
:
String
?,
var
translation
:
String
?)
:
Serializable
init
{
this
.
pojo
=
WordItemPojo
(
word
,
translation
)
}
fun
delete
()
{
FirebaseFirestore
.
getInstance
().
collection
(
"vocabularies"
).
document
(
vocabularyId
)
.
collection
(
"words"
).
document
(
id
!!
).
delete
()
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully deleted word with id $id"
)
}
.
addOnFailureListener
{
e
->
Log
.
w
(
TAG
,
"deleteWordWithId $id:failure"
,
e
.
fillInStackTrace
())
}
}
companion
object
{
private
val
TAG
=
"VN/"
+
WordItem
::
class
.
java
.
simpleName
}
}
app/src/main/java/com/paktalin/vocabularynotebook/activities/WordItemInfoActivity.kt
View file @
9b0bdf06
...
...
@@ -19,8 +19,8 @@ class WordItemInfoActivity: AppCompatActivity() {
}
private
fun
updateUi
()
{
tvWord
.
text
=
wordItem
.
pojo
.
word
tvTranslation
.
text
=
wordItem
.
pojo
.
translation
tvWord
.
text
=
wordItem
.
pojo
!!
.
word
tvTranslation
.
text
=
wordItem
.
pojo
!!
.
translation
}
companion
object
{
private
val
TAG
=
"VN/"
+
WordItemInfoActivity
::
class
.
java
.
simpleName
}
...
...
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