<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>init 7</title>
	
	<link>http://www.soccio.it/michelinux</link>
	<description>a low frequentation blog about open source, free software, linux, programming, android, and other stuff you may find interesting</description>
	<lastBuildDate>Sat, 10 Dec 2011 23:19:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Init7" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="init7" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Let’s call it inspiration</title>
		<link>http://www.soccio.it/michelinux/lets-call-it-inspiration/</link>
		<comments>http://www.soccio.it/michelinux/lets-call-it-inspiration/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 23:19:59 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Canonical]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[overlay]]></category>
		<category><![CDATA[scrollbar]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=541</guid>
		<description><![CDATA[If this comes to official repositories, we could say that eventually Gnome stopped copying from MacOSX and started copying from Unity.]]></description>
			<content:encoded><![CDATA[<p>If this comes to official repositories, we could say that eventually Gnome stopped copying from MacOSX and started copying from Unity.</p>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/bNV8-evh-VY" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/lets-call-it-inspiration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox 5 landed in Ubuntu Natty</title>
		<link>http://www.soccio.it/michelinux/firefox-5-landed-in-ubuntu-natty/</link>
		<comments>http://www.soccio.it/michelinux/firefox-5-landed-in-ubuntu-natty/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 18:34:07 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox 5.0]]></category>
		<category><![CDATA[natty]]></category>
		<category><![CDATA[Natty Narwhal]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ubuntu 11.04]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=499</guid>
		<description><![CDATA[A beta version of Firefox 5 (seems a b5pre) has just landed in the natty-proposed repository. Good thing that Ubuntu decided to stay up to date with Firefox.]]></description>
			<content:encoded><![CDATA[<p>A beta version of Firefox 5 (seems a b5pre) has just landed in the natty-proposed repository. Good thing that Ubuntu decided to stay up to date with Firefox.</p>
<p><a href="http://www.soccio.it/michelinux/firefox-5-landed-in-ubuntu-natty/firefox-5-0-on-ubuntu-natty/" rel="attachment wp-att-542"><img src="http://www.soccio.it/michelinux/wp-content/uploads/2011/06/Firefox-5.0-on-Ubuntu-Natty.png" alt="" title="Firefox 5.0 on Ubuntu Natty" width="571" height="409" class="aligncenter size-full wp-image-542" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/firefox-5-landed-in-ubuntu-natty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GestureDetector to detect Long Touch, Double Tap, Scroll or other touch events in Android</title>
		<link>http://www.soccio.it/michelinux/using-gesturedetector-to-detect-long-touch-double-tap-scroll-or-other-touch-events-in-android/</link>
		<comments>http://www.soccio.it/michelinux/using-gesturedetector-to-detect-long-touch-double-tap-scroll-or-other-touch-events-in-android/#comments</comments>
		<pubDate>Mon, 16 May 2011 06:00:19 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=500</guid>
		<description><![CDATA[Most of the Android UI elements already come with some easy way to detect and handle touch events. For example have a look to the following code: TextView myTextView = &#40;TextView&#41; findViewById&#40;R.id.myTextView&#41;; myTextView.setOnLongClickListener&#40;new OnLongClickListener&#40;&#41; &#123; @Override public boolean onLongClick&#40;View v&#41; &#123; Log.i&#40;&#34;MyExample&#34;, &#34;A Long Click has been detected&#34;&#41;; return true; &#125; &#125;&#41;; When you touch <a href="http://www.soccio.it/michelinux/using-gesturedetector-to-detect-long-touch-double-tap-scroll-or-other-touch-events-in-android/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Most of the Android UI elements already come with some easy way to detect and handle touch events. For example have a look to the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">TextView myTextView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myTextView</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
myTextView.<span style="color: #006633;">setOnLongClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> OnLongClickListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onLongClick<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Log.<span style="color: #006633;">i</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MyExample&quot;</span>, <span style="color: #0000ff;">&quot;A Long Click has been detected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>When you touch the <code lang="java">myTextView</code> long enough, you will see in the logs the print <em>A Long Click has been detected</em>.<br />
In other cases, however, in which this kind of solution is not available, or doesn&#8217;t fit your needs. For example</p>
<ul>
<li>the UI element does not let you set a listener for the action you want to detect. You can&#8217;t set a double click listener for a <code>TextView</code> widget, and other elements, like the Map Overlay, can only detect a very limited set of actions;
</li>
<li>you need more information about the action, e.g. the exact position of the pointer (<em>finger</em>).</li>
</ul>
<p>In those cases the best solution is to use the <code><a href="http://developer.android.com/reference/android/view/GestureDetector.html">GestureDetector</a></code>.</p>
<p>The <code>GestureDetector</code> works a little bit differently from what you may be used to. In fact it is not listening to the actions: it is in charge of translating what a widget or another UI element sees as a generic touch event, to a more specific action. Fortunately any UI element gives you some way to handle a generic touch event.</p>
<p>Let&#8217;s see a complete example of how to put the <code>GestureDetector</code> to work within a simple Activity class.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.GestureDetector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.MotionEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.TextView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GestureDetectorExample <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> TAG <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GestureDetectorExample&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> GestureDetector mGestureDetector<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TextView mTextView<span style="color: #339933;">;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        mTextView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myTextView</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        mTextView.<span style="color: #006633;">setOnTouchListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnTouchListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTouch<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v, MotionEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> mGestureDetector.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        mGestureDetector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GestureDetector<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GestureDetector.<span style="color: #006633;">SimpleOnGestureListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onLongPress<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Long Press event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onDoubleTap<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Double Tap event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onDown<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        mGestureDetector.<span style="color: #006633;">setIsLongpressEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Let&#8217;s see now what happens in the example:</p>
<ul>
<li>a <code>TouchListener</code> is set for the <code>TextView</code>;</li>
<li>a <code>GestureDetector</code> object is instantiated, with a reference to an object which implements the <code>OnGestureListener</code> interface (we&#8217;ll come back on this later);</li>
<li>when a touch event is detected by the <code>TextView</code>, the method <code>onTouch</code> is called;</li>
<li>the method <code>onTouch</code> calls the <code>GestureDetector</code> and pass it the <code>MotionEvent</code>, an object containing the information needed by the <code>GestureDetector</code> to recognize the different touch events;</li>
<li>the <code>GestureDetector</code> uses the <code>MotionEvent</code> object to identify the touch events;</li>
<li>once identified the type of the event, the <code>GestureDetector</code> calls the appropriate method of the <code>OnGestureListener</code> (double tap, long press, etc.).</li>
</ul>
<p>It&#8217;s time to run the program and perform some long tap, or double click on the <code>TextView</code> while keeping an eye on the logs in the <strong>LogCat</strong>.</p>
<p><img src="http://www.soccio.it/michelinux/wp-content/uploads/2011/05/LogCat_GestureDetector_longpress_doubletap.png" alt="" title="Double Tap and Long Press logs in the LogCat" width="465" height="71" class="aligncenter size-full wp-image-535" /></p>
<p>A couple of notes.</p>
<ul>
<li><strong>The <code>onDown</code> method.</strong><br />
If you try to remove it you will see that the <code>onDoubleTap</code> method is not called anymore. Same if the <code>onDown</code> method returns <code>false</code>. So keep in mind that to make <code>onDoubleTap</code> work you must have a <code>onDown</code> method returning true.</li>
<li><strong><code>SimpleOnGestureListener</code> class vs <code>OnGestureListener</code> interface</strong><br />
In the example, the <code>SimpleOnGestureListener</code> class is used. It is a commodity class that implements the <code>OnGestureListener</code> interface. If you decide to implement the <code>OnGestureListener</code> interface you must implement all its methods, even you only need to handle one event. When you inherit from the <code>SimpleOnGestureListener</code>, instead, you will only override the methods you need.</li>
</ul>
<p>Let&#8217;s now see another example, this time using the <code>Overlay</code> from the <a href="http://code.google.com/android/add-ons/google-apis/reference/index.html">Google Maps API</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.GestureDetector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.MotionEvent</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.MapActivity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.MapView</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.Overlay</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GestureDetectExampleMap <span style="color: #000000; font-weight: bold;">extends</span> MapActivity <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> TAG <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GestureDetectorExampleMap&quot;</span><span style="color: #339933;">;</span>
    MapView mMapView<span style="color: #339933;">;</span>
    GestureDetector mGestureDetector<span style="color: #339933;">;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        mMapView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MapView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">MapView</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        mMapView.<span style="color: #006633;">getOverlays</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Overlay<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTouchEvent<span style="color: #009900;">&#40;</span>MotionEvent e, MapView mapView<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                mGestureDetector.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>e, mapView<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        mGestureDetector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GestureDetector<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GestureDetector.<span style="color: #006633;">SimpleOnGestureListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onLongPress<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Long Press event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onDoubleTap<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Double Tap event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onDown<span style="color: #009900;">&#40;</span>MotionEvent e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">boolean</span> isRouteDisplayed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The <code>GestureDetector</code> part is exactly the same, but in this case the <code>GestureDetector.onTouchEvent</code> is called by the map <code>Overlay</code>, and unlike a generic <code>View</code> element, there is no need to instantiate a Listener for it.<br />
A touch event will go through the following steps:</p>
<ul>
<li>the touch event triggers the <code>onTouchEvent</code> inside the <code>Overlay</code>;</li>
<li>the <code>onTouchEvent</code> of the <code>Overlay</code> calls the correspondent method of the <code>GestureDetector</code> and pass it the <code>MotionEvent</code>, an object containing the information needed by the <code>GestureDetector</code> to recognize the different touch events;</li>
<li>the <code>GestureDetector</code> uses the <code>MotionEvent</code> object to identify the touch events;</li>
<li>once identified the type of the event, the <code>GestureDetector</code> calls the appropriate method of the <code>OnGestureListener</code> (double tap, long press, etc.).</li>
</ul>
<p>For lazy people only:  <a href='http://www.soccio.it/michelinux/wp-content/uploads/2011/05/GestureDetector.zip'>download a zip file with the two examples</a>.</p>
<p>It may be useful for you to have a look to a few articles that I also consulted before writing this article:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1678493/android-maps-how-to-long-click-a-map">android maps: How to Long Click a Map?</a></li>
<li><a href="http://stackoverflow.com/questions/4522637/android-onfling-not-responding">Android onFling not responding</a></li>
<li>Some classes from the <a href="http://code.google.com/p/raveneye/source/browse/RavenGatherer/src/com/activities?r=22">raveneye project on Google Code</a>.</li>
<li>I don&#8217;t like using big libraries when I only need one specific function or behavior. If you disagree and you are working with maps and overlays, you may like to have a look at the <a href="http://code.google.com/p/mapview-overlay-manager/">mapview-overlay-manager project</a>. However I&#8217;m quite sure you won&#8217;t need extra help after this article.</li>
</ul>
<p>Feel free to comment to ask any question, correct any mistake or suggest any improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/using-gesturedetector-to-detect-long-touch-double-tap-scroll-or-other-touch-events-in-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C++</title>
		<link>http://www.soccio.it/michelinux/c/</link>
		<comments>http://www.soccio.it/michelinux/c/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 16:15:10 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[linguaggi di programmazione]]></category>
		<category><![CDATA[Stroustrup]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=483</guid>
		<description><![CDATA[Sono sempre più convinto che Bjarne Stroustrup abbia qualche disturbo associativo che gli impedisce di scrivere libri in maniera ordinata o creare linguaggi di programmazione in cui la complicazione delle operazioni più semplici sembra essere la norma più che l&#8217;eccezione.]]></description>
			<content:encoded><![CDATA[<p>Sono sempre più convinto che <a href="http://it.wikipedia.org/wiki/Bjarne_Stroustrup">Bjarne Stroustrup</a> abbia qualche disturbo associativo che gli impedisce di scrivere libri in maniera ordinata o creare linguaggi di programmazione in cui la complicazione delle operazioni più semplici sembra essere la norma più che l&#8217;eccezione.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>H.264, che confusione</title>
		<link>http://www.soccio.it/michelinux/h-264-che-confusione/</link>
		<comments>http://www.soccio.it/michelinux/h-264-che-confusione/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 08:28:13 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[cantonate]]></category>
		<category><![CDATA[codec video]]></category>
		<category><![CDATA[h264]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=479</guid>
		<description><![CDATA[Macity prende un po&#8217; di cantonate sull&#8217;H.264 quando dice che: «MPEG LA rende lo standard H.264 royalty-free» Titolo d&#8217;effetto ma vero solo in parte: non pagherà diritti e brevetti solo chi lo userà a titolo gratuito. E poi ci mancherebbe altro che se metto un video in H.264 sul mio blog (che non abbia pubblicità, <a href="http://www.soccio.it/michelinux/h-264-che-confusione/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Macity prende <a href="http://www.macitynet.it/macity/articolo/MPEG-LA-rende-lo-standard-H.264-royalty-free/aA45667">un po&#8217; di cantonate sull&#8217;H.264</a> quando dice che:</p>
<p><em>«MPEG LA rende lo standard H.264 royalty-free»</em><br />
Titolo d&#8217;effetto ma vero solo in parte: non pagherà diritti e brevetti solo chi lo userà a titolo gratuito. E poi ci mancherebbe altro che se metto un video in H.264 sul mio blog (che non abbia pubblicità, per carità di Dio!) debba anche pagare qualcuno. Pensate, a titolo d&#8217;esempio, se Tim Berners-Lee avesse deciso di dare via il Web nella stessa maniera.</p>
<p><em>«non verranno mai richieste royalties  a chi utilizzerà il codec per produrre e distribuire filmati gratuiti per l’utente finale.»</em><br />
Produrre video? H.264 viene usato solo in fase di distribuzione. Quando ci lavori sopra ci lavori sempre in formati non compressi. Se poi qualcuno si è sbagliato e ha scritto &#8220;produrre&#8221; invece di &#8220;registrare&#8221;, allora mi scuso io per non aver capito una vostra improprietà di linguaggio. E comunque mi piacerebbe trovare una telecamerina che registri in H.264 che mi venga fornita a titolo gratuito.</p>
<p>«<em>L’annuncio del consorzio conferma nell’H.264 il formato di riferimento per l’HTML5 e allontana i potenziali sostenitori dell’Ogg Theora, il formato open-source fortemente voluto da Mozilla.</em>»<br />
Il formato non è fortemente voluto da Mozilla ma anche da giganti del calibro di Google, che è poi anche il padrone di Youtube. E poi, cari amici di Macity (l&#8217;articolo l&#8217;ha scritto Mauro Notarianni) siete rimasti indietro: è da un po&#8217; che abbiamo <a href="http://www.webmproject.org/">WebM</a> il quale, nel caso non vi foste giunta voce, è qualcosa in più di un codec video. Voi continuate pure a giocherellare con le vostre dita su schermi luccicanti. Se non vi scoccia troppo, <strong>nel frattempo noi andremmo avanti</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/h-264-che-confusione/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Partita a tre</title>
		<link>http://www.soccio.it/michelinux/partita-a-tre/</link>
		<comments>http://www.soccio.it/michelinux/partita-a-tre/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 10:16:45 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[confronto]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[windows mobile 7]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=474</guid>
		<description><![CDATA[A guardare il video seguente mi viene in mente che: al diavolo le app, è il browser che conta; Windows Mobile 7 va davvero bene; Symbian non se lo caga più nessuno, tra un po&#8217; nemmeno Nokia; la partita si giocherà a tre: Linux (leggi: Android, Meego, etc.), Windows Mobile, ed Apple; se Google smette <a href="http://www.soccio.it/michelinux/partita-a-tre/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A guardare il video seguente mi viene in mente che:</p>
<ul>
<li>al diavolo le app, è il browser che conta;</li>
<li>Windows Mobile 7 va davvero bene;</li>
<li>Symbian non se lo caga più nessuno, tra un po&#8217; nemmeno Nokia;</li>
<li>la partita si giocherà a tre: Linux (leggi: Android, Meego, etc.), Windows Mobile, ed Apple;</li>
<li>se Google smette di spingere su Android, Linux farà una brutta fine anche sul mobile.</li>
</ul>
<p></p>
<p><object width="620" height="374"><param name="movie" value="http://www.youtube.com/v/zgvphQx9MY8?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/zgvphQx9MY8?version=3" type="application/x-shockwave-flash" width="620" height="374" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/partita-a-tre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone4</title>
		<link>http://www.soccio.it/michelinux/iphone4/</link>
		<comments>http://www.soccio.it/michelinux/iphone4/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:13:50 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[iPhone 4]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=470</guid>
		<description><![CDATA[Andato a cena con nuovi amici, chiedo a uno di loro come si trova col nuovo iPhone 4. Bene, mi dice. È vera tutta la faccenda dell&#8217;antenna? Sì, è vera. E la batteria come va? Peggio del 3GS. Detto questo resta da dire che l&#8217;iPhone 4 è davvero ben fatto. È bello quasi quanto il <a href="http://www.soccio.it/michelinux/iphone4/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Andato a cena con nuovi amici, chiedo a uno di loro come si trova col nuovo iPhone 4. Bene, mi dice.<br />
È vera tutta la faccenda dell&#8217;antenna? <em>Sì, è vera.</em><br />
E la batteria come va? <em>Peggio del 3GS.</em></p>
<p>Detto questo resta da dire che l&#8217;iPhone 4 è davvero ben fatto. È bello quasi quanto il mio Nexus One.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/iphone4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stratosferico Nexus One</title>
		<link>http://www.soccio.it/michelinux/stratosferico-nexus-one/</link>
		<comments>http://www.soccio.it/michelinux/stratosferico-nexus-one/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 20:52:30 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[chicche]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[lancio]]></category>
		<category><![CDATA[launch]]></category>
		<category><![CDATA[nexus one]]></category>
		<category><![CDATA[razzo]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=468</guid>
		<description><![CDATA[C&#8217;è da dire che il primo tentativo è andato male, ma il video del secondo lancio è eccezionale. Di cosa sto parlando? Di un Nexus One montato su un razzo e fatto salire fino a otto chilometri e mezzo d&#8217;altitudine (ok, non è stratosfera, quella inizia a 12 chilometri, ma il nome ci sta tutto).]]></description>
			<content:encoded><![CDATA[<p>C&#8217;è da dire che il primo tentativo è andato male, ma il video del secondo lancio è eccezionale.</p>
<p>Di cosa sto parlando? Di <a href="http://blog.makezine.com/archive/2010/07/nexus_onearduino_smallsat_satellite.html">un Nexus One montato su un razzo</a> e fatto salire fino a otto chilometri e mezzo d&#8217;altitudine (ok, non è stratosfera, <a href="http://it.wikipedia.org/wiki/Stratosfera">quella</a> inizia a 12 chilometri, ma il nome ci sta tutto).</p>
<p><object width="620" height="490"><param name="movie" value="http://www.youtube.com/v/hQ7pUroGvFc?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hQ7pUroGvFc?version=3" type="application/x-shockwave-flash" width="620" height="490" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/stratosferico-nexus-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Answering Darek Currie</title>
		<link>http://www.soccio.it/michelinux/answering-darek-currie/</link>
		<comments>http://www.soccio.it/michelinux/answering-darek-currie/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 06:02:11 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[chicche]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=465</guid>
		<description><![CDATA[After writing an article about the Secunia report stating the Apple software has the highest number of security bugs, I have been attacked by a biologist/zoologist who now works as &#8220;Creative Technologist&#8221; (from now on I will say that my job is &#8220;Wonderful Engineer&#8220;) for an Apple specialist and authorized seller. Although the &#8220;creative&#8221; word <a href="http://www.soccio.it/michelinux/answering-darek-currie/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After writing <a href="http://www.oneitsecurity.it/22/07/2010/software-non-sicuri-ad-apple-la-medaglia-doro/">an article</a> about the Secunia report stating the Apple software has the highest number of security bugs, I have been attacked by a biologist/zoologist who now works as &#8220;<em>Creative Technologist</em>&#8221; (from now on I will say that my job is &#8220;<em>Wonderful Engineer</em>&#8220;) for an Apple specialist and authorized seller. Although the &#8220;creative&#8221; word in his job name, he states to be in the security field. I could guess that his job is to say &#8220;You don&#8217;t need anti-virus on Mac, because no criminal is caring about a platform used by only 5% of active computer population&#8221;. Or, since he is an active Christian, probably his job consists in praying &#8220;Please Jesus, protect all the Apple computers from viruses and hackers&#8221;.</p>
<p>Here is <a href="http://mac-security.blogspot.com/2010/07/desperate-propaganda-aka-fud-in-anti.html#comments">the answer</a> I posted to Darek Currie<sup><a href="http://www.soccio.it/michelinux/answering-darek-currie/#footnote_0_465" id="identifier_0_465" class="footnote-link footnote-identifier-link" title=" Do you think he is also smelling like curry? ">1</a></sup>&#8217;s blog, just in case he decides to not approve it in order to hide away his <a href="http://mac-security.blogspot.com/">complete ignorance</a> of what computer security is.</p>
<blockquote><p>Dear Derek,<br />
on the <a href="http://www.oneitsecurity.it/22/07/2010/software-non-sicuri-ad-apple-la-medaglia-doro/">oneITSecurity blog</a> you have accused me to plagiarize an article appeared on PCWorld. I don&#8217;t want to involve my Italian readers in a quite useless (for them) discussion. Still I want to state some points:</p>
<p>1. I did not plagiarize. PCWorld has copied and pasted a paragraph from the Secunia report. I read the Secunia pdf document, chose the most interesting parts and summarized the most interesting parts putting them in other words in a way that in Italian could sound better while keeping the current meaning. It seems <strong>you never read the Secunia report</strong> (I&#8217;m citing it, taking the news from it, copying even the numbers from it), or otherwise you would have not accused me.</p>
<p>2. I partially agree with you about the correct interpretation of the Secunia Report, and I did write it. Just counting the bugs is quite stupid. I believe that we should look at the time of bugs resolution, and at their severity. And this would lead us to a better evaluation of the &#8220;security&#8221; of a software.</p>
<p>3. My readers are quite aware of the difference of <em>safety</em> and <em>security</em>. My parents live in a small town. Their house has a wood door with an easy to pick lock. I live in a big city, with a reinforced steel door and a twelve plungers lock. And still while my house is more secure than theirs, their house is safer than mine. In software case, some software is safer only because it is lot easier to aim at a bigger target than a small one.</p>
<p>4. The Secunia report is talking about general software, while you are talking about the mere operating system, even in your post you are comparing Windows and MacOSX. Even I say that &#8220;Microsoft is not so bad, after all&#8221; there is some irony that I guess is not so easy to translate using an automatic service. </p>
<p>5. It seems more likely that you are an Apple fanatic more than I am &#8220;an anti-Mac security myth mongerer&#8221;. (BTW, thanks for teaching me a new English word: <em>mongerer</em>. Never heard or read it before, probably it is not used in UK).</p>
<p>6. If a friend of mine asks me &#8220;what computer should I buy&#8221;, I will suggest him or her to buy a Mac (except for some special application need, like Autocad). </p>
<p>7. Still waiting your apologies. </p></blockquote>
<ol class="footnotes"><li id="footnote_0_465" class="footnote"> Do you think he is also smelling like curry? </li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/answering-darek-currie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Italia.it vs France.fr</title>
		<link>http://www.soccio.it/michelinux/italia-it-vs-france-fr/</link>
		<comments>http://www.soccio.it/michelinux/italia-it-vs-france-fr/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 17:38:49 +0000</pubDate>
		<dc:creator>michele</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[france.fr]]></category>
		<category><![CDATA[italia.it]]></category>
		<category><![CDATA[portale]]></category>
		<category><![CDATA[Techcrunch]]></category>
		<category><![CDATA[turismo]]></category>

		<guid isPermaLink="false">http://www.soccio.it/michelinux/?p=462</guid>
		<description><![CDATA[Techcrunch dedica tutto un post puntare il dito contro i disservizi di France.fr mentre finora nemmeno una riga è stata finora spesa dal famoso blog per il nostro portale per il turismo Italia.it benché le nostre figuracce siano iniziate da molto molto prima. Il che fa di noi doppiamente perdenti: non ci prendono in considerazione <a href="http://www.soccio.it/michelinux/italia-it-vs-france-fr/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Techcrunch dedica <a href="http://techcrunch.com/2010/07/21/france-fr-still-down/">tutto un post</a> puntare il dito contro i disservizi di <a href="http://www.france.fr/">France.fr</a> mentre finora nemmeno una riga è stata finora spesa dal famoso blog per il nostro portale per il turismo <a href="http://www.italia.it/">Italia.it</a> benché le nostre figuracce siano iniziate da molto molto prima.</p>
<p>Il che fa di noi doppiamente perdenti: non ci prendono in considerazione né per il turismo, né per l&#8217;incompetenza.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soccio.it/michelinux/italia-it-vs-france-fr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

