Skip to content

Commit

Permalink
Merge pull request #7 from wahyutirta/mobile
Browse files Browse the repository at this point in the history
V 1.0.2
  • Loading branch information
ilhamhadisyah authored Jun 2, 2021
2 parents a6d37cf + 9a7ab66 commit 7512177
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.example.dermate.ui.adapter
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.res.Resources
import android.graphics.Color
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
Expand All @@ -24,6 +25,7 @@ class ArticleListViewAdapter(private val articleList: List<String>) :

private val binding = ArticleItemBinding.bind(view)
private lateinit var richPreview: RichPreview
@ExperimentalStdlibApi
internal fun bind(url: String) {

extractUrl(url)
Expand All @@ -41,6 +43,7 @@ class ArticleListViewAdapter(private val articleList: List<String>) :
}
}

@ExperimentalStdlibApi
private fun extractUrl(url: String) {
var data: MetaData

Expand All @@ -55,8 +58,20 @@ class ArticleListViewAdapter(private val articleList: List<String>) :
title.joinToString(" ")
}
binding.apply {
val halodoc = "HALODOC"
val alodokter = "ALODOKTER"
val articleProviderText ="Article by ${data.sitename}"
articleProvider.text = articleProviderText
if (data.sitename.equals(halodoc,true)){
articleProvider.text = articleProviderText
articleProvider.setTextColor(itemView.resources.getColor(R.color.red_pastel))
} else if (data.sitename.equals(alodokter,true)){
articleProvider.text = articleProviderText
articleProvider.setTextColor(itemView.resources.getColor(R.color.blue_pastel))
}else{
articleProvider.text = articleProviderText
articleProvider.setTextColor(itemView.resources.getColor(R.color.theme_color))
}

urlTitle.text = trimTitle
Glide.with(itemView.context.applicationContext).load(data.imageurl).into(imageThumbnail)
}
Expand All @@ -80,6 +95,7 @@ class ArticleListViewAdapter(private val articleList: List<String>) :
return ViewHolder(view)
}

@ExperimentalStdlibApi
override fun onBindViewHolder(holder: ArticleListViewAdapter.ViewHolder, position: Int) {

holder.bind(articleList[position])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HomeFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
articleViewModel = ViewModelProvider(this)[ArticleViewModel::class.java]
articleViewModel.articleData().observe(requireParentFragment().viewLifecycleOwner, {
it.url?.let { data -> setUi(data) }
it.url?.let { data -> setUi(data.shuffled()) }
})
}
private fun setUi(data : List<String>){
Expand Down
Loading

0 comments on commit 7512177

Please sign in to comment.