Skip to content

Commit

Permalink
removeSliderAt(position) function not work #88 and a NPE
Browse files Browse the repository at this point in the history
1. fixed removeSliderAt(position) function not work #88
logic mistake.
2. NullPointerException in MainActivity.java
05-05 04:12:14.960      472-472/? E/AndroidRuntime﹕ FATAL EXCEPTION:
main
Process: com.daimajia.slider.demo, PID: 472
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.daimajia.slider.demo/com.daimajia.slider.demo.MainActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.os.Bundle.putString(java.lang.String, java.lang.String)' on a
null object reference
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
....
Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'void android.os.Bundle.putString(java.lang.String,
java.lang.String)' on a null object reference
at com.daimajia.slider.demo.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5933)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
  • Loading branch information
zhouqiangWang committed May 4, 2015
1 parent e836594 commit 97e3276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions demo/src/main/java/com/daimajia/slider/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ protected void onCreate(Bundle savedInstanceState) {
.setOnSliderClickListener(this);

//add your extra information
textSliderView.getBundle()
.putString("extra",name);
if (textSliderView.getBundle() != null)
textSliderView.getBundle()
.putString("extra",name);

mDemoSlider.addSlider(textSliderView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public <T extends BaseSliderView> void removeSlider(T slider){
}

public void removeSliderAt(int position){
if(mImageContents.size() < position){
if(mImageContents.size() > position){
mImageContents.remove(position);
notifyDataSetChanged();
}
Expand Down

0 comments on commit 97e3276

Please sign in to comment.