How do I use an image which is stored in Firebase Storage?Using Glide to load a Placeholder from URL to display while loading a GIF (Android)How to save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Lazy load of images in ListViewWhy is the Android emulator so slow? How can we speed up the Android emulator?How to interact with listview itemsHow do I fix 'android.os.NetworkOnMainThreadException'?How to store and view images on firebase?Saving ToggleButton state in ListView by using SharedPreferencesUndo/Redo not working in android Canvasandroid.content.res.Resources$NotFoundException: in setImageResource
Why does it seem the best way to make a living is to invest in real estate?
Looking for circuit board material that can be dissolved
Is there anything on the ISS that would be destroyed if that object were returned to Earth?
Giving a good fancy look to a simple table
What is the difference between increasing volume and increasing gain?
Why not add cuspidal curves in the moduli space of stable curves?
Airport Security - advanced check, 4th amendment breach
What action is recommended if your accommodation refuses to let you leave without paying additional fees?
Bothered by watching coworkers slacking off
Missing quartile in boxplot
What's the correct way to determine turn order in this situation?
Duck, duck, gone!
Sending mail to the Professor for PhD, after seeing his tweet
Why do popular TCP-using services have UDP as well as TCP entries in /etc/services?
Manager told a colleague of mine I was getting fired soon
Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?
How to identify whether a publisher is genuine or not?
Should I be an author on another PhD student's paper if I went to their meetings and gave advice?
Drawing Maps; flat distortion
Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails
Is the "spacetime" the same thing as the mathematical 4th dimension?
As a team leader is it appropriate to bring in fundraiser candy?
Everyone Gets a Window Seat
How dangerous is a very out-of-true disc brake wheel?
How do I use an image which is stored in Firebase Storage?
Using Glide to load a Placeholder from URL to display while loading a GIF (Android)How to save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Lazy load of images in ListViewWhy is the Android emulator so slow? How can we speed up the Android emulator?How to interact with listview itemsHow do I fix 'android.os.NetworkOnMainThreadException'?How to store and view images on firebase?Saving ToggleButton state in ListView by using SharedPreferencesUndo/Redo not working in android Canvasandroid.content.res.Resources$NotFoundException: in setImageResource
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I'm building an app which allows the user to upload their own images, to use within the app. I'm using the Firebase Cloudstore database to store the information on each image, and Firebase Storage to store the actual images.
So, the images are stored in Firebase Storage in a folder called images; within that, they are given a randomly generated name, which is stored in the appropriate record in the database. Let's say the name of a particular image is "abcd.png", then the database record will look like this:
symbols
> key1 > name: "Test symbol"
uid: "User's randomly generated ID"
description: "A description, as set by the user"
url: "images/abcd.png"
Now, I want to show all the User's uploaded images as tiny thumbnails. I'm connecting to the database, finding all symbols which belong to the current user, and then using an ArrayAdapter to display them. Unfortunately, I'm currently getting a row of blank boxes. I'm not sure what I'm doing wrong.
The symbols are shown in a Fragment called CurrentSymbolsFragment. The layout (fragment_current_symbols.xml) is:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview_symbolList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
</GridView>
</android.support.constraint.ConstraintLayout>
and the class file is:
public class FragmentCurrentSymbols extends Fragment {
private ArrayList<ChartSymbol> mSymbols;
private Context mContext;
private GridView mGridCurrentSymbols;
static public FragmentCurrentSymbols newInstance(Context context,
ArrayList<ChartSymbol> symbols)
if(context == null) return null;
if(symbols == null) return null;
if(symbols.size() == 0) return null;
FragmentCurrentSymbols f = new FragmentCurrentSymbols();
f.setRequiredData(context, symbols);
return f;
public void setRequiredData(Context context, ArrayList<ChartSymbol> symbols)
if(context == null) return;
if(symbols == null) return;
if(symbols.size() == 0) return;
this.mContext = context;
this.mSymbols = symbols;
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState)
// Inflate layout
View rootView = inflater.inflate(R.layout.fragment_current_symbols, container, false);
mGridCurrentSymbols = rootView.findViewById(R.id.gridview_symbolList)
initialiseWithSymbols();
return rootView;
// Set symbols to be shown and initialise the view
public void setSymbols(ArrayList<ChartSymbol> symbols)
mSymbols = symbols;
initialiseWithSymbols();
/**
* initialiseWithSymbols
* Initialise the symbol list from the symbols
* This takes the symbols and shows them, in order, in the grid
**/
public void initialiseWithSymbols()
if (mSymbols == null) return;
// Now set up ChartSymbolAdapter to display symbols in grid
ChartSymbolAdapter mSymbolAdapter = new ChartSymbolAdapter(mContext,
R.layout.adapter_symbol_manage_layout,
mSymbols);
mGridCurrentSymbols.setAdapter(mSymbolAdapter);
mGridCurrentSymbols.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
The ChartSymbolAdapter
class is:
public class ChartSymbolAdapter extends ArrayAdapter<ChartSymbol>
private Context mContext;
private ArrayList<ChartSymbol> mSymbolArray;
private int layoutId;
private ChartSymbol selectedSymbol;
public ChartSymbolAdapter(Context context, int layout_id, ArrayList<ChartSymbol> symbolArray)
super(context, layout_id, symbolArray);
this.mContext=context;
this.mSymbolArray=symbolArray;
this.layoutId = layout_id;
private static class ViewHolder
private SymbolCell symbolCell;
private TextView symbolName, symbolKey;
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent)
ViewHolder mViewHolder;
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
if(convertView == null)
mViewHolder = new ViewHolder();
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
convertView = layoutInflater.inflate(layoutId, parent, false);
mViewHolder.symbolCell = convertView.findViewById(R.id.symbol_cell);
mViewHolder.symbolName = convertView.findViewById(R.id.symbol_name);
mViewHolder.symbolKey = convertView.findViewById(R.id.symbol_key);
convertView.setTag(mViewHolder);
// Now add the symbol
ChartSymbol cellSymbol = mSymbolArray.get(position);
// Find the url
String drawableUrl = cellSymbol.getUrl();
// If there's a Url, use it
if(drawableUrl != null)
Glide.with(getContext())
.load(drawableUrl)
.into(mViewHolder.symbolCell);
return convertView;
The SymbolCell
class extends ImageView
:
public class SymbolCell extends android.support.v7.widget.AppCompatImageView
ChartSymbol symbol;
Paint paint;
public SymbolCell(Context thisContext, AttributeSet attrs)
super(thisContext, attrs);
paint = new Paint();
/**
* onDraw
* Draw a square to contain the given symbol.
* @param canvas Canvas to draw on
*/
protected void onDraw(Canvas canvas)
// Draw a box around cell
// Set paint
int stroke_width = 2;
paint.setStrokeWidth(stroke_width);
float height = getHeight();
float width = getWidth();
// Draw a black border for item
paint.setColor(0xff000000);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(0, 0, width - 2*stroke_width, height - 2*stroke_width, paint);
When I try this out, I get a series of blank boxes. There are as many boxes as I have symbols stored, so that's correct, but they're not showing the actual image. I've made sure that I'm using images which have colours going right to the edges, so that's not the issue.
This is the first time I've used Glide in a project, so am I doing something wrong there?
Using the debugger, I can see that the symbols are retrieved correctly from Firestore, and that the URL is correct. I'm not sure how to check whether Glide is actually connecting to the storage to find the image, but it's certainly not showing it.
Can anyone see where I'm going wrong?
android firebase google-cloud-functions firebase-storage android-glide
add a comment
|
I'm building an app which allows the user to upload their own images, to use within the app. I'm using the Firebase Cloudstore database to store the information on each image, and Firebase Storage to store the actual images.
So, the images are stored in Firebase Storage in a folder called images; within that, they are given a randomly generated name, which is stored in the appropriate record in the database. Let's say the name of a particular image is "abcd.png", then the database record will look like this:
symbols
> key1 > name: "Test symbol"
uid: "User's randomly generated ID"
description: "A description, as set by the user"
url: "images/abcd.png"
Now, I want to show all the User's uploaded images as tiny thumbnails. I'm connecting to the database, finding all symbols which belong to the current user, and then using an ArrayAdapter to display them. Unfortunately, I'm currently getting a row of blank boxes. I'm not sure what I'm doing wrong.
The symbols are shown in a Fragment called CurrentSymbolsFragment. The layout (fragment_current_symbols.xml) is:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview_symbolList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
</GridView>
</android.support.constraint.ConstraintLayout>
and the class file is:
public class FragmentCurrentSymbols extends Fragment {
private ArrayList<ChartSymbol> mSymbols;
private Context mContext;
private GridView mGridCurrentSymbols;
static public FragmentCurrentSymbols newInstance(Context context,
ArrayList<ChartSymbol> symbols)
if(context == null) return null;
if(symbols == null) return null;
if(symbols.size() == 0) return null;
FragmentCurrentSymbols f = new FragmentCurrentSymbols();
f.setRequiredData(context, symbols);
return f;
public void setRequiredData(Context context, ArrayList<ChartSymbol> symbols)
if(context == null) return;
if(symbols == null) return;
if(symbols.size() == 0) return;
this.mContext = context;
this.mSymbols = symbols;
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState)
// Inflate layout
View rootView = inflater.inflate(R.layout.fragment_current_symbols, container, false);
mGridCurrentSymbols = rootView.findViewById(R.id.gridview_symbolList)
initialiseWithSymbols();
return rootView;
// Set symbols to be shown and initialise the view
public void setSymbols(ArrayList<ChartSymbol> symbols)
mSymbols = symbols;
initialiseWithSymbols();
/**
* initialiseWithSymbols
* Initialise the symbol list from the symbols
* This takes the symbols and shows them, in order, in the grid
**/
public void initialiseWithSymbols()
if (mSymbols == null) return;
// Now set up ChartSymbolAdapter to display symbols in grid
ChartSymbolAdapter mSymbolAdapter = new ChartSymbolAdapter(mContext,
R.layout.adapter_symbol_manage_layout,
mSymbols);
mGridCurrentSymbols.setAdapter(mSymbolAdapter);
mGridCurrentSymbols.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
The ChartSymbolAdapter
class is:
public class ChartSymbolAdapter extends ArrayAdapter<ChartSymbol>
private Context mContext;
private ArrayList<ChartSymbol> mSymbolArray;
private int layoutId;
private ChartSymbol selectedSymbol;
public ChartSymbolAdapter(Context context, int layout_id, ArrayList<ChartSymbol> symbolArray)
super(context, layout_id, symbolArray);
this.mContext=context;
this.mSymbolArray=symbolArray;
this.layoutId = layout_id;
private static class ViewHolder
private SymbolCell symbolCell;
private TextView symbolName, symbolKey;
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent)
ViewHolder mViewHolder;
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
if(convertView == null)
mViewHolder = new ViewHolder();
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
convertView = layoutInflater.inflate(layoutId, parent, false);
mViewHolder.symbolCell = convertView.findViewById(R.id.symbol_cell);
mViewHolder.symbolName = convertView.findViewById(R.id.symbol_name);
mViewHolder.symbolKey = convertView.findViewById(R.id.symbol_key);
convertView.setTag(mViewHolder);
// Now add the symbol
ChartSymbol cellSymbol = mSymbolArray.get(position);
// Find the url
String drawableUrl = cellSymbol.getUrl();
// If there's a Url, use it
if(drawableUrl != null)
Glide.with(getContext())
.load(drawableUrl)
.into(mViewHolder.symbolCell);
return convertView;
The SymbolCell
class extends ImageView
:
public class SymbolCell extends android.support.v7.widget.AppCompatImageView
ChartSymbol symbol;
Paint paint;
public SymbolCell(Context thisContext, AttributeSet attrs)
super(thisContext, attrs);
paint = new Paint();
/**
* onDraw
* Draw a square to contain the given symbol.
* @param canvas Canvas to draw on
*/
protected void onDraw(Canvas canvas)
// Draw a box around cell
// Set paint
int stroke_width = 2;
paint.setStrokeWidth(stroke_width);
float height = getHeight();
float width = getWidth();
// Draw a black border for item
paint.setColor(0xff000000);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(0, 0, width - 2*stroke_width, height - 2*stroke_width, paint);
When I try this out, I get a series of blank boxes. There are as many boxes as I have symbols stored, so that's correct, but they're not showing the actual image. I've made sure that I'm using images which have colours going right to the edges, so that's not the issue.
This is the first time I've used Glide in a project, so am I doing something wrong there?
Using the debugger, I can see that the symbols are retrieved correctly from Firestore, and that the URL is correct. I'm not sure how to check whether Glide is actually connecting to the storage to find the image, but it's certainly not showing it.
Can anyone see where I'm going wrong?
android firebase google-cloud-functions firebase-storage android-glide
1
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
2
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47
add a comment
|
I'm building an app which allows the user to upload their own images, to use within the app. I'm using the Firebase Cloudstore database to store the information on each image, and Firebase Storage to store the actual images.
So, the images are stored in Firebase Storage in a folder called images; within that, they are given a randomly generated name, which is stored in the appropriate record in the database. Let's say the name of a particular image is "abcd.png", then the database record will look like this:
symbols
> key1 > name: "Test symbol"
uid: "User's randomly generated ID"
description: "A description, as set by the user"
url: "images/abcd.png"
Now, I want to show all the User's uploaded images as tiny thumbnails. I'm connecting to the database, finding all symbols which belong to the current user, and then using an ArrayAdapter to display them. Unfortunately, I'm currently getting a row of blank boxes. I'm not sure what I'm doing wrong.
The symbols are shown in a Fragment called CurrentSymbolsFragment. The layout (fragment_current_symbols.xml) is:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview_symbolList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
</GridView>
</android.support.constraint.ConstraintLayout>
and the class file is:
public class FragmentCurrentSymbols extends Fragment {
private ArrayList<ChartSymbol> mSymbols;
private Context mContext;
private GridView mGridCurrentSymbols;
static public FragmentCurrentSymbols newInstance(Context context,
ArrayList<ChartSymbol> symbols)
if(context == null) return null;
if(symbols == null) return null;
if(symbols.size() == 0) return null;
FragmentCurrentSymbols f = new FragmentCurrentSymbols();
f.setRequiredData(context, symbols);
return f;
public void setRequiredData(Context context, ArrayList<ChartSymbol> symbols)
if(context == null) return;
if(symbols == null) return;
if(symbols.size() == 0) return;
this.mContext = context;
this.mSymbols = symbols;
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState)
// Inflate layout
View rootView = inflater.inflate(R.layout.fragment_current_symbols, container, false);
mGridCurrentSymbols = rootView.findViewById(R.id.gridview_symbolList)
initialiseWithSymbols();
return rootView;
// Set symbols to be shown and initialise the view
public void setSymbols(ArrayList<ChartSymbol> symbols)
mSymbols = symbols;
initialiseWithSymbols();
/**
* initialiseWithSymbols
* Initialise the symbol list from the symbols
* This takes the symbols and shows them, in order, in the grid
**/
public void initialiseWithSymbols()
if (mSymbols == null) return;
// Now set up ChartSymbolAdapter to display symbols in grid
ChartSymbolAdapter mSymbolAdapter = new ChartSymbolAdapter(mContext,
R.layout.adapter_symbol_manage_layout,
mSymbols);
mGridCurrentSymbols.setAdapter(mSymbolAdapter);
mGridCurrentSymbols.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
The ChartSymbolAdapter
class is:
public class ChartSymbolAdapter extends ArrayAdapter<ChartSymbol>
private Context mContext;
private ArrayList<ChartSymbol> mSymbolArray;
private int layoutId;
private ChartSymbol selectedSymbol;
public ChartSymbolAdapter(Context context, int layout_id, ArrayList<ChartSymbol> symbolArray)
super(context, layout_id, symbolArray);
this.mContext=context;
this.mSymbolArray=symbolArray;
this.layoutId = layout_id;
private static class ViewHolder
private SymbolCell symbolCell;
private TextView symbolName, symbolKey;
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent)
ViewHolder mViewHolder;
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
if(convertView == null)
mViewHolder = new ViewHolder();
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
convertView = layoutInflater.inflate(layoutId, parent, false);
mViewHolder.symbolCell = convertView.findViewById(R.id.symbol_cell);
mViewHolder.symbolName = convertView.findViewById(R.id.symbol_name);
mViewHolder.symbolKey = convertView.findViewById(R.id.symbol_key);
convertView.setTag(mViewHolder);
// Now add the symbol
ChartSymbol cellSymbol = mSymbolArray.get(position);
// Find the url
String drawableUrl = cellSymbol.getUrl();
// If there's a Url, use it
if(drawableUrl != null)
Glide.with(getContext())
.load(drawableUrl)
.into(mViewHolder.symbolCell);
return convertView;
The SymbolCell
class extends ImageView
:
public class SymbolCell extends android.support.v7.widget.AppCompatImageView
ChartSymbol symbol;
Paint paint;
public SymbolCell(Context thisContext, AttributeSet attrs)
super(thisContext, attrs);
paint = new Paint();
/**
* onDraw
* Draw a square to contain the given symbol.
* @param canvas Canvas to draw on
*/
protected void onDraw(Canvas canvas)
// Draw a box around cell
// Set paint
int stroke_width = 2;
paint.setStrokeWidth(stroke_width);
float height = getHeight();
float width = getWidth();
// Draw a black border for item
paint.setColor(0xff000000);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(0, 0, width - 2*stroke_width, height - 2*stroke_width, paint);
When I try this out, I get a series of blank boxes. There are as many boxes as I have symbols stored, so that's correct, but they're not showing the actual image. I've made sure that I'm using images which have colours going right to the edges, so that's not the issue.
This is the first time I've used Glide in a project, so am I doing something wrong there?
Using the debugger, I can see that the symbols are retrieved correctly from Firestore, and that the URL is correct. I'm not sure how to check whether Glide is actually connecting to the storage to find the image, but it's certainly not showing it.
Can anyone see where I'm going wrong?
android firebase google-cloud-functions firebase-storage android-glide
I'm building an app which allows the user to upload their own images, to use within the app. I'm using the Firebase Cloudstore database to store the information on each image, and Firebase Storage to store the actual images.
So, the images are stored in Firebase Storage in a folder called images; within that, they are given a randomly generated name, which is stored in the appropriate record in the database. Let's say the name of a particular image is "abcd.png", then the database record will look like this:
symbols
> key1 > name: "Test symbol"
uid: "User's randomly generated ID"
description: "A description, as set by the user"
url: "images/abcd.png"
Now, I want to show all the User's uploaded images as tiny thumbnails. I'm connecting to the database, finding all symbols which belong to the current user, and then using an ArrayAdapter to display them. Unfortunately, I'm currently getting a row of blank boxes. I'm not sure what I'm doing wrong.
The symbols are shown in a Fragment called CurrentSymbolsFragment. The layout (fragment_current_symbols.xml) is:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview_symbolList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
</GridView>
</android.support.constraint.ConstraintLayout>
and the class file is:
public class FragmentCurrentSymbols extends Fragment {
private ArrayList<ChartSymbol> mSymbols;
private Context mContext;
private GridView mGridCurrentSymbols;
static public FragmentCurrentSymbols newInstance(Context context,
ArrayList<ChartSymbol> symbols)
if(context == null) return null;
if(symbols == null) return null;
if(symbols.size() == 0) return null;
FragmentCurrentSymbols f = new FragmentCurrentSymbols();
f.setRequiredData(context, symbols);
return f;
public void setRequiredData(Context context, ArrayList<ChartSymbol> symbols)
if(context == null) return;
if(symbols == null) return;
if(symbols.size() == 0) return;
this.mContext = context;
this.mSymbols = symbols;
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState)
// Inflate layout
View rootView = inflater.inflate(R.layout.fragment_current_symbols, container, false);
mGridCurrentSymbols = rootView.findViewById(R.id.gridview_symbolList)
initialiseWithSymbols();
return rootView;
// Set symbols to be shown and initialise the view
public void setSymbols(ArrayList<ChartSymbol> symbols)
mSymbols = symbols;
initialiseWithSymbols();
/**
* initialiseWithSymbols
* Initialise the symbol list from the symbols
* This takes the symbols and shows them, in order, in the grid
**/
public void initialiseWithSymbols()
if (mSymbols == null) return;
// Now set up ChartSymbolAdapter to display symbols in grid
ChartSymbolAdapter mSymbolAdapter = new ChartSymbolAdapter(mContext,
R.layout.adapter_symbol_manage_layout,
mSymbols);
mGridCurrentSymbols.setAdapter(mSymbolAdapter);
mGridCurrentSymbols.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
The ChartSymbolAdapter
class is:
public class ChartSymbolAdapter extends ArrayAdapter<ChartSymbol>
private Context mContext;
private ArrayList<ChartSymbol> mSymbolArray;
private int layoutId;
private ChartSymbol selectedSymbol;
public ChartSymbolAdapter(Context context, int layout_id, ArrayList<ChartSymbol> symbolArray)
super(context, layout_id, symbolArray);
this.mContext=context;
this.mSymbolArray=symbolArray;
this.layoutId = layout_id;
private static class ViewHolder
private SymbolCell symbolCell;
private TextView symbolName, symbolKey;
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent)
ViewHolder mViewHolder;
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
if(convertView == null)
mViewHolder = new ViewHolder();
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
convertView = layoutInflater.inflate(layoutId, parent, false);
mViewHolder.symbolCell = convertView.findViewById(R.id.symbol_cell);
mViewHolder.symbolName = convertView.findViewById(R.id.symbol_name);
mViewHolder.symbolKey = convertView.findViewById(R.id.symbol_key);
convertView.setTag(mViewHolder);
// Now add the symbol
ChartSymbol cellSymbol = mSymbolArray.get(position);
// Find the url
String drawableUrl = cellSymbol.getUrl();
// If there's a Url, use it
if(drawableUrl != null)
Glide.with(getContext())
.load(drawableUrl)
.into(mViewHolder.symbolCell);
return convertView;
The SymbolCell
class extends ImageView
:
public class SymbolCell extends android.support.v7.widget.AppCompatImageView
ChartSymbol symbol;
Paint paint;
public SymbolCell(Context thisContext, AttributeSet attrs)
super(thisContext, attrs);
paint = new Paint();
/**
* onDraw
* Draw a square to contain the given symbol.
* @param canvas Canvas to draw on
*/
protected void onDraw(Canvas canvas)
// Draw a box around cell
// Set paint
int stroke_width = 2;
paint.setStrokeWidth(stroke_width);
float height = getHeight();
float width = getWidth();
// Draw a black border for item
paint.setColor(0xff000000);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(0, 0, width - 2*stroke_width, height - 2*stroke_width, paint);
When I try this out, I get a series of blank boxes. There are as many boxes as I have symbols stored, so that's correct, but they're not showing the actual image. I've made sure that I'm using images which have colours going right to the edges, so that's not the issue.
This is the first time I've used Glide in a project, so am I doing something wrong there?
Using the debugger, I can see that the symbols are retrieved correctly from Firestore, and that the URL is correct. I'm not sure how to check whether Glide is actually connecting to the storage to find the image, but it's certainly not showing it.
Can anyone see where I'm going wrong?
android firebase google-cloud-functions firebase-storage android-glide
android firebase google-cloud-functions firebase-storage android-glide
edited May 20 at 19:21
halfer
15.3k7 gold badges63 silver badges129 bronze badges
15.3k7 gold badges63 silver badges129 bronze badges
asked Mar 28 at 20:52
SharonSharon
9236 gold badges28 silver badges53 bronze badges
9236 gold badges28 silver badges53 bronze badges
1
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
2
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47
add a comment
|
1
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
2
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47
1
1
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
2
2
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406683%2fhow-do-i-use-an-image-which-is-stored-in-firebase-storage%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406683%2fhow-do-i-use-an-image-which-is-stored-in-firebase-storage%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
probably related: stackoverflow.com/a/46020245/549372
– Martin Zeitler
Mar 28 at 20:59
2
Is the url valid? "images/abcd.png" does not seem like a valid url.
– bensadiku
Mar 28 at 21:13
Thanks, Martin, I tried making changes according to that link, but I'm still getting blank squares.
– Sharon
Mar 29 at 12:45
bensadiku, good point! I've replaced that with a url which directly leads to an image (by setting drawableUrl = "schindlersfabrics.com/images/…" (just to eliminate that as a potential problem)), but it hasn't helped.
– Sharon
Mar 29 at 12:47