<commit_before>package com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgameactivity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.R;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.Fruit;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.LeaderboardController;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.ScoreController;

import java.util.*;

/* 
 * Main screen for the game
 * Comments to be added
 * To be modified to implement your own version of the game
 */
public class CatchGameActivity extends Activity {
    boolean play = false;
    boolean launched = false;
    Timer timerFallingFruits;
    Timer timerSpawnFruits;

    int fruitFallDelay = 40;
    int fruitSpawnDelay = 500;
    int fruitFallFactor = 5;
    Bitmap fallingObjectPict;

    List<Fruit> fruitList;
	CatchGameView fruitView;
    LifeView lifeView;
	Button bStart;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

        PreferenceManager.setDefaultValues(this, R.xml.settings, false);
//        ScoreController.getInstance().setLife(PreferenceManager.getDefaultSharedPreferences());

        updateLife();
        updateDifficulty();
        updateIcon();


        setContentView(R.layout.activity_catch_game);

        fruitView = (CatchGameView)findViewById(R.id.l3InfoCatchGameView1);
        lifeView = (LifeView)findViewById(R.id.l3InfoCatchLifeView1);

        bStart = (Button)findViewById(R.id.buttonStart);

        bStart.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				buttonStartClickEventHandler();
			}

		});

        fruitList = Collections.synchronizedList(new ArrayList<Fruit>());
//		testInitFruitList();
		fruitView.setFruitList(fruitList);


        LeaderboardController.getInstance().init(this);
	}

    private void updateIcon() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String iconSelected = prefs.getString("prefIcon", "");

        switch (iconSelected.charAt(0)) {
            case '1':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.apple);
                break;
            case '2':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.doge);
                break;
            case '3':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.bitcoin);
                break;
            case '4':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.waldo);
                break;
            case '5':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.awesome);
                break;
        }
    }

    private void updateDifficulty() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String difficultySelected = prefs.getString("prefDifficulty", "");

        switch (difficultySelected.charAt(0)) {
            case '1':
                this.fruitFallFactor = 3;
                this.fruitFallDelay = 50;
                this.fruitSpawnDelay = 600;
                break;
            case '2':
                this.fruitFallFactor = 5;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 450;
                break;
            case '3':
                this.fruitFallFactor = 8;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 300;
            case '4':
                this.fruitFallFactor = 11;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 150;
                break;
        }<commit_msg>Update difficulty criteria<commit_after>package com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgameactivity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.R;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.Fruit;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.LeaderboardController;
import com.lemoalsauvere.universite.s6.progevenementielle.projetandroid.l3info_catchgamedatastructure.ScoreController;

import java.util.*;

/* 
 * Main screen for the game
 * Comments to be added
 * To be modified to implement your own version of the game
 */
public class CatchGameActivity extends Activity {
    boolean play = false;
    boolean launched = false;
    Timer timerFallingFruits;
    Timer timerSpawnFruits;

    int fruitFallDelay = 40;
    int fruitSpawnDelay = 500;
    int fruitFallFactor = 5;
    Bitmap fallingObjectPict;

    List<Fruit> fruitList;
	CatchGameView fruitView;
    LifeView lifeView;
	Button bStart;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

        PreferenceManager.setDefaultValues(this, R.xml.settings, false);
//        ScoreController.getInstance().setLife(PreferenceManager.getDefaultSharedPreferences());

        updateLife();
        updateDifficulty();
        updateIcon();


        setContentView(R.layout.activity_catch_game);

        fruitView = (CatchGameView)findViewById(R.id.l3InfoCatchGameView1);
        lifeView = (LifeView)findViewById(R.id.l3InfoCatchLifeView1);

        bStart = (Button)findViewById(R.id.buttonStart);

        bStart.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				buttonStartClickEventHandler();
			}

		});

        fruitList = Collections.synchronizedList(new ArrayList<Fruit>());
//		testInitFruitList();
		fruitView.setFruitList(fruitList);


        LeaderboardController.getInstance().init(this);
	}

    private void updateIcon() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String iconSelected = prefs.getString("prefIcon", "");

        switch (iconSelected.charAt(0)) {
            case '1':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.apple);
                break;
            case '2':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.doge);
                break;
            case '3':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.bitcoin);
                break;
            case '4':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.waldo);
                break;
            case '5':
                fallingObjectPict = BitmapFactory.decodeResource(getResources(), R.drawable.awesome);
                break;
        }
    }

    private void updateDifficulty() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String difficultySelected = prefs.getString("prefDifficulty", "");

        switch (difficultySelected.charAt(0)) {
            case '1':
                this.fruitFallFactor = 3;
                this.fruitFallDelay = 50;
                this.fruitSpawnDelay = 600;
                break;
            case '2':
                this.fruitFallFactor = 5;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 450;
                break;
            case '3':
                this.fruitFallFactor = 7;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 350;
            case '4':
                this.fruitFallFactor = 10;
                this.fruitFallDelay = 40;
                this.fruitSpawnDelay = 200;
                break;
        }
{'fraction_non_alphanumeric': 0.08978292987839527, 'fraction_numerical': 0.012501420615979088, 'mean_word_length': 2.7719674239177023, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3147469', 'n_tokens_mistral': 2595, 'n_tokens_neox': 2381, 'n_words': 432}