Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

Commit

Permalink
Bump up versions of dependencies (google#338)
Browse files Browse the repository at this point in the history
After this change, minSdkVersion is going to be 14 since the support library 26 isn't able to set the minSdkVersion lower than 14.

Also findViewById now requires type inference. Modified the code that uses findViewById.
  • Loading branch information
thagikura authored Jul 28, 2017
1 parent fb956ef commit 717a7b4
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 65 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

buildscript {
ext {
minSdkVersion = 9
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = "25.0.3"
minSdkVersion = 14
targetSdkVersion = 26
compileSdkVersion = 26
buildToolsVersion = "26.0.0"
androidGradlePluginVersion = "2.3.3"
androidMavenGradlePluginVersion = "1.5"
gradleBintrayPluginVersion = "1.6"
kotlinVersion = "1.1.3"
supportLibVersion = "25.3.1"
espressoVersion = "2.2.2"
testRunnerVersion = "0.5"
supportLibVersion = "26.0.0"
espressoVersion = "3.0.0"
testRunnerVersion = "1.0.0"
junitVersion = "4.12"
}

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ machine:

dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter "android-25,build-tools-25.0.3,tools,platform-tools,extra-android-m2repository"
- echo y | android update sdk --no-ui --all --filter "android-26,build-tools-26.0.0,tools,platform-tools,extra-android-m2repository"
cache_directories:
- ~/.android
override:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.google.android.flexbox.FlexboxLayoutManager
*/
internal class CatViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

private val imageView = itemView.findViewById(R.id.imageview) as ImageView
private val imageView: ImageView = itemView.findViewById(R.id.imageview)

internal fun bindTo(@DrawableRes drawableRes: Int) {
imageView.setImageResource(drawableRes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)

val flexboxLayoutManager = FlexboxLayoutManager(this).apply {
Expand All @@ -47,7 +47,7 @@ class MainActivity : AppCompatActivity() {
alignItems = AlignItems.STRETCH
}

val recyclerView = findViewById(R.id.recyclerview) as RecyclerView
val recyclerView: RecyclerView = findViewById(R.id.recyclerview)
recyclerView.apply {
layoutManager = flexboxLayoutManager
adapter = CatAdapter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ internal class FlexItemEditFragment : DialogFragment() {
dialog.setTitle((viewIndex + 1).toString())

val activity = activity
val orderTextInput = view
.findViewById(R.id.input_layout_order) as TextInputLayout
val orderEdit = view.findViewById(R.id.edit_text_order) as EditText
val orderTextInput: TextInputLayout = view.findViewById(R.id.input_layout_order)
val orderEdit: EditText = view.findViewById(R.id.edit_text_order)
orderEdit.setText(flexItem.order.toString())
orderEdit.addTextChangedListener(
FlexEditTextWatcher(activity, orderTextInput, IntegerInputValidator(),
Expand All @@ -106,26 +105,23 @@ internal class FlexItemEditFragment : DialogFragment() {
orderEdit.isEnabled = false
}

val flexGrowInput = view
.findViewById(R.id.input_layout_flex_grow) as TextInputLayout
val flexGrowEdit = view.findViewById(R.id.edit_text_flex_grow) as EditText
val flexGrowInput: TextInputLayout = view .findViewById(R.id.input_layout_flex_grow)
val flexGrowEdit: EditText = view.findViewById(R.id.edit_text_flex_grow)
flexGrowEdit.setText(flexItem.flexGrow.toString())
flexGrowEdit.addTextChangedListener(
FlexEditTextWatcher(activity, flexGrowInput, NonNegativeDecimalInputValidator(),
R.string.must_be_non_negative_float))

val flexShrinkInput = view
.findViewById(R.id.input_layout_flex_shrink) as TextInputLayout
val flexShrinkEdit = view.findViewById(
R.id.edit_text_flex_shrink) as EditText
val flexShrinkInput: TextInputLayout = view.findViewById(R.id.input_layout_flex_shrink)
val flexShrinkEdit: EditText = view.findViewById(R.id.edit_text_flex_shrink)
flexShrinkEdit.setText(flexItem.flexShrink.toString())
flexShrinkEdit.addTextChangedListener(
FlexEditTextWatcher(activity, flexShrinkInput, NonNegativeDecimalInputValidator(),
R.string.must_be_non_negative_float))

val flexBasisPercentInput = view.findViewById(R.id.input_layout_flex_basis_percent) as TextInputLayout
val flexBasisPercentEdit = view.findViewById(
R.id.edit_text_flex_basis_percent) as EditText
val flexBasisPercentInput: TextInputLayout =
view.findViewById(R.id.input_layout_flex_basis_percent)
val flexBasisPercentEdit: EditText = view.findViewById(R.id.edit_text_flex_basis_percent)
if (flexItem.flexBasisPercent != FlexboxLayout.LayoutParams.FLEX_BASIS_PERCENT_DEFAULT) {
flexBasisPercentEdit
.setText(Math.round(flexItem.flexBasisPercent * 100).toString())
Expand All @@ -136,52 +132,43 @@ internal class FlexItemEditFragment : DialogFragment() {
FlexEditTextWatcher(activity, flexBasisPercentInput, FlexBasisPercentInputValidator(),
R.string.must_be_minus_one_or_non_negative_integer))

val widthInput = view
.findViewById(R.id.input_layout_width) as TextInputLayout
val widthEdit = view.findViewById(R.id.edit_text_width) as EditText
val widthInput: TextInputLayout = view.findViewById(R.id.input_layout_width)
val widthEdit: EditText = view.findViewById(R.id.edit_text_width)
widthEdit.setText(activity.pixelToDp(flexItem.width).toString())
widthEdit.addTextChangedListener(
FlexEditTextWatcher(activity, widthInput, DimensionInputValidator(),
R.string.must_be_minus_one_or_minus_two_or_non_negative_integer))

val heightInput = view
.findViewById(R.id.input_layout_height) as TextInputLayout
val heightEdit = view.findViewById(
R.id.edit_text_height) as EditText
val heightInput: TextInputLayout = view.findViewById(R.id.input_layout_height)
val heightEdit: EditText= view.findViewById(R.id.edit_text_height)
heightEdit.setText(activity.pixelToDp(flexItem.height).toString())
heightEdit.addTextChangedListener(
FlexEditTextWatcher(activity, heightInput, DimensionInputValidator(),
R.string.must_be_minus_one_or_minus_two_or_non_negative_integer))

val minWidthInput = view
.findViewById(R.id.input_layout_min_width) as TextInputLayout
val minWidthEdit = view.findViewById(R.id.edit_text_min_width) as EditText
val minWidthInput: TextInputLayout = view.findViewById(R.id.input_layout_min_width)
val minWidthEdit: EditText = view.findViewById(R.id.edit_text_min_width)
minWidthEdit.setText(activity.pixelToDp(flexItem.minWidth).toString())
minWidthEdit.addTextChangedListener(
FlexEditTextWatcher(activity, minWidthInput, FixedDimensionInputValidator(),
R.string.must_be_non_negative_integer))

val minHeightInput = view
.findViewById(R.id.input_layout_min_height) as TextInputLayout
val minHeightEdit = view.findViewById(
R.id.edit_text_min_height) as EditText
val minHeightInput: TextInputLayout = view.findViewById(R.id.input_layout_min_height)
val minHeightEdit: EditText = view.findViewById(R.id.edit_text_min_height)
minHeightEdit.setText(activity.pixelToDp(flexItem.minHeight).toString())
minHeightEdit.addTextChangedListener(
FlexEditTextWatcher(activity, minHeightInput, FixedDimensionInputValidator(),
R.string.must_be_non_negative_integer))

val maxWidthInput = view
.findViewById(R.id.input_layout_max_width) as TextInputLayout
val maxWidthEdit = view.findViewById(R.id.edit_text_max_width) as EditText
val maxWidthInput: TextInputLayout = view.findViewById(R.id.input_layout_max_width)
val maxWidthEdit: EditText = view.findViewById(R.id.edit_text_max_width)
maxWidthEdit.setText(activity.pixelToDp(flexItem.maxWidth).toString())
maxWidthEdit.addTextChangedListener(
FlexEditTextWatcher(activity, maxWidthInput, FixedDimensionInputValidator(),
R.string.must_be_non_negative_integer))

val maxHeightInput = view
.findViewById(R.id.input_layout_max_height) as TextInputLayout
val maxHeightEdit = view.findViewById(
R.id.edit_text_max_height) as EditText
val maxHeightInput: TextInputLayout = view.findViewById(R.id.input_layout_max_height)
val maxHeightEdit: EditText = view.findViewById(R.id.edit_text_max_height)
maxHeightEdit.setText(activity.pixelToDp(flexItem.maxHeight).toString())
maxHeightEdit.addTextChangedListener(
FlexEditTextWatcher(activity, maxHeightInput, FixedDimensionInputValidator(),
Expand All @@ -190,8 +177,7 @@ internal class FlexItemEditFragment : DialogFragment() {
setNextFocusesOnEnterDown(orderEdit, flexGrowEdit, flexShrinkEdit, flexBasisPercentEdit,
widthEdit, heightEdit, minWidthEdit, minHeightEdit, maxWidthEdit, maxHeightEdit)

val alignSelfSpinner = view.findViewById(
R.id.spinner_align_self) as Spinner
val alignSelfSpinner: Spinner = view.findViewById(R.id.spinner_align_self)
val arrayAdapter = ArrayAdapter.createFromResource(activity,
R.array.array_align_self, R.layout.spinner_item)
alignSelfSpinner.adapter = arrayAdapter
Expand All @@ -213,18 +199,18 @@ internal class FlexItemEditFragment : DialogFragment() {
}
}

val wrapBeforeCheckBox = view.findViewById(R.id.checkbox_wrap_before) as CheckBox
val wrapBeforeCheckBox: CheckBox = view.findViewById(R.id.checkbox_wrap_before)
wrapBeforeCheckBox.isChecked = flexItem.isWrapBefore
wrapBeforeCheckBox.setOnCheckedChangeListener { _, isChecked -> flexItemInEdit.isWrapBefore = isChecked }
val alignSelfPosition = arrayAdapter
.getPosition(alignSelfAsString(flexItem.alignSelf))
alignSelfSpinner.setSelection(alignSelfPosition)

view.findViewById(R.id.button_cancel).setOnClickListener {
view.findViewById<Button>(R.id.button_cancel).setOnClickListener {
copyFlexItemValues(flexItem, flexItemInEdit)
dismiss()
}
val okButton = view.findViewById(R.id.button_ok) as Button
val okButton: Button = view.findViewById(R.id.button_ok)
okButton.setOnClickListener(View.OnClickListener {
if (orderTextInput.isErrorEnabled || flexGrowInput.isErrorEnabled ||
flexBasisPercentInput.isErrorEnabled || widthInput.isErrorEnabled ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.google.android.apps.flexbox.R
*/
class FlexItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

private val textView: TextView = itemView.findViewById(R.id.textview) as TextView
private val textView: TextView = itemView.findViewById(R.id.textview)

fun bindTo(params: RecyclerView.LayoutParams) {
val adapterPosition = adapterPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import java.util.*
*/
class FlexboxLayoutFragment : Fragment() {

private lateinit var flexContainer: FlexContainer
private lateinit var flexContainer: FlexboxLayout

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
Expand All @@ -42,7 +42,7 @@ class FlexboxLayoutFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val activity = activity as MainActivity
flexContainer = view.findViewById(R.id.flexbox_layout) as FlexboxLayout
flexContainer = view.findViewById(R.id.flexbox_layout)

val fragmentHelper = FragmentHelper(activity, flexContainer)
fragmentHelper.initializeViews()
Expand All @@ -64,7 +64,7 @@ class FlexboxLayoutFragment : Fragment() {
}
}

val addFab = activity.findViewById(R.id.add_fab) as FloatingActionButton
val addFab: FloatingActionButton = activity.findViewById(R.id.add_fab)
addFab.setOnClickListener {
val viewIndex = flexContainer.flexItemCount
// index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
Expand All @@ -79,8 +79,7 @@ class FlexboxLayoutFragment : Fragment() {
FlexItemChangedListenerImpl(flexContainer), viewIndex))
flexContainer.addView(textView)
}
val removeFab = activity.findViewById(
R.id.remove_fab) as FloatingActionButton
val removeFab: FloatingActionButton = activity.findViewById(R.id.remove_fab)
removeFab.setOnClickListener(View.OnClickListener {
if (flexContainer.flexItemCount == 0) {
return@OnClickListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class FragmentHelper(private val activity: MainActivity, private val fl
fun initializeViews() {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
initializeStringResources()
val navigationView = activity.findViewById(R.id.nav_view) as NavigationView
val navigationView: NavigationView = activity.findViewById(R.id.nav_view)
navigationView.setNavigationItemSelectedListener(activity)
val navigationMenu = navigationView.menu
initializeFlexDirectionSpinner(navigationMenu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
val drawer = findViewById(R.id.drawer_layout) as DrawerLayout
val drawer: DrawerLayout = findViewById(R.id.drawer_layout)
val toggle = ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close)
drawer.addDrawerListener(toggle)
toggle.syncState()

val navigationView = findViewById(R.id.nav_view) as NavigationView
val radioGroup = navigationView.getHeaderView(0)
.findViewById(R.id.radiogroup_container_implementation) as RadioGroup
val navigationView: NavigationView = findViewById(R.id.nav_view)
val radioGroup: RadioGroup = navigationView.getHeaderView(0)
.findViewById(R.id.radiogroup_container_implementation)
val fragmentManager = supportFragmentManager

radioGroup.setOnCheckedChangeListener { _, checkedId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal class RecyclerViewFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val recyclerView = view.findViewById(R.id.recyclerview) as RecyclerView
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerview)
val activity = activity as MainActivity
val flexboxLayoutManager = FlexboxLayoutManager(activity)
recyclerView.layoutManager = flexboxLayoutManager
Expand All @@ -60,15 +60,15 @@ internal class RecyclerViewFragment : Fragment() {
val fragmentHelper = FragmentHelper(activity, flexboxLayoutManager)
fragmentHelper.initializeViews()

val addFab = activity.findViewById(R.id.add_fab) as FloatingActionButton
val addFab: FloatingActionButton = activity.findViewById(R.id.add_fab)
addFab.setOnClickListener {
val lp = FlexboxLayoutManager.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
fragmentHelper.setFlexItemAttributes(lp)
adapter.addItem(lp)
}
val removeFab = activity.findViewById(R.id.remove_fab) as FloatingActionButton
val removeFab: FloatingActionButton = activity.findViewById(R.id.remove_fab)
removeFab.setOnClickListener(View.OnClickListener {
if (adapter.itemCount == 0) {
return@OnClickListener
Expand Down

0 comments on commit 717a7b4

Please sign in to comment.