diff options
Diffstat (limited to 'java/com/android/incallui/incall/impl')
-rw-r--r-- | java/com/android/incallui/incall/impl/InCallFragment.java | 7 | ||||
-rw-r--r-- | java/com/android/incallui/incall/impl/InCallPagerAdapter.java | 29 |
2 files changed, 27 insertions, 9 deletions
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index 7e39ceb40..f9abf2044 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -241,7 +241,7 @@ public class InCallFragment extends Fragment @Override public void setPrimary(@NonNull PrimaryInfo primaryInfo) { LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString()); - setAdapterMedia(primaryInfo.multimediaData); + setAdapterMedia(primaryInfo.multimediaData, primaryInfo.showInCallButtonGrid); contactGridManager.setPrimary(primaryInfo); if (primaryInfo.shouldShowLocation) { @@ -267,9 +267,10 @@ public class InCallFragment extends Fragment } } - private void setAdapterMedia(MultimediaData multimediaData) { + private void setAdapterMedia(MultimediaData multimediaData, boolean showInCallButtonGrid) { if (adapter == null) { - adapter = new InCallPagerAdapter(getChildFragmentManager(), multimediaData); + adapter = + new InCallPagerAdapter(getChildFragmentManager(), multimediaData, showInCallButtonGrid); pager.setAdapter(adapter); } else { adapter.setAttachments(multimediaData); diff --git a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java index d4b04feff..ead35344f 100644 --- a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java +++ b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java @@ -21,6 +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 com.android.dialer.common.Assert; import com.android.dialer.multimedia.MultimediaData; import com.android.incallui.sessiondata.MultimediaFragment; @@ -28,28 +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(calderwoodra): 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() { + int count = 0; + if (showInCallButtonGrid) { + count++; + } if (attachments != null && attachments.hasData()) { - return 2; + count++; } - return 1; + Assert.checkArgument(count > 0, "InCallPager adapter doesn't have any pages."); + return count; } public void setAttachments(@Nullable MultimediaData attachments) { |