- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 WordPress 博客页面下载博客功能图像,然后稍后加载它们。
现在,每次用户向下和向上滚动时,图像都会一次又一次地加载。任何想法......plzzz ..我尝试了很多解决方案,例如,这个: Preload multiple images with Glide
但是,它没有用。
我正在使用 implementation 'com.github.bumptech.glide:glide:3.7.0'
这是我的代码:
RecyclerViewAdapter
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(imageView);
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
更新我找到这段代码并将其放在其他 Glide 代码之上,但它不起作用:
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.downloadOnly(new SimpleTarget<File>() {
@Override
public void onResourceReady(File resource, GlideAnimation<? super File> glideAnimation) {
}
});
更新:现在我使用了这段代码,它并没有更快地下载图像:
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.downloadOnly(new SimpleTarget<File>() {
@Override
public void onResourceReady(File resource, GlideAnimation<? super File> glideAnimation) {
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(imageView);
}
});
这是完整的ViewAdapter.java
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Model> dataset;
private Context mContext;
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
public static List<WPPost> mListPost;
ArrayList<String> imagepath = new ArrayList<>();
private String baseURL = "https://www.myfitbytes.com/";
public RecyclerViewAdapter(ArrayList<Model> mlist, Context context) {
this.dataset = mlist;
this.mContext = context;
}
public static class ImageTypeViewHolder extends RecyclerView.ViewHolder{
TextView title, subtitle, date;
ImageView imageView;
CardView cardview;
public ImageTypeViewHolder(View itemView) {
super(itemView);
this.title = (TextView) itemView.findViewById(R.id.title);
//this.subtitle = (TextView) itemView.findViewById(R.id.subtitle);
this.date = (TextView) itemView.findViewById(R.id.date);
this.imageView = (ImageView) itemView.findViewById(R.id.Icon);
this.cardview = (CardView) itemView.findViewById(R.id.cardview);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext()).inflate(R.layout.postdetails, parent, false);
return new ImageTypeViewHolder(view) ;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
// Log.d("RecyclerViewAdapter", "IMAGE="+object.Image);
imagepath.add(position, "");
if (Build.VERSION.SDK_INT >= 24)
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY) );
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY) );
}
else
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle ));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title ));
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date ));
}
( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
try {
getthumbnail(object.Image, ( (ImageTypeViewHolder) holder).imageView, position);
}catch (Exception e){
// Log.e("adapter ","failed to get image "+e.toString() );
}
/// dataset.get(position)
}
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, final Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.downloadOnly(new SimpleTarget<File>() {
@Override
public void onResourceReady(File resource, GlideAnimation<? super File> glideAnimation) {
Glide.with(mContext)
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(imageView);
}
});
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
@Override
public int getItemCount() {
return dataset.size() ;
}
}
更新所以,现在我尝试将 glide 3 更新为 4.x,但在 build.gradle 中出现以下错误。
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 27.1.0, 26.1.0. Examples include com.android.support:support-compat:27.1.1 and com.android.support:animated-vector-drawable:27.1.0 less... (⌘F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
代码是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.myfitbytes"
minSdkVersion 14
targetSdkVersion 26
versionCode 3
versionName "3.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
//library for wordpress rest api
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta2'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp:okhttp:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
//implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.3'
implementation 'org.apache.httpcomponents:httpcore:4.4.1'
//implementation 'org.apache.httpcomponents:httpclient:4.5.6'
//implementation group: 'org.apache.httpcomponents' , name: 'httpclient- android' , version: '4.3.5.1'
implementation files('libs/google-http-client-1.24.1.jar')
implementation files('libs/httpclient-4.5.3.jar')
//bottom nav
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
//picasso to download image from url faster
implementation 'com.squareup.picasso:picasso:2.71828'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
而且,这一行是红色的:
implementation 'com.android.support:appcompat-v7:26.1.0'
最佳答案
加载延迟问题和图像项目处置来自 onBindViewHolder
方法,您在该方法中调用了一个网络服务。每次滚动中出现列表项时,都会调用 onBindViewHolder
以使用正确的值初始化 View 。所以你根本不应该在这里调用网络服务(但在代码中每次都会调用)。由于 Glide
创建了一个请求队列,它保证图像只会被下载一次,因为它缓存了它们。此外,它保证在滚动过程中,如果 ImageView
在 RecyclerView
的可见区域中,则图像将被加载。
另一方面,在您的情况下到达图像 url 需要两级网络服务 api-s。所以我们应该结合Glide
过程和检索图像url过程来达到最佳性能。使用 Glide-OkHttp3-Integration库,我开发了这两个级别的异步调用,使 Glide
了解您的数据流。
• 请注意,您应该清理并重建您的项目以在编译时创建GlideApp
类。
ViewAdapter.java
// some code blocks
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
if (Build.VERSION.SDK_INT >= 24) {
// ( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
((ImageTypeViewHolder) holder).title.setText(Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY));
((ImageTypeViewHolder) holder).date.setText(Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY));
} else {
// ((ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle));
((ImageTypeViewHolder) holder).title.setText(Html.fromHtml(object.title));
((ImageTypeViewHolder) holder).date.setText(Html.fromHtml(object.date));
}
((ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
JsonApiGlideUrl url = new JsonApiGlideUrl(object.Image);
GlideApp.with(imageView.getContext())
.load(url)
.into(imageView);
}
// some code blocks
OkHttpAppGlideModule.java
import android.content.Context;
import android.support.annotation.NonNull;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
import java.io.InputStream;
/**
* Registers OkHttp related classes via Glide's annotation processor.
*
* <p>For Applications that depend on this library and include an
* {@link AppGlideModule} and Glide's annotation processor, this class
* will be automatically included.
*/
@GlideModule
public final class OkHttpAppGlideModule extends AppGlideModule {
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
registry.replace(JsonApiGlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
@Override
public boolean isManifestParsingEnabled() {
return false;
}
}
JsonApiGlideUrl.java
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.Headers;
import java.net.URL;
public class JsonApiGlideUrl extends GlideUrl {
public JsonApiGlideUrl(URL url) {
super(url);
}
public JsonApiGlideUrl(String url) {
super(url);
}
public JsonApiGlideUrl(URL url, Headers headers) {
super(url, headers);
}
public JsonApiGlideUrl(String url, Headers headers) {
super(url, headers);
}
}
OkHttpUrlLoader.java
import android.support.annotation.NonNull;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.model.ModelLoaderFactory;
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
import java.io.InputStream;
import okhttp3.Call;
import okhttp3.OkHttpClient;
/**
* A simple model loader for fetching media over http/https using OkHttp.
*/
public class OkHttpUrlLoader implements ModelLoader<JsonApiGlideUrl, InputStream> {
private final Call.Factory client;
// Public API.
@SuppressWarnings("WeakerAccess")
public OkHttpUrlLoader(@NonNull Call.Factory client) {
this.client = client;
}
@Override
public boolean handles(@NonNull JsonApiGlideUrl url) {
return true;
}
@Override
public LoadData<InputStream> buildLoadData(@NonNull JsonApiGlideUrl model, int width, int height, @NonNull Options options) {
return new LoadData<>(model, new OkHttpStreamFetcher(client, model));
}
/**
* The default factory for {@link OkHttpUrlLoader}s.
*/
// Public API.
@SuppressWarnings("WeakerAccess")
public static class Factory implements ModelLoaderFactory<JsonApiGlideUrl, InputStream> {
private static volatile Call.Factory internalClient;
private final Call.Factory client;
private static Call.Factory getInternalClient() {
if (internalClient == null) {
synchronized (Factory.class) {
if (internalClient == null) {
internalClient = new OkHttpClient();
}
}
}
return internalClient;
}
/**
* Constructor for a new Factory that runs requests using a static singleton client.
*/
public Factory() {
this(getInternalClient());
}
/**
* Constructor for a new Factory that runs requests using given client.
*
* @param client this is typically an instance of {@code OkHttpClient}.
*/
public Factory(@NonNull Call.Factory client) {
this.client = client;
}
@NonNull
@Override
public ModelLoader<JsonApiGlideUrl, InputStream> build(@NonNull MultiModelLoaderFactory multiFactory) {
return new OkHttpUrlLoader(client);
}
@Override
public void teardown() {
// Do nothing, this instance doesn't own the client.
}
}
}
OkHttpStreamFetcher.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.HttpException;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
import com.bumptech.glide.util.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/**
* Fetches an {@link InputStream} using the okhttp library.
*/
public class OkHttpStreamFetcher implements DataFetcher<InputStream>, okhttp3.Callback {
private static final String TAG = "OkHttpFetcher";
private final Call.Factory client;
private final JsonApiGlideUrl url;
private OkHttpJsonApiFetcher okHttpJsonApiFetcher;
private InputStream stream;
private ResponseBody responseBody;
private DataCallback<? super InputStream> callback;
// call may be accessed on the main thread while the object is in use on other threads. All other
// accesses to variables may occur on different threads, but only one at a time.
private volatile Call call;
// Public API.
@SuppressWarnings("WeakerAccess")
public OkHttpStreamFetcher(Call.Factory client, JsonApiGlideUrl url) {
this.client = client;
this.url = url;
}
@Override
public void loadData(@NonNull Priority priority, @NonNull final DataCallback<? super InputStream> callback) {
okHttpJsonApiFetcher = new OkHttpJsonApiFetcher(client, url);
okHttpJsonApiFetcher.loadData(new DataCallback<GlideUrl>() {
@Override
public void onDataReady(@Nullable GlideUrl data) {
Request.Builder requestBuilder = new Request.Builder().url(data.toStringUrl());
for (Map.Entry<String, String> headerEntry : data.getHeaders().entrySet()) {
String key = headerEntry.getKey();
requestBuilder.addHeader(key, headerEntry.getValue());
}
Request request = requestBuilder.build();
OkHttpStreamFetcher.this.callback = callback;
call = client.newCall(request);
call.enqueue(OkHttpStreamFetcher.this);
}
@Override
public void onLoadFailed(@NonNull Exception e) {
callback.onLoadFailed(e);
}
});
}
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "OkHttp failed to obtain result", e);
}
callback.onLoadFailed(e);
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
responseBody = response.body();
if (response.isSuccessful()) {
long contentLength = Preconditions.checkNotNull(responseBody).contentLength();
stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
callback.onDataReady(stream);
} else {
callback.onLoadFailed(new HttpException(response.message(), response.code()));
}
}
@Override
public void cleanup() {
okHttpJsonApiFetcher.cleanup();
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
// Ignored
}
if (responseBody != null) {
responseBody.close();
}
callback = null;
}
@Override
public void cancel() {
okHttpJsonApiFetcher.cancel();
Call local = call;
if (local != null) {
local.cancel();
}
}
@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}
@NonNull
@Override
public DataSource getDataSource() {
return DataSource.REMOTE;
}
}
OkHttpJsonApiFetcher.java
import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.load.HttpException;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/**
* Fetches an {@link InputStream} using the okhttp library.
*/
public class OkHttpJsonApiFetcher implements okhttp3.Callback {
private static final String TAG = "OkHttpJsonApiFetcher";
private final Call.Factory client;
private final JsonApiGlideUrl url;
private ResponseBody responseBody;
private DataFetcher.DataCallback<? super GlideUrl> callback;
// call may be accessed on the main thread while the object is in use on other threads. All other
// accesses to variables may occur on different threads, but only one at a time.
private volatile Call call;
// Public API.
@SuppressWarnings("WeakerAccess")
public OkHttpJsonApiFetcher(Call.Factory client, JsonApiGlideUrl url) {
this.client = client;
this.url = url;
}
public void loadData(@NonNull final DataFetcher.DataCallback<? super GlideUrl> callback) {
Request.Builder requestBuilder = new Request.Builder().get().url(url.toStringUrl());
for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
String key = headerEntry.getKey();
requestBuilder.addHeader(key, headerEntry.getValue());
}
Request request = requestBuilder.build();
this.callback = callback;
call = client.newCall(request);
call.enqueue(this);
}
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "OkHttp failed to obtain result", e);
}
callback.onLoadFailed(e);
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
responseBody = response.body();
if (response.isSuccessful() && responseBody != null) {
try {
String json = responseBody.string();
String url = JsonApiDataModel.getSourceUrl(json);
callback.onDataReady(new GlideUrl(url));
} catch (IOException e) {
callback.onLoadFailed(new HttpException(response.message(), response.code()));
e.printStackTrace();
}
} else {
callback.onLoadFailed(new HttpException(response.message(), response.code()));
}
}
public void cleanup() {
if (responseBody != null) {
responseBody.close();
}
callback = null;
}
public void cancel() {
Call local = call;
if (local != null) {
local.cancel();
}
}
}
JsonApiDataModel.java
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
public class JsonApiDataModel {
@SerializedName("media_details")
MediaDetails mediaDetails;
public static String getSourceUrl(String json) {
return new Gson().fromJson(json, JsonApiDataModel.class).mediaDetails.sizes.full.sourceUrl;
}
public class MediaDetails {
@SerializedName("sizes")
Sizes sizes;
}
public class Sizes {
// you can use full, medium or thumbnail here!
@SerializedName("full")
Full full;
}
public class Full {
@SerializedName("source_url")
String sourceUrl;
}
}
import com.aminography.glideapplication.glide.okhttp3.GlideApp;
import com.aminography.glideapplication.glide.okhttp3.JsonApiGlideUrl;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView imageView = findViewById(R.id.imageView);
TextView textView = findViewById(R.id.textView);
String sourceUrl = "https://www.myfitbytes.com/wp-json/wp/v2/media/2811";
textView.setText("JsonApiGlideUrl:\n\n" + sourceUrl);
final JsonApiGlideUrl url = new JsonApiGlideUrl(sourceUrl);
GlideApp.with(MainActivity.this).load(url).into(imageView);
}
}
关于java - 如何使用 Glide 显示带有间接链接/URL 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53161502/
假设我拥有域 mydomain.com,并且我在服务器上有一个 Web 应用程序,网址为 http://99.99.99.99:1234/MyApplication/startpage.somethi
我正在尝试通过以下方式更新已解析的 URL: u, _ := url.Parse(s) if u.Scheme == "" { u.Scheme = "https" } if u.Path =
如何将 www.somesite.com/api(.*) 映射到 www.somesite.com/$1:9000? (我需要将/api 映射到运行 @ 端口 9000 的 Play 框架应用程序)
我有一个资源结构,如航类 > 座位 > 预订,所以预订属于某个航类的某个座位: http://example.com/jdf_3prGPS4/1/jMBDy46PbNc
我想知道以下网址是否有效。 路径中的点,在主机之后: http://www.example.com/v.b.w..com 主机中的点,作为子域的一部分: http://v.b.w..co.manufa
我有两个域 - crmpicco.co.uk 和 ayrshireminis.com - 如果我浏览到: www.crmpicco.co.uk/mini/new我希望能够重定向到 www.ayrshi
我正在尝试使用 URL 重写和应用程序请求路由来重写到外部 URL。我设置了以下规则: 在规则中,“patternToMatch”是我试
我已经安装了带有 SharePoint 和 Url Rewrite 模块的 IIS 7.0。 是以下句子还是我配置错误才能看到这个结果? Url Redirect 可以将 url 重定向到任何内部(在
我想知道,为了获得良好的 SEO,您必须在 URL 中使用自然语言。您知道字符中单词或短语的最大大小吗?例如: www.me.com/this-is-a-really-long-url.htm 我问这
有人知道在 SEO 友好 URL 中使用逗号有什么问题吗?我正在使用一些在其 SEO 友好 URL 中使用大量逗号的软件;但我 100% 肯定我见过一些程序/平台无法正确识别 URL 并在第一个逗号后
我有一个网站,我正在为所有链接使用干净的 URL。我想知道对于简短的基本 URL 与较长的描述性 URL 有何看法。 例如,如果我的网站是关于 Georgia Bulldog 足球新闻的,那么哪个网站
我正在编写一个类似于 tinyurl 的 URL 缩短器,我想知道如何跟踪已经使用我的服务缩短的 URL?例如,tinyurl 为相同的长 URL 生成相同的小 URL,而不管是谁创建的。如
我是 magento 的新手。我正在开发一个模块。为此,我有一些要显示链接的 css 和 js 文件。我目前有类似 的链接 getSkinUrl('module_tryouts/css/jquery.
我想基于 HTTP_URL 重写 URL 以重定向到不同的端口,同时保留其余的 URL 和查询字符串(如果指定)。例如, http://host/john/page.aspx 应该重定向到 http:
我遇到了以下问题: 我的 Grails (2.2.0) 应用程序具有以下 URL 映射: "/api/clientQuote/$labcode/$cliCode/$quoCode"(controlle
我有一个很长的 URL,它不适合 URL 字段。它一直在修剪。该怎么办?有没有办法增加 SharePoint 2010 中的 URL 字段字符限制? 或者解决方法来容纳长 URL。例如,以下 URL
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 9年前关闭。 Improve this que
我们从客户以前的开发人员那里继承了相当多的 Google Apps 脚本项目。 Apps 脚本通过嵌入式小部件部署在 Google 网站 (sites.google.com) 的各个页面上。每当我们需
我正在编写一些文档,但遇到了一些词汇问题: http://www.example.com/en/public/img/logo.gif 被称为“绝对”网址,对吗? ../../public/img/l
我们从客户以前的开发人员那里继承了相当多的 Google Apps 脚本项目。 Apps 脚本通过嵌入式小部件部署在 Google 网站 (sites.google.com) 的各个页面上。每当我们需
我是一名优秀的程序员,十分优秀!