-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f541ec
commit 39af97d
Showing
17 changed files
with
211 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/example/androidProjectOnTFLite/ItemViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.androidProjectOnTFLite | ||
|
||
import android.net.Uri | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.androidProjectOnTFLite.RoomDB.Picture | ||
|
||
|
||
class ItemViewHolder(inflater: LayoutInflater, parent: ViewGroup) : RecyclerView.ViewHolder(inflater.inflate(R.layout.item, parent, false)){ | ||
|
||
private var classes: TextView? = null | ||
private var photo: ImageView? = null | ||
|
||
init{ | ||
classes = itemView.findViewById(R.id.classesTextView) | ||
photo = itemView.findViewById(R.id.photo) | ||
} | ||
|
||
fun bind(pic: Picture){ | ||
photo?.setImageURI(Uri.parse(pic.imgPath)) | ||
classes?.text = pic.imageNetClasses | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/example/androidProjectOnTFLite/RecyclerViewAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.androidProjectOnTFLite | ||
|
||
import android.net.Uri | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageButton | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.androidProjectOnTFLite.RoomDB.Picture | ||
import kotlinx.android.synthetic.main.item.view.* | ||
|
||
class RecyclerViewAdapter(val items: MutableList<Picture>) | ||
: RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>(){ | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) | ||
: ViewHolder { | ||
val v: View = LayoutInflater.from(parent.context) | ||
.inflate(R.layout.item,parent,false) | ||
return ViewHolder(v) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.image.setImageURI(Uri.parse(items[position].imgPath)) | ||
holder.classes.text = items[position].imageNetClasses | ||
holder.delete.setOnClickListener { deleteItem(position) } | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return items.size | ||
} | ||
|
||
private fun deleteItem(position: Int){ | ||
db?.pictureDao()?.delete(items[position]) //from db | ||
items.removeAt(position) //from list | ||
notifyItemRemoved(position) //from screen | ||
notifyItemRangeChanged(position, itemCount) | ||
} | ||
class ViewHolder(itemView:View): RecyclerView.ViewHolder(itemView){ | ||
val image: ImageView = itemView.photo | ||
val classes: TextView = itemView.classesTextView | ||
val delete: ImageButton = itemView.btnDelete | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/src/main/java/com/example/androidProjectOnTFLite/RoomDB/Picture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="595.275dp" | ||
android:height="841.891dp" | ||
android:viewportWidth="595.275" | ||
android:viewportHeight="841.891"> | ||
<path | ||
android:pathData="M326.039,513.568h-69.557v-9.441c0,-10.531 2.12,-19.876 6.358,-28.034c4.239,-8.156 13.165,-18.527 26.783,-31.117l12.33,-11.176c7.322,-6.678 12.684,-12.973 16.09,-18.882c3.4,-5.907 5.105,-11.817 5.105,-17.727c0,-8.99 -3.084,-16.022 -9.248,-21.098c-6.166,-5.073 -14.773,-7.611 -25.819,-7.611c-10.405,0 -21.646,2.152 -33.719,6.455c-12.075,4.305 -24.663,10.693 -37.765,19.171v-60.5c15.541,-5.395 29.735,-9.375 42.582,-11.946c12.843,-2.568 25.241,-3.854 37.186,-3.854c31.342,0 55.232,6.392 71.678,19.171c16.439,12.783 24.662,31.439 24.662,55.973c0,12.591 -2.506,23.862 -7.516,33.815c-5.008,9.956 -13.553,20.649 -25.625,32.08l-12.332,10.983c-8.736,7.966 -14.451,14.354 -17.148,19.171s-4.045,10.115 -4.045,15.896V513.568zM256.482,542.085h69.557v68.593h-69.557V542.085z" | ||
android:fillColor="#FFFFFF"/> | ||
<path | ||
android:pathData="M299.76,439.067m-218.516,0a218.516,218.516 0,1 1,437.032 0a218.516,218.516 0,1 1,-437.032 0" | ||
android:fillColor="#F44336"/> | ||
<path | ||
android:pathData="M184.061,369.552l46.347,-46.347l185.387,185.387l-46.347,46.347z" | ||
android:fillColor="#FFFFFF"/> | ||
<path | ||
android:pathData="M369.281,323.371l46.346,46.346l-185.387,185.387l-46.346,-46.346z" | ||
android:fillColor="#FFFFFF"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.