<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The world (and word) of jaymz &#187; android</title>
	<atom:link href="http://jaymz.eu/tag/android/feed/" rel="self" type="application/rss+xml" />
	<link>http://jaymz.eu</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jan 2012 21:42:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Tube Delay Refund for android released</title>
		<link>http://jaymz.eu/2010/07/tube-delay-refund-for-android-released/</link>
		<comments>http://jaymz.eu/2010/07/tube-delay-refund-for-android-released/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 02:21:46 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=489</guid>
		<description><![CDATA[Update (v1.4.0) National Rail &#38; TFL Travelcard support has been added. (August 2nd) Update (v1.3.2) Some layout rejigging has been done, defaults added and a few more menu options for resetting/prefilling. The preferences layout has also been tidied. (July 17) Updated (v1.2.0) I have updated this app to disable submission until all the station/date info [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update (v1.4.0) </strong><em>National Rail &amp; TFL Travelcard support has been added. (August 2nd)</em></p>
<p><strong>Update<em> </em>(v1.3.2) </strong><em>Some layout rejigging has been done, defaults added and a few more menu options for resetting/prefilling. The preferences layout has also been tidied. (July 17)</em></p>
<p><strong>Updated (v1.2.0) </strong><em>I have updated this app to disable submission until all the station/date info is added. I&#8217;ve also added some more labels to show what&#8217;s been entered so far. You <span style="text-decoration: underline;">must</span> make sure you&#8217;ve filled in all the preferences or else it&#8217;ll fail (Click menu&gt;preferences). (July 16)</em></p>
<p>A few days ago I was in bed trying to sleep and I suddenly thought it would be good if there was an app to submit refunds for the tube as you come out. I had in my head the idea of a timer that would count down from 15 minutes and then alert you that you were in valid refund territory.</p>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/07/131.png"><img class="aligncenter size-full wp-image-508" title="131" src="http://jaymz.eu/wp-content/uploads/2010/07/131.png" alt="" width="576" height="432" /></a></p>
<p>After I coded said timer, I pushed it live without refund submissions working. I also did a quick google to see what else there was only to discover that there was a company that released the exact same app on the iPhone about 3 months ago. Let this be a lesson that if you are about to code something as an exercise <em>don&#8217;t</em> go googling first or you&#8217;ll inevitably be put off because &#8220;whats the point&#8221;.</p>
<p style="text-align: center;">
<p>Several hours later today and it is now submitting refund applications to TFL and I get an email confirmation with the reference number. I&#8217;m very happy if incredibly tired. The app is free for now, all the others that do these on Blackberry/iOS are paid for. There doesn&#8217;t seem to be one for android yet, the guys that did the iPhone app said they where working on one way back in March or April, not quite sure what happened to it. They&#8217;re about to release the blackberry one so for now this is the <em>only</em> refund submission app on android <img src='http://jaymz.eu/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Took me basically 2 days part time.</p>
<p><a href="http://www.androidzoom.com/android_applications/travel/tube-refund_ipjg.html"><img class="aligncenter size-full wp-image-491" title="promo" src="http://jaymz.eu/wp-content/uploads/2010/07/promo.png" alt="" width="180" height="120" /></a></p>
<p>From a technical point of view this is making use of the apache http libraries to do a GET request for the TFL refund page. It parses that to grab the ASPX Viewstate variable and session cookies. Then it grabs the data from the main activity and combines that with the data stored in shared preferences for the form variables. The POST request is processed and the response parsed again to find the reference number. That&#8217;s then displayed via a Toast call. Fairly simple, having to deal with the viewstate crap was probably the most annoying part, that and debugging the actual POST.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/07/tube-delay-refund-for-android-released/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SpineMagazine.com radio player &amp; news reader for android</title>
		<link>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/</link>
		<comments>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 00:20:38 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=467</guid>
		<description><![CDATA[Quite a while back I was trying to get my head around the fairly complex ListView control for android and something I thought perfect for it was the set of radio shows over at spine magazine. I have had this code sitting around for a while and I thought why not knock out the news [...]]]></description>
			<content:encoded><![CDATA[<p>Quite a while back I was trying to get my head around the fairly complex <a href="http://developer.android.com/reference/android/widget/ListView.html">ListView</a> control for android and something I thought perfect for it was the set of radio shows over at <a href="http://www.spinemagazine.com">spine magazine</a>.</p>
<table width="100%">
<tbody>
<tr>
<td>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/07/screen-shows.png"><img class="aligncenter size-full wp-image-469" title="screen-shows" src="http://jaymz.eu/wp-content/uploads/2010/07/screen-shows.png" alt="" width="224" height="336" /></a></p>
</td>
<td>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/07/screen-news1.png"><img class="aligncenter size-full wp-image-476" title="screen-news" src="http://jaymz.eu/wp-content/uploads/2010/07/screen-news1.png" alt="" width="224" height="336" /></a></p>
</td>
</tr>
</tbody>
</table>
<p>I have had this code sitting around for a while and I thought why not knock out the news code and release it and then just continue to work on it and update it. As the saying goes, <em>release early, release often!</em> I think it&#8217;ll be easy enough to add in reviews using the same sort of code to get the data and just re-using the show layout. This particular app was a lot more complicated than the django-reference thing, so here is some of what I&#8217;ve learned&#8230; You can get this in the marketplace now. Bug reports are expected &amp; indeed welcome.</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2010/07/logo.png"><img class="aligncenter size-full wp-image-484" title="logo" src="http://jaymz.eu/wp-content/uploads/2010/07/logo.png" alt="" width="100" height="100" /></a></p>
<p><span style="color: #ff0000;"><strong>Warning! Technical crap follows.</strong></span></p>
<p>It takes a bit of time to get your head around it, essentially you subclass the <a href="http://developer.android.com/reference/android/widget/ArrayAdapter.html">ArrayAdapter</a> class with a container class to hold your list view elements. The ArrayAdapter is a templated class so you first need another class that is actually going to hold your data. This is were you&#8217;ll need to create a class for your data and then instantiate the ArrayList with this type. The code to hold my news post data is very simple:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">package</span> eu.<span class="me1">jaymz</span>.<span class="me1">spinemag</span>;
&nbsp;
<span class="co2">import android.util.Log;</span>
&nbsp;
<span class="kw2">public</span> <span class="kw2">class</span> NewsPost <span class="br0">&#123;</span>
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> title;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> description;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> date;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> author;
&nbsp;
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getTitle<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> title;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setTitle<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> title<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">title</span> = title;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getDescription<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> description;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setDescription<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> description<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">description</span> = description;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getAuthor<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> author;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setAuthor<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> author<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">author</span> = author;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getDate<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> date;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setDate<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> date<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">date</span> = date;
    <span class="br0">&#125;</span>
&nbsp;
<span class="br0">&#125;</span></pre></div></div>
<p>Then in my main activity class I cast the templated ArrayList to a NewsPost class:</p>
<p><strong><strong>ArrayList&lt;NewsPost&gt; spr_news = new ArrayList&lt;NewsPost&gt;();</strong></strong></p>
<p>With the data structure sorted I need a method in my ListView activity to actually fill in the ArrayList with data. This is very typically something along the lines of the following, here I read the JSON data from a URL, decode it and assign it to the class members, finally appending it to the ArrayList from earlier.</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">private</span> <span class="kw4">void</span> getPosts<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">try</span> <span class="br0">&#123;</span>
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AURL+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">URL</span></a> url = <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AURL+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">URL</span></a><span class="br0">&#40;</span><span class="st0">&quot;url for data&quot;</span><span class="br0">&#41;</span>;
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a> in = <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a><span class="br0">&#40;</span><span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStreamReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStreamReader</span></a><span class="br0">&#40;</span>url.<span class="me1">openStream</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> str = in.<span class="me1">readLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
            in.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
            spr_news = <span class="kw2">new</span> ArrayList&lt;NewsPost&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;
            JSONObject json = <span class="kw2">new</span> JSONObject<span class="br0">&#40;</span>str<span class="br0">&#41;</span>;
            JSONArray posts = json.<span class="me1">getJSONArray</span><span class="br0">&#40;</span><span class="st0">&quot;posts&quot;</span><span class="br0">&#41;</span>;
            <span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> x=<span class="nu0">0</span>; x &lt; posts.<span class="me1">length</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; x++<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                JSONObject post_data = <span class="kw2">new</span> JSONObject<span class="br0">&#40;</span>posts.<span class="me1">get</span><span class="br0">&#40;</span>x<span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                NewsPost post = <span class="kw2">new</span> NewsPost<span class="br0">&#40;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setTitle</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;title&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setDescription</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;description&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setDate</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;date&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setAuthor</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;author&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                spr_news.<span class="me1">add</span><span class="br0">&#40;</span>post<span class="br0">&#41;</span>;
                <span class="co1">//Log.d(&quot;NEW&quot;, &quot;added a post - &quot;+post.getTitle());</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span> <span class="kw2">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
        <span class="br0">&#125;</span>
        runOnUiThread<span class="br0">&#40;</span>setPosts<span class="br0">&#41;</span>;
    <span class="br0">&#125;</span></pre></div></div><br />
</strong></strong></p>
<p>With all the above in place the code is at the point where there is now an array full of structured data for our ArrayAdapter to show. To do this the ArrayAdapter needs subclassed to work with our earlier NewsPost classes members:</p>
<p><div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">private</span> <span class="kw2">class</span> NewsAdapter <span class="kw2">extends</span> ArrayAdapter&lt;NewsPost&gt; <span class="br0">&#123;</span>
&nbsp;
        <span class="kw2">private</span> ArrayList&lt;NewsPost&gt; items;
&nbsp;
        <span class="kw2">public</span> NewsAdapter<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Context</span></a> context, <span class="kw4">int</span> textViewResourceId, ArrayList&lt;NewsPost&gt; items<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw2">super</span><span class="br0">&#40;</span>context, textViewResourceId, items<span class="br0">&#41;</span>;
                <span class="kw2">this</span>.<span class="me1">items</span> = items;
        <span class="br0">&#125;</span>
        @Override
        <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> getView<span class="br0">&#40;</span><span class="kw4">int</span> position, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> convertView, ViewGroup parent<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> v = convertView;
                <span class="kw1">if</span> <span class="br0">&#40;</span>v == <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                    LayoutInflater vi = <span class="br0">&#40;</span>LayoutInflater<span class="br0">&#41;</span>getSystemService<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Context</span></a>.<span class="me1">LAYOUT_INFLATER_SERVICE</span><span class="br0">&#41;</span>;
                    v = vi.<span class="me1">inflate</span><span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">post</span>, <span class="kw2">null</span><span class="br0">&#41;</span>;
                <span class="br0">&#125;</span>
                NewsPost o = items.<span class="me1">get</span><span class="br0">&#40;</span>position<span class="br0">&#41;</span>;
                <span class="kw1">if</span> <span class="br0">&#40;</span>o != <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                    <span class="coMULTI">/* hmm, this looks proper ugly */</span>
                    TextView title = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_title</span><span class="br0">&#41;</span>;
                    TextView description = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_description</span><span class="br0">&#41;</span>;
                    TextView date = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_date</span><span class="br0">&#41;</span>;
                    TextView author = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_author</span><span class="br0">&#41;</span>;
&nbsp;
                    description.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getDescription</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    title.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getTitle</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    author.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getAuthor</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    date.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getDate</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                <span class="br0">&#125;</span>
                <span class="kw2">return</span> v;
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span></pre></div></div>
<p>All this code is really doing is loading the layout resource XML for our row and binding the data from the array elements members to views within the XML. Finally we need to tell the list view to update. Typically the above code has all been kicked off and ran in a thread, populating the ListView when it&#8217;s actually finished without stalling the phone itself.</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> i=<span class="nu0">0</span>;i&lt;spr_news.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;i++<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    n_adapter.<span class="me1">add</span><span class="br0">&#40;</span>spr_news.<span class="me1">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#41;</span>;
<span class="br0">&#125;</span>
m_ProgressDialog.<span class="me1">dismiss</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
n_adapter.<span class="me1">notifyDataSetChanged</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre></div></div>
<p>All the above is doing is updating the ArrayAdapter and adding our ArrayList elements to display. We then signal that the data has changed which will cause the ListView itself to update. Simple! <img src='http://jaymz.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Again, I must make the point of how verbose this all feels when I&#8217;m coding in python all day. I&#8217;m sure it needs a good refactor to now but I&#8217;m a lot more familiar with the way android works with layouts and indeed <strong>strong</strong> typing <img src='http://jaymz.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Django Reference in android market now</title>
		<link>http://jaymz.eu/2010/05/django-reference-in-android-market-now/</link>
		<comments>http://jaymz.eu/2010/05/django-reference-in-android-market-now/#comments</comments>
		<pubDate>Fri, 28 May 2010 13:36:20 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/2010/05/django-reference-in-android-market-now/</guid>
		<description><![CDATA[Very late last night, as I was enjoying &#8220;The Design &#38; Evolution of C++&#8221; (an excellent book, even if you&#8217;re not a C++ dev), I took a short break and was browsing around on the android market place and noticed there was no django app. I&#8217;ve recently picked up an HTC desire and have been [...]]]></description>
			<content:encoded><![CDATA[<p>Very late last night, as I was enjoying &#8220;<a href="http://www.amazon.co.uk/Design-Evolution-C-Bjarne-Stroustrup/dp/0201543303/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1275053838&amp;sr=8-2">The Design &amp; Evolution of C++</a>&#8221; (an excellent book, even if you&#8217;re not a C++ dev), I took a short break and was browsing around on the android market place and noticed there was no django app. I&#8217;ve recently picked up an HTC desire and have been really enjoying developing on it. I&#8217;m currently working on an application for Crooked Tongues to allow people to post &amp; comment their sneakers (don&#8217;t ask&#8230;) and I thought this would be a quick app to do and get out there. Anyone starting out developing apps will be aware that one of the hardest things is just thinking of something that isn&#8217;t already crowded out by what&#8217;s already available.</p>
<p>Basically, all I wanted was a more dedicated browser for the django docs. The content there is excellent so I quickly knocked together an application that lets you jump to major sections, set a page zoom by default and switch version easily. All in all it only took a few hours of development and thanks to the approval procedure it&#8217;s already available to install.</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2010/05/icon.png"><img class="aligncenter size-full wp-image-373" title="icon" src="http://jaymz.eu/wp-content/uploads/2010/05/icon.png" alt="" width="180" height="180" /></a></p>
<p>It&#8217;s a glorified web view but it&#8217;s a start point and its at least out there now. I&#8217;m getting a lot more used to the dev process now on android. The total code for this app weighs in around 400 lines &#8211; around 80 of those being XML to define the layout and strings used. The main activity class then manipulates the XML defined webview component to react to the (again XML) menu. My main constructor method looks like this:</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="java">@Override
    <span class="kw2">public</span> <span class="kw4">void</span> onCreate<span class="br0">&#40;</span>Bundle savedInstanceState<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        Resources res = getResources<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
        version = res.<span class="me1">getString</span><span class="br0">&#40;</span>R.<span class="me1">string</span>.<span class="me1">default_version</span><span class="br0">&#41;</span>;
        base_url = res.<span class="me1">getString</span><span class="br0">&#40;</span>R.<span class="me1">string</span>.<span class="me1">url_base</span><span class="br0">&#41;</span>;
&nbsp;
        <span class="kw2">super</span>.<span class="me1">onCreate</span><span class="br0">&#40;</span>savedInstanceState<span class="br0">&#41;</span>;
        setContentView<span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">main</span><span class="br0">&#41;</span>;
        webview = <span class="br0">&#40;</span>WebView<span class="br0">&#41;</span> findViewById<span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">webview</span><span class="br0">&#41;</span>;
&nbsp;
        webview.<span class="me1">getSettings</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">setJavaScriptEnabled</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span>;
        webview.<span class="me1">setWebViewClient</span><span class="br0">&#40;</span><span class="kw2">new</span> DjangoWebClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
&nbsp;
        <span class="kw2">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> zc = webview.<span class="me1">getZoomControls</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
        FrameLayout mContentView = <span class="br0">&#40;</span>FrameLayout<span class="br0">&#41;</span> getWindow<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getDecorView</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">findViewById</span><span class="br0">&#40;</span>android.<span class="me1">R</span>.<span class="me1">id</span>.<span class="me1">content</span><span class="br0">&#41;</span>;
        mContentView.<span class="me1">addView</span><span class="br0">&#40;</span>zc, ZOOM_PARAMS<span class="br0">&#41;</span>;
        zc.<span class="me1">setVisibility</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a>.<span class="me1">GONE</span><span class="br0">&#41;</span>;
&nbsp;
        setZoom<span class="br0">&#40;</span><span class="br0">&#41;</span>;
        loadDocs<span class="br0">&#40;</span><span class="br0">&#41;</span>;
    <span class="br0">&#125;</span></pre></div></div>
<p>The remainder of the methods are basically just reacting to the menu choices and directing the webview url appropriately. All in all quite simple.</p>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/05/release.png"><img class="aligncenter size-full wp-image-377" title="release" src="http://jaymz.eu/wp-content/uploads/2010/05/release.png" alt="" width="560" height="336" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/05/django-reference-in-android-market-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crooked Tongues TIA android app &#8211; Week 1</title>
		<link>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/</link>
		<comments>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/#comments</comments>
		<pubDate>Sun, 16 May 2010 23:22:14 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=346</guid>
		<description><![CDATA[I recently picked up an HTC desire and have been loving android as a platform. I&#8217;m not entirely sure why I didn&#8217;t go for android to begin with (apart from doing my friend Spangsberg a favour by buying out his iPhone contract before he left the country). I dabbled a little with objective C but [...]]]></description>
			<content:encoded><![CDATA[<p>I recently picked up an HTC desire and have been loving android as a platform. I&#8217;m not entirely sure why I didn&#8217;t go for android to begin with (apart from doing my friend Spangsberg a favour by buying out his iPhone contract before he left the country). I dabbled a little with objective C but not owning a full on mac for dev&#8217;ing put me off spending a significant time at home coding for the device. That and it seemed like a lot of work to get going (probably because I use Linux almost all day so am not used to the Mac toolchain).</p>
<p>Working with android on linux has been a total pleasure. Mostly. I&#8217;m still getting re-used to the verbosity of java compared to my day-to-day python but the experiance has been a good one so far. I&#8217;ve basically been learning by looking at the sample apps supplied combined with a lot of googling and reading of android dev forums. There is a real wealth of documentation out there and there&#8217;s an absolute ton of general java code to solve most problems. This is where I&#8217;m at about a week into it (spending a couple of hours every few days on it).</p>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/05/tia-updated.png"><img class="aligncenter size-full wp-image-347" title="tia-updated" src="http://jaymz.eu/wp-content/uploads/2010/05/tia-updated.png" alt="" width="448" height="336" /></a></p>
<p>The HTTP posts are working now as is uploading a camera shot, you can store user/passwords and then it&#8217;ll do the form posts with that data. For now I have it just &#8220;logging&#8221; in to a dummy setup on my own server &#8211; that side is just some PHP for now. The real backend runs python (django), for now its just easier to run that data through some PHP on my blog server. The data for the views comes via a JSON array, that data is served up via python and is essentially just a REST interface to the TIA area. I&#8217;m mainly concentrating on just learning my way around the SDK but already I&#8217;m seeing that theres a lot of power in combining the android platform with django (and maybe django-pistons on top) to create rather powerful connected mobile apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

