Skip to content

Commit

Permalink
Updated library for minimum API level 21 support and updated dependen…
Browse files Browse the repository at this point in the history
…cies for newer project support
  • Loading branch information
VijayMakwana committed Aug 13, 2022
1 parent a139717 commit 85aabd7
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 153 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 22 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# EasyPagerAdapter [![](https://jitpack.io/v/VijayMakwana/EasyPagerAdapter.svg)](https://jitpack.io/#VijayMakwana/EasyPagerAdapter) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg)](https://opensource.org/licenses/Apache-2.0)

**Easiest android ViewPager adapter implementation, Don't write ViewPager adapter ever again**
Expand All @@ -12,6 +10,8 @@

- No need to modify your model classes

- Minimum API Level support 21

- Supports multiple item view types

- Optional Callbacks/Listeners
Expand All @@ -26,43 +26,45 @@

- Support ViewPager2


## Setup

Migrate the project to AndroidX, do the following steps for migration
Refactor -> Migrate to AndroidX
## Setup

Migrate the project to AndroidX, do the following steps for migration
Refactor -> Migrate to AndroidX

### Gradle
### Gradle

Add this in your project level `build.gradle` file (**not** your module `build.gradle` file):
Add this in your project level `build.gradle` file (**not** your module `build.gradle` file):

```gradle
allprojects {
repositories {
repositories {
maven { url "https://jitpack.io" } // add this line
}
}
```

Then, add the library to your module `build.gradle`
Then, add the library to your module `build.gradle`

```
// apply plugin: 'kotlin-kapt' // this line only for Kotlin projects
android {
...
dataBinding.enabled true
buildFeatures {
dataBinding true
}
}
dependencies {
implementation 'com.github.VijayMakwana:EasyPagerAdapter:1.0.4'
implementation 'com.github.VijayMakwana:EasyPagerAdapter:1.1.0'
}
```

## Usage
## Usage

Create your item layouts with `<layout>` as root:
Create your item layouts with `<layout>` as root:

```xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
Expand Down Expand Up @@ -95,14 +97,14 @@
.into(mBinding.viewPager);
```

### If you want to attach callbacks or listeners then you can do like this
### If you want to attach callbacks or listeners then you can do like this

```kotlin
// Kotlin sample
mBinding.viewPager.setEasyPagerAdapter(mPageList)
.map<ImageModel>(R.layout.item_view_pager_image, BR.item)
.map<PersonDetail, ItemViewPagerPersonDetailBinding>
(R.layout.item_view_pager_person_detail, BR.person)
(R.layout.item_view_pager_person_detail, BR.person)
{ itemBind ->
itemBind.btnSubmit.setOnClickListener {
Toast.makeText(this@KotlinDemoActivity,
Expand All @@ -126,7 +128,7 @@
public void onClick(View view) {
Toast.makeText(JavaDemoActivity.this,
"Submit Button Clicked in the Person " +
itemBind.getPerson().getName() +
itemBind.getPerson().getName() +
" Page", Toast.LENGTH_LONG).show();
}
});
Expand All @@ -135,29 +137,29 @@
.into(mBinding.viewPager);
```

### **set fragment pager adapter**
### **set fragment pager adapter**

```kotlin
mBinding.viewPager.setEasyFragmentPagerAdapter
(supportFragmentManager, listOf(FragmentA(), FragmentB()))
```

### **set fragment state pager adapter**
### **set fragment state pager adapter**

```kotlin
mBinding.viewPager.setEasyFragmentStatePagerAdapter
(supportFragmentManager, listOf(FragmentA(), FragmentB()))
```

### **set viewpager2 fragment state adapter**
### **set viewpager2 fragment state adapter**

```kotlin
// ViewPager2
mBinding.viewPager2.setEasyFragmentStateAdapter(fragmmentActivity, listOf(FragmentA(), FragmentB(),FragmentC(), FragmentD()))
```

**Check out the wiki for detailed documentation and usage examples.**
**Check out the wiki for detailed documentation and usage examples.**

[Wiki](https://github.com/VijayMakwana/EasyPagerAdapter/wiki)
[Wiki](https://github.com/VijayMakwana/EasyPagerAdapter/wiki)

> Special thanks to [LastAdapter](https://github.com/nitrico/LastAdapter) by [@Miguel Ángel Moreno](https://github.com/nitrico) for inspiring this library
> Special thanks to [LastAdapter](https://github.com/nitrico/LastAdapter) by [@Miguel Ángel Moreno](https://github.com/nitrico) for inspiring this library
56 changes: 32 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}

android {
compileSdkVersion 29
compileSdk 32

defaultConfig {
applicationId "com.easypageradapter.easypageradaptersample"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
minSdk 21
targetSdk 32
versionCode 2
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true
buildFeatures {
dataBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':easypageradapter')
}
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.ViewPager2Activity"></activity>
<activity android:name=".ui.MainActivity">
<activity android:name=".ui.ViewPager2Activity"/>
<activity android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class KotlinDemoActivity : AppCompatActivity() {

private lateinit var mBinding: ActivityKotlinDemoBinding

private val mImageList = listOf<ImageModel>(
private val mImageList = listOf(
ImageModel(R.drawable.image_1, "Android"),
ImageModel(R.drawable.image_2, "Google Android"),
ImageModel(R.drawable.image_3, "Happy Android"),
ImageModel(R.drawable.image_4, "Noty Android"))

private val mPageList = listOf<Any>(
private val mPageList = listOf(
ImageModel(
image = R.drawable.image_1,
name = "Android"),
Expand Down
Loading

0 comments on commit 85aabd7

Please sign in to comment.