Remove changes from other PR
This commit is contained in:
parent
30339763ef
commit
463e3fce32
@ -9,4 +9,3 @@ data class Emoji(
|
|||||||
//Optional attributes
|
//Optional attributes
|
||||||
val category: String? = null
|
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
|
package com.h.pixeldroid.objects
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Represents a status posted by an account.
|
Represents a status posted by an account.
|
||||||
https://docs.joinmastodon.org/entities/status/
|
https://docs.joinmastodon.org/entities/status/
|
||||||
|
@ -7,4 +7,3 @@ data class Tag(
|
|||||||
//Optional attributes
|
//Optional attributes
|
||||||
val history: List<History>? = emptyList()
|
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