Skip to content

Commit 01361a4

Browse files
committed
Update 1.1.3
1 parent 1b82255 commit 01361a4

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ limitations under the License.
2828
android:id="@+id/img_vertical_slide"
2929
android:layout_width="match_parent"
3030
android:layout_height="0dp"
31-
android:layout_weight="1"/>
31+
android:layout_weight="1"
32+
slide:source="@drawable/long_background"
33+
slide:axis="vertical"/>
3234

3335
<com.gigamole.slideimageview.lib.SlideImageView
3436
android:id="@+id/img_horizontal_slide"

library/src/main/java/com/gigamole/slideimageview/lib/SlideImageView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class SlideImageView extends ImageView {
3535
private int height;
3636

3737
private float rate;
38+
private float originalRate;
39+
3840
private Bitmap bitmap;
3941

4042
private float bitmapX;
@@ -95,10 +97,12 @@ public SlideImageView(Context context, AttributeSet attrs, int defStyleAttr) {
9597

9698
public void setRate(float rate) {
9799
this.rate = rate * (-1);
100+
this.originalRate = this.rate;
98101
}
99102

100103
public void setAxis(Axis axis) {
101104
this.axis = axis;
105+
this.originalRate = this.rate;
102106
}
103107

104108
private void setAxis(int axis) {
@@ -131,9 +135,7 @@ private void createSource() {
131135
this.horizontalDirection = HorizontalDirection.LEFT_TO_RIGHT;
132136
this.verticalDirection = VerticalDirection.TOP_TO_BOTTOM;
133137

134-
if (this.rate > 0) {
135-
this.rate = this.rate * (-1);
136-
}
138+
this.rate = this.originalRate;
137139

138140
if (this.bitmap != null) {
139141
if (this.axis == Axis.HORIZONTAL) {
@@ -154,6 +156,8 @@ private void createSource() {
154156
} else {
155157
this.bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888);
156158
}
159+
160+
invalidate();
157161
}
158162

159163
@Override

0 commit comments

Comments
 (0)