{"id":19672682,"url":"https://github.com/halilozel1903/catchthefruits","last_synced_at":"2026-03-16T22:02:26.226Z","repository":{"id":91423729,"uuid":"140001642","full_name":"halilozel1903/CatchTheFruits","owner":"halilozel1903","description":"You can have fun with the Catch Fruits Game developed with Kotlin. 🍎 🍌 🍑 🍒 🫐 🍍 🥭 🥑 🍈 🍐 🍊","archived":false,"fork":false,"pushed_at":"2024-07-07T20:22:36.000Z","size":1211,"stargazers_count":25,"open_issues_count":0,"forks_count":9,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-05T12:23:15.869Z","etag":null,"topics":["android","android-application","android-development","android-game","android-game-app","android-games","android-kotlin-development","android-kotlin-tutorial","databinding","databinding-android","databinding-library","databinding-viewbinding","databindingutil","game-development","kotlin","kotlin-android","kotlin-game","kotlin-game-development","kotlin-language","kotlin-tutorial"],"latest_commit_sha":null,"homepage":"https://halilozel1903.medium.com","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halilozel1903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-06T15:28:30.000Z","updated_at":"2025-03-10T17:34:35.000Z","dependencies_parsed_at":"2023-07-25T18:52:30.912Z","dependency_job_id":"9f53999a-298a-4b68-af4a-67605c0267ed","html_url":"https://github.com/halilozel1903/CatchTheFruits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FCatchTheFruits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FCatchTheFruits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FCatchTheFruits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FCatchTheFruits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/CatchTheFruits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251415614,"owners_count":21585865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-application","android-development","android-game","android-game-app","android-games","android-kotlin-development","android-kotlin-tutorial","databinding","databinding-android","databinding-library","databinding-viewbinding","databindingutil","game-development","kotlin","kotlin-android","kotlin-game","kotlin-game-development","kotlin-language","kotlin-tutorial"],"created_at":"2024-11-11T17:13:02.094Z","updated_at":"2026-03-16T22:02:26.157Z","avatar_url":"https://github.com/halilozel1903.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"# Catch The Fruits 🍒 🍓 🍇 🍎 🍉 🍑 🍌 🥝 🍍 🫐 🍏 🍈 🍐\n\n![Screenshot](kotlin.png)\n\n\n# What is Kotlin ⁉️\n\nWhat is Kotlin? I wrote a blog post called What the Kotlin language is, what it does, its differences and similarities with Java, Kotlin's\nI have added the platforms it supports and the beautiful resources. You can access the article at the link below:\n\nhttps://medium.com/@halilozel1903/kotlin-nedir-43e312d2dca6\n\n\n# Kotlin Tutorials 📌\n\nI have prepared a series about Kotlin. It's a project that starts from the basics of Kotlin and moves forward.\nAdditions to the courses will continue. If you are new to Kotlin, I recommend you to review the examples in the link below:\n\nhttps://github.com/halilozel1903/KotlinTutorials\n\n\n## The goal of the project 😎\n\nTo show that Android application development with Kotlin is easier and less code than Java language.\n\n\n## Gameplay of the Project 👻\n\nThere are 9 different fruit pictures in the application. 1 random one changes every half second. other 8\nThe fruit is hidden until the game is over. Play time is 10 seconds. How much fruit can you catch during this time?\nIt is an application that measures its measurement and the strength of your reflexes.\n\n\u003cp\u003e\n  \u003cimg src=\"game.gif\" width=\"350\" \u003e\n\u003c/p\u003e\n\n\n## Content of the Project 📖\n\nThe following structures and components were used in the project: \u003cbr\u003e\n\n- Data Binding\n- Alert Dialog\n- Timers\n- Runnable \u0026 Handler\n- Grid Layout\n- Constraint Layout\n- TextView\n- ImageView\n\n\n## Screen Design of the Project 📱\n\n![Dizayn](pic1.png)\n\nThe project is designed as a single screen for now. The outermost Constraint Layout and the inside Grid Layout have been added. Grid Layout\n9 Image Views were used in it. One text view at the top to keep the time and another to show the score below\nA text view is used. You'll understand better what I'm talking about by reviewing the structure below.\n\nhttps://gist.github.com/halilozel1903/fa265cdd77678d68c5d4d17efcd576aa\n\nIn order to add Grid Layout in the design section, you need to add the following statement to the gradle file.\n\n```java \n implementation 'androidx.gridlayout:gridlayout:1.0.0'\n```\n\nYou can find the images added to Image Views by searching the following site:\n\nhttps://www.flaticon.com/search?word=fruit\n\nYou can find and replace different fruits if you want. I am attaching the pictures in the project below.\n\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/apple.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/bananas.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/cherry.png)\u003cbr\u003e\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/grapes.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/kiwi.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/orange.png)\u003cbr\u003e\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/pear.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/strawberry.png)\n![Screenshot](https://github.com/halilozel1903/CatchTheFruits/blob/master/app/src/main/res/drawable/watermelon.png)\n\n\n## Alert Dialog Definition and Usage 🚨\n\nWe can say that Alert Dialog is a question sentence that is asked to the user after a certain operation is completed in order to make a choice.\nIn our project, we gave the user the number of fruits he could catch for 10 seconds.\nWe are used to ask if he wants to play the game again.\n\nBelow are the codes related to the definition and usage of Alert Dialog:\n\n```kotlin \n  val dialog = AlertDialog.Builder(this@MainActivity)\n                dialog.setCancelable(false)\n                dialog.setTitle(\"Catch The Fruits\")\n                dialog.setMessage(\"Score : $score\\nWould you like play again?\")\n                dialog.setPositiveButton(\"YES\") { dialog, id -\u003e\n                \n                   Restart()\n                }\n                        .setNegativeButton(\"NO \") { dialog, which -\u003e\n                            score = 0\n                            tvScore.setText(\"Score : $score\")\n                            tvTime.setText(\"Time : \" + \"0\")\n\n                            for (image in imageArray) {\n\n                                image.visibility = View.INVISIBLE \n                            }\n                        }\n\n                val alert = dialog.create()\n                alert.show() \n```\n\n## Using Runnable, Handler and Timer ⏱\n\n**Runnable** : The operations to be done within the run method are specified.\n\n**Handler \u0026 Timer** : It allows us to direct the events that we want to be repeated at certain intervals and to use them.\nstructures that enable us to manage.\n\nIn our project, counting backwards from 10 to 0 is performed. Therefore, the above structures were used.\n\n```kotlin \n    var handler: Handler = Handler()\n\n    var runnable: Runnable = Runnable { }\n```\nObject definitions are made.\n\n```kotlin \n        object : CountDownTimer(10000, 1000) {\n\n            override fun onFinish() { \n\n                tvTime.text = \"Time's up!\" \n                handler.removeCallbacks(runnable)\n\n\n                for (image in imageArray) { \n\n                    image.visibility = View.INVISIBLE \n                }\n          \n            }\n\n            override fun onTick(p0: Long) { \n\n                tvTime.text = \"Time : \" + p0 / 1000 \n            }\n\n        }.start()\n```\n\nThere is a class that counts backwards from 10. If the class has 2, the method should be added.\nThese are the following methods. If these methods are not added, it will warn you and ask you to add the methods.\n\n  - _onFinish_ : This method is a function that includes what to do after the operation about the Timer is completed.\nIn our example, when the time is up, we print a message to the text and make the visible fruits on the screen invisible.\nso that he does not click on the fruits and increase the score. By deleting future calls, we finish our game.\n\n  - _onTick_ : It is the method that specifies what will be done in each second. Update seconds every second\nprocess is done and written in the text part.\n\n\n## How to Hide Pictures and Randomly Show them 🖼\n\nGenerate 9 random numbers with the help of the Random class and use them in the function below.\nwe show a random image every half second. It has a structure that repeats these processes continuously.\nWe do it with the help of runnable and handler.\n\n```kotlin\n// method to hide pictures\nfun hideImages() {\n    runnable = Runnable {\n        for (image in imageArray) {\n\n            image.visibility = View.INVISIBLE\n        }\n\n        val random = Random()\n        val index = random.nextInt(8 - 0)\n        imageArray[index].visibility = View.VISIBLE\n\n        handler.postDelayed(runnable, 500)\n    }\n    handler.post(runnable)\n}\n```\n\n\n## Score Increase Process when Clicking on Pictures 📸\n\nThe user gets points by clicking the pictures on the screen. How does the user do this?\nIf you're curious, let's examine the method below ;)\n\n```kotlin\n// Function that increases points when clicking pictures\n\nfun increaseScore(view: View) {\n\n    score++\n\n    tvScore.text = \"Score : $score\" // score value is displayed on the screen.\n\n}\n```\n\nEach time the user clicks, the score variable is incremented once and updates the score value on the screen.\n\n## Donation 💸\n\nIf this project help 💁 you to develop, you can give me a cup of coffee. ☕\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n## License  ℹ️\n```\nMIT License\n\nCopyright (c) 2023 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fcatchthefruits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fcatchthefruits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fcatchthefruits/lists"}