mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Fix backbutton behaviour
- close on MainActivity when back pressed - clear NavStack on rotation
This commit is contained in:
		| @@ -85,9 +85,4 @@ public class MainActivity extends AppCompatActivity { | |||||||
|                 return super.onOptionsItemSelected(item); |                 return super.onOptionsItemSelected(item); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void onBackPressed() { |  | ||||||
|         //ignore back |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -73,10 +73,6 @@ public class NavStack { | |||||||
|         return instance; |         return instance; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void addEntry(String url, Class ac, int serviceId) { |  | ||||||
|         stack.push(new NavEntry(url, serviceId)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public void navBack(Activity activity) throws Exception { |     public void navBack(Activity activity) throws Exception { | ||||||
|         if(stack.size() == 0) { // if stack is already empty here, activity was probably called |         if(stack.size() == 0) { // if stack is already empty here, activity was probably called | ||||||
|             // from another app |             // from another app | ||||||
| @@ -120,7 +116,10 @@ public class NavStack { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void openActivity(Context context, String url, int serviceId, Class acitivtyClass) { |     private void openActivity(Context context, String url, int serviceId, Class acitivtyClass) { | ||||||
|  |         //if last element has the same url do not push to stack again | ||||||
|  |         if(stack.isEmpty() || !stack.peek().url.equals(url)) { | ||||||
|             stack.push(new NavEntry(url, serviceId)); |             stack.push(new NavEntry(url, serviceId)); | ||||||
|  |         } | ||||||
|         Intent i = new Intent(context, acitivtyClass); |         Intent i = new Intent(context, acitivtyClass); | ||||||
|         i.putExtra(SERVICE_ID, serviceId); |         i.putExtra(SERVICE_ID, serviceId); | ||||||
|         i.putExtra(URL, url); |         i.putExtra(URL, url); | ||||||
| @@ -144,6 +143,7 @@ public class NavStack { | |||||||
|  |  | ||||||
|     public void restoreSavedInstanceState(Bundle state) { |     public void restoreSavedInstanceState(Bundle state) { | ||||||
|         ArrayList<String> sa = state.getStringArrayList(NAV_STACK); |         ArrayList<String> sa = state.getStringArrayList(NAV_STACK); | ||||||
|  |         stack.clear(); | ||||||
|         for(String url : sa) { |         for(String url : sa) { | ||||||
|             stack.push(new NavEntry(url, NewPipe.getServiceByUrl(url).getServiceId())); |             stack.push(new NavEntry(url, NewPipe.getServiceByUrl(url).getServiceId())); | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christian Schabesberger
					Christian Schabesberger