Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 Singleton { | |
// singelton pattern | |
private static var privateShared : Singleton? | |
class func shared() -> Singleton { | |
// make sure we get an instance from the singleton queue | |
guard let uwShared = read(privateShared) else { | |
privateShared = Singleton() | |
return privateShared! |
This file contains hidden or 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
// No Security | |
{ | |
"rules": { | |
".read": true, | |
".write": true | |
} | |
} |
This file contains hidden or 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 fun storeImage(bitmap: Bitmap, fileName: String){ | |
val wrapper = ContextWrapper(context) | |
var file = wrapper.getDir("images", Context.MODE_PRIVATE) | |
file = File(file, "${fileName}.jpg") | |
try{ | |
val stream: OutputStream = FileOutputStream(file) | |
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream) | |
stream.flush() | |
stream.close() | |
imageUri = Uri.parse(file.absolutePath) |
This file contains hidden or 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
Glide.with(this) | |
.load("imageUrl") | |
.into(object : CustomTarget<Drawable>(850, 850) { | |
override fun onLoadCleared(placeholder: Drawable?) { | |
// called when imageView is cleared. If you are referencing the bitmap | |
// somewhere else too other than this imageView clear it here | |
} | |
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) { | |
img_view.setImageDrawable(resource) | |
//do any aditional action |
This file contains hidden or 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 fun copyToClipboard(text: String){ | |
val clipboard = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager | |
val clip = ClipData.newPlainText(UUID.randomUUID().toString(), text) | |
clipboard.setPrimaryClip(clip) | |
} |
This file contains hidden or 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
package me.marcosdavalos.util | |
import android.graphics.Bitmap | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.view.View | |
val View.toBitmap: Bitmap get(){ | |
val bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888) | |
val canvas = Canvas(bitmap) |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="black">#000000</color> | |
<color name="white">#FFFFFF</color> | |
<color name="red_50">#FFEBEE</color> | |
<color name="red_100">#FFCDD2</color> | |
<color name="red_200">#EF9A9A</color> | |
<color name="red_300">#E57373</color> |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<androidx.cardview.widget.CardView | |
android:id="@+id/card_view" |
NewerOlder