android-ibc-forum

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

MessageActivity.java (3242B)


      1 package de.mtbnews.android;
      2 
      3 import android.app.Activity;
      4 import android.content.Intent;
      5 import android.content.SharedPreferences;
      6 import android.os.Bundle;
      7 import android.preference.PreferenceManager;
      8 import android.text.format.DateFormat;
      9 import android.view.Menu;
     10 import android.view.MenuInflater;
     11 import android.view.MenuItem;
     12 import android.widget.TextView;
     13 import de.mtbnews.android.tapatalk.TapatalkClient;
     14 import de.mtbnews.android.tapatalk.TapatalkException;
     15 import de.mtbnews.android.tapatalk.wrapper.Message;
     16 import de.mtbnews.android.util.ServerAsyncTask;
     17 import de.mtbnews.android.util.Utils;
     18 
     19 public class MessageActivity extends Activity
     20 {
     21 	private String boxId;
     22 	private String messageId;
     23 	private SharedPreferences prefs;
     24 
     25 	@Override
     26 	protected void onCreate(Bundle savedInstanceState)
     27 	{
     28 		super.onCreate(savedInstanceState);
     29 
     30 		setTheme(((IBCApplication) getApplication()).themeResId);
     31 		setContentView(R.layout.newsdetail);
     32 
     33 		prefs = PreferenceManager.getDefaultSharedPreferences(this);
     34 		boxId = getIntent().getStringExtra("box_id");
     35 		messageId = getIntent().getStringExtra("message_id");
     36 
     37 		new ServerAsyncTask(this, R.string.waitingforcontent)
     38 		{
     39 			private TapatalkClient client;
     40 			private Message message;
     41 
     42 			@Override
     43 			protected void callServer() throws TapatalkException
     44 			{
     45 				client = ((IBCApplication) getApplication()).getTapatalkClient();
     46 
     47 				if (Utils.loginExceeded(client))
     48 					client.login(prefs.getString("username", ""), prefs.getString("password", ""));
     49 
     50 				message = client.getMessage(boxId, messageId);
     51 			}
     52 
     53 			protected void doOnSuccess()
     54 			{
     55 				// MessageActivity.this.setTitle(feed.getTitle());
     56 
     57 				MessageActivity.this.setTitle(message.getTitle());
     58 
     59 				TextView datum = (TextView) findViewById(R.id.item_date);
     60 				datum.setText(DateFormat.getTimeFormat(MessageActivity.this).format(message.getDate()));
     61 
     62 				// TextView name = (TextView) findViewById(R.id.item_title);
     63 				// name.setText(item.getTitle());
     64 
     65 				final TextView desc = (TextView) findViewById(R.id.item_description);
     66 
     67 				// if (e.getContent() != null)
     68 				// final String html = item.getContent();
     69 				desc.setText(message.getContent());
     70 				// setTitle(item.getTitle());
     71 
     72 				// Button button = (Button) findViewById(R.id.item_button);
     73 				// button.setOnClickListener(new OnClickListener()
     74 				// {
     75 				//
     76 				// @Override
     77 				// public void onClick(View v)
     78 				//
     79 				// {
     80 				// Intent i = new Intent(Intent.ACTION_VIEW);
     81 				// // i.setData(item.getLink());
     82 				// startActivity(i);
     83 				// }
     84 				// });
     85 
     86 			}
     87 		}.execute();
     88 
     89 	}
     90 
     91 	@Override
     92 	public boolean onCreateOptionsMenu(Menu menu)
     93 	{
     94 		super.onCreateOptionsMenu(menu);
     95 		MenuInflater mi = new MenuInflater(getApplication());
     96 
     97 		mi.inflate(R.menu.message, menu);
     98 
     99 		return true;
    100 	}
    101 
    102 	public boolean onOptionsItemSelected(MenuItem item)
    103 	{
    104 		switch (item.getItemId())
    105 		{
    106 			case R.id.menu_reply:
    107 				Intent intent = new Intent(this, ReplyMailActivity.class);
    108 				intent.putExtra("message_id", messageId);
    109 				intent.putExtra("box_id", boxId);
    110 				startActivity(intent);
    111 				return true;
    112 
    113 			case R.id.menu_new_message:
    114 				Intent intent2 = new Intent(this, ReplyMailActivity.class);
    115 				startActivity(intent2);
    116 				return true;
    117 		}
    118 		return false;
    119 	}
    120 
    121 }