├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── brioal │ │ └── banner │ │ └── MainActivity.java ├── build.gradle └── proguard-rules.pro ├── brioalbanner ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── attrs.xml │ │ └── layout │ │ │ └── content.xml │ │ ├── java │ │ └── com │ │ │ └── brioal │ │ │ └── brioalbanner │ │ │ ├── interfaces │ │ │ └── OnPagerClickListener.java │ │ │ ├── adapter │ │ │ └── ViewPagerAdapter.java │ │ │ ├── util │ │ │ └── FixedSpeedScroller.java │ │ │ ├── entity │ │ │ └── BannerEntity.java │ │ │ └── view │ │ │ ├── BottonLayout.java │ │ │ └── Banner.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── art ├── 1.gif └── 2.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /brioalbanner/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':brioalbanner' 2 | -------------------------------------------------------------------------------- /art/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/art/1.gif -------------------------------------------------------------------------------- /art/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/art/2.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Banner 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /brioalbanner/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BrioalBanner 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Brioal/Banner/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /brioalbanner/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #c7b9b9b9 4 | #c7ffffff 5 | #000000 6 | #ffffff 7 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/interfaces/OnPagerClickListener.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.interfaces; 2 | 3 | import com.brioal.brioalbanner.entity.BannerEntity; 4 | 5 | /** 6 | * Created by Brioal on 2016/8/31. 7 | */ 8 | 9 | public interface OnPagerClickListener { 10 | void onClick(BannerEntity entity, int position); 11 | } 12 | -------------------------------------------------------------------------------- /brioalbanner/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /brioalbanner/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.1" 6 | defaultConfig { 7 | applicationId "com.brioal.banner" 8 | minSdkVersion 15 9 | targetSdkVersion 24 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:appcompat-v7:24.2.0' 23 | compile project(":brioalbanner") 24 | } 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Android\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /brioalbanner/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Android\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /brioalbanner/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.github.Brioal' 4 | android { 5 | compileSdkVersion 24 6 | buildToolsVersion "24.0.1" 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 24 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile 'com.android.support:appcompat-v7:24.2.0' 26 | compile 'com.github.bumptech.glide:glide:3.7.0' 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /brioalbanner/src/main/res/layout/content.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 26 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/adapter/ViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.adapter; 2 | 3 | import android.support.v4.view.PagerAdapter; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Brioal on 2016/8/31. 11 | */ 12 | 13 | public class ViewPagerAdapter extends PagerAdapter { 14 | private List mViews; 15 | 16 | public ViewPagerAdapter(List views) { 17 | mViews = views; 18 | } 19 | 20 | @Override 21 | public int getCount() { 22 | return mViews.size(); 23 | } 24 | 25 | @Override 26 | public boolean isViewFromObject(View view, Object object) { 27 | return view == object; 28 | } 29 | 30 | @Override 31 | public void destroyItem(ViewGroup container, int position, Object object) { 32 | container.removeView((View) object); 33 | } 34 | 35 | @Override 36 | public Object instantiateItem(ViewGroup container, int position) { 37 | container.addView(mViews.get(position)); 38 | return mViews.get(position); 39 | } 40 | 41 | @Override 42 | public int getItemPosition(Object object) { 43 | return POSITION_NONE; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/util/FixedSpeedScroller.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.util; 2 | 3 | import android.content.Context; 4 | import android.view.animation.Interpolator; 5 | import android.widget.Scroller; 6 | 7 | /** 8 | * Created by Brioal on 2016/8/31. 9 | */ 10 | 11 | public class FixedSpeedScroller extends Scroller { 12 | private int mDuration = 1500; 13 | 14 | public FixedSpeedScroller(Context context) { 15 | super(context); 16 | } 17 | 18 | public FixedSpeedScroller(Context context, Interpolator interpolator) { 19 | super(context, interpolator); 20 | } 21 | 22 | @Override 23 | public void startScroll(int startX, int startY, int dx, int dy, int duration) { 24 | // Ignore received duration, use fixed one instead 25 | super.startScroll(startX, startY, dx, dy, mDuration); 26 | } 27 | 28 | @Override 29 | public void startScroll(int startX, int startY, int dx, int dy) { 30 | // Ignore received duration, use fixed one instead 31 | super.startScroll(startX, startY, dx, dy, mDuration); 32 | } 33 | 34 | public void setmDuration(int time) { 35 | mDuration = time; 36 | } 37 | 38 | public int getmDuration() { 39 | return mDuration; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/entity/BannerEntity.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /**ViewPager Content Entity 6 | * Created by Brioal on 2016/8/31. 7 | */ 8 | 9 | public class BannerEntity implements Serializable{ 10 | private int mIndex; //序号 11 | private String mImageUrl; //图片链接 12 | private String mTip; //提示信息 13 | private String mClickUrl; //内容链接 14 | 15 | 16 | public BannerEntity(int index, String imageUrl, String tip, String clickUrl) { 17 | mIndex = index; 18 | mImageUrl = imageUrl; 19 | mTip = tip; 20 | mClickUrl = clickUrl; 21 | } 22 | 23 | public int getIndex() { 24 | return mIndex; 25 | } 26 | 27 | public void setIndex(int index) { 28 | mIndex = index; 29 | } 30 | 31 | public String getImageUrl() { 32 | return mImageUrl; 33 | } 34 | 35 | public void setImageUrl(String imageUrl) { 36 | mImageUrl = imageUrl; 37 | } 38 | 39 | public String getTip() { 40 | return mTip; 41 | } 42 | 43 | public void setTip(String tip) { 44 | mTip = tip; 45 | } 46 | 47 | public String getClickUrl() { 48 | return mClickUrl; 49 | } 50 | 51 | public void setClickUrl(String clickUrl) { 52 | mClickUrl = clickUrl; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Banner [![](https://jitpack.io/v/Brioal/Banner.svg)](https://jitpack.io/#Brioal/Banner) 2 | 仿知乎日报首页轮播图 3 | 效果对比演示 4 | 5 | ![](https://github.com/Brioal/Banner/blob/master/art/1.gif)|![](https://github.com/Brioal/Banner/blob/master/art/2.gif) 6 | 7 | #usage 8 | ##Step 1. Add the JitPack repository to your build file 9 | 10 | ###Add it in your root build.gradle at the end of repositories: 11 | ``` 12 | 13 | allprojects { 14 | repositories { 15 | ... 16 | maven { url "https://jitpack.io" } 17 | } 18 | } 19 | 20 | ``` 21 | ##Step 2. Add the dependency 22 | ``` 23 | dependencies { 24 | compile 'com.github.Brioal:Banner:1.0' 25 | } 26 | 27 | ``` 28 | 29 | ``` 30 | mList = new ArrayList<>(); 31 | mList.add(new BannerEntity(1, "http://123.206.20.217/testimage/img_1.png", "第一个提示", "第一个链接")); 32 | mList.add(new BannerEntity(2, "http://123.206.20.217/testimage/img_2.png", "第二个提示", "第二个链接")); 33 | mList.add(new BannerEntity(3, "http://123.206.20.217/testimage/img_3.png", "第三个提示", "第三个链接")); 34 | mList.add(new BannerEntity(4, "http://123.206.20.217/testimage/img_4.png", "第四个提示", "第四个链接")); 35 | mList.add(new BannerEntity(5, "http://123.206.20.217/testimage/img_5.png", "第五个提示", "第五个链接")); 36 | mBanner.setList(mList); 37 | mBanner.setPagerClickListener(new OnPagerClickListener() { 38 | @Override 39 | public void onClick(BannerEntity entity, int position) { 40 | if (mToast == null) { 41 | mToast = Toast.makeText(MainActivity.this, entity.getTip(), Toast.LENGTH_SHORT); 42 | } else { 43 | mToast.setText(entity.getClickUrl()); 44 | } 45 | mToast.show(); 46 | } 47 | }); 48 | ``` 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/brioal/banner/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.brioal.banner; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.widget.Toast; 6 | 7 | import com.brioal.brioalbanner.entity.BannerEntity; 8 | import com.brioal.brioalbanner.interfaces.OnPagerClickListener; 9 | import com.brioal.brioalbanner.view.Banner; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | private Banner mBanner; 16 | private List mList; 17 | private Toast mToast; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | mBanner = (Banner) findViewById(R.id.main_banner); 24 | mList = new ArrayList<>(); 25 | mList.add(new BannerEntity(1, "http://123.206.20.217/testimage/img_1.png", "第一个提示", "第一个链接")); 26 | mList.add(new BannerEntity(2, "http://123.206.20.217/testimage/img_2.png", "第二个提示", "第二个链接")); 27 | mList.add(new BannerEntity(3, "http://123.206.20.217/testimage/img_3.png", "第三个提示", "第三个链接")); 28 | mList.add(new BannerEntity(4, "http://123.206.20.217/testimage/img_4.png", "第四个提示", "第四个链接")); 29 | mList.add(new BannerEntity(5, "http://123.206.20.217/testimage/img_5.png", "第五个提示", "第五个链接")); 30 | mBanner.setList(mList); 31 | mBanner.setPagerClickListener(new OnPagerClickListener() { 32 | @Override 33 | public void onClick(BannerEntity entity, int position) { 34 | if (mToast == null) { 35 | mToast = Toast.makeText(MainActivity.this, entity.getTip(), Toast.LENGTH_SHORT); 36 | } else { 37 | mToast.setText(entity.getClickUrl()); 38 | } 39 | mToast.show(); 40 | } 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/view/BottonLayout.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | 9 | import com.brioal.brioalbanner.R; 10 | 11 | /** 12 | * Created by Brioal on 2016/8/31. 13 | */ 14 | 15 | public class BottonLayout extends View { 16 | public static final int GRAVITY_CENTER = 0; 17 | public static final int GRAVITY_LEFT = 1; 18 | public static final int GRAVITY_RIGHT = 2; 19 | 20 | private int mDotSum; //圆点总数 21 | private int mCurrentIndex; //当前下标 22 | private float mProgress; //滑动进度 23 | private int mNormalColor;//未选中的颜色 24 | private int mSelectColor; //选中的颜色 25 | private int mRadius; //小圆点半径 26 | private int mMagin; //小圆点的Magin 27 | private int mStartX; //圆点开始的坐标 28 | private int mDotX; //移动的点的X坐标 29 | private int mWidth; //宽度 30 | private int mHeight; //高度 31 | 32 | private Paint mPaint; 33 | private int mGravity; 34 | 35 | 36 | public BottonLayout(Context context) { 37 | this(context, null); 38 | } 39 | 40 | public BottonLayout(Context context, AttributeSet attrs) { 41 | super(context, attrs); 42 | init(); 43 | } 44 | 45 | public void setCurrentIndex(int currentIndex) { 46 | mCurrentIndex = currentIndex; 47 | } 48 | 49 | //设置圆点总数 50 | public void setDotSum(int dotSum) { 51 | mDotSum = dotSum; 52 | } 53 | 54 | //设置滑动的进度 55 | public void setProgress(float progress) { 56 | mProgress = progress; 57 | invalidate(); 58 | } 59 | 60 | 61 | private void init() { 62 | mDotSum = 5; 63 | mCurrentIndex = 0; 64 | mProgress = 0; 65 | mNormalColor = getResources().getColor(R.color.normal); 66 | mSelectColor = getResources().getColor(R.color.colorSelect); 67 | mRadius = 8; 68 | mMagin = 10; 69 | mGravity = GRAVITY_CENTER; 70 | mPaint = new Paint(); 71 | mPaint.setDither(true); 72 | mPaint.setAntiAlias(true); 73 | mPaint.setStyle(Paint.Style.FILL); 74 | 75 | } 76 | 77 | @Override 78 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 79 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 80 | int widthSize = MeasureSpec.getSize(widthMeasureSpec); 81 | int heightSize = MeasureSpec.getSize(heightMeasureSpec); 82 | mWidth = widthSize; 83 | mHeight = heightSize; 84 | setMeasuredDimension(widthSize, heightSize); 85 | switch (mGravity) { 86 | case GRAVITY_CENTER: 87 | mStartX = (mWidth - (mDotSum * mRadius + mDotSum * mMagin * 2)) / 2; 88 | break; 89 | case GRAVITY_LEFT: 90 | mStartX = mMagin; 91 | break; 92 | case GRAVITY_RIGHT: 93 | mStartX = mWidth - (mDotSum * mRadius + mDotSum * mMagin * 2); 94 | break; 95 | } 96 | } 97 | 98 | @Override 99 | protected void onDraw(Canvas canvas) { 100 | super.onDraw(canvas); 101 | mPaint.setColor(mNormalColor); 102 | for (int i = 0; i < mDotSum; i++) { 103 | canvas.drawCircle(mStartX + i * (mRadius + 2 * mMagin) + mMagin + mRadius / 2, mHeight / 2, mRadius, mPaint); 104 | } 105 | mPaint.setColor(mSelectColor); 106 | canvas.drawCircle(mStartX + mCurrentIndex * (mRadius + 2 * mMagin) + mMagin + mRadius / 2 + (mRadius + 2 * mMagin) * mProgress, mHeight / 2, mRadius, mPaint); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /brioalbanner/src/main/java/com/brioal/brioalbanner/view/Banner.java: -------------------------------------------------------------------------------- 1 | package com.brioal.brioalbanner.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Color; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.v4.view.ViewPager; 9 | import android.util.AttributeSet; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.animation.LinearInterpolator; 13 | import android.widget.ImageView; 14 | import android.widget.RelativeLayout; 15 | import android.widget.TextView; 16 | 17 | import com.brioal.brioalbanner.R; 18 | import com.brioal.brioalbanner.adapter.ViewPagerAdapter; 19 | import com.brioal.brioalbanner.entity.BannerEntity; 20 | import com.brioal.brioalbanner.interfaces.OnPagerClickListener; 21 | import com.brioal.brioalbanner.util.FixedSpeedScroller; 22 | import com.bumptech.glide.Glide; 23 | 24 | import java.lang.reflect.Field; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * Created by Brioal on 2016/8/31. 30 | */ 31 | 32 | public class Banner extends RelativeLayout { 33 | private BottonLayout mBottonLayout; 34 | private ViewPager mViewPager; 35 | private List mList; 36 | private List mViews; 37 | private ViewPagerAdapter mPagerAdapter; 38 | private OnPagerClickListener mClickListener; 39 | private int mAlpha = 70; 40 | private boolean isAutoMoving = true; 41 | private boolean isAuto = true; 42 | private Handler mHandler = new Handler() { 43 | @Override 44 | public void handleMessage(Message msg) { 45 | super.handleMessage(msg); 46 | } 47 | }; 48 | private long mPauseDuration; 49 | private int mChangeDuration; 50 | 51 | 52 | public Banner(Context context) { 53 | this(context, null); 54 | } 55 | 56 | public Banner(Context context, AttributeSet attrs) { 57 | super(context, attrs); 58 | init(context, attrs); 59 | } 60 | 61 | //设置是否开启自动轮播 62 | public void setAuto(boolean auto) { 63 | isAuto = auto; 64 | } 65 | 66 | //设置切换花费的时间 67 | public void setChangeDuration(int changeDuration) { 68 | mChangeDuration = changeDuration; 69 | } 70 | 71 | //设置停顿的时间 72 | public void setPauseDuration(long pauseDuration) { 73 | mPauseDuration = pauseDuration; 74 | } 75 | 76 | //设置提示及圆点的背景透明度 77 | public void setAlpha(int alpha) { 78 | mAlpha = alpha; 79 | } 80 | 81 | 82 | private void init(Context context, AttributeSet attrs) { 83 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Banner); 84 | mPauseDuration = array.getInteger(R.styleable.Banner_banner_pause_duration, 2000); 85 | mChangeDuration = array.getInteger(R.styleable.Banner_banner_change_duration, 800); 86 | array.recycle(); 87 | mViewPager = new ViewPager(getContext()); 88 | LayoutParams pagerParams = new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); 89 | addView(mViewPager, pagerParams); 90 | 91 | mBottonLayout = new BottonLayout(getContext()); 92 | LayoutParams bottonParams = new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 50); 93 | bottonParams.addRule(ALIGN_PARENT_BOTTOM); 94 | mBottonLayout.setBackgroundColor(Color.argb(mAlpha, 0, 0, 0)); 95 | addView(mBottonLayout, bottonParams); 96 | 97 | mHandler.postDelayed(new Runnable() { 98 | @Override 99 | public void run() { 100 | if (isAutoMoving) { 101 | int index = mViewPager.getCurrentItem(); 102 | mViewPager.setCurrentItem((index + 1) % (mList.size()), true); 103 | mHandler.postDelayed(this, mPauseDuration * 2 + mChangeDuration); 104 | } else { 105 | mHandler.postDelayed(this, mPauseDuration * 4 + mChangeDuration); 106 | } 107 | } 108 | }, mPauseDuration); 109 | 110 | } 111 | 112 | 113 | public void setPagerClickListener(OnPagerClickListener clickListener) { 114 | mClickListener = clickListener; 115 | } 116 | 117 | public void setList(List list) { 118 | mList = list; 119 | mViews = new ArrayList<>(); 120 | mBottonLayout.setDotSum(list.size()); 121 | for (int i = 0; i < mList.size(); i++) { 122 | View itemView = LayoutInflater.from(getContext()).inflate(R.layout.content, null, false); 123 | ImageView iv = (ImageView) itemView.findViewById(R.id.fra_iv_image); 124 | TextView tv = (TextView) itemView.findViewById(R.id.fra_tv_tip); 125 | tv.setBackgroundColor(Color.argb(mAlpha, 0, 0, 0)); 126 | BannerEntity entity = mList.get(i); 127 | Glide.with(getContext()).load(entity.getImageUrl()).into(iv); 128 | tv.setText(entity.getTip()); 129 | final int finalI = i; 130 | itemView.setClickable(true); 131 | itemView.setOnClickListener(new OnClickListener() { 132 | @Override 133 | public void onClick(View view) { 134 | if (mClickListener != null) { 135 | mClickListener.onClick(mList.get(finalI), finalI); 136 | } 137 | } 138 | }); 139 | mViews.add(itemView); 140 | } 141 | mPagerAdapter = new ViewPagerAdapter(mViews); 142 | mViewPager.setAdapter(mPagerAdapter); 143 | mViewPager.setClickable(true); 144 | if (isAuto) { 145 | try { 146 | Field field = ViewPager.class.getDeclaredField("mScroller"); 147 | field.setAccessible(true); 148 | FixedSpeedScroller scroller = new FixedSpeedScroller(mViewPager.getContext(), 149 | new LinearInterpolator()); 150 | field.set(mViewPager, scroller); 151 | scroller.setmDuration(mChangeDuration); 152 | } catch (Exception e) { 153 | e.printStackTrace(); 154 | } 155 | } 156 | 157 | mViewPager.setOnClickListener(new OnClickListener() { 158 | @Override 159 | public void onClick(View view) { 160 | if (mClickListener != null) { 161 | int index = mViewPager.getCurrentItem(); 162 | mClickListener.onClick(mList.get(index), index); 163 | } 164 | } 165 | }); 166 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 167 | @Override 168 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 169 | mBottonLayout.setCurrentIndex(position); 170 | mBottonLayout.setProgress(positionOffset); 171 | } 172 | 173 | @Override 174 | public void onPageSelected(int position) { 175 | 176 | } 177 | 178 | @Override 179 | public void onPageScrollStateChanged(int state) { 180 | switch (state) { 181 | case ViewPager.SCROLL_STATE_DRAGGING: 182 | isAutoMoving = false; 183 | break; 184 | default: 185 | isAutoMoving = true; 186 | break; 187 | } 188 | } 189 | }); 190 | } 191 | 192 | 193 | } 194 | --------------------------------------------------------------------------------