Android Open Source - beers-todrink Beer Dialog Confirmation






From Project

Back to project page beers-todrink.

License

The source code is released under:

MIT License

If you think the Android project beers-todrink 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 br.com.androidzin.brunomateus.beerstodrink;
/*from www.  j  a v  a 2  s.c om*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;

import br.com.androidzin.brunomateus.beerstodrink.model.Beer;

/**
 * Created by bruno on 19/12/14.
 */
public class BeerDialogConfirmation extends DialogFragment {

    private Beer mBeer;

    public interface BeerDialogConfirmartionListener {
        public void onDialogPositiveClick(Beer beer);
    }

    private BeerDialogConfirmartionListener mListener;

    public void setBeer(Beer beer) {
        this.mBeer = beer;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.marked_not_drank);
        builder.setPositiveButton(R.string.no_i_havent, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mListener.onDialogPositiveClick(mBeer);
            }
        }).setNegativeButton(R.string.ive_already_drank, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        return builder.create();
    }

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

        try {
            mListener = (BeerDialogConfirmartionListener) getActivity();
        } catch (ClassCastException e){
            throw  new ClassCastException(activity.toString()
                    + "must implement BeerDialogConfirmationListener");
        }
    }
}




Java Source Code List

br.com.androidzin.brunomateus.beerstodrink.ApplicationTest.java
br.com.androidzin.brunomateus.beerstodrink.BeerDetailActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerDetailFragment.java
br.com.androidzin.brunomateus.beerstodrink.BeerDialogConfirmation.java
br.com.androidzin.brunomateus.beerstodrink.BeerDrinkingActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerFilterCountryDialog.java
br.com.androidzin.brunomateus.beerstodrink.BeerFilterTest.java
br.com.androidzin.brunomateus.beerstodrink.BeerListActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerListFragment.java
br.com.androidzin.brunomateus.beerstodrink.BeerProviderSimple.java
br.com.androidzin.brunomateus.beerstodrink.BeerProviderTest.java
br.com.androidzin.brunomateus.beerstodrink.adapter.BeerAdapter.java
br.com.androidzin.brunomateus.beerstodrink.adapter.BeerViewHolder.java
br.com.androidzin.brunomateus.beerstodrink.adapter.CursorRecyclerViewAdapter.java
br.com.androidzin.brunomateus.beerstodrink.model.Beer.java
br.com.androidzin.brunomateus.beerstodrink.provider.BeerContract.java
br.com.androidzin.brunomateus.beerstodrink.provider.BeerProvider.java
br.com.androidzin.brunomateus.beerstodrink.util.FilterBuilder.java