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

<channel>
	<title>gallery &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/gallery/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Tue, 01 Nov 2011 02:48:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>gallery &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Android Workspace Widget</title>
		<link>https://blog.sephiroth.it/2011/11/01/android-workspace-widget/</link>
					<comments>https://blog.sephiroth.it/2011/11/01/android-workspace-widget/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Tue, 01 Nov 2011 02:48:09 +0000</pubDate>
				<category><![CDATA[android]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[workspace]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=1592</guid>

					<description><![CDATA[&#160; I was looking for an android widget similar to the launcher workspace widget ( the one used in almost all launchers ), but a bit more customizable and with the possibility to use an Adapter as content provider. So at the end I mixed&#160;portion of code from the android launcher Workspace widget, the Gallery &#8230; <a href="https://blog.sephiroth.it/2011/11/01/android-workspace-widget/" class="more-link">Continue reading <span class="screen-reader-text">Android Workspace Widget</span></a>]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p><a href="https://blog.sephiroth.it/wp-content/uploads/2011/11/device-2011-10-31-220138.png"><img decoding="async" class="size-thumbnail wp-image-1598 alignright" title="workspace_thumb" src="https://blog.sephiroth.it/wp-content/uploads/2011/11/workspace_thumb-150x150.png" alt="" width="150" height="150" /></a>I was looking for an android widget similar to the launcher workspace widget ( the one used in almost all launchers ), but a bit more customizable and with the possibility to use an Adapter as content provider. So at the end I mixed portion of code from the android launcher <a href="http://www.google.com/codesearch/p?hl=en#cZwlSNS7aEw/packages/apps/Launcher2/src/com/android/launcher2/Workspace.java">Workspace</a> widget, the <a href="http://www.google.com/codesearch/p?hl=en#cZwlSNS7aEw/frameworks/base/core/java/android/widget/Gallery.java&amp;q=Gallery.java&amp;exact_package=android&amp;type=cs">Gallery</a> widget and the <a href="http://www.google.com/codesearch/p?hl=en#cZwlSNS7aEw/frameworks/base/core/java/android/widget/AbsListView.java&amp;q=AbsListView.java&amp;exact_package=android&amp;type=cs">AbsListView</a> widget.</p>
<p>Nothing particular tricky, just a combination of the 3 widgets in order to have the same sliding effect of the workspace ( using custom number of columns and rows ), but at the same time with an <strong>ArrayAdapter</strong> for creating views, and a little glow effect at start at the end of scrolling for creating the gingerbread style overscroll effect.</p>
<p>This is the source code: <strong><a href="https://blog.sephiroth.it/wp-content/uploads/2011/11/workspace.zip">workspace</a></strong></p>
<p>It&#8217;s just a first version, so it&#8217;s not really optimized&#8230;</p>
<p>The adapter used for creating this example looks like this:<br />
[cc]<br />
class WorkspaceAdapter extends ArrayAdapter<applicationinfo> {</p>
<p>	int screenId;<br />
	PackageManager pm;<br />
	private LayoutInflater mInflater;<br />
	private int nCellsPerScreen = 4;</p>
<p>	public WorkspaceAdapter( Context context, int textViewResourceId, List</applicationinfo><applicationinfo> objects ) {<br />
		super( context, textViewResourceId, objects );<br />
		screenId = textViewResourceId;<br />
		pm = context.getPackageManager();<br />
		nCellsPerScreen = context.getResources().getInteger( R.integer.config_portraitCells ) * context.getResources().getInteger( R.integer.config_portraitRows );<br />
		mInflater = (LayoutInflater) context.getSystemService( LAYOUT_INFLATER_SERVICE );<br />
	}</p>
<p>	@Override<br />
	public int getCount() {<br />
		return (int) Math.ceil( (double) super.getCount() / nCellsPerScreen );<br />
	}</p>
<p>	public int getRealCount() {<br />
		return super.getCount();<br />
	}</p>
<p>	@Override<br />
	public View getView( int position, View convertView, ViewGroup parent ) {</p>
<p>		if ( convertView == null ) {<br />
			convertView = mInflater.inflate( screenId, mWorkspace, false );<br />
			((CellLayout)convertView).setNumCols( nCellsPerScreen );<br />
		}</p>
<p>		CellLayout cell = (CellLayout) convertView;</p>
<p>		int index = position * nCellsPerScreen;<br />
		int realCount = getRealCount();</p>
<p>		for ( int i = 0; i < nCellsPerScreen; i++ ) {
			CellInfo cellInfo = cell.findVacantCell( 1, 1 );
			TextView text;

			if ( cellInfo == null ) {
				text = (TextView) cell.getChildAt( i );
			} else {
				text = (TextView) mInflater.inflate( R.layout.application_boxed, cell, false );
				CellLayout.LayoutParams lp = new CellLayout.LayoutParams( cellInfo.cellX, cellInfo.cellY, cellInfo.spanH,
						cellInfo.spanV );
				cell.addView( text, i, lp );
			}

			if ( index + i < realCount ) {
				ApplicationInfo appInfo = getItem( index + i );
				CharSequence label = appInfo.loadLabel( pm );
				Drawable bm = appInfo.loadIcon( pm );

				text.setCompoundDrawablesWithIntrinsicBounds( null, bm, null, null ); // new
				text.setText( label );
				text.setClickable( true );
				text.setFocusable( true );
				text.setVisibility( View.VISIBLE );
			} else {
				text.setVisibility( View.INVISIBLE );
			}
		}
		return convertView;
	}
}
[/cc]

&nbsp;

</applicationinfo></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2011/11/01/android-workspace-widget/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
