common-ktx

//library/ss_n.common_ktx.extension

Package ss_n.common_ktx.extension

Functions

Name Summary
addFragment [androidJvm]
fun AppCompatActivity.addFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
fun Fragment.addFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
addNowFragment [androidJvm]
fun AppCompatActivity.addNowFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
fun Fragment.addNowFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
changeDpToPx [androidJvm]
fun Context.changeDpToPx(dp: Float): Float
changeVisible [androidJvm]
fun View.changeVisible(isVisible: Boolean)
Change Visibility View.VISIBLE or View.GONE
createFullScreen [androidJvm]
fun Dialog.createFullScreen(@LayoutReslayoutRes: Int?, isCancelable: Boolean = true, isCanceledOnTouchOutside: Boolean = true)
Crate FullScreen Dialog Can be used in DialogFragment
createRetrofitService [androidJvm]
fun <T> String.createRetrofitService(service: Class<T>, client: OkHttpClient? = HttpClient.defaultClient, converterFactory: Converter.Factory? = MoshiConverterFactory.create( Builder().add(KotlinJsonAdapterFactory()).build() )): T
Create Retrofit Service
decimalText [androidJvm]
fun Int.decimalText(): String
fun Long.decimalText(): String
Integer to Decimal Text
decrypt [androidJvm]
fun String.decrypt(alias: String, ivKey: String = "", keyProvider: String = "AndroidKeyStore", isPrintError: Boolean = false): String?
delete [androidJvm]
fun DialogFragment.delete(fragmentManager: FragmentManager)
distanceBetween [androidJvm]
fun Location.distanceBetween(targetLocation: Location): Float
encrypt [androidJvm]
fun String.encrypt(alias: String, ivKey: String = "", keyProvider: String = "AndroidKeyStore", isPrintError: Boolean = false): String?
getAlarmManager [androidJvm]
fun Context.getAlarmManager(): AlarmManager
getColorCompat [androidJvm]
fun Context.getColorCompat(@ColorRescolorRes: Int): Int
getConnectivityManager [androidJvm]
fun Context.getConnectivityManager(): ConnectivityManager
getFileSize [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun String.getFileSize(sizeFormat: Long = 1024): Long
Get File Size
getInputMethodManager [androidJvm]
fun Context.getInputMethodManager(): InputMethodManager
getLocationManager [androidJvm]
fun Context.getLocationManager(): LocationManager
getNotificationManager [androidJvm]
fun Context.getNotificationManager(): NotificationManager
getPixelOffset [androidJvm]
fun Int.getPixelOffset(context: Context): Int
Get Dimension Offset
getPixelSize [androidJvm]
fun Int.getPixelSize(context: Context): Int
Get Dimension Pixel Size
getPreferences [androidJvm]
fun Context.getPreferences(name: String = "shared_pref"): SharedPreferences
getString [androidJvm]
fun EditText.getString(): String
Get to EditText Input Data
getViewSize [androidJvm]
fun View.getViewSize(): Point
Get View Size
gone [androidJvm]
fun View.gone()
Set Visibility to View.GONE
hasAudioRecordPermission [androidJvm]
fun Context.hasAudioRecordPermission(): Boolean
hasCalendarPermission [androidJvm]
fun Context.hasCalendarPermission(): Boolean
hasCameraCapturePermission [androidJvm]
fun Context.hasCameraCapturePermission(): Boolean
hasCameraPermission [androidJvm]
fun Context.hasCameraPermission(): Boolean
hasFile [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun String.hasFile(): Boolean
Has File
hasFilePermission [androidJvm]
fun Context.hasFilePermission(): Boolean
hasJapanese [androidJvm]
fun String.hasJapanese(errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Partial Matched Japanese
hasLocationPermission [androidJvm]
fun Context.hasLocationPermission(): Boolean
hasMediaRecordPermission [androidJvm]
fun Context.hasMediaRecordPermission(): Boolean
hasMicPermission [androidJvm]
fun Context.hasMicPermission(): Boolean
hasNotificationPermission [androidJvm]
@RequiresApi(value = 33)
fun Context.hasNotificationPermission(): Boolean
hasPermission [androidJvm]
fun Activity.hasPermission(permissions: Array<String>): Boolean
fun DialogFragment.hasPermission(permissions: Array<String>): Boolean
fun Fragment.hasPermission(permissions: Array<String>): Boolean
hasReadAudioPermission [androidJvm]
@RequiresApi(value = 33)
fun Context.hasReadAudioPermission(): Boolean
hasReadImagePermission [androidJvm]
@RequiresApi(value = 33)
fun Context.hasReadImagePermission(): Boolean
hasReadMoviePermission [androidJvm]
@RequiresApi(value = 33)
fun Context.hasReadMoviePermission(): Boolean
hasRuntimePermissions [androidJvm]
fun Context.hasRuntimePermissions(permissions: Array<String>): Boolean
hideKeyboard [androidJvm]
fun View.hideKeyboard()
fun Context.hideKeyboard(view: View?)
Hide to Keyboard
inflate [androidJvm]
fun ViewGroup.inflate(layoutInflater: LayoutInflater? = null, @LayoutReslayout: Int, attachToRoot: Boolean = false): View
Layout Inflate
initHiddenKeyboard [androidJvm]
fun Activity.initHiddenKeyboard()
Do not display keyboard in initial display of Activity
inVisible [androidJvm]
fun View.inVisible()
Set Visibility to View.INVISIBLE
isActiveNetwork [androidJvm]
@RequiresPermission(value = "android.permission.ACCESS_NETWORK_STATE")
fun Context.isActiveNetwork(): Boolean
isInt [androidJvm]
fun String.isInt(errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Matched Int
isMailAddress [androidJvm]
fun String.isMailAddress(errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Matched MailAddress
isNumber [androidJvm]
fun String.isNumber(errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Matched Number
isPhoneNumber [androidJvm]
fun String.isPhoneNumber(errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Matched PhoneNumber
isSuccessPermissionResult [androidJvm]
fun IntArray.isSuccessPermissionResult(): Boolean
loadSoundPool [androidJvm]
suspend fun Context.loadSoundPool(files: MutableList<Int>): MutableList<Int>
makeFile [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun String.makeFile(): File
Crate File from String If there is no directory, create it together
matchPattern [androidJvm]
fun String.matchPattern(pattern: String, errorMessage: String = "", error: (String) -> Unit?? = null): Boolean
Regex String
moveFile [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun String.moveFile(target: String): File?
Move File
onPermissionResult [androidJvm]
fun IntArray.onPermissionResult(permissionListener: PermissionListener)
recursiveDeleteFile [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun File.recursiveDeleteFile()
Recursive Delete Files
replaceFragment [androidJvm]
fun AppCompatActivity.replaceFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
fun Fragment.replaceFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
replaceNowFragment [androidJvm]
fun AppCompatActivity.replaceNowFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
fun Fragment.replaceNowFragment(@LayoutRescontainer: Int, fragment: Fragment, arg: Bundle? = null, isAddStack: Boolean = false, stackTag: String? = null)
requestLocation [androidJvm]
fun Context.requestLocation(locationListener: LocationListener, permissionError: () -> Unit?? = null, criteria: Criteria = Criteria().apply { accuracy = Criteria.ACCURACY_FINE powerRequirement = Criteria.POWER_HIGH isSpeedRequired = false isAltitudeRequired = false isBearingRequired = false isCostAllowed = true horizontalAccuracy = Criteria.ACCURACY_HIGH verticalAccuracy = Criteria.ACCURACY_HIGH }, enabledOnly: Boolean = true, minTime: Long = 1000, minDistance: Float = 40.0f)
resizeBitmap [androidJvm]
fun Uri.resizeBitmap(context: Context, width: Int, height: Int): Bitmap?
save [androidJvm]
@RequiresPermission(allOf = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"])
fun Bitmap.save(filePath: String, format: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG, quality: Int = 100, isErrorLog: Boolean = false): Boolean
Bitmap save
sendNotification [androidJvm]
fun Context.sendNotification(tag: String? = null, notificationId: Int, channelId: String, sender: PendingIntent, title: String, message: String, @DrawableRessmallIcon: Int, style: NotificationCompat.Style? = null, largeIcon: Bitmap? = null, largeIconRes: Int? = null, isBigStyle: Boolean = false, isAutoCancel: Boolean = false, isFullScreenIntent: Boolean = false)
setMargin [androidJvm]
fun View.setMargin(left: Int? = null, top: Int? = null, right: Int? = null, bottom: Int? = null)
Set Margin to View
setMarginRes [androidJvm]
fun View.setMarginRes(@DimenResleftRes: Int? = null, @DimenRestopRes: Int? = null, @DimenResrightRes: Int? = null, @DimenResbottomRes: Int? = null)
Set Margin to View
setNotificationChannel [androidJvm]
@RequiresApi(api = 26)
fun Context.setNotificationChannel(channelId: String, name: String, priority: Int = NotificationManager.IMPORTANCE_HIGH, description: String? = null)
setOnSingleClickListener [androidJvm]
fun View.setOnSingleClickListener(enableDelayTime: Long = ViewConfiguration.getJumpTapTimeout().toLong(), listener: (View?) -> Unit)
Set On Single Click Listener Interval is 500ms
showDialog [androidJvm]
fun AppCompatActivity.showDialog(dialog: DialogFragment, arg: Bundle? = null, tag: String = dialog.javaClass.canonicalName ?: "showDialog")
fun Fragment.showDialog(dialog: DialogFragment, arg: Bundle? = null, tag: String = dialog.javaClass.canonicalName ?: "showDialog")
showGallery [androidJvm]
fun Activity.showGallery(requestCode: Int = 1)
Show Gallery of Devise
showKeyboard [androidJvm]
fun EditText.showKeyboard(delayTime: Long = 0)
Show Keyboard
showToast [androidJvm]
fun String.showToast(context: Context, toastLength: Int = Toast.LENGTH_SHORT)
Show Toast
testObserver [androidJvm]
fun <T> LiveData<T>.testObserver(): TestObserver<T>
Used in unit tests
toBundleKey [androidJvm]
fun String.toBundleKey(value: Any): Bundle
Create Bundle
toBundleValue [androidJvm]
fun Any.toBundleValue(key: String): Bundle
Create Bundle
toCalender [androidJvm]
fun Date.toCalender(locale: Locale = Locale.getDefault()): Calendar
toDate [androidJvm]
fun String.toDate(pattern: String = "yyyy/MM/dd HH:mm:ss", locale: Locale = Locale.getDefault()): Date?
String parse to Date
toDay [androidJvm]
fun Date.toDay(locale: Locale = Locale.getDefault()): Int
toFormat [androidJvm]
fun Date.toFormat(pattern: String = "yyyy/MM/dd HH:mm:ss", locale: Locale = Locale.getDefault()): String
toHour [androidJvm]
fun Date.toHour(locale: Locale = Locale.getDefault()): Int
toJsonString [androidJvm]
fun Any.toJsonString(isLog: Boolean = false): String?
Object to Json String Must installed Moshi Code gen!!
toMapKey [androidJvm]
fun String.toMapKey(value: Any): Map<String, Any>
Create Map
toMapValue [androidJvm]
fun Any.toMapValue(key: String): Map<String, Any>
Create Map
toMinute [androidJvm]
fun Date.toMinute(locale: Locale = Locale.getDefault()): Int
toMonth [androidJvm]
fun Date.toMonth(locale: Locale = Locale.getDefault()): Int
toMutableMapKey [androidJvm]
fun String.toMutableMapKey(value: Any): MutableMap<String, Any>
Create MutableMap
toMutableMapValue [androidJvm]
fun Any.toMutableMapValue(key: String): MutableMap<String, Any>
Create MutableMap
toSecond [androidJvm]
fun Date.toSecond(locale: Locale = Locale.getDefault()): Int
toSepia [androidJvm]
fun Bitmap.toSepia(): Bitmap
Sepia image processing
toSpeech [androidJvm]
fun String.toSpeech(context: Context, utteranceProgressListener: UtteranceProgressListener? = null, pitchHeight: Float = 1.0f, pitchRate: Float = 1.0f): TextToSpeechManager.Error
Text To Speech
toYear [androidJvm]
fun Date.toYear(locale: Locale = Locale.getDefault()): Int
visible [androidJvm]
fun View.visible()
Set Visibility to View.VISIBLE