Java Code Examples for com.pixplicity.easyprefs.library.Prefs#putBoolean()

The following examples show how to use com.pixplicity.easyprefs.library.Prefs#putBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentPlayer.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
private void askPhoneStatePermissions() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Prefs.getBoolean(PREF_PHONE_PERM_ASKED, false)) {
        Prefs.putBoolean(PREF_PHONE_PERM_ASKED, true);
        new MaterialDialog.Builder(getActivity())
                .title(R.string.phone_state_permissions)
                .content(R.string.phone_state_description)
                .positiveText(R.string.ok)
                .onAny(new MaterialDialog.SingleButtonCallback() {
                    @TargetApi(Build.VERSION_CODES.M)
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        getActivity().requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, CODE_PERMISSIONS_PHONE_STATE);
                    }
                }).build().show();
    }
}
 
Example 2
Source File: FragmentHelp.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_help, container, false);

    if (((IToolbarHolder) getActivity()).getToolbar() != null) {
        ((IToolbarHolder) getActivity()).getToolbar().setVisibility(View.GONE);
    }

    vpHelp = (ViewPager) view.findViewById(R.id.vpHelp);
    indicatorHelp = (CircleIndicator) view.findViewById(R.id.indicatorHelp);
    helpPagesAdapter = new HelpPagesAdapter(getChildFragmentManager());

    initCloseListener();
    helpPagesAdapter.setCloseClickListener(closeClickListener);
    vpHelp.setAdapter(helpPagesAdapter);
    indicatorHelp.setViewPager(vpHelp);
    Prefs.putBoolean(PREF_HELP_SHOWN, true);
    return view;
}
 
Example 3
Source File: ResultLevelFragment.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = createView(R.layout.fragment_result_level, inflater, container);
    view.setBackgroundColor(LevelColorUtil.fromLevelColor(GoogleFlipGameApplication.getUserModel().getCurrentBackgroundColor()));
    ButterKnife.bind(this, view);

    Bundle extras = getActivity().getIntent().getExtras();
    if (extras != null) {
        _success = extras.getBoolean(IntentKeys.RESULT_SUCCESS);
        float time = extras.getFloat(IntentKeys.RESULT_TIME);
        Long levelId = extras.getLong(IntentKeys.RESULT_LEVEL_ID);
        _isTutorial = extras.getBoolean(IntentKeys.IS_TUTORIAL);


        if (_isTutorial) {
            GoogleFlipGameApplication.getUserModel().unlockLevel(0);
            _levelResult = LevelResult.NEW;

            if (_success) {
                _scoreLabel1.setText(String.format("%.1f", time) + "s");
            } else {
                _scoreLabel1.setText(getResources().getString(R.string.done));
            }

            _scoreLabel2.setVisibility(View.GONE);

            _recordLabel.setText(getResources().getString(R.string.to_first_level));
            _recordLabel.setVisibility(View.VISIBLE);
        } else {
            if (_success) {
                _scoreLabel1.setText(String.format("%.1f", time) + "s");

                _nextButton.setVisibility(GoogleFlipGameApplication.getUserModel().hasNextLevel() ? View.VISIBLE : View.GONE);

                _levelResult = GoogleFlipGameApplication.getUserModel().updateLevelResult(new LevelResultVO(levelId, time, _success));

                if (!GoogleFlipGameApplication.getUserModel().hasNextLevel() && !Prefs.getBoolean(PrefKeys.LEVELS_COMPLETE, false)) {
                    Prefs.putBoolean(PrefKeys.LEVELS_COMPLETE, true);

                    _scoreLabel1.setText(getResources().getString(R.string.yay));
                    _scoreLabel2.setText(getResources().getString(R.string.you_won));
                    _recordLabel.setVisibility(View.GONE);
                } else {
                    _scoreLabel2.setVisibility(View.GONE);

                    // update score
                    switch (_levelResult) {
                        case BETTER:
                            _recordLabel.setText(getResources().getString(R.string.new_record));
                            break;
                        case NEW:
                            _recordLabel.setVisibility(View.GONE);
                            break;
                        case WORSE:
                            Float bestTime = GoogleFlipGameApplication.getUserModel().getResultForLevel(levelId).seconds;
                            _recordLabel.setText(getResources().getString(R.string.your_record) + " " + String.format("%.1f", bestTime) + "s");
                            break;
                    }
                }
            } else {
                _levelResult = LevelResult.FAIL;

                String str = getResources().getString(LOST_TEXTS[(int) (Math.floor(Math.random() * LOST_TEXTS.length))]);

                if (str.contains("\n")) {
                    _scoreLabel1.setText(str.split("\n")[0]);
                    _scoreLabel2.setText(str.split("\n")[1]);
                } else {
                    _scoreLabel1.setText(str);
                    _scoreLabel2.setVisibility(View.GONE);
                }

                _recordLabel.setVisibility(View.GONE);
                _nextButton.setText(getResources().getString(R.string.play_again));
            }
        }

        _scoreLabel1.show();

        if (_scoreLabel2.getVisibility() == View.VISIBLE) {
            _scoreLabel2.show(200);
        }

        if (_recordLabel.getVisibility() == View.VISIBLE) {
            _recordLabel.show(500);
        }
    }

    return view;
}
 
Example 4
Source File: SoundManager.java    From tilt-game-android with MIT License 4 votes vote down vote up
public static void toggleMute () {
    sIsMuted = !sIsMuted;

    Prefs.putBoolean(PrefKeys.MUTED, sIsMuted);
}