mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Merge pull request #6639 from TeamNewPipe/fix/db_transaction
Fix crash when refreshing feed after importing database or subscriptions
This commit is contained in:
		| @@ -51,4 +51,15 @@ public final class NewPipeDatabase { | |||||||
|             throw new RuntimeException("Checkpoint was blocked from completing"); |             throw new RuntimeException("Checkpoint was blocked from completing"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void close() { | ||||||
|  |         if (databaseInstance != null) { | ||||||
|  |             synchronized (NewPipeDatabase.class) { | ||||||
|  |                 if (databaseInstance != null) { | ||||||
|  |                     databaseInstance.close(); | ||||||
|  |                     databaseInstance = null; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ import androidx.fragment.app.FragmentTransaction; | |||||||
| import com.nostra13.universalimageloader.core.ImageLoader; | import com.nostra13.universalimageloader.core.ImageLoader; | ||||||
|  |  | ||||||
| import org.schabi.newpipe.MainActivity; | import org.schabi.newpipe.MainActivity; | ||||||
|  | import org.schabi.newpipe.NewPipeDatabase; | ||||||
| import org.schabi.newpipe.R; | import org.schabi.newpipe.R; | ||||||
| import org.schabi.newpipe.RouterActivity; | import org.schabi.newpipe.RouterActivity; | ||||||
| import org.schabi.newpipe.about.AboutActivity; | import org.schabi.newpipe.about.AboutActivity; | ||||||
| @@ -608,6 +609,7 @@ public final class NavigationHelper { | |||||||
|      * @param activity the activity to finish |      * @param activity the activity to finish | ||||||
|      */ |      */ | ||||||
|     public static void restartApp(final Activity activity) { |     public static void restartApp(final Activity activity) { | ||||||
|  |         NewPipeDatabase.close(); | ||||||
|         activity.finishAffinity(); |         activity.finishAffinity(); | ||||||
|         final Intent intent = new Intent(activity, MainActivity.class); |         final Intent intent = new Intent(activity, MainActivity.class); | ||||||
|         activity.startActivity(intent); |         activity.startActivity(intent); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tobi
					Tobi