1.迁移到AndroidX

2.修改支持无限循环滑动
This commit is contained in:
leafwai
2022-02-17 15:40:13 +08:00
parent 334e6d26bd
commit 046e67bf78
17 changed files with 159 additions and 153 deletions

View File

@@ -5,14 +5,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
compileSdkVersion 31
defaultConfig {
applicationId "com.littlemango.stacklayoutmanagermaster"
minSdkVersion 19
targetSdkVersion 27
minSdkVersion 21
targetSdkVersion 31
versionCode 6
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
@@ -22,19 +22,19 @@ android {
}
}
ext.kotlin_version = '1.2.60'
ext.kotlin_version = '1.6.10'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation project(':StackLayoutManager')
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.material:material:1.5.0'
}

View File

@@ -1,13 +1,11 @@
package com.littlemango.stacklayoutmanagermaster
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
@@ -18,7 +16,7 @@ class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.littlemango.stacklayoutmanagermaster", appContext.packageName)
}
}

View File

@@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@@ -1,6 +1,5 @@
package com.littlemango.stacklayoutmanagermaster;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import com.littlemango.stacklayoutmanager.StackAnimation;

View File

@@ -1,11 +1,11 @@
package com.littlemango.stacklayoutmanagermaster;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,7 +15,7 @@ import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import com.littlemango.stacklayoutmanager.StackLayoutManager;
import com.littlemango.stacklayoutmanager.StackLayoutManager.ScrollOrientation;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@@ -66,22 +66,22 @@ public class MainActivity extends AppCompatActivity {
resetRandom();
break;
case 2:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.LEFT_TO_RIGHT);
mStackLayoutManager = new StackLayoutManager(StackLayoutManager.ScrollOrientation.LEFT_TO_RIGHT);
mRecyclerView.setLayoutManager(mStackLayoutManager);
getSupportActionBar().setTitle("Picture 0");
break;
case 3:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.RIGHT_TO_LEFT);
mStackLayoutManager = new StackLayoutManager(StackLayoutManager.ScrollOrientation.RIGHT_TO_LEFT);
mRecyclerView.setLayoutManager(mStackLayoutManager);
getSupportActionBar().setTitle("Picture 0");
break;
case 4:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.TOP_TO_BOTTOM);
mStackLayoutManager = new StackLayoutManager(StackLayoutManager.ScrollOrientation.TOP_TO_BOTTOM);
mRecyclerView.setLayoutManager(mStackLayoutManager);
getSupportActionBar().setTitle("Picture 0");
break;
case 5:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.BOTTOM_TO_TOP);
mStackLayoutManager = new StackLayoutManager(StackLayoutManager.ScrollOrientation.BOTTOM_TO_TOP);
mRecyclerView.setLayoutManager(mStackLayoutManager);
getSupportActionBar().setTitle("Picture 0");
break;

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<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"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -22,4 +22,4 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="270dp"
android:layout_height="400dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -17,4 +17,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="50sp"/>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>