Hello, I'm learning and I wanted your suggestion, in a simple way at the beginning, of how to make this transition of products to another Activity. The application I'm developing it loads a list of products from a WebService, so in the application it does not have product registration, just reading the available products and in doing this reading the products are already loaded in Firebase, where I also store the clients that can be registered in the application. So when someone is going to create a new application, my idea is that it has three steps. The first is the choice of the customer that will order, then the product or products that will be ordered, and the last screen where all the information (customer, product and product information: total value ...) appears. In the choose products screen, it already loads the Firebase information, using FirebaseUI (maybe not the best way, but so far it worked well with the client and is very fast to load) the function that I use to load the RecyclerView of the products is this:
public void setupRecycler(){
adapter = new FirebaseRecyclerAdapter<Produto, ProdutoHolder>(
Produto.class,
R.layout.recyclerview_items,
ProdutoHolder.class,
ref
) {
@Override
protected void populateViewHolder(final ProdutoHolder viewHolder, final Produto model, final int position) {
viewHolder.setId(model.getId().toUpperCase());
viewHolder.setNome(model.getNome());
viewHolder.setDescricao(model.getDescricao());
viewHolder.setTamanho(model.getTamanho());
viewHolder.setQuantidade(model.getQuantidade());
viewHolder.setValor(model.getValor());
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SystemClock.elapsedRealtime() - lastClickTime < 1500){
viewHolder.itemView.setBackgroundColor(Color.RED);
return;
}
lastClickTime = SystemClock.elapsedRealtime();
viewHolder.itemView.setBackgroundColor(Color.GREEN);
String idProduto = model.getId();
String nomeProduto = model.getNome();
String descricaoProduto = model.getDescricao();
String tamanhoProduto = model.getTamanho();
String quantidadeProduto = model.getQuantidade();
String valorProduto = model.getValor();
}
});
}
};
recyclerView.setAdapter(adapter);
}
Photos of the steps: [REQUEST] [CHOOSE CUSTOMER] [CHOOSE PRODUCT] [ FINAL SCREEN (not yet completed)
This OnClick was used for testing, but it works cool so too, inside the adapter itself it can pick up the product information, but how can I pass all this information to another Activity, and if it is more than one product? I thought about using JSON, I did some tests, but it did not work, I'm pretty sure, since you do not need to change anything, just pass the product information, so maybe an Array already solves it. Well this is my doubt, It has always helped me to ask a question here, so Obrigado.