android - Is it possible to store the return from the Glide library for use with a proxy pattern? -


i'm trying build static method return images activity i've set update programatically display details on given item (hills in scotland). plan include image i'm using glide retrieve google maps. it's possible user flicking between different hills, quite resource , data intensive, hoping use proxy pattern call images when needed, , cache seen persist through app lifecycle.

the code i've written far below, main question kind of object glide returning, , possible store hashmap? use of object placeholder until can find should replace with.

i've read glide caches images automatically, i'm wanting write in code offers placeholder image users no data connection, since it's expected application used remotely. i'm not it's possible check glide's cache specific image, i'd end checking cached image wasn't present, , trying download image poor connection, causing issues user (maybe?)

private static hashmap<string, object> munroimagemap = new hashmap<string, object>();  public static void getmunroimage(context context, string munroname, double latitude, double longitude, imageview view) {      object imageobject = munroimagemap.get(munroname);      if (imageobject != null){         //view.setimageresource(object);     } else if (imageobject == null /*&& user has data connection*/) {         string googlestreetviewimage =                 "https://maps.googleapis.com/maps/api/streetview?size=600x300&location=" +                         latitude + ","                         + longitude                         + "&heading=151.78&pitch=-0.76&key="                         + context.getstring(r.string.google_services_api_key);          // if possible, i'd put image hashmap before placing view.         glide.with(context).load(googlestreetviewimage).into(view);     } else {         /*view.setimageresource(placeholder image);*/     } } 

thanks help! , i'm happy told poor solution if there's better way handle this.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -