Merge "Cross fade escalation card when content changes." into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b10df69a84
@@ -148,7 +148,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
public void setHasInternet(boolean hasInternet) {
|
public void setHasInternet(boolean hasInternet) {
|
||||||
if (mHasInternet != hasInternet) {
|
if (mHasInternet != hasInternet) {
|
||||||
mHasInternet = hasInternet;
|
mHasInternet = hasInternet;
|
||||||
refreshData();
|
refreshEscalationCards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
if (!Objects.equals(mAccount, account)) {
|
if (!Objects.equals(mAccount, account)) {
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
mSupportFeatureProvider.refreshOperationRules();
|
mSupportFeatureProvider.refreshOperationRules();
|
||||||
refreshData();
|
refreshEscalationCards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,18 +170,42 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
*/
|
*/
|
||||||
private void refreshData() {
|
private void refreshData() {
|
||||||
mSupportData.clear();
|
mSupportData.clear();
|
||||||
if (mAccount == null) {
|
|
||||||
addSignInPromo();
|
|
||||||
} else if (mHasInternet) {
|
|
||||||
addEscalationCards();
|
addEscalationCards();
|
||||||
} else {
|
|
||||||
addOfflineEscalationCards();
|
|
||||||
}
|
|
||||||
addMoreHelpItems();
|
addMoreHelpItems();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds 1 escalation card. Based on current phone state, the escalation card can display
|
||||||
|
* different content.
|
||||||
|
*/
|
||||||
private void addEscalationCards() {
|
private void addEscalationCards() {
|
||||||
|
if (mAccount == null) {
|
||||||
|
addSignInPromo();
|
||||||
|
} else if (mHasInternet) {
|
||||||
|
addOnlineEscalationCards();
|
||||||
|
} else {
|
||||||
|
addOfflineEscalationCards();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds and refreshes escalation card data.
|
||||||
|
*/
|
||||||
|
private void refreshEscalationCards() {
|
||||||
|
if (getItemCount() > 0) {
|
||||||
|
final int itemType = getItemViewType(0 /* position */);
|
||||||
|
if (itemType == TYPE_SIGN_IN_BUTTON
|
||||||
|
|| itemType == TYPE_ESCALATION_OPTIONS
|
||||||
|
|| itemType == TYPE_ESCALATION_OPTIONS_OFFLINE) {
|
||||||
|
mSupportData.remove(0 /* position */);
|
||||||
|
addEscalationCards();
|
||||||
|
notifyItemChanged(0 /* position */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOnlineEscalationCards() {
|
||||||
final boolean hasPhoneOperation =
|
final boolean hasPhoneOperation =
|
||||||
mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE);
|
mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE);
|
||||||
final boolean hasChatOperation =
|
final boolean hasChatOperation =
|
||||||
@@ -218,7 +242,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
.setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT))
|
.setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT))
|
||||||
.setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
|
.setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
|
||||||
}
|
}
|
||||||
mSupportData.add(builder.build());
|
mSupportData.add(0 /* index */, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOfflineEscalationCards() {
|
private void addOfflineEscalationCards() {
|
||||||
@@ -231,7 +255,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
|
operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
|
||||||
PHONE, mSelectedCountry, false /* hasInternet */);
|
PHONE, mSelectedCountry, false /* hasInternet */);
|
||||||
}
|
}
|
||||||
mSupportData.add(new OfflineEscalationData.Builder(mActivity)
|
mSupportData.add(0 /* index */, new OfflineEscalationData.Builder(mActivity)
|
||||||
.setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
|
.setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
|
||||||
.setTollFreePhone(mSupportFeatureProvider.getSupportPhones(
|
.setTollFreePhone(mSupportFeatureProvider.getSupportPhones(
|
||||||
mSelectedCountry, true /* isTollFree */))
|
mSelectedCountry, true /* isTollFree */))
|
||||||
@@ -245,7 +269,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addSignInPromo() {
|
private void addSignInPromo() {
|
||||||
mSupportData.add(new EscalationData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
|
mSupportData.add(0 /* index */, new EscalationData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
|
||||||
.setText1(R.string.support_sign_in_button_text)
|
.setText1(R.string.support_sign_in_button_text)
|
||||||
.setText2(R.string.support_sign_in_required_help)
|
.setText2(R.string.support_sign_in_required_help)
|
||||||
.setTileTitle(R.string.support_sign_in_required_title)
|
.setTileTitle(R.string.support_sign_in_required_title)
|
||||||
@@ -439,7 +463,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
final String selectedCountry = countryCodes.get(position);
|
final String selectedCountry = countryCodes.get(position);
|
||||||
if (!TextUtils.equals(selectedCountry, mSelectedCountry)) {
|
if (!TextUtils.equals(selectedCountry, mSelectedCountry)) {
|
||||||
mSelectedCountry = selectedCountry;
|
mSelectedCountry = selectedCountry;
|
||||||
refreshData();
|
refreshEscalationCards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user