@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); activity = getActivity(); if (activity != null) { // bAction.setEnabled(isComplete()); String pageId = getArguments().getString(PAGE_ID); String selectedLang = ApplicationSettings.getSelectedLanguage(activity); PBDatabase dbInstance = new PBDatabase(activity); dbInstance.open(); currentPage = dbInstance.retrievePage(pageId, selectedLang); dbInstance.close(); tvTitle.setText(currentPage.getTitle()); if (currentPage.getContent() == null) tvContent.setVisibility(View.GONE); else tvContent.setText(Html.fromHtml(currentPage.getContent(), null, new MyTagHandler())); if (currentPage.getIntroduction() == null) tvIntro.setVisibility(View.GONE); else tvIntro.setText(currentPage.getIntroduction()); if (currentPage.getWarning() == null) llWarning.setVisibility(View.GONE); else tvWarning.setText(currentPage.getWarning()); bAction.setText(currentPage.getAction().get(0).getTitle()); pageItemAdapter = new PageItemAdapter(activity, null); lvItems.setAdapter(pageItemAdapter); pageItemAdapter.setData(currentPage.getItems()); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_type_interactive_alert, container, false); alertDelayEditText = (TextView) view.findViewById(R.id.alertDelay_edittext); alertDelayEditText.setText( String.valueOf(ApplicationSettings.getAlertDelay(getActivity())) + " min"); delayDialogSettings(); alertDelayEditText.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { actions.show(); } }); tvTitle = (TextView) view.findViewById(R.id.fragment_title); tvIntro = (TextView) view.findViewById(R.id.fragment_intro); tvContent = (TextView) view.findViewById(R.id.fragment_contents); bAction = (Button) view.findViewById(R.id.fragment_action); bAction.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Log.e(">>>>", "action button pressed"); ApplicationSettings.setAlertDelay( getActivity(), ApplicationSettings.getAlertDelay(getActivity())); String pageId = currentPage.getAction().get(0).getLink(); int parentActivity = getArguments().getInt(PARENT_ACTIVITY); Intent i; if (parentActivity == AppConstants.FROM_WIZARD_ACTIVITY) { i = new Intent(activity, WizardActivity.class); } else { // AppUtil.showToast("New frequency saved.", 1000, activity); String confirmation = (currentPage.getAction().get(0).getConfirmation() == null) ? AppConstants.DEFAULT_CONFIRMATION_MESSAGE : currentPage.getAction().get(0).getConfirmation(); Toast.makeText(activity, confirmation, Toast.LENGTH_SHORT).show(); i = new Intent(activity, MainActivity.class); } // Intent i = new Intent(activity, WizardActivity.class); i.putExtra("page_id", pageId); startActivity(i); if (parentActivity == AppConstants.FROM_MAIN_ACTIVITY) { activity.finish(); } } }); lvItems = (ListView) view.findViewById(R.id.fragment_item_list); llWarning = (LinearLayout) view.findViewById(R.id.ll_fragment_warning); tvWarning = (TextView) view.findViewById(R.id.fragment_warning); lvItems.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PageItem selectedItem = (PageItem) parent.getItemAtPosition(position); String pageId = selectedItem.getLink(); int parentActivity = getArguments().getInt(PARENT_ACTIVITY); Intent i; if (parentActivity == AppConstants.FROM_WIZARD_ACTIVITY) { i = new Intent(activity, WizardActivity.class); } else { i = new Intent(activity, MainActivity.class); } // Intent i = new Intent(activity, WizardActivity.class); i.putExtra("page_id", pageId); startActivity(i); } }); return view; }
@Override public void onClick(DialogInterface dialog, int which) { ApplicationSettings.setAlertDelay(getActivity(), which + 1); alertDelayEditText.setText(time_options[which].toString() + " min"); }