Skip to content
This repository was archived by the owner on Oct 19, 2020. It is now read-only.

Commit d53188a

Browse files
Hamza BhattiHamza Bhatti
authored andcommitted
Added Bring To Front Feature for list of imageviews
1 parent 3d1d81a commit d53188a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tn_imageview/src/main/java/us/technerd/tnimageview/TNImageView.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.io.IOException;
1616
import java.net.URI;
17+
import java.util.ArrayList;
1718
import java.util.List;
1819

1920
/**
@@ -30,6 +31,7 @@ public class TNImageView {
3031
private float oldDist = 1f;
3132
private float d = 0f;
3233
private float newRot = 0f;
34+
private List<ImageView> imageList = new ArrayList<>();
3335

3436

3537
public ImageView makeRotatableScalable(ImageView imageView){
@@ -46,6 +48,16 @@ public ImageView makeRotatableScalable(ImageView imageView){
4648
public boolean onTouch(View v, MotionEvent event) {
4749
final ImageView view = (ImageView) v;
4850

51+
if(!imageList.isEmpty()) {
52+
for (ImageView i : imageList) {
53+
54+
if (i == view) {
55+
view.bringToFront();
56+
view.getRootView().invalidate();
57+
}
58+
}
59+
}
60+
4961
((BitmapDrawable) view.getDrawable()).setAntiAlias(true);
5062
switch (event.getAction() & MotionEvent.ACTION_MASK) {
5163
case MotionEvent.ACTION_DOWN:
@@ -178,6 +190,7 @@ public void addTNImageViewsWithUri(Context context, List<Uri> uriList, RelativeL
178190
layoutParams.bottomMargin = 250 - 500;
179191
layoutParams.rightMargin = 250 - 500;
180192
image.setLayoutParams(layoutParams);
193+
imageList.add(image);
181194
makeRotatableScalable(image);
182195
relativeLayout.addView(image, layoutParams);
183196
}
@@ -195,6 +208,7 @@ public void addTNImageViewsWithBitmap(Context context, List<Bitmap> bitmapList,
195208
layoutParams.bottomMargin = 250 - 500;
196209
layoutParams.rightMargin = 250 - 500;
197210
image.setLayoutParams(layoutParams);
211+
imageList.add(image);
198212
makeRotatableScalable(image);
199213
relativeLayout.addView(image, layoutParams);
200214
}

0 commit comments

Comments
 (0)