Skip to content

Commit

Permalink
1.sample适配0.5.0版本
Browse files Browse the repository at this point in the history
2.library升级到0.6.0版本
  • Loading branch information
caikaidev committed Oct 23, 2016
1 parent 6766cec commit f522f7a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 102 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@

Gradle:

in module's build.gradle,use:

```
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
```

replace:

```
repositories {
jcenter()
}
```

in app's build.gradle,add:

```
compile 'com.kcode.github:autoScrollViewPager:0.1.0'
```
Expand All @@ -13,7 +32,7 @@ compile 'com.kcode.github:autoScrollViewPager:0.1.0'
* in layout

```
<com.kcode.autoscrollviewpager.view.AutoScrollViewPager
<com.kcode.autoscrollviewpager.view.AutoScrollViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="220dp">
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:24.2.0'
testCompile 'junit:junit:4.12'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.kcode.github:autoScrollViewPager:0.1.0',{
compile 'com.github.fccaikai:AutoScrollViewPager:0.5.0',{
exclude group: 'com.android.support', module:'appcompat-v7'
}
}
11 changes: 4 additions & 7 deletions app/src/main/java/com/kcode/autoviewpager/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import com.kcode.autoscrollviewpager.view.AutoViewPager;
import com.kcode.autoscrollviewpager.view.BaseViewPagerAdapter;
import com.kcode.autoviewpager.bean.Picture;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

private AutoViewPager mViewPager;
private PictureViewPagerAdapter mAdapter;
private AutoScrollViewPager autoScrollViewPager;

private String[] paths = {"https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=c493b482b47eca800d053ee7a1229712/8cb1cb1349540923abd671df9658d109b2de49d7.jpg",
Expand All @@ -32,15 +32,12 @@ protected void onCreate(Bundle savedInstanceState) {

autoScrollViewPager = (AutoScrollViewPager) findViewById(R.id.viewPager);
mViewPager = autoScrollViewPager.getViewPager();
mAdapter = new PictureViewPagerAdapter(getApplicationContext(),initData(),mViewPager, listener);

new BaseViewPagerAdapter<Picture>(getApplicationContext(),initData(),mViewPager, listener){

autoScrollViewPager.setAdapter(new BaseViewPagerAdapter<Picture>(this,initData(),listener) {
@Override
public void loadImage(ImageView view, int position, Picture picture) {

Picasso.with(MainActivity.this).load(picture.getPath()).into(view);
}
};
});
}

private List<Picture> initData() {
Expand Down

This file was deleted.

41 changes: 0 additions & 41 deletions app/src/main/java/com/kcode/autoviewpager/ViewPagerAdapter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by caik on 2016/10/17.
*/

public class AutoScrollViewPager extends RelativeLayout{
public class AutoScrollViewPager extends RelativeLayout {

private AutoViewPager mViewPager;

Expand All @@ -33,34 +33,35 @@ public AutoScrollViewPager(Context context, AttributeSet attrs) {
init(context);
}

private void init(Context context){
private void init(Context context) {
mContext = context;
mViewPager = new AutoViewPager(context);
layout = new LinearLayout(mContext);
addView(mViewPager);
}

public void setAdapter(BaseViewPagerAdapter adapter){
public void setAdapter(BaseViewPagerAdapter adapter) {
if (mViewPager != null) {
mViewPager.init(mViewPager,adapter);
mViewPager.init(mViewPager, adapter);
}
}

public AutoViewPager getViewPager() {
return mViewPager;
}
public void initPointView(int size){

public void initPointView(int size) {

layout = new LinearLayout(mContext);
for (int i = 0; i < size; i++) {
ImageView imageView = new ImageView(mContext);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20,20);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
params.leftMargin = 8;
params.gravity = CENTER;
imageView.setLayoutParams(params);
if (i == 0) {
imageView.setBackgroundResource(R.drawable.point_checked);
}else {
} else {
imageView.setBackgroundResource(R.drawable.point_normal);
}

Expand All @@ -70,7 +71,7 @@ public void initPointView(int size){
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(ALIGN_PARENT_BOTTOM);
layoutParams.addRule(ALIGN_PARENT_RIGHT);
layoutParams.setMargins(12,20,12,20);
layoutParams.setMargins(12, 20, 12, 20);
layout.setLayoutParams(layoutParams);
addView(layout);
}
Expand All @@ -80,13 +81,19 @@ public void updatePointView(int position) {
int size = layout.getChildCount();
for (int i = 0; i < size; i++) {
ImageView imageView = (ImageView) layout.getChildAt(i);
if (i == position){
if (i == position) {
imageView.setBackgroundResource(R.drawable.point_checked);
}else {
} else {
imageView.setBackgroundResource(R.drawable.point_normal);
}

}
}

public void onDestroy() {
if (mViewPager != null) {
mViewPager.onDestroy();
}
}

}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}

Expand Down

0 comments on commit f522f7a

Please sign in to comment.