package com.amazon.aws.demo.s3;
import com.amazon.aws.demo.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
public class S3ObjectView extends Activity{
protected Handler mHandler;
protected TextView loadingText;
protected TextView bodyText;
protected String bucketName;
protected String objectName;
protected String objectData;
private final Runnable postResults = new Runnable() {
@Override
public void run(){
updateUi();
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item_view);
Bundle extras = this.getIntent().getExtras();
bucketName = extras.getString(S3.BUCKET_NAME);
objectName = extras.getString(S3.OBJECT_NAME);
mHandler = new Handler();
loadingText = (TextView) findViewById(R.id.item_view_loading_text);
bodyText = (TextView) findViewById(R.id.item_view_body_text);
startPopulateText();
}
private void startPopulateText(){
Thread t = new Thread() {
@Override
public void run(){
objectData = S3.getDataForObject(bucketName, objectName);
mHandler.post(postResults);
}
};
t.start();
}
private void updateUi(){
loadingText.setText(objectName);
bodyText.setText(objectData);
loadingText.setTextSize(16);
}
}