Created
October 20, 2011 18:10
-
-
Save tistaharahap/1301843 to your computer and use it in GitHub Desktop.
An abstract of running a Startup in plain Android AsyncTask subclass.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class RunStartupTask extends AsyncTask<Problem, Idea, Execution> { | |
public static final List<Founder> founders = new ArrayList<Founder>(); | |
private ProgressDialog dialog; | |
@Override | |
protected void onPreExecute() { | |
founders.add("Clark"); | |
founders.add("Kent"); | |
new GetFunding().execute(founders); | |
dialog = new ProgressDialog(getActivity()); | |
dialog.setIcon(R.drawable.logo); | |
dialog.setIndeterminate(Startup.WAKU); | |
dialog.setTitle(Startup.NAME); | |
dialog.setMessage("Cooking.."); | |
dialog.show(); | |
} | |
@Override | |
protected Execution doInBackground(Problem... problems) { | |
Execution exec = new Execution(); | |
for(int i=0, max=problems.length(); i<max; i++) { | |
try { | |
// 2 Founders are enough! | |
Founder.get( i % 2 == 0 ? 0 : 1 ).delegate(); | |
StoryBoard story = new StoryBoard(problems[i]); | |
Wireframe wireframe = story.getWireframe(); | |
UIX uix = wireframe.generateUix(); | |
Development dev = new Development(uix, | |
Development.BACKEND | Development.WEB | Development.MWEB | | |
Development.ANDROID | Development.IOS | Development.BB); | |
publishProgress(new Idea((int) ((i / (float) max) * 100))); | |
exec.add(dev); | |
} catch(Exception e) { | |
Log.e(Startup.NAME, "Nice Try!"); | |
e.printStackTrace(); | |
} | |
} | |
return exec; | |
} | |
@Override | |
protected void onProgressUpdate(Idea... idea) { | |
setProgressPercent(idea[0].getProgress()); | |
} | |
@Override | |
protected void onPostExecute(Execution exec) { | |
dialog.dismiss(); | |
new RunStartupTask().execute(new Problem(exec.getAnalytics(), exec.getNextVersionImprovements())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment