Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ep/feature/multiautors #144

Open
wants to merge 4 commits into
base: ep/feature/updateTicketsListDataAndNewTicket
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class PyrusServiceDesk private constructor(
internal val application: Application,
internal val appId: String,
internal val userId: String?,
internal val userName: String?,
internal val authorId: String?,
internal val securityKey: String?,
internal val domain: String?,
internal val apiVersion: Int,
Expand Down Expand Up @@ -78,6 +80,10 @@ class PyrusServiceDesk private constructor(

private const val DEFAULT_TOKEN_TYPE: String = "android"

internal val usersId: List<String> = listOf("251380375", "251374579")

internal val usersName: List<String> = listOf("Много Лосося ДК Москва, Большая Филёвская улица, 3", "Старик Хинкалыч - Кострома Коллаж")

internal var logging = false
private set

Expand Down Expand Up @@ -106,7 +112,9 @@ class PyrusServiceDesk private constructor(
initInternal(
application,
appId,
null,
"255371017", //TODO
"папа джонс",
"10",
null,
domain,
API_VERSION_1,
Expand Down Expand Up @@ -137,6 +145,8 @@ class PyrusServiceDesk private constructor(
application: Application,
appId: String,
userId: String,
userName: String,
authorId: String?,
securityKey: String,
domain: String? = null,
loggingEnabled: Boolean = false,
Expand All @@ -146,6 +156,8 @@ class PyrusServiceDesk private constructor(
application,
appId,
userId,
userName,
authorId,
securityKey,
domain,
API_VERSION_2,
Expand All @@ -158,6 +170,8 @@ class PyrusServiceDesk private constructor(
application: Application,
appId: String,
userId: String?,
userName: String?,
authorId: String?,
securityKey: String?,
domain: String?,
apiVersion: Int = API_VERSION_1,
Expand All @@ -179,6 +193,8 @@ class PyrusServiceDesk private constructor(
application,
appId,
userId,
userName,
authorId,
securityKey,
validDomain,
apiVersion,
Expand All @@ -192,6 +208,8 @@ class PyrusServiceDesk private constructor(
application,
appId,
userId,
userName,
authorId,
securityKey,
validDomain,
apiVersion,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package com.pyrus.pyrusservicedesk.presentation.call

import kotlinx.coroutines.CoroutineScope
import com.pyrus.pyrusservicedesk.sdk.RequestFactory
import com.pyrus.pyrusservicedesk.sdk.data.TicketShortDescription
import com.pyrus.pyrusservicedesk.sdk.data.Command
import com.pyrus.pyrusservicedesk.sdk.data.intermediate.Tickets
import com.pyrus.pyrusservicedesk.sdk.response.ResponseCallback
import com.pyrus.pyrusservicedesk.sdk.response.ResponseError
import kotlinx.coroutines.CoroutineScope

/**
* Adapter for obtaining list of available tickets.
* @param scope coroutine scope for executing request.
*/
internal class GetTicketsCall(
scope: CoroutineScope,
private val requests: RequestFactory)
: BaseCall<List<TicketShortDescription>>(scope) {
private val requests: RequestFactory,
private val commands: List<Command> = emptyList()
) : BaseCall<Tickets>(scope) {

override suspend fun run(): CallResult<List<TicketShortDescription>> {
var tickets: List<TicketShortDescription>? = null
override suspend fun run(): CallResult<Tickets> {
var getTicketsResult: Tickets? = null
var error: ResponseError? = null
requests.getTicketsRequest().execute(
object: ResponseCallback<List<TicketShortDescription>> {
override fun onSuccess(data: List<TicketShortDescription>) {
tickets = data
requests.getTicketsRequest(commands).execute(
object: ResponseCallback<Tickets> {
override fun onSuccess(data: Tickets) {
getTicketsResult = data
}

override fun onFailure(responseError: ResponseError) {
Expand All @@ -30,6 +32,6 @@ internal class GetTicketsCall(

}
)
return CallResult(tickets, error)
return CallResult(getTicketsResult, error)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.addTicket

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.pyrus.pyrusservicedesk.PyrusServiceDesk
import com.pyrus.pyrusservicedesk.R
import com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.ticket.TicketActivity

class AddTicketAdapter (users: List<String>, val onItemClick: (Int) -> Unit) : RecyclerView.Adapter<AddTicketAdapter.AddTicketViewHolder>() {

private var users: List<String> = emptyList()
init {
this.users = users
}

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): AddTicketViewHolder {
return AddTicketViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.add_ticket_item, parent, false))
}

override fun onBindViewHolder(holder: AddTicketViewHolder, position: Int) {
val item = users[position]
holder.userName.text = item
}

override fun getItemCount(): Int {
return users.size
}

inner class AddTicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

val userName: TextView = itemView.findViewById(R.id.userNameTv)

init {
itemView.setOnClickListener{
onItemClick(bindingAdapterPosition)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.addTicket

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.pyrus.pyrusservicedesk.PyrusServiceDesk
import com.pyrus.pyrusservicedesk.R
import com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.ticket.TicketActivity
import com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.tickets_list.TicketsListViewModel
import com.pyrus.pyrusservicedesk.utils.getViewModelWithActivityScope

class AddTicketFragment: BottomSheetDialogFragment() {

private val viewModel: TicketsListViewModel by getViewModelWithActivityScope(TicketsListViewModel::class.java)

override fun getTheme() = R.style.PsdAppBottomSheetDialogTheme

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view = inflater.inflate(R.layout.add_ticket_fragment, null, false)
return view
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val recyclerview: RecyclerView = view.findViewById(R.id.usersRv)
recyclerview.layoutManager = LinearLayoutManager(view.context)

val adapter = AddTicketAdapter(users = getUsersName(),
onItemClick = { position ->
startActivity(TicketActivity.getLaunchIntent(userId = PyrusServiceDesk.usersId[position]))
dismiss()
})
recyclerview.adapter = adapter
}

private fun getUsersName(): List<String> {
return viewModel.getUsersName() ?: emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.pyrus.pyrusservicedesk.presentation.ui.navigation_page.filterTicketsList

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
import com.pyrus.pyrusservicedesk.R

class FilterTicketsAdapter (users: List<String>, userIds: List<String>, userId: String, val onItemClick: (Int) -> Unit) : RecyclerView.Adapter<FilterTicketsAdapter.AddTicketViewHolder>() {

private var users: List<String> = emptyList()
private var userIds: List<String> = emptyList()
private var userId: String = ""
init {
this.users = users
this.userIds = userIds
this.userId = userId
}

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): AddTicketViewHolder {
return AddTicketViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.filter_tickets_item, parent, false))
}

override fun onBindViewHolder(holder: AddTicketViewHolder, position: Int) {
val item = users[position]
holder.userName.text = item
holder.selectedUserIv.visibility = if(userIds[position] == userId) View.VISIBLE else View.GONE
}

override fun getItemCount(): Int {
return users.size
}

inner class AddTicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

val userName: TextView = itemView.findViewById(R.id.userNameTv)
val selectedUserIv: ImageView = itemView.findViewById(R.id.selectedUserIv)

init {
itemView.setOnClickListener{
onItemClick(bindingAdapterPosition)
}
}
}
}
Loading