Fix crashing on About on release build
This commit is contained in:
parent
40da78af8b
commit
46dc5eb58e
9 changed files with 66 additions and 43 deletions
|
@ -25,7 +25,7 @@ android {
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
Properties properties = getProperties('/Users/apple/Documents/Github/retro.properties ')
|
Properties properties = getProperties('C:/Users/h4h13/Documents/GitHub/retro.properties ')
|
||||||
storeFile file(getProperty(properties, 'storeFile'))
|
storeFile file(getProperty(properties, 'storeFile'))
|
||||||
keyAlias getProperty(properties, 'keyAlias')
|
keyAlias getProperty(properties, 'keyAlias')
|
||||||
storePassword getProperty(properties, 'storePassword')
|
storePassword getProperty(properties, 'storePassword')
|
||||||
|
|
|
@ -3,24 +3,24 @@
|
||||||
"name": "Hemanth Savarala",
|
"name": "Hemanth Savarala",
|
||||||
"summary": "Lead Developer & Designer",
|
"summary": "Lead Developer & Designer",
|
||||||
"link": "https://github.com/h4h13",
|
"link": "https://github.com/h4h13",
|
||||||
"profile_image": "https://i.imgur.com/AoVs9oj.jpg"
|
"image": "https://i.imgur.com/AoVs9oj.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Lennart Glamann",
|
"name": "Lennart Glamann",
|
||||||
"summary": "Play Store banner and Images",
|
"summary": "Play Store banner and Images",
|
||||||
"link": "https://t.me/FlixbusLennart",
|
"link": "https://t.me/FlixbusLennart",
|
||||||
"profile_image": "https://i.imgur.com/Q5Nsx1R.jpg"
|
"image": "https://i.imgur.com/Q5Nsx1R.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Daksh P. Jain",
|
"name": "Daksh P. Jain",
|
||||||
"summary": "Support Representative & Moderator",
|
"summary": "Support Representative & Moderator",
|
||||||
"link": "https://daksh.eu.org",
|
"link": "https://daksh.eu.org",
|
||||||
"profile_image": "https://i.imgur.com/fnYpg65.jpg"
|
"image": "https://i.imgur.com/fnYpg65.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Milind Goel",
|
"name": "Milind Goel",
|
||||||
"summary": "Support Representative & Moderator",
|
"summary": "Support Representative & Moderator",
|
||||||
"link": "https://t.me/MilindGoel15",
|
"link": "https://t.me/MilindGoel15",
|
||||||
"profile_image": "https://i.imgur.com/Bz4De21_d.jpg"
|
"image": "https://i.imgur.com/Bz4De21_d.jpg"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -108,6 +108,7 @@ private val dataModule = module {
|
||||||
get(),
|
get(),
|
||||||
get(),
|
get(),
|
||||||
get(),
|
get(),
|
||||||
|
get(),
|
||||||
get()
|
get()
|
||||||
)
|
)
|
||||||
} bind Repository::class
|
} bind Repository::class
|
||||||
|
@ -153,6 +154,9 @@ private val dataModule = module {
|
||||||
get()
|
get()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
single {
|
||||||
|
RealLocalDataRepository(get())
|
||||||
|
} bind LocalDataRepository::class
|
||||||
}
|
}
|
||||||
|
|
||||||
private val viewModules = module {
|
private val viewModules = module {
|
||||||
|
|
|
@ -59,6 +59,11 @@ class ContributorAdapter(
|
||||||
return contributors.size
|
return contributors.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun swapData(it: List<Contributor>) {
|
||||||
|
contributors = it
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
val title: TextView = itemView.findViewById(R.id.title)
|
val title: TextView = itemView.findViewById(R.id.title)
|
||||||
val text: TextView = itemView.findViewById(R.id.text)
|
val text: TextView = itemView.findViewById(R.id.text)
|
||||||
|
@ -68,7 +73,7 @@ class ContributorAdapter(
|
||||||
title.text = contributor.name
|
title.text = contributor.name
|
||||||
text.text = contributor.summary
|
text.text = contributor.summary
|
||||||
Glide.with(image.context)
|
Glide.with(image.context)
|
||||||
.load(contributor.profileImage)
|
.load(contributor.image)
|
||||||
.error(R.drawable.ic_account)
|
.error(R.drawable.ic_account)
|
||||||
.placeholder(R.drawable.ic_account)
|
.placeholder(R.drawable.ic_account)
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
|
|
|
@ -32,7 +32,6 @@ class LibraryViewModel(
|
||||||
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
||||||
private val genres = MutableLiveData<List<Genre>>()
|
private val genres = MutableLiveData<List<Genre>>()
|
||||||
private val searchResults = MutableLiveData<List<Any>>()
|
private val searchResults = MutableLiveData<List<Any>>()
|
||||||
|
|
||||||
val paletteColor: LiveData<Int> = _paletteColor
|
val paletteColor: LiveData<Int> = _paletteColor
|
||||||
val panelState: MutableLiveData<NowPlayingPanelState> = MutableLiveData<NowPlayingPanelState>()
|
val panelState: MutableLiveData<NowPlayingPanelState> = MutableLiveData<NowPlayingPanelState>()
|
||||||
|
|
||||||
|
@ -293,6 +292,10 @@ class LibraryViewModel(
|
||||||
fun artist(artistId: Long): LiveData<Artist> = liveData {
|
fun artist(artistId: Long): LiveData<Artist> = liveData {
|
||||||
emit(repository.artistById(artistId))
|
emit(repository.artistById(artistId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fetchContributors(): LiveData<List<Contributor>> = liveData {
|
||||||
|
emit(repository.contributor())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ReloadType {
|
enum class ReloadType {
|
||||||
|
|
|
@ -13,18 +13,17 @@ import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.Constants
|
import code.name.monkey.retromusic.Constants
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
||||||
import code.name.monkey.retromusic.model.Contributor
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import kotlinx.android.synthetic.main.card_credit.*
|
import kotlinx.android.synthetic.main.card_credit.*
|
||||||
import kotlinx.android.synthetic.main.card_other.*
|
import kotlinx.android.synthetic.main.card_other.*
|
||||||
import kotlinx.android.synthetic.main.card_retro_info.*
|
import kotlinx.android.synthetic.main.card_retro_info.*
|
||||||
import kotlinx.android.synthetic.main.card_social.*
|
import kotlinx.android.synthetic.main.card_social.*
|
||||||
import java.io.IOException
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
|
|
||||||
class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
||||||
|
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
version.setSummary(getAppVersion())
|
version.setSummary(getAppVersion())
|
||||||
|
@ -32,23 +31,6 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
||||||
loadContributors()
|
loadContributors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val contributorsJson: String?
|
|
||||||
get() {
|
|
||||||
val json: String
|
|
||||||
try {
|
|
||||||
val inputStream = requireActivity().assets.open("contributors.json")
|
|
||||||
val size = inputStream.available()
|
|
||||||
val buffer = ByteArray(size)
|
|
||||||
inputStream.read(buffer)
|
|
||||||
inputStream.close()
|
|
||||||
json = String(buffer, StandardCharsets.UTF_8)
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
ex.printStackTrace()
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return json
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun openUrl(url: String) {
|
private fun openUrl(url: String) {
|
||||||
val i = Intent(Intent.ACTION_VIEW)
|
val i = Intent(Intent.ACTION_VIEW)
|
||||||
|
@ -111,16 +93,14 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadContributors() {
|
private fun loadContributors() {
|
||||||
val type = object : TypeToken<List<Contributor>>() {
|
val contributorAdapter = ContributorAdapter(emptyList())
|
||||||
|
|
||||||
}.type
|
|
||||||
val contributors = Gson().fromJson<List<Contributor>>(contributorsJson, type)
|
|
||||||
|
|
||||||
val contributorAdapter = ContributorAdapter(contributors)
|
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
layoutManager = LinearLayoutManager(requireContext())
|
layoutManager = LinearLayoutManager(requireContext())
|
||||||
itemAnimator = DefaultItemAnimator()
|
itemAnimator = DefaultItemAnimator()
|
||||||
adapter = contributorAdapter
|
adapter = contributorAdapter
|
||||||
}
|
}
|
||||||
|
libraryViewModel.fetchContributors().observe(viewLifecycleOwner, { contributors ->
|
||||||
|
contributorAdapter.swapData(contributors)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,14 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.model
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
data class Contributor(
|
@Parcelize
|
||||||
val name: String,
|
class Contributor(
|
||||||
val summary: String,
|
@SerializedName("name") val name: String = "",
|
||||||
val link: String,
|
@SerializedName("summary") val summary: String = "",
|
||||||
@SerializedName("profile_image")
|
@SerializedName("link") val link: String = "",
|
||||||
val profileImage: String
|
@SerializedName("image") val image: String = ""
|
||||||
)
|
) : Parcelable
|
|
@ -0,0 +1,25 @@
|
||||||
|
package code.name.monkey.retromusic.repository
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import code.name.monkey.retromusic.model.Contributor
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
|
||||||
|
interface LocalDataRepository {
|
||||||
|
fun contributors(): List<Contributor>
|
||||||
|
}
|
||||||
|
|
||||||
|
class RealLocalDataRepository(
|
||||||
|
private val context: Context
|
||||||
|
) : LocalDataRepository {
|
||||||
|
|
||||||
|
override fun contributors(): List<Contributor> {
|
||||||
|
val jsonString = context.assets.open("contributors.json")
|
||||||
|
.bufferedReader().use { it.readText() }
|
||||||
|
|
||||||
|
val gsonBuilder = GsonBuilder()
|
||||||
|
val gson = gsonBuilder.create()
|
||||||
|
val listContributorType = object : TypeToken<List<Contributor>>() {}.type
|
||||||
|
return gson.fromJson(jsonString, listContributorType)
|
||||||
|
}
|
||||||
|
}
|
|
@ -98,6 +98,7 @@ interface Repository {
|
||||||
suspend fun blackListPaths(): List<BlackListStoreEntity>
|
suspend fun blackListPaths(): List<BlackListStoreEntity>
|
||||||
suspend fun lyrics(artist: String, title: String): Result<String>
|
suspend fun lyrics(artist: String, title: String): Result<String>
|
||||||
suspend fun deleteSongs(songs: List<Song>)
|
suspend fun deleteSongs(songs: List<Song>)
|
||||||
|
suspend fun contributor(): List<Contributor>
|
||||||
}
|
}
|
||||||
|
|
||||||
class RealRepository(
|
class RealRepository(
|
||||||
|
@ -112,7 +113,8 @@ class RealRepository(
|
||||||
private val searchRepository: RealSearchRepository,
|
private val searchRepository: RealSearchRepository,
|
||||||
private val topPlayedRepository: TopPlayedRepository,
|
private val topPlayedRepository: TopPlayedRepository,
|
||||||
private val roomRepository: RoomRepository,
|
private val roomRepository: RoomRepository,
|
||||||
private val lyricsRestService: LyricsRestService
|
private val lyricsRestService: LyricsRestService,
|
||||||
|
private val localDataRepository: LocalDataRepository
|
||||||
) : Repository {
|
) : Repository {
|
||||||
|
|
||||||
override suspend fun lyrics(artist: String, title: String): Result<String> = try {
|
override suspend fun lyrics(artist: String, title: String): Result<String> = try {
|
||||||
|
@ -124,6 +126,8 @@ class RealRepository(
|
||||||
|
|
||||||
override suspend fun deleteSongs(songs: List<Song>) = roomRepository.deleteSongs(songs)
|
override suspend fun deleteSongs(songs: List<Song>) = roomRepository.deleteSongs(songs)
|
||||||
|
|
||||||
|
override suspend fun contributor(): List<Contributor> = localDataRepository.contributors()
|
||||||
|
|
||||||
override suspend fun fetchAlbums(): List<Album> = albumRepository.albums()
|
override suspend fun fetchAlbums(): List<Album> = albumRepository.albums()
|
||||||
|
|
||||||
override suspend fun albumByIdAsync(albumId: Long): Album = albumRepository.album(albumId)
|
override suspend fun albumByIdAsync(albumId: Long): Album = albumRepository.album(albumId)
|
||||||
|
|
Loading…
Reference in a new issue