I have a simple Activity with TabLayout, ViewPager and 2 Fragments in it. Here's my Activity:
public class ManagementCompanyOverviewActivity extends BaseActivity implements ManagementCompanyOverviewView {
private ManagementCompanyVPAdapter mVPAdapter;
private TabLayout mTLContent;
private ViewPager mVPContent;
@InjectPresenter
ManagementCompanyPresenter mPresenter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_management_company);
mVPAdapter = new ManagementCompanyVPAdapter(getSupportFragmentManager());
mTLContent = (TabLayout) findViewById(R.id.tl_company_content);
mVPContent = (ViewPager) findViewById(R.id.vp_company_content);
mVPContent.setAdapter(mVPAdapter);
mTLContent.setupWithViewPager(mVPContent);
}
@Override
public void onAboutCompanyInfoReceivedFromServer(AboutCompanyViewModel model) {
}
Activity has a Presenter (I'm using Moxy), Presenter sends request, gets answer, creates JavaObject (view model) and with getViewState()
passes this model to activity. I need to pass this model from Activity to one of my Fragments.
Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_about_company, container, false);
mTVName = (TextView) view.findViewById(R.id.tv_company_name);
mTVDirector = (TextView) view.findViewById(R.id.tv_company_director);
mTVWebsite = (TextView) view.findViewById(R.id.tv_company_website);
mTVEmail = (TextView) view.findViewById(R.id.tv_company_email);
mTVPhone = (TextView) view.findViewById(R.id.tv_company_phone);
mTVSchedule = (TextView) view.findViewById(R.id.tv_company_schedule);
mTVAddress = (TextView) view.findViewById(R.id.tv_company_address);
return view;
}
This fragment has some TextViews to show the info from my model. How to pass this model? If I know it right I should create a listener, but how? I don't completely understand how to work with em.