Know thy code

1,300 views

Published on

How to build bet

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,300
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Apologize
  •  Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow. Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android. The repo command is an executable Python script that you can put anywhere in your path
  • Know thy code

    1. 1. Know thy code<br />Framework<br />
    2. 2. Know thy code ???.*<br />What we wont know after this talk<br />Code review secrets <br />Know my code <br />What we will learn from it ( Hopefully )<br />How to make better use of framework source<br />How to make new components from the framework<br />Framework<br />
    3. 3. Android – Open Source<br /> Android has been available under a free software/open source license since October, 21 2008<br />Google published the entire source code (including network and telephony stacks) under an Apache License.<br />
    4. 4. Android – Open Source<br />Source available at source.android.com.<br />Source is a bunch of git projects.<br />Google built repo on top of git.<br />Souce is ~3GB , needs ~10GB to build.<br />Currently only builds on Linux and Mac<br />
    5. 5. What code will we be seeing<br />
    6. 6. Framework source in eclipse<br />Source code from major release-specific branches can be downloaded like this:<br />http://android.git.kernel.org/?p=platform/frameworks/base.git;a=snapshot;h=refs/heads/froyo;sf=tgz<br />You can get other versions by changing the branch name (froyo) in the link above (to donut, gingerbread, etc.)<br />Links : https://bitly.com/bundles/rvyas/1<br />
    7. 7. Framework source in eclipse<br />Extract the android folder from <br /><tarball>/core/java/ <br />into <br />android-sdk/platforms/<platform version>/sources/<br />Make sure the platform-version is the same as the android version of the tarball.<br />Refresh project in eclipse <br />To test press Alt + Shift + T to check if you can view the activity class <br />Source : http://kmansoft.wordpress.com/2011/01/27/android-sources-for-debugging/<br />
    8. 8.
    9. 9. Alternate “cloud” source viewer<br />Chrome extension : bit.ly/andsrcchrome<br /> Adds an 'ad' command to the Chrome Omnibox<br />
    10. 10. Alternate “cloud” source viewer<br />
    11. 11. Getting hands dirty<br />
    12. 12. Getting hands dirty<br />publicclassSeekBarextendsAbsSeekBar<br />publicabstractclassAbsSeekBarextendsProgressBar<br />mThumbOffset= thumb.getIntrinsicWidth() / 2;<br />setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);<br />setThumbPos(w, thumb, scale, 0);<br />Modified code : http://bit.ly/andvsb<br />
    13. 13. Getting hands dirty<br />Story : HTTP Requests <br />
    14. 14. Getting hands dirty<br />publicabstractclassAsyncTask<Params, Progress, Result> {<br />privatestaticfinal String LOG_TAG = "AsyncTask";<br />privatestaticfinalintCORE_POOL_SIZE = 5;<br />privatestaticfinalintMAXIMUM_POOL_SIZE = 128;<br />privatestaticfinalintKEEP_ALIVE = 10;<br />privatestaticfinalBlockingQueue<Runnable> sWorkQueue =<br />newLinkedBlockingQueue<Runnable>(10);<br />privatestaticfinalThreadFactorysThreadFactory = newThreadFactory() {<br />privatefinalAtomicIntegermCount = newAtomicInteger(1);<br />public Thread newThread(Runnable r) {<br />returnnew Thread(r, "AsyncTask #" + mCount.getAndIncrement());<br /> }<br /> };<br />
    15. 15. Performance examples<br />publicclassSQLiteDatabaseextendsSQLiteClosable<br />Android implements locking in SQLiteDatabase<br />- No point trying to hit the database from multiple threads<br />- On the positive you don’t need to synchronize your requests.<br />
    16. 16. Questions?<br />Thank you.<br />

    ×