Skip to content

Commit

Permalink
Version-2 Released
Browse files Browse the repository at this point in the history
  • Loading branch information
professorDeveloper committed Mar 6, 2024
1 parent bca7e60 commit d2d53e0
Show file tree
Hide file tree
Showing 31 changed files with 1,255 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.azamovhudstc.soplay"
minSdk 23
targetSdk 33
versionCode 1
versionName "1.0"
versionCode ((System.currentTimeMillis() / 60000).toInteger())
versionName "2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -76,6 +76,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"

Expand Down Expand Up @@ -160,6 +161,7 @@ dependencies {
implementation 'com.vmadalin:easypermissions-ktx:1.0.0'
// Shimmer Effect
implementation 'com.facebook.shimmer:shimmer:0.5.0'
implementation 'com.github.javiersantos:AppUpdater:2.7'

//

Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"versionCode": 28495693,
"versionName": "2.0",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/azamovhudstc/soplay/app/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.azamovhudstc.soplay.app

import android.app.Application
import com.azamovhudstc.soplay.utils.initializeNetwork
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
Expand All @@ -11,5 +12,6 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
instance=this
initializeNetwork(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.Flow

interface TvRepository {
fun getTv(): Flow<Result<ArrayList<Movie>>>
fun getNextTvPage(page:Int): Flow<Result<ArrayList<Movie>>>

suspend fun getTvFullDataByHref(href: String): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class DetailRepositoryImpl : DetailRepository {
val country: String =
document.select("div.fullmeta-item span.fullmeta-label:contains(Страна) + span.fullmeta-seclabel a")
.text()
val durationElement = document.selectFirst(".fullmeta-item .fullmeta-seclabel a")?.text()
val durationElement =
document.selectFirst(".fullmeta-item .fullmeta-seclabel a")?.text()
val duration = durationElement?.replace(" мин", "")

val posterImageSrc: String =
Expand All @@ -59,10 +60,14 @@ class DetailRepositoryImpl : DetailRepository {
val matches = pattern.findAll(document.html())

// Process the matches
val options = matches.map {
val options = matches.mapNotNull {
val value = it.groupValues[1]
val text = it.groupValues[2]
Pair(text, value)
if (value != "http://yangi-kinolar.ru/vast/player.html?file=[xfvalue_kino_url]") {
Pair(text, value)
} else {
null
}
}.toList()

val imageUrls = document.select(".xfieldimagegallery img.lazyload[data-src]")
Expand All @@ -85,7 +90,7 @@ class DetailRepositoryImpl : DetailRepository {
val data = FullMovieData(
year = year,
country = country,
duration = "000",
duration = "000",
posterImageSrc = posterImageSrc,
genres = genres,
directors = directors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.azamovhudstc.soplay.repository.HomeRepository
import com.azamovhudstc.soplay.utils.Constants.mainUrl
import com.azamovhudstc.soplay.utils.isOnline
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import org.jsoup.Connection
Expand Down Expand Up @@ -125,12 +124,12 @@ class HomeRepositoryImpl : HomeRepository {
"Upgrade-Insecure-Requests" to "1",
"X-Requested-With" to "XMLHttpRequest"
)
).get()
).execute().parse()
emit(Result.success(extractMovieList(document)))

}.flowOn(Dispatchers.IO)

override fun getLastPagination(page: Int)=flow<Result<ArrayList<MovieInfo>>> {
override fun getLastPagination(page: Int) = flow<Result<ArrayList<MovieInfo>>> {
val document =
Jsoup.connect("$mainUrl/lastnews/page/$page")
.followRedirects(true)
Expand All @@ -145,13 +144,13 @@ class HomeRepositoryImpl : HomeRepository {
"Upgrade-Insecure-Requests" to "1",
"X-Requested-With" to "XMLHttpRequest"
)
).get()
).execute().parse()


emit(Result.success(extractMovieList(document)))
}.flowOn(Dispatchers.IO)
emit(Result.success(extractMovieList(document)))
}.flowOn(Dispatchers.IO)

override fun getLastNews()=flow<Result<ArrayList<MovieInfo>>> {
override fun getLastNews() = flow<Result<ArrayList<MovieInfo>>> {
val document =
Jsoup.connect(mainUrl + "/lastnews/")
.followRedirects(true)
Expand All @@ -166,9 +165,9 @@ class HomeRepositoryImpl : HomeRepository {
"Upgrade-Insecure-Requests" to "1",
"X-Requested-With" to "XMLHttpRequest"
)
).get()
).execute().parse()
emit(Result.success(extractMovieList(document)))


}.flowOn(Dispatchers.IO)
}.flowOn(Dispatchers.IO)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import com.azamovhudstc.soplay.data.Movie
import com.azamovhudstc.soplay.repository.TvRepository
import com.azamovhudstc.soplay.utils.Color
import com.azamovhudstc.soplay.utils.Utils.getJsoup
import com.azamovhudstc.soplay.utils.Utils.httpClient
import com.azamovhudstc.soplay.utils.parser
import com.azamovhudstc.soplay.utils.printlnColored
import com.azamovhudstc.soplay.utils.snackString
import com.lagradost.nicehttp.Requests
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.jsoup.select.Elements

Expand Down Expand Up @@ -53,11 +49,42 @@ class TvRepositoryImpl : TvRepository {

}.flowOn(Dispatchers.IO)

override fun getNextTvPage(page: Int) = flow<Result<ArrayList<Movie>>> {
val tvList = ArrayList<Movie>()
val doc = getJsoup("$mainURL/page/$page/")
val movieElements: Elements = doc.select(".tcarusel-item.main-news")
if (movieElements != null) {
movieElements
.map {
val href = it.select("a[href]").attr("href")
val title = it.select("a[href]").text()
val image = it.select("img.xfieldimage").attr("src")
val rating = it.select(".current-rating").text().toInt()
printlnColored(" Text: ${removeNumbers(title)}", Color.YELLOW)
printlnColored(" Image: $image", Color.DARK_ORANGE)
printlnColored(" Href: $href", Color.CYAN)
printlnColored(" Rating: $rating", Color.GREEN)
printlnColored("-----------------------------", Color.YELLOW)

}

}
movieElements.map {
val href = it.select("a[href]").attr("href")
val title = it.select("a[href]").text()
val image = it.select("img.xfieldimage").attr("src")
val rating = it.select(".current-rating").text().toInt()

tvList.add(Movie(href, removeNumbers(title), image, rating))
}
emit(Result.success(tvList))
}.flowOn(Dispatchers.IO)

private fun removeNumbers(input: String): String {
return input.replace(Regex("\\d+"), "").trim()
}

override suspend fun getTvFullDataByHref(href: String)= withContext(Dispatchers.IO) {
override suspend fun getTvFullDataByHref(href: String) = withContext(Dispatchers.IO) {

try {
val doc = getJsoup(href)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import android.content.SharedPreferences
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import com.azamovhudstc.soplay.R
import com.azamovhudstc.soplay.databinding.ActivityMainBinding
import com.azamovhudstc.soplay.utils.hideWithoutAnimation
import com.azamovhudstc.soplay.utils.initActivity
import com.azamovhudstc.soplay.utils.showWithAnimation
import com.azamovhudstc.soplay.utils.snackString
import com.azamovhudstc.soplay.utils.*
import com.vmadalin.easypermissions.EasyPermissions
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
Expand All @@ -30,6 +30,16 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
initActivity(this)
hasPermission()
setupBottomNavigationView()
checkUpdate()
}


private fun checkUpdate() {
lifecycleScope.launch(Dispatchers.IO){
if (loadData<Boolean>("check_update") != false) AppUpdater.check(this@MainActivity)

}

}

private fun hasPermission() {
Expand Down Expand Up @@ -72,6 +82,9 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
R.id.popularSeeAllScreen -> {
binding.bottomNavigation.hideWithoutAnimation(binding.fragmentContainerView)
}
R.id.navigation_settings->{
binding.bottomNavigation.hideWithoutAnimation(binding.fragmentContainerView)
}

R.id.searchScreen -> {
binding.bottomNavigation.hideWithoutAnimation(binding.fragmentContainerView)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.azamovhudstc.soplay.ui.screens.bottomsheet

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.azamovhudstc.soplay.databinding.BottomSheetCustomBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class CustomBottomDialog : BottomSheetDialogFragment() {
private var _binding: BottomSheetCustomBinding? = null
private val binding get() = _binding!!

private val viewList = mutableListOf<View>()
fun addView(view: View) {
viewList.add(view)
}
var title: String?=null
fun setTitleText(string: String){
title = string
}

private var checkText: String? = null
private var checkChecked: Boolean = false
private var checkCallback: ((Boolean) -> Unit)? = null

fun setCheck(text: String, checked: Boolean, callback: ((Boolean) -> Unit)) {
checkText = text
checkChecked = checked
checkCallback = callback
}

private var negativeText: String? = null
private var negativeCallback: (() -> Unit)? = null
fun setNegativeButton(text: String, callback: (() -> Unit)) {
negativeText = text
negativeCallback = callback
}

private var positiveText: String? = null
private var positiveCallback: (() -> Unit)? = null
fun setPositiveButton(text: String, callback: (() -> Unit)) {
positiveText = text
positiveCallback = callback
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = BottomSheetCustomBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding.bottomSheerCustomTitle.text = title
viewList.forEach {
binding.bottomDialogCustomContainer.addView(it)
}
if (checkText != null) binding.bottomDialogCustomCheckBox.apply {
visibility = View.VISIBLE
text = checkText
isChecked = checkChecked
setOnCheckedChangeListener { _, checked ->
checkCallback?.invoke(checked)
}
}

if(negativeText!=null) binding.bottomDialogCustomNegative.apply {
visibility = View.VISIBLE
text = negativeText
setOnClickListener {
negativeCallback?.invoke()
}
}

if(positiveText!=null) binding.bottomDialogCustomPositive.apply {
visibility = View.VISIBLE
text = positiveText
setOnClickListener {
positiveCallback?.invoke()
}
}

}

override fun onDestroy() {
_binding = null
super.onDestroy()
}

companion object {
fun newInstance() = CustomBottomDialog()
}

}
Loading

0 comments on commit d2d53e0

Please sign in to comment.