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

ReplyPostActivity.java (2593B)


      1 package de.mtbnews.android;
      2 
      3 import android.app.Activity;
      4 import android.content.SharedPreferences;
      5 import android.os.Bundle;
      6 import android.preference.PreferenceManager;
      7 import android.view.View;
      8 import android.view.View.OnClickListener;
      9 import android.widget.Button;
     10 import android.widget.TextView;
     11 import android.widget.Toast;
     12 import de.mtbnews.android.tapatalk.TapatalkClient;
     13 import de.mtbnews.android.tapatalk.TapatalkException;
     14 import de.mtbnews.android.util.ServerAsyncTask;
     15 import de.mtbnews.android.util.Utils;
     16 
     17 public class ReplyPostActivity extends Activity
     18 {
     19 	private String forumId;
     20 	private String topicId;
     21 	private String subject;
     22 	private String quote;
     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.post);
     32 		prefs = PreferenceManager.getDefaultSharedPreferences(this);
     33 
     34 		topicId = getIntent().getStringExtra("topic_id");
     35 		forumId = getIntent().getStringExtra("forum_id");
     36 		subject = getIntent().getStringExtra("subject");
     37 		quote = getIntent().getStringExtra("quote");
     38 
     39 		ReplyPostActivity.this.setTitle(R.string.reply);
     40 
     41 		final TextView recipient = (TextView) findViewById(R.id.recipient);
     42 		recipient.setVisibility(View.INVISIBLE);
     43 		final TextView label = (TextView) findViewById(R.id.recipient_label);
     44 		label.setVisibility(View.INVISIBLE);
     45 
     46 		final TextView subject = (TextView) findViewById(R.id.subject);
     47 		subject.setText(ReplyPostActivity.this.subject != null ? ReplyPostActivity.this.subject : "");
     48 
     49 		final TextView text = (TextView) findViewById(R.id.content);
     50 		text.setText(quote != null ? "[quote]" + quote + "[/quote]" : "");
     51 
     52 		Button button = (Button) findViewById(R.id.send);
     53 		button.setOnClickListener(new OnClickListener()
     54 		{
     55 
     56 			@Override
     57 			public void onClick(View v)
     58 			{
     59 				new ServerAsyncTask(ReplyPostActivity.this, R.string.send)
     60 				{
     61 
     62 					@Override
     63 					protected void callServer() throws TapatalkException
     64 					{
     65 						TapatalkClient client = ((IBCApplication) getApplication()).getTapatalkClient();
     66 
     67 						// Login.
     68 						if (Utils.loginExceeded(client))
     69 							client.login(prefs.getString("username", ""), prefs.getString("password", ""));
     70 
     71 						client.createReply(forumId, topicId, subject.getText().toString(), text.getText().toString());
     72 					}
     73 
     74 					protected void doOnSuccess()
     75 					{
     76 						Toast.makeText(ReplyPostActivity.this, R.string.sent_ok, Toast.LENGTH_LONG);
     77 						ReplyPostActivity.this.finish();
     78 					}
     79 				}.execute();
     80 			}
     81 		});
     82 	}
     83 }