This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
51 changed files
with
3,090 additions
and
567 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
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
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,60 @@ | ||
package com.neko.uwu | ||
|
||
import android.app.AlertDialog | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.neko.v2ray.R | ||
import com.neko.v2ray.ui.MainActivity | ||
import com.google.android.material.card.MaterialCardView | ||
|
||
class AdapterDatabase( | ||
private val ctx: Context, | ||
private val arrID: ArrayList<*>, | ||
private val arrName: ArrayList<*>, | ||
private val arrUsername: ArrayList<*>, | ||
private val arrEmail: ArrayList<*>, | ||
private val arrAge: ArrayList<*>, | ||
private val arrHobi: ArrayList<*>, | ||
private val arrTgl: ArrayList<*> | ||
) : RecyclerView.Adapter<AdapterDatabase.ViewHolderDatabase>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderDatabase { | ||
val view = LayoutInflater.from(ctx).inflate(R.layout.card_item, parent, false) | ||
return ViewHolderDatabase(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolderDatabase, position: Int) { | ||
val alphabet: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9') | ||
val randomString: String = List(15) { alphabet.random() }.joinToString("") | ||
|
||
holder.tvID.text = arrID[position].toString() | ||
holder.uwuID.text = randomString | ||
holder.tvName.text = arrName[position].toString() | ||
holder.tvUsername.text = arrUsername[position].toString() | ||
holder.tvEmail.text = arrEmail[position].toString() | ||
holder.tvAge.text = arrAge[position].toString() | ||
holder.tvHobi.text = arrHobi[position].toString() | ||
holder.tvTgl.text = arrTgl[position].toString() | ||
} | ||
|
||
override fun getItemCount(): Int = arrName.size | ||
|
||
inner class ViewHolderDatabase(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val tvID: TextView = itemView.findViewById(R.id.tv_id) | ||
val uwuID: TextView = itemView.findViewById(R.id.uwu_id) | ||
val tvName: TextView = itemView.findViewById(R.id.tv_name) | ||
val tvUsername: TextView = itemView.findViewById(R.id.tv_username) | ||
val tvEmail: TextView = itemView.findViewById(R.id.tv_email) | ||
val tvAge: TextView = itemView.findViewById(R.id.tv_age) | ||
val tvHobi: TextView = itemView.findViewById(R.id.tv_hobi) | ||
val tvTgl: TextView = itemView.findViewById(R.id.tv_tgl) | ||
val cvDatabase: MaterialCardView = itemView.findViewById(R.id.cv_database) | ||
} | ||
} | ||
|
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,83 @@ | ||
package com.neko.uwu | ||
|
||
import android.content.ContentValues | ||
import android.content.Context | ||
import android.database.Cursor | ||
import android.database.sqlite.SQLiteDatabase | ||
import android.database.sqlite.SQLiteOpenHelper | ||
|
||
class MyDatabaseHelper(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) { | ||
private val ctx: Context = context | ||
|
||
companion object { | ||
private const val DATABASE_NAME = "neko.db" | ||
private const val DATABASE_VERSION = 1 | ||
|
||
private const val TABLE_NAME = "nekoray" | ||
private const val FIELD_ID = "id" | ||
private const val FIELD_NAME = "name" | ||
private const val FIELD_USERNAME = "username" | ||
private const val FIELD_EMAIL = "email" | ||
private const val FIELD_AGE = "age" | ||
private const val FIELD_HOBI = "hobi" | ||
private const val FIELD_TGL = "tgl" | ||
} | ||
|
||
override fun onCreate(db: SQLiteDatabase) { | ||
val query = "CREATE TABLE $TABLE_NAME (" + | ||
"$FIELD_ID INTEGER PRIMARY KEY AUTOINCREMENT, " + | ||
"$FIELD_NAME TEXT, " + | ||
"$FIELD_USERNAME TEXT, " + | ||
"$FIELD_EMAIL TEXT, " + | ||
"$FIELD_AGE TEXT, " + | ||
"$FIELD_HOBI TEXT, " + | ||
"$FIELD_TGL TEXT );" | ||
|
||
db.execSQL(query) | ||
} | ||
|
||
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { | ||
db.execSQL("DROP TABLE IF EXISTS $TABLE_NAME") | ||
onCreate(db) | ||
} | ||
|
||
fun tambahDatabase(name: String, username: String, email: String, age: String, hobi: String, tgl: String): Long { | ||
val db = this.writableDatabase | ||
val cv = ContentValues() | ||
|
||
cv.put(FIELD_NAME, name) | ||
cv.put(FIELD_USERNAME, username) | ||
cv.put(FIELD_EMAIL, email) | ||
cv.put(FIELD_AGE, age) | ||
cv.put(FIELD_HOBI, hobi) | ||
cv.put(FIELD_TGL, tgl) | ||
|
||
return db.insert(TABLE_NAME, null, cv) | ||
} | ||
|
||
fun ubahDatabase(id: String, name: String, username: String, email: String, age: String, hobi: String, tgl: String): Long { | ||
val db = this.writableDatabase | ||
val cv = ContentValues() | ||
|
||
cv.put(FIELD_NAME, name) | ||
cv.put(FIELD_USERNAME, username) | ||
cv.put(FIELD_EMAIL, email) | ||
cv.put(FIELD_AGE, age) | ||
cv.put(FIELD_HOBI, hobi) | ||
cv.put(FIELD_TGL, tgl) | ||
|
||
return db.update(TABLE_NAME, cv, "id = ?", arrayOf(id)).toLong() | ||
} | ||
|
||
fun hapusDatabase(id: String): Long { | ||
val db = this.writableDatabase | ||
return db.delete(TABLE_NAME, "id = ?", arrayOf(id)).toLong() | ||
} | ||
|
||
fun bacaSemuaData(): Cursor? { | ||
val query = "SELECT * FROM $TABLE_NAME" | ||
val db = this.readableDatabase | ||
|
||
return db?.rawQuery(query, null) | ||
} | ||
} |
Oops, something went wrong.