This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LiveSubject.FILE_UPLOAD_FILE.subscribe({ | |
when(it) { | |
is UploadFileStatus.Complete -> { | |
Glide.with(this).load(it.s3Url).into(image) | |
toast("Uploaded image") | |
logD("complete upload") | |
} | |
is UploadFileStatus.Error -> { | |
logE("could not upload") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UploadService : JobIntentService() { | |
private val secrets = getSecrets() | |
override fun onHandleWork(intent: Intent) { | |
if (intent.extras?.containsKey(IMAGE_URI) == true) { | |
val imageUri = intent.getParcelableExtra<Uri>(IMAGE_URI) | |
var image: Bitmap? = null | |
if (imageUri != null) { | |
image = MediaStore.Images.Media.getBitmap(contentResolver, imageUri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
companion object { | |
/** | |
* Unique job ID for this service. | |
*/ | |
const val JOB_ID = 1000 | |
const val IMAGE_URI = "image_uri" | |
const val IMAGE_URL = "image_url" | |
const val DOCUMENT_URI = "document_uri" | |
const val DOCUMENT_URL = "document_url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class UploadFileStatus{ | |
data class FileStatus(val status: Int): UploadFileStatus() | |
data class Error(val exception: Throwable): UploadFileStatus() | |
data class Complete(val s3Url: String): UploadFileStatus() | |
data class Start(val start: Boolean): UploadFileStatus() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Aws SDK | |
implementation 'com.amazonaws:aws-android-sdk-core:2.6.+' | |
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.+' | |
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.+' | |
implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.+' | |
// RxJava | |
implementation "io.reactivex.rxjava3:rxjava:3.0.4" | |
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object EMOJIS { | |
private const val GRINNING_FACE = "😀" | |
private const val BEAMING_FACE_WITH_SMILING_EYES = "😁" | |
private const val GRINNING_SQUINTING_FACE = "😆" | |
private const val GRINNING_FACE_WITH_SWEAT = "😅" | |
const val FACE_WITH_TEARS_OF_JOY = "😂" | |
private const val ROLLING_ON_THE_FLOOR_LAUGHING = "🤣" | |
private const val SLIGHTLY_SMILING_FACE = "🙂" | |
private const val UPSIDE_DOWN_FACE = "🙃" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mediaRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { | |
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { | |
if ((gridLayoutManager.findLastVisibleItemPosition() == localDocumentsAdapter.itemCount - DOCUMENT_BUFFER) && dy > 0) { | |
documentViewModel.getImages(DOCUMENTS_COUNT) | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val _imagesLiveData = MutableLiveData<MutableList<Three<Uri?, String?, Date>>>() | |
val imagesLiveData: LiveData<MutableList<Three<Uri?, String?, Date>>> | |
get() = _imagesLiveData | |
private var start = 0 | |
private var areAllLoaded = false | |
fun getImages(count: Int) { | |
if (areAllLoaded) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun getImages(count: Int, start: Int): Three<MutableList<Three<Uri?, String?, Date>>, Boolean, Int> { | |
val imagesList = mutableListOf<Three<Uri?, String?, Date>>() | |
var index = start | |
return withContext(Dispatchers.IO) { | |
while (imageCursor?.moveToPosition(i) == true) { | |
val id = imageIdColumn?.let { imageCursor.getLong(it) } | |
val dateModified = Date(TimeUnit.SECONDS.toMillis(imageCursor.getLong(imageDateModifiedColumn ?: 0))) | |
val displayName = imageDisplayNameColumn?.let { imageCursor.getString(it) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fiftyone as fo | |
import os | |
import xml.etree.ElementTree as ET | |
import cv2 | |
name = "headsegmentation_dataset_ccncsa" | |
dataset_dir = "/home/priyansh-kedia/Documents/Datasets/headsegmentation_dataset_ccncsa/" | |
dataset = fo.Dataset() |
NewerOlder