Java Code Examples for android.widget.ImageView.setMaxHeight()

The following are Jave code examples for showing how to use setMaxHeight() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: zero-to-app-emojistories   File: StoryAdapter.java   View Source Code Vote up 8 votes
public void addImage(StorageReference storageRef, String filePath, String storyId) {
    storyId += "-photo";

    removeStuffWithThisKey(storyId);

    final ImageView imageThing = new ImageView(myContext);

    int gridThingPixels = (int) myContext.getResources().getDimension(R.dimen.grid_thing);
    imageThing.setMaxHeight(gridThingPixels);
    imageThing.setMaxWidth(gridThingPixels);

    gridContents.add(new TaggedView(imageThing, storyId));

    this.notifyDataSetChanged();


    // and a photo (up to 10mb)
    Task<byte[]> imageDownloadTask = storageRef.child(filePath).getBytes(100 * 1024 * 1024);
    imageDownloadTask.addOnCompleteListener(new OnCompleteListener<byte[]>() {
        @Override
        public void onComplete(@NonNull Task<byte[]> task) {
            byte[] imageBytes = task.getResult();

            Bitmap imageBitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
            imageThing.setImageBitmap(imageBitmap);

            StoryAdapter.this.notifyDataSetChanged();
        }
    });
}
 
Example 2
Project: MyFire   File: MultiImageView.java   View Source Code Vote up 7 votes
private ImageView createImageView(int position, final boolean isMultiImage) {
	String url = imagesList.get(position);
	ImageView imageView = new ColorFilterImageView(getContext());
	if(isMultiImage){
		imageView.setScaleType(ScaleType.CENTER_CROP);
		imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
	}else {
		imageView.setAdjustViewBounds(true);
		imageView.setScaleType(ScaleType.CENTER_CROP);
		imageView.setMaxHeight(pxOneMaxWandH);
		imageView.setLayoutParams(onePicPara);
	}

	imageView.setTag(R.string.zone_img_position,position);
	imageView.setId(url.hashCode());
	imageView.setOnClickListener(mImageViewOnClickListener);
	ImageLoaderUtils.display(getContext(), imageView, ImageUtil.getImageUrl(url));
	return imageView;
}
 
Example 3
Project: mi-firma-android   File: InitiativeAdapter.java   View Source Code Vote up 7 votes
public View getView(int position, View convertView,
                    ViewGroup parent) {
    if(convertView==null){
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        convertView = inflater.inflate(R.layout.fragment_initiative_item, parent, false);
    }
    // Obtenemos el elemento.
    Initiative objectItem = initiativeList.get(position);

    // Componemos la vista con los datos del elemento.
    TextView titleTextViewItem = (TextView) convertView.findViewById(R.id.initiative_title);

    byte[] byteArray = objectItem.getBanner();
    ImageView imageView = (ImageView) convertView.findViewById(R.id.initiative_image);
    Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
    imageView.setImageBitmap(bmp);
    imageView.setMaxHeight(5);

    titleTextViewItem.setText(objectItem.getTitle());

    return convertView;
}
 
Example 4
Project: zero-to-app-emojistories   File: StoryAdapter.java   View Source Code Vote up 5 votes
public void addImage(byte[] imageBytes, String storyId) {
    storyId += "-photo";

    removeStuffWithThisKey(storyId);

    ImageView imageThing = new ImageView(myContext);

    int gridThingPixels = (int) myContext.getResources().getDimension(R.dimen.grid_thing);
    imageThing.setMaxHeight(gridThingPixels);
    imageThing.setMaxWidth(gridThingPixels);

    Bitmap imageBitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
    imageThing.setImageBitmap(imageBitmap);

    gridContents.add(new TaggedView(imageThing, storyId));

    this.notifyDataSetChanged();
}