use of androidx.viewpager.widget.ViewPager in project Slide by ccrama.
the class Album method onCreate.
public void onCreate(Bundle savedInstanceState) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstanceState);
getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
setContentView(R.layout.album);
// Keep the screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (getIntent().hasExtra(SUBREDDIT)) {
this.subreddit = getIntent().getExtras().getString(SUBREDDIT);
}
if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) {
this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE);
}
final ViewPager pager = (ViewPager) findViewById(R.id.images);
album = new AlbumPagerAdapter(getSupportFragmentManager());
pager.setAdapter(album);
pager.setCurrentItem(1);
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == 0 && positionOffsetPixels == 0) {
finish();
}
if (position == 0 && ((AlbumPagerAdapter) pager.getAdapter()).blankPage != null) {
if (((AlbumPagerAdapter) pager.getAdapter()).blankPage != null) {
((AlbumPagerAdapter) pager.getAdapter()).blankPage.doOffset(positionOffset);
}
((AlbumPagerAdapter) pager.getAdapter()).blankPage.realBack.setBackgroundColor(Palette.adjustAlpha(positionOffset * 0.7f));
}
}
});
if (!Reddit.appRestart.contains("tutorialSwipe")) {
startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
}
}
use of androidx.viewpager.widget.ViewPager in project fdroidclient by f-droid.
the class ScreenShotsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
FDroidApp fdroidApp = (FDroidApp) getApplication();
fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenshots);
String packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME);
int startPosition = getIntent().getIntExtra(EXTRA_START_POSITION, 0);
App app = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
String[] screenshots = app.getAllScreenshots(this);
ViewPager viewPager = (ViewPager) findViewById(R.id.screenshot_view_pager);
ScreenShotPagerAdapter adapter = new ScreenShotPagerAdapter(getSupportFragmentManager(), screenshots);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(startPosition);
// display some nice animation while swiping
viewPager.setPageTransformer(true, new DepthPageTransformer());
}
use of androidx.viewpager.widget.ViewPager in project Android-SpinKit by ybq.
the class DetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPager.setOffscreenPageLimit(0);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return Style.values().length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_pager, null);
SpinKitView spinKitView = (SpinKitView) view.findViewById(R.id.spin_kit);
TextView name = (TextView) view.findViewById(R.id.name);
Style style = Style.values()[position];
name.setText(style.name().toLowerCase());
Sprite drawable = SpriteFactory.create(style);
spinKitView.setIndeterminateDrawable(drawable);
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int color = (int) ArgbEvaluator.getInstance().evaluate(positionOffset, colors[position % colors.length], colors[(position + 1) % colors.length]);
getWindow().getDecorView().setBackgroundColor(color);
}
@Override
public void onPageSelected(int position) {
getWindow().getDecorView().setBackgroundColor(colors[position % colors.length]);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewPager.setCurrentItem(getIntent().getIntExtra("position", 0));
}
use of androidx.viewpager.widget.ViewPager in project aware-client by denzilferreira.
the class ESM_DateTime method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
datePicked = Calendar.getInstance();
View ui = inflater.inflate(R.layout.esm_datetime, null);
builder.setView(ui);
esm_dialog = builder.create();
esm_dialog.setCanceledOnTouchOutside(false);
try {
TextView esm_title = (TextView) ui.findViewById(R.id.esm_title);
esm_title.setText(getTitle());
TextView esm_instructions = (TextView) ui.findViewById(R.id.esm_instructions);
esm_instructions.setText(getInstructions());
final ViewPager datetimePager = (ViewPager) ui.findViewById(R.id.datetimepager);
DateTimePagerAdapter dateTimePagerAdapter = new DateTimePagerAdapter(getContext());
datetimePager.setAdapter(dateTimePagerAdapter);
datetimePager.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
final TabLayout tabLayout = ui.findViewById(R.id.datetimetabs);
tabLayout.setupWithViewPager(datetimePager, true);
Button cancel_text = (Button) ui.findViewById(R.id.esm_cancel);
cancel_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
esm_dialog.cancel();
}
});
Button submit_number = (Button) ui.findViewById(R.id.esm_submit);
submit_number.setText(getSubmitButton());
submit_number.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
ContentValues rowData = new ContentValues();
rowData.put(ESM_Provider.ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
rowData.put(ESM_Provider.ESM_Data.ANSWER, dateFormat.format(datePicked.getTime()));
rowData.put(ESM_Provider.ESM_Data.STATUS, ESM.STATUS_ANSWERED);
getActivity().getContentResolver().update(ESM_Provider.ESM_Data.CONTENT_URI, rowData, ESM_Provider.ESM_Data._ID + "=" + getID(), null);
Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
answer.putExtra(ESM.EXTRA_ANSWER, rowData.getAsString(ESM_Provider.ESM_Data.ANSWER));
getActivity().sendBroadcast(answer);
if (Aware.DEBUG)
Log.d(Aware.TAG, "Answer:" + rowData.toString());
esm_dialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
return esm_dialog;
}
use of androidx.viewpager.widget.ViewPager in project android_packages_apps_Settings by omnirom.
the class ProfileSelectFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
final Activity activity = getActivity();
final int selectedTab = convertPosition(getTabId(activity, getArguments()));
final View tabContainer = mContentView.findViewById(R.id.tab_container);
final ViewPager viewPager = tabContainer.findViewById(R.id.view_pager);
viewPager.setAdapter(new ProfileSelectFragment.ViewPagerAdapter(this));
final TabLayout tabs = tabContainer.findViewById(R.id.tabs);
tabs.setupWithViewPager(viewPager);
setupTabTextColor(tabs);
tabContainer.setVisibility(View.VISIBLE);
final TabLayout.Tab tab = tabs.getTabAt(selectedTab);
tab.select();
final FrameLayout listContainer = mContentView.findViewById(android.R.id.list_container);
listContainer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
final RecyclerView recyclerView = getListView();
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
Utils.setActionBarShadowAnimation(activity, getSettingsLifecycle(), recyclerView);
return mContentView;
}
Aggregations