Skip to content

Commit

Permalink
fix base64 image lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Jun 6, 2022
1 parent 4c9c073 commit d03380e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.ethosa.ktc"
minSdk 21
targetSdk 32
versionCode 22
versionName "0.8.11"
versionCode 23
versionName "0.8.12"
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/ethosa/ktc/college/news/LastNews.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ import androidx.annotation.Keep
data class LastNews(
val anonce: List<News>,
val news: List<News>
)
) {
fun catch() {
for (new in news) new.catch()
for (new in anonce) new.catch()
}
}
10 changes: 8 additions & 2 deletions app/src/main/java/com/ethosa/ktc/college/news/News.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ data class News(
val title: String,
var body: String,
val date: String,
val image: String,
var image: String,
val id: String
)
) {
fun catch() {
if ("data:image" in image || image.length > 256) {
image = ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class NewsAdapter(
binding.root.setOnClickListener {
// Go to WallPostActivity
val intent = Intent(binding.root.context, WallPostActivity::class.java)
intent.putExtra("image", new.image)
intent.putExtra("id", new.id)
intent.putExtra("title", new.title)
intent.putExtra("image", new.image)
binding.root.context.startActivity(intent)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class NewsStoriesAdapter(
override fun onBindViewHolder(holder: ViewHolder, pos: Int) {
val binding = holder.binding
val new = items[pos]
new.catch()

// Download image and blurs it.
Glide.with(binding.root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ class NewsFragment : Fragment(), CollegeCallback {
// Parse JSON
val jsonString = response.body?.string()
val news = Gson().fromJson(jsonString, LastNews::class.java)
news.catch()
// Create animation object
val animate = ObjectAnimator.ofFloat(
_binding?.progressLoad, "alpha",
1f, 0f
).setDuration(500)
activity?.runOnUiThread {
animate.start()
_binding?.news?.adapter = NewsAdapter(news.anonce + news.news)
_binding?.news?.adapter = NewsAdapter(news.news + news.anonce)
_binding?.newsStories?.adapter = NewsStoriesAdapter(
(news.anonce + news.news)
.filter { it.image != "" }
Expand Down

0 comments on commit d03380e

Please sign in to comment.