【发布时间】:2016-06-26 08:05:54
【问题描述】:
Android Studio 2.1.2
我收到此警告,但我似乎找不到原因。我没有使用任何原始类型。
Unchecked call to attachView(DownloadViewContract) as a member of raw type
我有如下界面
public interface DownloadPresenterContract {
interface Operations<DownloadViewContract> {
void attachView(DownloadViewContract view);
void detachView();
void getData();
}
}
以及下面的实现
public class DownloadPresenterImp implements
DownloadPresenterContract.Operations<DownloadViewContract> {
private DownloadViewContract mView;
private DownloadPresenterImp() {
}
public static DownloadPresenterImp getNewInstance() {
return new DownloadPresenterImp();
}
/* Operations */
@Override
public void attachView(DownloadViewContract view) {
mView = view;
}
}
这是我的视图界面
public interface DownloadViewContract {
void onSuccessDownload();
void onFailureDownload(String errMsg);
}
在我的片段中,这是我的观点
public class DownloadView extends Fragment implements DownloadViewContract {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
mDownloadPresenterContract = DownloadPresenterImp.getNewInstance();
/* UNCHECKED MEMBER TO RAW TYPE */
mDownloadPresenterContract.attachView(DownloadView.this);
}
.....
}
我不明白为什么我会收到警告,因为我明确地将 DownloadViewContract 命名为演示者界面中的类型。而且由于我的视图实现了DownloadViewContract 接口,我认为应该没有任何问题。
非常感谢您的任何建议,
【问题讨论】:
-
可以出示
mDownloadPresenterContract的声明吗? -
DownloadPresenterContract 在我的问题中已经存在。公共接口 DownloadPresenterContract { interface Operations
{ void attachView(DownloadViewContract view);无效分离视图();无效的getData(); } }