Class CommonExtKt
-
- All Implemented Interfaces:
public final class CommonExtKt
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringGET_REQUESTpublic final static StringUTF8public final static StringRESPONSE_OKpublic final static IntegerRESPONSE_CODE_SUCCESSpublic final static StringMIME_TEXTpublic final static StringALLOW_ACCESS_CONTROL_ORIGINpublic final static StringALLOW_ALL_ORIGINSprivate final static LongmbToBytesprivate final static LongbytesToKbsprivate final static LongbytesToMbsprivate final static FloatbytesToMbs
-
Method Summary
Modifier and Type Method Description final LonggetMbToBytes()final LonggetBytesToKbs()final LonggetBytesToMbs()final FloatgetBytesToMbs()final static BooleanisNotNullNotEmpty(String $self)final static BooleanisNotNullNotEmpty(Array<?> $self)final static BooleanisNotNullNotEmpty(JSONObject $self)final static StringorDefault(String $self, String defaultValue)final static IntegertoIntFlag(Boolean $self)final static BooleanisNullOrEmpty(JSONArray $self)final static BooleanisEmpty(JSONArray $self)final static Map<String, String>toStringMap(JSONObject $self)final static UnitputAll(Map<String, String> $self, Map<String, String> map)final static Unitput(Map<String, String> $self, Pair<String, String> entry)final static GzipSinkgzipSink(OutputStream $self)final static BufferedSourcegzipSource(BufferedSource $self)final static Integershr(Byte $self, Byte that)final static WebResourceResponsetoWebResourceResponse(InputStream $self, String mimeType)final static BooleanisGetRequest(WebResourceRequest $self)final static IntegertoDp(Float $self)Catching the Exception in case of any faulty values in Floating point numbers final static IntegerconvertToDp(Integer $self)convert this pixels value to dp final static IntegerconvertToPixels(Integer $self)convert this dp value to pixels final static IntegerroundToIntSafe(Float $self)convert this pixels value to dp final static FloatroundTo1Precision(Float $self)final static Pair<Integer, Integer>getScreenWidthAndHeight(Context $self)final static BitSettoBitSet(ByteArray $self)Convert a ByteArray to a BitSet by iterating through each byte and extracting each bit and setting it in the BitSet final static StringgetMainStackTrace(BufferedSource $self, Integer maxNumberOfLines, String startMarker, String endMarker)This function extracts the main stack trace from an input stream. final static BooleanisEdgeToEdgeEnabled(Context $self)final static UnithandleInsetsForEmbeddedBrowser(WindowInsetsHandler.FinalInsets $self, RelativeLayout.LayoutParams layoutParams, Orientation orientation)final static JSONObjectgetOrientationAppendedSafeArea(WindowInsetsHandler.FinalInsets $self, Orientation orientation)final static StringconvertToUrlEncodedForm(Map<String, ?> $self)final static <T extends Any> UnitonCompleted(Deferred<T> $self, Function1<T, Unit> onCompleted)final static UnitsafeClose(Source $self)final static UnitsafeClose(Sink $self)final static StringgetBase64EncodedString(BufferedSource $self)final static UnitsafeCancel(CoroutineScope $self)final static JobscheduleAtFixedRate(CoroutineScope $self, Long initialDelay, Long period, SuspendFunction0<Unit> action)final static JobscheduleAtFixedRateInMain(CoroutineScope $self, Long initialDelay, Long period, SuspendFunction0<Unit> action)final static UnitwithLockSafe(ReentrantMutex $self, SuspendFunction0<Unit> action)final static IntentregisterReceiverCompat(Context $self, BroadcastReceiver receiver, IntentFilter filter)final static Map<String, Object>union(Map<String, Object> $self, Map<String, Object> map)final static <T extends Any> TgetCatching(T default, Function0<T> block)final static BitmapgetBitmapFromDrawable(Context $self, Integer drawableId)Method to convert a drawable to a bitmap final static BooleanisValidUrl(String $self)final static BooleanisWithinThreshold(Long $self, Long other, Long threshold)Compares two Long values and checks if their absolute difference is within a specified threshold. final static ActivityfindActivityContext(View $self, Integer maxDepth)Traverses up the view hierarchy to find the first Activity context. -
-
Method Detail
-
getMbToBytes
final Long getMbToBytes()
-
getBytesToKbs
final Long getBytesToKbs()
-
getBytesToMbs
final Long getBytesToMbs()
-
getBytesToMbs
final Float getBytesToMbs()
-
isNotNullNotEmpty
final static Boolean isNotNullNotEmpty(String $self)
-
isNotNullNotEmpty
final static Boolean isNotNullNotEmpty(Array<?> $self)
-
isNotNullNotEmpty
final static Boolean isNotNullNotEmpty(JSONObject $self)
-
isNullOrEmpty
final static Boolean isNullOrEmpty(JSONArray $self)
-
toStringMap
final static Map<String, String> toStringMap(JSONObject $self)
-
gzipSink
final static GzipSink gzipSink(OutputStream $self)
-
gzipSource
final static BufferedSource gzipSource(BufferedSource $self)
-
toWebResourceResponse
final static WebResourceResponse toWebResourceResponse(InputStream $self, String mimeType)
-
isGetRequest
@RequiresApi(value = 21) final static Boolean isGetRequest(WebResourceRequest $self)
-
toDp
final static Integer toDp(Float $self)
Catching the Exception in case of any faulty values in Floating point numbers
-
convertToDp
final static Integer convertToDp(Integer $self)
convert this pixels value to dp
-
convertToPixels
final static Integer convertToPixels(Integer $self)
convert this dp value to pixels
-
roundToIntSafe
final static Integer roundToIntSafe(Float $self)
convert this pixels value to dp
-
roundTo1Precision
final static Float roundTo1Precision(Float $self)
-
getScreenWidthAndHeight
final static Pair<Integer, Integer> getScreenWidthAndHeight(Context $self)
-
toBitSet
final static BitSet toBitSet(ByteArray $self)
Convert a ByteArray to a BitSet by iterating through each byte and extracting each bit and setting it in the BitSet
-
getMainStackTrace
final static String getMainStackTrace(BufferedSource $self, Integer maxNumberOfLines, String startMarker, String endMarker)
This function extracts the main stack trace from an input stream.
- Parameters:
maxNumberOfLines- The maximum number of lines to read from the input stream.startMarker- The string that marks the start of the main stack trace.endMarker- The string that marks the end of the main stack trace.- Returns:
The main stack trace as a string. If the main stack trace is empty, it returns the stack trace.
-
isEdgeToEdgeEnabled
@ChecksSdkIntAtLeast(api = 35) final static Boolean isEdgeToEdgeEnabled(Context $self)
-
handleInsetsForEmbeddedBrowser
final static Unit handleInsetsForEmbeddedBrowser(WindowInsetsHandler.FinalInsets $self, RelativeLayout.LayoutParams layoutParams, Orientation orientation)
-
getOrientationAppendedSafeArea
final static JSONObject getOrientationAppendedSafeArea(WindowInsetsHandler.FinalInsets $self, Orientation orientation)
-
convertToUrlEncodedForm
final static String convertToUrlEncodedForm(Map<String, ?> $self)
-
onCompleted
final static <T extends Any> Unit onCompleted(Deferred<T> $self, Function1<T, Unit> onCompleted)
-
getBase64EncodedString
final static String getBase64EncodedString(BufferedSource $self)
-
safeCancel
final static Unit safeCancel(CoroutineScope $self)
-
scheduleAtFixedRate
final static Job scheduleAtFixedRate(CoroutineScope $self, Long initialDelay, Long period, SuspendFunction0<Unit> action)
-
scheduleAtFixedRateInMain
final static Job scheduleAtFixedRateInMain(CoroutineScope $self, Long initialDelay, Long period, SuspendFunction0<Unit> action)
-
withLockSafe
final static Unit withLockSafe(ReentrantMutex $self, SuspendFunction0<Unit> action)
-
registerReceiverCompat
final static Intent registerReceiverCompat(Context $self, BroadcastReceiver receiver, IntentFilter filter)
-
getCatching
final static <T extends Any> T getCatching(T default, Function0<T> block)
-
getBitmapFromDrawable
final static Bitmap getBitmapFromDrawable(Context $self, Integer drawableId)
Method to convert a drawable to a bitmap
-
isValidUrl
final static Boolean isValidUrl(String $self)
-
isWithinThreshold
final static Boolean isWithinThreshold(Long $self, Long other, Long threshold)
Compares two Long values and checks if their absolute difference is within a specified threshold.
- Parameters:
other- The other Long value to compare with.threshold- The maximum allowable difference between the two values for them to be considered "close- Returns:
True if the absolute difference between the two values is less than or equal to the threshold, false otherwise.
-
findActivityContext
final static Activity findActivityContext(View $self, Integer maxDepth)
Traverses up the view hierarchy to find the first Activity context.
- Returns:
WeakReference<Activity> if found, or null if not.
-
-
-
-