Skip to content

Commit

Permalink
Big refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiktorl4z committed May 1, 2017
1 parent 887ca40 commit b25d2bb
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 709 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/l4z/quizapp/FileHelper.java
@@ -1,8 +1,10 @@
package com.example.l4z.quizapp;

import android.content.res.AssetManager;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
Expand Down
93 changes: 0 additions & 93 deletions app/src/main/java/com/example/l4z/quizapp/FinalScoreTable.java

This file was deleted.

23 changes: 7 additions & 16 deletions app/src/main/java/com/example/l4z/quizapp/FinalScreenActivity.java
Expand Up @@ -5,15 +5,13 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

import static com.example.l4z.quizapp.MainActivity.QUESTIONS_INTENT;
Expand All @@ -30,22 +28,18 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_final);


userName = getIntent().getExtras().getString(MainMenu.KOX);

textView = (TextView)findViewById(R.id.text_message);
checkBox = (CheckBox)findViewById(R.id.checkBox);
textView = (TextView) findViewById(R.id.text_message);
checkBox = (CheckBox) findViewById(R.id.checkBox);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
feedback = "I want more!";
} else{
} else {
feedback = "";
}
});




ArrayList<String> list = getIntent().getExtras().getStringArrayList(QUESTIONS_INTENT);
pointsGained = (TextView) findViewById(R.id.pointsGained);
pointsGained.setText(list.get(0));
Expand All @@ -72,14 +66,14 @@ protected void onCreate(Bundle savedInstanceState) {
imageView.setImageResource(R.drawable.silver);
}

email = (ImageView)findViewById(R.id.emailImage);
email = (ImageView) findViewById(R.id.emailImage);
email.setOnClickListener((View.OnClickListener) v -> {
EditText editText = (EditText) findViewById(R.id.feedBackText);
String comment = editText.getText().toString();
String commentLike = comment + " " + feedback;
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","WiktorKalinowski@gmail.com", null));
intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback Quiz App Game from " );
"mailto", "WiktorKalinowski@gmail.com", null));
intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback Quiz App Game from ");
intent.putExtra(Intent.EXTRA_TEXT, commentLike);
try {
startActivity(Intent.createChooser(intent, "Send mail..."));
Expand All @@ -96,7 +90,4 @@ protected void onCreate(Bundle savedInstanceState) {
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}



}
3 changes: 0 additions & 3 deletions app/src/main/java/com/example/l4z/quizapp/MainActivity.java
Expand Up @@ -5,7 +5,6 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.l4z.quizapp.information.Question;

Expand Down Expand Up @@ -292,12 +291,10 @@ public void showFinalScreen() {
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);

}
}
3 changes: 0 additions & 3 deletions app/src/main/java/com/example/l4z/quizapp/MainMenu.java
Expand Up @@ -3,8 +3,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;

Expand All @@ -14,7 +12,6 @@ public class MainMenu extends AppCompatActivity {
Button championButton, itemButton, spellsButton;
EditText editText;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Expand Up @@ -3,21 +3,17 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.widget.Button;

import com.example.l4z.quizapp.information.Question;

import java.util.List;


/**
* A {@link android.support.v4.app.FragmentStatePagerAdapter} that returns a fragment
* representing an object in the collection.
*/
public class QuestionCollectionPagerAdapter extends FragmentStatePagerAdapter {

Button buttonAnswer;

private final List<Question> questions;

public QuestionCollectionPagerAdapter(FragmentManager fm, List<Question> questions) {
Expand Down Expand Up @@ -49,6 +45,4 @@ public List<Question> getQuestions() {
public CharSequence getPageTitle(int position) {
return "QUESTION " + (position + 1);
}


}
13 changes: 3 additions & 10 deletions app/src/main/java/com/example/l4z/quizapp/QuestionFragment.java
@@ -1,10 +1,8 @@
package com.example.l4z.quizapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -15,18 +13,17 @@
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.l4z.quizapp.information.Question;

public class QuestionFragment extends Fragment {


private static final String questionKey = "question";


private Question question;
private TextView mQuestion;
private RadioGroup mRadioGroup;
private RadioButton mRadioButton1,mRadioButton2,mRadioButton3;
private RadioButton mRadioButton1, mRadioButton2, mRadioButton3;
private Button mButtonAnswer;
private ImageView mImageView;
private boolean lastQuestion;
Expand All @@ -49,15 +46,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mRadioButton3 = (RadioButton) rootView.findViewById(R.id.answer3);
mImageView = (ImageView) rootView.findViewById(R.id.imageView);


mButtonAnswer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
QuestionFragment.this.showAnswers();
}
});

if(lastQuestion){
if (lastQuestion) {
mButtonAnswer.setVisibility(View.VISIBLE);
}

Expand Down Expand Up @@ -104,15 +100,12 @@ public void setLastQuestion(boolean lastQuestion) {
this.lastQuestion = lastQuestion;
}


@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(questionKey, question);

}


@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/l4z/quizapp/SplashScreen.java
Expand Up @@ -6,7 +6,7 @@
import android.os.Bundle;
import android.util.Log;

public class SplashScreen extends Activity{
public class SplashScreen extends Activity {

private static final int CZAS = 2000;

Expand All @@ -30,7 +30,7 @@ public void run() {
Log.e("SplashScreen", e.getMessage());
}

Intent intent = new Intent(SplashScreen.this, MainMenu.class);
Intent intent = new Intent(SplashScreen.this, MainMenu.class);
SplashScreen.this.startActivity(intent);
SplashScreen.this.finish();
}
Expand Down

0 comments on commit b25d2bb

Please sign in to comment.