Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Created December 11, 2010 14:38
Show Gist options
  • Save jbrechtel/737396 to your computer and use it in GitHub Desktop.
Save jbrechtel/737396 to your computer and use it in GitHub Desktop.
def createRemoteViews(): RemoteViews = {
val views = new RemoteViews(context.getPackageName(), R.layout.latest_apps)
views.removeAllViews(R.id.buttons)
dao.latestApps.take(4) foreach (appInfo => views.addView(R.id.buttons, createAppRemoteView(appInfo)))
views.setViewVisibility(R.id.buttons, android.view.View.VISIBLE)
return views
}
private def createAppRemoteView(appInfo: ApplicationInfo): RemoteViews = {
val views = new RemoteViews(context.getPackageName(), R.layout.app_button)
val uri = "android.resource://"+appInfo.packageName+"/"+appInfo.icon.toString
views.setImageViewUri(R.id.app_icon, Uri.parse(uri))
views.setOnClickPendingIntent(R.id.app_container, pendingIntentForApp(appInfo))
views.setTextViewText(R.id.app_label, appInfo.loadLabel(packageManager))
return views
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment