diff --git a/J-Slider-debug.aar b/J-Slider-debug.aar deleted file mode 100644 index 409b585..0000000 Binary files a/J-Slider-debug.aar and /dev/null differ diff --git a/J-Slider-release.aar b/J-Slider-release.aar index 55c868d..948bc45 100644 Binary files a/J-Slider-release.aar and b/J-Slider-release.aar differ diff --git a/J-Slider/build.gradle.kts b/J-Slider/build.gradle.kts index df49557..5301169 100644 --- a/J-Slider/build.gradle.kts +++ b/J-Slider/build.gradle.kts @@ -42,7 +42,7 @@ afterEvaluate { register("release") { groupId = "com.github.Jumman04" artifactId = "Jummania-Slider" - version = "2.9(alpha)" + version = "4.0" afterEvaluate { from(components["release"]) diff --git a/J-Slider/src/main/java/com/jummania/JSlider.kt b/J-Slider/src/main/java/com/jummania/JSlider.kt index 8a583ac..2a44c5f 100644 --- a/J-Slider/src/main/java/com/jummania/JSlider.kt +++ b/J-Slider/src/main/java/com/jummania/JSlider.kt @@ -7,6 +7,7 @@ import android.graphics.Color import android.os.Handler import android.os.Looper import android.util.AttributeSet +import android.util.Log import android.view.Gravity import android.view.LayoutInflater import android.view.View @@ -139,100 +140,125 @@ class JSlider @JvmOverloads constructor( private lateinit var listener: OnSlideChangeListener init { - // Obtain styled attributes from XML - val typedArray: TypedArray = context.theme.obtainStyledAttributes( - attrs, R.styleable.JSlider, defStyleAttr, defStyleAttr - ) - - // Set sliding duration based on the attribute, default to 1555 milliseconds - setSlidingDuration( - typedArray.getInt(R.styleable.JSlider_slidingDuration, 1555).toLong() - ) - // Set indicator size based on the attribute, default to 30 pixels - setIndicatorSize( - typedArray.getDimensionPixelSize( - R.styleable.JSlider_indicatorSize, 30 + try { + // Obtain styled attributes from XML + val typedArray: TypedArray = context.theme.obtainStyledAttributes( + attrs, R.styleable.JSlider, defStyleAttr, defStyleAttr ) - ) - // Set padding for the slider based on left, top, right, and bottom attributes - setSliderPadding( - typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingLeft, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingTop, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingRight, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingBottom, 0) - ) + try { - // Enable or disable auto-sliding based on the attribute, default to true - enableAutoSliding(typedArray.getBoolean(R.styleable.JSlider_enableAutoSliding, true)) + // Set sliding duration based on the attribute, default to 1555 milliseconds + setSlidingDuration( + typedArray.getInt(R.styleable.JSlider_slidingDuration, 1555).toLong() + ) - // Enable or disable the indicator based on the attribute, default to true - enableIndicator(typedArray.getBoolean(R.styleable.JSlider_enableIndicator, true)) + // Set indicator size based on the attribute, default to 30 pixels + setIndicatorSize( + typedArray.getDimensionPixelSize( + R.styleable.JSlider_indicatorSize, 30 + ) + ) - // Set indicator colors based on the attributes, default to semi-transparent white and white - setIndicatorColor( - typedArray.getColor( - R.styleable.JSlider_defaultIndicatorColor, Color.parseColor("#90ffffff") - ), typedArray.getColor(R.styleable.JSlider_selectedIndicatorColor, Color.WHITE) - ) + // Set padding for the slider based on left, top, right, and bottom attributes + setSliderPadding( + typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingLeft, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingTop, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingRight, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_sliderPaddingBottom, 0) + ) - // Set padding for the indicator based on left, top, right, and bottom attributes - setIndicatorPadding( - typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingLeft, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingTop, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingRight, 0), - typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingBottom, 55) - ) + // Enable or disable auto-sliding based on the attribute, default to true + enableAutoSliding( + typedArray.getBoolean( + R.styleable.JSlider_enableAutoSliding, true + ) + ) - // Set horizontal margin for the indicator dots, default to 6 pixels - setIndicatorMarginHorizontal( - typedArray.getDimensionPixelSize( - R.styleable.JSlider_indicatorMarginHorizontal, 6 - ) - ) + // Enable or disable the indicator based on the attribute, default to true + enableIndicator(typedArray.getBoolean(R.styleable.JSlider_enableIndicator, true)) - // Set slide animation based on the specified attribute - setSlideAnimation( - AnimationTypes.values()[typedArray.getInt( - R.styleable.JSlider_slideAnimation, AnimationTypes.DEFAULT.ordinal - )] - ) + // Set indicator colors based on the attributes, default to semi-transparent white and white + setIndicatorColor( + typedArray.getColor( + R.styleable.JSlider_defaultIndicatorColor, Color.parseColor("#90ffffff") + ), typedArray.getColor(R.styleable.JSlider_selectedIndicatorColor, Color.WHITE) + ) - // Set indicator alignment based on the specified attribute - setIndicatorAlignment( - Alignment.values()[typedArray.getInt( - R.styleable.JSlider_indicatorAlignment, Alignment.BOTTOM.ordinal - )] - ) - // Set indicator gravity based on the specified attribute - setIndicatorGravity(typedArray.getInt(R.styleable.JSlider_indicatorGravity, Gravity.CENTER)) - - // Set indicator update mode based on the specified attribute - setIndicatorUpdateTypes( - UpdateTypes.values()[typedArray.getInt( - R.styleable.JSlider_indicatorUpdateMode, UpdateTypes.SYNC.ordinal - )] - ) + // Set padding for the indicator based on left, top, right, and bottom attributes + setIndicatorPadding( + typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingLeft, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingTop, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingRight, 0), + typedArray.getDimensionPixelSize(R.styleable.JSlider_indicatorPaddingBottom, 55) + ) - // Setting the indicator shape type for a JSlider. - // This assumes that there is an enum called ShapeTypes defined - // in the JSlider class or its associated class, which represents the available shape types. - - // Obtain a reference to the ShapeTypes enum and set the selected shape type based on the attributes - // specified in the XML layout using the R.styleable.JSlider_indicatorShapeTypes attribute. - // If the attribute is not defined, default to ShapeTypes.CIRCLE. - setIndicatorShapeTypes( - ShapeTypes.values()[typedArray.getInt( - R.styleable.JSlider_indicatorShapeTypes, ShapeTypes.CIRCLE.ordinal - )] - ) + // Set horizontal margin for the indicator dots, default to 6 pixels + setIndicatorMarginHorizontal( + typedArray.getDimensionPixelSize( + R.styleable.JSlider_indicatorMarginHorizontal, 6 + ) + ) + + // Set slide animation based on the specified attribute + setSlideAnimation( + AnimationTypes.values()[typedArray.getInt( + R.styleable.JSlider_slideAnimation, AnimationTypes.DEFAULT.ordinal + )] + ) + + // Set indicator alignment based on the specified attribute + setIndicatorAlignment( + Alignment.values()[typedArray.getInt( + R.styleable.JSlider_indicatorAlignment, Alignment.BOTTOM.ordinal + )] + ) + // Set indicator gravity based on the specified attribute + setIndicatorGravity( + typedArray.getInt( + R.styleable.JSlider_indicatorGravity, Gravity.CENTER + ) + ) + + // Set indicator update mode based on the specified attribute + setIndicatorUpdateTypes( + UpdateTypes.values()[typedArray.getInt( + R.styleable.JSlider_indicatorUpdateMode, UpdateTypes.SYNC.ordinal + )] + ) + + // Setting the indicator shape type for a JSlider. + // This assumes that there is an enum called ShapeTypes defined + // in the JSlider class or its associated class, which represents the available shape types. + + // Obtain a reference to the ShapeTypes enum and set the selected shape type based on the attributes + // specified in the XML layout using the R.styleable.JSlider_indicatorShapeTypes attribute. + // If the attribute is not defined, default to ShapeTypes.CIRCLE. + setIndicatorShapeTypes( + ShapeTypes.values()[typedArray.getInt( + R.styleable.JSlider_indicatorShapeTypes, ShapeTypes.CIRCLE.ordinal + )] + ) + + } finally { + // Recycle the TypedArray to avoid memory leaks + typedArray.recycle() + } + // Add the slider and indicator layout to the view + addView(jSlider) + addView(dotIndicatorLayout) + addView(selectedIndicatorLayout) + + } catch (e: Resources.NotFoundException) { + Log.e("JSlider Initialization", "Resource not found: ${e.message}") + e.printStackTrace() + } catch (e: Exception) { + Log.e("JSlider Initialization", "An unexpected error occurred: ${e.message}") + e.printStackTrace() + } - // Add the slider and indicator layout to the view - addView(jSlider) - addView(dotIndicatorLayout) - addView(selectedIndicatorLayout) } diff --git a/J-Slider/src/main/java/com/jummania/types/AnimationTypes.kt b/J-Slider/src/main/java/com/jummania/types/AnimationTypes.kt index c492469..c0bbfcd 100644 --- a/J-Slider/src/main/java/com/jummania/types/AnimationTypes.kt +++ b/J-Slider/src/main/java/com/jummania/types/AnimationTypes.kt @@ -51,8 +51,7 @@ import com.jummania.animations.ZoomOut */ enum class AnimationTypes( internal val reverse: Boolean = false, - internal val onGetAnim: (ViewPager) -> PageTransformer? -) { + internal val onGetAnim: (ViewPager) -> PageTransformer?) { ANTI_CLOCK_SPIN(false, { AntiClockSpin() }), BACKGROUND_TO_FOREGROUND(false, { BackgroundToForeground() }), CARD_STACK(false, { CardStack() }), diff --git a/J-Slider/src/main/java/com/jummania/widgets/Slider.kt b/J-Slider/src/main/java/com/jummania/widgets/Slider.kt index 6518e39..4087ad0 100644 --- a/J-Slider/src/main/java/com/jummania/widgets/Slider.kt +++ b/J-Slider/src/main/java/com/jummania/widgets/Slider.kt @@ -45,9 +45,9 @@ internal abstract class Slider(context: Context) : ViewPager(context) { widthMeasureSpec, MeasureSpec.makeMeasureSpec(child.measuredHeight, MeasureSpec.EXACTLY) ) - } else { - // If the height mode is EXACTLY or unspecified, use the original onMeasure + } else + // If the height mode is EXACTLY or unspecified, use the original onMeasure super.onMeasure(widthMeasureSpec, heightMeasureSpec) - } + } } diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2168df3..71b4e6b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "com.jummania.jummaniaslider" minSdk = 17 targetSdk = 34 - versionCode = 3 - versionName = "2.9(alpha)" + versionCode = 4 + versionName = "4.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -21,8 +21,7 @@ android { release { isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } @@ -42,7 +41,5 @@ dependencies { implementation("com.google.android.material:material:1.10.0") implementation(project(":J-Slider")) - implementation("com.squareup.picasso:picasso:2.8") - //./gradlew assembleRelease } \ No newline at end of file diff --git a/app/src/main/java/com/jummania/jummaniaslider/MainActivity.kt b/app/src/main/java/com/jummania/jummaniaslider/MainActivity.kt index 4bfc74b..554ecff 100644 --- a/app/src/main/java/com/jummania/jummaniaslider/MainActivity.kt +++ b/app/src/main/java/com/jummania/jummaniaslider/MainActivity.kt @@ -5,12 +5,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button -import android.widget.ImageView -import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.jummania.JSlider -import com.squareup.picasso.Picasso class MainActivity : AppCompatActivity() { @@ -122,21 +119,22 @@ class MainActivity : AppCompatActivity() { override fun onSliderCreate(view: View, position: Int) { + /* val textView: TextView = view.findViewById(R.id.text_view) //find your child val imageView: ImageView = view.findViewById(R.id.image_view) - Picasso.get() .load("https://jummania.com/App/BanglaNatokSamahar/Images/Cover%20Photo.jpg") .error(R.drawable.default_error).placeholder(R.drawable.default_loading) .into(imageView) - textView.text = getString(R.string.Developer_Name) + textView.text = getString(R.string.Developer_Name) - view.setOnClickListener { + */ + view.setOnClickListener { Toast.makeText( this@MainActivity, - getString(R.string.Developer_Name) + "\nItem Position: $position", + "Developer Name: ${getString(R.string.Developer_Name)}\nItem Position: $position", Toast.LENGTH_SHORT ).show() } diff --git a/app/src/main/res/drawable/img.png b/app/src/main/res/drawable/img.png new file mode 100644 index 0000000..faee230 Binary files /dev/null and b/app/src/main/res/drawable/img.png differ diff --git a/app/src/main/res/layout/item_slider2.xml b/app/src/main/res/layout/item_slider2.xml index 44fa61e..98a2d09 100644 --- a/app/src/main/res/layout/item_slider2.xml +++ b/app/src/main/res/layout/item_slider2.xml @@ -14,7 +14,8 @@ android:id="@+id/image_view" android:layout_width="match_parent" android:layout_height="180dp" - android:scaleType="centerCrop" /> + android:scaleType="centerCrop" + android:src="@drawable/img" /> diff --git a/jitpack.yml b/jitpack.yml index acc71b6..d961600 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -4,5 +4,5 @@ jdk: before_install: - ./scripts/prepareJitpackEnvironment.sh install: - - FILE="-Dfile=J-Slider-debug.aar" - - mvn install:install-file $FILE -DgroupId=com.github.Jumman04 -DartifactId=Jummania-Slider -Dversion=2.9(alpha) -Dpackaging=aar -DgeneratePom=true + - FILE="-Dfile=J-Slider-release.aar" + - mvn install:install-file $FILE -DgroupId=com.github.Jumman04 -DartifactId=Jummania-Slider -Dversion=4.0 -Dpackaging=aar -DgeneratePom=true diff --git a/pom.xml b/pom.xml index 7749b28..0fbc8fc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,13 @@ - + 4.0.0 com.github.Jumman04 Jummania-Slider - 2.9(alpha) + 4.0 pom - Empower Your UI with Seamless Slides: Introducing JSlider, the Universal Slider Library + Empower Your UI with Seamless Slides: Introducing JSlider, the Universal Slider + Library + \ No newline at end of file