Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
otashjumaev committed Dec 6, 2020
1 parent 8cecd9f commit 4c886fb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/com/imb/jobtop/adapter/CategoryAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.imb.jobtop.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -9,6 +10,7 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.imb.jobtop.R
import com.imb.jobtop.model.Category
import com.imb.jobtop.utils.Colors
import kotlinx.android.synthetic.main.list_item_category.view.*
import kotlinx.android.synthetic.main.list_item_job.view.*

Expand All @@ -29,7 +31,7 @@ class CategoryViewHolder(itemView: View) :
fun bind(item: Category, onclickListener: OnCategoryClickListener) {
itemView.categoryTitle.text = item.title
itemView.categoryCount.text = "${item.jobCount} ta ish o'rni mavjud"
// itemView.categoryIcon.setImageBitmap(item.icon)
itemView.setBackgroundColor(Colors.getRandomColor())
itemView.setOnClickListener { onclickListener.onClick(item) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class FragmentMainVacancy : BaseFragment(R.layout.fragment_main_vacancy) {
db = Firebase.firestore
data = mutableListOf()
categ = mutableListOf()
dataByInterest = mutableListOf()

db.collection("user").document(Firebase.auth.uid!!).get().addOnSuccessListener {
interest = it.toObject<User>()?.interests
fetchData("energetika")
Expand Down Expand Up @@ -97,11 +99,11 @@ class FragmentMainVacancy : BaseFragment(R.layout.fragment_main_vacancy) {
val d = doc.toObject<Vacancy>()
data.add(Mapper.vacancyToJob(d, doc.id, cat))
interest?.let {
if (doc.id == interest)
if (cat == interest)
dataByInterest.add(Mapper.vacancyToJob(d, doc.id, cat))
}
Log.d("TAG", "fetchData: ${doc.id} ${doc.data}")
Log.d("TAG", "fetchedData: $d")
Log.d("TAG", "fetchData: ${doc.id}")
Log.d("TAG", "\n\ninterest: $interest \n\n")
}
categ.add(Category(db.collection(cat).id, cat, document.documents.size))
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/imb/jobtop/model/models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ data class Job(
var salary: String,
var isFavorite: Boolean = false,
var location: String,
var requirements: String
var requirements: String,
val lat: String? = null,
val lng: String? = null
)

data class Category(
Expand Down Expand Up @@ -45,7 +47,9 @@ object Mapper {
phoneNumber = v.tel ?: "000",
salary = v.maosh ?: "tekinga",
location = v.address ?: "oshatta",
requirements = v.talablar ?: "diplom bolsa boldi"
requirements = v.talablar ?: "diplom bolsa boldi",
lat = v.lat,
lng = v.lng,
)
}
}
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/imb/jobtop/utils/Colors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.imb.jobtop.utils

import androidx.core.graphics.toColorInt
import java.util.*

object Colors {
fun getRandomColor(): Int {
val list = listOf(
"#9AD3BC",
"#89BEB3",
"#FFB6B9",
"#94B4A4",
"#FFAAA5"
)
return list[Random().nextInt(4)].toColorInt()
}
}
8 changes: 4 additions & 4 deletions app/src/main/res/layout/list_item_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp">
android:layout_margin="4dp">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_category_item"
android:foreground="?android:selectableItemBackground"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
Expand All @@ -26,14 +26,14 @@
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@color/black"
android:textSize="20sp" />
android:textSize="17sp" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/categoryCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="18sp" />
android:textSize="15sp" />

</androidx.appcompat.widget.LinearLayoutCompat>

Expand Down

0 comments on commit 4c886fb

Please sign in to comment.