smooth transition between LiveStreamPlayerActivity opening

MoreHomeActivity creation

Blogs api integration
This commit is contained in:
2024-05-31 20:27:01 +05:30
parent 5bc2b44bc1
commit 78f3cd85e6
33 changed files with 483 additions and 13 deletions

View File

@@ -15,6 +15,11 @@
android:supportsRtl="true"
android:theme="@style/Theme.Woka"
tools:targetApi="31">
<activity
android:name=".home.MoreHomeActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/TransparentActivity" />
<activity
android:name=".players.LiveStreamPlayerActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

View File

@@ -0,0 +1,21 @@
package com.woka.home
import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.woka.databinding.BlogViewHolderBinding
import com.woka.modules.blogs.Blog
class BlogsAdapter(config: AsyncDifferConfig<Blog>) :
ListAdapter<Blog, BlogsAdapter.BlogViewHolder>(config) {
inner class BlogViewHolder(binding: BlogViewHolderBinding): ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BlogViewHolder {
}
override fun onBindViewHolder(holder: BlogViewHolder, position: Int) {
}
}

View File

@@ -0,0 +1,45 @@
package com.woka.home
import android.graphics.Color
import android.os.Bundle
import android.view.WindowManager
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.ViewModelProvider
import com.woka.R
import com.woka.modules.BlogsViewModel
import com.woka.utils.WokaBaseActivity
import com.woka.utils.lightStatusBar
class MoreHomeActivity : WokaBaseActivity() {
private lateinit var blogsViewModel: BlogsViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_more_home)
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
}
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = Color.TRANSPARENT
window.navigationBarColor = getColor(R.color.more_bg)
window.lightStatusBar()
blogsViewModel = ViewModelProvider(this)[BlogsViewModel::class.java]
setObservers()
}
private fun setObservers() {
blogsViewModel.blogsLiveData.observe(this){
}
}
}

View File

@@ -22,6 +22,7 @@ import com.woka.R
import com.woka.WokaApp.Companion.userPrefs
import com.woka.databinding.FragmentHome1Binding
import com.woka.home.HomeViewModel
import com.woka.home.MoreHomeActivity
import com.woka.home.TimePeriod
import com.woka.mvvm.userDataModels.UserDataResponse
import com.woka.networking.ApiResult
@@ -58,22 +59,14 @@ class Home1Fragment : Fragment() {
player = ExoPlayer.Builder(it).build()
}
initViews()
initPlayerView()
handleScaleAnimations()
updateBackground()
minuteReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// this function is called every minute
if (intent?.action == ACTION_TIME_TICK) {
updateBackground()
}
}
}
activity?.registerReceiver(minuteReceiver, IntentFilter(ACTION_TIME_TICK))
setObservers()
clickEvents()
@@ -81,12 +74,22 @@ class Home1Fragment : Fragment() {
return binding.root
}
private fun initViews() {
if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide()
}else{
binding.playerView.show()
}
}
override fun onResume() {
super.onResume()
handleAnimations()
if (!player.isPlaying){
player.play()
}
binding.playerView.show()
}
override fun onPause() {
@@ -98,6 +101,10 @@ class Home1Fragment : Fragment() {
if (star2Animator?.isRunning == true) star2Animator?.pause()
if (player.isPlaying) player.pause()
if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide()
}
}
override fun onDestroy() {
@@ -140,6 +147,16 @@ class Home1Fragment : Fragment() {
moreTxt.text = getString(R.string.more)
}
}
minuteReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// this function is called every minute
if (intent?.action == ACTION_TIME_TICK) {
updateBackground()
}
}
}
activity?.registerReceiver(minuteReceiver, IntentFilter(ACTION_TIME_TICK))
}
private fun clickEvents() {
@@ -149,6 +166,11 @@ class Home1Fragment : Fragment() {
startActivity(Intent(it, LiveStreamPlayerActivity::class.java))
}
}
more.setOnClickListener {
activity?.let {
startActivity(Intent(it, MoreHomeActivity::class.java))
} }
}
}

View File

@@ -1,10 +1,14 @@
package com.woka.home.fragments
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Canvas
import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.TextureView
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
@@ -18,7 +22,8 @@ import com.woka.mvvm.userDataModels.UserDataResponse
import com.woka.networking.ApiResult
import com.woka.players.LiveStreamPlayerActivity
import com.woka.utils.UserType
import com.woka.utils.toast
import com.woka.utils.hide
import com.woka.utils.show
class Home2Fragment : Fragment() {
@@ -39,6 +44,8 @@ class Home2Fragment : Fragment() {
player = ExoPlayer.Builder(it).build()
}
iniViews()
initPlayerView()
setObservers()
@@ -48,16 +55,32 @@ class Home2Fragment : Fragment() {
return binding.root
}
private fun iniViews() {
if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide()
}else{
binding.playerView.show()
}
}
override fun onResume() {
super.onResume()
if (!player.isPlaying){
player.play()
}
binding.playerView.show()
}
override fun onPause() {
super.onPause()
if (player.isPlaying) player.pause()
if (player.isPlaying) {
player.pause()
}
if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide()
}
}
override fun onDestroy() {

View File

@@ -0,0 +1,17 @@
package com.woka.modules
import com.woka.modules.blogs.BlogsResponse
import com.woka.networking.ApiResult
import com.woka.networking.RetrofitHelper
import com.woka.networking.RetrofitHelper.handleApiCall
class BlogsRepository {
private val apiService = RetrofitHelper.getRetrofit().create(ModuleApiService::class.java)
suspend fun getBlogs(): ApiResult<BlogsResponse>{
return handleApiCall{
apiService.getBlogs()
}
}
}

View File

@@ -0,0 +1,30 @@
package com.woka.modules
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.woka.modules.blogs.BlogsResponse
import com.woka.networking.ApiResult
import kotlinx.coroutines.launch
class BlogsViewModel: ViewModel() {
private val blogsRepository = BlogsRepository()
private val _blogsLiveData = MutableLiveData<ApiResult<BlogsResponse>>()
val blogsLiveData: LiveData<ApiResult<BlogsResponse>?>
get() = _blogsLiveData
init {
loadBlogs()
}
private fun loadBlogs(){
viewModelScope.launch {
_blogsLiveData.postValue(ApiResult.Loading())
_blogsLiveData.postValue(blogsRepository.getBlogs())
}
}
}

View File

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

View File

@@ -0,0 +1,12 @@
package com.woka.modules.blogs
data class Blog(
val article_url: Any?,
val category_master_id: String?,
val content_more_details: List<ContentMoreDetail?>?,
val description: String?,
val id: Int?,
val language_master_id: Int?,
val thumbnail_path: String?,
val title: String?
)

View File

@@ -0,0 +1,6 @@
package com.woka.modules.blogs
data class BlogsResponse(
val blogs: List<Blog?>?,
val total_records: Int?
)

View File

@@ -0,0 +1,11 @@
package com.woka.modules.blogs
data class ContentMoreDetail(
val article: String?,
val content_id: Int?,
val description: String?,
val id: Int?,
val language_master_id: Int?,
val post_type: Int?,
val title: String?
)

View File

@@ -90,7 +90,11 @@ class LiveStreamPlayerActivity : AppCompatActivity(), FullscreenHandler {
override fun onFullscreenExitRequested() {
player.stop()
onBackPressedDispatcher.onBackPressed()
val windowInsetsController =
WindowCompat.getInsetsController(window, window.decorView)
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
finish()
}
override fun onAllowRotationChanged(allowRotation: Boolean) {}

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.5,25C5.602,25 0,19.397 0,12.5C0,5.602 5.602,0 12.5,0C19.397,0 25,5.602 25,12.5C25,19.397 19.397,25 12.5,25ZM12.5,23.913C18.809,23.913 23.913,18.809 23.913,12.5C23.913,6.191 18.809,1.087 12.5,1.087C6.191,1.087 1.087,6.191 1.087,12.5C1.087,18.809 6.191,23.913 12.5,23.913ZM6.946,14.674C6.968,14.68 6.991,14.687 7.014,14.691C7.18,14.704 7.343,14.642 7.456,14.521L12.5,9.477L17.544,14.521C17.761,14.738 18.109,14.738 18.325,14.521C18.542,14.304 18.542,13.956 18.325,13.74L12.891,8.305C12.789,8.199 12.646,8.139 12.5,8.139C12.354,8.139 12.211,8.199 12.109,8.305L6.675,13.74C6.524,13.88 6.464,14.092 6.522,14.292C6.579,14.489 6.743,14.638 6.946,14.674Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp"/>
</shape>

View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home.MoreHomeActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/img_more_bg"
android:contentDescription="@string/image"
android:scaleType="fitXY"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:translationZ="1dp"
android:layout_marginTop="@dimen/_30sdp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="15dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.woka.utils.PressableImageView
android:id="@+id/more"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:contentDescription="@string/more"
android:scaleType="fitXY"
android:src="@drawable/ic_more_up" />
<TextView
android:id="@+id/more_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="@font/exo_2_bold"
android:text="@string/more"
android:textAlignment="center"
android:textColor="@color/white"
/>
<TextView
android:id="@+id/coming_soon_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/coming_soonn_on_woka"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_16ssp"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
/>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="5dp"
android:layout_marginTop="5dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:src="@drawable/img_masila_tn_small"
android:contentDescription="@string/masila"
android:scaleType="fitXY"
/>
<com.woka.utils.PressableCard
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_25"
android:backgroundTint="@color/color_primary"
android:layout_centerInParent="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/play_trailer"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
/>
</com.woka.utils.PressableCard>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/masila"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary"
android:textSize="@dimen/_12ssp"
android:layout_marginStart="15dp"
android:layout_marginVertical="10dp"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/blogs"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_16ssp"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_blogs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="horizontal"
tools:listitem="@layout/blog_view_holder"
android:layout_marginVertical="5dp"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<com.woka.utils.PressableCard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/round_bg_5"
android:backgroundTint="@color/white"
android:layout_marginEnd="15dp"
android:elevation="3dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="@dimen/_120sdp"
android:layout_height="@dimen/_80sdp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="5dp">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/image"
android:src="@color/black"
/>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Sabak Degi Naani: The Lessons of a Wise Grandmother"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:ems="9"
/>
</LinearLayout>
</com.woka.utils.PressableCard>

View File

@@ -124,11 +124,20 @@
app:layout_constraintBottom_toTopOf="@id/g1"
app:layout_constraintTop_toBottomOf="@id/profile_image">
<ImageView
android:id="@+id/player_view_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/image"
android:translationZ="0dp"
/>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:resize_mode="fill"
android:translationZ="1dp"
/>
</androidx.cardview.widget.CardView>

View File

@@ -551,6 +551,7 @@
app:layout_constraintStart_toStartOf="parent">
<com.woka.utils.PressableImageView
android:id="@+id/more"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:contentDescription="@string/more"

View File

@@ -116,4 +116,8 @@
<string name="woka_fm">वोका एफएम</string>
<string name="games">खेल</string>
<string name="coming_soonn_on_woka">जल्द ही Woka पर आ रहा है</string>
<string name="woka_live_tv">वोका लाइव टीवी</string>
<string name="blogs">ब्लॉग</string>
<string name="masila">मासिला</string>
<string name="play_trailer">ट्रेलर चलाएं</string>
</resources>

View File

@@ -15,4 +15,6 @@
<color name="morning_status">#a3e1d3</color>
<color name="afternoon_status">#11b3fe</color>
<color name="night_status">#443682</color>
<color name="more_bg">#cbe16f</color>
</resources>

View File

@@ -136,4 +136,6 @@
<string name="coming_soonn_on_woka">Coming soonn on Woka</string>
<string name="woka_live_tv">WOKA LIVE TV</string>
<string name="blogs">BLOGS</string>
<string name="masila">MASILA</string>
<string name="play_trailer">PLAY TRAILER</string>
</resources>