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

Проблема в сгенерированном коде TestListView$$State #265

Open
dfazullin opened this issue Dec 12, 2019 · 0 comments

Comments

@dfazullin
Copy link

dfazullin commented Dec 12, 2019

Решил обновить проект.
Перешел на Androidx и с com.github.moxy на com.arello-mobile
Проблему со всеми импортами решил, но появилась ошибка кодогенерации moxy (то есть при com.github.moxy - такого не было)

Мой gradle

dependencies {
   ...
    // Moxy
    implementation "com.arello-mobile:moxy:$moxyVersion" //moxyVersion = '1.5.5'
    implementation 'tech.schoolhelper:moxy-x-androidx:1.7.0'
    kapt "com.arello-mobile:moxy-compiler:$moxyVersion"
   ...
}

Fragment

class TestListFragment: BaseListFragment<String, TestListView, TestListPresenter, StringPaginationAdapter>(), TestListView {

    @InjectPresenter
    lateinit var presenter: TestListPresenter

    @ProvidePresenter
    fun providePresenter(): TestListPresenter = TestListPresenter()

    override fun initPresenter() = presenter

    override fun initAdapter() = StringPaginationAdapter()
}

Родительский Fragment

abstract class BaseListFragment<
        ITEM: Any,
        VIEW: BaseListView<ITEM>,
        PRESENTER: BaseListPresenter<ITEM, VIEW>,
        A: BasePaginationAdapter<ITEM>
    > : BaseFragment(), BaseListView<ITEM>, PaginationRecyclerView.OnLoadMore {

    val listPresenter: PRESENTER by lazy { initPresenter() }

    abstract fun initPresenter(): PRESENTER

    val adapter: A by lazy { initAdapter() }

    open val emptyListLayoutRes = R.layout.layout_base_empty_list
    private var emptyLayout: View? = null
    override val layoutRes = R.layout.layout_base_list

    abstract fun initAdapter(): A

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val layout = super.onCreateView(inflater, container, savedInstanceState)
        layout.findViewById<FrameLayout>(R.id.flListContent)?.run {
            instanceEmptyList(inflater, container?.findViewById(R.id.flListContent))?.let {
                emptyLayout = it
                this@run.addView(emptyLayout)
                hideEmptyList()
            }
        }
        return layout
    }

    private fun instanceEmptyList(inflater: LayoutInflater, container: ViewGroup?): View? {
        return if (emptyListLayoutRes != -1) { inflater.inflate(emptyListLayoutRes, container, false) }
        else { null }
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        initRecyclerView(rvList)
        initRefresher()
        super.onViewCreated(view, savedInstanceState)
    }

    open fun initRecyclerView(recyclerView: PaginationRecyclerView) {
        recyclerView.adapter = adapter
        recyclerView.withPagination = this@BaseListFragment.withPagination
        recyclerView.listener = this
    }

    override fun updateList(list: List<ITEM>) {
        rlRefresher?.isRefreshing = false
        adapter.update(list)
    }

    open fun getRefresherLayout(): SwipeRefreshLayout? = rlRefresh

    open fun getRecyclerView(): PaginationRecyclerView = prvList
}

View

interface TestListView : BaseListView<String>

Родительский View

@StateStrategyType(AddToEndSingleStrategy::class)
interface BaseListView <I>: BaseView {
    ...
    fun updateList(list: List<I>)
    ...
}

Сгенерированный код TestListView$$State (Ругается на "List<? extends I>", Не знает "I")

public class TestListView$$State extends MvpViewState<TestListView> implements TestListView {

        ......

	@Override
	public void updateList(List<? extends I> list) {
		UpdateListCommand updateListCommand = new UpdateListCommand(list);
		mViewCommands.beforeApply(updateListCommand);

		if (mViews == null || mViews.isEmpty()) {
			return;
		}

		for (TestListView view : mViews) {
			view.updateList(list);
		}

		mViewCommands.afterApply(updateListCommand);
	}

	public class UpdateListCommand extends ViewCommand<TestListView> {
		public final List<? extends I> list;

		UpdateListCommand(List<? extends I> list) {
			super("updateList", AddToEndSingleStrategy.class);

			this.list = list;
		}

		@Override
		public void apply(TestListView mvpView) {
			mvpView.updateList(list);
		}
	}

        ......

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant