Skip to content

Commit

Permalink
Merge pull request #1 from Aftermoon-dev/1.1.0-beta2
Browse files Browse the repository at this point in the history
Release 1.1.0-beta2
  • Loading branch information
Aftermoon-dev authored Dec 26, 2021
2 parents ac39a18 + 0083bda commit aeaa165
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .idea/misc.xml

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

42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<h1 align="center">SlideActionLayout</h1>

<p align="center">
<a href="https://android-arsenal.com/api?level=16"><img alt="API" src="https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat"/></a>
<a href="http://www.apache.org/licenses/LICENSE-2.0"><img alt="License" src="https://img.shields.io/github/license/Aftermoon-dev/SlideActionLayout"></a>
<a href="https://github.com/Aftermoon-dev/SlideActionLayout"><img alt="Github Stars" src="https://img.shields.io/github/stars/Aftermoon-dev/SlideActionLayout?style=social"></a>
<a href="https://android-arsenal.com/api?level=16"><img alt="API" src="https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat"/></a>
<a href="https://jitpack.io/#Aftermoon-dev/SlideActionLayout"><img alt="Jitpack Version" src="https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg"></a>
</p>

<a href="https://github.com/Aftermoon-dev/SlideActionLayout/actions/workflows/android.yml"><img alt="Build" src="https://img.shields.io/github/workflow/status/Aftermoon-dev/SlideActionLayout/Android%20CI"></a>
<a href="https://github.com/Aftermoon-dev/SlideActionLayout"><img alt="Github Stars" src="https://img.shields.io/github/stars/Aftermoon-dev/SlideActionLayout?style=social"></a>
<p align="center">
Simple SlideView Layout Library with Fragment, ViewPager2 for Android
</p>

# Screenshots
<p align="center">
<img src="https://user-images.githubusercontent.com/3215313/116183122-4dd99d80-a758-11eb-8924-f6d61c33c782.png" width="30%">
<img src="https://user-images.githubusercontent.com/3215313/116183433-ce000300-a758-11eb-8bdf-a2e146ddcb7c.png" width="30%">
<img src="https://user-images.githubusercontent.com/3215313/116183125-4f0aca80-a758-11eb-92ec-51002fe9676a.png" width="30%">
<img src="https://user-images.githubusercontent.com/3215313/147399993-6d3815c9-96e7-4deb-8770-b92b80d7c98d.png" width="30%">
<img src="https://user-images.githubusercontent.com/3215313/147399994-c45ffb1b-52fe-4cfa-a7bf-814d70dc26a6.png" width="30%">
<img src="https://user-images.githubusercontent.com/3215313/147399995-a9e9f177-5606-4430-8a84-17a6f988caf0.png" width="30%">
</p>

# Download

1. Add JitPack Repository to Your Project `build.gradle` File
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
2. Add `SlideActionLayout` Dependency to Your Module `build.gradle` File (`VERSION` need change to Last Release Below)

[![](https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg)](https://jitpack.io/#Aftermoon-dev/SlideActionLayout)
```
dependencies {
implementation 'com.github.Aftermoon-dev:SlideActionLayout:VERSION'
}
}
```

2. Add `SlideActionLayout` Dependency to Your Module `build.gradle` File ([![](https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg)](https://jitpack.io/#Aftermoon-dev/SlideActionLayout))
```
dependencies {
implementation 'com.github.Aftermoon-dev:SlideActionLayout:Tag'
}
```
```

# Usage
Will be Later
Expand Down
4 changes: 2 additions & 2 deletions SlideActionLayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ afterEvaluate {
release(MavenPublication) {
from components.release
groupId = 'com.github.Aftermoon-dev.SlideActionLayout'
version = '1.1.0-beta1'
version = '1.1.0-beta2'
}

debug(MavenPublication) {
from components.debug
groupId = 'com.github.Aftermoon-dev.SlideActionLayout'
version = '1.1.0-beta1'
version = '1.1.0-beta2'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import androidx.core.view.ViewCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
Expand Down Expand Up @@ -111,6 +112,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
}
}


/**
* Add Image Fragment
* @param drawable Drawable Type Image
Expand All @@ -122,7 +124,18 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
}

/**
* Add Fragment Fragments
* Add Image Fragment with Image Scale Type
* @param drawable Drawable Type Image
* @param scaleType ImageView ScaleType
*/
fun addImageFragment(drawable: Drawable, scaleType: ImageView.ScaleType) {
checkInitial()
val imageFragment = ImageFragment.newInstance(drawable, scaleType)
slideActionAdapter!!.addFragment(imageFragment)
}

/**
* Add Image Fragments
* @param drawables Drawables ArrayList
*/
fun addDrawableFragments(drawables: ArrayList<Drawable>) {
Expand All @@ -133,6 +146,20 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
}
}


/**
* Add Image Fragments with Image Scale Type
* @param drawables Drawables ArrayList
* @param scaleType ImageView ScaleType
*/
fun addDrawableFragments(drawables: ArrayList<Drawable>, scaleType: ImageView.ScaleType) {
checkInitial()

for (i in 0..drawables.size) {
slideActionAdapter!!.addFragment(ImageFragment.newInstance(drawables[i], scaleType))
}
}

/**
* Add Image Fragment
* @param bitmap Bitmap Type Image
Expand All @@ -143,6 +170,17 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
slideActionAdapter!!.addFragment(imageFragment)
}

/**
* Add Image Fragment with Image Scale Type
* @param bitmap Bitmap Type Image
* @param scaleType ImageView ScaleType
*/
fun addImageFragment(bitmap: Bitmap, scaleType: ImageView.ScaleType) {
checkInitial()
val imageFragment = ImageFragment.newInstance(bitmap, scaleType)
slideActionAdapter!!.addFragment(imageFragment)
}

/**
* Add Bitmap Fragments
* @param bitmaps Bitmap ArrayList
Expand All @@ -155,6 +193,19 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
}
}

/**
* Add Bitmap Fragments with Scale Type
* @param bitmaps Bitmap ArrayList
* @param scaleType ImageView ScaleType
*/
fun addBitmapFragments(bitmaps: ArrayList<Bitmap>, scaleType: ImageView.ScaleType) {
checkInitial()

for (i in 0..bitmaps.size) {
slideActionAdapter!!.addFragment(ImageFragment.newInstance(bitmaps[i], scaleType))
}
}

/**
* Add Fragment
* @param fragment New Fragment
Expand Down Expand Up @@ -275,7 +326,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
autoSlideHandler!!.postDelayed(object : Runnable {
override fun run() {
if(slideActionAdapter != null && autoSlideEnabled) {
if(viewPager.currentItem < slideActionAdapter!!.itemCount) {
if(viewPager.currentItem < slideActionAdapter!!.itemCount - 1) {
viewPager.currentItem = viewPager.currentItem + 1
}
else {
Expand All @@ -290,7 +341,6 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
else {
if (autoSlideHandler != null) {
autoSlideHandler!!.removeCallbacksAndMessages(null)
autoSlideHandler = null
}
}
}
Expand All @@ -299,7 +349,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
* Get Current State of Auto Slide
* @return Enabled or Disabled Auto Slide
*/
fun getEnableAutoSlide(): Boolean = autoSlideEnabled
fun isEnableAutoSlide(): Boolean = autoSlideEnabled

/**
* Check Initial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.StateListDrawable
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.BlendModeColorFilterCompat
Expand All @@ -36,7 +37,7 @@ class CreateIndicator {
* @param selectedColor Selected Circle Fill Color Value (argb)
* @param unselectedColor Unselected Circle Fill Color Value (argb)
*/
fun createCircleIndicator(context: Context, selectedColor: Int, unselectedColor: Int): StateListDrawable {
fun createCircleIndicator(context: Context, @ColorInt selectedColor: Int, @ColorInt unselectedColor: Int): StateListDrawable {
val stateListDrawable = StateListDrawable()

val dotLayout = ResourcesCompat.getDrawable(context.resources, R.drawable.selected_dot, null) as LayerDrawable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ImageFragment: Fragment() {
super.onViewCreated(view, savedInstanceState)
arguments?.let {
bitmap = it.getParcelable("image")
scaleType = it.getSerializable("scaleType") as ImageView.ScaleType
scaleType = it.getSerializable("scaleType") as ImageView.ScaleType?

if(bitmap != null) {
Log.d(this.javaClass.simpleName, "Image Success")
Expand Down
19 changes: 16 additions & 3 deletions app/src/main/java/dev/aftermoon/slideaction_demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package dev.aftermoon.slideaction_demo

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.Gravity
import android.widget.Button
import androidx.core.content.ContextCompat
import androidx.viewpager2.widget.ViewPager2
import dev.aftermoon.slideactionlayout.SlideActionLayout
Expand All @@ -42,5 +40,20 @@ class MainActivity : AppCompatActivity() {
ContextCompat.getDrawable(this, R.drawable.second)?.let { layout.addImageFragment(it) }
ContextCompat.getDrawable(this, R.drawable.third)?.let { layout.addImageFragment(it) }
layout.addFragment(TestFragment())

layout.setAutoSlide(3000, true)

val btn = findViewById<Button>(R.id.btn_autoslide)

btn.setOnClickListener {
if (layout.isEnableAutoSlide()) {
btn.text = getString(R.string.autoslide_on)
layout.setEnableAutoSlide(false)
}
else {
btn.text = getString(R.string.autoslide_off)
layout.setEnableAutoSlide(true)
}
}
}
}
9 changes: 8 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
<dev.aftermoon.slideactionlayout.SlideActionLayout
android:id="@+id/slideactionlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="500dp">

</dev.aftermoon.slideactionlayout.SlideActionLayout>

<Button
android:id="@+id/btn_autoslide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/autoslide_off" />

</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<resources>
<string name="app_name">SlideActionLayout_Demo</string>
<string name="autoslide_on">Enable Auto Slide</string>
<string name="autoslide_off">Disable Auto Slide</string>
</resources>

0 comments on commit aeaa165

Please sign in to comment.