kandi background
Explore Kits

cwac-pager | CWAC-Pager : Power to the PagerAdapter | Android library

 by   commonsguy Java Version: v0.2.6 License: Apache-2.0

 by   commonsguy Java Version: v0.2.6 License: Apache-2.0

Download this library from

kandi X-RAY | cwac-pager Summary

cwac-pager is a Java library typically used in Mobile, Android applications. cwac-pager has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.
NOTE: Work on this project is suspended, as the author has moved away from ViewPager to using RecyclerView as a pager. This repository will be made private on or after 1 July 2021. This project offers an ArrayPagerAdapter that offers another alternative PagerAdapter implementation for use with ViewPager.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • cwac-pager has a low active ecosystem.
  • It has 114 star(s) with 28 fork(s). There are 10 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 5 open issues and 10 have been closed. On average issues are closed in 19 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of cwac-pager is v0.2.6
cwac-pager Support
Best in #Android
Average in #Android
cwac-pager Support
Best in #Android
Average in #Android

quality kandi Quality

  • cwac-pager has 0 bugs and 0 code smells.
cwac-pager Quality
Best in #Android
Average in #Android
cwac-pager Quality
Best in #Android
Average in #Android

securitySecurity

  • cwac-pager has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • cwac-pager code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
cwac-pager Security
Best in #Android
Average in #Android
cwac-pager Security
Best in #Android
Average in #Android

license License

  • cwac-pager is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
cwac-pager License
Best in #Android
Average in #Android
cwac-pager License
Best in #Android
Average in #Android

buildReuse

  • cwac-pager releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • cwac-pager saves you 439 person hours of effort in developing the same functionality from scratch.
  • It has 1039 lines of code, 99 functions and 26 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
cwac-pager Reuse
Best in #Android
Average in #Android
cwac-pager Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi has reviewed cwac-pager and discovered the below as its top functions. This is intended to give you an instant insight into cwac-pager implemented functionality, and help decide if they suit your requirements.

  • This method is responsible for creating a new fragment .
    • Instantiate a new fragment .
      • helper method to set a selection item from the adapter
        • Sets the primary item .
          • Inserts a new page .
            • On create view .
              • Swap the current item
                • Create a new editor fragment .
                  • Writes the tag to the Parcel .
                    • Return the description .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      cwac-pager Key Features

                      This is version v0.2.6 of this module, meaning it is still pretty young.

                      cwac-pager Examples and Code Snippets

                      See all related Code Snippets

                      default

                      copy iconCopydownload iconDownload
                      repositories {
                          maven {
                              url "https://s3.amazonaws.com/repo.commonsware.com"
                          }
                      }
                      
                      dependencies {
                          compile 'com.commonsware.cwac:pager:0.2.6'
                      }

                      Creating and Populating the Adapter

                      copy iconCopydownload iconDownload
                      static class SamplePagerAdapter extends
                         ArrayPagerAdapter<EditorFragment> {

                      See all related Code Snippets

                      Community Discussions

                      Trending Discussions on cwac-pager
                      • App crash after adding another item - cwac-pager
                      Trending Discussions on cwac-pager

                      QUESTION

                      App crash after adding another item - cwac-pager

                      Asked 2018-Feb-04 at 16:26


                      I'm having trouble with adding another page to the cwac-pager's ArrayPagerAdapter (v4). I had to use that library because I wasn't able to add a new tab dynamically using the system PagerAdapter.
                      MainActivity.java:

                      public class MainActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener {
                      
                          private ViewPager viewPager;
                          private ArrayPagerAdapter pagerAdapter;
                          private TabLayout tabLayout;
                      
                          @Override
                          protected void onCreate(Bundle savedInstanceState) {
                              super.onCreate(savedInstanceState);
                              setContentView(R.layout.activity_main);
                      
                              setSupportActionBar((Toolbar) findViewById(R.id.app_toolbar));
                      
                              tabLayout = findViewById(R.id.tab_layout);
                              tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
                      
                              viewPager = findViewById(R.id.pager);
                              pagerAdapter = new CustomPagerAdapter(getSupportFragmentManager(), new ArrayList<PageDescriptor>());
                              viewPager.setAdapter(pagerAdapter);
                              viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
                              tabLayout.addOnTabSelectedListener(this);
                          }
                      
                          @Override
                          public void onStart() {
                              super.onStart();
                              pagerAdapter.add(new TestPageDescriptor());
                              tabLayout.addTab(tabLayout.newTab().setText("Hello"));
                              // Uncomment the following lines to make the app crash
                              pagerAdapter.add(new TestPageDescriptor()); // CRASH
                              tabLayout.addTab(tabLayout.newTab().setText("Hello2"));
                          }
                      
                          @Override
                          public void onStop() {
                              super.onStop();
                              // Remove all the tabs (required in my main application, not in this test)
                              tabLayout.removeAllTabs();
                              for (int i = 0; i < pagerAdapter.getCount(); i++) {
                                  pagerAdapter.remove(i);
                              }
                          }
                      
                          @Override
                          public void onTabSelected(TabLayout.Tab tab) {
                              viewPager.setCurrentItem(tab.getPosition());
                          }
                      
                          @Override
                          public void onTabUnselected(TabLayout.Tab tab) {
                      
                          }
                      
                          @Override
                          public void onTabReselected(TabLayout.Tab tab) {
                      
                          }
                      
                          private class CustomPagerAdapter extends ArrayPagerAdapter<Fragment> {
                      
                              CustomPagerAdapter(FragmentManager fragmentManager, List<PageDescriptor> descriptors) {
                                  super(fragmentManager, descriptors);
                              }
                      
                              @Override
                              protected Fragment createFragment(PageDescriptor desc) {
                                  return new TestFragment();
                              }
                          }
                      
                          private class TestPageDescriptor extends SimplePageDescriptor {
                      
                              TestPageDescriptor() {
                                  super("Test","TestHey");
                              }
                          }
                      }
                      

                      TestFragment.java:

                      public class TestFragment extends Fragment {
                      
                          @Override
                          public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                              return inflater.inflate(R.layout.test_frag, container, false);
                          }
                      }
                      

                      activity_main.xml:

                      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                          xmlns:app="http://schemas.android.com/apk/res-auto"
                          xmlns:tools="http://schemas.android.com/tools"
                          android:id="@+id/container"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          tools:context="me.test.myapplication.MainActivity"
                          android:orientation="vertical">
                      
                          <android.support.v7.widget.Toolbar
                              android:id="@+id/app_toolbar"
                              android:layout_width="match_parent"
                              android:layout_height="?attr/actionBarSize"
                              android:background="?attr/colorPrimary"
                              android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
                              app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                              app:title="@string/app_name" />
                      
                          <android.support.design.widget.TabLayout
                              android:id="@+id/tab_layout"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:background="?attr/colorPrimary"
                              android:elevation="4dp"
                              android:minHeight="?attr/actionBarSize"/>
                      
                          <android.support.v4.view.ViewPager
                              android:id="@+id/pager"
                              android:layout_width="match_parent"
                              android:layout_height="fill_parent" />
                      </LinearLayout>
                      

                      test_frag.xml: just a LinearLayout with a View, no matter which.

                      In MainActivity.java see the comments I added in onStart(): if you run the app with just one tab (last two lines of the method commented), the activity will start correctly. However, if you add another tab by uncommenting the lines, the app will crash immediately. What am I doing wrong?
                      Thanks

                      Edit: logcat

                      I/Process: Sending signal. PID: 3877 SIG: 9
                      Application terminated.
                      

                      No exceptions, no errors.

                      ANSWER

                      Answered 2018-Feb-04 at 16:26

                      The fragment tags need to be unique, as is covered in the library documentation. So, as Matt Clark pointed out, you need to use different tags for your different pages.

                      Note that you do not need to create your own subclass of SimplePageDescriptor, at least in the code from your question. You could just use SimplePageDescriptor directly.

                      Source https://stackoverflow.com/questions/48609986

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install cwac-pager

                      You can download it from GitHub.
                      You can use cwac-pager like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the cwac-pager component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      [The Busy Coder’s Guide to Android Development](https://commonsware.com/Android) contains two chapters covering ViewPager. The second chapter, on advanced ViewPager techniques, covers this library in depth.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Consider Popular Android Libraries
                      Try Top Libraries by commonsguy
                      Compare Android Libraries with Highest Support
                      Compare Android Libraries with Highest Quality
                      Compare Android Libraries with Highest Security
                      Compare Android Libraries with Permissive License
                      Compare Android Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.