extension UIApplication {
// Get the app's version
class func appVersion() -> String {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
}
// Get the app's build
class func appBuild() -> String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
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
| fun setButtonTint(button: FloatingActionButton, tint: ColorStateList) { | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| button.backgroundTintList = tint | |
| } else { | |
| ViewCompat.setBackgroundTintList(button, tint) | |
| } | |
| } |
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
| java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling. | |
| at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:112) | |
| at android.os.Handler.handleCallback(Handler.java:815) | |
| at android.os.Handler.dispatchMessage(Handler.java:104) | |
| at android.os.Looper.loop(Looper.java:194) | |
| at android.app.ActivityThread.main(ActivityThread.java:5624) | |
| at java.lang.reflect.Method.invoke(Native Method) | |
| at java.lang.reflect.Method.invoke(Method.java:372) | |
| at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) | |
| at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) |
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
| val inputStream = activity.contentResolver.openInputStream(uri) | |
| val drawable = Drawable.createFromStream(inputStream, uri.toString()) |
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
| var stringBuilder = StringBuilder(100) // Initialization Example | |
| stringBuilder.setLength(0) // Set length of buffer to 0 for clearing the StringBuilder | |
| stringBuilder.trimToSize() // Trim the underlying buffer |
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
| Uri uri = getImageUri(bitmap); | |
| String path = getRealPathFromURI(uri); | |
| String filename = path.substring(path.lastIndexOf("/")+1); | |
| String fileWOExtension; | |
| if (filename.indexOf(".") > 0) { | |
| fileWOExtension = filename.substring(0, filename.lastIndexOf(".")); | |
| } else { | |
| fileWOExtension = filename; | |
| } | |
| Log.d(TAG, "Real Path: " + path); |
private String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {fun getImageUriFromBitmap(context: Context, bitmap: Bitmap): Uri{
val bytes = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes)
val path = MediaStore.Images.Media.insertImage(context.contentResolver, bitmap, "Title", null)
return Uri.parse(path.toString())
}
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
| // Button Border XML | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:shape="rectangle"> | |
| <gradient android:startColor="#FFFFFF" | |
| android:endColor="#46A4EF" | |
| android:angle="180" /> | |
| <corners android:radius="5dp" /> | |
| <stroke android:width="5px" android:color="#000000" /> | |
| </shape> |
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
| func getPhoto(_ url: String){ | |
| // If hhtp is missing from the url | |
| //let tempUrl: String = "http:" + url.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
| let tempUrl: String = url.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
| if let mURL = URL(string: tempUrl) { | |
| //print(mURL) | |
| if let mData = try? Data(contentsOf: mURL) { |