Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/FragmentHelper.java
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | protected void attachFragmentToContainer(FragmentManager fm,Fragment fragment, AttachParameters parameters){ | ||||
switch (parameters.transaction){ | switch (parameters.transaction){ | ||||
case REPLACE: | case REPLACE: | ||||
ft.replace(frameID,fragment,parameters.tag); | ft.replace(frameID,fragment,parameters.tag); | ||||
} | } | ||||
if (parameters.addToBackStack) | if (parameters.addToBackStack) | ||||
ft.addToBackStack("state_"+parameters.tag); | ft.addToBackStack("state_"+parameters.tag); | ||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); | ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); | ||||
if(!fm.isDestroyed()) | |||||
ft.commit(); | ft.commit(); | ||||
//fm.executePendingTransactions(); | //fm.executePendingTransactions(); | ||||
} | } | ||||
public void setBlockAllActivities(boolean shouldI) { | public void setBlockAllActivities(boolean shouldI) { | ||||
this.shouldHaltAllActivities = shouldI; | this.shouldHaltAllActivities = shouldI; | ||||
} | } | ||||
public void stopLastRequestIfNeeded(){ | public void stopLastRequestIfNeeded(){ | ||||
if(lastTaskRef == null) return; | if(lastTaskRef == null) return; | ||||
AsyncDataDownload task = lastTaskRef.get(); | AsyncDataDownload task = lastTaskRef.get(); | ||||
if(task!=null){ | if(task!=null){ | ||||
task.cancel(true); | task.cancel(true); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Wrapper to show the errors/status that happened | * Wrapper to show the errors/status that happened | ||||
* @param res result from Fetcher | * @param res result from Fetcher | ||||
*/ | */ | ||||
public void showErrorMessage(Fetcher.result res){ | public void showErrorMessage(Fetcher.Result res){ | ||||
//TODO: implement a common set of errors for all fragments | //TODO: implement a common set of errors for all fragments | ||||
switch (res){ | switch (res){ | ||||
case OK: | case OK: | ||||
break; | break; | ||||
case CLIENT_OFFLINE: | case CLIENT_OFFLINE: | ||||
showToastMessage(R.string.network_error, true); | showToastMessage(R.string.network_error, true); | ||||
break; | break; | ||||
case SERVER_ERROR: | case SERVER_ERROR: | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register