diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/incallui/incall/impl/InCallPagerAdapter.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/incallui/incall/impl/InCallPagerAdapter.java')
-rw-r--r-- | java/com/android/incallui/incall/impl/InCallPagerAdapter.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java index 0b1088d2d..ead35344f 100644 --- a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java +++ b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java @@ -21,7 +21,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; -import android.text.TextUtils; +import com.android.dialer.common.Assert; import com.android.dialer.multimedia.MultimediaData; import com.android.incallui.sessiondata.MultimediaFragment; @@ -29,29 +29,44 @@ import com.android.incallui.sessiondata.MultimediaFragment; public class InCallPagerAdapter extends FragmentStatePagerAdapter { @Nullable private MultimediaData attachments; + private final boolean showInCallButtonGrid; - public InCallPagerAdapter(FragmentManager fragmentManager, @Nullable MultimediaData attachments) { + public InCallPagerAdapter( + FragmentManager fragmentManager, + @Nullable MultimediaData attachments, + boolean showInCallButtonGrid) { super(fragmentManager); this.attachments = attachments; + this.showInCallButtonGrid = showInCallButtonGrid; } @Override public Fragment getItem(int position) { - if (position == getButtonGridPosition()) { + if (!showInCallButtonGrid) { + // TODO(calderwoodra): handle fragment invalidation for when the data changes. + return MultimediaFragment.newInstance( + attachments, true /* isInteractive */, false /* showAvatar */, false /* isSpam */); + + } else if (position == getButtonGridPosition()) { return InCallButtonGridFragment.newInstance(); + } else { - // TODO: handle fragment invalidation for when the data changes. - return MultimediaFragment.newInstance(attachments, true, false, false); + return MultimediaFragment.newInstance( + attachments, true /* isInteractive */, false /* showAvatar */, false /* isSpam */); } } @Override public int getCount() { - if (attachments != null - && (!TextUtils.isEmpty(attachments.getText()) || attachments.hasImageData())) { - return 2; + int count = 0; + if (showInCallButtonGrid) { + count++; + } + if (attachments != null && attachments.hasData()) { + count++; } - return 1; + Assert.checkArgument(count > 0, "InCallPager adapter doesn't have any pages."); + return count; } public void setAttachments(@Nullable MultimediaData attachments) { |