Android Open Source - treedo Dialog Builder






From Project

Back to project page treedo.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Everyone is permitted to copy and distribute verbatim or modified copies of this license document, ...

If you think the Android project treedo 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 com.mbonnin.treedo;
//from w  w w  .  j  av  a 2s  .c o  m
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Created by martin on 17/11/14.
 */
public class DialogBuilder {
    AlertDialog.Builder mBuilder;
    LinearLayout mViewHolder;
    String mButtonLabel;
    ImageView mIcon;
    TextView mTitle;
    Listener mListener;

    interface Listener {
        void onButtonClick();
    }

    public DialogBuilder(Activity activity) {
        mBuilder = new AlertDialog.Builder(activity);
        View view = activity.getLayoutInflater().inflate(R.layout.dialog, null);
        mViewHolder = (LinearLayout)view.findViewById(R.id.view_holder);
        mIcon = (ImageView)view.findViewById(R.id.icon);
        mTitle = (TextView)view.findViewById(R.id.title);

        mBuilder.setView(view);
        mButtonLabel = activity.getString(R.string.ok);
    }

    public void setView(View view) {
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        mViewHolder.removeAllViews();
        mViewHolder.addView(view,layoutParams);
    }

    public void setButtonLabel(String label) {
        mButtonLabel = label;
    }

    public void setListener(Listener listener) {
        mListener = listener;
    }

    public void setTitle(String title) {
        mTitle.setText(title);
    }

    public void setIcon(int id) {
        mIcon.setImageResource(id);
    }

    public AlertDialog show() {
        mBuilder.setNeutralButton(mButtonLabel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                if (mListener != null) {
                    mListener.onButtonClick();
                }
            }
        });

        return mBuilder.show();

    }
}




Java Source Code List

com.mbonnin.treedo.ApplicationTest.java
com.mbonnin.treedo.BackupAdapter.java
com.mbonnin.treedo.BackupManager.java
com.mbonnin.treedo.Database.java
com.mbonnin.treedo.DialogBuilder.java
com.mbonnin.treedo.ItemAdapter.java
com.mbonnin.treedo.ItemDecorator.java
com.mbonnin.treedo.ItemEditText.java
com.mbonnin.treedo.ItemListView.java
com.mbonnin.treedo.ItemView2.java
com.mbonnin.treedo.ItemView.java
com.mbonnin.treedo.Item.java
com.mbonnin.treedo.MainActivity.java
com.mbonnin.treedo.ObservableScrollView.java
com.mbonnin.treedo.ProgressBar.java
com.mbonnin.treedo.SpacerView.java
com.mbonnin.treedo.TypeSpinnerAdapter.java
com.mbonnin.treedo.Utils.java