source:
issm/oecreview/Archive/14312-15392/ISSM-15012-15013.diff@
15393
Last change on this file since 15393 was 15393, checked in by , 12 years ago | |
---|---|
File size: 19.5 KB |
-
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryAdapter.java
3 3 import java.util.List; 4 4 5 5 import android.app.Activity; 6 import android.graphics.drawable.Drawable;7 6 import android.view.View; 8 7 import android.view.ViewGroup; 9 8 import android.widget.BaseAdapter; … … 16 15 17 16 private static ImageView imageView; 18 17 19 private List<Drawable> plotsImages;20 18 19 private List<Integer> plotsImages; 21 20 private static ViewHolder holder; 21 22 public GalleryAdapter(Activity context, List<Integer> plotsImages) 23 { 24 this.context = context; 25 this.plotsImages = plotsImages; 26 } 22 27 23 public GalleryAdapter(Activity context, List<Drawable> plotsImages) {24 28 25 this.context = context;26 this.plotsImages = plotsImages;27 28 }29 30 29 @Override 31 30 public int getCount() { 32 31 return plotsImages.size(); … … 64 63 holder = (ViewHolder) convertView.getTag(); 65 64 } 66 65 67 holder.imageView.setImageDrawable(plotsImages.get(position));68 66 67 holder.imageView.setImageBitmap(ImageList.getImageList().get(position)); 69 68 holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY); 70 69 holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90)); 71 70 -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MenuPage.java
12 12 public class MenuPage extends Activity 13 13 { 14 14 ISSM issm = new ISSM(); 15 GalleryImage gallery = new GalleryImage();15 //GalleryImage gallery = new GalleryImage(); 16 16 private String issmFolder; 17 17 //------------------------------------------------------------------------ 18 18 public void onCreate(Bundle icicle) -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryImage.java
5 5 import android.app.Activity; 6 6 import android.content.Intent; 7 7 import android.graphics.Bitmap; 8 import android.graphics.drawable.BitmapDrawable;9 import android.graphics.drawable.Drawable;10 8 import android.os.Bundle; 11 9 import android.view.View; 12 10 import android.view.View.OnClickListener; … … 33 31 34 32 private int selectedImagePosition = 0; 35 33 36 private List<Drawable> drawables; 34 //private List<Drawable> drawables; 35 private List<Integer> drawables; 37 36 38 37 private GalleryAdapter galImageAdapter; 39 38 … … 184 183 185 184 private void getDrawablesList() { 186 185 187 drawables = new ArrayList< Drawable>();188 186 drawables = new ArrayList<Integer>(); 187 int resID; 189 188 for (int i = 0; i < 17; i++) 190 189 { 191 drawables.add(getResources().getDrawable(getResources().getIdentifier("image"+i, "drawable", getPackageName()))); 190 resID=getResources().getIdentifier("image"+i, "drawable", getPackageName()); 191 drawables.add(resID); 192 192 193 } 193 194 194 } 195 195 196 196 private void setSelectedImage(int selectedImagePosition) { 197 198 BitmapDrawable bd = (BitmapDrawable) drawables.get(selectedImagePosition); 199 Bitmap b = Bitmap.createScaledBitmap(bd.getBitmap(), (int) (bd.getIntrinsicHeight() * 0.9), (int) (bd.getIntrinsicWidth() * 0.7), false); 197 198 int width= getResources().getDisplayMetrics().widthPixels; 199 int height= getResources().getDisplayMetrics().heightPixels; 200 Bitmap b; 201 b = ImageResizer.decodeSampledBitmapFromResource(getResources(), drawables.get(selectedImagePosition), width, height); 202 b = Bitmap.createScaledBitmap(b, width, height, true); 200 203 selectedImageView.setImageBitmap(b); 201 204 selectedImageView.setScaleType(ScaleType.FIT_XY); 202 205 selectedTextView.setText(description.getDescription(selectedImagePosition )); -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorBar.java
1 1 package gov.nasa.jpl.issm; 2 2 3 import java.text.DecimalFormat;4 5 3 import android.content.Context; 6 4 import android.graphics.Canvas; 7 5 import android.graphics.Color; 8 6 import android.graphics.Paint; 9 7 import android.util.AttributeSet; 10 import android.view.MotionEvent;11 8 import android.view.View; 12 9 ///////////////////////////////////////////////////////////// 13 10 public class ColorBar extends View … … 18 15 private int width = 30; 19 16 private int start_x = 10; 20 17 private int start_y = 10; 21 private int end_y = 0;18 //private int end_y = 0; 22 19 boolean touch; 23 20 final int MAX_SCALING =255; 24 21 double [][] colorBuffer; … … 75 72 } 76 73 y+=3; 77 74 } 78 end_y = y;75 //end_y = y; 79 76 } 80 77 //---------------------------------------------------------------- 81 78 /*allow user to move color bar around -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSM.java
8 8 import android.os.Bundle; 9 9 import android.app.Activity; 10 10 import android.app.ProgressDialog; 11 import android.graphics.Matrix;12 11 import android.util.DisplayMetrics; 13 12 import android.view.GestureDetector; 14 13 import android.view.Gravity; -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSMAPP.java
6 6 import java.io.InputStream; 7 7 import java.io.OutputStream; 8 8 import android.app.Activity; 9 import android.app.ProgressDialog; 9 10 import android.os.AsyncTask; 10 11 import android.os.Bundle; 11 12 import android.os.Environment; … … 21 22 /////////////////////////////////////////////////////////////////////////// 22 23 public class ISSMAPP extends Activity 23 24 { 24 MenuPage mp = new MenuPage();25 ImageList imageList; 25 26 private static final String PREFERENCE_FIRST_RUN = null; 26 27 private String extStorageDirectory; 27 28 private String issmFolder; 28 29 SharedPreferences settings; 30 private ProgressDialog progressDialog; 29 31 //------------------------------------------------------------------------ 30 32 public void onCreate(Bundle icicle) 31 33 { … … 35 37 boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true); 36 38 extStorageDirectory = Environment.getExternalStorageDirectory().toString(); 37 39 issmFolder = extStorageDirectory + "/ISSM/input_files/"; 38 40 imageList = new ImageList(this); 39 41 new CopyDataTask().execute(firstrun); 40 42 } 41 43 //------------------------------------------------------------------------------------------- … … 46 48 @Override 47 49 protected Boolean doInBackground(Boolean... target) 48 50 { 49 StartAnimations(); 50 try { 51 Thread.sleep(3000); 52 } catch (InterruptedException e1) { 53 // TODO Auto-generated catch block 54 e1.printStackTrace(); 55 } 51 imageList.decodeAndResizeImage(); 56 52 //not sure why, but target[0] can be true on install! more to be done. 57 53 //if(target[0] = false) 58 54 //{ … … 65 61 //} 66 62 return true; 67 63 } 64 @Override 65 protected void onPreExecute() 66 { 67 progressDialog = new ProgressDialog(ISSMAPP.this); 68 progressDialog.setMessage("Loading Data"); 69 progressDialog.setIndeterminate(true); 70 progressDialog.setCancelable(false); 71 progressDialog.show(); 72 } 68 73 protected void onPostExecute(Boolean result) 69 74 { 75 progressDialog.dismiss(); 70 76 Intent i = new Intent(ISSMAPP.this, MenuPage.class); 71 77 i.putExtra("pathToFile", issmFolder); 72 78 startActivity(i); … … 77 83 { 78 84 if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) 79 85 { 80 System.out.println(issmFolder);81 86 File txtDirectory = new File(issmFolder); 82 87 83 88 // Check and create directory in SDcard 84 89 if(!txtDirectory.exists()) 85 90 { 86 91 txtDirectory.mkdirs(); 87 System.out.println("making directory");88 92 } 89 93 CopyAssets(); // Then run the method to copy the file. 90 94 … … 126 130 Log.e("tag", e.getMessage()); 127 131 } 128 132 } 129 System.out.println("Done");130 133 } 131 134 //---------------------------------------------------------------------------- 132 135 private void copyFile(InputStream in, OutputStream out) throws IOException -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageList.java
1 package gov.nasa.jpl.issm; 2 3 import java.util.ArrayList; 4 5 import android.content.Context; 6 import android.graphics.Bitmap; 7 8 public class ImageList 9 { 10 private static ArrayList <Bitmap> imageList; 11 private Context context; 12 final int nImage = 17; 13 //---------------------------------------------------------- 14 public ImageList(Context context) 15 { 16 imageList = new ArrayList <Bitmap>(); 17 this.context = context; 18 } 19 //---------------------------------------------------------- 20 public void decodeAndResizeImage() 21 { 22 int resID; 23 for(int i = 0 ; i < nImage; i++) 24 { 25 resID=context.getResources().getIdentifier("image"+i, "drawable", context.getPackageName()); 26 imageList.add(ImageResizer.decodeSampledBitmapFromResource(context.getResources(), resID , 50, 50)); 27 } 28 } 29 //---------------------------------------------------------- 30 public static ArrayList<Bitmap> getImageList() 31 { 32 return imageList; 33 } 34 } -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ZoomImageView.java
16 16 package gov.nasa.jpl.issm; 17 17 18 18 import android.content.Context; 19 import android.graphics.Bitmap; 19 20 import android.graphics.Canvas; 21 import android.graphics.drawable.BitmapDrawable; 20 22 import android.graphics.drawable.Drawable; 21 23 import android.util.AttributeSet; 22 24 import android.view.MotionEvent; … … 26 28 27 29 public class ZoomImageView extends View { 28 30 private static final int INVALID_POINTER_ID = -1; 29 31 private Bitmap b; 30 32 private Drawable mIcon; 31 33 private float mPosX; 32 34 private float mPosY; 33 34 35 private float mLastTouchX; 35 36 private float mLastTouchY; 36 37 private int mActivePointerId = INVALID_POINTER_ID; … … 38 39 private ScaleGestureDetector mScaleDetector; 39 40 private float mScaleFactor = 1.f; 40 41 42 41 43 public ZoomImageView(Context context, int i) { 42 44 this(context, null, 0, i); 43 45 } … … 46 48 this(context, attrs, 0 ,i); 47 49 } 48 50 51 49 52 public ZoomImageView(Context context, AttributeSet attrs, int defStyle, int i) { 50 53 super(context, attrs, defStyle); 51 mIcon = getResources().getDrawable(getResources().getIdentifier("image"+i, "drawable", context.getPackageName())); 54 int resID2 = getResources().getIdentifier("image"+i, "drawable", context.getPackageName()); 55 //mIcon = getResources().getDrawable(resID); 52 56 int width= context.getResources().getDisplayMetrics().widthPixels; 53 57 int height= context.getResources().getDisplayMetrics().heightPixels; 58 59 60 b = ImageResizer.decodeSampledBitmapFromResource(getResources(), resID2, width, height); 61 b = Bitmap.createScaledBitmap(b, width, height, true); 62 mIcon = new BitmapDrawable(getResources(), b); 54 63 mIcon.setBounds(0, 0, width, height); 55 56 64 mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); 57 65 } 58 66 … … 133 141 canvas.translate(mPosX, mPosY); 134 142 canvas.scale(mScaleFactor, mScaleFactor); 135 143 mIcon.draw(canvas); 144 // canvas.drawBitmap(b,0,0,null); 136 145 canvas.restore(); 137 146 } 138 147 -
../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageResizer.java
1 package gov.nasa.jpl.issm; 2 3 import android.content.res.Resources; 4 import android.graphics.Bitmap; 5 import android.graphics.BitmapFactory; 6 7 public class ImageResizer { 8 9 public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, 10 int reqWidth, int reqHeight) { 11 12 // First decode with inJustDecodeBounds=true to check dimensions 13 final BitmapFactory.Options options = new BitmapFactory.Options(); 14 options.inJustDecodeBounds = true; 15 BitmapFactory.decodeResource(res, resId, options); 16 17 // Calculate inSampleSize 18 options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); 19 20 // Decode bitmap with inSampleSize set 21 options.inJustDecodeBounds = false; 22 return BitmapFactory.decodeResource(res, resId, options); 23 } 24 25 public static int calculateInSampleSize( 26 BitmapFactory.Options options, int reqWidth, int reqHeight) 27 { 28 // Raw height and width of image 29 int height = options.outHeight; 30 int width = options.outWidth; 31 int inSampleSize = 1; 32 33 if (height > reqHeight || width > reqWidth) { 34 35 // Calculate ratios of height and width to requested height and width 36 final int heightRatio = Math.round((float) height / (float) reqHeight); 37 final int widthRatio = Math.round((float) width / (float) reqWidth); 38 39 // Choose the smallest ratio as inSampleSize value, this will guarantee 40 // a final image with both dimensions larger than or equal to the 41 // requested height and width. 42 inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio; 43 } 44 45 return inSampleSize; 46 47 } 48 49 } -
../trunk-jpl/src/mobile/android/ISSM_APP/res/anim/translate.xml
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
8 8 android:toXDelta="0%" 9 9 android:fromYDelta="200%" 10 10 android:toYDelta="0%" 11 android:duration=" 2000"11 android:duration="3000" 12 12 android:zAdjustment="top" /> 13 13 14 14 </set> 15 No newline at end of file
Note:
See TracBrowser
for help on using the repository browser.