Circleci project setup (#7)

This commit is contained in:
2023-02-27 22:33:09 +00:00
committed by GitHub
parent 565c5fe90b
commit 24461b9444
206 changed files with 3145 additions and 4460 deletions

View File

@@ -0,0 +1,35 @@
package h_mal.appttude.com.objects
class ApprovalsObject {
var driver_details_approval: Int = 0
var driver_license_approval: Int = 0
var private_hire_approval: Int = 0
var vehicle_details_approval: Int = 0
var mot_details_approval: Int = 0
var insurance_details_approval: Int = 0
var log_book_approval: Int = 0
var ph_car_approval: Int = 0
constructor()
constructor(
driver_details_approval: Int,
driver_license_approval: Int,
private_hire_approval: Int,
vehicle_details_approval: Int,
mot_details_approval: Int,
insurance_details_approval: Int,
log_book_approval: Int,
private_hire_vehicle_approval: Int
) {
this.driver_details_approval = driver_details_approval
this.driver_license_approval = driver_license_approval
this.private_hire_approval = private_hire_approval
this.vehicle_details_approval = vehicle_details_approval
this.mot_details_approval = mot_details_approval
this.insurance_details_approval = insurance_details_approval
this.log_book_approval = log_book_approval
ph_car_approval = private_hire_vehicle_approval
}
}

View File

@@ -0,0 +1,33 @@
package h_mal.appttude.com.objects
import h_mal.appttude.com.model.*
import java.util.*
class ArchiveObject {
var driver_license: HashMap<String, DriversLicenseObject>? = null
var private_hire: HashMap<String, PrivateHireObject>? = null
var vehicle_details: HashMap<String, VehicleProfileObject>? = null
var insurance_details: HashMap<String, InsuranceObject>? = null
var mot_details: HashMap<String, MotObject>? = null
var log_book: HashMap<String, LogbookObject>? = null
var ph_car: HashMap<String, PrivateHireVehicleObject>? = null
constructor()
constructor(
driver_license: HashMap<String, DriversLicenseObject>?,
private_hire: HashMap<String, PrivateHireObject>?,
vehicle_details: HashMap<String, VehicleProfileObject>?,
insurance_details: HashMap<String, InsuranceObject>?,
mot_details: HashMap<String, MotObject>?,
log_book: HashMap<String, LogbookObject>?,
private_hire_vehicle: HashMap<String, PrivateHireVehicleObject>?
) {
this.driver_license = driver_license
this.private_hire = private_hire
this.vehicle_details = vehicle_details
this.insurance_details = insurance_details
this.mot_details = mot_details
this.log_book = log_book
this.ph_car = private_hire_vehicle
}
}

View File

@@ -0,0 +1,16 @@
package h_mal.appttude.com.objects
class UserObject {
var profileName: String? = null
var profileEmail: String? = null
var profilePicString: String? = null
constructor()
constructor(profileName: String?, profileEmail: String?, profilePicString: String?) {
this.profileName = profileName
this.profileEmail = profileEmail
this.profilePicString = profilePicString
}
}

View File

@@ -0,0 +1,35 @@
package h_mal.appttude.com.objects
import h_mal.appttude.com.objects.wholeObject.DriverProfile
import h_mal.appttude.com.objects.wholeObject.VehicleProfile
class WholeDriverObject {
var driver_profile: DriverProfile? = null
var role: String? = null
var archive: ArchiveObject? = null
var user_details: UserObject? = null
var vehicle_profile: VehicleProfile? = null
var approvalsObject: ApprovalsObject? = null
var driver_number: String? = null
constructor(
driver_profile: DriverProfile?,
role: String?,
archive: ArchiveObject?,
user_details: UserObject?,
vehicle_profile: VehicleProfile?,
approvalsObject: ApprovalsObject?,
driver_number: String?
) {
this.driver_profile = driver_profile
this.role = role
this.archive = archive
this.user_details = user_details
this.vehicle_profile = vehicle_profile
this.approvalsObject = approvalsObject
this.driver_number = driver_number
}
constructor()
}

View File

@@ -0,0 +1,24 @@
package h_mal.appttude.com.objects.wholeObject
import h_mal.appttude.com.model.DriverProfileObject
import h_mal.appttude.com.model.DriversLicenseObject
import h_mal.appttude.com.model.PrivateHireObject
class DriverProfile {
var driver_profile: DriverProfileObject? = null
var driver_license: DriversLicenseObject? = null
var private_hire: PrivateHireObject? = null
constructor(
driver_profile: DriverProfileObject?,
driver_license: DriversLicenseObject?,
private_hire: PrivateHireObject?
) {
this.driver_profile = driver_profile
this.driver_license = driver_license
this.private_hire = private_hire
}
constructor()
}

View File

@@ -0,0 +1,42 @@
package h_mal.appttude.com.objects.wholeObject
import android.os.Parcel
import android.os.Parcelable
import h_mal.appttude.com.objects.WholeDriverObject
class MappedObject : Parcelable {
var userId: String? = null
var wholeDriverObject: WholeDriverObject? = null
constructor(userId: String?, wholeDriverObject: WholeDriverObject?) {
this.userId = userId
this.wholeDriverObject = wholeDriverObject
}
constructor()
protected constructor(`in`: Parcel) {
userId = `in`.readString()
}
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(userId)
}
companion object {
@JvmField
val CREATOR: Parcelable.Creator<MappedObject?> = object : Parcelable.Creator<MappedObject?> {
override fun createFromParcel(`in`: Parcel): MappedObject? {
return MappedObject(`in`)
}
override fun newArray(size: Int): Array<MappedObject?> {
return arrayOfNulls(size)
}
}
}
}

View File

@@ -0,0 +1,38 @@
package h_mal.appttude.com.objects.wholeObject
import h_mal.appttude.com.model.InsuranceObject
import h_mal.appttude.com.model.LogbookObject
import h_mal.appttude.com.model.PrivateHireVehicleObject
import h_mal.appttude.com.model.MotObject
import h_mal.appttude.com.model.VehicleProfileObject
class VehicleProfile {
var insurance_details: InsuranceObject? = null
var log_book: LogbookObject? = null
var mot_details: MotObject? = null
var vehicle_details: VehicleProfileObject? = null
var privateHireVehicleObject: PrivateHireVehicleObject? = null
constructor()
// public VehicleProfile(InsuranceObject insurance_details, LogbookObject log_book, MotObject mot_details, VehicleProfileObject vehicle_details) {
// this.insurance_details = insurance_details;
// this.log_book = log_book;
// this.mot_details = mot_details;
// this.vehicle_details = vehicle_details;
// }
constructor(
insurance_details: InsuranceObject?,
log_book: LogbookObject?,
mot_details: MotObject?,
vehicle_details: VehicleProfileObject?,
private_hire_vehicle: PrivateHireVehicleObject?
) {
this.insurance_details = insurance_details
this.log_book = log_book
this.mot_details = mot_details
this.vehicle_details = vehicle_details
privateHireVehicleObject = private_hire_vehicle
}
}

View File

@@ -0,0 +1,188 @@
package h_mal.appttude.com.ui
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import h_mal.appttude.com.objects.wholeObject.MappedObject
import h_mal.appttude.com.R
class ApprovalListAdapter(
private val activity: Activity,
objects: Array<MappedObject?>
): ArrayAdapter<MappedObject?>(activity, 0, objects) {
var mappedObject: MappedObject? = objects[0]
var names: Array<String> = arrayOf(
"Driver Profile",
"Driver License",
"Private Hire",
"Vehicle Profile",
"Insurance",
"MOT",
"Logbook",
"P/H Vehicle"
)
var approvalCode: Int = 0
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var listItemView: View? = convertView
if (listItemView == null) {
listItemView = LayoutInflater.from(activity).inflate(
R.layout.approval_list_grid_item, parent, false
)
}
// approvalCode = getApprovalStatusCode(position)
// val textView: TextView = listItemView!!.findViewById(R.id.approval_text)
// textView.text = names.get(position)
// val imageView: ImageView = listItemView.findViewById(R.id.approval_iv)
// imageView.setImageResource(
// MainActivity.approvalsClass!!.setImageResource(
// approvalCode
// )
// )
// imageView.setOnClickListener {
// SetApprovalDialog(
// approvalCode,
// activity,
// mappedObject.userId,
// position,
// imageView
// )
// }
// val archiveImage: ImageView = listItemView.findViewById(R.id.archive_icon)
// mappedObject.wholeDriverObject?.archive?.let {
//
//
// archiveImage.visibility = getArchive(
// position,
// it
// )
// archiveImage.setOnClickListener {
// var s: String? = null
// when (position) {
// 1 -> s = FirebaseClass.DRIVERS_LICENSE_FIREBASE
// 2 -> s = FirebaseClass.PRIVATE_HIRE_FIREBASE
// 3 -> s = FirebaseClass.VEHICLE_DETAILS_FIREBASE
// 4 -> s = FirebaseClass.INSURANCE_FIREBASE
// 5 -> s = FirebaseClass.MOT_FIREBASE
// 6 -> s = FirebaseClass.LOG_BOOK_FIREBASE
// 7 -> s = FirebaseClass.PRIVATE_HIRE_VEHICLE_LICENSE
// }
//// executeFragment(ArchiveFragment(), mappedObject.userId, s)
// }
// }
// listItemView.setOnClickListener(View.OnClickListener { getFragment(position) })
// listItemView.minimumHeight = parent.height / 4
// listItemView.setPadding(
// convertDpToPixel(9f, context).toInt(),
// convertDpToPixel(9f, context).toInt(),
// convertDpToPixel(9f, context).toInt(),
// convertDpToPixel(9f, context).toInt()
// )
return (listItemView)!!
}
// override fun getCount(): Int {
// return 8
// }
//
// private fun getArchive(i: Int, archiveObject: ArchiveObject?): Int {
// var o: Any? = null
// val visible: Int
// when (i) {
// 0 -> { }
// 1 -> o = archiveObject!!.driver_license
// 2 -> o = archiveObject!!.private_hire
// 3 -> o = archiveObject!!.vehicle_details
// 4 -> o = archiveObject!!.insurance_details
// 5 -> o = archiveObject!!.mot_details
// 6 -> o = archiveObject!!.log_book
// 7 -> o = archiveObject!!.ph_car
// }
// if (o != null) {
// visible = View.VISIBLE
// } else {
// visible = View.GONE
// }
// return visible
// }
//
// private fun getFragment(i: Int) {
// lateinit var f: Fragment
// val driverProfile by lazy { mappedObject.wholeDriverObject?.driver_profile }
// val vehicleProfile by lazy { mappedObject.wholeDriverObject?.vehicle_profile }
// val o: Any? = when (i) {
// 0 -> {
// f = DriverProfileFragment()
// driverProfile?.driver_profile
// }
// 1 -> {
// f = DriverLicenseFragment()
// driverProfile?.driver_license
// }
// 2 -> {
// f = PrivateHireLicenseFragment()
// driverProfile?.private_hire
// }
// 3 -> {
// f = VehicleProfileFragment()
// vehicleProfile?.vehicle_details
// }
// 4 -> {
// f = InsuranceFragment()
// vehicleProfile?.insurance_details
// }
// 5 -> {
// f = MotFragment()
// vehicleProfile?.insurance_details
// }
// 6 -> {
// f = LogbookFragment()
// vehicleProfile?.log_book
// }
// 7 -> {
// f = PrivateHireVehicleFragment()
// vehicleProfile?.privateHireVehicleObject
// }
// else -> null
// }
// if (o == null) {
//// executeFragment(f, mappedObject.userId)
// } else {
// MainActivity.archiveClass.openDialogArchive(
// context, o, mappedObject.userId, f
// )
// }
// }
//
// private fun getApprovalStatusCode(i: Int): Int {
// val statusCode = mappedObject.wholeDriverObject?.approvalsObject?.let{
// when (i) {
// 0 -> it.driver_details_approval
// 1 -> it.driver_license_approval
// 2 -> it.private_hire_approval
// 3 -> it.vehicle_details_approval
// 4 -> it.insurance_details_approval
// 5 -> it.mot_details_approval
// 6 -> it.log_book_approval
// 7 -> it.ph_car_approval
// else -> FirebaseClass.NO_DATE_PRESENT
// }
// }
// return statusCode ?: FirebaseClass.NO_DATE_PRESENT
// }
//
// companion object {
// fun convertDpToPixel(dp: Float, context: Context): Float {
// return dp * (context.resources
// .displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT)
// }
// }
}

View File

@@ -0,0 +1,107 @@
package h_mal.appttude.com.ui
import android.app.AlertDialog
import android.content.Context
import android.view.View
import androidx.cardview.widget.CardView
class DriverStatusClass : View.OnClickListener {
var userId: String? = null
var cardView: CardView? = null
var context: Context? = null
var currentSelection: Boolean = false
override fun onClick(v: View) {
val choices: Array<String> = arrayOf("Active", "Inactive")
val alertDialog: AlertDialog.Builder = AlertDialog.Builder(context)
var selection: Int = -1
if (currentSelection) {
selection = 0
} else if (!currentSelection) {
selection = 1
}
alertDialog.setSingleChoiceItems(
choices,
selection
) { dialog, which -> }
alertDialog.create().show()
}
private fun SetStatus(status: Boolean) {
// MainActivity.mDatabase!!.child(FirebaseClass.USER_FIREBASE)
// .child((userId)!!).child(FirebaseClass.DRIVER_STATUS).setValue(status)
// .addOnCompleteListener { task ->
// if (task.isSuccessful) {
// cardView!!.setBackgroundColor(setStatusColour(status))
// } else {
// }
// }
}
private fun setStatusColour(b: Boolean): Int {
if (b) {
return android.R.color.holo_green_dark
} else {
return android.R.color.holo_red_dark
}
} // public int getOverApprovalStatusCode(WholeDriverObject wholeDriverObject){
//
// if (wholeDriverObject.approvalsObject != null){
// ApprovalsObject approvalsObject = wholeDriverObject.approvalsObject;
//
// int[] ints = new int[]{approvalsObject.getDriver_details_approval(),
// approvalsObject.driver_license_approval,
// approvalsObject.private_hire_approval,
// approvalsObject.vehicle_details_approval,
// approvalsObject.insurance_details_approval,
// approvalsObject.mot_details_approval,
// approvalsObject.log_book_approval,
// approvalsObject.ph_car_approval};
//
//
// return setImageResource(mode(ints));
// }
//
// return setImageResource(NO_DATE_PRESENT);
// }
//
// public void setStatusCode(String userId,String approvalNameString,int status){
//
// if (!approvalNameString.equals("")) {
// mDatabase.child(USER_FIREBASE).child(userId).child(USER_APPROVALS).child(approvalNameString)
// .setValue(status).addOnCompleteListener(new OnCompleteListener<Void>() {
// @Override
// public void onComplete(@NonNull Task<Void> task) {
// if (task.isSuccessful()) {
//
// } else {
//
// }
// }
// });
// }
//
//
// }
//
// public int setImageResource(int statusCode){
// int imageResource;
//
// switch (statusCode){
// case APPROVAL_PENDING:
// imageResource = R.drawable.pending;
// break;
// case APPROVAL_DENIED:
// imageResource = R.drawable.denied;
// break;
// case APPROVED:
// imageResource = R.drawable.approved;
// break;
// default:
// imageResource = R.drawable.zero;
// break;
// }
//
// return imageResource;
// }
}

View File

@@ -0,0 +1,151 @@
package h_mal.appttude.com.ui
import android.app.AlertDialog
import android.content.DialogInterface
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
import android.view.*
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.ValueEventListener
import h_mal.appttude.com.objects.WholeDriverObject
import h_mal.appttude.com.objects.wholeObject.MappedObject
import h_mal.appttude.com.R
import kotlinx.android.synthetic.admin.fragment_home_super_user.*
import java.io.IOException
import java.util.*
class HomeSuperUserFragment : Fragment() {
var users: DatabaseReference? = null
var mappedObjectList: MutableList<MappedObject>? = null
private var sharedPreferences: SharedPreferences? = null
private var sortOrder: Int = 0
private val sortDesc: Boolean = false
private var recyclerViewAdapter: RecyclerViewAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
mappedObjectList = ArrayList()
users!!.addValueEventListener(valueEventListener)
sharedPreferences = requireActivity().getSharedPreferences("PREFS", 0)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view: View = inflater.inflate(R.layout.fragment_home_super_user, container, false)
recycler_view.apply {
layoutManager = LinearLayoutManager(context)
recyclerViewAdapter = RecyclerViewAdapter(context, mappedObjectList)
adapter = recyclerViewAdapter
}
return view
}
var valueEventListener: ValueEventListener = object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
mappedObjectList!!.clear()
Log.i("Count ", "" + snapshot.childrenCount)
for (postSnapshot: DataSnapshot in snapshot.children) {
if ((postSnapshot.child("role").value.toString() == "driver")) {
mappedObjectList!!.add(
MappedObject(
postSnapshot.key, postSnapshot.getValue(
WholeDriverObject::class.java
)
)
)
}
}
sortDate(sortOrder, sortDesc)
}
override fun onCancelled(databaseError: DatabaseError) {
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_calls_fragment, menu)
super.onCreateOptionsMenu(menu, inflater)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.archive) {
val grpname: Array<String> = arrayOf("Driver Name", "Driver Number", "Approval")
sortOrder = sharedPreferences!!.getInt(SORT, 0)
val checkedItem: Int = sortOrder
var compareInt = 0
val click = DialogInterface.OnClickListener { dialog, _ ->
sortDate(compareInt, false)
dialog.dismiss()
}
val builder: AlertDialog.Builder = AlertDialog.Builder(context)
builder.setTitle("Sort by:")
.setSingleChoiceItems(
grpname,
checkedItem
) { _, pos -> compareInt = pos }
.setPositiveButton("Ascending", click)
.setNegativeButton("Descending", click)
.create().show()
}
return super.onOptionsItemSelected(item)
}
private fun sortDate(compareInt: Int, reversed: Boolean) {
val comparator: Comparator<MappedObject> = object : Comparator<MappedObject> {
override fun compare(o1: MappedObject, o2: MappedObject): Int {
when (compareInt) {
0 -> return o1.wholeDriverObject?.user_details?.profileName!!.compareTo(
o2.wholeDriverObject?.user_details?.profileName!!
)
1 -> {
var s1: String? = o1.wholeDriverObject?.driver_number
var s2: String? = o2.wholeDriverObject?.driver_number
if (o1.wholeDriverObject?.driver_number == null || (o1.wholeDriverObject!!
.driver_number == "0")
) {
s1 = ";"
}
if (o2.wholeDriverObject?.driver_number == null || (o2.wholeDriverObject!!
.driver_number == "0")
) {
s2 = ";"
}
return s1!!.compareTo((s2)!!)
}
else -> { throw IOException("dfdfs") }
// 2 -> return MainActivity.approvalsClass.getOverApprovalStatusCode(o1.wholeDriverObject) -
// MainActivity.approvalsClass.getOverApprovalStatusCode(o2.wholeDriverObject)
// else -> return MainActivity.approvalsClass.getOverApprovalStatusCode(
// o1.wholeDriverObject
// ) - MainActivity.approvalsClass.getOverApprovalStatusCode(o2.wholeDriverObject)
}
}
}
sharedPreferences!!.edit().putInt(SORT, compareInt).apply()
sharedPreferences!!.edit().putBoolean(REVERSED, reversed).apply()
if (reversed) {
Collections.sort(mappedObjectList, comparator.reversed())
} else {
Collections.sort(mappedObjectList, comparator)
}
recyclerViewAdapter!!.notifyDataSetChanged()
}
companion object {
private val SORT: String = "SORT"
private val REVERSED: String = "REVERSED"
}
}

View File

@@ -0,0 +1,101 @@
package h_mal.appttude.com.ui
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import androidx.core.view.GravityCompat
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.navigation.NavigationView
import com.google.firebase.auth.FirebaseUser
import h_mal.appttude.com.R
import h_mal.appttude.com.base.BaseActivity
import h_mal.appttude.com.dialogs.ExitDialog.displayExitDialog
import h_mal.appttude.com.utils.setGlideImage
import h_mal.appttude.com.viewmodels.MainViewModel
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.nav_header_main.view.*
class MainActivity : BaseActivity<MainViewModel>(),
NavigationView.OnNavigationItemSelectedListener {
private val vm by createLazyViewModel<MainViewModel>()
override fun getViewModel(): MainViewModel = vm
override val layoutId: Int = R.layout.activity_main
lateinit var navController: NavController
lateinit var appBarConfiguration: AppBarConfiguration
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)
navController = findNavController(R.id.container)
appBarConfiguration = AppBarConfiguration(navController.graph, drawer_layout)
nav_view.setupWithNavController(navController)
setupActionBarWithNavController(navController, appBarConfiguration)
getViewModel().getUserDetails()
setupLogoutInDrawer()
}
override fun onSupportNavigateUp(): Boolean {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
override fun setTitle(title: CharSequence) {
toolbar.title = title
}
override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
} else {
val navHostFragment = supportFragmentManager.findFragmentById(R.id.container)
navHostFragment?.childFragmentManager?.backStackEntryCount?.takeIf { it >= 1 }?.let {
return super.onBackPressed()
}
displayExitDialog()
}
}
override fun onSuccess(data: Any?) {
super.onSuccess(data)
when(data){
is FirebaseUser -> {
setupDrawer(data)
}
}
}
private fun setupDrawer(user: FirebaseUser) {
val header: View = nav_view.getHeaderView(0)
header.driver_email.text = user.email
header.driver_name.text = user.displayName
header.profileImage.setGlideImage(user.photoUrl)
}
private fun setupLogoutInDrawer(){
logout.setOnClickListener {
getViewModel().logOut()
}
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_user_settings -> { }
}
drawer_layout.closeDrawer(GravityCompat.START)
return true
}
}

View File

@@ -0,0 +1,102 @@
package h_mal.appttude.com.ui
import android.app.AlertDialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import h_mal.appttude.com.objects.UserObject
import h_mal.appttude.com.objects.wholeObject.MappedObject
import h_mal.appttude.com.R
class RecyclerViewAdapter constructor(var context: Context?, var objects: List<MappedObject>?) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RecyclerView.ViewHolder {
val viewCurrent: View =
LayoutInflater.from(context).inflate(R.layout.list_item_layout, viewGroup, false)
return ViewHolderMain(viewCurrent)
}
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, i: Int) {
val viewHolderCurrent: ViewHolderMain = viewHolder as ViewHolderMain
val mappedObject: MappedObject = objects!!.get(i)
val `object`: UserObject? = mappedObject.wholeDriverObject?.user_details
if (`object`!!.profilePicString != null) {
Picasso.get()
.load(`object`.profilePicString)
.resize(128, 128)
.placeholder(R.drawable.choice_img_round)
.into(viewHolderCurrent.profilePicImage)
} else {
viewHolderCurrent.profilePicImage.setImageResource(R.drawable.choice_img_round)
}
viewHolderCurrent.userNameTextView.setText(`object`.profileName)
viewHolderCurrent.userEmailTextView.setText(`object`.profileEmail)
if (mappedObject.wholeDriverObject?.driver_number == null) {
viewHolderCurrent.driverNo.text = "0"
} else {
val s: String = mappedObject.wholeDriverObject?.driver_number.toString()
viewHolderCurrent.driverNo.text = s
}
viewHolderCurrent.driverNo.setOnClickListener {
val builder: AlertDialog.Builder = AlertDialog.Builder(
context
)
val input: EditText = EditText(context)
val layout: LinearLayout = LinearLayout(context)
layout.orientation = LinearLayout.VERTICAL
layout.setPadding(28, 0, 56, 0)
input.setText(viewHolderCurrent.driverNo.text.toString())
input.setSelectAllOnFocus(true)
layout.addView(input)
builder.setTitle("Change Driver Number")
.setView(layout)
.setPositiveButton(
"Submit"
) { dialog, which ->
}.create()
.show()
}
// viewHolderCurrent.profileApprovalImage.setImageResource(
// MainActivity.approvalsClass!!.getOverApprovalStatusCode(mappedObject.wholeDriverObject)
// )
viewHolderCurrent.itemView.setOnClickListener {
val bundle: Bundle = Bundle()
bundle.putParcelable("mapped", mappedObject)
// executeFragment(UserMainFragment(), bundle)
}
}
override fun getItemCount(): Int {
return objects!!.size
}
internal inner class ViewHolderMain constructor(listItemView: View) :
RecyclerView.ViewHolder(listItemView) {
var profilePicImage: ImageView
var userNameTextView: TextView
var userEmailTextView: TextView
// CardView statusCard;
var profileApprovalImage: ImageView
var driverNo: TextView
init {
profilePicImage = listItemView.findViewById(R.id.driverPic)
userNameTextView = listItemView.findViewById(R.id.username_text)
// statusCard = listItemView.findViewById(R.id.status_icon);
userEmailTextView = listItemView.findViewById(R.id.emailaddress_text)
profileApprovalImage = listItemView.findViewById(R.id.approval_iv)
driverNo = listItemView.findViewById(R.id.driver_no)
}
}
}

View File

@@ -0,0 +1,30 @@
package h_mal.appttude.com.ui
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.GridView
import androidx.fragment.app.Fragment
import h_mal.appttude.com.objects.wholeObject.MappedObject
import h_mal.appttude.com.R
class UserMainFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view: View = inflater.inflate(R.layout.fragment_user_main, container, false)
Log.i("UserMain", "onCreateView: height = " + view.height)
val mappedObject: MappedObject? = requireArguments().getParcelable<MappedObject>("mapped")
activity?.title = mappedObject?.wholeDriverObject?.user_details?.profileName
val listView: GridView = view.findViewById(R.id.approvals_list)
listView.adapter = ApprovalListAdapter(requireActivity(), arrayOf(mappedObject))
return view
}
}

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center"
app:cardCornerRadius="22dp"
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/cardviewoutline"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/approval_iv"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
tools:src="@drawable/pending" />
<View
android:id="@+id/view_1"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/approval_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="17sp"
android:textStyle="bold"
tools:text="Private Hire License" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<FrameLayout
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="12dp">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
<ImageView
android:id="@+id/archive_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_archive_black_24dp"
app:tint="@color/colour_three" />
</FrameLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.HomeSuperUserFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.UserMainFragment">
<GridView
android:id="@+id/approvals_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:rowCount="4"
android:stretchMode="columnWidth"
tools:listitem="@layout/approval_list_grid_item"/>
</RelativeLayout>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colour_nine">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/driverPic"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
app:civ_border_width="3dp"
app:civ_shadow_radius="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/choice_img_round" />
<ImageView
android:id="@+id/approval_iv"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
app:layout_constraintTop_toTopOf="@id/driverPic"
app:layout_constraintRight_toRightOf="@id/driverPic"
android:adjustViewBounds="true"
tools:src="@android:drawable/presence_online" />
<TextView
android:id="@+id/driver_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="24dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/driverPic"
tools:text="T22" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@id/driverPic"
app:layout_constraintLeft_toRightOf="@id/driverPic"
app:layout_constraintRight_toLeftOf="@id/driver_no"
app:layout_constraintTop_toTopOf="@id/driverPic">
<TextView
android:id="@+id/username_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:text="Haider Malik" />
<TextView
android:id="@+id/emailaddress_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="11sp"
tools:text="h.malik144.au@gmail.com" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>