Skip to content

Commit a29087f

Browse files
feat : restructure the repo to include other API placeholders
1 parent 25aa2f1 commit a29087f

File tree

14 files changed

+136
-8
lines changed

14 files changed

+136
-8
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
<meta-data
1616
android:name="preloaded_fonts"
1717
android:resource="@array/preloaded_fonts" />
18-
19-
<activity android:name=".MainActivity"
20-
android:theme="@style/AppThemeNoActionbar">
18+
<activity
19+
android:name=".ImageLabelActivity"
20+
android:theme="@style/AppThemeNoActionbar"/>
21+
<activity android:name=".HomeActivity">
2122
<intent-filter>
2223
<action android:name="android.intent.action.MAIN" />
2324

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.the_dagger.mlkit
2+
3+
import android.support.v7.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.support.v7.widget.LinearLayoutManager
6+
import kotlinx.android.synthetic.main.activity_home.*
7+
8+
class HomeActivity : AppCompatActivity() {
9+
10+
private val apiList by lazy {
11+
ArrayList<PojoApi>()
12+
}
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
setContentView(R.layout.activity_home)
17+
apiList.add(PojoApi(R.drawable.text_recognition,getString(R.string.title_text),getString(R.string.desc_text),0))
18+
apiList.add(PojoApi(R.drawable.face_detection,getString(R.string.title_face),getString(R.string.desc_face),1))
19+
apiList.add(PojoApi(R.drawable.barcode_scanning,getString(R.string.title_barcode),getString(R.string.desc_barcode),2))
20+
apiList.add(PojoApi(R.drawable.image_labelling,getString(R.string.title_labelling),getString(R.string.desc_labelling),3))
21+
apiList.add(PojoApi(R.drawable.landmark_identification,getString(R.string.title_landmark),getString(R.string.desc_landmark),4))
22+
23+
rvHome.layoutManager = LinearLayoutManager(this)
24+
rvHome.adapter = HomeAdapter(apiList)
25+
}
26+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.github.the_dagger.mlkit
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import android.support.v7.widget.RecyclerView
6+
import android.view.LayoutInflater
7+
import android.view.View
8+
import android.view.ViewGroup
9+
import android.widget.Toast
10+
import kotlinx.android.synthetic.main.item_row_home.view.*
11+
12+
class HomeAdapter(private val apiList: List<PojoApi>) : RecyclerView.Adapter<HomeAdapter.HomeHolder>() {
13+
14+
lateinit var context: Context
15+
16+
class HomeHolder(itemView: View?) : RecyclerView.ViewHolder(itemView)
17+
18+
override fun onBindViewHolder(holder: HomeHolder, position: Int) {
19+
val currItem = apiList[position]
20+
with(holder.itemView) {
21+
tViewApiName.text = currItem.title
22+
tViewApiDesc.text = currItem.desc
23+
iViewApi.setImageResource(currItem.imageId)
24+
cViewHome.setOnClickListener {
25+
when(currItem.id){
26+
0 -> Toast.makeText(context,"Work in Progress",Toast.LENGTH_SHORT).show()
27+
1 -> Toast.makeText(context,"Work in Progress",Toast.LENGTH_SHORT).show()
28+
2 -> Toast.makeText(context,"Work in Progress",Toast.LENGTH_SHORT).show()
29+
3 -> context.startActivity(Intent(context,ImageLabelActivity::class.java))
30+
4 -> Toast.makeText(context,"Work in Progress",Toast.LENGTH_SHORT).show()
31+
}
32+
}
33+
}
34+
}
35+
36+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeHolder {
37+
context = parent.context
38+
return HomeHolder(LayoutInflater.from(context).inflate(R.layout.item_row_home, parent, false))
39+
}
40+
41+
override fun getItemCount() = apiList.size
42+
}

app/src/main/java/io/github/the_dagger/mlkit/MainActivity.kt renamed to app/src/main/java/io/github/the_dagger/mlkit/ImageLabelActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import kotlinx.android.synthetic.main.activity_main.*
1313
import kotlinx.android.synthetic.main.layout_bottom_sheet.*
1414

1515

16-
class MainActivity : AppCompatActivity() {
16+
class ImageLabelActivity : AppCompatActivity() {
1717

1818
private var itemsList: ArrayList<Any> = ArrayList()
19-
private lateinit var itemAdapter: ItemAdapter
19+
private lateinit var itemAdapter: ImageLabelAdapter
2020

2121
private lateinit var sheetBehavior: BottomSheetBehavior<*>
2222

@@ -59,7 +59,7 @@ class MainActivity : AppCompatActivity() {
5959
// Task completed successfully
6060
fabProgressCircle.hide()
6161
itemsList.addAll(it)
62-
itemAdapter = ItemAdapter(itemsList,false)
62+
itemAdapter = ImageLabelAdapter(itemsList,false)
6363
rvLabel.adapter = itemAdapter
6464
sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED)
6565
}
@@ -80,7 +80,7 @@ class MainActivity : AppCompatActivity() {
8080
// Task completed successfully
8181
fabProgressCircle.hide()
8282
itemsList.addAll(it)
83-
itemAdapter = ItemAdapter(itemsList,true)
83+
itemAdapter = ImageLabelAdapter(itemsList,true)
8484
rvLabel.adapter = itemAdapter
8585
sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED)
8686
}

app/src/main/java/io/github/the_dagger/mlkit/ItemAdapter.kt renamed to app/src/main/java/io/github/the_dagger/mlkit/ImageLabelAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.google.firebase.ml.vision.cloud.label.FirebaseVisionCloudLabel
1010
import com.google.firebase.ml.vision.label.FirebaseVisionLabel
1111
import kotlinx.android.synthetic.main.item_row.view.*
1212

13-
class ItemAdapter(private val firebaseVisionList: List<Any>, private val isCloud: Boolean) : RecyclerView.Adapter<ItemAdapter.ItemHolder>() {
13+
class ImageLabelAdapter(private val firebaseVisionList: List<Any>, private val isCloud: Boolean) : RecyclerView.Adapter<ImageLabelAdapter.ItemHolder>() {
1414
lateinit var context: Context
1515
inner class ItemHolder(itemView: View?) : RecyclerView.ViewHolder(itemView) {
1616

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package io.github.the_dagger.mlkit
2+
3+
class PojoApi(val imageId: Int, val title: String, val desc: String, val id : Int)
34.7 KB
Loading
37.4 KB
Loading
30 KB
Loading
29.6 KB
Loading

0 commit comments

Comments
 (0)