Skip to content

Commit

Permalink
适配 androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomsh committed May 31, 2019
1 parent 5c7371a commit 399d377
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 56 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ repositories {
}
dependencies{
implementation 'com.github.wenchaosong:Banner:2.3.11'
// 或者
implementation('com.github.wenchaosong:Banner:2.3.11') {
exclude group: 'com.android.support'
}
implementation 'com.github.wenchaosong:Banner:2.3.12' //此版本适配了 androidx
}
```
或者引用本地lib
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.github.wenchaosong:BottomBar:3.0.7'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.github.wenchaosong:BottomBar:3.0.8'
implementation project(':banner')
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/test/LazyFragment.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.test;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public abstract class LazyFragment extends Fragment {

/**
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/test/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -29,6 +27,9 @@
import java.util.Arrays;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener,
AdapterView.OnItemClickListener {

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/test/demo/BannerAnimationActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
Expand All @@ -17,6 +15,9 @@
import java.util.ArrayList;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

public class BannerAnimationActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

Banner banner;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/test/demo/BannerLocalActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.ms.banner.Banner;
import com.test.R;
Expand All @@ -10,6 +9,8 @@
import java.util.ArrayList;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;

public class BannerLocalActivity extends AppCompatActivity {

Banner banner;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/test/demo/BannerStyleActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
Expand All @@ -12,6 +11,8 @@
import com.test.R;
import com.test.ui.CustomViewHolder;

import androidx.appcompat.app.AppCompatActivity;

public class BannerStyleActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {

Banner banner;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/test/demo/CustomBannerActivity.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.ms.banner.Banner;
import com.ms.banner.BannerConfig;
import com.test.App;
import com.test.R;
import com.test.ui.CustomViewHolder;

import androidx.appcompat.app.AppCompatActivity;

public class CustomBannerActivity extends AppCompatActivity {

Banner banner1, banner2, banner3;
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/test/demo/CustomViewPagerActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.LinearLayout;

Expand All @@ -17,6 +15,9 @@
import java.util.ArrayList;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

public class CustomViewPagerActivity extends AppCompatActivity {

Banner banner1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
Expand All @@ -12,6 +11,8 @@
import com.test.R;
import com.test.ui.CustomViewHolder;

import androidx.appcompat.app.AppCompatActivity;

public class IndicatorPositionActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {

Banner banner;
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/test/demo/SimpleFragmentActivity.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.test.demo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.bottom.PageNavigationView;
import com.test.LazyFragment;
import com.test.R;

import java.util.ArrayList;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

public class SimpleFragmentActivity extends AppCompatActivity {

private String[] mTitles = {"首页", "更多"};
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/test/ui/GallyPageTransformer.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.test.ui;

import android.support.v4.view.ViewPager;
import android.view.View;

import androidx.viewpager.widget.ViewPager;

/**
* 自定义动画效果
* 调用 banner.setPageTransformer()方法设置
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="0dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v4.widget.SwipeRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -15,6 +15,6 @@
android:divider="@null"
android:scrollbars="none" />

</android.support.v4.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</LinearLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/banner_item.xml
Original file line number Diff line number Diff line change
@@ -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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/group"
android:layout_width="match_parent"
Expand Down Expand Up @@ -57,4 +57,4 @@

</LinearLayout>

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
2 changes: 1 addition & 1 deletion banner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
}

apply plugin: 'com.github.dcendents.android-maven'
Expand Down
10 changes: 5 additions & 5 deletions banner/src/main/java/com/ms/banner/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntRange;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
Expand All @@ -30,8 +27,11 @@
import java.util.ArrayList;
import java.util.List;

import static android.support.v4.view.ViewPager.OnPageChangeListener;
import static android.support.v4.view.ViewPager.PageTransformer;
import androidx.annotation.IntRange;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.PageTransformer;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;

public class Banner extends FrameLayout implements OnPageChangeListener {

Expand Down
10 changes: 5 additions & 5 deletions banner/src/main/java/com/ms/banner/BannerNew.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntRange;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
Expand All @@ -30,8 +27,11 @@
import java.util.ArrayList;
import java.util.List;

import static android.support.v4.view.ViewPager.OnPageChangeListener;
import static android.support.v4.view.ViewPager.PageTransformer;
import androidx.annotation.IntRange;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import androidx.viewpager.widget.ViewPager.PageTransformer;

public class BannerNew extends FrameLayout implements OnPageChangeListener {

Expand Down
6 changes: 3 additions & 3 deletions banner/src/main/java/com/ms/banner/Transformer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ms.banner;

import android.support.v4.view.ViewPager.PageTransformer;

import com.ms.banner.transformer.AccordionTransformer;
import com.ms.banner.transformer.BackgroundToForegroundTransformer;
import com.ms.banner.transformer.CubeInTransformer;
Expand All @@ -14,14 +12,16 @@
import com.ms.banner.transformer.RotateDownTransformer;
import com.ms.banner.transformer.RotateUpTransformer;
import com.ms.banner.transformer.ScaleInOutTransformer;
import com.ms.banner.transformer.ScaleTransformer;
import com.ms.banner.transformer.ScaleRightTransformer;
import com.ms.banner.transformer.ScaleTransformer;
import com.ms.banner.transformer.StackTransformer;
import com.ms.banner.transformer.TabletTransformer;
import com.ms.banner.transformer.ZoomInTransformer;
import com.ms.banner.transformer.ZoomOutSlideTransformer;
import com.ms.banner.transformer.ZoomOutTranformer;

import androidx.viewpager.widget.ViewPager.PageTransformer;

public class Transformer {

public static Class<? extends PageTransformer> Default = DefaultTransformer.class;
Expand Down
7 changes: 4 additions & 3 deletions banner/src/main/java/com/ms/banner/WeakHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;

import java.lang.ref.WeakReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

public class WeakHandler {

private final Handler.Callback mCallback; // hard reference to Callback. We need to keep callback in memory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.ms.banner.transformer;

import android.support.v4.view.ViewPager.PageTransformer;
import android.view.View;

import androidx.viewpager.widget.ViewPager.PageTransformer;

public abstract class ABaseTransformer implements PageTransformer {

protected abstract void onTransform(View page, float position);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.ms.banner.transformer;

import android.support.v4.view.ViewPager;
import android.view.View;

import androidx.viewpager.widget.ViewPager;

public class ScaleRightTransformer implements ViewPager.PageTransformer {

private ViewPager viewPager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.ms.banner.transformer;

import android.support.v4.view.ViewPager;
import android.view.View;

import androidx.viewpager.widget.ViewPager;

public class ScaleTransformer implements ViewPager.PageTransformer {

private ViewPager viewPager;
Expand Down
9 changes: 6 additions & 3 deletions banner/src/main/java/com/ms/banner/view/ArcShapeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ protected void onDraw(Canvas canvas) {
mPaint.setShader(gradient);

if (direction == 0) {
//up
mPath.moveTo(0, getHeight());
mPath.quadTo(getWidth() / 2, getHeight() - 2 * arcHeight, getWidth(), getHeight());
canvas.drawPath(mPath, mPaint);
} else {
mPath.moveTo(0, getHeight());
mPath.lineTo(0, getHeight() - arcHeight);
mPath.quadTo(getWidth() / 2, getHeight(), getWidth(), getHeight() - arcHeight);
//down
mPath.moveTo(0, getHeight() - arcHeight);
mPath.lineTo(0, getHeight());
mPath.lineTo(getWidth(), getHeight());
mPath.lineTo(getWidth(), getHeight() - arcHeight);
mPath.quadTo(getWidth() / 2, getHeight() + arcHeight, 0, getHeight() - arcHeight);
canvas.drawPath(mPath, mPaint);
}
}
Expand Down
Loading

0 comments on commit 399d377

Please sign in to comment.