25 |
TextView mDescription; |
TextView mDescription; |
26 |
TextView mCaption; |
TextView mCaption; |
27 |
ImageView mImageView; |
ImageView mImageView; |
28 |
ArrayList<ImageEntry> mImagePaths; |
ArrayList<ImageEntry> mImages; |
29 |
int mIndex; |
int mIndex; |
30 |
|
|
31 |
|
|
37 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
38 |
setContentView(R.layout.pictureview); |
setContentView(R.layout.pictureview); |
39 |
|
|
40 |
mImagePaths = (ArrayList<ImageEntry>) getIntent().getSerializableExtra("images"); |
mImages = (ArrayList<ImageEntry>) getIntent().getSerializableExtra("images"); |
41 |
mIndex = getIntent().getIntExtra("index", 0); |
mIndex = getIntent().getIntExtra("index", 0); |
42 |
|
|
43 |
|
|
63 |
} |
} |
64 |
|
|
65 |
private void loadImage() { |
private void loadImage() { |
66 |
ImageEntry currentImage = mImagePaths.get(mIndex); |
ImageEntry currentImage = mImages.get(mIndex); |
67 |
mBitmap = BitmapFactory.decodeFile( currentImage.path ); |
mBitmap = BitmapFactory.decodeFile( currentImage.path ); |
68 |
mImageView.setImageBitmap(mBitmap); |
mImageView.setImageBitmap(mBitmap); |
69 |
|
|
77 |
|
|
78 |
String pathParts[] = currentImage.path.split("/"); |
String pathParts[] = currentImage.path.split("/"); |
79 |
String fileName = pathParts[ pathParts.length -1]; |
String fileName = pathParts[ pathParts.length -1]; |
80 |
String desc = "" + (mIndex +1) + "/" + mImagePaths.size() + " - " + fileName; |
String desc = "" + (mIndex +1) + "/" + mImages.size() + " - " + fileName; |
81 |
mDescription.setText(desc); |
mDescription.setText(desc); |
82 |
} |
} |
83 |
|
|
98 |
|
|
99 |
switch(item.getItemId()) { |
switch(item.getItemId()) { |
100 |
case CONTEXT_VIEWIMG: |
case CONTEXT_VIEWIMG: |
101 |
String uri = "file://" + mImagePaths.get(mIndex); |
String uri = "file://" + mImages.get(mIndex).path; |
102 |
|
|
103 |
Intent i = new Intent(Intent.ACTION_VIEW); |
Intent i = new Intent(Intent.ACTION_VIEW); |
104 |
i.setDataAndType(Uri.parse(uri), "image/jpeg"); |
i.setDataAndType(Uri.parse(uri), "image/jpeg"); |
127 |
float diff = firstX - x; |
float diff = firstX - x; |
128 |
|
|
129 |
if (diff > 150) { |
if (diff > 150) { |
130 |
int newIndex = Math.min(mIndex+1, mImagePaths.size() -1); |
int newIndex = Math.min(mIndex+1, mImages.size() -1); |
131 |
loadImage(newIndex); |
loadImage(newIndex); |
132 |
firstX = null; |
firstX = null; |
133 |
return false; |
return false; |