Muhammad al-xorazmiy nomidagi tоshkent axbоrоt texnоlоgiyalari universiteti mustaqil ish mavzu



Download 0,82 Mb.
bet10/10
Sana28.05.2022
Hajmi0,82 Mb.
#612616
1   2   3   4   5   6   7   8   9   10
Bog'liq
Loyiha ishi Jumanov Ozodbek

FOYDALANILGAN ADABIYOTLAR

  1. https://www.smashingmagazine.com/2018/02/comprehensive-guide-to-mobile-app-design/Герберт Шилдт. Java 8. Полное руководство, 9-е издание = Java 8. The Complete Reference, 9th Edition. — М.: «Вильямс»

  2. Кей С. Хорстманн. Java SE 8. Вводный курс = Java SE 8 for the Really Impatient. — М.: «Вильямс

  3. Фрэд Лонг, Дхрув Мохиндра, Роберт С. Сикорд, Дин Ф. Сазерленд, Дэвид Свобода. Руководство для программиста на Java: 75 рекомендаций по написанию надежных и защищённых программ = Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs. — М.: «Вильямс

  4. Кей С. Хорстманн, Гари Корнелл. Java. Библиотека профессионала, том 1. Основы. 9-е издание = Core Java, Volume I: Fundamentals (9th Edition). — М.: «Вильямс

Internet saytlari

  1. https://dasturchi.uz/plangs/tutorials/javatut/java-haqida/

  2. http://software.uz/ru/normdoc

  3. https://daryo.uz/search/?q=mobil+ilova

  4. http://uz.infocom.uz/2018/09/11/barcha-mobil-ilovalar-platformalari-uchun-qoshimcha-imkoniyalar/

  5. http://www.androiddocs.com/design/patterns/app-structure.html

  6. https://ru.wikipedia.org/wiki/Java

  7. https://www.smashingmagazine.com/2018/02/comprehensive-guide-to-mobile-app-design/

  8. https://apptractor.ru/develop/chistaya-arhitektura-na-android-i-ios.html



ILOVA
import android.content.Intent
import android.content.res.Resources
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.squareup.picasso.Picasso
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.dialog_transaction.view.*
import kotlinx.android.synthetic.main.fragment_profile.*
import lecho.lib.hellocharts.model.PieChartData
import lecho.lib.hellocharts.model.SliceValue
import java.util.concurrent.TimeUnit
class ProfileFragment : ViewPagerFragment() {

companion object {


fun newInstance() = ProfileFragment().apply {}
}

private val alertDialog: AlertDialog by lazy {


return@lazy AlertDialog.Builder(requireContext()).setView(layoutPay).create()
}

private val layoutPay by lazy {


return@lazy LayoutInflater.from(requireContext()).inflate(R.layout.dialog_transaction, null, false)
}

private val userViewModel by lazy {


return@lazy ViewModelProviders.of(requireActivity()).get(UserViewModel::class.java)
}

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState)
userViewModel
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {


return inflater.inflate(R.layout.fragment_profile, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {


updateResources(UpdateCenter.language.value ?: resources)


pcvOverall.isChartRotationEnabled = false


progressBarCurrentLevel.scaleY = 3f
ivPlus.setOnClickListener {
alertDialog.show()
}

imageViewEdit.setOnClickListener {


userViewModel.user.value?.let {
(requireActivity() as? MainNavigable)?.navigateToEditProfile(it)
}
}

layoutPay.ivPayMe.setOnClickListener {


if (layoutPay.editTextAmount.text.toString().toIntOrNull() != null) {


ApiFactory.getApiService()
.getCheckOutLink(0,
layoutPay.editTextAmount.text.toString().toInt() * 100)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.retryWhen { errors ->
errors.flatMap { Observable.timer(5, TimeUnit.SECONDS) }
}.subscribeKt(Consumer { response ->
if (response.result != null) {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(response.result)
startActivity(i)

} else {
Toast.makeText(requireContext(), response.error, Toast.LENGTH_SHORT).show()


}
})
} else {

layoutPay.editTextAmount.error = resources.getString(R.string.enter_amount)


}

alertDialog.dismiss()


}


layoutPay.ivClick.setOnClickListener {
if (layoutPay.editTextAmount.text.toString().toIntOrNull() != null) {
ApiFactory.getApiService()
.getCheckOutLink(1,
layoutPay.editTextAmount.text.toString().toInt())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.retryWhen { errors ->
errors.flatMap { Observable.timer(5, TimeUnit.SECONDS) }
}.subscribeKt(Consumer { response ->
if (response.result != null) {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(response.result)
startActivity(i)

} else {
Toast.makeText(requireContext(), response.error, Toast.LENGTH_SHORT).show()


}
})
}
alertDialog.dismiss()
}
userViewModel.user.run {

value?.let {


bindCurrentUser(it)
}

observe(this@ProfileFragment, Observer { profile ->


bindCurrentUser(profile)
})
}

UpdateCenter.language.observe(this, Observer {


updateResources(it)
})

}
private fun bindCurrentUser(user: User) {


Picasso.get().load(user.image).placeholder(if (user.gender == 1) R.drawable.ic_man else R.drawable.ic_girl).into(imageViewProfile)


textViewName.text = user.name
textViewEmail.text = user.email ?: user.phone
textViewCurrentLevel.text = user.levelName
textViewBalanceAmount.text = String.format(resources.getString(R.string.uzs), user.balance.toUZS())
val pieDataCurrent = ArrayList()
pieDataCurrent.add(SliceValue(100 * user.userLevelMark.toFloat() / user.levelMark.toFloat(), ContextCompat.getColor(requireContext(), R.color.colorPrimary)))
pieDataCurrent.add(SliceValue(100f - 100 * user.userLevelMark.toFloat() / user.levelMark.toFloat(), ContextCompat.getColor(requireContext(), R.color.colorPrimaryLight)))

val pieDataOverall = ArrayList()


pieDataOverall.add(SliceValue(SliceValue(100 * user.userMark.toFloat() / user.totalMark.toFloat(), ContextCompat.getColor(requireContext(), R.color.colorPrimary))))
pieDataOverall.add(SliceValue(SliceValue(100f - 100 * user.userMark.toFloat() / user.totalMark.toFloat(), ContextCompat.getColor(requireContext(), R.color.colorPrimaryLight))))
pcvOverall.pieChartData = PieChartData(pieDataOverall)

}


private fun updateResources(resources: Resources) {
textViewCurrentLevelDesc.text = resources.getString(R.string.current_level)
textViewOverallLevel.text = resources.getString(R.string.overall_level)
textViewBalance.text = resources.getString(R.string.balance)
textViewBalanceAmount.text = String.format(resources.getString(R.string.uzs),
userViewModel.user.value?.balance?.toUZS())
}
}
import android.app.AlertDialog
import android.content.res.Resources
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import kotlinx.android.synthetic.main.fragment_settings.*

class SettingsFragment : ViewPagerFragment() {


companion object {


fun newInstance() = SettingsFragment().apply {

}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_settings, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {


super.onViewCreated(view, savedInstanceState)

updateResources(UpdateCenter.language.value ?: resources)


if (getLanguage() == "uz") {


textViewCurrentLanguage.text = resources.getString(R.string.uzbek)
} else {
textViewCurrentLanguage.text = resources.getString(R.string.english)
}

layoutLanguage.setOnClickListener {


var language = if (getLanguage() == "uz") 0 else 1
AlertDialog.Builder(requireContext())
.setTitle(R.string.app_language)
.setSingleChoiceItems(arrayOf(resources.getString(R.string.uzbek),
resources.getString(R.string.english)), language) { _, b ->
language = b
}
.setPositiveButton(R.string.ok) { d, i ->
d.dismiss()
val lang = if (language == 0) {
textViewCurrentLanguage.text = resources.getString(R.string.uzbek)
"uz"
} else {
textViewCurrentLanguage.text = resources.getString(R.string.english)
"en"
}

UpdateCenter.language.postValue(requireContext().setNewLocale(lang).resources)


}
.setNegativeButton(resources.getString(R.string.cancel)) { d, _ ->
d.dismiss()
}
.show()
}

layoutTerms.setOnClickListener {


(activity as? MainNavigable?)?.navigateToTerms()
}

layoutNotification.setOnClickListener {


(activity as? MainNavigable?)?.navigateToNotification()
}

layoutPrivacy.setOnClickListener {


(activity as? MainNavigable?)?.navigateToPrivacy()
}

layoutContactUs.setOnClickListener {


(activity as? MainNavigable?)?.navigateToContactUs()
}

layoutLogOut.setOnClickListener {


AlertDialog.Builder(requireContext())
.setTitle(R.string.are_u_sure_log_out)
.setPositiveButton(resources.getString(R.string.ok)) { d, _ ->
(activity as? AccountAccessible?)?.logOut()
d.dismiss()
}
.setNegativeButton(resources.getString(R.string.cancel)) { d, _ ->
d.dismiss()
}
.show()
}

layoutDeleteAccount.setOnClickListener {


AlertDialog.Builder(requireContext())
.setTitle(R.string.are_u_sure_delete_account)
.setPositiveButton(resources.getString(R.string.ok)) { d, _ ->
(activity as? AccountAccessible?)?.deleteAccount()
d.dismiss()
}
.setNegativeButton(resources.getString(R.string.cancel)) { d, _ ->
d.dismiss()
}
.show()
}

UpdateCenter.language.observe(this, Observer {


updateResources(it)
})

}


private fun updateResources(resources: Resources) {
textViewLanguage.text = resources.getString(R.string.app_language)
textViewNotifications.text = resources.getString(R.string.notifications)
textViewTerms.text = resources.getString(R.string.terms_of_service)
textViewPrivacy.text = resources.getString(R.string.privacy_policy)
textViewContactUs.text = resources.getString(R.string.contact_us)
textViewLogOut.text = resources.getString(R.string.log_out)
textViewDeleteAccount.text = resources.getString(R.string.delete_account)
}
}
import android.app.DatePickerDialog
import android.content.Intent
import android.content.res.Resources
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.esafirm.imagepicker.features.ImagePicker
import com.esafirm.imagepicker.features.ReturnMode
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.fragment_edit_profile.*
import java.text.SimpleDateFormat
import java.util.*

class FillProfileFragment : FullScreenFragment() {


companion object {


fun newInstance(user: User) = FillProfileFragment().apply {
arguments = Bundle().apply {
putSerializable("user", user)
}
}
}

private val userViewModel by lazy {


return@lazy ViewModelProviders.of(this).get(UserViewModel::class.java)
}

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState)
userViewModel
}

override fun getSwipeBackView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_edit_profile, container, false)


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

updateResources(UpdateCenter.language.value ?: resources)


(arguments?.getSerializable("user") as? User)?.let {


bindProfile(it)
}

imageViewProfile.setOnClickListener {


ImagePicker.create(this)


.returnMode(ReturnMode.ALL)
.folderMode(true)
.toolbarFolderTitle(resources.getString(R.string.folder))
.toolbarImageTitle(resources.getString(R.string.tap_to_select))
.toolbarArrowColor(ContextCompat.getColor(requireContext(), R.color.colorWhite))
.includeVideo(false)
.single()
.showCamera(true)
.imageDirectory("Camera")
.enableLog(true)
.imageLoader(PicassoLoader())
.start()
}

editTextBirthDay.setOnClickListener {


DatePickerDialog(requireContext(), DatePickerDialog.OnDateSetListener { _, y, m, d ->
val c = Calendar.getInstance()
c[Calendar.YEAR] = y
c[Calendar.MONTH] = m
c[Calendar.DAY_OF_MONTH] = d
editTextBirthDay.setText(SimpleDateFormat("dd.MM.yyyy", Locale.getDefault()).format(c.time))
}, 1970, 1, 1).show()
}

editTextGender.setOnClickListener {


val items = arrayOf(resources.getString(R.string.male), resources.getString(R.string.female))
val cur = if (editTextGender.text.toString() == resources.getString(R.string.male)) 1 else 0
AlertDialog.Builder(requireContext()).setSingleChoiceItems(items, cur) { a, b ->
editTextGender.setText(items[b])
a.dismiss()
}.show()
}

buttonSave.setOnClickListener {


when {
editTextName.text.toString().isEmpty() -> {
editTextName.error = (UpdateCenter.language.value
?: resources).getString(R.string.enter_full_name)
}
editTextEmail.text.toString().isEmpty() -> {
editTextPhone.error = (UpdateCenter.language.value
?: resources).getString(R.string.enter_email)
}
editTextPhone.text.toString().isEmpty() -> {
editTextPhone.error = (UpdateCenter.language.value
?: resources).getString(R.string.enter_phone_number)
}
editTextBirthDay.text.toString().isEmpty() -> {
editTextBirthDay.error = (UpdateCenter.language.value
?: resources).getString(R.string.enter_birthday)
}
editTextGender.text.toString().isEmpty() -> {
editTextBirthDay.error = (UpdateCenter.language.value
?: resources).getString(R.string.enter_birthday)
}
else -> {
val user = User(
name = editTextName.text.toString(),
email = editTextEmail.text.toString(),
phone = editTextPhone.text.toString(),
birthday = SimpleDateFormat("dd.MM.yyyy",
Locale.getDefault()).parse(editTextBirthDay.text.toString()).time,
gender = if (editTextGender.text.toString() == resources.getString(R.string.male)) 1 else 0
)

userViewModel.editCurrentUser(user)


.observe(this, Observer { result ->
if (!result)
Toast.makeText(requireContext(),
(UpdateCenter.language.value
?: resources).getString(R.string.something_went_wrong),
Toast.LENGTH_SHORT).show()
startActivity(Intent(requireContext(),
MainActivity::class.java))
})
}

}
}

}

private fun bindProfile(user: User) {


if (!user.image.isNullOrEmpty()) {


Picasso.get().load(user.image).placeholder(if (user.gender == 1) R.drawable.ic_man else R.drawable.ic_girl).into(imageViewProfile)
}

user.email?.let {


editTextEmail.setText(it)
}

user.phone?.let {


editTextPhone.setText(user.phone)
}

user.gender?.let {


editTextGender.setText(if (it == 1) resources.getString(R.string.male)
else resources.getString(R.string.female))
}

user.birthday?.let {


editTextBirthDay.setText(SimpleDateFormat("dd.MM.yyyy", Locale.getDefault())
.format(Date(it)))
}

}


private fun updateResources(resources: Resources) {
editTextName.hint = resources.getString(R.string.name)
editTextEmail.hint = resources.getString(R.string.email)
editTextPhone.hint = resources.getString(R.string.phone)
editTextBirthDay.hint = resources.getString(R.string.birthday)
editTextGender.hint = resources.getString(R.string.gender)

}


}


Download 0,82 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish