PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-android/src/com/nimbits/android/CustomDialog.java

http://nimbits-server.googlecode.com/
Java | 65 lines | 51 code | 13 blank | 1 comment | 0 complexity | e78c9e2d75ed47972c9322461f722d97 MD5 | raw file
 1package com.nimbits.android;
 2
 3import android.app.Dialog;
 4import android.content.Context;
 5import android.os.Bundle;
 6import android.util.Log;
 7import android.view.View;
 8import android.widget.Button;
 9import android.widget.EditText;
10import com.nimbits.client.model.Const;
11
12import java.io.UnsupportedEncodingException;
13
14public class CustomDialog  extends Dialog{
15	 public interface ReadyListener {
16	        public void ready(String name) throws UnsupportedEncodingException;
17	    }
18
19
20	    private final String prompt;
21	    String getEntry() {
22			return entry;
23		}
24
25		void setEntry(String entry) {
26			this.entry = entry;
27		}
28
29		private String entry;
30	    
31	    private final ReadyListener readyListener;
32	    private EditText etName;
33
34	    public CustomDialog(Context context, String prompt,
35	            ReadyListener readyListener) {
36	        super(context);
37	       // this.name = name;
38	        this.prompt = prompt;
39	        this.readyListener = readyListener;
40	    }
41
42	    @Override
43	    public void onCreate(Bundle savedInstanceState) {
44	        super.onCreate(savedInstanceState);
45	        setContentView(R.layout.catagory_dialog);
46	        setTitle(prompt);
47	        Button buttonOK = (Button) findViewById(R.id.Button01);
48	        buttonOK.setOnClickListener(new OKListener());
49	        etName = (EditText) findViewById(R.id.EditText01);
50	    }
51
52	    private class OKListener implements android.view.View.OnClickListener {
53	        public void onClick(View v) {
54	        	setEntry(String.valueOf(etName.getText()));
55
56                try {
57                    readyListener.ready(getEntry());
58                } catch (UnsupportedEncodingException e) {
59                    Log.e(Const.N, e.getMessage());
60                }
61                CustomDialog.this.dismiss();
62	        }
63	    }
64
65	}