1 /* 2 * Copyright (C) 2003-2015 eXo Platform SAS. 3 * 4 * This is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as 6 * published by the Free Software Foundation; either version 3 of 7 * the License, or (at your option) any later version. 8 * 9 * This software is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this software; if not, write to the Free 16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 17 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 18 */ 19 package org.exoplatform.utils.image; 20 21 import org.exoplatform.R; 22 23 import android.content.Context; 24 import android.graphics.drawable.Drawable; 25 import android.text.Html.ImageGetter; 26 27 /** 28 * An ImageGetter that replaces every {@code <img>} tag by an empty drawable.<br/> 29 * Usage: 30 * 31 * <pre> 32 * EmptyImageGetter emptyImage = new EmptyImageGetter(context); 33 * Html.fromHtml(anHtmlString, emptyImage, null); 34 * </pre> 35 * 36 * @author Philippe Aristote paristote@exoplatform.com 37 * @since May 20, 2015 38 */ 39 public class EmptyImageGetter implements ImageGetter { 40 41 private Context context; 42 43 public EmptyImageGetter(Context ctx) { 44 this.context = ctx; 45 } 46 47 @Override 48 public Drawable getDrawable(String src) { 49 return context.getResources().getDrawable(R.drawable.empty_drawable); 50 } 51 52 }