我使用OKHTTP库使Picasso自动缓存照片。我上课。但是当我这样工作时,我看不到毕加索的照片。我通过添加Android Manifest来运行它。 “ android:name.Global”我从中删除了照片。问题是什么 ?对不起,我的英语不好。预先感谢。
我的build.gradle;
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
implementation 'com.squareup.picasso:picasso:2.71828'
我的Global.java
import android.app.Application;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.squareup.picasso.Picasso;
public class Global extends Application {
@Override
public void onCreate() {
super.onCreate();
Picasso picasso = new Picasso.Builder(this)
.downloader(new OkHttp3Downloader(this,Integer.MAX_VALUE))
.build();
picasso.setIndicatorsEnabled(true);
picasso.setLoggingEnabled(true);
Picasso.setSingletonInstance(picasso);
}
}
我的Android MAnifest.xml;
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Global"
我的Java for Picasso;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_promotion, container,
false);
IntroImage01 = (KenBurnsView)view.findViewById(R.id.IntroImage01);
mDatabase.child("IntroImage01").addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String url = dataSnapshot.getValue(String.class);
Picasso.get()
.load(url)
.into(IntroImage01);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
我的代码有效,但是正如我所说,添加全局变量时看不到图片。