Skip to content

Commit

Permalink
use findView instead of findViewById
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-burns committed Sep 25, 2011
1 parent c0f0358 commit df6e656
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/scala/LaunchActivity.scala
Expand Up @@ -40,13 +40,15 @@ import android.widget.LinearLayout

import android.util.Log

class LaunchActivity extends FragmentActivity {
import TypedResource._

class LaunchActivity extends FragmentActivity with TypedFragmentActivity {
override def onCreate(savedInstanceState : Bundle) {
super.onCreate(savedInstanceState)

setContentView(R.layout.main)

val resolveInfosPager = findViewById(R.id.paginatorizer).asInstanceOf[ViewPager]
val resolveInfosPager = findView(TR.paginatorizer)

val vto = resolveInfosPager.getViewTreeObserver
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
Expand Down Expand Up @@ -107,7 +109,7 @@ object AppsFragment {
}
}

class AppsFragment extends Fragment {
class AppsFragment extends Fragment with TypedFragment {
var page = 0
var resolveInfos = null : List[ResolveInfo]
var numRows = 1
Expand Down Expand Up @@ -146,8 +148,8 @@ class AppsFragment extends Fragment {
if (positionIndex(rowIndex, columnIndex) < resolveInfos.size) {
resolveInfo = resolveInfos.get(positionIndex(rowIndex, columnIndex))
cell = inflater.inflate(R.layout.app_item, null, false)
tv = cell.findViewById(R.id.app_name).asInstanceOf[TextView]
iv = cell.findViewById(R.id.app_icon).asInstanceOf[ImageView]
tv = cell.findView(TR.app_name)
iv = cell.findView(TR.app_icon)

tv.setText(resolveInfo.loadLabel(packageManager))
iv.setImageDrawable(resolveInfo.loadIcon(packageManager))
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/mixins/TypedFragment.scala
@@ -0,0 +1,11 @@
package com.mike_burns.ohlaunch
import android.support.v4.app.FragmentActivity
import android.support.v4.app.Fragment

trait TypedFragmentActivity extends FragmentActivity with TypedActivityHolder {
def activity = this
}

trait TypedFragment extends Fragment with TypedActivityHolder {
def activity = getActivity
}

0 comments on commit df6e656

Please sign in to comment.