diff --git a/app/.gitignore b/app/.gitignore index c5ae418..9bc39b4 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -3,4 +3,4 @@ /cmake_install.cmake /CMakeFiles/ /Makefile -/src/main/cpp/native-lib.c +/src/main/cpp/native.c diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9761d60..4cd55cf 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -15,17 +15,17 @@ if (IS_SO_BUILD) # and CMake builds them for you. When you build your app, Gradle # automatically packages shared libraries with your APK. add_library( # Specifies the name of the library. - native-lib + native # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). - src/main/cpp/native-lib.c) + src/main/cpp/native.c) # 设置编译输出路径 set_target_properties( - native-lib + native PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI} @@ -36,18 +36,18 @@ else () SHARED src/main/cpp/nothing.c) - add_library(native-lib + add_library(native SHARED IMPORTED) set_target_properties( # Specifies the target library. - native-lib + native # Specifies the parameter you want to define. PROPERTIES IMPORTED_LOCATION # Provides the path to the library you want to import. - ${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}/libnative-lib.so) + ${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}/libnative.so) endif () add_library(libssl @@ -87,7 +87,7 @@ find_library( # Defines the name of the path variable that stores the if (IS_SO_BUILD) # Links your native library against one or more other native libraries. target_link_libraries( # Specifies the target library. - native-lib + native libssl libcrypto ${log-lib}) @@ -96,6 +96,6 @@ else () nothing libssl libcrypto - native-lib + native ${log-lib}) endif () \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 77f8e1d..6d2470e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -104,7 +104,7 @@ dependencies { implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2" implementation 'androidx.core:core-ktx:1.11.0-beta02' - implementation 'androidx.leanback:leanback:1.0.0' + implementation 'androidx.leanback:leanback:1.2.0-alpha02' implementation 'com.github.bumptech.glide:glide:4.11.0' implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2" implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0-RC") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 511d935..379173e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,6 +14,7 @@ android:supportsRtl="true" android:theme="@style/Theme.MyTV"> = tvListViewModel.size()) { + itemPosition = 0 + savePosition(0) + } + + val tv = list2[itemPosition].item val tvModel = tvListViewModel.getTVModel(itemPosition) if (tvModel?.ysp() != null) { + Log.i(TAG, "ysp ${tvModel.getTV()}") lifecycleScope.launch(Dispatchers.IO) { tvModel.let { request?.fetchData(it) } } } else { - (activity as? MainActivity)?.play(list2[itemPosition].item) -// (activity as? MainActivity)?.switchInfoFragment(list2[itemPosition].item) + (activity as? MainActivity)?.play(tv) +// (activity as? MainActivity)?.switchInfoFragment(tv) } + Toast.makeText( + activity, + tv.title, + Toast.LENGTH_SHORT + ).show() (activity as? MainActivity)?.switchMainFragment() } diff --git a/app/src/main/java/com/lizongying/mytv/Request.kt b/app/src/main/java/com/lizongying/mytv/Request.kt index bef780f..9de7715 100644 --- a/app/src/main/java/com/lizongying/mytv/Request.kt +++ b/app/src/main/java/com/lizongying/mytv/Request.kt @@ -89,6 +89,7 @@ class Request(var context: Context) { override fun onResponse(call: Call, response: Response) { if (response.isSuccessful) { val liveInfo = response.body() + Log.i(TAG, "liveInfo $liveInfo") if (liveInfo?.data?.playurl != null) { val chanll = liveInfo.data.chanll val decodedBytes = Base64.decode( @@ -117,6 +118,7 @@ class Request(var context: Context) { } override fun onFailure(call: Call, t: Throwable) { + Log.i(TAG, "get data error") } }) } diff --git a/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt b/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt index 78b941a..dff5038 100644 --- a/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt +++ b/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt @@ -1,6 +1,5 @@ package com.lizongying.mytv.models -import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import com.lizongying.mytv.TV @@ -41,4 +40,8 @@ class TVListViewModel : ViewModel() { fun getTVModel(id: Int): TVViewModel? { return tvModelListLiveData.value?.get(id) } + + fun size(): Int { + return tvListLiveData.value!!.size + } } \ No newline at end of file