use of androidx.viewpager.widget.PagerAdapter in project SmartTabLayout by ogaclejapan.
the class SmartTabLayout method populateTabStrip.
private void populateTabStrip() {
final PagerAdapter adapter = viewPager.getAdapter();
for (int i = 0; i < adapter.getCount(); i++) {
final View tabView = (tabProvider == null) ? createDefaultTabView(adapter.getPageTitle(i)) : tabProvider.createTabView(tabStrip, i, adapter);
if (tabView == null) {
throw new IllegalStateException("tabView is null.");
}
if (distributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}
if (internalTabClickListener != null) {
tabView.setOnClickListener(internalTabClickListener);
}
tabStrip.addView(tabView);
if (i == viewPager.getCurrentItem()) {
tabView.setSelected(true);
}
}
}
use of androidx.viewpager.widget.PagerAdapter in project xabber-android by redsolution.
the class ImageViewerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_viewer);
// get params
Intent intent = getIntent();
Bundle args = intent.getExtras();
if (args == null) {
finish();
return;
}
String imageUrl = args.getString(IMAGE_URL);
String messageId = args.getString(MESSAGE_ID);
int imagePosition = args.getInt(ATTACHMENT_POSITION);
// setup toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.inflateMenu(R.menu.menu_image_viewer);
toolbar.setOnMenuItemClickListener(this);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavUtils.navigateUpFromSameTask(ImageViewerActivity.this);
}
});
// get imageAttachments
Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
MessageItem messageItem = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, messageId).findFirst();
if (imageUrl != null) {
Attachment attachment = new Attachment();
attachment.setFileUrl(imageUrl);
imageAttachments.add(attachment);
} else {
RealmList<Attachment> attachments = messageItem.getAttachments();
for (Attachment attachment : attachments) {
if (attachment.isImage())
imageAttachments.add(attachment);
}
}
// get account jid
this.accountJid = messageItem.getAccount();
// find views
progressBar = findViewById(R.id.progressBar);
ivCancelDownload = findViewById(R.id.ivCancelDownload);
ivCancelDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onCancelDownloadClick();
}
});
viewPager = findViewById(R.id.viewPager);
PagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
Attachment attachment = imageAttachments.get(position);
return ImageViewerFragment.newInstance(attachment.getFilePath(), attachment.getFileUrl(), attachment.getUniqueId());
}
@Override
public int getCount() {
return imageAttachments.size();
}
};
viewPager.setAdapter(pagerAdapter);
viewPager.setCurrentItem(imagePosition);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
updateToolbar();
unsubscribeAttachmentState();
subscribeForAttachment(imageAttachments.get(position));
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
if (imageAttachments.size() > imagePosition)
subscribeForAttachment(imageAttachments.get(imagePosition));
}
use of androidx.viewpager.widget.PagerAdapter in project CircleIndicator by ongakuer.
the class CircleIndicator method createIndicators.
private void createIndicators() {
PagerAdapter adapter = mViewpager.getAdapter();
int count;
if (adapter == null) {
count = 0;
} else {
count = adapter.getCount();
}
createIndicators(count, mViewpager.getCurrentItem());
}
use of androidx.viewpager.widget.PagerAdapter in project UltimateRecyclerView by cymcsg.
the class SlidingTabLayout method populateTabStrip.
private void populateTabStrip() {
final PagerAdapter adapter = mViewPager.getAdapter();
final OnClickListener tabClickListener = new TabClickListener();
for (int i = 0; i < adapter.getCount(); i++) {
View tabView = null;
TextView tabTitleView = null;
if (mTabViewLayoutId != 0) {
// If there is a custom tab view layout id set, try and inflate it
tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
}
if (tabView == null) {
tabView = createDefaultTabView(getContext());
}
if (tabTitleView == null && TextView.class.isInstance(tabView)) {
tabTitleView = (TextView) tabView;
}
if (mDistributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}
tabTitleView.setText(adapter.getPageTitle(i));
tabView.setOnClickListener(tabClickListener);
String desc = mContentDescriptions.get(i, null);
if (desc != null) {
tabView.setContentDescription(desc);
}
mTabStrip.addView(tabView);
if (i == mViewPager.getCurrentItem()) {
tabView.setSelected(true);
}
}
}
use of androidx.viewpager.widget.PagerAdapter in project SeriesGuide by UweTrottmann.
the class SlidingTabLayout method populateTabStrip.
private void populateTabStrip() {
final PagerAdapter adapter = viewPager.getAdapter();
if (adapter == null)
return;
populateTabStrip(adapter.getCount(), position -> {
CharSequence titleOrNull = adapter.getPageTitle(position);
return titleOrNull == null ? "" : titleOrNull.toString();
});
}
Aggregations