模拟器正在显示我的图像。但是我的手机不能

时间:2019-06-07 12:44:56

标签: android firebase-realtime-database picasso

我可以在模拟器中看到来自Firebase的图像,但是当我发布到手机上时却看不到手机中的图像。我正在使用 Firebase 实时数据库和Picasso库。我将图片网址存储在数据库中。我使用毕加索显示图片。但是我可以在模拟器中看到图像,看不到手机。我尝试使用“ with”功能,但是代码不允许使用。我怎样才能解决这个问题 ?

public class IngredientsAdapter extends 
RecyclerView.Adapter <IngredientsAdapter.MyViewHolder> {
**Context** mContext;
ArrayList<Ingredients> mIngredientsArrayList;
CustomItemClickListener mListener;
public IngredientsAdapter(Context context, ArrayList<Ingredients> 
ingredientsArrayList, CustomItemClickListener listener) {
    mContext = context;
    mIngredientsArrayList = ingredientsArrayList;
    mListener = listener;
}



   @Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final View view = 
    LayoutInflater.from(mContext).inflate(R.layout.soup_cardview, parent, false);
    final MyViewHolder viewHolder = new MyViewHolder(view);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mListener.onItemClick(view, viewHolder.getAdapterPosition());
        }
    });
    return viewHolder;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {


    holder.soupName.setText(mIngredientsArrayList.get(position).getName());
   Picasso.get().load(mIngredientsArrayList.get(position).getImage()).into(holder.soupImage);
}

**@Override**
public int getItemCount() {
    return mIngredientsArrayList.size();
}

class MyViewHolder extends RecyclerView.ViewHolder {
    TextView soupName;
    ImageView soupImage;
    TextView soupIngredients;
    TextView soupDetail;


    public MyViewHolder(View itemView) {
        super(itemView);
        soupName = itemView.findViewById(R.id.menu_name);
        soupImage=itemView.findViewById(R.id.menu_image);

    }  }

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android{
    compileSdkVersion 28
    defaultConfig {
        applicationId "cd.com.cook"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    } }

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    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'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.support:appcompat-v7:28.0.0'

}
apply plugin:** 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

打开硬件加速后,设备可以渲染最大图像大小。此大小取决于设备。如果位图大于此大小-将不会呈现。

int[] maxSize = new int[1];
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxSize, 0);