I am trying to make an application. In my app there is a recycler that contains images, when you click on particualr item it goes to middle activity (that activity gets link to load image(by Picasso) and shows the image), then you can go to the last activity that "does something".
But there is a problem in my back arrow thing:
The Last activity is a child of Middle activity, so when you click on the arrow icon it goes to the Middle Activity. BUT Middle activity is supposed to get data of image (like link to load image from recycler item). So when the arrow on LastActivity is clicked it goes to MiddleActivity but doesn't work properly because doesn't have the essential link of image.
It is my click ItemClickListener in my Adapter for recycler:
//IMPLEMENT CLICK LISTENER
holder.setItemClickListener(new ItemClickListener() {
@Override
public void onItemClick(View v, int pos) {
String getTitle = mMainList.get(pos).getKeyId();
Toast.makeText(v.getContext(),getTitle,Toast.LENGTH_SHORT).show();
//Go to the next Activity
Intent show_more = new Intent(v.getContext(), MiddleActivity.class);
show_more.putExtra("image_link", mMainList.get(pos).getImageLink());
v.getContext().startActivity(show_more);
}
});
It is intent in MiddleActivity that goes to LastActivity
Intent go_to_last = new Intent(MiddleActivity.this, LastActivity.class);
String image_link_push = getIntent().getStringExtra("image_link");
go_to_last.putExtra("image_link_push", image_link_push);//push link further
startActivity(go_to_last);
My thought is that I need to customize the back arrow and send by intent the image link. Procces would be looking like this:
MainAct (send image link by intent) --- MiddleAct (get the link, and send to the next) --- LastAct (get the link,on pressed back arrow send the same link to Middle) link would be dragged through all the activities
I tried to make it by onBackPressed method (in LastActivity) but it does nothing:
image_link_back = getIntent().getStringExtra("image_link_push");
@Override //!!
public void onBackPressed()
{
Intent intent = new Intent(LastActivity.this, MiddleActivity.class);
intent.putExtra("image_link_back", image_link_back);
startActivity(intent);
super.onBackPressed();
finish();
}
Hopefully I have explained my problem correctly.
How can I "customize" the arrow back and solve the problem? I would appreciate you answering me.