所以我使用ImageGetter来显示JSON博客文章中的图像.我在日志中获取了正确的源,但是当URL达到setBounds时URL会发生变化.有任何想法吗?
码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blog_view);
Intent intent = getIntent();
Uri blogUri = intent.getData();
mPost = blogUri.toString();
mUrl = getIntent().getStringExtra("mUrl");
TextView textView = (TextView) findViewById(R.id.scrollView1);
textView.setText(Html.fromHtml(mPost, imgGetter, null));
}
private ImageGetter imgGetter = new ImageGetter(){
@Override
public Drawable getDrawable(String source){
Drawable drawable = Drawable.createFromPath(source);
try {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}catch (NullPointerException e){
logException(e);
}
return drawable;
}
};
Run Code Online (Sandbox Code Playgroud)
尝试前的"来源"是
http://www.domain.com/images_blog/feature.png
但在捕获中错误是:
无法解码流:
java.io.FileNotFoundException: /http:/www.domain.com/images_blog/feature.png : open failed: ENOENT (No such file or directory)
Run Code Online (Sandbox Code Playgroud) 使用 BLoC 进行 Flutter 新手。基于搜索模板构建,希望在items应用程序加载时加载数据 (),而不是在状态更改时加载。
该方法getCrystals()在搜索意图时返回正确的数据.isEmpty,但如何在应用程序加载时完成呢?
crystal_repo.dart
abstract class CrystalRepo {
Future<BuiltList<Crystal>> getCrystals();
Future<BuiltList<Crystal>> searchCrystal({
@required String query,
int startIndex: 0,
});
}
Run Code Online (Sandbox Code Playgroud)
crystal_repo_impl.dart
class CrystalRepoImpl implements CrystalRepo {
static const _timeoutInMilliseconds = 120000; // 2 minutes
final Map<String, Tuple2<int, CrystalResponse>> _cached = {};
///
final CrystalApi _api;
final Mappers _mappers;
CrystalRepoImpl(this._api, this._mappers);
@override
Future<BuiltList<Crystal>> searchCrystal({
String query,
int startIndex = 0,
}) async {
assert(query != null);
final crystalsResponse = await _api.searchCrystal( …Run Code Online (Sandbox Code Playgroud)