Skip to content

Commit

Permalink
Merge pull request #194 from jampez77/bug/koin-isolation
Browse files Browse the repository at this point in the history
Bug/koin isolation
  • Loading branch information
jampez77 committed Feb 1, 2022
2 parents fc095d6 + 957b5a3 commit 540a1d9
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -68,7 +68,7 @@ In your Project's build.gradle file:
In your Application's or Module's build.gradle file:

dependencies {
api 'com.github.jampez77:UCE-Handler:2.0.14'
api 'com.github.jampez77:UCE-Handler:2.0.15'
}

In your Application class:
Expand Down
1 change: 0 additions & 1 deletion example_app/src/main/AndroidManifest.xml
Expand Up @@ -5,7 +5,6 @@

<application
android:name=".UCEHandlerApplication"
tools:replace="android:name"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
3 changes: 0 additions & 3 deletions uce_handler/build.gradle
Expand Up @@ -38,9 +38,6 @@ dependencies {

api "androidx.core:core-ktx:1.7.0"

// Koin
api "io.insert-koin:koin-android:3.1.5"

api 'androidx.navigation:navigation-fragment-ktx:2.4.0'
api 'androidx.navigation:navigation-ui-ktx:2.4.0'

Expand Down
3 changes: 1 addition & 2 deletions uce_handler/src/main/AndroidManifest.xml
Expand Up @@ -6,8 +6,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".utils.UCEApplication"
tools:replace="android:name"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".features.uce.UCEDefaultActivity"
Expand Down
@@ -0,0 +1,16 @@
package com.jampez.uceh.data

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.jampez.uceh.features.supportissue.SupportIssueRepository
import com.jampez.uceh.features.uce.UCEViewModel

class UCEViewModelFactory(private val supportIssueRepository: SupportIssueRepository): ViewModelProvider.Factory{
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
if(modelClass.isAssignableFrom(UCEViewModel::class.java)){
return UCEViewModel(supportIssueRepository) as T
}
throw IllegalArgumentException ("UnknownViewModel")
}

}

This file was deleted.

@@ -0,0 +1,7 @@
package com.jampez.uceh.features.bitbucket

import com.google.gson.annotations.SerializedName

data class BitBucketError(
@SerializedName("message") val message: String
)
Expand Up @@ -5,5 +5,6 @@ import com.google.gson.annotations.SerializedName
data class BitBucketResponse(
@SerializedName("id") val id: Long,
@SerializedName("title") val title: String,
@SerializedName("type") val type: String
@SerializedName("type") val type: String,
@SerializedName("error") val error: BitBucketError
)

This file was deleted.

Expand Up @@ -15,32 +15,43 @@ import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModelProvider
import com.jampez.uceh.R
import com.jampez.uceh.data.UCEViewModelFactory
import com.jampez.uceh.databinding.FragmentUceBinding
import com.jampez.uceh.features.bitbucket.Content
import com.jampez.uceh.features.supportissue.SupportIssueRepository
import com.jampez.uceh.utils.Mode
import com.jampez.uceh.utils.getColorCompat
import com.jampez.uceh.utils.getDrawableCompat
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.*
import org.koin.androidx.viewmodel.ext.android.viewModel

class UCEFragment : Fragment(R.layout.fragment_uce) {

private var strCurrentErrorLog: String? = null
private var ticketNumber = MutableLiveData<String>()

private val viewModel: UCEViewModel by viewModel()
private lateinit var viewModel: UCEViewModel

private var _binding: FragmentUceBinding? = null
private val binding get() = _binding!!

private val repository: SupportIssueRepository by lazy {
SupportIssueRepository()
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View {
_binding = FragmentUceBinding.inflate(inflater, container, false)

val factory = UCEViewModelFactory(repository)
viewModel = ViewModelProvider(this, factory).get(UCEViewModel::class.java)


return binding.root
}

Expand Down Expand Up @@ -166,22 +177,26 @@ class UCEFragment : Fragment(R.layout.fragment_uce) {
viewModel.postBitBucketIssue(content).observe(viewLifecycleOwner) {
Log.d("bitbucket response", it.data.toString())

var responseText = "There was an issue creating the issue"
val type = it.data?.type
responseText = "$responseText: \n$type"
if (type == "issue") {
val supportTickerNumber = it.data.id
val supportTicketTitle = it.data.title
var responseText = "Error"

ticketNumber.postValue(ticketNumber.value + "BB$supportTickerNumber")
when (val type = it.data?.type){
"issue" -> {
val supportTickerNumber = it.data.id
val supportTicketTitle = it.data.title

responseText = "$supportTicketTitle " +
"\n\nSorry about that! " +
"\n\nYour support ticket number is below." +
"\n\nPlease use this when talking to our support team about this issue."
ticketNumber.postValue(ticketNumber.value + "BB$supportTickerNumber")

responseText = "$supportTicketTitle " +
"\n\nSorry about that! " +
"\n\nYour support ticket number is below." +
"\n\nPlease use this when talking to our support team about this issue."

}
"error" -> responseText = "$responseText: \n${it.data.error.message}"
else -> responseText = "$responseText: \n$type"
}


when {
UCEHandler._gitLabService != null -> postGitlabIssue()
else -> postIssueEndUI(responseText)
Expand Down
26 changes: 0 additions & 26 deletions uce_handler/src/main/java/com/jampez/uceh/utils/UCEApplication.kt

This file was deleted.

0 comments on commit 540a1d9

Please sign in to comment.