Search in sources :

Example 6 with ViewPager

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);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Intent(android.content.Intent) ViewPager(androidx.viewpager.widget.ViewPager)

Example 7 with ViewPager

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());
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) App(org.fdroid.fdroid.data.App) FDroidApp(org.fdroid.fdroid.FDroidApp) ViewPager(androidx.viewpager.widget.ViewPager)

Example 8 with ViewPager

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));
}
Also used : Sprite(com.github.ybq.android.spinkit.sprite.Sprite) ViewGroup(android.view.ViewGroup) ViewPager(androidx.viewpager.widget.ViewPager) SpinKitView(com.github.ybq.android.spinkit.SpinKitView) TextView(android.widget.TextView) View(android.view.View) PagerAdapter(androidx.viewpager.widget.PagerAdapter) SuppressLint(android.annotation.SuppressLint) Style(com.github.ybq.android.spinkit.Style) TextView(android.widget.TextView) SpinKitView(com.github.ybq.android.spinkit.SpinKitView)

Example 9 with ViewPager

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;
}
Also used : AlertDialog(android.app.AlertDialog) ContentValues(android.content.ContentValues) JSONException(org.json.JSONException) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager) Button(android.widget.Button) TabLayout(com.google.android.material.tabs.TabLayout) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) SimpleDateFormat(java.text.SimpleDateFormat) NonNull(androidx.annotation.NonNull)

Example 10 with ViewPager

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;
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout) FrameLayout(android.widget.FrameLayout) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewPager(androidx.viewpager.widget.ViewPager) LinearLayout(android.widget.LinearLayout)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)68 View (android.view.View)24 Intent (android.content.Intent)12 TabLayout (com.google.android.material.tabs.TabLayout)12 Toolbar (androidx.appcompat.widget.Toolbar)11 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)9 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)9 ImageView (android.widget.ImageView)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 Bundle (android.os.Bundle)6 PagerAdapter (androidx.viewpager.widget.PagerAdapter)6 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)5 LinearInterpolator (android.view.animation.LinearInterpolator)4 NonNull (androidx.annotation.NonNull)4 FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4