Commit bddb81ab authored by Luboš Horáček's avatar Luboš Horáček

#285 Třikrát a dost!

parent 3b818629
......@@ -48,7 +48,7 @@
android:value="Tablexia.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="6" />
android:value="7" />
<meta-data
android:name="AA_SERIALIZERS"
android:value="cz.nic.tablexia.menu.MenuEnumSerializer" />
......
ALTER TABLE Users ADD COLUMN PlayCountHallOfFame INTEGER NOT NULL DEFAULT 0;
ALTER TABLE Users ADD COLUMN PlayCountStatistics INTEGER NOT NULL DEFAULT 0;
ALTER TABLE Users ADD COLUMN PlayCountEncyclopedia INTEGER NOT NULL DEFAULT 0;
/*******************************************************************************
* Tablexia
*
*
* Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
......@@ -43,7 +43,7 @@ import cz.nic.tablexia.menu.mainmenu.MainMenuDefinition;
/**
* Class with common menu fragments functionality.
*
*
* @author Matyáš Latner
*/
public abstract class AbstractMenuFragment extends Fragment {
......@@ -67,6 +67,10 @@ public abstract class AbstractMenuFragment extends Fragment {
this.fragmentVisibilityListener = fragmentVisibilityListener;
}
protected void playIntroSound() {
playLongSound(introSoundPath, false);
}
private class FragmentDataPreloader extends AsyncTask<Integer, Void, View> {
View layoutView = null;
......@@ -76,7 +80,7 @@ public abstract class AbstractMenuFragment extends Fragment {
// INTRO SOUND
if (introSoundPath != null) {
playLongSound(introSoundPath, false);
playIntroSound();
}
// LOADING LAYOUT
......@@ -142,7 +146,7 @@ public abstract class AbstractMenuFragment extends Fragment {
/**
* Creates new MenuFragment with specific layout loaded in non UI thread
*
*
* @param layoutId fragment layout id
* @param introSoundPath path of sound file with screen introduction speech
*/
......@@ -152,7 +156,7 @@ public abstract class AbstractMenuFragment extends Fragment {
/**
* Creates new MenuFragment with specific layout
*
*
* @param layoutId fragment layout id
* @param inflateinUIThread <code>true</code> - layout is inflated in UI thread
* @param introSoundPath path of sound file with screen introduction speech
......@@ -190,7 +194,7 @@ public abstract class AbstractMenuFragment extends Fragment {
* Callback method for asynchronous data loading.
* Method is call while is asynchronous data loading processed.
* Method is call outside the UI thread.
*
*
* @param layoutView inflated fragment layout
*/
protected void asyncFragmentDataLoad(View layoutView) {
......@@ -201,7 +205,7 @@ public abstract class AbstractMenuFragment extends Fragment {
* Callback method for synchronous data loading.
* Method is call after asynchronous data loading.
* Method is call in the UI thread.
*
*
* @param layoutView inflated fragment layout
*/
protected void syncFragmentDataLoad(View layoutView) {
......@@ -228,7 +232,7 @@ public abstract class AbstractMenuFragment extends Fragment {
/**
* Return <code>true</code> if fragment is loaded
*
*
* @return <code>true</code> if fragment is loaded
*/
public boolean isLoadingComplete() {
......
......@@ -22,7 +22,6 @@ package cz.nic.tablexia.menu.mainmenu.screen;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
......@@ -30,7 +29,6 @@ import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v4.widget.SlidingPaneLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
......@@ -88,6 +86,14 @@ public class Encyclopedia extends AbstractMenuFragment {
super(R.layout.screen_encyclopedia, SpeechSounds.ENCYCLOPEDIA_INTRO);
}
@Override
protected void playIntroSound() {
if (getTablexiaContext().getSelectedUser().getPlayCountEncyclopedia() < 3) {
super.playIntroSound();
getTablexiaContext().getSelectedUser().addPlayCountEncyclopedia();
}
}
@Override
protected void syncFragmentDataLoad(View view) {
viewPager = (ViewPager) view.findViewById(R.id.screen_encyclopedia);
......
......@@ -131,6 +131,14 @@ public class HallOfFame extends AbstractMenuFragment {
super(R.layout.screen_halloffame, SpeechSounds.HALLOFFAME_INTRO);
}
@Override
protected void playIntroSound() {
if (getTablexiaContext().getSelectedUser().getPlayCountHallOfFame() < 3) {
super.playIntroSound();
getTablexiaContext().getSelectedUser().addPlayCountHallOfFame();
}
}
@Override
protected void asyncFragmentDataLoad(View layoutView) {
contentHorizontalScrollView = (HorizontalScrollView) layoutView;
......
/*******************************************************************************
* Tablexia
*
*
* Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
......@@ -71,7 +71,7 @@ import cz.nic.tablexia.util.Utility;
/**
* Statistics screen fragment.
*
*
* @author Vaclav Tarantik, Matyáš Latner
*/
public class Statistics extends AbstractMenuFragment {
......@@ -143,6 +143,14 @@ public class Statistics extends AbstractMenuFragment {
selectedGameDefinition = INITIALLY_SELECTED_GAME;
}
@Override
protected void playIntroSound() {
if (getTablexiaContext().getSelectedUser().getPlayCountStatistics() < 3) {
super.playIntroSound();
getTablexiaContext().getSelectedUser().addPlayCountStatistics();
}
}
/* //////////////////////////////////////////// TABLEXIA FRAGMENT LIFECYCLE */
@Override
......@@ -394,7 +402,7 @@ public class Statistics extends AbstractMenuFragment {
/**
* Prepares chart view
*
*
* @param fragmentLayout fragments layout view
*/
private void prepareChartView(View fragmentLayout) {
......@@ -556,7 +564,7 @@ public class Statistics extends AbstractMenuFragment {
/**
* Create chart serie and renderer for specific difficulty
*
*
* @param gameDifficulty difficulty for game serie
* @param color
* @param lineWidth
......@@ -569,7 +577,7 @@ public class Statistics extends AbstractMenuFragment {
/**
* Adds new line to chart with selected game and specific game difficulty
*
*
* @param gameDifficulty game difficulty
*/
private void addUserGamesLine(GameDifficulty gameDifficulty) {
......@@ -587,7 +595,7 @@ public class Statistics extends AbstractMenuFragment {
/**
* Adds line for specific difficulty to chart.
*
*
* @param difficult difficulty for add in
* @param gameLogs list of user games
*/
......
/*******************************************************************************
* Tablexia
*
*
* Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
......@@ -64,6 +64,10 @@ public class User extends Model {
@Column(name = "ConsecutivelyAllGames3Stars")
private boolean consecutivelyAllGames3Stars;
@Column(name = "PlayCountHallOfFame") private Integer playCountHallOfFame;
@Column(name = "PlayCountStatistics") private Integer playCountStatistics;
@Column(name = "PlayCountEncyclopedia") private Integer playCountEncyclopedia;
public User() {
super();
}
......@@ -172,6 +176,33 @@ public class User extends Model {
this.consecutivelyAllGames0Stars = consecutivelyAllGames0Stars;
}
public Integer getPlayCountHallOfFame() {
return playCountHallOfFame;
}
public void addPlayCountHallOfFame() {
playCountHallOfFame++;
save();
}
public Integer getPlayCountStatistics() {
return playCountStatistics;
}
public void addPlayCountStatistics() {
playCountStatistics++;
save();
}
public Integer getPlayCountEncyclopedia() {
return playCountEncyclopedia;
}
public void addPlayCountEncyclopedia() {
playCountEncyclopedia++;
save();
}
public static boolean existsUsersForName(String nickName) {
return (new Select().from(User.class).where("NickName = ?", nickName).executeSingle()) != null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment