Beispiel #1
0
 @Override
 public void onDestroyView() {
   super.onDestroyView();
   InputFragmentView = null; // now cleaning up!
   gifFromResource.recycle();
   Log.d("Exercise Type", "DestroyView Called");
 }
 private void loadImage(String path) {
   if (path.endsWith(".gif")) {
     try {
       GifDrawable drawable = new GifDrawable(path);
       imageView.setImageDrawable(drawable);
       drawable.start();
     } catch (IOException e) {
       e.printStackTrace();
     }
   } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
     usingTileBitmap(path);
   }
   if (imageView.getDrawable() == null) {
     imageView.setImageDrawable(Drawable.createFromPath(path));
   }
   imageView.setOnClickListener(clicked);
 }
 private void setFace(SpannableStringBuilder spb, String smileName, int length) {
   String path = SmileTable.get(smileName);
   try {
     int height = (int) editTextFastReply.getTextSize() * 2;
     GifDrawable drawable = new GifDrawable(ChhApplication.getInstance().getAssets(), path);
     // Drawable drawable = Drawable.createFromStream(getResources().getAssets().open(path),
     // smileName);
     drawable.setBounds(0, 0, height, height);
     ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
     SpannableString spanStr = new SpannableString(smileName);
     spanStr.setSpan(imageSpan, 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     spb.append(spanStr);
   } catch (IOException e) {
     e.printStackTrace();
     spb.append(smileName);
   }
 }
    @Override
    public void onDestroyView() {
      Drawable drawable = imageView.getDrawable();
      if (drawable != null) {
        if (drawable instanceof GifDrawable) {
          ((GifDrawable) drawable).recycle();
        } else {
          drawable.setCallback(null);
        }
        imageView.setImageDrawable(null);
      }

      super.onDestroyView();
      if (task != null && task.loading && !task.isCancelled()) {
        task.cancel(true);
      }
    }