我有一个包含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?)
}
}
有人帮助我......
答案 0 :(得分:0)
尝试导入嵌套接口方法。