Android Open Source - MentalMathX Dialog Results View






From Project

Back to project page MentalMathX.

License

The source code is released under:

GNU General Public License

If you think the Android project MentalMathX 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 net.schlingel.bplaced.mentalmathx.view.impl;
//from   w w  w. ja v a  2  s .  c o m

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import net.schlingel.bplaced.mentalmathx.R;
import net.schlingel.bplaced.mentalmathx.model.Result;
import net.schlingel.bplaced.mentalmathx.utils.LabelHelper;
import net.schlingel.bplaced.mentalmathx.view.ResultsView;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;
import org.w3c.dom.Text;

/**
 * Created by zombie on 29.06.14.
 */
public class DialogResultsView extends DialogFragment implements ResultsView, View.OnClickListener {
    private FragmentActivity host;

    TextView txtVwTime;

    TextView txtVwCorrectGuesses;

    TextView txtVwWrongGuesses;

    TextView txtVwSummary;

    Button btnOK;

    private Result result;

    public static DialogResultsView from(FragmentActivity host) {
        DialogResultsView dlg = new DialogResultsView();
        dlg.setHost(host);

        return dlg;
    }

    @Override
    public void show(Result results) {
        result = results;
        show(host.getSupportFragmentManager(), this.getClass().getSimpleName());
    }

    public void setHost(FragmentActivity host) {
        this.host = host;
    }

    @Override
    public void onClick(View view) {
        listener.onOK(this);
    }

    public interface OKListener {
        public void onOK(DialogFragment fragment);
    }

    private OKListener listener;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_results_view, container, false);

        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        txtVwSummary = (TextView)view.findViewById(R.id.txtVwSummary);
        txtVwTime = (TextView)view.findViewById(R.id.txtVwTime);
        txtVwCorrectGuesses = (TextView)view.findViewById(R.id.txtVwCorrectGuesses);
        txtVwWrongGuesses = (TextView)view.findViewById(R.id.txtVwWrongGuesses);
        btnOK = (Button)view.findViewById(R.id.btnOK);

        txtVwCorrectGuesses.setText(Integer.toString(result.getCorrectGuesses()));
        txtVwWrongGuesses.setText(Integer.toString(result.getWrongGuesses()));
        txtVwTime.setText(LabelHelper.timeLabelFrom(result.getTime()));
        txtVwSummary.setText(LabelHelper.summaryLabelFor(result.getMode(), host));
        btnOK.setOnClickListener(this);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        return dialog;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        if(activity instanceof OKListener) {
            this.listener = (OKListener)activity;
        } else {
            throw new IllegalArgumentException("Activity must be an OKListener instance!");
        }
    }
}




Java Source Code List

net.schlingel.bplaced.mentalmathx.AboutActivity.java
net.schlingel.bplaced.mentalmathx.GameActivity.java
net.schlingel.bplaced.mentalmathx.HighscoresActivity.java
net.schlingel.bplaced.mentalmathx.NewGameActivity.java
net.schlingel.bplaced.mentalmathx.SelectDifficultyActivity.java
net.schlingel.bplaced.mentalmathx.controller.GameController.java
net.schlingel.bplaced.mentalmathx.controller.HighscoreController.java
net.schlingel.bplaced.mentalmathx.controller.impl.GameControllerImpl.java
net.schlingel.bplaced.mentalmathx.controller.impl.HighscoreControllerImpl.java
net.schlingel.bplaced.mentalmathx.game.Difficulty.java
net.schlingel.bplaced.mentalmathx.game.Mode.java
net.schlingel.bplaced.mentalmathx.game.logic.FiniteGameLogic.java
net.schlingel.bplaced.mentalmathx.game.logic.GameLogic.java
net.schlingel.bplaced.mentalmathx.game.logic.HoundredRoundsGameLogic.java
net.schlingel.bplaced.mentalmathx.game.logic.InfiniteGameLogic.java
net.schlingel.bplaced.mentalmathx.game.logic.TenExercisesGameLogic.java
net.schlingel.bplaced.mentalmathx.game.logic.TenRoundsGameLogic.java
net.schlingel.bplaced.mentalmathx.game.strategy.EasyExerciseStrategy.java
net.schlingel.bplaced.mentalmathx.game.strategy.ExerciseStrategyFactory.java
net.schlingel.bplaced.mentalmathx.game.strategy.ExerciseStrategy.java
net.schlingel.bplaced.mentalmathx.game.strategy.HardExerciseStrategy.java
net.schlingel.bplaced.mentalmathx.game.strategy.MediumExerciseStrategy.java
net.schlingel.bplaced.mentalmathx.game.strategy.OneOOneExerciseStrategy.java
net.schlingel.bplaced.mentalmathx.math.Calculation.java
net.schlingel.bplaced.mentalmathx.math.Calculations.java
net.schlingel.bplaced.mentalmathx.math.Number.java
net.schlingel.bplaced.mentalmathx.math.Operator.java
net.schlingel.bplaced.mentalmathx.math.Term.java
net.schlingel.bplaced.mentalmathx.model.Result.java
net.schlingel.bplaced.mentalmathx.model.Score.java
net.schlingel.bplaced.mentalmathx.model.adapters.ScoreAdapter.java
net.schlingel.bplaced.mentalmathx.utils.DatabaseHelper.java
net.schlingel.bplaced.mentalmathx.utils.DelayedTask.java
net.schlingel.bplaced.mentalmathx.utils.LabelHelper.java
net.schlingel.bplaced.mentalmathx.utils.MarathonScoreComparator.java
net.schlingel.bplaced.mentalmathx.utils.RegularScoreComparator.java
net.schlingel.bplaced.mentalmathx.view.DisplayMode.java
net.schlingel.bplaced.mentalmathx.view.GameView.java
net.schlingel.bplaced.mentalmathx.view.HighscoresView.java
net.schlingel.bplaced.mentalmathx.view.ResultsView.java
net.schlingel.bplaced.mentalmathx.view.impl.DialogResultsView.java
net.schlingel.bplaced.mentalmathx.view.impl.FragmentHighscoresSubView.java