Skip to content

Commit

Permalink
update: Enhance Performance
Browse files Browse the repository at this point in the history
  • Loading branch information
amirisback committed Apr 26, 2024
1 parent 653b414 commit 05b0b77
Show file tree
Hide file tree
Showing 45 changed files with 347 additions and 841 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<application
android:name=".FrogoApp"
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/frogobox/appsdk/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.frogobox.sdk.ui.FrogoWebViewActivity
class MainActivity : CoreMainActivity<ActivityMainBinding>() {

private val tes: String by lazy {
singlePref.loadPrefString("test")
singlePref.getPrefString("test")
}

override fun setupViewBinding(): ActivityMainBinding {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import com.frogobox.appsdk.R
import com.frogobox.appsdk.core.BaseActivity
import com.frogobox.appsdk.databinding.ActivityNewsDetailBinding
import com.frogobox.appsdk.model.Article
import com.frogobox.sdk.ext.getExtraDataExt
import com.frogobox.sdk.ext.getExtraExt
import com.frogobox.sdk.ext.setImageExt

class NewsDetailActivity : BaseActivity<ActivityNewsDetailBinding>() {

private val extraData: Article by lazy {
getExtraDataExt("EXTRA_NEWS_DETAIL")
getExtraExt("EXTRA_NEWS_DETAIL")
}

override fun setupViewBinding(): ActivityNewsDetailBinding {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/frogobox/appsdk/news/NewsViewHolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.frogobox.appsdk.databinding.ItemNewsBinding
import com.frogobox.appsdk.model.Article
import com.frogobox.sdk.ext.setImageExt
import com.frogobox.sdk.ext.startActivityExt
import com.frogobox.sdk.ext.toJson


/*
Expand All @@ -28,10 +29,9 @@ class NewsViewHolder(private val binding: ItemNewsBinding) : RecyclerView.ViewHo
tvNewsTitle.text = data.title
tvNewsDescription.text = data.description
root.setOnClickListener {
it.context.startActivityExt<NewsDetailActivity, Article>(
"EXTRA_NEWS_DETAIL",
data
)
it.context.startActivityExt<NewsDetailActivity> { intent ->
intent.putExtra("EXTRA_NEWS_DETAIL", data.toJson())
}
}
}
}
Expand Down
34 changes: 26 additions & 8 deletions app/src/main/java/com/frogobox/appsdk/news/NewsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.frogobox.sdk.ext.showLogError
import com.frogobox.sdk.view.FrogoViewModel2


/*
/**
* Created by faisalamir on 08/04/22
* FrogoSDK
* -----------------------------------------
Expand All @@ -28,6 +28,30 @@ class NewsViewModel(
private val repository: AppRepository,
) : FrogoViewModel2() {

protected var _eventFailed = MutableLiveData<String>()
var eventFailed: LiveData<String> = _eventFailed

protected var _eventSuccess = MutableLiveData<String>()
var eventSuccess: LiveData<String> = _eventSuccess

protected var _eventEmptyState = MutableLiveData<Boolean>()
var eventEmptyState: LiveData<Boolean> = _eventEmptyState

protected var _eventFailedState = MutableLiveData<Boolean>()
var eventFailedState: LiveData<Boolean> = _eventFailedState

protected var _eventFinishState = MutableLiveData<Boolean>()
var eventFinishState: LiveData<Boolean> = _eventFinishState

protected var _eventSuccessState = MutableLiveData<Boolean>()
var eventSuccessState: LiveData<Boolean> = _eventSuccessState

protected var _eventNoInternetState = MutableLiveData<Boolean>()
var eventNoInternetState: LiveData<Boolean> = _eventNoInternetState

protected var _eventShowProgressState = MutableLiveData<Boolean>()
var eventShowProgressState: LiveData<Boolean> = _eventShowProgressState

private var _articles = MutableLiveData<List<Article>>()
var articles: LiveData<List<Article>> = _articles

Expand Down Expand Up @@ -66,13 +90,7 @@ class NewsViewModel(
}

private fun getPref() {
repository.getPrefString("KEY_PREF", object : FrogoDataResponse<String> {
override fun onFailed(statusCode: Int, errorMessage: String) {}
override fun onFinish() {}
override fun onHideProgress() {}
override fun onShowProgress() {}
override fun onSuccess(data: String) {}
})
repository.getPrefString("KEY_PREF")
}

override fun onStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.frogobox.coresdk.source.FrogoResult
import com.frogobox.sdk.view.FrogoViewModel2


/*
/**
* Created by faisalamir on 08/04/22
* FrogoSDK
* -----------------------------------------
Expand Down Expand Up @@ -43,13 +43,7 @@ class NewsResultViewModel(
}

private fun getPref() {
repository.getPrefString("KEY_PREF", object : FrogoDataResponse<String> {
override fun onFailed(statusCode: Int, errorMessage: String) {}
override fun onFinish() {}
override fun onHideProgress() {}
override fun onShowProgress() {}
override fun onSuccess(data: String) {}
})
repository.getPrefString("KEY_PREF")
}

override fun onStart() {
Expand Down
27 changes: 2 additions & 25 deletions app/src/main/java/com/frogobox/appsdk/source/AppRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.frogobox.coresdk.response.FrogoDataResponse
import com.frogobox.coresdk.response.FrogoStateResponse
import com.frogobox.coresdk.source.FrogoResult
import com.frogobox.sdk.ext.showLogDebug
import com.frogobox.sdk.ext.toJson
import com.frogobox.sdk.source.FrogoRepository
import com.frogobox.sdk.util.FrogoFunc
import com.google.gson.Gson
Expand Down Expand Up @@ -107,31 +108,7 @@ class AppRepository(
callback.onShowProgress()
}
})

savePrefString(
"KEY_PREF",
Gson().toJson(data[0]),
object : FrogoStateResponse {
override fun onSuccess() {
showLogDebug("PREFERENCE >>>>>> SUCCESS CREATED")
}

override fun onFailed(
statusCode: Int,
errorMessage: String
) {
}

override fun onFinish() {}
override fun onHideProgress() {
callback.onHideProgress()
}

override fun onShowProgress() {
callback.onShowProgress()
}
})

savePrefString("KEY_PREF", data[0].toJson())
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ repositories {

dependencies {
// library frogo-build-src
implementation("com.github.frogobox:open-build-src:3.0.3")
implementation("com.github.frogobox:open-build-src:3.0.4")
}
4 changes: 0 additions & 4 deletions core-sdk-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ dependencies {
ksp(Androidx.Lifecycle.compiler)
ksp(Androidx.Room.compiler)
ksp(GitHub.glideCompiler)
api(Util.Acra.mail)

ksp(Google.autoService)
compileOnly(Google.autoServiceAnnotation)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import android.app.Activity
import android.app.Application
import cat.ereza.customactivityoncrash.config.CaocConfig
import com.frogobox.sdk.ui.FrogoCustomCrashActivity
import org.acra.config.mailSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra


/**
Expand Down Expand Up @@ -46,29 +43,11 @@ abstract class FrogoApplication : Application() {
return FrogoCustomCrashActivity::class.java
}

open fun setupACRA() {
initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON
alsoReportToAndroidFramework = true
mailSender {
//required
mailTo = "[email protected]"
//defaults to true
reportAsFile = true
//defaults to ACRA-report.stacktrace
reportFileName = "Crash.txt"
}
}
}

override fun onCreate() {
super.onCreate()
onCreateExt()
if (isDebugMode()) {
setupCAOC()
} else {
setupACRA()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.frogobox.sdk.delegate.piracy.util.PiracyMessage
import com.frogobox.sdk.ext.getInstallerId
import com.frogobox.sdk.ext.showLogD
import com.frogobox.sdk.util.FrogoFunc
import com.frogobox.sdk.util.SimpleDialogUtil
import com.frogobox.sdkutil.piracychecker.callback
import com.frogobox.sdkutil.piracychecker.doNotAllow
import com.frogobox.sdkutil.piracychecker.enums.Display
Expand Down Expand Up @@ -102,14 +103,21 @@ class PiracyDelegatesImpl : PiracyDelegates {
}

override fun showPiracedDialog(message: PiracyMessage, callback: FrogoPiracyDialogCallback?) {
FrogoFunc.createDialogDefault(
SimpleDialogUtil.create(
piracyDelegateContext,
message.title,
message.description,
) {
callback?.doOnPirated(message)
piracyDelegateActivity.finishAffinity()
}
object : SimpleDialogUtil.OnDialogClickListener {
override fun positiveButton() {
callback?.doOnPirated(message)
piracyDelegateActivity.finishAffinity()
}

override fun negativeButton() {
// TODO
}
}
)
}

override fun checkRootMethod1(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.frogobox.sdk.delegate.preference

import com.frogobox.coresdk.response.FrogoDataResponse
import com.frogobox.coresdk.response.FrogoStateResponse


/**
* Created by faisalamir on 01/07/22
Expand All @@ -29,48 +26,28 @@ interface PreferenceDelegates {

fun savePrefLong(key: String, value: Long)

fun savePrefString(key: String, value: String, callback: FrogoStateResponse)

fun savePrefLong(key: String, value: Long, callback: FrogoStateResponse)

fun savePrefFloat(key: String, value: Float, callback: FrogoStateResponse)

fun savePrefInt(key: String, value: Int, callback: FrogoStateResponse)

fun savePrefBoolean(key: String, value: Boolean, callback: FrogoStateResponse)

fun deletePref(key: String)

fun nukePref()

fun loadPrefFloat(key: String): Float

fun loadPrefFloat(key: String, defaultValue: Float): Float

fun loadPrefString(key: String): String

fun loadPrefString(key: String, defaultValue: String): String

fun loadPrefInt(key: String): Int

fun loadPrefInt(key: String, defaultValue: Int): Int
fun getPrefFloat(key: String): Float

fun loadPrefLong(key: String): Long
fun getPrefFloat(key: String, defaultValue: Float): Float

fun loadPrefLong(key: String, defaultValue: Long): Long
fun getPrefString(key: String): String

fun loadPrefBoolean(key: String): Boolean
fun getPrefString(key: String, defaultValue: String): String

fun loadPrefBoolean(key: String, defaultValue: Boolean): Boolean
fun getPrefInt(key: String): Int

fun loadPrefString(key: String, callback: FrogoDataResponse<String>)
fun getPrefInt(key: String, defaultValue: Int): Int

fun loadPrefLong(key: String, callback: FrogoDataResponse<Long>)
fun getPrefLong(key: String): Long

fun loadPrefFloat(key: String, callback: FrogoDataResponse<Float>)
fun getPrefLong(key: String, defaultValue: Long): Long

fun loadPrefInt(key: String, callback: FrogoDataResponse<Int>)
fun getPrefBoolean(key: String): Boolean

fun loadPrefBoolean(key: String, callback: FrogoDataResponse<Boolean>)
fun getPrefBoolean(key: String, defaultValue: Boolean): Boolean

}
Loading

0 comments on commit 05b0b77

Please sign in to comment.