繁体   English   中英

无法访问其他类中的方法,但是其他人可以

[英]Cannot access a method in other class, but other one can

我有一个带有2个方法的类,但是在调试时,我可以访问showLog()方法,但不能从其他类访问editProductCode()方法。 这是我的代码:

class ProductCodeModel(private val mView: ProductCodeContract.View) : ProductCodeContract.Model {

fun showLog(){
    Log.e("====", "Can access this method")
}

override fun editProductCode(storeId: Int?, departmentId: Int?, name: String?, code: String?, unit: String?, isDynamicReference: Int?, minimumLimit: Float?, isActive: Int?, note: String?) {
    Constraint.mRetrofit?.create(MaterialService::class.java)
            ?.editProductCode(storeId, departmentId, name, code, unit, minimumLimit, isDynamicReference, isActive, note)
            ?.subscribeOn(Schedulers.io())
            ?.observeOn(AndroidSchedulers.mainThread())
            ?.subscribeWith(object : DisposableObserver<InventoryResponse>() {
                override fun onComplete() {

                }

                override fun onNext(response: InventoryResponse) {
                    if (response.status == Constraint.STATUS_RIGHT)
                        mView.editProductCodeSuccess(response.inventory)
                    else {
                        mView.editProductCodeFailed(response.error?.desc)
                    }
                }

                override fun onError(e: Throwable) {
                    val msg = Resources.getSystem().getString(android.R.string.unknownName)
                    mView.editProductCodeFailed(msg)
                }
            })
}

这是我的声明:

private val mModel = ProductCodeModel(this)
mModel.showLog() //I can access this method
mModel.editProductCode(storeId, departmentId, name, code, unit, isDynamicReference, minimumLimit, isActive, note) //I cannot access this method

ProductCodeContract类

interface ProductCodeContract {

interface View {
    fun getInventoryListSuccess(inventoryList: List<Inventory>?)
    fun getInventoryListFailed(msg: String?)

    fun createProductCodeSuccess(inventory: Inventory?)
    fun createProductCodeFailed(msg: String?)

    fun editProductCodeSuccess(inventory: Inventory?)
    fun editProductCodeFailed(msg: String?)
}

interface Model {
    fun getInventoryList(storeId: Int?, offset: Int?, limit: Int?)
    fun createProductCode(storeId: Int?, departmentId: Int?, name: String?, code: String?, unit: String?, isDynamicReference: Int?,
                          minimumLimit: Float?, isActive: Int?, note: String?)

    fun editProductCode(storeId: Int?, departmentId: Int?, name: String?, code: String?, unit: String?, isDynamicReference: Int?,
                        minimumLimit: Float?, isActive: Int?, note: String?)
}

}

来人帮帮我...

尝试导入嵌套接口方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM