Q:

Will having an object of MainActivity in another class cause a memory leak?

I know that having static references in the MainActivity class will cause a memory leak but I have to access an object in MainActivity.
I have a MainActivity object in a RecyclerView ViewHolder class and I get the existing instance of MainActivity by getting the context from a provided view and casting it to MainActivity, could this cause any problems or memory leaks?
Here's what i'm doing:
public class songRecyclerVH extends RecyclerView.ViewHolder implements songRecyclerRowView {

TextView artist;
TextView title;
ImageView albumart;
MainActivity mainActivity;

public songRecyclerVH(final View itemView) {
    super(itemView);

    artist = itemView.findViewById(R.id.artist);
    title = itemView.findViewById(R.id.title);
    albumart = itemView.findViewById(R.id.albumart);
    title.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mainActivity = (MainActivity) view.getContext();
            mainActivity.presenter.onSongClicked((Integer.valueOf(title.getTag().toString())));
        }
    });
}

A:

The code is ok. Context will leak memory when the view is detached from Activity. 
You can simply consider using interface to communicate and avoid memory leak.

