Solving some warning

This commit is contained in:
Kelvin 2023-12-11 13:26:13 +01:00
commit f31b6c50e9
7 changed files with 11 additions and 20 deletions

View file

@ -1,5 +1,6 @@
package com.futo.platformplayer.activities package com.futo.platformplayer.activities
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
@ -852,6 +853,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
* Navigate takes a MainFragment, and makes them the current main visible view * Navigate takes a MainFragment, and makes them the current main visible view
* A parameter can be provided which becomes available in the onShow of said fragment * A parameter can be provided which becomes available in the onShow of said fragment
*/ */
@SuppressLint("CommitTransaction")
fun navigate(segment: MainFragment, parameter: Any? = null, withHistory: Boolean = true, isBack: Boolean = false) { fun navigate(segment: MainFragment, parameter: Any? = null, withHistory: Boolean = true, isBack: Boolean = false) {
Logger.i(TAG, "Navigate to $segment (parameter=$parameter, withHistory=$withHistory, isBack=$isBack)") Logger.i(TAG, "Navigate to $segment (parameter=$parameter, withHistory=$withHistory, isBack=$isBack)")
@ -897,11 +899,6 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
} }
transaction.commitNow(); transaction.commitNow();
} else { } else {
//Special cases
if(segment is VideoDetailFragment) {
_fragContainerVideoDetail.visibility = View.VISIBLE;
_fragVideoDetail.maximizeVideoDetail();
}
if(!segment.hasBottomBar) { if(!segment.hasBottomBar) {
supportFragmentManager.beginTransaction() supportFragmentManager.beginTransaction()

View file

@ -191,7 +191,7 @@ class ManagedHttpServer(private val _requestedPort: Int = 0) {
} }
} }
fun addBridgeHandlers(obj: Any, tag: String? = null) { fun addBridgeHandlers(obj: Any, tag: String? = null) {
val tagToUse = tag ?: obj.javaClass.name; //val tagToUse = tag ?: obj.javaClass.name;
val getMethods = obj::class.java.declaredMethods val getMethods = obj::class.java.declaredMethods
.filter { it.getAnnotation(HttpGET::class.java) != null } .filter { it.getAnnotation(HttpGET::class.java) != null }
.map { Pair<Method, HttpGET>(it, it.getAnnotation(HttpGET::class.java)!!) } .map { Pair<Method, HttpGET>(it, it.getAnnotation(HttpGET::class.java)!!) }

View file

@ -41,7 +41,7 @@ class SingleAsyncItemPager<T> {
fun getCurrentItem(scope: CoroutineScope) : Deferred<T?>? { fun getCurrentItem(scope: CoroutineScope) : Deferred<T?>? {
synchronized(_requestedPageItems) { synchronized(_requestedPageItems) {
if (_currentResultPos >= _requestedPageItems.size) { if (_currentResultPos >= _requestedPageItems.size) {
val startPos = fillDeferredUntil(_currentResultPos); fillDeferredUntil(_currentResultPos);
if(!_pager.hasMorePages()) { if(!_pager.hasMorePages()) {
Logger.i("SingleAsyncItemPager", "end of async page reached"); Logger.i("SingleAsyncItemPager", "end of async page reached");
completeRemainder { it?.complete(null) }; completeRemainder { it?.complete(null) };
@ -49,7 +49,7 @@ class SingleAsyncItemPager<T> {
if(_isRequesting) if(_isRequesting)
return _requestedPageItems[_currentResultPos]; return _requestedPageItems[_currentResultPos];
_isRequesting = true; _isRequesting = true;
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
try { try {
Logger.i("SingleAsyncItemPager", "Started Pager"); Logger.i("SingleAsyncItemPager", "Started Pager");
val timeForPage = measureTimeMillis { _pager.nextPage() }; val timeForPage = measureTimeMillis { _pager.nextPage() };

View file

@ -269,7 +269,7 @@ class V8Plugin {
throwExceptionFromV8( throwExceptionFromV8(
config, config,
result.getOrThrow(config, "plugin_type", "V8Plugin"), result.getOrThrow(config, "plugin_type", "V8Plugin"),
result.getOrThrow(config, "message", "V8Plugin"), context + ":" + result.getOrThrow(config, "message", "V8Plugin"),
null, null,
null, null,
codeStripped codeStripped
@ -280,7 +280,7 @@ class V8Plugin {
return result; return result;
} }
catch(scriptEx: JavetCompilationException) { catch(scriptEx: JavetCompilationException) {
throw ScriptCompilationException(config, "Compilation: ${scriptEx.message}\n(${scriptEx.scriptingError.lineNumber})[${scriptEx.scriptingError.startColumn}-${scriptEx.scriptingError.endColumn}]: ${scriptEx.scriptingError.sourceLine}", null, codeStripped); throw ScriptCompilationException(config, "Compilation: [${context}]: ${scriptEx.message}\n(${scriptEx.scriptingError.lineNumber})[${scriptEx.scriptingError.startColumn}-${scriptEx.scriptingError.endColumn}]: ${scriptEx.scriptingError.sourceLine}", null, codeStripped);
} }
catch(executeEx: JavetExecutionException) { catch(executeEx: JavetExecutionException) {
if(executeEx.scriptingError?.context?.containsKey("plugin_type") == true) { if(executeEx.scriptingError?.context?.containsKey("plugin_type") == true) {

View file

@ -731,7 +731,6 @@ class StateApp {
StatePlatform.instance.reloadClient(context, client.config.id); StatePlatform.instance.reloadClient(context, client.config.id);
} catch (e: Throwable) { } catch (e: Throwable) {
Logger.e(SourceDetailFragment.TAG, "Failed to reload client.", e) Logger.e(SourceDetailFragment.TAG, "Failed to reload client.", e)
return@launch;
} }
} }
} }

View file

@ -676,7 +676,7 @@ class StatePlatform {
} }
} }
fun getChannelContent(baseClient: IPlatformClient, channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0, ignorePlugins: List<String>? = null): IPager<IPlatformContent> { fun getChannelContent(baseClient: IPlatformClient, channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0): IPager<IPlatformContent> {
val clientCapabilities = baseClient.getChannelCapabilities(); val clientCapabilities = baseClient.getChannelCapabilities();
val client = if(usePooledClients > 1) val client = if(usePooledClients > 1)
_channelClientPool.getClientPooled(baseClient, usePooledClients); _channelClientPool.getClientPooled(baseClient, usePooledClients);
@ -796,7 +796,7 @@ class StatePlatform {
fun getChannelContent(channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0, ignorePlugins: List<String>? = null): IPager<IPlatformContent> { fun getChannelContent(channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0, ignorePlugins: List<String>? = null): IPager<IPlatformContent> {
Logger.i(TAG, "Platform - getChannelVideos"); Logger.i(TAG, "Platform - getChannelVideos");
val baseClient = getChannelClient(channelUrl, ignorePlugins); val baseClient = getChannelClient(channelUrl, ignorePlugins);
return getChannelContent(baseClient, channelUrl, isSubscriptionOptimized, usePooledClients, ignorePlugins); return getChannelContent(baseClient, channelUrl, isSubscriptionOptimized, usePooledClients);
} }
fun getChannelContent(channelUrl: String, type: String?, ordering: String = ResultCapabilities.ORDER_CHONOLOGICAL): IPager<IPlatformContent> { fun getChannelContent(channelUrl: String, type: String?, ordering: String = ResultCapabilities.ORDER_CHONOLOGICAL): IPager<IPlatformContent> {
val client = getChannelClient(channelUrl); val client = getChannelClient(channelUrl);
@ -899,18 +899,13 @@ class StatePlatform {
devId = newClient.devID; devId = newClient.devID;
try { try {
StateDeveloper.instance.initializeDev(devId!!); StateDeveloper.instance.initializeDev(devId!!);
var didEnable = false;
if (isPrimary) { if (isPrimary) {
_primaryClientObj = newClient; _primaryClientObj = newClient;
_enabledClients.add(0, newClient); _enabledClients.add(0, newClient);
newClient.initialize(); newClient.initialize();
didEnable = true;
} else if (isEnabled) { } else if (isEnabled) {
_enabledClients.add(newClient); _enabledClients.add(newClient);
if(!didEnable) {
newClient.initialize(); newClient.initialize();
didEnable = true;
}
} }
_availableClients.add(newClient); _availableClients.add(newClient);
} catch (ex: Exception) { } catch (ex: Exception) {

View file

@ -153,7 +153,7 @@ class SimpleSubscriptionAlgorithm(
try { try {
val platformClient = StatePlatform.instance.getChannelClientOrNull(url, toIgnore) ?: continue; val platformClient = StatePlatform.instance.getChannelClientOrNull(url, toIgnore) ?: continue;
val time = measureTimeMillis { val time = measureTimeMillis {
pager = StatePlatform.instance.getChannelContent(platformClient, url, true, threadPool.poolSize, toIgnore); pager = StatePlatform.instance.getChannelContent(platformClient, url, true, threadPool.poolSize);
pager = StateCache.cachePagerResults(scope, pager!!) { pager = StateCache.cachePagerResults(scope, pager!!) {
onNewCacheHit.emit(sub, it); onNewCacheHit.emit(sub, it);
}; };