Estoy pasando parámetros desde un recyclerview hacia otra actividad, el problema especifico es que se trae una URL la cual alberga una imagen, la cual estoy pasando a la otra actividad pero tengo problemas para presentarla en la actividad donde se reciben los parámetros traidos desde el recyclerview. se esta utilizando un pequeño servidor para imagen para almacenarlas al traerlas desde el Json.
Clase del RecyclerViewAdapter
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
Context context;
List<GetHotels> getDataAdapter;
ImageLoader imageLoader1;
public RecyclerViewAdapter(List<GetHotels> getDataAdapter, Context context){
super();
this.getDataAdapter = getDataAdapter;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerviewhotel, parent, false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder Viewholder, final int position) {
final GetHotels getDataAdapter1 = getDataAdapter.get(position);
imageLoader1 = ServerImageParseAdapter.getInstance(context).getImageLoader();
imageLoader1.get(getDataAdapter1.getLogo(),
ImageLoader.getImageListener(
Viewholder.networkImageView,//Server Image
R.mipmap.ic_launcher,//Before loading server image the default showing image.
android.R.drawable.ic_dialog_alert //Error image if requested image dose not found on server.
)
);
Viewholder.networkImageView.setImageUrl(getDataAdapter1.getLogo(), imageLoader1);
Viewholder.ImageTitleNameView.setText(getDataAdapter1.getName());
Viewholder.networkImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context,DetailBusinessActivity.class);
intent.putExtra("Logo",getDataAdapter1.getLogo().toString());
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return getDataAdapter.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
public NetworkImageView networkImageView ;
public TextView ImageTitleNameView;
public TextView Phone;
public RatingBar start;
public ViewHolder(View itemView) {
super(itemView);
networkImageView = (NetworkImageView) itemView.findViewById(R.id.VollyNetworkImageView1) ;
ImageTitleNameView = (TextView) itemView.findViewById(R.id.name_h) ;
start = (RatingBar) itemView.findViewById(R.id.MyRating);
}
}
}
Clase ServerImageParseAdapter.
public class ServerImageParseAdapter {
public static ServerImageParseAdapter SIAdapter;
public static Context context1;
public RequestQueue requestQueue1;
public ImageLoader Imageloader1;
public Cache cache1 ;
public Network networkOBJ ;
LruCache<String, Bitmap> LRUCACHE = new LruCache<String, Bitmap>(30);
private ServerImageParseAdapter(Context context) {
this.context1 = context;
this.requestQueue1 = RQ();
Imageloader1 = new ImageLoader(requestQueue1, new ImageLoader.ImageCache() {
@Override
public Bitmap getBitmap(String URL) {
return LRUCACHE.get(URL);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
LRUCACHE.put(url, bitmap);
}
});
}
public ImageLoader getImageLoader() {
return Imageloader1;
}
public static ServerImageParseAdapter getInstance(Context SynchronizedContext) {
if (SIAdapter == null) {
SIAdapter = new ServerImageParseAdapter(SynchronizedContext);
}
return SIAdapter;
}
public RequestQueue RQ() {
if (requestQueue1 == null) {
cache1 = new DiskBasedCache(context1.getCacheDir());
networkOBJ = new BasicNetwork(new HurlStack());
requestQueue1 = new RequestQueue(cache1, networkOBJ);
requestQueue1.start();
}
return requestQueue1;
}
}
La clase donde se reciben los parámetros del RecyclerView
public class DetailBusinessActivity extends AppCompatActivity implements OnMapReadyCallback {
//ImageLoader imageLoader = new ImageLoader(this);
private GoogleMap mMap;
String logo;
String Name = "";
String TypeBusiness = "";
String Adreess = "";
String Phone = "";
String Email = "";
String Web = "";
String lat = "";
String lon = "";
Double latD2, lonD2;
ImageView PhoneL;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_business);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Otain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.mapasRes);
mapFragment.getMapAsync(this);
Intent i = getIntent();
logo = i.getStringExtra("Logo");
Name = i.getStringExtra("Name");
Adreess = i.getStringExtra("Adreess");
TypeBusiness = i.getStringExtra("TypeBusiness");
Phone = i.getStringExtra("Phone");
Email = i.getStringExtra("Email");
Web = i.getStringExtra("Web");
lat = i.getStringExtra("Lat");
lon = i.getStringExtra("Lng");
// Locate the TextViews in singleitemview.xml
TextView txtrank = (TextView) findViewById(R.id.Name);
TextView txtBusieness = (TextView) findViewById(R.id.Busieness);
TextView textAdreess = (TextView) findViewById(R.id.Adreess);
TextView textPhone = (TextView) findViewById(R.id.Phone);
TextView textEmail = (TextView) findViewById(R.id.Email);
TextView textWeb = (TextView) findViewById(R.id.Web);
PhoneL = (ImageView) findViewById(R.id.PhoneL);
PhoneL.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View view) {
Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_DIAL);
intentcall.setData(Uri.parse("tel:" + Phone)); // set the Uri
startActivity(intentcall);
}
});
// Set results to the TextViews
txtrank.setText(Name);
txtBusieness.setText(TypeBusiness);
textAdreess.setText(Adreess);
textPhone.setText(Phone);
textEmail.setText(Email);
textWeb.setText(Web);
// ImageView imgflag = (ImageView) findViewById(R.id.Logo);
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
// imageLoader.DisplayImage(logo, imgflag);
latD2 = Double.parseDouble(lat);
lonD2 = Double.parseDouble(lon);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng Hotels = new LatLng(latD2, lonD2);
mMap.addMarker(new MarkerOptions().position(Hotels).title(Name)
.snippet(Adreess)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(Hotels));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(latD2, lonD2), 12));
mMap.getUiSettings().setZoomControlsEnabled(true);
}
}