Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
finishing some feature and fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
spookynova committed Aug 8, 2023
1 parent ad9b302 commit 70d9957
Show file tree
Hide file tree
Showing 24 changed files with 1,063 additions and 322 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies {
implementation 'me.relex:circleindicator:2.1.6'
implementation 'org.imaginativeworld.whynotimagecarousel:whynotimagecarousel:2.1.0'
implementation 'nl.joery.animatedbottombar:library:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.exoplayer:exoplayer:2.14.2'
implementation 'com.google.android.exoplayer:exoplayer-core:2.14.2'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.14.2'
Expand Down
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "id.blossom",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
14 changes: 8 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name="id.blossom.BlossomApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/sakura"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@drawable/sakura"
android:supportsRtl="true"
android:theme="@style/Theme.Blossom"
tools:targetApi="31">
<activity
android:name=".ui.activity.faq.FaqActivity"
android:exported="false" />
<activity
android:name=".ui.activity.about.AboutActivity"
android:exported="false" />
<activity
android:name=".ui.activity.showall.ShowAllAnimeActivity"
android:exported="false" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/id/blossom/data/api/NetworkService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ interface NetworkService {
@GET("luckyanime/properties/genre/{genreId}")
suspend fun getPropertiesGenreAnime(
@Path("genreId") genreId: String,
@Query("page") page: Int,
) : PropertyGenresAnimeResponse

// streaming
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class AnimeRepository @Inject constructor(private val networkService: NetworkSer
}
}

fun getResultGenresAnime(genres: String): Flow<List<PropertyGenresAnimeDataItem>> {
fun getResultGenresAnime(genres: String, page: Int): Flow<List<PropertyGenresAnimeDataItem>> {
return flow {
emit(networkService.getPropertiesGenreAnime(genres))
emit(networkService.getPropertiesGenreAnime(genres, page))
}.map {
it.data!!
}
Expand Down
70 changes: 70 additions & 0 deletions app/src/main/java/id/blossom/ui/activity/about/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package id.blossom.ui.activity.about

import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.browser.customtabs.CustomTabsIntent
import id.blossom.BuildConfig
import id.blossom.databinding.ActivityAboutBinding
import id.blossom.utils.Utils

class AboutActivity : AppCompatActivity() {

lateinit var binding: ActivityAboutBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(binding.root)
Utils().setFullScreenFlag(window)
val customBrowser = CustomTabsIntent.Builder().build()

binding.tvVersion.text = "Version ${BuildConfig.VERSION_NAME}"
binding.llGithub.setOnClickListener {
customBrowser.launchUrl(this, Uri.parse("https://github.com/evnx32"))
}

binding.llApi.setOnClickListener {
customBrowser.launchUrl(
this,
Uri.parse("https://github.com/LuckyIndraEfendi/AnimeIndo-Rest-API")
)
}

binding.llLicense.setOnClickListener {
customBrowser.launchUrl(
this,
Uri.parse("https://www.apache.org/licenses/LICENSE-2.0"))
}

binding.llInstagram.setOnClickListener {
customBrowser.launchUrl(
this,
Uri.parse("https://www.instagram.com/dword_ptr/")
)
}

binding.llFacebook.setOnClickListener {
customBrowser.launchUrl(
this,
Uri.parse("https://www.facebook.com/KanMaruKun")
)
}

binding.llEmail.setOnClickListener {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:evnx32@gmail.com")
startActivity(intent)
}

}

companion object {
fun start(context: Context) {
val intent = Intent(context, AboutActivity::class.java)
context.startActivity(intent)
}
}
}
29 changes: 29 additions & 0 deletions app/src/main/java/id/blossom/ui/activity/faq/FaqActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package id.blossom.ui.activity.faq

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import id.blossom.databinding.ActivityFaqBinding
import id.blossom.utils.Utils

class FaqActivity : AppCompatActivity() {

lateinit var binding: ActivityFaqBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityFaqBinding.inflate(layoutInflater)
setContentView(binding.root)
Utils().setFullScreenFlag(window)

}


companion object {
fun start(context: Context) {
val intent = Intent(context, FaqActivity::class.java)
context.startActivity(intent)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GenresResultActivity : AppCompatActivity() {

binding.tvSelectedGenre.text = "Hasil Pencarian Genre $genreName"
if (genreId != null) {
genresResultViewModel.fetchGenresResultAnime(genreId)
genresResultViewModel.fetchGenresResultAnime(genreId, page)
} else {
Toast.makeText(this, "Genre Id is null", Toast.LENGTH_LONG).show()
}
Expand All @@ -65,42 +65,38 @@ class GenresResultActivity : AppCompatActivity() {
binding.animeResultGenreRv.setLoadingListener(object : XRecyclerView.LoadingListener {
override fun onRefresh() {
page = 1
//genresResultViewModel.fetchGenresResultAnime(genreId.toString())
genresResultViewModel.fetchGenresResultAnime(genreId.toString(), page)
}

override fun onLoadMore() {
page++
//scheduleViewModel.fetchScheduleAnime(page, queryDays.toString())
genresResultViewModel.fetchGenresResultAnime(genreId.toString(), page)
}

})
}

private fun setupObserver() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
genresResultViewModel.uiStateGenresResultAnime.collect {
when (it) {
is UiState.Success -> {
binding.progressPropertiesGenre.visibility = View.GONE
renderPropertiesGenre(it.data)
}
is UiState.Loading -> {
binding.progressPropertiesGenre.visibility = View.VISIBLE
}
is UiState.Error -> {
//Handle Error
Toast.makeText(this@GenresResultActivity, it.message, Toast.LENGTH_LONG)
.show()
}
}

genresResultViewModel.uiStateGenresResultAnime.observe(this) {
when (it) {
is UiState.Success -> {
binding.progressPropertiesGenre.visibility = View.GONE
renderPropertiesGenre(it.data)
}
is UiState.Loading -> {
binding.progressPropertiesGenre.visibility = View.VISIBLE
}
is UiState.Error -> {
//Handle Error
Toast.makeText(this@GenresResultActivity, it.message, Toast.LENGTH_LONG)
.show()
}
}
}
}

private fun renderPropertiesGenre(data: List<PropertyGenresAnimeDataItem>) {
genresResultAdapter.clearData()
genresResultAdapter.addData(data)
genresResultAdapter.notifyDataSetChanged()
}
Expand All @@ -116,7 +112,7 @@ class GenresResultActivity : AppCompatActivity() {


companion object {
fun start(context : Context, genreId : String, genreName : String ){
fun start(context: Context, genreId: String, genreName: String) {
val intent = Intent(context, GenresResultActivity::class.java)
intent.putExtra("genreId", genreId)
intent.putExtra("genreName", genreName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package id.blossom.ui.activity.genres

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import id.blossom.data.model.anime.genres.result.PropertyGenresAnimeDataItem
Expand All @@ -13,17 +15,17 @@ import kotlinx.coroutines.launch

class GenresResultViewModel (private val animeRepository: AnimeRepository) : ViewModel() {
private val _uiStateGenresResultAnime =
MutableStateFlow<UiState<List<PropertyGenresAnimeDataItem>>>(UiState.Loading)
val uiStateGenresResultAnime: StateFlow<UiState<List<PropertyGenresAnimeDataItem>>> = _uiStateGenresResultAnime
MutableLiveData<UiState<List<PropertyGenresAnimeDataItem>>>(UiState.Loading)
val uiStateGenresResultAnime: LiveData<UiState<List<PropertyGenresAnimeDataItem>>> = _uiStateGenresResultAnime


init {

}

fun fetchGenresResultAnime(genres : String) {
fun fetchGenresResultAnime(genres : String, page : Int) {
viewModelScope.launch {
animeRepository.getResultGenresAnime(genres)
animeRepository.getResultGenresAnime(genres,page)
.catch { e ->
_uiStateGenresResultAnime.value = UiState.Error(e.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ShowAllOngoingAnimeAdapter (
RecyclerView.ViewHolder(binding.root) {
fun bind(value: OngoingAnimeDataItem) {
binding.animeTitle.text = value.title.toString()
binding.llAnimeRate.visibility = View.GONE
binding.animeRateDetail.text = value.episode.toString()
binding.animeRateIcon.visibility = View.GONE
Glide.with(binding.animeImageView.context).load(value.image)
.diskCacheStrategy(DiskCacheStrategy.ALL).into(binding.animeImageView)
itemView.setOnClickListener {
Expand Down
Loading

0 comments on commit 70d9957

Please # to comment.