mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	fixed
This commit is contained in:
		
							parent
							
								
									576377e4bb
								
							
						
					
					
						commit
						8d0d37093f
					
				
					 4 changed files with 76 additions and 52 deletions
				
			
		|  | @ -4,8 +4,11 @@ import android.util.Log | |||
| import androidx.lifecycle.LifecycleOwner | ||||
| import androidx.lifecycle.LiveData | ||||
| import androidx.lifecycle.Observer | ||||
| import com.bumptech.glide.load.HttpException | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.withContext | ||||
| import java.net.SocketTimeoutException | ||||
| import java.net.UnknownHostException | ||||
| 
 | ||||
| fun <T> LifecycleOwner.observe(liveData: LiveData<T>, action: (t: T) -> Unit) { | ||||
|     liveData.observe(this, Observer { it?.let { t -> action(t) } }) | ||||
|  | @ -55,17 +58,22 @@ suspend fun <T> safeApiCall( | |||
|         } catch (throwable: Throwable) { | ||||
|             logError(throwable) | ||||
|             when (throwable) { | ||||
|                 /*is HttpException -> { | ||||
|                     Resource.Failure(false, throwable.code(), throwable.response()?.errorBody(), throwable.localizedMessage) | ||||
|                 } | ||||
|                 is SocketTimeoutException -> { | ||||
|                     Resource.Failure(true,null,null,"Please try again later.") | ||||
|                     Resource.Failure(true, null, null, "Please try again later.") | ||||
|                 } | ||||
|                 is HttpException -> { | ||||
|                     Resource.Failure(false, throwable.statusCode, null, throwable.localizedMessage) | ||||
|                 } | ||||
|                 is UnknownHostException -> { | ||||
|                     Resource.Failure(true, null, null, "Cannot connect to server, try again later.") | ||||
|                 } | ||||
|                 is UnknownHostException ->{ | ||||
|                     Resource.Failure(true,null,null,"Cannot connect to server, try again later.") | ||||
|                 }*/ | ||||
|                 else -> { | ||||
|                     Resource.Failure(true, null, null, throwable.localizedMessage) | ||||
|                     val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString( | ||||
|                         separator = "\n" | ||||
|                     ) { | ||||
|                         "${it.fileName} ${it.lineNumber}" | ||||
|                     } | ||||
|                     Resource.Failure(false, null, null, stackTraceMsg) // | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ package com.lagradost.cloudstream3.services | |||
| import android.app.Service | ||||
| import android.content.Intent | ||||
| import android.os.IBinder | ||||
| import android.util.Log | ||||
| import com.lagradost.cloudstream3.recivers.VideoDownloadRestartReceiver | ||||
| import com.lagradost.cloudstream3.utils.DataStore.getKey | ||||
| import com.lagradost.cloudstream3.utils.DataStore.getKeys | ||||
|  | @ -19,6 +20,8 @@ class VideoDownloadKeepAliveService : Service() { | |||
| 
 | ||||
|     override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||||
|         val startValue = intent?.getIntExtra(START_VALUE_KEY, RESTART_NONE) ?: RESTART_NONE | ||||
|         Log.i("Service", "Restarted with start value of $startValue") | ||||
| 
 | ||||
|         if (startValue == RESTART_ALL_DOWNLOADS_AND_QUEUE) { | ||||
|             val keys = this.getKeys(VideoDownloadManager.KEY_RESUME_PACKAGES) | ||||
|             val resumePkg = keys.mapNotNull { k -> this.getKey<VideoDownloadManager.DownloadResumePackage>(k) } | ||||
|  |  | |||
|  | @ -171,20 +171,18 @@ class ResultFragment : Fragment() { | |||
|             0 -> { | ||||
|                 result_loading.visibility = VISIBLE | ||||
|                 result_finish_loading.visibility = GONE | ||||
|                 result_reload_connectionerror.visibility = GONE | ||||
|                 result_reload_connection_open_in_browser.visibility = GONE | ||||
|                 result_loading_error.visibility = GONE | ||||
|             } | ||||
|             1 -> { | ||||
|                 result_loading.visibility = GONE | ||||
|                 result_finish_loading.visibility = GONE | ||||
|                 result_reload_connectionerror.visibility = VISIBLE | ||||
|                 result_loading_error.visibility = VISIBLE | ||||
|                 result_reload_connection_open_in_browser.visibility = if (url == null) GONE else VISIBLE | ||||
|             } | ||||
|             2 -> { | ||||
|                 result_loading.visibility = GONE | ||||
|                 result_finish_loading.visibility = VISIBLE | ||||
|                 result_reload_connectionerror.visibility = GONE | ||||
|                 result_reload_connection_open_in_browser.visibility = GONE | ||||
|                 result_loading_error.visibility = GONE | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -660,6 +658,7 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE) | |||
|                     } | ||||
|                 } | ||||
|                 is Resource.Failure -> { | ||||
|                     result_error_text.text = data.errorString | ||||
|                     updateVisStatus(1) | ||||
|                 } | ||||
|                 is Resource.Loading -> { | ||||
|  |  | |||
|  | @ -17,48 +17,62 @@ | |||
|             android:layout_gravity="center" | ||||
|             android:layout_width="50dp" android:layout_height="50dp"> | ||||
|     </ProgressBar> | ||||
|     <com.google.android.material.button.MaterialButton | ||||
|             android:layout_columnWeight="1" | ||||
|     <LinearLayout | ||||
|             android:id="@+id/result_loading_error" | ||||
|             android:orientation="vertical" | ||||
|             android:layout_gravity="center" | ||||
|             android:layout_height="50dp" | ||||
|             android:layout_marginBottom="50dp" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content"> | ||||
|         <com.google.android.material.button.MaterialButton | ||||
|                 android:layout_gravity="center" | ||||
|                 android:layout_height="50dp" | ||||
|                 android:layout_margin="5dp" | ||||
| 
 | ||||
|             app:icon="@drawable/ic_baseline_autorenew_24" | ||||
|             app:iconSize="20dp" | ||||
|             android:text="@string/reload_error" | ||||
|             android:id="@+id/result_reload_connectionerror" | ||||
|             android:textAllCaps="false" | ||||
|             android:textSize="15sp" | ||||
|             app:cornerRadius="5dp" | ||||
|             app:strokeWidth="2dp" | ||||
|             app:strokeColor="@color/colorAccent" | ||||
|             style="@style/Widget.MaterialComponents.Button.OutlinedButton" | ||||
|             app:rippleColor="@color/colorPrimary" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:minWidth="200dp" | ||||
|     > | ||||
|     </com.google.android.material.button.MaterialButton> | ||||
|     <com.google.android.material.button.MaterialButton | ||||
|             android:layout_columnWeight="1" | ||||
|             android:layout_gravity="center" | ||||
|             android:layout_height="50dp" | ||||
|             android:layout_marginTop="50dp" | ||||
|                 app:icon="@drawable/ic_baseline_autorenew_24" | ||||
|                 app:iconSize="20dp" | ||||
|                 android:text="@string/reload_error" | ||||
|                 android:id="@+id/result_reload_connectionerror" | ||||
|                 android:textAllCaps="false" | ||||
|                 android:textSize="15sp" | ||||
|                 app:cornerRadius="5dp" | ||||
|                 app:strokeWidth="2dp" | ||||
|                 app:strokeColor="@color/colorAccent" | ||||
|                 style="@style/Widget.MaterialComponents.Button.OutlinedButton" | ||||
|                 app:rippleColor="@color/colorPrimary" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:minWidth="200dp" | ||||
|         > | ||||
|         </com.google.android.material.button.MaterialButton> | ||||
|         <com.google.android.material.button.MaterialButton | ||||
|                 android:layout_gravity="center" | ||||
|                 android:layout_height="50dp" | ||||
|                 android:layout_margin="5dp" | ||||
| 
 | ||||
|             app:icon="@drawable/ic_baseline_public_24" | ||||
|             app:iconSize="20dp" | ||||
|             android:text="@string/result_open_in_browser" | ||||
|             android:id="@+id/result_reload_connection_open_in_browser" | ||||
|             android:textAllCaps="false" | ||||
|             android:textSize="15sp" | ||||
|             app:cornerRadius="5dp" | ||||
|             app:strokeWidth="2dp" | ||||
|             app:strokeColor="@color/colorAccent" | ||||
|             style="@style/Widget.MaterialComponents.Button.OutlinedButton" | ||||
|             app:rippleColor="@color/colorPrimary" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:minWidth="200dp" | ||||
|     > | ||||
|     </com.google.android.material.button.MaterialButton> | ||||
|                 app:icon="@drawable/ic_baseline_public_24" | ||||
|                 app:iconSize="20dp" | ||||
|                 android:text="@string/result_open_in_browser" | ||||
|                 android:id="@+id/result_reload_connection_open_in_browser" | ||||
|                 android:textAllCaps="false" | ||||
|                 android:textSize="15sp" | ||||
|                 app:cornerRadius="5dp" | ||||
|                 app:strokeWidth="2dp" | ||||
|                 app:strokeColor="@color/colorAccent" | ||||
|                 style="@style/Widget.MaterialComponents.Button.OutlinedButton" | ||||
|                 app:rippleColor="@color/colorPrimary" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:minWidth="200dp" | ||||
|         > | ||||
|         </com.google.android.material.button.MaterialButton> | ||||
|         <TextView | ||||
|                 android:layout_margin="5dp" | ||||
|                 android:gravity="center" | ||||
|                 android:layout_gravity="center" | ||||
|                 android:id="@+id/result_error_text" | ||||
|                 android:textColor="?attr/colorPrimary" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content"> | ||||
|         </TextView> | ||||
|     </LinearLayout> | ||||
| 
 | ||||
|     <FrameLayout | ||||
|             android:visibility="gone" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue