diff --git a/10-inch tablet screenshots/1.png b/10-inch tablet screenshots/1.png new file mode 100644 index 0000000..d639331 Binary files /dev/null and b/10-inch tablet screenshots/1.png differ diff --git a/10-inch tablet screenshots/2.png b/10-inch tablet screenshots/2.png new file mode 100644 index 0000000..cd59a98 Binary files /dev/null and b/10-inch tablet screenshots/2.png differ diff --git a/7-inch tablet screenshots/1.png b/7-inch tablet screenshots/1.png new file mode 100644 index 0000000..c372af4 Binary files /dev/null and b/7-inch tablet screenshots/1.png differ diff --git a/7-inch tablet screenshots/2.png b/7-inch tablet screenshots/2.png new file mode 100644 index 0000000..b5bb906 Binary files /dev/null and b/7-inch tablet screenshots/2.png differ diff --git a/Feature Graphic/funmemesgraphic.png b/Feature Graphic/funmemesgraphic.png new file mode 100644 index 0000000..76a3efe Binary files /dev/null and b/Feature Graphic/funmemesgraphic.png differ diff --git a/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MainActivity.kt b/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MainActivity.kt index 60d4475..db574d7 100644 --- a/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MainActivity.kt +++ b/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MainActivity.kt @@ -46,7 +46,6 @@ class MainActivity : AppCompatActivity() { // Instantiate the RequestQueue. progress_bar_loading.visibility = View.VISIBLE //when meme is loading progress bar will load - val queue = Volley.newRequestQueue(this) val url = "https://meme-api.herokuapp.com/gimme" // api call is done to fetch image of meme @@ -88,7 +87,7 @@ class MainActivity : AppCompatActivity() { }) // Add the request to the RequestQueue. - queue.add(jsonObjectRequest) + MySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest) } fun nextMeme(view: View) { diff --git a/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MySingleton.kt b/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MySingleton.kt new file mode 100644 index 0000000..ae95053 --- /dev/null +++ b/MemeShare/app/src/main/java/com/pratyakshkhurana/funmemes/MySingleton.kt @@ -0,0 +1,31 @@ +package com.pratyakshkhurana.funmemes + +import android.content.Context +import com.android.volley.Request +import com.android.volley.RequestQueue +import com.android.volley.toolbox.Volley + +//Singleton class is the one , it has only one instance +//so app can call one request at at time +//so we call using singleton and follow singleton pattern +class MySingleton constructor(context: Context) { + companion object { + //volatile to make thread safe, ensure safety + @Volatile + private var INSTANCE: MySingleton? = null + fun getInstance(context: Context) = + INSTANCE ?: synchronized(this) { + INSTANCE ?: MySingleton(context).also { + INSTANCE = it + } + } + } + private val requestQueue: RequestQueue by lazy { + // applicationContext is key, it keeps you from leaking the + // Activity or BroadcastReceiver if someone passes one in. + Volley.newRequestQueue(context.applicationContext) + } + fun addToRequestQueue(req: Request) { + requestQueue.add(req) + } +} \ No newline at end of file