Commit 3c301df8 authored by Dayona Joseph's avatar Dayona Joseph
Browse files

Call unregister Language receiver

Fix home pwa parsing error
parent 25c10350
Pipeline #68642 passed with stage
in 3 minutes and 10 seconds
......@@ -28,7 +28,6 @@ import android.preference.PreferenceManager
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
......@@ -60,6 +59,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
ApplicationManagerServiceConnection(this)
private val codeRequestPermissions = 9527
var doubleBackToExitPressedOnce = false;
private var isReceiverRegistered = false
......@@ -75,7 +75,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
mActivity = this
disableCategoryIfOpenSource()
bottom_navigation_view.setOnNavigationItemSelectedListener{
if (selectFragment(it.itemId,it)) {
disableCategoryIfOpenSource()
......@@ -181,11 +180,11 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
mLangReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
finish()
// selectFragment(currentFragmentId,null)
}
}
val filter = IntentFilter(Intent.ACTION_LOCALE_CHANGED)
registerReceiver(mLangReceiver, filter)
isReceiverRegistered = true;
}
return mLangReceiver
}
......@@ -240,6 +239,10 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
override fun onDestroy() {
super.onDestroy()
if (isReceiverRegistered) {
unregisterReceiver(mLangReceiver)
isReceiverRegistered = false // set it back to false.
}
homeFragment.decrementApplicationUses()
searchFragment.decrementApplicationUses()
updatesFragment.decrementApplicationUses()
......
......@@ -31,6 +31,7 @@ class HomePwaRequest {
urlConnection.disconnect()
callback.invoke(null, result)
} catch (e: Exception) {
e.printStackTrace()
callback.invoke(Error.findError(e), null)
}
}
......@@ -42,13 +43,13 @@ class HomePwaRequest {
@JsonProperty("headings")
val headings: Map<String, String>?,
@JsonProperty(BANNER_APPS_KEY)
val bannerApps: List<BasicData>,
val bannerApps: List<PwasBasicData>,
@JsonProperty(POPULAR_APPS_KEY)
val topUpdatedApps: List<BasicData>,
val topUpdatedApps: List<PwasBasicData>,
@JsonProperty(POPULAR_GAMES_KEY)
val topUpdatedGames: List<BasicData>,
val topUpdatedGames: List<PwasBasicData>,
@JsonProperty(DISCOVER_KEY)
val discover: List<BasicData>
val discover: List<PwasBasicData>
) {
companion object {
......@@ -61,7 +62,7 @@ class HomePwaRequest {
}
fun getBannerApps(applicationManager: ApplicationManager, context: Context): ArrayList<Application> {
return ApplicationParser.parseToApps(applicationManager, context, bannerApps.toTypedArray())
return ApplicationParser.PwaParseToApps(applicationManager, context, bannerApps.toTypedArray())
}
fun getApps(applicationManager: ApplicationManager, context: Context): LinkedHashMap<Category, ArrayList<Application>> {
......@@ -71,9 +72,9 @@ class HomePwaRequest {
heading = heading
?: "" // Use default heading as empty to let it generate from the key itself.
val parsedApps = when (it) {
POPULAR_APPS_KEY -> ApplicationParser.parseToApps(applicationManager, context, topUpdatedApps.toTypedArray())
POPULAR_GAMES_KEY -> ApplicationParser.parseToApps(applicationManager, context, topUpdatedGames.toTypedArray())
DISCOVER_KEY -> ApplicationParser.parseToApps(applicationManager, context, discover.toTypedArray())
POPULAR_APPS_KEY -> ApplicationParser.PwaParseToApps(applicationManager, context, topUpdatedApps.toTypedArray())
POPULAR_GAMES_KEY -> ApplicationParser.PwaParseToApps(applicationManager, context, topUpdatedGames.toTypedArray())
DISCOVER_KEY -> ApplicationParser.PwaParseToApps(applicationManager, context, discover.toTypedArray())
else -> throw IllegalArgumentException("Unrecognised key $it encountered")
}
apps[Category(it, heading)] = parsedApps
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment