Completed implementing AboutActivity.kt

Completed integrating faqs api and FaqActivity.kt
This commit is contained in:
2024-06-04 16:19:09 +05:30
parent 5946bf414f
commit 2bf884ed56
18 changed files with 124 additions and 21 deletions

View File

@@ -16,9 +16,12 @@
android:theme="@style/Theme.Woka"
tools:targetApi="31">
<activity
android:name=".home.sidebar.AboutActivity"
android:screenOrientation="portrait"
android:name=".home.sidebar.FaqActivity"
android:exported="false" />
<activity
android:name=".home.sidebar.AboutActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".home.MoreHomeActivity"
android:exported="false"

View File

@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.bumptech.glide.Glide
import com.woka.R
import com.woka.databinding.BlogViewHolderBinding
import com.woka.modules.blogs.Blog
import com.woka.modules.blogs.models.Blog
import java.util.concurrent.Executors
class BlogsAdapter(config: AsyncDifferConfig<Blog>) :

View File

@@ -149,7 +149,9 @@ class HomeActivity : WokaBaseActivity(),
}
override fun onBackPressed() {
if (binding.bottomNav.getSelectedTab() != HOME){
if (binding.homeDrawer.isDrawerOpen(GravityCompat.END)){
binding.homeDrawer.closeDrawer(GravityCompat.END)
}else if (binding.bottomNav.getSelectedTab() != HOME){
binding.bottomNav.selectTab(HOME)
}else {
super.onBackPressed()

View File

@@ -9,7 +9,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.woka.R
import com.woka.databinding.ActivityMoreHomeBinding
import com.woka.modules.BlogsRepository
import com.woka.modules.blogs.BlogsRepository
import com.woka.networking.ApiResult
import com.woka.utils.WokaBaseActivity
import com.woka.utils.hide

View File

@@ -1,12 +1,9 @@
package com.woka.home.sidebar
import android.graphics.Color
import android.os.Bundle
import android.transition.Fade
import android.transition.Slide
import android.view.Gravity.END
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.woka.R

View File

@@ -0,0 +1,21 @@
package com.woka.home.sidebar
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.woka.R
class FaqActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_faq)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}
}

View File

@@ -1,12 +1,17 @@
package com.woka.modules
import com.woka.modules.blogs.BlogsResponse
import com.woka.modules.blogs.models.BlogsResponse
import com.woka.modules.faqs.models.FaqResponse
import com.woka.networking.ApiResponse
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.POST
interface ModuleApiService {
@GET("blogs")
suspend fun getBlogs(): Response<ApiResponse<BlogsResponse>>
@POST("faq_listing")
suspend fun getFaqs(): Response<ApiResponse<FaqResponse>>
}

View File

@@ -1,9 +1,9 @@
package com.woka.modules
package com.woka.modules.blogs
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.woka.modules.blogs.BlogsResponse
import com.woka.modules.ModuleApiService
import com.woka.modules.blogs.models.BlogsResponse
import com.woka.networking.ApiResult
import com.woka.networking.RetrofitHelper
import com.woka.networking.RetrofitHelper.handleApiCall

View File

@@ -1,4 +1,4 @@
package com.woka.modules.blogs
package com.woka.modules.blogs.models
data class Blog(
val article_url: Any?,

View File

@@ -1,4 +1,4 @@
package com.woka.modules.blogs
package com.woka.modules.blogs.models
data class BlogsResponse(
val blogs: List<Blog?>?,

View File

@@ -1,4 +1,4 @@
package com.woka.modules.blogs
package com.woka.modules.blogs.models
data class ContentMoreDetail(
val article: String?,

View File

@@ -0,0 +1,37 @@
package com.woka.modules.faqs
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.woka.modules.ModuleApiService
import com.woka.modules.faqs.models.FaqResponse
import com.woka.networking.ApiResult
import com.woka.networking.RetrofitHelper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
object FAQsRepository {
private val apiService = RetrofitHelper.getRetrofit().create(ModuleApiService::class.java)
private val _faqLiveData = MutableLiveData<ApiResult<FaqResponse>>()
val faqLiveData: LiveData<ApiResult<FaqResponse>?>
get() = _faqLiveData
init {
loadFaqs()
}
private suspend fun getBlogs(): ApiResult<FaqResponse> {
return RetrofitHelper.handleApiCall {
apiService.getFaqs()
}
}
private fun loadFaqs(){
CoroutineScope(Dispatchers.IO).launch {
_faqLiveData.postValue(ApiResult.Loading())
_faqLiveData.postValue(getBlogs())
}
}
}

View File

@@ -0,0 +1,6 @@
package com.woka.modules.faqs.models
data class FaqResponse(
val result: List<Result?>?,
val total_records: Int?
)

View File

@@ -0,0 +1,10 @@
package com.woka.modules.faqs.models
data class Result(
val category_master_id: Int?,
val english_answer: String?,
val english_question: String?,
val hindi_answer: String?,
val hindi_question: String?,
val id: Int?
)

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#09005D"
android:centerColor="#4B3DD0"
android:endColor="#09005D"
android:angle="270"
/>
</shape>

View File

@@ -70,16 +70,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum"
android:text="@string/about_woka_description"
android:fontFamily="@font/exo_2"
android:textColor="@color/black"
android:textSize="@dimen/_11ssp"
android:textSize="@dimen/_12ssp"
android:textAlignment="center"
app:layout_constraintTop_toBottomOf="@id/g1"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="25dp"
/>
android:layout_marginStart="15dp"
android:layout_marginEnd="10dp"
android:layout_marginVertical="25dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/faq_bg"
tools:context=".home.sidebar.FaqActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -138,4 +138,5 @@
<string name="blogs">Blogs</string>
<string name="masila">MASILA</string>
<string name="play_trailer">PLAY TRAILER</string>
<string name="about_woka_description">WOKA endeavours to make this world a happier and a safe place for Children. A world where families and communities unite joyfully in celebration of their unity and learn from each other\'s diversity.</string>
</resources>