1

in my android app, I am listing the images' previews with network image view. I want that if user press the previews it opens an activity with viewpager and show the original images of specific item of my recycler view. So, i have a two method in my mind.

1-) I will save two image for each of my images in my database. One of them will be preview image with small size and other one will be the original one. In my main newsfeed, app will load the preview images so download size will be smaller. And if user press a preview image it will open activity and download the original one.

2-) There will be only original images in my db and i will minimize it's size after the download and if user press the preview it will show the original one directly since it is already downloaded.

I wonder which one is better method, or is there a better method than those?

This is where i set click listeners for my images:

for(int i = 0; i < listItem.getImageCount(); i++) {
        final NetworkImageView niv = new NetworkImageView(context);

        niv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
            }
        });

        holderr.layoutImages.addView(niv);
    }

Thank you.

shanks
  • 342
  • 2
  • 4
  • 16
  • You mean, Something like `WhatsApp` users picture? first it shows the preview or small size, and then if we click on the info we can see the maximum size of that picture.is this what you are looking for? – ʍѳђઽ૯ท Jan 15 '16 at 20:34
  • 1
    yea, exactly i have done some research, now I am doing something like this: I created an activity with viewpager and for example if there are six pictures in preview it creates six fragments inside it, and there are image views inside per fragment (I am following the first option, after activity created, it downloads the original images). But downloading 1920 x 1080 image is a huge process i guess, i wonder what the best dimensions are for a full screen image? – shanks Jan 15 '16 at 20:40
  • I wrote my idea below, for reduce the image **before** downloading, i think you should use `Ask Question`, though. – ʍѳђઽ૯ท Jan 15 '16 at 21:03

1 Answers1

1

You can try this:

How to reduce an Image file size before uploading to a server

The idea is, before sending to the server, that image's size would be decreased and then download it, after that(e.g - in small ImageView),

Use something like this: Full doc: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

android:scaleType="centerCrop"

And then if the users clicked on the info Button(or whatever), the big ImageView will be shown But, with one difference between the height and weight of it than previous ImageView.

Here is an example for using that ImageView with android:scaleType="fitXY" :

<ImageView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:contentDescription="Main Image"
   android:padding="1dp"
   android:scaleType="fitXY"
   android:src="@drawable/balloon" />

http://hmkcode.com/android-designing-whatsapp-like-user-profile-screen/

The point is, i think you don't need to store that image in your sdcard or wherever.just use it(store it) one time with the best quality :)

hope that helps.

Community
  • 1
  • 1
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108