| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments.ui; | 5 package org.chromium.chrome.browser.payments.ui; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
| 10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 mFieldViews.clear(); | 314 mFieldViews.clear(); |
| 315 mEditableTextFields.clear(); | 315 mEditableTextFields.clear(); |
| 316 mDropdownFields.clear(); | 316 mDropdownFields.clear(); |
| 317 | 317 |
| 318 // Add Views for each of the {@link EditorFields}. | 318 // Add Views for each of the {@link EditorFields}. |
| 319 for (int i = 0; i < mEditorModel.getFields().size(); i++) { | 319 for (int i = 0; i < mEditorModel.getFields().size(); i++) { |
| 320 EditorFieldModel fieldModel = mEditorModel.getFields().get(i); | 320 EditorFieldModel fieldModel = mEditorModel.getFields().get(i); |
| 321 EditorFieldModel nextFieldModel = null; | 321 EditorFieldModel nextFieldModel = null; |
| 322 | 322 |
| 323 boolean isLastField = i == mEditorModel.getFields().size() - 1; | 323 boolean isLastField = i == mEditorModel.getFields().size() - 1; |
| 324 // Dropdown fields will take a full line | 324 boolean useFullLine = fieldModel.isFullLine(); |
| 325 boolean useFullLine = fieldModel.isFullLine() || isLastField | 325 if (!isLastField && !useFullLine) { |
| 326 || (fieldModel.getInputTypeHint() == EditorFieldModel.INPUT_
TYPE_HINT_DROPDOWN); | |
| 327 | |
| 328 if (!useFullLine) { | |
| 329 // If the next field isn't full, stretch it out. | 326 // If the next field isn't full, stretch it out. |
| 330 nextFieldModel = mEditorModel.getFields().get(i + 1); | 327 nextFieldModel = mEditorModel.getFields().get(i + 1); |
| 331 useFullLine = useFullLine || nextFieldModel.isFullLine() | 328 if (nextFieldModel.isFullLine()) useFullLine = true; |
| 332 || (nextFieldModel.getInputTypeHint() | |
| 333 == EditorFieldModel.INPUT_TYPE_HINT_DROPDOWN)
; | |
| 334 } | 329 } |
| 335 | 330 |
| 336 if (useFullLine) { | 331 if (useFullLine || isLastField) { |
| 337 addFieldViewToEditor(mDataView, fieldModel); | 332 addFieldViewToEditor(mDataView, fieldModel); |
| 338 } else { | 333 } else { |
| 339 // Create a LinearLayout to put it and the next view side by sid
e. | 334 // Create a LinearLayout to put it and the next view side by sid
e. |
| 340 LinearLayout rowLayout = new LinearLayout(mContext); | 335 LinearLayout rowLayout = new LinearLayout(mContext); |
| 341 mDataView.addView(rowLayout); | 336 mDataView.addView(rowLayout); |
| 342 | 337 |
| 343 View firstView = addFieldViewToEditor(rowLayout, fieldModel); | 338 View firstView = addFieldViewToEditor(rowLayout, fieldModel); |
| 344 View lastView = addFieldViewToEditor(rowLayout, nextFieldModel); | 339 View lastView = addFieldViewToEditor(rowLayout, nextFieldModel); |
| 345 | 340 |
| 346 LinearLayout.LayoutParams firstParams = | 341 LinearLayout.LayoutParams firstParams = |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 public List<EditText> getEditableTextFieldsForTest() { | 538 public List<EditText> getEditableTextFieldsForTest() { |
| 544 return mEditableTextFields; | 539 return mEditableTextFields; |
| 545 } | 540 } |
| 546 | 541 |
| 547 /** @return All dropdown fields in the editor. Used only for tests. */ | 542 /** @return All dropdown fields in the editor. Used only for tests. */ |
| 548 @VisibleForTesting | 543 @VisibleForTesting |
| 549 public List<Spinner> getDropdownFieldsForTest() { | 544 public List<Spinner> getDropdownFieldsForTest() { |
| 550 return mDropdownFields; | 545 return mDropdownFields; |
| 551 } | 546 } |
| 552 } | 547 } |
| OLD | NEW |