From c8a84acbec91678c14e23d8dfed20f26d9d0361e Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 19 Feb 2021 18:30:06 +0100 Subject: Moving TopManga files into their own subdir --- .../java/xyz/adjutor/aniki/RestTopMangaResponse.kt | 19 ----- app/src/main/java/xyz/adjutor/aniki/TopManga.kt | 31 -------- .../main/java/xyz/adjutor/aniki/TopMangaAdapter.kt | 69 ---------------- app/src/main/java/xyz/adjutor/aniki/TopMangaApi.kt | 11 --- .../main/java/xyz/adjutor/aniki/TopMangaPage.kt | 92 --------------------- .../adjutor/aniki/topmanga/RestTopMangaResponse.kt | 19 +++++ .../java/xyz/adjutor/aniki/topmanga/TopManga.kt | 31 ++++++++ .../xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt | 70 ++++++++++++++++ .../java/xyz/adjutor/aniki/topmanga/TopMangaApi.kt | 11 +++ .../xyz/adjutor/aniki/topmanga/TopMangaPage.kt | 93 ++++++++++++++++++++++ 10 files changed, 224 insertions(+), 222 deletions(-) delete mode 100644 app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/TopManga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/TopMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/TopMangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/RestTopMangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/TopManga.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt (limited to 'app/src/main/java/xyz/adjutor/aniki') diff --git a/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt deleted file mode 100644 index 0a7ebc8..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt +++ /dev/null @@ -1,19 +0,0 @@ -package xyz.adjutor.aniki - -import com.google.gson.annotations.SerializedName - -class RestTopMangaResponse { - - @SerializedName("request_hash") - var request_hash: String? = null - @SerializedName("request_cached") - var request_cached: Boolean? = null - @SerializedName("request_cached_expiry") - var request_cached_expiry: Int? = null - @SerializedName("top") - var top: List? = null - - fun getResults(): List { - return top!! - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/TopManga.kt b/app/src/main/java/xyz/adjutor/aniki/TopManga.kt deleted file mode 100644 index 9cba192..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/TopManga.kt +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.adjutor.aniki - -import com.google.gson.annotations.SerializedName - -//Content of the top field from the api of top manga -class TopManga{ - - @SerializedName("mal_id") - var mal_id: Int? = null - @SerializedName("rank") - var rank: Int? = null - @SerializedName("title") - var title: String? = null - @SerializedName("url") - var url: String? = null - @SerializedName("type") - var type: String? = null - @SerializedName("volumes") - var volumes: Int? = null - @SerializedName("start_date") - var start_date: String? = null - @SerializedName("end_date") - var end_date: String? = null - @SerializedName("members") - var members: Int? = null - @SerializedName("score") - var score: Float? = null - @SerializedName("image_url") - var image_url: String? = null - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaAdapter.kt deleted file mode 100644 index 1478111..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaAdapter.kt +++ /dev/null @@ -1,69 +0,0 @@ -@file:Suppress("DEPRECATION") - -package xyz.adjutor.aniki - -import android.annotation.SuppressLint -import android.graphics.Bitmap -import android.graphics.BitmapFactory -import android.os.AsyncTask -import android.util.Log -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView - -class TopMangaAdapter(val mangaList: List) : - RecyclerView.Adapter() { - - // Describes an item view and its place within the RecyclerView - class MangaViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val mangaTitle: TextView = itemView.findViewById(R.id.tv_title) - val mangaRank: TextView = itemView.findViewById(R.id.tv_rank) - val mangaImage: ImageView = itemView.findViewById(R.id.iv_image) - - } - - // Returns a new ViewHolder - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MangaViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_layout, parent, false) - - return MangaViewHolder(view) - } - - // Returns size of data list - override fun getItemCount(): Int { - return mangaList.size - } - - // Displays data at a certain position - override fun onBindViewHolder(holder: MangaViewHolder, position: Int) { - val currentManga: TopManga = mangaList[position] - holder.mangaTitle.text = currentManga.title - holder.mangaRank.text = currentManga.rank.toString() - DownloadImageFromInternet(holder.mangaImage).execute(currentManga.image_url) - } - - @SuppressLint("StaticFieldLeak") - private inner class DownloadImageFromInternet(var imageView: ImageView) : AsyncTask() { - override fun doInBackground(vararg urls: String): Bitmap? { - val imageURL = urls[0] - var image: Bitmap? = null - try { - val `in` = java.net.URL(imageURL).openStream() - image = BitmapFactory.decodeStream(`in`) - } - catch (e: Exception) { - Log.e("Error Message", e.message.toString()) - e.printStackTrace() - } - return image - } - override fun onPostExecute(result: Bitmap?) { - imageView.setImageBitmap(result) - } - } -} - diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaApi.kt deleted file mode 100644 index b760233..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaApi.kt +++ /dev/null @@ -1,11 +0,0 @@ -package xyz.adjutor.aniki - -import retrofit2.http.GET -import retrofit2.Call - -interface TopMangaApi { - - @GET("v3/top/manga") - fun getTopMangaData(): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt deleted file mode 100644 index 6606b6c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt +++ /dev/null @@ -1,92 +0,0 @@ -package xyz.adjutor.aniki - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Button -import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.snackbar.Snackbar -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory - -class TopMangaPage : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - // Inflate the layout for this fragment - val view = inflater.inflate(R.layout.top_manga_page, container, false) - - makeApiCall(view, base_url) - - return view - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - //button to return to the home page - view.findViewById