日期:2014-05-16  浏览次数:20347 次

各种dialog,alertdialog,AlertDialog.Builder(this)的总结,并封住成javaScript调用
package com.emn.emf.android.basecommands.loading;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.emn.emf.android.AndroidBaseActivity;
import com.emn.emf.android.CommandObject;
import com.emn.emf.android.R;

public class Loading extends AndroidBaseActivity implements CommandObject {
	private ProgressDialog myDialog2 = null;
	private ProgressDialog myDialogTime = null;
	private long time = 0,time2 = 0,time3 = 0;
	private CustomDialog cd;
	private Dialog cd2;
	public  AlertDialog alertDialog;
	private String showCenterTipTitle = "",showCenterTipTitle2 = "",showCenterTipTitle3 = "",showCenterTipTitle4 = "";
	private String showCenterTipTime = "",showCenterTipTime2 = "",showCenterCallback3 = null,showCenterTipContent3 = "";
	private String showCenterTipContent = "",showCenterTipContent2 = ""	,showCenterTipTimeTitle = "";;
	private String showCenterCallback4 = null,showCenterTipContent4 = "";
	private String showCenterTipTimeTime = "",showCenterTipTiemContent = "",showCenterCallback = "";
	private Handler mHandler = new Handler();

	@Override
	public Boolean checkValidation(String checkCommand, Object parameters) {
		// TODO Auto-generated method stub
		return Boolean.TRUE;
	}
	/*
	 * (non-Javadoc)
	 * @see com.emn.emf.android.CommandObject#handleIt(java.lang.String, java.lang.Object)
	 */
	@Override
	public Object handleIt(String checkCommand, Object parameters) {

		String jsonstartLoad = "";
		if (checkCommand.equals("startLoad")) {
			jsonstartLoad = getStartLoad(parameters);
		} else if (checkCommand.equals("finishLoad")) {
			jsonstartLoad = getFinishLoading();

		} else if (checkCommand.equals("showCenterTipMyTwoButton")) {
			jsonstartLoad = getshowCenterTipMyTwoButton(parameters);
		} else if (checkCommand.equals("showCenterTipMyTime")) {
			jsonstartLoad = getshowCenterTipMyTime(parameters);
		} else if (checkCommand.equals("showCenterTipButtonTwo")) {
			jsonstartLoad = getshowCenterTipButtonTwo(parameters);
		} 
		else if (checkCommand.equals("showCenterTipButtonOne")) {
			jsonstartLoad = getshowCenterTipBttonOne(parameters);
		}else if (checkCommand.equals("showCenterTipTimeSystem")) {
			jsonstartLoad = getshowCenterTipTimeSystem(parameters);
		}
		return jsonstartLoad;

	}
	/*
	 *  启动对话框,带有系统默认旋转图片,可以自定义标题,和内容提示部分。
	 */
	private String getStartLoad(Object parameters) {

		String loadingTitle = "";
		String loadingContent = "";
		String strJSONParam = parameters.toString();
		JSONObject jsonObject;
		try {
			jsonObject = new JSONObject(strJSONParam);
			loadingTitle = jsonObject.getString("title");
			loadingContent = jsonObject.getString("content");
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		CharSequence strDialogTitle = (CharSequence) loadingTitle;
		CharSequence strDialogBody = (CharSequence) loadingContent;

		// 显示Progress对话框
		myDialog2 = ProgressDialog.show(AndroidBaseActivity.self,
				strDialogTitle, strDialogBody, true);

		

		return "{states:success}";
	}

	
    /*
     * 加载Loading效果,你可以自定义指定标题,内容。但没有自动取消。
     * 如果需要取消需要调用JS方法finishLoading()进行取消。
     */
	private String getshowCenterTipTimeSystem(Object parameters) {
		String strJSONParam = parameters.toString();
		JSONObject jsonObject;
		try {
			jsonObject = new JSONObject(strJSONParam);
			showCenterTipTimeTitle = jsonObject.getString("title");
			showCenterTipTimeTime = jsonObject.getString("time");
			showCenterTipTiemContent = jsonObject.getString("content");
			time2 = Long.parseLong(showCenterTipTimeTime);

		} catch (JSONException e1) {
			// TODO Auto-generate