Skip to content

Commit

Permalink
refactor: Migrate Internal OS Helper class to kotlin (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle authored Oct 28, 2024
1 parent e5c30d2 commit efad64c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.mparticle.internal;
package com.mparticle.internal

import android.annotation.TargetApi;
import android.os.Build;
import android.os.StatFs;
import android.annotation.TargetApi
import android.os.Build
import android.os.StatFs

/**
* This is solely used to avoid logcat warnings that Android will generate when loading a class,
* even if you use conditional execution based on VERSION.
*/
@TargetApi(18)
public class JellybeanHelper {
public static long getAvailableMemory(StatFs stat) {
object JellybeanHelper {
@JvmStatic
fun getAvailableMemory(stat: StatFs): Long {
try {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong();
return stat.availableBlocksLong * stat.blockSizeLong
}
} catch (Exception e) {
} catch (e: Exception) {
//For some reason, it appears some devices even in jelly bean don't have this method.
}

return 0;
return 0
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.mparticle.internal;
package com.mparticle.internal

import android.annotation.TargetApi;
import android.os.Build;

import org.json.JSONArray;
import android.annotation.TargetApi
import android.os.Build
import org.json.JSONArray

/**
* This is solely used to avoid logcat warnings that Android will generate when loading a class,
* even if you use conditional execution based on VERSION.
*/
@TargetApi(19)
public class KitKatHelper {
public static void remove(JSONArray array, int index) {
object KitKatHelper {
@JvmStatic
fun remove(array: JSONArray, index: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
array.remove(index);
array.remove(index)
}
}
}

0 comments on commit efad64c

Please sign in to comment.