Remove changes from other PR
This commit is contained in:
parent
30339763ef
commit
463e3fce32
@ -8,5 +8,4 @@ data class Emoji(
|
||||
val visible_in_picker: Boolean,
|
||||
//Optional attributes
|
||||
val category: String? = null
|
||||
)
|
||||
|
||||
)
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.h.pixeldroid.objects
|
||||
|
||||
|
||||
/*
|
||||
Represents a status posted by an account.
|
||||
https://docs.joinmastodon.org/entities/status/
|
||||
|
@ -6,5 +6,4 @@ data class Tag(
|
||||
val url: String,
|
||||
//Optional attributes
|
||||
val history: List<History>? = emptyList()
|
||||
)
|
||||
|
||||
)
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user