Search in sources :

Example 1 with StatefulView

use of m.co.rh.id.anavigator.StatefulView in project a-medic-log by rh-id.

the class SettingsPage method dispose.

@Override
public void dispose(Activity activity) {
    super.dispose(activity);
    if (mStatefulViews != null && !mStatefulViews.isEmpty()) {
        for (StatefulView statefulView : mStatefulViews) {
            statefulView.dispose(activity);
        }
        mStatefulViews.clear();
        mStatefulViews = null;
    }
}
Also used : StatefulView(m.co.rh.id.anavigator.StatefulView)

Example 2 with StatefulView

use of m.co.rh.id.anavigator.StatefulView in project a-medic-log by rh-id.

the class AppProviderModule method getNavigator.

@SuppressWarnings({ "rawtypes", "unchecked" })
private Navigator getNavigator(Provider provider) {
    Map<String, StatefulViewFactory<Activity, StatefulView<Activity>>> navMap = new HashMap<>();
    navMap.put(Routes.HOME_PAGE, (args, activity) -> {
        if (args instanceof StatefulView) {
            return (StatefulView) args;
        }
        return new SplashPage();
    });
    navMap.put(Routes.SETTINGS_PAGE, (args, activity) -> new SettingsPage());
    navMap.put(Routes.DONATIONS_PAGE, (args, activity) -> new DonationsPage());
    navMap.put(Routes.PROFILES_PAGE, (args, activity) -> new ProfileListPage());
    navMap.put(Routes.PROFILE_SELECT_DIALOG, (args, activity) -> new ProfileSelectSVDialog());
    navMap.put(Routes.PROFILE_DETAIL_PAGE, (args, activity) -> new ProfileDetailPage());
    navMap.put(Routes.NOTES_PAGE, (args, activity) -> new NoteListPage());
    navMap.put(Routes.NOTE_DETAIL_PAGE, (args, activity) -> new NoteDetailPage());
    navMap.put(Routes.NOTE_TAG_DETAIL_DIALOG, (args, activity) -> new NoteTagDetailSVDialog());
    navMap.put(Routes.NOTE_ATTACHMENT_DETAIL_PAGE, (args, activity) -> new NoteAttachmentDetailPage());
    navMap.put(Routes.MEDICINE_DETAIL_PAGE, (args, activity) -> new MedicineDetailPage());
    navMap.put(Routes.MEDICINE_REMINDER_DETAIL_PAGE, (args, activity) -> new MedicineReminderDetailPage());
    navMap.put(Routes.MEDICINE_INTAKES_PAGE, (args, activity) -> new MedicineIntakeListPage());
    navMap.put(Routes.MEDICINE_INTAKE_DETAIL_PAGE, (args, activity) -> new MedicineIntakeDetailPage());
    navMap.put(Routes.COMMON_CREATE_FILE_DIALOG, (args, activity) -> new CreateFileSVDialog());
    navMap.put(Routes.COMMON_IMAGEVIEW, (args, activity) -> new ImageViewPage());
    navMap.putAll(provider.get(NavExtDialogConfig.class).getNavMap());
    NavConfiguration.Builder<Activity, StatefulView> navBuilder = new NavConfiguration.Builder(Routes.HOME_PAGE, navMap);
    navBuilder.setSaveStateFile(new File(mApplication.getCacheDir(), "anavigator/Navigator.state"));
    navBuilder.setRequiredComponent(provider);
    NavConfiguration<Activity, StatefulView> navConfiguration = navBuilder.build();
    Navigator navigator = new Navigator(MainActivity.class, navConfiguration);
    mNavigator = navigator;
    mApplication.registerActivityLifecycleCallbacks(navigator);
    mApplication.registerComponentCallbacks(navigator);
    return navigator;
}
Also used : HashMap(java.util.HashMap) MedicineDetailPage(m.co.rh.id.a_medic_log.app.ui.page.MedicineDetailPage) MainActivity(m.co.rh.id.a_medic_log.app.MainActivity) Activity(android.app.Activity) StatefulViewFactory(m.co.rh.id.anavigator.component.StatefulViewFactory) NoteTagDetailSVDialog(m.co.rh.id.a_medic_log.app.ui.page.NoteTagDetailSVDialog) SettingsPage(m.co.rh.id.a_medic_log.app.ui.page.SettingsPage) NavConfiguration(m.co.rh.id.anavigator.NavConfiguration) StatefulView(m.co.rh.id.anavigator.StatefulView) NoteDetailPage(m.co.rh.id.a_medic_log.app.ui.page.NoteDetailPage) ProfileSelectSVDialog(m.co.rh.id.a_medic_log.app.ui.page.ProfileSelectSVDialog) NoteListPage(m.co.rh.id.a_medic_log.app.ui.page.NoteListPage) MedicineIntakeListPage(m.co.rh.id.a_medic_log.app.ui.page.MedicineIntakeListPage) INavigator(m.co.rh.id.anavigator.component.INavigator) Navigator(m.co.rh.id.anavigator.Navigator) NoteAttachmentDetailPage(m.co.rh.id.a_medic_log.app.ui.page.NoteAttachmentDetailPage) ProfileDetailPage(m.co.rh.id.a_medic_log.app.ui.page.ProfileDetailPage) CreateFileSVDialog(m.co.rh.id.a_medic_log.app.ui.page.common.CreateFileSVDialog) SplashPage(m.co.rh.id.a_medic_log.app.ui.page.SplashPage) MedicineReminderDetailPage(m.co.rh.id.a_medic_log.app.ui.page.MedicineReminderDetailPage) ProfileListPage(m.co.rh.id.a_medic_log.app.ui.page.ProfileListPage) ImageViewPage(m.co.rh.id.a_medic_log.app.ui.page.common.ImageViewPage) DonationsPage(m.co.rh.id.a_medic_log.app.ui.page.DonationsPage) File(java.io.File) MedicineIntakeDetailPage(m.co.rh.id.a_medic_log.app.ui.page.MedicineIntakeDetailPage)

Example 3 with StatefulView

use of m.co.rh.id.anavigator.StatefulView in project a-medic-log by rh-id.

the class SettingsPage method createView.

@Override
protected View createView(Activity activity, ViewGroup container) {
    View view = activity.getLayoutInflater().inflate(R.layout.page_settings, container, false);
    mAppBarSV.setTitle(activity.getString(R.string.title_settings));
    ViewGroup containerAppBar = view.findViewById(R.id.container_app_bar);
    containerAppBar.addView(mAppBarSV.buildView(activity, container));
    ViewGroup content = view.findViewById(R.id.content);
    for (StatefulView statefulView : mStatefulViews) {
        LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        content.addView(statefulView.buildView(activity, content), lparams);
    }
    return view;
}
Also used : StatefulView(m.co.rh.id.anavigator.StatefulView) ViewGroup(android.view.ViewGroup) StatefulView(m.co.rh.id.anavigator.StatefulView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Aggregations

StatefulView (m.co.rh.id.anavigator.StatefulView)3 Activity (android.app.Activity)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 LinearLayout (android.widget.LinearLayout)1 File (java.io.File)1 HashMap (java.util.HashMap)1 MainActivity (m.co.rh.id.a_medic_log.app.MainActivity)1 DonationsPage (m.co.rh.id.a_medic_log.app.ui.page.DonationsPage)1 MedicineDetailPage (m.co.rh.id.a_medic_log.app.ui.page.MedicineDetailPage)1 MedicineIntakeDetailPage (m.co.rh.id.a_medic_log.app.ui.page.MedicineIntakeDetailPage)1 MedicineIntakeListPage (m.co.rh.id.a_medic_log.app.ui.page.MedicineIntakeListPage)1 MedicineReminderDetailPage (m.co.rh.id.a_medic_log.app.ui.page.MedicineReminderDetailPage)1 NoteAttachmentDetailPage (m.co.rh.id.a_medic_log.app.ui.page.NoteAttachmentDetailPage)1 NoteDetailPage (m.co.rh.id.a_medic_log.app.ui.page.NoteDetailPage)1 NoteListPage (m.co.rh.id.a_medic_log.app.ui.page.NoteListPage)1 NoteTagDetailSVDialog (m.co.rh.id.a_medic_log.app.ui.page.NoteTagDetailSVDialog)1 ProfileDetailPage (m.co.rh.id.a_medic_log.app.ui.page.ProfileDetailPage)1 ProfileListPage (m.co.rh.id.a_medic_log.app.ui.page.ProfileListPage)1 ProfileSelectSVDialog (m.co.rh.id.a_medic_log.app.ui.page.ProfileSelectSVDialog)1