我正在使用Glide库从URL加载图像,而URL是从Graph Request(Facebook)获得的。在RecyclerAdapter中使用。当我滚动时,每个ImageView会在不到一秒钟的时间内显示错误的图片,然后进行纠正。这是代码:
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
ImageView main_image = viewHolder.main_image,
getEventCover(position, main_image);
}
private void getEventCover(int position, final ImageView img){
GraphRequest request = GraphRequest.newGraphPathRequest(
AccessToken.getCurrentAccessToken(),
event.get(position).getEventID(),
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
JSONObject data = response.getJSONObject();
try {
JSONObject cover = data.getJSONObject("cover");
String source = cover.getString("source");
Glide.with(fragment)
.load(source)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.centerCrop()
.into(img);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
);
Bundle parameters = new Bundle();
parameters.putString("fields", "cover");
request.setParameters(parameters);
request.executeAsync();
}
Run Code Online (Sandbox Code Playgroud) 因此,我在测试 Google 地图功能时遇到了问题。在我的活动中,我有回调onMapClick(LatLng latlng),其中有显示/隐藏工具栏的方法。现在,我想测试它,但我不知道如何在地图上执行点击。我试着用这个:
onView(withContentDescription("Mapa Google")).perform(click());
Run Code Online (Sandbox Code Playgroud)
和这个:
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject map = device.findObject(new UiSelector()
.descriptionContains("Mapa Google"));
map.click();
Run Code Online (Sandbox Code Playgroud)
但它接缝,它不起作用。你知道我如何测试这种行为吗?