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
| class ResponseMapper<T> : RMapper<T> { | |
| private var errorString: String = "{}" | |
| override fun getErrorString() = errorString | |
| override fun apply(it: Response<T>): Single<T> { | |
| return when { | |
| it.isSuccessful -> Single.just(it.body()!!) | |
| it.errorBody() == null -> Single.error<T>(UnrecoverableException("Unknown exception")) | |
| else -> { |
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 str = if (json.has("errors") && json.getJSONArray("errors").length() > 0 && | |
| (json.getJSONArray("errors").get(0) as JSONObject).length() > 0 && | |
| (json.getJSONArray("errors").get(0) as JSONObject).keys().hasNext()) { | |
| val errorsObj = json.getJSONArray("errors").get(0) as JSONObject | |
| errorsObj.keys() | |
| .asSequence() | |
| .map { errorsObj.getString(it) } | |
| .joinToString("\n") | |
| } else if (json.has("error_description")) { | |
| json.getString("error_description") |
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
| class ResponseMapper<T> : RMapper<T> { | |
| private var errorString: String = "{}" | |
| override fun getErrorString() = errorString | |
| override fun apply(it: Response<T>): Single<T> { | |
| return when { | |
| it.isSuccessful -> Single.just(it.body()!!) | |
| it.errorBody() == null -> Single.error<T>(UnrecoverableException("Unknown exception")) | |
| else -> { |
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 getStripeIdToServer(hm: Map<String, String>) = | |
| freebirdApi.authStripe(hm) | |
| .doOnSubscribe { view?.showProgress() } | |
| .doAfterTerminate { view?.hideProgress() } | |
| .flatMap { json -> | |
| view?.onJsonObjectCallback(json) | |
| return@flatMap freebirdApi.addExternalAccount(mapOf(Pair("token", json.getString("access_token")))) | |
| } | |
| .subscribe({ | |
| preferences.setUserInfo(it.user) |
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
| private static boolean isRooted() { | |
| return findBinary("su"); | |
| } | |
| public static boolean findBinary(String binaryName) { | |
| boolean found = false; | |
| if (!found) { | |
| String[] places = {"/sbin/", "/system/bin/", | |
| "/system/xbin/", "/data/local/xbin/", | |
| "/data/local/bin/", "/system/sd/xbin/", |
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
| private static byte[] encrypt(byte[] key, byte[] input) throws Exception { | |
| SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); | |
| Cipher cipher = Cipher.getInstance("AES"); | |
| cipher.init(Cipher.ENCRYPT_MODE, skeySpec); | |
| byte[] encrypted = cipher.doFinal(input); | |
| return encrypted; | |
| } | |
| private static byte[] decrypt(byte[] key, byte[] encrypted) throws Exception { | |
| SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); |