-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate Internal OS Helper class to kotlin (#515)
- Loading branch information
1 parent
e5c30d2
commit efad64c
Showing
2 changed files
with
18 additions
and
17 deletions.
There are no files selected for viewing
19 changes: 10 additions & 9 deletions
19
...m/mparticle/internal/JellybeanHelper.java → ...com/mparticle/internal/JellybeanHelper.kt
This file contains 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
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 | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
.../com/mparticle/internal/KitKatHelper.java → ...in/com/mparticle/internal/KitKatHelper.kt
This file contains 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
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) | ||
} | ||
} | ||
} |