-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67e7c6f
Showing
106 changed files
with
4,166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
apply plugin: 'com.jakewharton.butterknife' | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.2" | ||
|
||
defaultConfig { | ||
applicationId "org.hiro.memorygame" | ||
minSdkVersion 21 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.3.0' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
|
||
implementation 'com.android.support.constraint:constraint-layout:2.0.4' | ||
implementation 'com.squareup.retrofit2:retrofit:2.6.0' | ||
implementation 'com.google.code.gson:gson:2.8.6' | ||
|
||
implementation 'com.squareup.retrofit2:converter-gson:2.6.0' | ||
|
||
implementation 'com.labo.kaji:fragmentanimations:0.1.1' | ||
implementation 'de.hdodenhof:circleimageview:3.1.0' | ||
|
||
implementation 'com.jakewharton:butterknife:10.2.3' | ||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/org/hiro/memorygame/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.hiro.memorygame; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("org.hiro.memorygame", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.hiro.memorygame"> | ||
|
||
<application | ||
android:name=".app.App" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MemoryGame"> | ||
<activity | ||
android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.hiro.memorygame; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.media.MediaPlayer; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import org.hiro.memorygame.controlller.FragmentController; | ||
import org.hiro.memorygame.fragments.MainMenuFragment; | ||
|
||
public class MainActivity extends AppCompatActivity implements MainMenuFragment.OnMusicListener { | ||
private MediaPlayer mediaPlayer; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
FragmentController.init(getSupportFragmentManager(), R.id.container); | ||
MainMenuFragment mainMenuFragment = new MainMenuFragment(); | ||
FragmentController.getController().open(mainMenuFragment); | ||
playMusic(); | ||
mainMenuFragment.setOnMusicListener(this); | ||
} | ||
|
||
private void playMusic() { | ||
mediaPlayer = MediaPlayer.create(this, R.raw.grasswalk); | ||
mediaPlayer.setLooping(true); | ||
mediaPlayer.start(); | ||
} | ||
|
||
private void pauseMusic() { | ||
mediaPlayer.pause(); | ||
} | ||
|
||
private void stopMusic() { | ||
mediaPlayer.stop(); | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
@Override | ||
public void onMusic(View view, TextView musicText) { | ||
if (mediaPlayer.isPlaying()) { | ||
pauseMusic(); | ||
musicText.setText("Off"); | ||
} else { | ||
playMusic(); | ||
musicText.setText("On"); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
stopMusic(); | ||
super.onDestroy(); | ||
} | ||
|
||
@SuppressLint("NewApi") | ||
@Override | ||
public void onBackPressed() { | ||
if (FragmentController.getController().countFragment() > 1) | ||
FragmentController.getController().close(); | ||
else { | ||
AlertDialog.Builder dialog = new AlertDialog.Builder(this); | ||
dialog.setPositiveButton("Exit", (dialog1, which) -> finishAffinity()); | ||
dialog.setMessage("Do you want exit?"); | ||
dialog.setTitle("Exit"); | ||
dialog.setNegativeButton("Cancel", (dialog1, which) -> dialog.setCancelable(true)); | ||
dialog.show(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.hiro.memorygame.app; | ||
|
||
import android.app.Application; | ||
import android.database.sqlite.SQLiteDatabase; | ||
|
||
import org.hiro.memorygame.database.DataBase; | ||
|
||
public class App extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
DataBase.init(this); | ||
DataBase db = DataBase.getDataBase(); | ||
SQLiteDatabase s = db.mDatabase; | ||
} | ||
|
||
@Override | ||
public void onTerminate() { | ||
super.onTerminate(); | ||
DataBase.getDataBase().closeDatabase(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/hiro/memorygame/controlller/FragmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.hiro.memorygame.controlller; | ||
|
||
|
||
import androidx.annotation.IdRes; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentTransaction; | ||
|
||
public class FragmentController { | ||
private static FragmentController controller; | ||
private FragmentManager manager; | ||
private int resId; | ||
|
||
private FragmentController(FragmentManager manager, int resId) { | ||
this.manager = manager; | ||
this.resId = resId; | ||
} | ||
|
||
public static void init(FragmentManager fragmentManager, @IdRes int resId) { | ||
controller = new FragmentController(fragmentManager, resId); | ||
} | ||
|
||
public static FragmentController getController() { | ||
return controller; | ||
} | ||
|
||
public void open(Fragment fragment) { | ||
FragmentTransaction transaction = manager.beginTransaction(); | ||
transaction.addToBackStack(fragment.toString()); | ||
transaction.replace(resId, fragment); | ||
transaction.commit(); | ||
} | ||
|
||
public int countFragment() { | ||
return manager.getBackStackEntryCount(); | ||
|
||
} | ||
|
||
public void close() { | ||
manager.popBackStack(); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
app/src/main/java/org/hiro/memorygame/database/DataBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.hiro.memorygame.database; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.database.Cursor; | ||
|
||
import org.hiro.memorygame.libs.DBHelper; | ||
import org.hiro.memorygame.models.LevelData; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class DataBase extends DBHelper { | ||
@SuppressLint("StaticFieldLeak") | ||
private static DataBase dataBase; | ||
|
||
private DataBase(Context context) { | ||
super(context, "data.db"); | ||
} | ||
|
||
public static DataBase getDataBase() { | ||
return dataBase; | ||
} | ||
|
||
public static void init(Context context) { | ||
dataBase = new DataBase(context); | ||
} | ||
|
||
public ArrayList<LevelData> getLevels() { | ||
ArrayList<LevelData> data = new ArrayList<>(); | ||
Cursor cursor = mDatabase.rawQuery("select *from levels", null); | ||
cursor.moveToFirst(); | ||
while (!cursor.isAfterLast()) { | ||
data.add(LevelData.getInstance(cursor)); | ||
cursor.moveToNext(); | ||
} | ||
cursor.close(); | ||
return data; | ||
} | ||
|
||
public void setStars(int level, int stars) { | ||
ContentValues values = new ContentValues(); | ||
values.put("star", stars); | ||
mDatabase.update("levels", values, "_id=?", new String[]{level + ""}); | ||
if (level < 9) { | ||
values = new ContentValues(); | ||
values.put("exist", 1); | ||
mDatabase.update("levels", values, "_id=?", new String[]{(level + 1) + ""}); | ||
} | ||
} | ||
|
||
public int getLevel() { | ||
int count = 0; | ||
Cursor cursor = mDatabase.rawQuery("select *from levels where exist =1", null); | ||
cursor.moveToFirst(); | ||
while (!cursor.isAfterLast()) { | ||
count++; | ||
cursor.moveToNext(); | ||
} | ||
cursor.close(); | ||
return count; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/org/hiro/memorygame/dialogs/SimpleDialog_Game.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.hiro.memorygame.dialogs; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AlertDialog; | ||
|
||
import org.hiro.memorygame.R; | ||
|
||
public class SimpleDialog_Game extends AlertDialog { | ||
|
||
private ImageView staricon1; | ||
private ImageView staricon2; | ||
private ImageView staricon3; | ||
|
||
public SimpleDialog_Game(@NonNull Context context) { | ||
super(context); | ||
|
||
View view = LayoutInflater.from(getContext()).inflate(R.layout.simple_dialog, null, false); | ||
|
||
staricon1 = view.findViewById(R.id.staricon1); | ||
staricon2 = view.findViewById(R.id.staricon2); | ||
staricon3 = view.findViewById(R.id.staricon3); | ||
staricon1.animate().scaleX(3).scaleY(3).setDuration(3000).start(); | ||
staricon1.animate().scaleX(-1).scaleY(-1).rotationX(180).setDuration(3000).start(); | ||
|
||
staricon2.animate().scaleX(3).scaleY(3).setDuration(3000).start(); | ||
staricon2.animate().scaleX(-1).scaleY(-1).rotationX(180).setDuration(3000).start(); | ||
|
||
staricon3.animate().scaleX(3).scaleY(3).setDuration(3000).start(); | ||
staricon3.animate().scaleX(-1).scaleY(-1).rotationX(180).setDuration(3000).start(); | ||
|
||
setView(view); | ||
} | ||
|
||
} |
Oops, something went wrong.