【问题标题】:glide does'nt load the picture from storage firebase滑翔不会从存储火力库中加载图片
【发布时间】:2020-05-30 14:33:50
【问题描述】:

Glide 不会从存储 Firebase 中加载图片。

这是我添加的依赖项。

implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.google.firebase:firebase-storage:16.0.4'

这是我使用的函数。

private void getUserInfo(){
    mCustomerDatabase.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if(dataSnapshot.exists() && dataSnapshot.getChildrenCount()>0){
                Map<String, Object> map = (Map<String, Object>) dataSnapshot.getValue();
                if(map.get("name")!=null){
                    mName = map.get("name").toString();
                    mNameField.setText(mName);
                }
                if(map.get("phone")!=null){
                    mPhone = map.get("phone").toString();
                    mPhoneField.setText(mPhone);
                }
                if(map.get("profileImageUrl")!=null){
                    mProfileImageUrl = map.get("profileImageUrl").toString();
                    Glide.with(getApplication()).load(mProfileImageUrl).into(mProfileImage);
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}

注意:在我将 Gradle 列表升级到 androidx 之前它运行良好

注册前

注册后

【问题讨论】:

标签: java android firebase firebase-storage android-glide


【解决方案1】:

我不确定您是否可以在更新到androidx 之前下载个人资料图片。看起来您拥有的图像是该ImageView 的默认图像。

我实际上会建议以下内容。

  1. 检查您的AndroidManifest.xml 中是否有INTERNET 权限。

    <uses-permission android:name="android.permission.INTERNET" /> 
    
  2. 当您尝试使用 Glide 加载图像时,请使用以下内容添加占位符图像。

    Glide.with(getApplication())
         .load(mProfileImageUrl)
         .apply(new RequestOptions()
             .placeholder(R.drawable.default_person)
             .fitCenter())
         .into(mProfileImage);
    

【讨论】:

  • 我在下面的 Glide 版本中有它 - implementation 'com.github.bumptech.glide:glide:4.6.1'
猜你喜欢
  • 2018-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
  • 2017-07-12
相关资源
最近更新 更多