Android Open Source - DVBViewerController Timer Info Fragment






From Project

Back to project page DVBViewerController.

License

The source code is released under:

Apache License

If you think the Android project DVBViewerController listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.bennir.DVBViewerController.wizard.ui;
//from  w  ww . ja va2 s.  c om
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import de.bennir.DVBViewerController.R;
import de.bennir.DVBViewerController.wizard.model.TimerInfoPage;

public class TimerInfoFragment extends Fragment {
    private static final String ARG_KEY = "key";
    private PageFragmentCallbacks mCallbacks;
    private String mKey;
    private TimerInfoPage mPage;
    private TextView mNameView;
    private TextView mPriorityView;
    private CheckBox mEnabledView;

    public TimerInfoFragment() {
    }

    public static TimerInfoFragment create(String key) {
        Bundle args = new Bundle();
        args.putString(ARG_KEY, key);

        TimerInfoFragment fragment = new TimerInfoFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle args = getArguments();
        mKey = args.getString(ARG_KEY);
        mPage = (TimerInfoPage) mCallbacks.onGetPage(mKey);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_page_timer_info, container, false);
        ((TextView) rootView.findViewById(android.R.id.title)).setText(getResources().getString(R.string.timer_info));

        mNameView = (TextView) rootView.findViewById(R.id.timer_name);
        mNameView.setText(mPage.getData().getString(TimerInfoPage.NAME_DATA_KEY));

        mPriorityView = (TextView) rootView.findViewById(R.id.timer_priority);
        mPriorityView.setText(mPage.getData().getString(TimerInfoPage.PRIORITY_DATA_KEY));

        mEnabledView = (CheckBox) rootView.findViewById(R.id.timer_enabled);
        if (mPage.getData().getBoolean(TimerInfoPage.ENABLED_DATA_KEY)) {
            mEnabledView.setChecked(true);
        }

        return rootView;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        if (!(activity instanceof PageFragmentCallbacks)) {
            throw new ClassCastException("Activity must implement PageFragmentCallbacks");
        }

        mCallbacks = (PageFragmentCallbacks) activity;
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mCallbacks = null;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mNameView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1,
                                          int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void afterTextChanged(Editable editable) {
                mPage.getData().putString(TimerInfoPage.NAME_DATA_KEY,
                        (editable != null) ? editable.toString() : null);
                mPage.notifyDataChanged();
            }
        });

        mPriorityView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1,
                                          int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void afterTextChanged(Editable editable) {
                mPage.getData().putString(TimerInfoPage.PRIORITY_DATA_KEY,
                        (editable != null) ? editable.toString() : null);
                mPage.notifyDataChanged();
            }
        });

        mEnabledView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                mPage.getData().putBoolean(TimerInfoPage.ENABLED_DATA_KEY, mEnabledView.isChecked());
                mPage.notifyDataChanged();
            }
        });
    }

    @Override
    public void setMenuVisibility(boolean menuVisible) {
        super.setMenuVisibility(menuVisible);

        // In a future update to the support library, this should override setUserVisibleHint
        // instead of setMenuVisibility.
        if (mNameView != null) {
            InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            if (!menuVisible) {
                imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
            }
        }
    }
}




Java Source Code List

com.android.datetimepicker.AccessibleLinearLayout.java
com.android.datetimepicker.AccessibleTextView.java
com.android.datetimepicker.Utils.java
com.android.datetimepicker.date.AccessibleDateAnimator.java
com.android.datetimepicker.date.DatePickerController.java
com.android.datetimepicker.date.DatePickerDialog.java
com.android.datetimepicker.date.DayPickerView.java
com.android.datetimepicker.date.SimpleMonthAdapter.java
com.android.datetimepicker.date.SimpleMonthView.java
com.android.datetimepicker.date.TextViewWithCircularIndicator.java
com.android.datetimepicker.date.YearPickerView.java
com.android.datetimepicker.time.AmPmCirclesView.java
com.android.datetimepicker.time.CircleView.java
com.android.datetimepicker.time.RadialPickerLayout.java
com.android.datetimepicker.time.RadialSelectorView.java
com.android.datetimepicker.time.RadialTextsView.java
com.android.datetimepicker.time.TimePickerDialog.java
com.googlecode.eyesfree.utils.TouchExplorationHelper.java
de.bennir.DVBViewerController.ChannelFragment.java
de.bennir.DVBViewerController.ChannelGroupFragment.java
de.bennir.DVBViewerController.DVBViewerControllerActivity.java
de.bennir.DVBViewerController.DeviceSelectionActivity.java
de.bennir.DVBViewerController.EPGFragment.java
de.bennir.DVBViewerController.RemoteFragment.java
de.bennir.DVBViewerController.SettingsFragment.java
de.bennir.DVBViewerController.TimerFragment.java
de.bennir.DVBViewerController.TimerWizardActivity.java
de.bennir.DVBViewerController.TimerWizardModel.java
de.bennir.DVBViewerController.channels.ChanGroupAdapter.java
de.bennir.DVBViewerController.channels.DVBChannelAdapter.java
de.bennir.DVBViewerController.channels.DVBChannel.java
de.bennir.DVBViewerController.epg.EPGInfoAdapter.java
de.bennir.DVBViewerController.epg.EPGInfo.java
de.bennir.DVBViewerController.service.DVBServer.java
de.bennir.DVBViewerController.service.DVBService.java
de.bennir.DVBViewerController.timers.DVBTimer.java
de.bennir.DVBViewerController.timers.TimerAdapter.java
de.bennir.DVBViewerController.util.DateUtils.java
de.bennir.DVBViewerController.util.ThreadExecutor.java
de.bennir.DVBViewerController.view.QuickReturnListView.java
de.bennir.DVBViewerController.wizard.model.AbstractWizardModel.java
de.bennir.DVBViewerController.wizard.model.BranchPage.java
de.bennir.DVBViewerController.wizard.model.ModelCallbacks.java
de.bennir.DVBViewerController.wizard.model.MultipleFixedChoicePage.java
de.bennir.DVBViewerController.wizard.model.PageList.java
de.bennir.DVBViewerController.wizard.model.PageTreeNode.java
de.bennir.DVBViewerController.wizard.model.Page.java
de.bennir.DVBViewerController.wizard.model.ReviewItem.java
de.bennir.DVBViewerController.wizard.model.SingleFixedChoicePage.java
de.bennir.DVBViewerController.wizard.model.TimerDatePage.java
de.bennir.DVBViewerController.wizard.model.TimerInfoPage.java
de.bennir.DVBViewerController.wizard.ui.MultipleChoiceFragment.java
de.bennir.DVBViewerController.wizard.ui.PageFragmentCallbacks.java
de.bennir.DVBViewerController.wizard.ui.ReviewFragment.java
de.bennir.DVBViewerController.wizard.ui.SingleChoiceFragment.java
de.bennir.DVBViewerController.wizard.ui.StepPagerStrip.java
de.bennir.DVBViewerController.wizard.ui.TimerDateFragment.java
de.bennir.DVBViewerController.wizard.ui.TimerInfoFragment.java