Remove changes from other PR

This commit is contained in:
Matthieu 2020-03-06 00:24:43 +01:00
parent 30339763ef
commit 463e3fce32
5 changed files with 3 additions and 51 deletions

View File

@ -9,4 +9,3 @@ data class Emoji(
//Optional attributes
val category: String? = null
)

View File

@ -1,21 +0,0 @@
package com.h.pixeldroid.objects
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.h.pixeldroid.utils.ImageConverter.Companion.retrieveBitmapFromUrl
import java.io.Serializable
class Post(private val status: Status) : Serializable {
fun getPostImage(context : AppCompatActivity) : ImageView {
//Retreive the url from the list of media attachments
val imgUrl = status.component9()[0].component3()
//Convert retrieved bitmap to an ImageView and return it
val imageView: ImageView = ImageView(context)
imageView.setImageBitmap(retrieveBitmapFromUrl(imgUrl))
return imageView
}
}

View File

@ -1,5 +1,6 @@
package com.h.pixeldroid.objects
/*
Represents a status posted by an account.
https://docs.joinmastodon.org/entities/status/

View File

@ -7,4 +7,3 @@ data class Tag(
//Optional attributes
val history: List<History>? = emptyList()
)

View File

@ -1,26 +0,0 @@
package com.h.pixeldroid.utils
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class ImageConverter {
companion object {
fun retrieveBitmapFromUrl(src : String) : Bitmap? {
return try {
val url: URL = URL(src)
val connection : HttpURLConnection = url.openConnection() as HttpURLConnection
connection.doInput = true
connection.connect()
val input : InputStream = connection.inputStream
BitmapFactory.decodeStream(input)
} catch (e : IOException) {
e.printStackTrace()
null
}
}
}
}