--- android/Side9/src/dk/thoerup/side9/PictureView.java 2010/11/02 13:53:49 1184 +++ android/Side9/src/dk/thoerup/side9/PictureView.java 2010/11/02 17:08:57 1185 @@ -1,8 +1,6 @@ package dk.thoerup.side9; -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; + import java.util.ArrayList; import android.app.Activity; @@ -27,7 +25,7 @@ TextView mDescription; TextView mCaption; ImageView mImageView; - ArrayList mImagePaths; + ArrayList mImagePaths; int mIndex; @@ -39,7 +37,7 @@ super.onCreate(savedInstanceState); setContentView(R.layout.pictureview); - mImagePaths = (ArrayList) getIntent().getSerializableExtra("files"); + mImagePaths = (ArrayList) getIntent().getSerializableExtra("images"); mIndex = getIntent().getIntExtra("index", 0); @@ -65,44 +63,26 @@ } private void loadImage() { - String currentFile = mImagePaths.get(mIndex); - mBitmap = BitmapFactory.decodeFile( currentFile ); + ImageEntry currentImage = mImagePaths.get(mIndex); + mBitmap = BitmapFactory.decodeFile( currentImage.path ); mImageView.setImageBitmap(mBitmap); + - String pathParts[] = currentFile.split("/"); - String fileName = pathParts[ pathParts.length -1]; - String desc = "" + (mIndex +1) + "/" + mImagePaths.size() + " - " + fileName; - mDescription.setText(desc); - - String infoFileName = currentFile.replace(".jpg", ".txt"); - - File infoFile = new File(infoFileName); - if (infoFile.exists() ) { - String caption = getFileContent(infoFile); + if (currentImage.caption.length() > 0) { mCaption.setVisibility(View.VISIBLE); - mCaption.setText(caption); - + mCaption.setText(currentImage.caption); } else { mCaption.setVisibility(View.INVISIBLE); } + + String pathParts[] = currentImage.path.split("/"); + String fileName = pathParts[ pathParts.length -1]; + String desc = "" + (mIndex +1) + "/" + mImagePaths.size() + " - " + fileName; + mDescription.setText(desc); } - String getFileContent(File filename) { - try { - RandomAccessFile raf = new RandomAccessFile(filename, "r"); - int size = (int)raf.length(); - byte buf[] = new byte[size]; - - raf.readFully(buf); - return new String(buf); - } catch (IOException e) { - Log.e(TAG, "Error", e); - return ""; - } - } - @Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(Menu.NONE, CONTEXT_VIEWIMG, Menu.NONE, "Built-in viewer");