ошибка: не удается найти метод символа contextModule (ContextModule) - PullRequest
0 голосов
/ 25 апреля 2019

Я разрабатываю новостное приложение, но получаю следующую ошибку от Logcat

ошибка: не удается найти метод символа contextModule (ContextModule)

ниже снимка экрана ошибки снимок экрана ошибки

ниже класса BBCFragment.java

открытый класс BBCSportFragment расширяет фрагмент, реализует ArticleAdapter.ClickListener {

public List<Article> articleList = new ArrayList<>();
@ActivityContext
public Context activityContext;
@ApplicationContext
public Context mContext;

@BindView(R.id.recycler_view)
RecyclerView recyclerView;
@Inject
BBCSportFragmentComponent bbcSportFragmentComponent;
BBCFragmentContextModule bbcFragmentContextModule;
private SportNews sportNews;
private ArticleAdapter articleAdapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bbcsport, container, false);
    Activity activity = getActivity();
    ButterKnife.bind(this, view);
    SportInterface sportInterface = SportClient.getApiService();
    Call<SportNews> call = sportInterface.getArticles();
    call.enqueue(new Callback<SportNews>() {
        @Override
        public void onResponse(Call<SportNews> call, Response<SportNews> response) {
            sportNews = response.body();
            if (sportNews != null && sportNews.getArticles() != null) {
                articleList.addAll(sportNews.getArticles());
            }
            articleAdapter = new ArticleAdapter(articleList, sportNews);
            ApplicationComponent applicationComponent = MyApplication.get(Objects.requireNonNull(activity)).getApplicationComponent();
            bbcSportFragmentComponent =
                    DaggerBBCSportFragmentComponent.builder()
                            .applicationComponent(applicationComponent)
                            .contextModule(new ContextModule(getContext()))
                            .build();
            bbcSportFragmentComponent.injectBBCSportFragment(BBCSportFragment.this);
            RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setAdapter(articleAdapter);
        }

        @Override
        public void onFailure(Call<SportNews> call, Throwable t) {
            Log.e("Error", "error");
        }
    });


    return view;


}

}

ниже класса ApplicationComponent.java

@ApplicationScope
@Component(modules = {ContextModule.class, SportClient.class})
public interface ApplicationComponent {


    public SportInterface sportInterface();

    @ApplicationContext
    public Context getContext();

    public void injectApplication(MyApplication myApplication);


}

below MyApplication.java class


public class MyApplication extends Application {

    ApplicationComponent applicationComponent;

    public static MyApplication get(Activity activity) {
        return (MyApplication) activity.getApplication();
    }

    @Override
    public void onCreate() {
        super.onCreate();

        applicationComponent = DaggerApplicationComponent.builder().contextModule(new ContextModule(this)).build();
        applicationComponent.injectApplication(this);

    }

    public ApplicationComponent getApplicationComponent() {
        return applicationComponent;
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...