(){
13 |
14 | override fun doInBackground(vararg params: String?): String {
15 | var response = ""
16 | val readTimeOut = 20000
17 | val connectTimeOut = 5000
18 | val base_url = "https://api.adviceslip.com/advice/search/"
19 |
20 | try
21 | {
22 | val toSearch = params[0]
23 |
24 | val url = URL( base_url + toSearch )
25 |
26 | val connection = url.openConnection() as HttpURLConnection
27 | connection.requestMethod = requestMethod.reqName
28 | connection.readTimeout = readTimeOut
29 | connection.connectTimeout = connectTimeOut
30 | connection.connect()
31 | // Connection successful
32 | if ( connection.responseCode == HttpURLConnection.HTTP_OK ) {
33 | // Read result
34 | val streamReader = InputStreamReader(connection.inputStream)
35 | val bufferedReader = BufferedReader(streamReader)
36 | val stringBuilder = StringBuilder()
37 | var line:String? = bufferedReader.readLine()
38 | while(line != null){ // Create result from buffer
39 | stringBuilder.append(line).append('\n')
40 | line = bufferedReader.readLine()
41 | }
42 | bufferedReader.close()
43 | streamReader.close()
44 | response = stringBuilder.toString()
45 | }
46 | else{// Connection failed.
47 | Log.e("Error: ",connection.responseCode.toString())
48 | var errorStr = ""
49 | // Read error message
50 | val streamReader = InputStreamReader(connection.errorStream)
51 | val bufferedReader = BufferedReader(streamReader)
52 | val stringBuilder = StringBuilder()
53 | var line:String? = bufferedReader.readLine()
54 | while(line != null){ // Create result from buffer
55 | stringBuilder.append(line).append('\n')
56 | line = bufferedReader.readLine()
57 | }
58 | bufferedReader.close()
59 | streamReader.close()
60 | errorStr = stringBuilder.toString()
61 |
62 | connectionInterface.onError(errorStr)
63 | }
64 | connection.disconnect()
65 | }
66 | catch (err :Exception){
67 | Log.e("Error",err.toString())
68 | }
69 | return response
70 | }
71 |
72 | override fun onPostExecute(result: String?) {
73 | result?.let{
74 | connectionInterface.onSuccess(result)
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ITU ACM 2018 - Android Programming Study Group
2 |
3 | ### Instructors
4 |
5 | **Alperen Kantarcı**
6 |
7 | *Computer Engineering #4 @I.T.U*
8 |
9 | [*LinkedIn*](https://www.linkedin.com/in/alperenkantarci/)
10 |
11 | **Burak Bekci**
12 |
13 | *Computer Engineering #3 @I.T.U*
14 |
15 | [*LinkedIn*](https://www.linkedin.com/in/burak-bekci-129b1514b/)
16 |
17 |
18 | ### Prerequisities
19 | 1. Basic knowledge about any programming language.
20 | 2. Android Studio (Version 3.0 or newer Note:Latest release is 3.2.1)
21 |
22 | ### Goal
23 |
24 | The aim of this study group is to learn the fundamentals of the Android Application development using Kotlin programming language, using Git for your projects, mobile application design and so on. At the end of the course you will have solid base for Android application development and you will be able to create applications that you desired and you will be able to show off to your friends with your own applications :smiley:
25 |
26 | ### Syllabus
27 |
28 | | Week | Topic |
29 | | :----------------- | ------------------------------------------------------------ |
30 | | Week 1 (25/10/18) | Kotlin fundamentals (Kotlin vs Java, basic operators, collection types, control flow, functions, Billion dollar mistake(Null reference) ) |
31 | | Week 2 (01/11/18) | Kotlin fundamentals (classes, inheritance, higher order functions, Android project structure ) |
32 | | Week 3 (08/11/18) | Mid-Break (Holiday) |
33 | | Week 4 (15/11/18) | Warm up project - Setting GitHub, XML design, HTTP requests, JSON parsing and table views |
34 | | Week 5 (22/11/18) | Notes - Setting up the project, creating, editing and showing notes in a table view |
35 | | Week 6 (29/11/18) | Notify - Storing notes on the local storage |
36 | | Week 7 (06/12/18) | Quizify - Setting up the project, creating questions and answering shuffled questions |
37 | | Week 8 (13/12/18) | Quizify - Storing questions on firebase database |
38 | | Week 9 (20/12/18) | Quizify - Authentication with firebase |
39 | | Week 10 (27/12/18) | Quizify - Creating the leaderboard using firebase |
40 |
41 | Lessons will be around 1:30 - 2 hours
42 |
43 | (Lectures will be in ITU Faculty of Chemical and Metallurgical Engineering classroom D205 at every Thursday 17.30)
44 |
45 | # Important Links
46 | [TryKotlin](https://try.kotlinlang.org) - If you want to try kotlin without any installation or if you want to practice
47 | [Android Studio](https://developer.android.com/studio/) Offical download adress of the Android Studio
48 | [Android Developers](https://developer.android.com/docs/) First website that you will need while developing applications
49 |
50 | # Suggested Readings
51 | [About advantages and disadavantages about Kotlin](https://medium.com/@octskyward/why-kotlin-is-my-next-programming-language-c25c001e26e3)
52 |
53 | [Must read article for Android Developers](https://medium.com/mindorks/a-roadmap-to-become-a-better-android-developer-3038cf7f8c8d)
54 |
55 | # Project
56 | Addition for the apps covered in the course, we will create another application inwhich all fundamentals of the Android Environment will be covered. For more information visit the [Project file](/Project)
57 |
--------------------------------------------------------------------------------
/Project/Week 2/Added Files/HomePageFragment.kt:
--------------------------------------------------------------------------------
1 | package com.itu.dailyfilm.Fragments
2 |
3 |
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import android.widget.ArrayAdapter
10 | import android.widget.ListView
11 | import android.widget.TextView
12 | import com.itu.dailyfilm.Models.Film
13 | import com.itu.dailyfilm.HttGet
14 | import com.itu.dailyfilm.Interfaces.InternetInterface
15 | import com.itu.dailyfilm.JSONParser
16 | import com.itu.dailyfilm.Models.Ratings
17 | import com.itu.dailyfilm.R
18 |
19 | class HomePageFragment : Fragment() , InternetInterface {
20 |
21 | override fun onError() {}
22 |
23 |
24 | override fun onSuccess(result: String) {
25 | // Parse the film object
26 | val film = JSONParser.retObjectFromJSON(result)
27 | // Fill the views
28 | fillTextWithInfo(film)
29 | }
30 |
31 | private var mParam1: String? = null
32 | private var mParam2: String? = null
33 |
34 | private lateinit var titleText:TextView
35 | private lateinit var yearText:TextView
36 | private lateinit var plotText:TextView
37 | private lateinit var runTimeTextView: TextView
38 |
39 | private lateinit var ratingsListView: ListView
40 |
41 | override fun onCreate(savedInstanceState: Bundle?) {
42 | super.onCreate(savedInstanceState)
43 | }
44 |
45 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
46 | savedInstanceState: Bundle?): View? {
47 |
48 | return inflater.inflate(R.layout.fragment_home_page_fragment, container, false)
49 | }
50 |
51 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
52 | super.onViewCreated(view, savedInstanceState)
53 | // Initialize text views
54 | initTextViews(view)
55 |
56 | HttGet(this).execute("tt2313197")
57 | }
58 |
59 | private fun initTextViews(view:View){
60 | // initialize text views
61 | titleText = view.findViewById(R.id.home_page_title_text)
62 | yearText = view.findViewById(R.id.home_page_year_text)
63 | plotText = view.findViewById(R.id.home_page_plot_text)
64 | runTimeTextView = view.findViewById(R.id.home_page_runtime_text)
65 | // initialize list view
66 | ratingsListView = view.findViewById(R.id.home_page_ratings_list)
67 |
68 | }
69 |
70 | // Fill the text views with film information
71 | private fun fillTextWithInfo(film: Film?){
72 | titleText.text = film?.title
73 | yearText.text = film?.year.toString()
74 | plotText.text = film?.plot
75 | runTimeTextView.text = film?.runtime
76 |
77 | film?.let {
78 | fillRatingsList(film)
79 | }
80 |
81 | }
82 |
83 | private fun fillRatingsList(film: Film){
84 | val curContext = context
85 | curContext?.let {
86 | val listAdapter = ArrayAdapter(curContext, android.R.layout.simple_list_item_1, film.ratings )
87 | ratingsListView.adapter = listAdapter
88 | }
89 | }
90 |
91 | companion object {
92 | fun newInstance(): HomePageFragment{
93 | val fragment = HomePageFragment()
94 | return fragment
95 | }
96 | }
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/Project/DailyFilm/app/src/main/java/com/itu/dailyfilm/Fragments/HomePageFragment.kt:
--------------------------------------------------------------------------------
1 | package com.itu.dailyfilm.Fragments
2 |
3 |
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import android.widget.ArrayAdapter
10 | import android.widget.ListView
11 | import android.widget.TextView
12 | import com.itu.dailyfilm.Models.Film
13 | import com.itu.dailyfilm.HttGet
14 | import com.itu.dailyfilm.Interfaces.InternetInterface
15 | import com.itu.dailyfilm.JSONParser
16 | import com.itu.dailyfilm.Models.Ratings
17 | import com.itu.dailyfilm.R
18 |
19 | class HomePageFragment : Fragment() , InternetInterface {
20 |
21 | override fun onError() {}
22 |
23 |
24 | override fun onSuccess(result: String) {
25 | // Parse the film object
26 | val film = JSONParser.retObjectFromJSON(result)
27 | // Fill the views
28 | fillTextWithInfo(film)
29 | }
30 |
31 | private var mParam1: String? = null
32 | private var mParam2: String? = null
33 |
34 | private lateinit var titleText:TextView
35 | private lateinit var yearText:TextView
36 | private lateinit var plotText:TextView
37 | private lateinit var runTimeTextView: TextView
38 |
39 | private lateinit var ratingsListView: ListView
40 |
41 | override fun onCreate(savedInstanceState: Bundle?) {
42 | super.onCreate(savedInstanceState)
43 | }
44 |
45 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
46 | savedInstanceState: Bundle?): View? {
47 |
48 | return inflater.inflate(R.layout.fragment_home_page_fragment, container, false)
49 | }
50 |
51 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
52 | super.onViewCreated(view, savedInstanceState)
53 | // Initialize text views
54 | initTextViews(view)
55 |
56 | HttGet(this).execute("tt2313197")
57 | }
58 |
59 | private fun initTextViews(view:View){
60 | // initialize text views
61 | titleText = view.findViewById(R.id.home_page_title_text)
62 | yearText = view.findViewById(R.id.home_page_year_text)
63 | plotText = view.findViewById(R.id.home_page_plot_text)
64 | runTimeTextView = view.findViewById(R.id.home_page_runtime_text)
65 | // initialize list view
66 | ratingsListView = view.findViewById(R.id.home_page_ratings_list)
67 |
68 | }
69 |
70 | // Fill the text views with film information
71 | private fun fillTextWithInfo(film: Film?){
72 | titleText.text = film?.title
73 | yearText.text = film?.year.toString()
74 | plotText.text = film?.plot
75 | runTimeTextView.text = film?.runtime
76 |
77 | film?.let {
78 | fillRatingsList(film)
79 | }
80 |
81 | }
82 |
83 | private fun fillRatingsList(film: Film){
84 | val curContext = context
85 | curContext?.let {
86 | val listAdapter = ArrayAdapter(curContext, android.R.layout.simple_list_item_1, film.ratings )
87 | ratingsListView.adapter = listAdapter
88 | }
89 | }
90 |
91 | companion object {
92 | fun newInstance(): HomePageFragment{
93 | val fragment = HomePageFragment()
94 | return fragment
95 | }
96 | }
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/Week4/app/src/main/java/itu/ituacm/week4real/Fragments/MainFragment.kt:
--------------------------------------------------------------------------------
1 | package itu.ituacm.week4real.Fragments
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.support.v4.app.Fragment
6 | import android.support.v7.widget.LinearLayoutManager
7 | import android.support.v7.widget.RecyclerView
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.Button
12 | import android.widget.EditText
13 | import itu.ituacm.week4real.*
14 | import org.w3c.dom.Node
15 | import java.util.*
16 |
17 | class MainFragment : Fragment(), clickInterface{
18 |
19 | override fun onItemDelete(pos: Int) {
20 | var toDelete = pos
21 | if (pos >= notes.size)
22 | toDelete = pos % notes.size
23 | // Remove from database
24 | dbHelper?.deleteNode(notes[toDelete].id)
25 | // Remove from list
26 | notes.removeAt(toDelete)
27 |
28 | adapter.notifyItemRemoved(toDelete)
29 | adapter.notifyItemRangeChanged(toDelete,toDelete + 1 )
30 | }
31 |
32 | companion object {
33 | fun newInstance(): MainFragment{
34 | return MainFragment()
35 | }
36 | }
37 |
38 | lateinit var editText:EditText
39 | lateinit var recyclerView: RecyclerView
40 | lateinit var button:Button
41 | lateinit var adapter: NoteAdapter
42 |
43 | var noteText:String = ""
44 | var notes : ArrayList = ArrayList()
45 | var dbHelper:DatabaseHelper? = null
46 |
47 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
48 | val view:View = inflater.inflate(R.layout.main_fragment,container,false)
49 | val activity = activity
50 | button = view.findViewById(R.id.button)
51 | editText = view.findViewById(R.id.editText)
52 | recyclerView = view.findViewById(R.id.recyler_view)
53 | recyclerView.layoutManager = LinearLayoutManager(activity)
54 | adapter = NoteAdapter(notes,activity!!.applicationContext, this)
55 | recyclerView.adapter = adapter
56 |
57 |
58 | button.setOnClickListener {
59 | val noteText = editText.text.toString()
60 | editText.setText("")
61 | addNote(noteText)
62 | }
63 | return view
64 | }
65 |
66 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
67 | context?.let {
68 | dbHelper = DatabaseHelper(context!!)
69 | readAllNotes()
70 | }
71 | }
72 |
73 | fun addNote(noteText:String){
74 | val currentPos = notes.size+1
75 | val noteToAdd = Note(-1,"Title $currentPos",noteText,currentPos)
76 | notes.add(noteToAdd)
77 | adapter.notifyItemInserted(currentPos)
78 | writeNoteToDataBase(noteToAdd)
79 | }
80 |
81 | private fun writeNoteToDataBase(note: Note){
82 | dbHelper?.addNote(note)
83 | }
84 |
85 | private fun readAllNotes(){
86 | dbHelper?.let {
87 | val notesList = dbHelper!!.getAllNotes()
88 | notes = notesList as ArrayList
89 | adapter = NoteAdapter(notes, context!!, this)
90 | recyclerView.adapter = adapter
91 | }
92 | }
93 |
94 | override fun onItemClick(pos: Int) {
95 | (activity as MainActivity).openFragment(NoteFragment.newInstance("",notes[pos]), "Notes")
96 | }
97 |
98 |
99 | override fun onAttach(context: Context?) {
100 | super.onAttach(context)
101 | val resources = context!!.resources
102 | }
103 | }
--------------------------------------------------------------------------------
/Week3/Week3-API-Project/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
15 |
21 |
27 |
28 |
33 |
40 |
41 |
45 |
46 |
58 |
59 |
69 |
70 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/Week2/src/Main.kt:
--------------------------------------------------------------------------------
1 | fun main(args: Array){
2 | example1()
3 | example2()
4 | example3()
5 | example4()
6 | example5()
7 | example6()
8 | }
9 |
10 | fun example1(){
11 | /* This example focus on class attributes
12 | Used file: Person.kt
13 | */
14 |
15 | // Creating person objects.
16 | //Using primary constructor
17 | val person1 = Person("05431736161","Burak","Bekci")
18 | // Using secondary constructor with 1 parameter.
19 | val person2 = Person("Alperen")
20 | // Using constructor with no argument.
21 | val person3 = Person()
22 | // val person4 = Person("05431736161","Burak") -> Gives error. No constructor is defined with 2 parameter.
23 |
24 | // In kotlin '=' operation can be used for both assignment and reading.
25 | println("We declared phone number attribute as public. We can access it from here. Phone number person1: ${person1.phoneNumber}") // Reading operation
26 | person1.phoneNumber = "+90123125334" // Assignment operation
27 | println("We declared phone number attribute as public. We can access it from here. Phone number person1: ${person1.phoneNumber}") // Reading operation
28 |
29 | // Below attributes are not allowed to reach from here.
30 | //person1.name -> Private
31 | //person1.surName -> Protected.
32 |
33 | person1.printPerson()
34 | // Below function will print meaningful things now (after override).
35 | println(person1)
36 | // Using static attributes.
37 | person1.printAge()
38 | person2.printAge()
39 | }
40 |
41 | fun example2(){
42 | /*
43 | This example focuses on inheritance.
44 | Used files: Animal.kt, Cat.kt, Fish.kat
45 | */
46 | val cat = Cat("Boncuk")
47 | cat.printAnimal()
48 | cat.saySomething()
49 | val fish = Fish("Hamsi")
50 | fish.printAnimal()
51 | fish.saySomething()
52 | fish.printProtected()
53 | }
54 |
55 | fun example3(){
56 | /*
57 | Main topic on this example is Interfaces.
58 | See Mother.kt, Child.kt and ChildMotherInterface.kt
59 | */
60 | //Creating objects.
61 | val child = Child("Alperen")
62 | val mother = Mother(child)
63 | //Setting interface objects.
64 | mother.setInterface()
65 | println("Plane has came to airport. Our child will get on soon.")
66 | //First event occurs.
67 | child.getOnPlane()
68 | println("Plane has landed.")
69 | //Second event occurs
70 | child.getOffFromPlane("Istanbul")
71 | }
72 | fun example4(){
73 | /*
74 | Main topic of this example is high order functions.
75 | Calculator.kt is the source code.
76 | */
77 | val cal = Calculator(80,16,1)
78 | val cal1 = Calculator(80,16,2)
79 | val cal2 = Calculator(80,16,3)
80 | val cal3 = Calculator(80,16,0)
81 | }
82 |
83 | fun example5(){
84 | /*
85 | Using built-in lambda functions.
86 | see Film.kt file.
87 | */
88 |
89 |
90 | // Define a lambda.
91 | val func = {println("\nHi I am a function\n")}
92 | // Invoke it.
93 | func()
94 |
95 | println("\nPrinting a list with forEach")
96 | val numberList = mutableListOf(1,3,6,1,62,4)
97 | numberList.forEachIndexed { index, i -> println("Number on $index is $i") }
98 |
99 | val filmList = mutableListOf(Film("AB",3.2f),Film("asa",1.1f),Film("AA",9.1f),Film("V",8.1f))
100 |
101 | println("\nSorting a film list in increasing order by score")
102 | filmList.sortBy { it.score }
103 | filmList.forEach { println("${it.name}: ${it.score}") }
104 |
105 | println("\nSorting a film list in decreasing order by score")
106 | filmList.sortByDescending { it.score }
107 | filmList.forEach { println(it.toString()) }
108 |
109 | println("\nFiltering a list")
110 | val filteredList = filmList.filter { it.name == "AB" }
111 |
112 | filteredList.forEach { println(it.toString()) }
113 |
114 | }
115 |
116 | fun example6(){
117 | // Calling a static function from object class.
118 | // There is no need to create objects to call a function.
119 | println(StringUtil.replaceName("Hi I am Burak","Burak","Alperen"))
120 | }
--------------------------------------------------------------------------------
/Week4/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/Project/DailyFilm/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Week3/Week3-API-Project/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Project/Week 2/Added Files/fragment_home_page_fragment.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
13 |
14 |
18 |
19 |
26 |
29 |
35 |
36 |
37 |
38 |
39 |
40 |
45 |
46 |
51 |
52 |
60 |
61 |
70 |
71 |
80 |
81 |
90 |
91 |
102 |
103 |
112 |
113 |
114 |
115 |
116 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/Project/DailyFilm/app/src/main/res/layout/fragment_home_page_fragment.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
13 |
14 |
18 |
19 |
26 |
29 |
35 |
36 |
37 |
38 |
39 |
40 |
45 |
46 |
51 |
52 |
60 |
61 |
70 |
71 |
80 |
81 |
90 |
91 |
102 |
103 |
112 |
113 |
114 |
115 |
116 |
120 |
121 |
122 |
--------------------------------------------------------------------------------