use of androidx.viewpager.widget.ViewPager in project Gadgetbridge by Freeyourgadget.
the class AppManagerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragmentappmanager);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
}
if (mGBDevice == null) {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
assert fab != null;
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, READ_REQUEST_CODE);
}
});
// Set up the ViewPager with the sections adapter.
ViewPager viewPager = (ViewPager) findViewById(R.id.appmanager_pager);
if (viewPager != null) {
viewPager.setAdapter(getPagerAdapter());
}
}
use of androidx.viewpager.widget.ViewPager 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.ViewPager in project CircleIndicator by ongakuer.
the class DefaultFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
ViewPager viewpager = view.findViewById(R.id.viewpager);
CircleIndicator indicator = view.findViewById(R.id.indicator);
viewpager.setAdapter(new SamplePagerAdapter());
indicator.setViewPager(viewpager);
viewpager.setCurrentItem(2);
}
use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.
the class CustomAnimationFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
int indicatorWidth = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()) + 0.5f);
int indicatorHeight = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()) + 0.5f);
int indicatorMargin = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics()) + 0.5f);
ViewPager viewpager = view.findViewById(R.id.viewpager);
CircleIndicator indicator = view.findViewById(R.id.indicator);
Config config = new Config.Builder().width(indicatorWidth).height(indicatorHeight).margin(indicatorMargin).animator(R.animator.indicator_animator).animatorReverse(R.animator.indicator_animator_reverse).drawable(R.drawable.black_radius_square).build();
indicator.initialize(config);
viewpager.setAdapter(new SamplePagerAdapter());
indicator.setViewPager(viewpager);
}
use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.
the class SnackbarBehaviorFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
ViewPager viewpager = view.findViewById(R.id.viewpager);
CircleIndicator indicator = view.findViewById(R.id.indicator);
viewpager.setAdapter(new SamplePagerAdapter());
indicator.setViewPager(viewpager);
mSnackbar = Snackbar.make(view.findViewById(R.id.coordinator_layout), "Snackbar", Snackbar.LENGTH_SHORT);
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mSnackbar.isShown()) {
mSnackbar.show();
} else {
mSnackbar.dismiss();
}
}
});
}
Aggregations