[]
I have a list of categories and list of products, going directly to the list of categories and clicking on the Item in RecyclerView
redirects me to the activity where I can edit the category, and follow if it is possible that when adding a new product I want to select the category for this product and to redirect to the list of categories I want to click on the item of RecyclerView redirects me to activity with product, adding Category to the product.
This fragment of my code:
AddProduct-Activity
private void openProdCategory() {
Intent intent = new Intent(AddProduct.this, ProdCatList.class);
startActivityForResult(intent, GET_CATEGORY_REQUEST);
}
CategoryLisy-Activity
if (getIntent().hasExtra(String.valueOf(AddProduct.GET_CATEGORY_REQUEST))) {
prodCatAdapter.setOnItemClickListener(new ProdCatAdapter.OnItemClickListener() {
@Override
public void onItemClick(Prod_Cat prodCat) {
Intent data = new Intent(ProdCatList.this, AddProduct.class);
data.putExtra(EXTRA_PROD_CATID, prodCat.getProdCatId());
data.putExtra(EXTRA_PROD_CATNAME, prodCat.getCategoryName());
setResult(RESULT_OK, data);
finish();
}
});
} else {
prodCatAdapter.setOnItemClickListener(new ProdCatAdapter.OnItemClickListener() {
@Override
public void onItemClick(Prod_Cat prodCat) {
Intent intent = new Intent(ProdCatList.this, AddCatProd.class);
intent.putExtra(AddCatProd.EXTRA_CATID, prodCat.getProdCatId());
intent.putExtra(AddCatProd.EXTRA_CATTITLE, prodCat.getCategoryName());
intent.putExtra(AddCatProd.EXTRA_CATDESCRIPTION, prodCat.getCategoryDescription());
intent.putExtra(AddCatProd.EXTRA_CATPRIOR, String.valueOf(prodCat.getCategoryPriority()));
startActivityForResult(intent, EDIT_CATPROD_REQUEST);
}
});
}