Android Open Source - android-cassowary-layout Edit Ratio Dialog






From Project

Back to project page android-cassowary-layout.

License

The source code is released under:

Apache License

If you think the Android project android-cassowary-layout 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 no.agens.cassowarylayoutdemo.util;
/*ww  w.ja  va  2 s .  c o m*/
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.EditText;

import no.agens.cassowarylayoutdemo.R;

/**
 * Created by alex on 08/12/2014.
 */
public class EditRatioDialog {

    private EditRatioDialog() {
    }

    public interface EditRatioDialogCallback {
        void setAspectRatioWidthFactor(float aspectRatioWidthFactor);
        void setAspectRatioHeightFactor(float aspectRatioHeightFactor);
    }


    public static void show(float aspectRatioWidthFactor,
                            float aspectRatioHeightFactor,
                            final Context context,
                            final EditRatioDialogCallback callback) {

        // quick and dirty dialog to set ratio
        LayoutInflater li = LayoutInflater.from(context);

        ViewGroup dialogAspectRatioEdit = (ViewGroup)li.inflate(R.layout.dialog_aspect_ratio_edit, null);
        final EditText aspectRatioWidthFactorEditText = (EditText)  dialogAspectRatioEdit.findViewById(R.id.aspectRatioWidthFactor);
        final EditText aspectRatioHeightFactorEditText = (EditText)  dialogAspectRatioEdit.findViewById(R.id.aspectRatioHeightFactor);

        aspectRatioWidthFactorEditText.setText(Float.toString(aspectRatioWidthFactor));
        aspectRatioHeightFactorEditText.setText(Float.toString(aspectRatioHeightFactor));

        new AlertDialog.Builder(context)
                .setTitle(R.string.enter_ratio)
                .setView(dialogAspectRatioEdit)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        callback.setAspectRatioWidthFactor(getValueFromEditText(aspectRatioWidthFactorEditText));
                        callback.setAspectRatioHeightFactor(getValueFromEditText(aspectRatioHeightFactorEditText));
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // Do nothing.
            }
        }).show();
    }

    private static float getValueFromEditText(EditText editText) {
        return Float.parseFloat(editText.getText().toString());
    }
}




Java Source Code List

no.agens.cassowarylayout.ApplicationTest.java
no.agens.cassowarylayout.CassowaryLayout.java
no.agens.cassowarylayout.CassowaryModel.java
no.agens.cassowarylayout.ChildNode.java
no.agens.cassowarylayout.ConstraintParser.java
no.agens.cassowarylayout.ContainerNode.java
no.agens.cassowarylayout.DefaultViewIdResolver.java
no.agens.cassowarylayout.Node.java
no.agens.cassowarylayout.ViewIdResolver.java
no.agens.cassowarylayout.util.CassowaryUtil.java
no.agens.cassowarylayout.util.DimensionParserTest.java
no.agens.cassowarylayout.util.DimensionParser.java
no.agens.cassowarylayout.util.ExpressionTokenizerTest.java
no.agens.cassowarylayout.util.InfixToPostFixTest.java
no.agens.cassowarylayout.util.MeasureSpecUtils.java
no.agens.cassowarylayout.util.TimerUtil.java
no.agens.cassowarylayoutdemo.ApplicationTest.java
no.agens.cassowarylayoutdemo.CassowaryLayoutInLinearLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutMatchParentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutWrapContentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInListViewActivity.java
no.agens.cassowarylayoutdemo.CenterInParentActivity.java
no.agens.cassowarylayoutdemo.CenterViewRelativeToSiblingActivity.java
no.agens.cassowarylayoutdemo.ChessBoardActivity.java
no.agens.cassowarylayoutdemo.DynamicWidthActivity.java
no.agens.cassowarylayoutdemo.ExampleMenuActivity.java
no.agens.cassowarylayoutdemo.FixedAspectRatioDemoActivity.java
no.agens.cassowarylayoutdemo.IntrinsicHeightTextInWrapContentContainerActivity.java
no.agens.cassowarylayoutdemo.LayoutParamsSwitcherActivity.java
no.agens.cassowarylayoutdemo.LinearLayoutInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.ParallaxScrollingActivity.java
no.agens.cassowarylayoutdemo.PreSetupTestActivity.java
no.agens.cassowarylayoutdemo.ProgrammaticDemoActivity.java
no.agens.cassowarylayoutdemo.XmlLayoutDemoActivity.java
no.agens.cassowarylayoutdemo.util.EditRatioDialog.java