summaryrefslogblamecommitdiff
path: root/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
blob: 16e15db41e971e57b1c35188742ecad8cda96fe4 (plain) (tree)
1
2
3
4
5
6
7

                            
                         


                           
                              








                                        
                                 



                                 
                            
                             
                                   




                                                   

                                   




















                                                     
                               


                    
        
















                                                                                 


                                                                             





                                                                                                                     
                                                           






                                                                                                















                                                                                                
 

























                                                                                                 
                                                       
                
                                                  



                                                                    
                                                       
         
        



                                                                  


                                                                        

         


                                                     
                                     

                                          
                


                                                                            
                                                             


                                                                                                           


                                                                                                                                                     
                                                                                            



                                                                                                         
                                                                                             
                                                                                                                   






                                                                                     
                                                                       
                                                    
                                                    
         
 

                                        



                                                                                                        
                                                                                                




















                                                                                                                                    
                                                                                   

                                                              
                                                        

                            
         
 
 
package com.macaroon.piztor;

import java.io.Closeable;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.zip.Inflater;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.map.LocationData;
import com.baidu.mapapi.map.MKMapTouchListener;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;

public class AlertMaker {

	private Calendar calendar;
	private Context context;
	private GeoPoint markerPoint;
	private MapMaker mapMaker;
	private long timestamp;
	int mHour;
	int mMinute;
	myApp app;
	
	public AlertMaker(Context cc, MapMaker mm) {
		context =cc;
		mapMaker = mm;
	}
		
	public static void closeBoard(Context cc) {
		InputMethodManager imm = (InputMethodManager) cc
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		  if (imm.isActive())
			  imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
		 InputMethodManager.HIDE_NOT_ALWAYS);
		 }

	public void showSettingsAlert() {
		
		closeBoard(context);
		AlertDialog.Builder gpsDialog = new AlertDialog.Builder(context);
		gpsDialog.setTitle("GPS设置");
		gpsDialog.setMessage("GPS未开启,是否前去打开?");
		gpsDialog.setPositiveButton("设置",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
						context.startActivity(intent);
					}
				});
		gpsDialog.setNegativeButton("不使用GPS",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel();
					}
				});
		gpsDialog.show();
	}
	
	public void showLateAlert() {
		
		closeBoard(context);
		AlertDialog.Builder lateDialog = new AlertDialog.Builder(context);
		lateDialog.setTitle("阿哦");
		lateDialog.setMessage("你迟到了!");
		lateDialog.setNeutralButton("知道了", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface arg0, int arg1) {
				arg0.cancel();
			}
		});
		lateDialog.show();
		closeBoard(context);
	}

public void showRemoveMarkerAlert() {
		
		closeBoard(context);
		AlertDialog.Builder removeDialog = new AlertDialog.Builder(context);
		removeDialog.setTitle("取消路标");
		removeDialog.setMessage("是否取消路标?");
		removeDialog.setPositiveButton("确定",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						mapMaker.mOverlay.removeItem(mapMaker.nowMarker);
						mapMaker.nowMarker = null;
						mapMaker.mMapView.refresh();
						mapMaker.popLay.hidePop();
					}
				});
		removeDialog.