Chromium Code Reviews| 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; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 | 850 |
| 851 PaymentDetailsModifier modifier = getModifier(instrument); | 851 PaymentDetailsModifier modifier = getModifier(instrument); |
| 852 PaymentItem total = modifier == null ? null : modifier.total; | 852 PaymentItem total = modifier == null ? null : modifier.total; |
| 853 if (total == null) total = mRawTotal; | 853 if (total == null) total = mRawTotal; |
| 854 | 854 |
| 855 CurrencyFormatter formatter = getOrCreateCurrencyFormatter(total.amount) ; | 855 CurrencyFormatter formatter = getOrCreateCurrencyFormatter(total.amount) ; |
| 856 mUiShoppingCart.setTotal(new LineItem(total.label, formatter.getFormatte dCurrencyCode(), | 856 mUiShoppingCart.setTotal(new LineItem(total.label, formatter.getFormatte dCurrencyCode(), |
| 857 formatter.format(total.amount.value), false /* isPending */)); | 857 formatter.format(total.amount.value), false /* isPending */)); |
| 858 mUiShoppingCart.setAdditionalContents( | 858 mUiShoppingCart.setAdditionalContents( |
| 859 modifier == null ? null : getLineItems(modifier.additionalDispla yItems)); | 859 modifier == null ? null : getLineItems(modifier.additionalDispla yItems)); |
| 860 mUI.updateOrderSummarySection(mUiShoppingCart); | |
|
gogerald1
2017/05/11 20:11:20
why is this redundant? we have to update UI if mUi
wuandy1
2017/05/12 01:34:28
what i meant was it looked like at the end of upda
gogerald1
2017/05/12 14:23:04
This is also called when selected payment option i
| |
| 861 } | 860 } |
| 862 | 861 |
| 863 /** @return The first modifier that matches the given instrument, or null. * / | 862 /** @return The first modifier that matches the given instrument, or null. * / |
| 864 @Nullable private PaymentDetailsModifier getModifier(@Nullable PaymentInstru ment instrument) { | 863 @Nullable private PaymentDetailsModifier getModifier(@Nullable PaymentInstru ment instrument) { |
| 865 if (mModifiers == null || instrument == null) return null; | 864 if (mModifiers == null || instrument == null) return null; |
| 866 Set<String> methodNames = instrument.getInstrumentMethodNames(); | 865 // make a copy to ensure it is modifiable. |
| 866 Set<String> methodNames = new HashSet<>(instrument.getInstrumentMethodNa mes()); | |
| 867 methodNames.retainAll(mModifiers.keySet()); | 867 methodNames.retainAll(mModifiers.keySet()); |
| 868 return methodNames.isEmpty() ? null : mModifiers.get(methodNames.iterato r().next()); | 868 return methodNames.isEmpty() ? null : mModifiers.get(methodNames.iterato r().next()); |
| 869 } | 869 } |
| 870 | 870 |
| 871 /** | 871 /** |
| 872 * Converts a list of payment items and returns their parsed representation. | 872 * Converts a list of payment items and returns their parsed representation. |
| 873 * | 873 * |
| 874 * @param items The payment items to parse. Can be null. | 874 * @param items The payment items to parse. Can be null. |
| 875 * @return A list of valid line items. | 875 * @return A list of valid line items. |
| 876 */ | 876 */ |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1870 | 1870 |
| 1871 /** | 1871 /** |
| 1872 * The frecency score is calculated according to use count and last use date . The formula is | 1872 * The frecency score is calculated according to use count and last use date . The formula is |
| 1873 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. | 1873 * the same as the one used in GetFrecencyScore in autofill_data_model.cc. |
| 1874 */ | 1874 */ |
| 1875 private static final double getFrecencyScore(int count, long date) { | 1875 private static final double getFrecencyScore(int count, long date) { |
| 1876 long currentTime = System.currentTimeMillis(); | 1876 long currentTime = System.currentTimeMillis(); |
| 1877 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); | 1877 return -Math.log((currentTime - date) / (24 * 60 * 60 * 1000) + 2) / Mat h.log(count + 2); |
| 1878 } | 1878 } |
| 1879 } | 1879 } |
| OLD | NEW |