source: issm/oecreview/Archive/14312-15392/ISSM-15012-15013.diff

Last change on this file was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 19.5 KB
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryAdapter.java

     
    33import java.util.List;
    44
    55import android.app.Activity;
    6 import android.graphics.drawable.Drawable;
    76import android.view.View;
    87import android.view.ViewGroup;
    98import android.widget.BaseAdapter;
     
    1615
    1716                private static ImageView imageView;
    1817
    19                 private List<Drawable> plotsImages;
    20 
     18               
     19                private List<Integer> plotsImages;
    2120                private static ViewHolder holder;
     21               
     22                public GalleryAdapter(Activity context, List<Integer> plotsImages)
     23                {
     24                                this.context = context;
     25                                this.plotsImages = plotsImages;
     26                }
    2227
    23                 public GalleryAdapter(Activity context, List<Drawable> plotsImages) {
    2428
    25                         this.context = context;
    26                         this.plotsImages = plotsImages;
    27 
    28                 }
    29 
    3029                @Override
    3130                public int getCount() {
    3231                        return plotsImages.size();
     
    6463                                holder = (ViewHolder) convertView.getTag();
    6564                        }
    6665
    67                         holder.imageView.setImageDrawable(plotsImages.get(position));
    68 
     66               
     67                holder.imageView.setImageBitmap(ImageList.getImageList().get(position));
    6968                        holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    7069                        holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90));
    7170
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/MenuPage.java

     
    1212public class MenuPage extends Activity
    1313{
    1414        ISSM issm = new ISSM();
    15         GalleryImage gallery = new GalleryImage();
     15        //GalleryImage gallery = new GalleryImage();
    1616        private String issmFolder;
    1717//------------------------------------------------------------------------     
    1818        public void onCreate(Bundle icicle)
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/GalleryImage.java

     
    55import android.app.Activity;
    66import android.content.Intent;
    77import android.graphics.Bitmap;
    8 import android.graphics.drawable.BitmapDrawable;
    9 import android.graphics.drawable.Drawable;
    108import android.os.Bundle;
    119import android.view.View;
    1210import android.view.View.OnClickListener;
     
    3331
    3432        private int selectedImagePosition = 0;
    3533
    36         private List<Drawable> drawables;
     34        //private List<Drawable> drawables;
     35        private List<Integer> drawables;
    3736
    3837        private GalleryAdapter galImageAdapter;
    3938       
     
    184183
    185184        private void getDrawablesList() {
    186185
    187                 drawables = new ArrayList<Drawable>();
    188                
     186                drawables = new ArrayList<Integer>();
     187                int resID;
    189188                for (int i = 0; i < 17; i++)
    190189                {
    191                         drawables.add(getResources().getDrawable(getResources().getIdentifier("image"+i, "drawable", getPackageName())));
     190                        resID=getResources().getIdentifier("image"+i, "drawable", getPackageName());
     191                        drawables.add(resID);
     192               
    192193                }
    193                
    194194        }
    195195
    196196        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);
    200203                selectedImageView.setImageBitmap(b);
    201204                selectedImageView.setScaleType(ScaleType.FIT_XY);
    202205                selectedTextView.setText(description.getDescription(selectedImagePosition ));
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ColorBar.java

     
    11package gov.nasa.jpl.issm;
    22
    3 import java.text.DecimalFormat;
    4 
    53import android.content.Context;
    64import android.graphics.Canvas;
    75import android.graphics.Color;
    86import android.graphics.Paint;
    97import android.util.AttributeSet;
    10 import android.view.MotionEvent;
    118import android.view.View;
    129/////////////////////////////////////////////////////////////
    1310public class ColorBar extends View
     
    1815    private int width = 30;
    1916        private int start_x = 10;
    2017        private int start_y = 10;
    21         private int end_y = 0;
     18        //private int end_y = 0;
    2219        boolean touch;
    2320        final int MAX_SCALING =255;
    2421        double [][] colorBuffer;
     
    7572                }
    7673                y+=3;
    7774        }
    78         end_y = y;
     75        //end_y = y;
    7976    }
    8077//----------------------------------------------------------------   
    8178    /*allow user to move color bar around
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSM.java

     
    88import android.os.Bundle;
    99import android.app.Activity;
    1010import android.app.ProgressDialog;
    11 import android.graphics.Matrix;
    1211import android.util.DisplayMetrics;
    1312import android.view.GestureDetector;
    1413import android.view.Gravity;
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSMAPP.java

     
    66import java.io.InputStream;
    77import java.io.OutputStream;
    88import android.app.Activity;
     9import android.app.ProgressDialog;
    910import android.os.AsyncTask;
    1011import android.os.Bundle;
    1112import android.os.Environment;
     
    2122///////////////////////////////////////////////////////////////////////////
    2223public class ISSMAPP extends Activity
    2324{
    24         MenuPage mp = new MenuPage();
     25        ImageList imageList;
    2526        private static final String PREFERENCE_FIRST_RUN = null;
    2627        private String extStorageDirectory;
    2728        private String issmFolder;
    2829        SharedPreferences settings;
     30        private ProgressDialog progressDialog;
    2931//------------------------------------------------------------------------     
    3032        public void onCreate(Bundle icicle)
    3133        {
     
    3537            boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
    3638            extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    3739            issmFolder = extStorageDirectory + "/ISSM/input_files/";
    38 
     40            imageList = new ImageList(this);
    3941            new CopyDataTask().execute(firstrun);   
    4042        }
    4143//-------------------------------------------------------------------------------------------
     
    4648                        @Override
    4749                        protected Boolean doInBackground(Boolean... target)
    4850                        {
    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();
    5652                                //not sure why, but target[0] can be true on install! more to be done.
    5753                                //if(target[0] = false)
    5854                                //{
     
    6561                                //}
    6662                                return true;
    6763                        }
     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                        }
    6873                        protected void onPostExecute(Boolean result)
    6974                        {
     75                                progressDialog.dismiss();
    7076                                Intent i = new Intent(ISSMAPP.this, MenuPage.class);
    7177                                i.putExtra("pathToFile", issmFolder);
    7278                        startActivity(i);
     
    7783        {
    7884            if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
    7985            {
    80                 System.out.println(issmFolder);
    8186                File txtDirectory = new File(issmFolder);
    8287               
    8388                // Check and create directory in SDcard
    8489                if(!txtDirectory.exists())
    8590                {
    8691                        txtDirectory.mkdirs();
    87                         System.out.println("making directory");
    8892                }
    8993                CopyAssets(); // Then run the method to copy the file.
    9094
     
    126130                            Log.e("tag", e.getMessage());
    127131                        }
    128132                    }
    129                     System.out.println("Done");
    130133                }
    131134//----------------------------------------------------------------------------
    132135                private void copyFile(InputStream in, OutputStream out) throws IOException
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageList.java

     
     1package gov.nasa.jpl.issm;
     2
     3import java.util.ArrayList;
     4
     5import android.content.Context;
     6import android.graphics.Bitmap;
     7
     8public 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

     
    1616package gov.nasa.jpl.issm;
    1717
    1818import android.content.Context;
     19import android.graphics.Bitmap;
    1920import android.graphics.Canvas;
     21import android.graphics.drawable.BitmapDrawable;
    2022import android.graphics.drawable.Drawable;
    2123import android.util.AttributeSet;
    2224import android.view.MotionEvent;
     
    2628
    2729public class ZoomImageView extends View {
    2830    private static final int INVALID_POINTER_ID = -1;
    29    
     31    private Bitmap b;
    3032    private Drawable mIcon;
    3133    private float mPosX;
    3234    private float mPosY;
    33    
    3435    private float mLastTouchX;
    3536    private float mLastTouchY;
    3637    private int mActivePointerId = INVALID_POINTER_ID;
     
    3839    private ScaleGestureDetector mScaleDetector;
    3940    private float mScaleFactor = 1.f;
    4041   
     42   
    4143    public ZoomImageView(Context context, int i) {
    4244        this(context, null, 0, i);
    4345    }
     
    4648        this(context, attrs, 0 ,i);
    4749    }
    4850   
     51   
    4952    public ZoomImageView(Context context, AttributeSet attrs, int defStyle, int i) {
    5053        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);
    5256        int width= context.getResources().getDisplayMetrics().widthPixels;
    5357        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);
    5463        mIcon.setBounds(0, 0, width, height);
    55        
    5664        mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    5765    }
    5866
     
    133141        canvas.translate(mPosX, mPosY);
    134142        canvas.scale(mScaleFactor, mScaleFactor);
    135143        mIcon.draw(canvas);
     144       // canvas.drawBitmap(b,0,0,null);
    136145        canvas.restore();
    137146    }
    138147
  • ../trunk-jpl/src/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ImageResizer.java

     
     1package gov.nasa.jpl.issm;
     2
     3import android.content.res.Resources;
     4import android.graphics.Bitmap;
     5import android.graphics.BitmapFactory;
     6
     7public 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
     
    88    android:toXDelta="0%"
    99    android:fromYDelta="200%"
    1010    android:toYDelta="0%"
    11     android:duration="2000"
     11    android:duration="3000"
    1212    android:zAdjustment="top" />
    1313 
    1414</set>
     15 No newline at end of file
Note: See TracBrowser for help on using the repository browser.