Android Open Source - stack-overlook Question Activity






From Project

Back to project page stack-overlook.

License

The source code is released under:

MIT License

If you think the Android project stack-overlook listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.sambuo.stackoverlook;
/*from www  . j a  va 2s.  c o  m*/
import com.sambuo.stackoverlook.entities.Question;
import com.sambuo.stackoverlook.repositories.StackOverflowRepository;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.widget.TextView;

public class QuestionActivity extends Activity {
  
  private final StackOverflowRepository repository = StackOverflowRepository.getInstance();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.question);
    
    Intent intent = getIntent();
    if (!intent.hasExtra(AnswersActivity.EXTRA_QUESTION_ID)) {
      Log.e(QuestionActivity.class.toString(), "QuestionId was not given to QuestionActivity");
    }
    
    long questionId = intent.getLongExtra(AnswersActivity.EXTRA_QUESTION_ID, 0);
    String answerBodyString = intent.getStringExtra(AnswersActivity.EXTRA_ANSWER_BODY);
    int answerScoreInt = intent.getIntExtra(AnswersActivity.EXTRA_ANSWER_SCORE, 0);
    Question question = this.repository.getQuestionFromQuestionId(questionId);
    
    TextView title = (TextView) findViewById(R.id.title);
    TextView questionBody = (TextView) findViewById(R.id.questionBody);
    TextView questionScore = (TextView) findViewById(R.id.questionScore);
    TextView answerScore = (TextView) findViewById(R.id.answerScore);
    TextView answerBody = (TextView) findViewById(R.id.answerBody);
    
    title.setText(Html.fromHtml(question.getTitle()));
    questionBody.setText(Html.fromHtml(question.getBody()));
    questionScore.setText(String.format("%d", question.getScore()));
    answerBody.setText(Html.fromHtml(answerBodyString));
    answerScore.setText(String.format("%d", answerScoreInt));
  }
}




Java Source Code List

com.sambuo.stackoverlook.AnswersActivity.java
com.sambuo.stackoverlook.QuestionActivity.java
com.sambuo.stackoverlook.UsersActivity.java
com.sambuo.stackoverlook.entities.Answer.java
com.sambuo.stackoverlook.entities.Question.java
com.sambuo.stackoverlook.entities.User.java
com.sambuo.stackoverlook.repositories.StackOverflowRepository.java
com.sambuo.stackoverlook.utilities.Reducer.java
com.sambuo.stackoverlook.utilities.Utils.java