Java 类android.support.v4.util.ObjectsCompat 实例源码

项目:cwac-crossport    文件:AppBarLayout.java   
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
  WindowInsetsCompat newInsets = null;

  if (ViewCompat.getFitsSystemWindows(this)) {
    // If we're set to fit system windows, keep the insets
    newInsets = insets;
  }

  // If our insets have changed, keep them and invalidate the scroll ranges...
      if (!ObjectsCompat.equals(mLastInsets, newInsets)) {
    mLastInsets = newInsets;
    invalidateScrollRanges();
  }

  return insets;
}
项目:material-components-android    文件:AppBarLayout.java   
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
  WindowInsetsCompat newInsets = null;

  if (ViewCompat.getFitsSystemWindows(this)) {
    // If we're set to fit system windows, keep the insets
    newInsets = insets;
  }

  // If our insets have changed, keep them and invalidate the scroll ranges...
  if (!ObjectsCompat.equals(lastInsets, newInsets)) {
    lastInsets = newInsets;
    invalidateScrollRanges();
  }

  return insets;
}
项目:material-components-android    文件:CollapsingToolbarLayout.java   
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
  WindowInsetsCompat newInsets = null;

  if (ViewCompat.getFitsSystemWindows(this)) {
    // If we're set to fit system windows, keep the insets
    newInsets = insets;
  }

  // If our insets have changed, keep them and invalidate the scroll ranges...
  if (!ObjectsCompat.equals(lastInsets, newInsets)) {
    lastInsets = newInsets;
    requestLayout();
  }

  // Consume the insets. This is done so that child views with fitSystemWindows=true do not
  // get the default padding functionality from View
  return insets.consumeSystemWindowInsets();
}
项目:multiline-collapsingtoolbar    文件:CollapsingToolbarLayout.java   
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
    WindowInsetsCompat newInsets = null;

    if (ViewCompat.getFitsSystemWindows(this)) {
        // If we're set to fit system windows, keep the insets
        newInsets = insets;
    }

    // If our insets have changed, keep them and invalidate the scroll ranges...
    if (!ObjectsCompat.equals(mLastInsets, newInsets)) {
        mLastInsets = newInsets;
        requestLayout();
    }

    // Consume the insets. This is done so that child views with fitSystemWindows=true do not
    // get the default padding functionality from View
    return insets.consumeSystemWindowInsets();
}
项目:cwac-crossport    文件:CoordinatorLayout.java   
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
      if (!ObjectsCompat.equals(mLastInsets, insets)) {
    mLastInsets = insets;
    mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
    setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null);

    // Now dispatch to the Behaviors
    insets = dispatchApplyWindowInsetsToBehaviors(insets);
    requestLayout();
  }
  return insets;
}
项目:AndelaTrackChallenge    文件:CountryDiffUtil.java   
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
    Country oldCountry = oldCountries.get(oldItemPosition);
    Country newCountry = newCountries.get(newItemPosition);

    return oldCountry.refreshedAt == newCountry.refreshedAt &&
            oldCountry.btc == newCountry.btc &&
            oldCountry.eth == newCountry.eth &&
            ObjectsCompat.equals(oldCountry.currency, newCountry.currency) &&
            ObjectsCompat.equals(oldCountry.code, newCountry.code);
}
项目:AndelaTrackChallenge    文件:CardsAdapter.java   
public void replace(Country newCountry) {
    for (Country country : countries) {
        if (ObjectsCompat.equals(country.code, newCountry.code)) {
            int index = countries.indexOf(country);
            countries.set(index, newCountry);
            notifyItemChanged(index);

            break;
        }
    }
}
项目:AndelaTrackChallenge    文件:CardsAdapter.java   
private void loadCardColor(Country country) {
    Context context = itemView.getContext();
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), country.getFlagRes());
    Palette.from(bitmap)
            .maximumColorCount(4)
            .generate(palette -> {
                if (!ObjectsCompat.equals(signature, country.toString())) {
                    return;
                }
                Palette.Swatch swatch = palette.getDarkVibrantSwatch();
                if (swatch == null) {
                    swatch = palette.getLightVibrantSwatch();
                }
                if (swatch == null) {
                    swatch = new Palette.Swatch(Easel.getThemeAttrColor(context, R.attr.cardColor), 4);
                }

                cardCurrency.setCardBackgroundColor(Easel.getDarkerColor(swatch.getRgb(), 0.9f));
                titleTextView.setTextColor(swatch.getTitleTextColor());
                int bodyTextColor = swatch.getBodyTextColor();

                ButterKnife.apply(
                        Arrays.asList(btcTextView, ethTextView, btcLabelTextView, ethLabelTextView),
                        (ButterKnife.Action<TextView>) (view, index) ->
                                view.setTextColor(bodyTextColor));

                overflowButton.setImageDrawable(Easel
                        .tint(overflowButton.getDrawable(), bodyTextColor));
            });
}
项目:AndelaTrackChallenge    文件:SettingsFragment.java   
private void loadSummaries(String key) {
    ListPreference preference = (ListPreference) findPreference("THEME");
    preference.setSummary(preference.getEntry());

    if (ObjectsCompat.equals(key, "THEME")) {
        getActivity().recreate();
    }
}
项目:material-components-android    文件:CoordinatorLayout.java   
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) {
  if (!ObjectsCompat.equals(lastInsets, insets)) {
    lastInsets = insets;
    drawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0;
    setWillNotDraw(!drawStatusBarBackground && getBackground() == null);

    // Now dispatch to the Behaviors
    insets = dispatchApplyWindowInsetsToBehaviors(insets);
    requestLayout();
  }
  return insets;
}
项目:AndelaTrackChallenge    文件:ApiClient.java   
public static Single<Country> loadRate(Country oldCountry) {
    long minutesBefore = System.currentTimeMillis() - (10 * 60 * 1000);
    if (oldCountry.refreshedAt > minutesBefore)
        return Single.error(new Throwable("No refresh needed!"));

    return getApi().getPrice(oldCountry.code, BTC_ETH)
            .map(response -> {
                HttpUrl url = response.raw().request().url();
                String from = url.queryParameter(Api.FROM_SYMBOL);

                if (TextUtils.isEmpty(from)) {
                    return null;
                }

                Exchange exchange = response.body();
                if (exchange == null) {
                    return null;
                }

                if (ObjectsCompat.equals(oldCountry.code, from)) {
                    int btcStatus = Country.SAME;
                    if (oldCountry.btc != -1) {
                        if (exchange.bitcoin > oldCountry.btc) {
                            btcStatus = Country.RISE;
                        } else if (exchange.bitcoin < oldCountry.btc) {
                            btcStatus = Country.DROP;
                        }
                    }

                    int ethStatus = Country.SAME;
                    if (oldCountry.eth != -1) {
                        if (exchange.bitcoin > oldCountry.btc) {
                            ethStatus = Country.RISE;
                        } else if (exchange.bitcoin < oldCountry.btc) {
                            ethStatus = Country.DROP;
                        }
                    }
                    oldCountry.btcStatus = btcStatus;
                    oldCountry.ethStatus = ethStatus;

                    oldCountry.eth = exchange.ethereum;
                    oldCountry.btc = exchange.bitcoin;
                    oldCountry.refreshedAt = System.currentTimeMillis();
                    return oldCountry;
                }
                return null;
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}