-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "24.0.3" | ||
defaultConfig { | ||
applicationId "com.loonggg.rvbanner" | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.0.0' | ||
compile 'com.github.bumptech.glide:glide:3.7.0' | ||
testCompile 'junit:junit:4.12' | ||
compile project(path: ':rvbanner') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in D:\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.loonggg.rvbanner; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.loonggg.rvbanner", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.loonggg.rvbanner"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.loonggg.rvbanner; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.widget.ImageView; | ||
import android.widget.Toast; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.loonggg.rvbanner.lib.RecyclerViewBanner; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
private RecyclerViewBanner recyclerViewBanner; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
recyclerViewBanner = (RecyclerViewBanner) findViewById(R.id.rv_banner); | ||
final List<RecyclerViewBanner.RvBanner> banners = new ArrayList<>(); | ||
for (int i = 0; i < 2; i++) { | ||
banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487221110004&di=d6043e4b0c90ddf3ea5096c3d8eb8f58&imgtype=0&src=http%3A%2F%2Fimage.tianjimedia.com%2FuploadImages%2F2014%2F067%2F5116EPAUD762_1000x500.jpg")); | ||
banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487221129421&di=c085432cf7c15836f8a6479138740f39&imgtype=0&src=http%3A%2F%2Fimage85.360doc.com%2FDownloadImg%2F2015%2F05%2F0517%2F53199602_2.jpg")); | ||
banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487221161254&di=fbb99c5dad3d5a2a2c8b0b44e8c0e081&imgtype=0&src=http%3A%2F%2Fimage.tianjimedia.com%2FuploadImages%2F2013%2F255%2FP52AOTE73EIG_1000x500.jpg")); | ||
} | ||
recyclerViewBanner.isShowIndicatorPoint(true); | ||
recyclerViewBanner.setRvBannerDatas(banners); | ||
recyclerViewBanner.setOnSwitchRvBannerListener(new RecyclerViewBanner.OnSwitchRvBannerListener() { | ||
@Override | ||
public void switchBanner(int position, ImageView bannerView) { | ||
Glide.with(bannerView.getContext()).load(banners.get(position % banners.size()).getUrl()).placeholder(R.mipmap.ic_launcher).into(bannerView); | ||
} | ||
}); | ||
recyclerViewBanner.setOnRvBannerClickListener(new RecyclerViewBanner.OnRvBannerClickListener() { | ||
@Override | ||
public void onClick(RecyclerViewBanner.RvBanner banner) { | ||
Toast.makeText(MainActivity.this, banner.getUrl(), Toast.LENGTH_LONG).show(); | ||
} | ||
}); | ||
} | ||
|
||
private class Banner implements RecyclerViewBanner.RvBanner { | ||
|
||
String url; | ||
|
||
public Banner(String url) { | ||
this.url = url; | ||
} | ||
|
||
@Override | ||
public String getUrl() { | ||
return url; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:loonggg="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.loonggg.rvbanner.MainActivity"> | ||
|
||
<com.loonggg.rvbanner.lib.RecyclerViewBanner | ||
android:id="@+id/rv_banner" | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" | ||
loonggg:interval="6000" | ||
loonggg:isShowPoint="true" /> | ||
</RelativeLayout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">RecyclerViewBannerDemo</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.loonggg.rvbanner; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() throws Exception { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |