<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Haven&#039;t decided on title</title>
	<atom:link href="http://cuu508.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cuu508.wordpress.com</link>
	<description>No tagline either!</description>
	<lastBuildDate>Thu, 26 Jan 2012 10:15:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cuu508.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Haven&#039;t decided on title</title>
		<link>http://cuu508.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cuu508.wordpress.com/osd.xml" title="Haven&#039;t decided on title" />
	<atom:link rel='hub' href='http://cuu508.wordpress.com/?pushpress=hub'/>
		<item>
		<title>CSN jautājumi 1.2</title>
		<link>http://cuu508.wordpress.com/2012/01/22/csn-jautajumi-1-2/</link>
		<comments>http://cuu508.wordpress.com/2012/01/22/csn-jautajumi-1-2/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 14:48:42 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=424</guid>
		<description><![CDATA[New version up, time to reflect on some of the more interesting aspects of its development. Changelog is short and sweet: Exam mode Interface language switch in menu The Exam Mode doesn&#8217;t sound like that much of a deal, but it took quite a bit of development effort. I had to rethink navigation, make the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=424&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="https://market.android.com/details?id=lv.monkeyseemonkeydo.satiksmesnoteikumi">New version up</a>, time to reflect on some of the more interesting aspects of its development.</p>
<p>Changelog is short and sweet:</p>
<ul>
<li>Exam mode</li>
<li>Interface language switch in menu</li>
</ul>
<p>The Exam Mode doesn&#8217;t sound like that much of a deal, but it took quite a bit of development effort. I had to rethink navigation, make the main activity stateful, and add &#8220;Exams&#8221; section in statistics screen.</p>
<h4>Navigation changes</h4>
<p>In the earlier versions the navigation model was rather simple. There was an &#8220;infinite&#8221; deck of questions (in my mental model and in code I call them &#8220;cards&#8221;, and they are implemented as fragments) that one can scroll through. The extra functions were stuffed in options menu. Now, with the exam mode there are a few problems: </p>
<ul>
<li>Need to make clear when we&#8217;re in &#8220;Training&#8221; mode and when in the &#8220;Exam&#8221; mode.</li>
<li>When in exam mode, need to display exam progress (number of questions answered, elapsed time)</li>
<li>When user completes exam, need to show exam results and allow to review cards with mistakes</li>
</ul>
<p>As for the exam progress, I came up with what I thought was great idea: when user swipes through exam cards, show a centered translucent window with progress information. Here&#8217;s how it looked:</p>
<span style="text-align:center; display: block;"><a href="http://cuu508.wordpress.com/2012/01/22/csn-jautajumi-1-2/"><img src="http://img.youtube.com/vi/jufK9LMU8iM/2.jpg" alt="" /></a></span>
<p>The spinning strip of numbers was a custom widget that was fun to build. Ultimately I ended up using a different method for showing exam progress, and this one was dropped from codebase.</p>
<p>As for exam results, I had an idea of having a new type of &#8220;card&#8221; that displays exam results instead of question and answers. So the decks of cards could look like this, training mode:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/1-infinite-strip.png"><img src="http://cuu508.files.wordpress.com/2012/01/1-infinite-strip.png?w=300&#038;h=52" alt="" title="1-infinite-strip" width="300" height="52" class="alignnone size-medium wp-image-425" /></a></p>
<p>And exam mode:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/2-finite-strip.png"><img src="http://cuu508.files.wordpress.com/2012/01/2-finite-strip.png?w=300&#038;h=49" alt="" title="2-finite-strip" width="300" height="49" class="alignnone size-medium wp-image-426" /></a></p>
<p>When user completes exam, we should allow reviewing questions, for the educational effect. At least this is how I used the official online exam webapp: complete exam, then look at every question again, memorize my reasoning that lead to answer, and memorize whether that reasoning was correct or not.</p>
<p>Instead of looking at all answers, some might want to look just at the wrong answers, so my app should allow for that. So I stretched my &#8220;deck of cards&#8221; metaphor further:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/3-finite-strip-plus.png"><img src="http://cuu508.files.wordpress.com/2012/01/3-finite-strip-plus.png?w=300&#038;h=49" alt="" title="3-finite-strip-plus" width="300" height="49" class="alignnone size-medium wp-image-427" /></a></p>
<p>I actually had this implemented, but as with the exam progress overlay window, this didn&#8217;t make it into the app. Although the navigation model was perfectly clear in my head, I was worried it wouldn&#8217;t make such perfect sense to others.</p>
<h4>Actionbar</h4>
<p>The need to clearly indicate training and exam modes was what ultimately lead me to introducing actionbar in the interface. That, and then-recently launched <a href="http://developer.android.com/design/index.html">Android Design</a> site, which established actionbar as a standard component of typical Android app. </p>
<p>I had considered adding actionbar before, but was reluctant to do so, because actionbar takes vertical screen space, and I was already struggling to fit some of the more text-heavy questions into available space. Making things vertically scrollable of course is the easy way out. Anyhow, I set out to try add actionbar and still fit everything into the screen.</p>
<p>I picked up the <a href="http://beta.abs.io/">beta version</a> of <a href="http://actionbarsherlock.com/">ActionBarSherlock</a> and got busy. Having actionbar opened new avenues of UX. Here&#8217;s the custom widget that shows exam progress:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/4-progress.png"><img src="http://cuu508.files.wordpress.com/2012/01/4-progress.png?w=300&#038;h=228" alt="" title="4-progress" width="300" height="228" class="alignnone size-medium wp-image-428" /></a></p>
<p>Once the exam is over, there&#8217;s an &#8220;lightbulb&#8221; action item that cycles through the red cards:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/5-bulb.png"><img src="http://cuu508.files.wordpress.com/2012/01/5-bulb.png?w=180&#038;h=300" alt="" title="5-bulb" width="180" height="300" class="alignnone size-medium wp-image-429" /></a></p>
<p>ActionBarSherlock comes with tab support, perfect fit for the statistics screen:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/2.png"><img src="http://cuu508.files.wordpress.com/2012/01/2.png?w=180&#038;h=300" alt="" title="2" width="180" height="300" class="alignnone size-medium wp-image-435" /></a></p>
<h4>Fitting everything</h4>
<p>The questions have varying amount of content:</p>
<ul>
<li>Some have illustrations, some do not</li>
<li>Each question has 2-5 answer variants. Each variant could be as short as &#8220;Yes&#8221; or &#8220;No&#8221;, or it could take a couple sentences</li>
<li>Questions and answers in Russian take considerably more screen space. It seems words in Russian are just longer on average</li>
</ul>
<p>For the cards, I have my &#8220;ideal&#8221; layout with nice, readable font sizes, margins, and equal amounts of vertical space devoted to each answer. If I cannot fit content in the screen, I&#8217;m willing to gradually give these up:</p>
<ul>
<li>Allow answers to have different screen heights. This is for situations where one answer could fit in, for example, two lines of text, and another answer needs three lines. Give just enough space for each one. Doesn&#8217;t look as neat as equal heights, but oh well</li>
<li>Question block has defined certain minimum height. If the content still doesn&#8217;t fit, remove that minimum height requirement</li>
<li>Last resort&#8211;drop down on font sizes and try everything again</li>
</ul>
<p>I wrote a crazy-messy-looking &#8220;constraints solver&#8221; that implements this strategy. And it works, every screen eventually kinda fits, even if the font sizes have to be dropped down significantly:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/6-squeeze.png"><img src="http://cuu508.files.wordpress.com/2012/01/6-squeeze.png?w=200&#038;h=300" alt="" title="6-squeeze" width="200" height="300" class="alignnone size-medium wp-image-430" /></a></p>
<p>Another nice tweak I did, is this: if there are 4+ answers, and all are really short, display them in two columns:</p>
<p><a href="http://cuu508.files.wordpress.com/2012/01/7-columns.png"><img src="http://cuu508.files.wordpress.com/2012/01/7-columns.png?w=179&#038;h=300" alt="" title="7-columns" width="179" height="300" class="alignnone size-medium wp-image-431" /></a></p>
<h4>Making the main activity stateful</h4>
<p>Before there was exam mode, the main activity could get away without keeping any state information&#8211;except for statistics kept in sqlite database. If user leaves the app, and Android system kills the app, and user comes back again, it&#8217;s OK to start a brand new deck of cards. It isn&#8217;t quite so for exam. If I&#8217;m midway of an exam, then take and incoming call, and upon returning to app, the exam state is gone&#8211;I&#8217;d be greatly disappointed. So I made my activity save its state in <code>onSaveInstanceState()</code>, and then restore it in <code>onCreate()</code>. To make this process clean and easy, I implemented the <a href="http://developer.android.com/reference/android/os/Parcelable.html">Parcelable</a> interface for some of my data objects.  </p>
<p>In the closing, I thought it would be interesting to compare LOC of <a href="http://cuu508.wordpress.com/2011/05/04/may-3-may-4/">an early version</a> which had just two short .java files, and the current version. Then:</p>
<p><pre class="brush: bash;">
$ find . -name *.java | grep -v R\.java | xargs cat | wc -l
159
</pre></p>
<p>And now:</p>
<p><pre class="brush: bash;">
$ find . -name *.java | grep -v R\.java | xargs cat | wc -l
2398
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=424&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2012/01/22/csn-jautajumi-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/1-infinite-strip.png?w=300" medium="image">
			<media:title type="html">1-infinite-strip</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/2-finite-strip.png?w=300" medium="image">
			<media:title type="html">2-finite-strip</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/3-finite-strip-plus.png?w=300" medium="image">
			<media:title type="html">3-finite-strip-plus</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/4-progress.png?w=300" medium="image">
			<media:title type="html">4-progress</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/5-bulb.png?w=180" medium="image">
			<media:title type="html">5-bulb</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/2.png?w=180" medium="image">
			<media:title type="html">2</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/6-squeeze.png?w=200" medium="image">
			<media:title type="html">6-squeeze</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2012/01/7-columns.png?w=179" medium="image">
			<media:title type="html">7-columns</media:title>
		</media:content>
	</item>
		<item>
		<title>CSN jautājumi 1.1</title>
		<link>http://cuu508.wordpress.com/2011/12/28/csn-jautajumi-1-1/</link>
		<comments>http://cuu508.wordpress.com/2011/12/28/csn-jautajumi-1-1/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 13:10:43 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=413</guid>
		<description><![CDATA[New version up! I&#8217;ll share some technical notes here. Mobile web dev, PhoneGap, jQuery Mobile and XUI One feature that got requested was to include a reference of driving rules within the app. The reference is available on internet (i.e. I don&#8217;t have to scan books), as a long formatted HTML document. Formatting is bold, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=413&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="https://market.android.com/details?id=lv.monkeyseemonkeydo.satiksmesnoteikumi">New version up</a>! I&#8217;ll share some technical notes here.</p>
<p><a href="http://cuu508.files.wordpress.com/2011/12/splash-lv.png"><img src="http://cuu508.files.wordpress.com/2011/12/splash-lv.png?w=180&#038;h=300" alt="" title="Splash screen in the new version" width="180" height="300" class="alignnone size-medium wp-image-416" /></a></p>
<h4>Mobile web dev, PhoneGap, jQuery Mobile and XUI</h4>
<p>One feature that got requested was to include a reference of driving rules within the app. The reference is available on internet (i.e. I don&#8217;t have to scan books), as a long formatted HTML document. Formatting is bold, italic, font sizes, superscripts. For the mobile, it makes sense to keep format in HTML and use WebView to display it. But one long page is not easy to get around. So&#8230;</p>
<p>First, got python script running that splits the page in subpages, it uses both BeautifulSoup and regexps, whichever is easier in each case. It generates output with Mako templates.</p>
<p>Next, bundle the static HTML, JS and CSS in the app with PhoneGap. But, umm, phonegap.jar is big (158KB although ProGuard would probably shave some parts off). And phonegap.js is big as well at 146KB. I&#8217;m developing for mobile, I&#8217;m concerned with file sizes, kilobytes count! Scratch that, <em>bytes count!</em></p>
<p>So I got rid of phonegap, as I didn&#8217;t really have use all the cool integration features, I just needed a WebView that loads local static content.</p>
<p>Next I stole some generic style rules from jQuery Mobile. Next I integrated the whole jQuery Mobile, which drags in jQuery itself too. Just to rip them out soon after. Because, again, for the little features that I needed (showing/hiding elements, handling onclick) this was definitely an overkill, dragging along IE compatibility stuff and everything. Next I picked up <b>xui.js</b>. Mostly because I was amused with the name and its meaning in Russian, but also because on the homepage it was described as being &#8220;super micro tiny&#8221;. At 10KB, I thought, it wasn&#8217;t all that  super-micro-tiny. But it&#8217;s OK, and the library packs a (relatively) lot in those 10KB. </p>
<p><a href="http://cuu508.files.wordpress.com/2011/12/r1.png"><img src="http://cuu508.files.wordpress.com/2011/12/r1.png?w=300&#038;h=250" alt="" title="r1" width="300" height="250" class="alignnone size-medium wp-image-417" /></a></p>
<p>Yeah, and browsers these days. I&#8217;ve been out of the loop for some time, and look now, animations in CSS, gradients in CSS, nice nice nice.</p>
<h4>The other things</h4>
<p>Manipulating messy HTML and getting the taste of mobile <em>web</em> development was really the most interesting part, but there were few others.</p>
<p>Did the translation to Russian. Russian texts on average seem to be longer than Latvian so had to do some conditional font size tweaking. Also, they take twice the space on disk, because each character is two bytes in UTF-8! sqlite file with Latvian questions is 270KB, Russian version is 542KB for approximately the same number of questions. When compressed the difference goes down to about 30%. </p>
<p>I&#8217;ve fixed some bugs (one was to do with picture sizing on XHDPI devices like Galaxy Nexus. I want Galaxy Nexus. I want many things.), and am aware of some bugs still remaining. </p>
<p>In closing, an unrelated comment about the Go language! I haven&#8217;t written a single line of Go yet, but from the samples I&#8217;ve seen and articles I&#8217;ve read it looks like a sweet language. Low-level enough to be able to do interesting things fast&#8211;think data structures, pointers (I&#8217;m obsessed with optimizations if you haven&#8217;t noticed by now), and still <em>feel</em> reasonably high-level, readable and concise. I don&#8217;t have an immediate application for it, I however have a small hope that in the next IO Google annouces Go as supported on Android and releases SDK and everyone gets crazy writing impressively performant apps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/413/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=413&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/12/28/csn-jautajumi-1-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/12/splash-lv.png?w=180" medium="image">
			<media:title type="html">Splash screen in the new version</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/12/r1.png?w=300" medium="image">
			<media:title type="html">r1</media:title>
		</media:content>
	</item>
		<item>
		<title>CSN jautājumi</title>
		<link>http://cuu508.wordpress.com/2011/12/14/csn-jautajumi/</link>
		<comments>http://cuu508.wordpress.com/2011/12/14/csn-jautajumi/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 12:26:26 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=401</guid>
		<description><![CDATA[Back in spring-summer when I was studying for motorcycle licence, I put together an app to try exam questions with. It was super-simple, and took about one-two days worh of work. Python script scraped exam questions and illustrations from the official, HTML-driven test site and packaged them up neatly in SQLite database. The database (about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=401&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back in spring-summer when I was studying for motorcycle licence, I put together <a href="http://cuu508.wordpress.com/2011/05/04/may-3-may-4/">an app to try exam questions with</a>. It was super-simple, and took about one-two days worh of work. Python script scraped exam questions and illustrations  from the official, <a href="http://csnt.csdd.lv">HTML-driven test site</a> and packaged them up neatly in SQLite database. The database (about 3MB) would be distributed with the app. The most interesting aspect was that pictures were encoded in WebP format to get the APK size down. Android doesn&#8217;t have built-in support for WebP until ICS, so I had to get my hands dirty with NDK and JNI.</p>
<p>So that was that. A really bare-bones app, but a fun weekend project. Now I&#8217;ve got another fun weekend project to share! The same idea and codebase fixed up to look better, and work better! <a href="https://market.android.com/details?id=lv.monkeyseemonkeydo.satiksmesnoteikumi">Here it is on Android Market</a>.</p>
<p><a href="http://cuu508.files.wordpress.com/2011/12/shot1.png"><img src="http://cuu508.files.wordpress.com/2011/12/shot1.png?w=180&#038;h=300" alt="" title="Screenshot of &quot;CSN jautājumi&quot;" width="180" height="300" class="alignnone size-medium wp-image-402" /></a></p>
<p>The notable changes:</p>
<ul>
<li>I&#8217;m still no artist/designer, but I think this one looks a bit better than the previous version</li>
<li>I&#8217;m using newer version of libwebp, and the JNI bindings that are supplied with it. Byte array to Bitmap conversion in Java land is a bit more efficient too. <a href="http://stackoverflow.com/a/8422707/5821">Details here</a></li>
<li>Move through question &#8220;cards&#8221; with swipes. I&#8217;m using ViewPager for this and I have to admit I&#8217;ve had a pleasant experience with it. Each question screen is a self-contained fragment. I wrote adapter that instantiates the fragments, and ViewPager takes care of the rest&#8211;creating new fragments when they are about to become visible, destroying fragments when they move further off-screen</li>
<li>Encoded WebP pictures are not in SQLite database any more but in separate file now. The reason is this: A SQLite database bundled with the app (in <code>/assets/</code> or in <code>/res/raw</code>) cannot be used, even if read-only, from these locations. It first has to be copied to internal or external storage. By storing pictures separately, I can keep the database size low (200KB or so), and waste less space with the duplicate copy</li>
</ul>
<p>Cool stuff, in other news my car has engine knock. Android development is enjoyable once you learn the ropes, but now when I think about it, it would be so so insanely cool if I had the necessary expertise to work on engines of motor vehicles. Yeah, well THAT would be something!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/401/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=401&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/12/14/csn-jautajumi/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/12/shot1.png?w=180" medium="image">
			<media:title type="html">Screenshot of &#34;CSN jautājumi&#34;</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello Django</title>
		<link>http://cuu508.wordpress.com/2011/11/22/hello-django/</link>
		<comments>http://cuu508.wordpress.com/2011/11/22/hello-django/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 12:58:26 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=394</guid>
		<description><![CDATA[After long time with Android, I&#8217;m doing some part-time web development again, this time with Django. Being Django noob, I&#8217;m &#8220;OMG&#8221; about the vastness of the ecosystem around it. Some pointers and gotchas I&#8217;ve encountered in past couple days: Django Best Practices document, and linked resources, e.g. Django Coding Style. This lead me to Rearranging [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=394&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After long time with Android, I&#8217;m doing some part-time web development again, this time with Django. Being Django noob, I&#8217;m &#8220;OMG&#8221; about the vastness of the ecosystem around it. Some pointers and gotchas I&#8217;ve encountered in past couple days:</p>
<ul>
<li><a href="http://lincolnloop.com/django-best-practices/">Django Best Practices</a> document, and linked resources, e.g. Django <a href="https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/">Coding Style</a>. This lead me to
<ul>
<li>Rearranging and renaming my templates</li>
<li>Splitting up my <code>urls.py</code> file</li>
<li>Getting I18N to work early. <code>LOCALE_PATHS</code> must be set in <code>settings.py</code>!</li>
<li>Moving my stuff into an virtualenv</li>
</ul>
<p>Also reassured some things I had done were right to do:</p>
<ul>
<li>Start populating <code>DEVELOP.txt</code> and <code>README.txt</code> early on</li>
<li>Install requirements with <code>pip</code> from <code>requirements.txt</code>. My app doesn&#8217;t have <code>setup.py</code> yet, and it isn&#8217;t managed by Silver Lining, I&#8217;ll think about deployment options when it&#8217;s closer to being somewhat ready</li>
</ul>
</li>
<li>
    There was a bit of mess with static files. I&#8217;m using <a href="https://docs.djangoproject.com/en/dev/howto/static-files/">django.contrib.staticfiles</a>, and my <code>STATIC_ROOT</code> and <code>STATICFILES_DIRS</code> variables are set like <a href="http://stackoverflow.com/q/6397194/5821">here</a> (except I have &#8220;whatever&#8221; instead of &#8220;bla&#8221; in <code>STATIC_ROOT</code> and this path doesn&#8217;t have to exist by the way).
</li>
<li>I&#8217;m playing with <a href="https://www.django-cms.org/">django-cms</a>. Some discoveries:
<ul>
<li>CMS toolbar didn&#8217;t show up in my templates, turns out had to add <code>{{ cms_toolbar }}</code> tag in templates.
<li><a href="http://south.aeracode.org/">South</a>, the intelligent schema and data migrations thing seems nice. But it broke my tests, I had to add <code>SOUTH_TESTS_MIGRATE = False</code> in <code>settings.py</code> to fix this</li>
<li><a href="https://github.com/ojii/django-sekizai">Sekizai</a> is a neat useful library. It&#8217;s used in django-cms for handling css and js imports in templates
    </ul>
</li>
<li>When I run tests with <code>./manage.py test</code> it appears all the included tests for Django and all of the things in my <code>INSTALLED_APPS</code> are run. Signifcant portion of them fail, and that&#8217;s apparently normal. For example, Sekizai ships with tests but with no templates that the tests use&#8211;in my setup these tests have no chance to succeed. So apparently I should only test my stuff, like so: <code>./manage.py test my_cool_app my_other_cool_app ...</code></li>
<li>I&#8217;m developing in Eclipse, with PyDev plugin. PyDev has special project type &#8220;Django project&#8221;. With that set up, I can run <code>manage.py</code> commands and development server from within Eclipse. That&#8217;s cool, but I&#8217;m so used to console&#8230;
</li>
<li>Overall I&#8217;m impressed by readability of the code. When facing a problem, it&#8217;s sometimes more productive to view .py source than search on internets</li>
<li>That&#8217;s it for now, but there&#8217;s lot more to come, because, <a href="https://code.djangoproject.com/wiki/DjangoResources">LOOK AT THIS</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/394/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/394/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/394/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=394&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/11/22/hello-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>
	</item>
		<item>
		<title>LockingHorizontalScrollView update</title>
		<link>http://cuu508.wordpress.com/2011/09/14/horizontalscrollview-update/</link>
		<comments>http://cuu508.wordpress.com/2011/09/14/horizontalscrollview-update/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 18:16:30 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=384</guid>
		<description><![CDATA[First, good news everyone, Google has released ViewPager widget. Check it out! I&#8217;ve done some small tweaks to my LockingHorizontalScrollView as well: Fixed the bug where short and slow scroll wouldn&#8217;t register as fling Added getPosition() and setPosition(int position) calls that let you get/set &#8220;screen&#8221; currently visible Added setInsensitiveEdges(boolean value) method. After calling setInsensitiveEdges(true) the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=384&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First, good news everyone, Google has released <a href="http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html">ViewPager</a> widget. Check it out!</p>
<p>I&#8217;ve done some small tweaks to my <code>LockingHorizontalScrollView</code> as well:</p>
<ul>
<li>Fixed the bug where short and slow scroll wouldn&#8217;t register as fling</li>
<li>Added <code>getPosition()</code> and <code>setPosition(int position)</code> calls that let you get/set &#8220;screen&#8221; currently visible
</li>
<li>Added <code>setInsensitiveEdges(boolean value)</code> method. After calling <code>setInsensitiveEdges(true)</code> the touch events close to left and right sides of widget won&#8217;t be considered when detecting scrolls and flings. This works around the problem when user has hand wrapped around phone and touches sides of touchscreen by accident, and the widget jumps!
</li>
<li>Updated example application and .apk file.
</li>
<li>New demo video!
</li>
</ul>
<span style="text-align:center; display: block;"><a href="http://cuu508.wordpress.com/2011/09/14/horizontalscrollview-update/"><img src="http://img.youtube.com/vi/qxhYGAC1X5s/2.jpg" alt="" /></a></span>
<p><a href="https://bitbucket.org/cuu508/friendlygallery">Code lives here in bitbucket</a>. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/384/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=384&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/09/14/horizontalscrollview-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>
	</item>
		<item>
		<title>***</title>
		<link>http://cuu508.wordpress.com/2011/09/01/377/</link>
		<comments>http://cuu508.wordpress.com/2011/09/01/377/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 16:25:44 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=377</guid>
		<description><![CDATA[Yeeeah, and so, having finished Deus Ex 3 late yesterday, I&#8217;m back to normal life and work. Those guards sure got confused when I was sprinting through them with invisibility cloak on. Likewise, dynamic languages sure can confuse hell out of poor unsuspecting programmer: quick recap of last 3 hours of adventures: Let&#8217;s set up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=377&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yeeeah, and so, having finished Deus Ex 3 late yesterday, I&#8217;m back to normal life and work. </p>
<p>Those guards sure got confused when I was sprinting through them with invisibility cloak on. Likewise, dynamic languages sure can confuse hell out of poor unsuspecting programmer: quick recap of last 3 hours of adventures:</p>
<ul>
<li>Let&#8217;s set up development environment for my Pylons app on Fedora 15, Python2.7! Deployment of this app is managed by SilverLining, which has strong ties with Ubuntu and Py2.6&#8211;so I&#8217;m in unexplored teritory, exciting!</li>
<li>Replace Py 2.6 references in SilverLining to 2.7</li>
<li>Install my app: some weird errors mentioning <code>sys.prefix</code> but app seems to work overall</li>
<li>Let&#8217;s run tests: nose complains that there&#8217;s no such thing as &#8220;<code>--with-pylons</code>&#8221; flag</li>
<li>That&#8217;s because I cannot do &#8220;<code>import pylons</code>&#8220;</li>
<li>That&#8217;s because I cannot do &#8220;<code>import paste.registry</code>&#8220;</li>
<li>That&#8217;s because for some reason Paste didn&#8217;t get installed in <code>lib/python</code> but in <code>lib/python2.7/site-packages</code></li>
<li>Research virtualenv</li>
<li>Research sitecustomize.py</li>
<li>Where does <code>sys.prefix</code> come from?</li>
<li>Dig through easy_install, setuptools</li>
<li>Dig through distutils, discover distutils.cfg, discover <code>Distribution.parse_config_files()</code>. Smell magic</li>
<li>Discover <code>setuptools.dist.Distribution</code> but no magic there</li>
<li>Discover code in <code>distutils/__init__.py</code> that patches Distribution class at runtime (this is the confusing dynamic bit)</li>
<li>Discover code in SilverLining that patches <code>distutils/__init__.py</code> </li>
<li>Finally understand what&#8217;s going on and can fix the <code>sys.prefix</code> issue</li>
<li>Try tests again?</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/377/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=377&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/09/01/377/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>
	</item>
		<item>
		<title>Android on X86, it works</title>
		<link>http://cuu508.wordpress.com/2011/08/01/android-on-x86-it-works/</link>
		<comments>http://cuu508.wordpress.com/2011/08/01/android-on-x86-it-works/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 21:46:10 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=373</guid>
		<description><![CDATA[Android X86 project&#8211;pretty cool. Tried some of my apps on their eeepc.iso image, and OMG OMG they kind-of worked! Tricky bits: no mouse! &#8211;disable mouse integration in Machine menu how do I install my APKs? &#8211;follow instructions on their site about setting up NAT &#38; connecting with adb portrait mode is rotated by 90 degrees&#8211;google [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=373&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.android-x86.org">Android X86 project</a>&#8211;pretty cool. Tried some of my apps on their <code>eeepc.iso</code> image, and OMG OMG they kind-of worked!</p>
<p>Tricky bits:</p>
<ul>
<li>no mouse! &#8211;disable mouse integration in Machine menu</li>
<li>how do I install my APKs? &#8211;follow instructions on their site about setting up NAT &amp; connecting with adb</li>
<li>portrait mode is rotated by 90 degrees&#8211;google &#8220;android x86 portrait&#8221; and follow instructions</li>
<li>it&#8217;s LiveCD, my stuff disappears after each reboot! They have instructions for installing on disk, but didn&#8217;t bother with that yet</li>
</ul>
<p><a href="http://cuu508.files.wordpress.com/2011/08/ekranattels-2.png"><img src="http://cuu508.files.wordpress.com/2011/08/ekranattels-2.png?w=300&#038;h=187" alt="" title="Ekranattels-2" width="300" height="187" class="alignnone size-medium wp-image-374" /></a></p>
<p>PS. Live wallpaper in the screenshot: <a href="https://market.android.com/details?id=lv.monkeyseemonkeydo.wallpaper.fall">get it here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/373/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=373&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/08/01/android-on-x86-it-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/08/ekranattels-2.png?w=300" medium="image">
			<media:title type="html">Ekranattels-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Horizontal scrolling widget based on HorizontalScrollView</title>
		<link>http://cuu508.wordpress.com/2011/07/20/horizontal-scrolling-widget-based-on-horizontalscrollview/</link>
		<comments>http://cuu508.wordpress.com/2011/07/20/horizontal-scrolling-widget-based-on-horizontalscrollview/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 22:12:47 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=365</guid>
		<description><![CDATA[Update: Google have released ViewPager, check it out! Also, I&#8217;ve done some tweaks to LockingHorizontalScrollView, here&#8217;s a post about them. The effect I&#8217;m going after is the same as in Google+ and the new Market app: Several homescreens/streams/dashboard views. One visible at a time, swipe left and right to switch between them. There is no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=365&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Google have released <a href="http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html">ViewPager</a>, check it out! Also, I&#8217;ve done some tweaks to <code>LockingHorizontalScrollView</code>, <a href="http://cuu508.wordpress.com/2011/09/14/horizontalscrollview-update/">here&#8217;s a post about them</a>.</p>
<p>The effect I&#8217;m going after is the same as in Google+ and the new Market app:</p>
<p><a href="http://cuu508.files.wordpress.com/2011/07/googleplus.png"><img src="http://cuu508.files.wordpress.com/2011/07/googleplus.png?w=300&#038;h=247" alt="" title="googleplus" width="300" height="247" class="alignnone size-medium wp-image-348" /></a></p>
<ul>
<li>Several homescreens/streams/dashboard views. One visible at a time, swipe left and right to switch between them.</li>
<li>There is no padding around each child view, they take all the space that is allocated to their parent view.</li>
<li>Switching views one-at-a-time. Don&#8217;t want flinging over 3 views at once.</li>
</ul>
<p>Turns out <code>Gallery</code> widget is not the best starting point for implementing something like this:</p>
<ul>
<li>It supports padding around each gallery item. Gallery items don&#8217;t generally take up all the horizontal space, several can be visible at the same time, next to each other.</li>
<li>When user swipes, Gallery flings, potentially over several child elements. Preventing that requires some hacky code.</li>
<li>It is adapter-based. Cannot define all the views in singe XML layout, need to create/inflate them in adapter.</li>
</ul>
<p>Then there&#8217;s <code>HorizontalScrollView</code>. It&#8217;s much simpler than Gallery so less quirks to hack around. The most prominent feature that <code>Gallery</code> has and <code>HorizontalScrollView</code> lacks, is that gallery always tries to center on one of its elements. HorizontalScrollView can be scrolled freely, and will happily  stay at any horizontal scroll offset. But this is not hard to fix. By listening in on touch events and detecting flings, I can make it smooth-scroll to the nearest screen-ful in fling&#8217;s direction. I&#8217;m saying &#8220;screen-ful&#8221; not &#8220;element&#8221; because HorizontalScrollView is a subclass of <code>FrameLayout</code> and can only have a single child view. So I&#8217;m putting a horizontal LinearLayout in there, and the child views go in that layout. The LinearLayout is slightly hacked too to set appropriate widths for its child views. </p>
<p>Here&#8217;s screencast of updated the demo application:</p>
<span style="text-align:center; display: block;"><a href="http://cuu508.wordpress.com/2011/07/20/horizontal-scrolling-widget-based-on-horizontalscrollview/"><img src="http://img.youtube.com/vi/qE2xQDZT1wk/2.jpg" alt="" /></a></span>
<p>So two classes of interest <a href="https://bitbucket.org/cuu508/friendlygallery">in the repo</a>:</p>
<ul>
<li><code>LockingHorizontalScrollView</code>. &#8220;<i>Locking</i>&#8221; as in &#8220;<i>will lock on to grid</i>&#8220;</li>
<li><code>WideLinearLayout</code>. &#8220;<i>Wide</i>&#8221; as in &#8220;<i>each child element will be asked something similar to FILL_PARENT</i>&#8220;</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/365/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=365&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/07/20/horizontal-scrolling-widget-based-on-horizontalscrollview/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/07/googleplus.png?w=300" medium="image">
			<media:title type="html">googleplus</media:title>
		</media:content>
	</item>
		<item>
		<title>Gallery widget update</title>
		<link>http://cuu508.wordpress.com/2011/07/18/gallery-widget-update/</link>
		<comments>http://cuu508.wordpress.com/2011/07/18/gallery-widget-update/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 18:51:55 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=361</guid>
		<description><![CDATA[Made some improvements to its code and put it up on bitbucket. There&#8217;s also an example app. It demonstrates that this widget has issues with ListView as child :-/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=361&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Made some improvements to its code and put it up on <a href="https://bitbucket.org/cuu508/friendlygallery">bitbucket</a>. </p>
<p>There&#8217;s also an example app. It demonstrates that this widget has issues with <code>ListView</code> as child :-/</p>
<p><a href="http://cuu508.files.wordpress.com/2011/07/friendlygalleryexample.png"><img src="http://cuu508.files.wordpress.com/2011/07/friendlygalleryexample.png?w=180&#038;h=300" alt="" title="friendlygalleryexample" width="180" height="300" class="alignnone size-medium wp-image-362" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=361&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/07/18/gallery-widget-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/07/friendlygalleryexample.png?w=180" medium="image">
			<media:title type="html">friendlygalleryexample</media:title>
		</media:content>
	</item>
		<item>
		<title>Broken Tools for Make Benefit Fun Times</title>
		<link>http://cuu508.wordpress.com/2011/07/14/broken-tools-for-make-benefit-fun-times/</link>
		<comments>http://cuu508.wordpress.com/2011/07/14/broken-tools-for-make-benefit-fun-times/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 16:54:20 +0000</pubDate>
		<dc:creator>cuu508</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://cuu508.wordpress.com/?p=355</guid>
		<description><![CDATA[[imagine a picture with a can of worms, with worms starting to spread out, here] Don&#8217;t be surprised, but the custom Gallery from yesterday, it&#8217;s buggy. I was looking at one of the bugs, my investigation involved lots of debug messages about touchscreen events in rapid succession. While scrutinizing these, I spotted a boolean variable [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=355&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>[imagine a picture with a can of worms, with worms starting to spread out, here]</p>
<p>Don&#8217;t be surprised, but the custom Gallery from yesterday, it&#8217;s buggy. </p>
<p>I was looking at one of the bugs, my investigation involved lots of debug messages about touchscreen events in rapid succession. While scrutinizing these, I spotted a boolean variable that was flipping seemingly without me assigning anything to it.</p>
<p>OK easy, I thought, apparently there&#8217;s some code assigning to it that I don&#8217;t know about. Maybe the superclass is messing with me, maybe I&#8217;ve leaked some object reference somewhere, maybe it&#8217;s threading issue. Or maybe there&#8217;s several copies of my code running, with several corresponding boolean variables.</p>
<p>So I wrapped my boolean in object that </p>
<ul>
<li>prints all reads and assignments to debug console: nobody can bypass my logging statements now</li>
<li>is threadsafe: assignments, reads and logging statements won&#8217;t get interleaved</li>
<li>doesn&#8217;t leak reference to wrapped value, but primitive Java types are pass-by-value anyway right?</li>
<li>prints its <code>hashCode</code> and timestamp of creation: gives some affirmation that I&#8217;m looking at the same object all of the time</li>
</ul>
<p>And as I was staring at the log, the value was still flipping! Two reads, with no write inbetween, were reporting different values. So my next line of thought touched on aspects of JVM, CPU, radioactivity and sanity. As usual though, explanation turned out to be simple and boring: debug log not outputting messages in chronological order. I came up with a counter variable that I would increment on every assignment, so it should only monotonically grow. Lo and behold, in the log messages it was going up and down! Quick glance at timestamps of debug messages and there was my answer, in plain sight, the order of messages was clearly not chronological.</p>
<p><a href="http://cuu508.files.wordpress.com/2011/07/logcat.png"><img src="http://cuu508.files.wordpress.com/2011/07/logcat.png?w=500&#038;h=323" alt="" title="logcat" width="500" height="323" class="alignnone size-full wp-image-356" /></a><br />
(I&#8217;ve circled some timestamps with orange, and my counter variable with red)</p>
<p>By the way, it appears that printing debug messages in terminal with <code>adb logcat</code> is fine, the messages come in order. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuu508.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuu508.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuu508.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuu508.wordpress.com&amp;blog=232242&amp;post=355&amp;subd=cuu508&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuu508.wordpress.com/2011/07/14/broken-tools-for-make-benefit-fun-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/49a5be1c12519dc592e6d1aafd8026e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuu508</media:title>
		</media:content>

		<media:content url="http://cuu508.files.wordpress.com/2011/07/logcat.png" medium="image">
			<media:title type="html">logcat</media:title>
		</media:content>
	</item>
	</channel>
</rss>
