android: single login wizard, bugfix race condition.

This commit is contained in:
Joachim Fritzsch 2014-05-01 13:19:42 +02:00
parent 166a5feb25
commit 2ff3ee7e06
1 changed files with 13 additions and 4 deletions

View File

@ -108,7 +108,7 @@ public class ProjectAttachService extends Service {
private ArrayList<ProjectAttachWrapper> selectedProjects = new ArrayList<ProjectAttachWrapper>(); private ArrayList<ProjectAttachWrapper> selectedProjects = new ArrayList<ProjectAttachWrapper>();
public boolean projectConfigRetrievalFinished = false; public boolean projectConfigRetrievalFinished = true; // shows whether project retrieval is ongoing
//credentials //credentials
private String email = ""; private String email = "";
@ -152,16 +152,20 @@ public class ProjectAttachService extends Service {
* @return success * @return success
*/ */
public boolean setSelectedProjects (ArrayList<ProjectInfo> selected) { public boolean setSelectedProjects (ArrayList<ProjectInfo> selected) {
if(!projectConfigRetrievalFinished) {
if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setSelectedProjects: stop, async task already running.");
return false;
}
selectedProjects.clear(); selectedProjects.clear();
for(ProjectInfo tmp: selected) { for(ProjectInfo tmp: selected) {
selectedProjects.add(new ProjectAttachWrapper(tmp)); selectedProjects.add(new ProjectAttachWrapper(tmp));
} }
// get projectConfigs
if(mIsBound) { if(mIsBound) {
new GetProjectConfigsAsync().execute(); new GetProjectConfigsAsync().execute();
} else { } else {
if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setSelectedProjects: could not load configuration files, monitor not bound!"); if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setSelectedProjects: could not load configuration files, monitor not bound.");
return false; return false;
} }
@ -177,6 +181,11 @@ public class ProjectAttachService extends Service {
* @return success * @return success
*/ */
public boolean setManuallySelectedProject(String url) { public boolean setManuallySelectedProject(String url) {
if(!projectConfigRetrievalFinished) {
if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setManuallySelectedProject: stop, async task already running.");
return false;
}
selectedProjects.clear(); selectedProjects.clear();
selectedProjects.add(new ProjectAttachWrapper(url)); selectedProjects.add(new ProjectAttachWrapper(url));
@ -184,7 +193,7 @@ public class ProjectAttachService extends Service {
if(mIsBound) { if(mIsBound) {
new GetProjectConfigsAsync().execute(); new GetProjectConfigsAsync().execute();
} else { } else {
if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setManuallySelectedProject: could not load configuration file, monitor not bound!"); if(Logging.ERROR) Log.e(Logging.TAG,"ProjectAttachService.setManuallySelectedProject: could not load configuration file, monitor not bound.");
return false; return false;
} }