android-openrat

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-openrat.git
Log | Files | Refs

FileShowActivity.java (1266B)


      1 /**
      2  * 
      3  */
      4 package de.openrat.android.client;
      5 
      6 import java.io.IOException;
      7 
      8 import android.app.Activity;
      9 import android.graphics.Bitmap;
     10 import android.graphics.BitmapFactory;
     11 import android.os.Bundle;
     12 import android.widget.ImageView;
     13 import de.openrat.android.client.util.OpenRatClientAsyncTask;
     14 import de.openrat.client.OpenRatClient;
     15 
     16 /**
     17  * @author dankert
     18  * 
     19  */
     20 public class FileShowActivity extends Activity
     21 {
     22 	public static final String ID = "id";
     23 	public static final String CLIENT = "client";
     24 	private String objectid;
     25 	private OpenRatClient client;
     26 
     27 	byte[] data;
     28 
     29 	@Override
     30 	protected void onCreate(Bundle savedInstanceState)
     31 	{
     32 		super.onCreate(savedInstanceState);
     33 
     34 		client = (OpenRatClient) getIntent().getSerializableExtra(CLIENT);
     35 
     36 		new OpenRatClientAsyncTask(this, R.string.waitingforcontent)
     37 		{
     38 
     39 			@Override
     40 			protected void callServer() throws IOException
     41 			{
     42 				objectid = getIntent().getStringExtra(ID);
     43 				data = client.getFileContent(objectid);
     44 			}
     45 
     46 			protected void doOnSuccess()
     47 			{
     48 				Bitmap imageBitmap = BitmapFactory.decodeByteArray(data,0,data.length);
     49 				setContentView(R.layout.show_image);
     50 				ImageView image = (ImageView) findViewById(R.id.image);
     51 				image.setImageBitmap(imageBitmap);
     52 			}
     53 
     54 		}.execute();
     55 	}
     56 
     57 }