Skip to content

Commit

Permalink
v1.1.1 Release (#7)
Browse files Browse the repository at this point in the history
* Add badge for release

* add explanations

* fixed badges position

* Fixed bug of using previous xml version

* Fixed layout bug

* Feature/sample (#4)

* Add Layout test

* Create sample app

* Create LICENSE

* Update README.md

* Update README.md

* Update README.md

* Modify SDK Version

* Add screenshot

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Add License badge

* Modify scroll listener

* Update README.md

* Add functions for adding listeners to the viewHolder

* Update README.md

* Update README.md

* Refactor based on Android Studio Lint

* Modified README
  • Loading branch information
seunghyukcho authored Jul 31, 2019
1 parent ba79463 commit 6752288
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 182 deletions.
86 changes: 86 additions & 0 deletions .idea/markdown-navigator.xml

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

3 changes: 3 additions & 0 deletions .idea/markdown-navigator/profiles_settings.xml

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

44 changes: 16 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.org/shhj1998/android-live-slider.svg?branch=master)](https://travis-ci.org/shhj1998/android-live-slider)
[![Jitpack](https://jitpack.io/v/shhj1998/android-live-slider.svg)](https://jitpack.io/#shhj1998/android-live-slider)
[![Downloads](https://jitpack.io/v/shhj1998/android-live-slider/month.svg)](https://jitpack.io/#shhj1998/android-live-slider)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Awesome Recyclerview library that supports live animations and auto swipe with ViewPager.
Expand All @@ -10,8 +11,7 @@ Awesome Recyclerview library that supports live animations and auto swipe with V
## Requirements

- Minimum SDK Version : 24
- Recommended SDK Version : 28

- Recommended SDK Version : 29

## Preview

Expand Down Expand Up @@ -80,7 +80,7 @@ data class ExampleItem (
#### Step 3. Implement your customer PagerAdapter by inheriting the abstract class `LiveSliderPagerAdapter`.

```kotlin
class ExamplePageAdapter : LiveSliderPagerAdapter<ExampleItem>() {
class ExamplePageAdapter : LiveSliderPagerAdapter<ExampleItem, String>() {
override fun createView(context: Context, container: ViewGroup, item: ExampleItem): View {
val inflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
// Create and connect the view xml you want to display in the viewPager.
Expand All @@ -99,6 +99,7 @@ class ExamplePageAdapter : LiveSliderPagerAdapter<ExampleItem>() {
view.image.startAnimation(AnimationUtils.loadAnimation(context, R.anim.zoom))
...
}

override fun stopAnimation(context: Context, view: View) {
view.image.clearAnimation()
...
Expand All @@ -113,7 +114,7 @@ mRecyclerView = findViewById(R.id.recycler_view)
...

// definition of your recyclerview adapter
mExampleAdapter = LiveSliderAdapter(ExamplePageAdapter(), true)
mExampleAdapter = LiveSliderAdapter(applicationContext, ExamplePageAdapter(), true)
mExampleAdapter.setHasStableIds(true)

mRecyclerView.adapter = mExampleAdapter
Expand All @@ -122,45 +123,32 @@ mRecyclerView.adapter = mExampleAdapter
mRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
var animationItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition()

if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (animationItemPosition == NO_POSITION) {
val firstItemPosition = layoutManager.findFirstVisibleItemPosition()
val lastItemPosition = layoutManager.findLastVisibleItemPosition()
val firstView = layoutManager.findViewByPosition(firstItemPosition)
val lastView = layoutManager.findViewByPosition(lastItemPosition)

animationItemPosition = when {
firstItemPosition == NO_POSITION -> lastItemPosition
lastItemPosition == NO_POSITION -> firstItemPosition
(firstView!!.bottom - recycler_view.top) >= (recycler_view.bottom - lastView!!.top) -> firstItemPosition
else -> lastItemPosition
}
}

// Only execute the animations that you are looking at.
mFeedAdapter.startAnimation(animationItemPosition)

if(newState == RecyclerView.SCROLL_STATE_IDLE) {
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
val animationItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition()

mExampleAdapter.startAnimation(animationItemPosition)
}
}
})
```

#### Step 5. Set your recyclerview data with your contents.
When you call the `setData()` function with parsed contents data, it applies directly to the `live-slider` recyclerview.

When you call the `setFeedData()` function with parsed contents data, it applies immediately to the `live-slider` recyclerview.

```kotlin
var mSampleData: Array<LiveSliderFeed<ExampleItem>>
var mSampleData: Array<LiveSliderFeed<ExampleItem, String>>

...

mExampleAdapter!!.setData(mSampleData)
mExampleAdapter!!.setFeedData(mSampleData)
```

**Finish!**

More details are in our [example project](app).
More details are in our [example project](app). Also, if you want to add listeners to category title like touch, you can see our other [example application](https://github.com/Park-Wonbin/android-rss-viewer).


## License
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.github.poscat.liveslider.example"
minSdkVersion 24
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.poscat.liveslider.example

import android.graphics.BitmapFactory
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.poscat.liveslider.LiveSliderAdapter
Expand All @@ -14,7 +14,7 @@ class MainActivity : AppCompatActivity() {
* Define the RecyclerView and the CustomAdapter.
*/
private lateinit var mRecyclerView: RecyclerView
private lateinit var mExampleAdapter: ExampleRecyclerViewAdapter
private lateinit var mExampleAdapter: LiveSliderAdapter<ExampleItem, String>

/**
* This is sample data.
Expand Down Expand Up @@ -92,7 +92,7 @@ class MainActivity : AppCompatActivity() {
/**
* Create CustomAdapter.
*/
mExampleAdapter = ExampleRecyclerViewAdapter(applicationContext, ExamplePagerAdapter())
mExampleAdapter = LiveSliderAdapter(applicationContext, ExamplePagerAdapter(), true)
mExampleAdapter.setHasStableIds(true)

mRecyclerView.adapter = mExampleAdapter
Expand All @@ -103,23 +103,10 @@ class MainActivity : AppCompatActivity() {
*/
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
var animationItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition()

if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (animationItemPosition == RecyclerView.NO_POSITION) {
val firstItemPosition = layoutManager.findFirstVisibleItemPosition()
val lastItemPosition = layoutManager.findLastVisibleItemPosition()
val firstView = layoutManager.findViewByPosition(firstItemPosition)
val lastView = layoutManager.findViewByPosition(lastItemPosition)

animationItemPosition = when {
firstItemPosition == RecyclerView.NO_POSITION -> lastItemPosition
lastItemPosition == RecyclerView.NO_POSITION -> firstItemPosition
(firstView!!.bottom - mRecyclerView.top) >= (mRecyclerView.bottom - lastView!!.top) -> firstItemPosition
else -> lastItemPosition
}
}

if(newState == RecyclerView.SCROLL_STATE_IDLE) {
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
val animationItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition()

mExampleAdapter.startAnimation(animationItemPosition)
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout/example_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/default_img"/>
android:src="@drawable/default_img"
android:contentDescription="thumbnail" />

<TextView
android:id="@+id/title"
android:text="Title"
android:textSize="17dp"
android:textSize="17sp"
android:textStyle="bold"
android:textColor="#fff"
android:layout_width="wrap_content"
Expand All @@ -24,14 +25,14 @@
android:shadowRadius="1.0"
android:shadowDx="1.0"
android:shadowDy="1.0"
android:layout_gravity="left|bottom"
android:layout_gravity="start|bottom"
android:layout_margin="15dp"/>

<TextView
android:id="@+id/description"
android:bufferType="spannable"
android:text="Description"
android:textSize="15dp"
android:textSize="15sp"
android:textColor="#fff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
6 changes: 3 additions & 3 deletions liveslider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.shhj1998'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 24
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"

Expand All @@ -34,7 +34,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.core:core-ktx:+"
implementation "androidx.core:core-ktx:1.0.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
Expand Down
Loading

0 comments on commit 6752288

Please sign in to comment.