Example usage for android.os Message Message

List of usage examples for android.os Message Message

Introduction

In this page you can find the example usage for android.os Message Message.

Prototype

public Message() 

Source Link

Document

Constructor (but the preferred way to get a Message is to call #obtain() Message.obtain() ).

Usage

From source file:com.zoffcc.applications.zanavi.Navit.java

public void start_targetsearch_from_intent(String target_address) {
    Navit_last_address_partial_match = true; // this will overwrite the default setting --> this is not good
    Navit_last_address_search_string = target_address;
    Navit_last_address_hn_string = "";

    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    Boolean use_online_searchmode_here = true;
    Boolean hide_duplicates_searchmode_here = false;
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------

    int dialog_num_;

    if (use_online_searchmode_here) {
        dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
        Navit.use_index_search = false;/*from  w  ww.ja  va  2  s.co m*/
        Log.e("Navit", "*google*:online search");
    } else {
        dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
        Navit.use_index_search = Navit.allow_use_index_search();
    }

    // clear results
    Navit.NavitAddressResultList_foundItems.clear();
    Navit.Navit_Address_Result_double_index.clear();
    Navit.NavitSearchresultBarIndex = -1;
    Navit.NavitSearchresultBar_title = "";
    Navit.NavitSearchresultBar_text = "";
    search_hide_duplicates = false;

    if (Navit_last_address_search_string.equals("")) {
        // empty search string entered
        Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
    } else {
        // show dialog
        try {
            Log.e("Navit", "*google*:call-11: (0)num " + dialog_num_);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (hide_duplicates_searchmode_here) {
            search_hide_duplicates = true;
            // hide duplicates when searching
            // hide duplicates when searching
            Message msg22 = new Message();
            Bundle b22 = new Bundle();
            b22.putInt("Callback", 45);
            msg22.setData(b22);
            NavitGraphics.callback_handler.sendMessage(msg22);
            // hide duplicates when searching
            // hide duplicates when searching
        }

        System.out.println("dialog -- 11:002");
        Message msg = progress_handler.obtainMessage();
        Bundle b = new Bundle();
        msg.what = 11;
        b.putInt("dialog_num", dialog_num_);
        msg.setData(b);
        progress_handler.sendMessage(msg);
    }
}

From source file:carnero.cgeo.cgBase.java

public void storeCache(cgeoapplication app, Activity activity, cgCache cache, String geocode, int listId,
        Handler handler) {//w  ww.  ja  v  a 2  s  .  c  o m
    try {
        // cache details
        if (cache != null) {
            final HashMap<String, String> params = new HashMap<String, String>();
            params.put("geocode", cache.geocode);
            final Long searchId = searchByGeocode(params, listId, false);
            cache = app.getCache(searchId);
        } else if (geocode != null) {
            final HashMap<String, String> params = new HashMap<String, String>();
            params.put("geocode", geocode);
            final Long searchId = searchByGeocode(params, listId, false);
            cache = app.getCache(searchId);
        }

        if (cache == null) {
            if (handler != null) {
                handler.sendMessage(new Message());
            }

            return;
        }

        final cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, cache.geocode, false, listId, true);

        // store images from description
        if (cache.description != null) {
            Html.fromHtml(cache.description, imgGetter, null);
        }

        // store spoilers
        if (cache.spoilers != null && cache.spoilers.isEmpty() == false) {
            for (cgSpoiler oneSpoiler : cache.spoilers) {
                imgGetter.getDrawable(oneSpoiler.url);
            }
        }

        // store map previews
        if (settings.storeOfflineMaps == 1 && cache.latitude != null && cache.longitude != null) {
            final String latlonMap = String.format((Locale) null, "%.6f", cache.latitude) + ","
                    + String.format((Locale) null, "%.6f", cache.longitude);
            final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
            final int maxWidth = display.getWidth() - 25;
            final int maxHeight = display.getHeight() - 25;
            int edge = 0;
            if (maxWidth > maxHeight) {
                edge = maxWidth;
            } else {
                edge = maxHeight;
            }

            String type = "mystery";
            if (cache.found == true) {
                type = cache.type + "_found";
            } else if (cache.disabled == true) {
                type = cache.type + "_disabled";
            } else {
                type = cache.type;
            }

            final String markerUrl = urlencode_rfc3986(
                    "http://cgeo.carnero.cc/_markers/marker_cache_" + type + ".png");
            final StringBuilder waypoints = new StringBuilder();
            if (cache.waypoints != null && cache.waypoints.size() > 0) {
                for (cgWaypoint waypoint : cache.waypoints) {
                    if (waypoint.latitude == null && waypoint.longitude == null) {
                        continue;
                    }

                    waypoints.append("&markers=icon%3Ahttp://cgeo.carnero.cc/_markers/marker_waypoint_");
                    waypoints.append(waypoint.type);
                    waypoints.append(".png%7C");
                    waypoints.append(String.format((Locale) null, "%.6f", waypoint.latitude));
                    waypoints.append(",");
                    waypoints.append(String.format((Locale) null, "%.6f", waypoint.longitude));
                }
            }

            // download map images in separate background thread for higher performance
            final String code = cache.geocode;
            final int finalEdge = edge;
            Thread staticMapsThread = new Thread("getting static map") {
                @Override
                public void run() {
                    cgMapImg mapGetter = new cgMapImg(settings, code);

                    mapGetter.getDrawable(
                            "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=20&size="
                                    + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A"
                                    + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false",
                            1);
                    mapGetter.getDrawable(
                            "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=18&size="
                                    + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A"
                                    + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false",
                            2);
                    mapGetter.getDrawable(
                            "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=16&size="
                                    + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A"
                                    + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false",
                            3);
                    mapGetter.getDrawable(
                            "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=14&size="
                                    + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A"
                                    + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false",
                            4);
                    mapGetter.getDrawable(
                            "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=11&size="
                                    + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A"
                                    + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false",
                            5);
                }
            };
            staticMapsThread.setPriority(Thread.MIN_PRIORITY);
            staticMapsThread.start();
        }

        app.markStored(cache.geocode, listId);
        app.removeCacheFromCache(cache.geocode);

        if (handler != null) {
            handler.sendMessage(new Message());
        }
    } catch (Exception e) {
        Log.e(cgSettings.tag, "cgBase.storeCache: " + e.toString());
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressLint("NewApi")
@Override//from w  w  w .ja  va 2s.  c  o  m
public boolean onOptionsItemSelected(MenuItem item) {
    //System.out.println("menu button pressed ID=" + item.getItemId());

    if ((item.getItemId() == R.id.share_menu_destination)
            || (item.getItemId() == R.id.overflow_share_destination) || (item.getItemId() == 23020)) {
        // System.out.println("share destination pressed ID=" + item.getItemId());
        // ------------
        // ------------
        // share the current destination with your friends
        String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
        if (current_target_string2.equals("x:x")) {
            Log.e("Navit", "no target set!");
        } else {
            try {
                String tmp[] = current_target_string2.split(":", 2);

                if (Navit.OSD_route_001.arriving_time_valid) {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
                } else {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), "", true);
                }

            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with target!");
            }
        }
        return true;
    } else if (item.getItemId() == R.id.item_download_menu_button) {
        // System.out.println("download icon pressed(1) ID=" + item.getItemId());

        Intent mapdownload_cancel_activity = new Intent(this, ZANaviDownloadMapCancelActivity.class);
        mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        startActivity(mapdownload_cancel_activity);

        return true;
    } else if ((item.getItemId() == R.id.share_menu_location)
            || (item.getItemId() == R.id.overflow_share_location) || (item.getItemId() == 23000)) {
        // System.out.println("share location pressed ID=" + item.getItemId());
        // ------------
        // ------------
        // share the current location with your friends
        location_coords cur_target = new location_coords();
        try {
            geo_coord tmp = get_current_vehicle_position();
            cur_target.lat = tmp.Latitude;
            cur_target.lon = tmp.Longitude;

            if ((cur_target.lat == 0.0) && (cur_target.lon == 0.0)) {
                cur_target = NavitVehicle.get_last_known_pos();
            }
        } catch (Exception e) {
            cur_target = null;
            try {
                cur_target = NavitVehicle.get_last_known_pos();
            } catch (Exception e2) {
                cur_target = null;
            }
        }

        if (cur_target == null) {
            Log.e("Navit", "no location found!");
        } else {
            try {
                share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon),
                        Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with location!");
            }
        }
        return true;
    } else if ((item.getItemId() == R.id.item_settings_menu_button)
            || (item.getItemId() == R.id.overflow_settings) || (item.getItemId() == 490)) {
        // open settings menu
        Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
        startActivity(settingsActivity);

        return true;
    } else if (item.getItemId() == R.id.search_menu_offline) {
        // ok startup address search activity (offline binfile search)
        Navit.use_index_search = Navit.allow_use_index_search();
        Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
        search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent2.putExtra("address_string", Navit_last_address_search_string);
        search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent2.putExtra("type", "offline");
        search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);

        String pm_temp2 = "0";
        if (Navit_last_address_partial_match) {
            pm_temp2 = "1";
        }

        search_intent2.putExtra("partial_match", pm_temp2);

        Navit.use_index_search = Navit.allow_use_index_search();
        if (Navit.use_index_search) {
            this.startActivityForResult(search_intent2, NavitAddressResultList_id);
        } else {
            this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
        }

        return true;
    } else if (item.getItemId() == R.id.search_menu_online) {
        // ok startup address search activity (online google maps search)
        Navit.use_index_search = false;
        Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
        search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent.putExtra("address_string", Navit_last_address_search_string);
        //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent.putExtra("type", "online");
        String pm_temp = "0";
        if (Navit_last_address_partial_match) {
            pm_temp = "1";
        }
        search_intent.putExtra("partial_match", pm_temp);
        this.startActivityForResult(search_intent, NavitAddressSearch_id_online);

        return true;
    } else if (item.getItemId() == R.id.item_endnavigation_menu_button) {
        // stop navigation (this menu should only appear when navigation is actually on!)
        NavitGraphics.deactivate_nav_wakelock();
        Message msg2 = new Message();
        Bundle b2 = new Bundle();
        b2.putInt("Callback", 7);
        msg2.setData(b2);
        NavitGraphics.callback_handler.sendMessage(msg2);
        Log.e("Navit", "stop navigation");

        if (p.PREF_enable_debug_write_gpx) {
            NavitVehicle.speech_recording_end();
        }

        // redraw all OSD elements
        Navit.OSD_route_001.arriving_time_valid = false;
        Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
        Navit.OSD_route_001.driving_distance_to_target_valid = false;
        Navit.OSD_nextturn.nextturn_distance_valid = false;
        Navit.OSD_nextturn.nextturn_image_valid = false;
        Navit.OSD_compass.direct_distance_to_target_valid = false;
        NavitGraphics.OSD_new.postInvalidate();

        return true;
    } else if (item.getItemId() == R.id.item_recentdest_menu_button) {
        // show recent destination list
        Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
        this.startActivityForResult(i2, Navit.NavitRecentDest_id);

        return true;
    } else if (item.getItemId() == R.id.overflow_zoom_to_route) {
        return onOptionsItemSelected_wrapper(11);
    } else if (item.getItemId() == R.id.overflow_donate_item) {
        return onOptionsItemSelected_wrapper(26);
    } else if (item.getItemId() == R.id.overflow_donate_bitcoins_item) {
        return onOptionsItemSelected_wrapper(27);
    } else if (item.getItemId() == R.id.overflow_exit) {
        return onOptionsItemSelected_wrapper(99);
    } else if (item.getItemId() == R.id.overflow_toggle_poi) {
        return onOptionsItemSelected_wrapper(5);
    } else if (item.getItemId() == R.id.overflow_announcer_on) {
        return onOptionsItemSelected_wrapper(13);
    } else if (item.getItemId() == R.id.overflow_announcer_off) {
        return onOptionsItemSelected_wrapper(12);
    } else if (item.getItemId() == R.id.overflow_download_maps) {
        return onOptionsItemSelected_wrapper(3);
    } else if (item.getItemId() == R.id.overflow_delete_maps) {
        return onOptionsItemSelected_wrapper(8);
    } else if (item.getItemId() == R.id.overflow_maps_age) {
        return onOptionsItemSelected_wrapper(17);
    } else if (item.getItemId() == R.id.overflow_coord_dialog) {
        return onOptionsItemSelected_wrapper(19);
    } else if (item.getItemId() == R.id.overflow_add_traffic_block) {
        return onOptionsItemSelected_wrapper(21);
    } else if (item.getItemId() == R.id.overflow_clear_traffic_block) {
        return onOptionsItemSelected_wrapper(22);
    } else if (item.getItemId() == R.id.overflow_convert_gpx_file) {
        return onOptionsItemSelected_wrapper(20);
    } else if (item.getItemId() == R.id.overflow_clear_gpx_map) {
        return onOptionsItemSelected_wrapper(23);
    } else if (item.getItemId() == R.id.overflow_replay_gps_file) {
        return onOptionsItemSelected_wrapper(28);
    } else if (item.getItemId() == R.id.overflow_yaml_tests) {
        return onOptionsItemSelected_wrapper(609);
    } else if (item.getItemId() == R.id.overflow_demo_v_normal) {
        return onOptionsItemSelected_wrapper(601);
    } else if (item.getItemId() == R.id.overflow_demo_v_fast) {
        return onOptionsItemSelected_wrapper(604);
    } else if (item.getItemId() == R.id.overflow_speech_texts) {
        return onOptionsItemSelected_wrapper(602);
    } else if (item.getItemId() == R.id.overflow_nav_commands) {
        return onOptionsItemSelected_wrapper(603);
    } else if (item.getItemId() == R.id.overflow_toggle_route_graph) {
        return onOptionsItemSelected_wrapper(605);
    } else if (item.getItemId() == R.id.overflow_export_map_points_to_sdcard) {
        return onOptionsItemSelected_wrapper(607);
    } else if (item.getItemId() == R.id.overflow_import_map_points_from_sdcard) {
        return onOptionsItemSelected_wrapper(608);
    } else if (item.getItemId() == R.id.overflow_send_feedback) {
        return onOptionsItemSelected_wrapper(24);
    } else if (item.getItemId() == R.id.overflow_online_help) {
        return onOptionsItemSelected_wrapper(16);
    } else if (item.getItemId() == R.id.overflow_about) {
        return onOptionsItemSelected_wrapper(29);
    } else if (item.getItemId() == R.id.overflow_target_in_gmaps) {
        return onOptionsItemSelected_wrapper(15);
    }
    //      else
    //      {
    //         return onOptionsItemSelected_wrapper(item.getItemId());
    //      }

    return false;
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@SuppressLint("NewApi")
public boolean onOptionsItemSelected_wrapper(int id) {
    // Handle item selection
    switch (id) {
    case 1:// www . ja v  a  2  s  .  co m
        // zoom in
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 1);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        // if we zoom, hide the bubble
        if (N_NavitGraphics.NavitAOverlay != null) {
            N_NavitGraphics.NavitAOverlay.hide_bubble();
        }
        Log.e("Navit", "onOptionsItemSelected -> zoom in");
        break;
    case 2:
        // zoom out
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 2);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        // if we zoom, hide the bubble
        if (N_NavitGraphics.NavitAOverlay != null) {
            N_NavitGraphics.NavitAOverlay.hide_bubble();
        }
        Log.e("Navit", "onOptionsItemSelected -> zoom out");
        break;
    case 3:
        // map download menu
        Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
        this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
        break;
    case 5:
        toggle_poi_pref();
        set_poi_layers();
        draw_map();
        break;
    case 6:
        // ok startup address search activity (online google maps search)
        Navit.use_index_search = false;
        Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
        search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent.putExtra("address_string", Navit_last_address_search_string);
        //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent.putExtra("type", "online");
        String pm_temp = "0";
        if (Navit_last_address_partial_match) {
            pm_temp = "1";
        }
        search_intent.putExtra("partial_match", pm_temp);
        this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
        break;
    case 7:
        // ok startup address search activity (offline binfile search)
        Navit.use_index_search = Navit.allow_use_index_search();
        Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
        search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent2.putExtra("address_string", Navit_last_address_search_string);
        search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent2.putExtra("type", "offline");
        search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);

        String pm_temp2 = "0";
        if (Navit_last_address_partial_match) {
            pm_temp2 = "1";
        }

        search_intent2.putExtra("partial_match", pm_temp2);
        this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
        break;
    case 8:
        // map delete menu
        Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
        this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
        break;
    case 9:
        // stop navigation (this menu should only appear when navigation is actually on!)
        Message msg2 = new Message();
        Bundle b2 = new Bundle();
        b2.putInt("Callback", 7);
        msg2.setData(b2);
        NavitGraphics.callback_handler.sendMessage(msg2);
        Log.e("Navit", "stop navigation");
        break;
    case 10:
        // open settings menu
        Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
        startActivity(settingsActivity);
        break;
    case 11:
        //zoom_to_route
        zoom_to_route();
        break;
    case 12:

        // --------- make app crash ---------
        // --------- make app crash ---------
        // --------- make app crash ---------
        // ** // DEBUG // ** // crash_app_java(1);
        // ** // DEBUG // ** // crash_app_C();
        // --------- make app crash ---------
        // --------- make app crash ---------
        // --------- make app crash ---------

        // announcer off
        Navit_Announcer = false;
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 34);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        try {
            invalidateOptionsMenu();
        } catch (Exception e) {
        }
        break;
    case 13:
        // announcer on
        Navit_Announcer = true;
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 35);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        try {
            invalidateOptionsMenu();
        } catch (Exception e) {
        }
        break;
    case 14:
        // show recent destination list
        Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
        this.startActivityForResult(i2, Navit.NavitRecentDest_id);
        break;
    case 15:
        // show current target on googlemaps
        String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
        // Log.e("Navit", "got target  1: "+current_target_string);
        if (current_target_string.equals("x:x")) {
            Log.e("Navit", "no target set!");
        } else {
            try {
                String tmp[] = current_target_string.split(":", 2);
                googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with target!");
            }
        }
        break;
    case 16:
        // show online manual
        Log.e("Navit", "user wants online help, show the website lang="
                + NavitTextTranslations.main_language.toLowerCase());
        // URL to ZANavi Manual (in english language)
        String url = "http://zanavi.cc/index.php/Manual";
        if (FDBL) {
            url = "http://fd.zanavi.cc/manual";
        }
        if (NavitTextTranslations.main_language.toLowerCase().equals("de")) {
            // show german manual
            url = "http://zanavi.cc/index.php/Manual/de";
            if (FDBL) {
                url = "http://fd.zanavi.cc/manualde";
            }
        }

        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
        break;
    case 17:
        // show age of maps (online)
        Intent i3 = new Intent(Intent.ACTION_VIEW);
        i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
        startActivity(i3);
        break;
    case 18:
        Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
        //intent_latlon.setAction("android.intent.action.POINTPICK");
        intent_latlon.setPackage("com.cruthu.latlongcalc1");
        intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
        //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
        try {
            startActivity(intent_latlon);
        } catch (Exception e88) {
            e88.printStackTrace();
            // show install page
            try {
                // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
                String urlx = "market://details?id=com.cruthu.latlongcalc1";
                Intent ix = new Intent(Intent.ACTION_VIEW);
                ix.setData(Uri.parse(urlx));
                startActivity(ix);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        break;
    case 19:
        // GeoCoordEnterDialog
        Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
        this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
        break;
    case 20:
        // convert GPX file
        Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
        File a = new File(p.PREF_last_selected_dir_gpxfiles);
        try {
            // convert the "/../" in the path to normal absolut dir
            intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
            //can user select directories or not
            intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
            // disable the "new" button
            intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
            //alternatively you can set file filter
            //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
            startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        break;
    case 21:
        // add traffic block (like blocked road, or construction site) at current location of crosshair
        try {
            String traffic = "";
            if (Navit.GFX_OVERSPILL) {
                traffic = NavitGraphics.CallbackGeoCalc(7,
                        (int) (NavitGraphics.Global_dpi_factor
                                * (NavitGraphics.mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill)),
                        (int) (NavitGraphics.Global_dpi_factor
                                * (NavitGraphics.mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill)));
            } else {
                traffic = NavitGraphics.CallbackGeoCalc(7,
                        (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2),
                        (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
            }

            // System.out.println("traffic=" + traffic);
            File traffic_file_dir = new File(MAP_FILENAME_PATH);
            traffic_file_dir.mkdirs();
            File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
            FileOutputStream fOut = null;
            OutputStreamWriter osw = null;
            try {
                fOut = new FileOutputStream(traffic_file, true);
                osw = new OutputStreamWriter(fOut);
                osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
                osw.write(traffic); // item coordinates
                osw.close();
                fOut.close();
            } catch (Exception ef) {
                ef.printStackTrace();
            }

            // update route, if a route is set
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 73);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case 22:
        // clear all traffic blocks
        try {
            File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
            traffic_file.delete();

            // update route, if a route is set
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 73);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
        break;
    case 23:
        // clear all GPX maps
        try {
            File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
            gpx_file.delete();

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
        break;
    case 24:
        // show feedback form
        Intent i4 = new Intent(this, NavitFeedbackFormActivity.class);
        this.startActivityForResult(i4, Navit.NavitSendFeedback_id);
        break;
    case 25:
        // share the current destination with your friends         
        String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
        if (current_target_string2.equals("x:x")) {
            Log.e("Navit", "no target set!");
        } else {
            try {
                String tmp[] = current_target_string2.split(":", 2);

                if (Navit.OSD_route_001.arriving_time_valid) {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
                } else {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), "", true);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with target!");
            }
        }
        break;
    case 26:
        // donate
        Log.e("Navit", "start donate app");
        donate();
        break;
    case 27:
        // donate
        Log.e("Navit", "donate bitcoins");
        donate_bitcoins();
        break;
    case 28:
        // replay GPS file
        Intent intent771 = new Intent(getBaseContext(), FileDialog.class);
        File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR);
        try {
            // convert the "/../" in the path to normal absolut dir
            intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath());
            //can user select directories or not
            intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
            // disable the "new" button
            intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
            //alternatively you can set file filter
            intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
            startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        break;
    case 29:
        // About Screen
        Intent it002 = new Intent(this, ZANaviAboutPage.class);
        this.startActivityForResult(it002, Navit.ZANaviAbout_id);
        break;
    case 88:
        // dummy entry, just to make "breaks" in the menu
        break;
    case 601:
        // DEBUG: activate demo vehicle and set position to position to screen center

        Navit.DemoVehicle = true;

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 101);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        final Thread demo_v_001 = new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000); // wait 1 seconds before we start

                    try {
                        float lat = 0;
                        float lon = 0;

                        String lat_lon = "";
                        if (Navit.GFX_OVERSPILL) {
                            lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor
                                    * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill),
                                    NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2
                                            + NavitGraphics.mCanvasHeight_overspill));
                        } else {
                            lat_lon = NavitGraphics.CallbackGeoCalc(1,
                                    NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2,
                                    NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
                        }
                        String tmp[] = lat_lon.split(":", 2);
                        //System.out.println("tmp=" + lat_lon);
                        lat = Float.parseFloat(tmp[0]);
                        lon = Float.parseFloat(tmp[1]);
                        //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
                        Location l = null;
                        l = new Location("ZANavi Demo 001");
                        l.setLatitude(lat);
                        l.setLongitude(lon);
                        l.setBearing(0.0f);
                        l.setSpeed(0);
                        l.setAccuracy(4.0f); // accuracy 4 meters
                        // NavitVehicle.update_compass_heading(0.0f);
                        NavitVehicle.set_mock_location__fast(l);
                    } catch (Exception e) {
                    }

                    Message msg = new Message();
                    Bundle b = new Bundle();
                    b.putInt("Callback", 52);
                    b.putString("s", "45"); // speed in km/h of Demo-Vehicle
                    // b.putString("s", "20");

                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);
                } catch (Exception e) {
                }
            }
        };
        demo_v_001.start();

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 51);

        if (Navit.GFX_OVERSPILL) {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
        } else {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
        }
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        break;
    case 602:
        // DEBUG: toggle textview with spoken and translated string (to help with translation)
        try {
            if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) {
                NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
                NavitGraphics.NavitMsgTv2_.setEnabled(false);
                NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE);
                NavitGraphics.NavitMsgTv2sc_.setEnabled(false);
            } else {
                NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
                NavitGraphics.NavitMsgTv2sc_.setEnabled(true);
                NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
                NavitGraphics.NavitMsgTv2_.setEnabled(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case 603:
        // DEBUG: show all possible navigation commands (also translated)
        NavitGraphics.generate_all_speech_commands();
        break;
    case 604:
        // DEBUG: activate FAST driving demo vehicle and set position to screen center

        Navit.DemoVehicle = true;

        msg = new Message();

        b = new Bundle();
        b.putInt("Callback", 52);
        b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 51);
        if (Navit.GFX_OVERSPILL) {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
        } else {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
        }
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        try {
            float lat = 0;
            float lon = 0;

            lat = 0;
            lon = 0;
            String lat_lon = "";
            if (Navit.GFX_OVERSPILL) {
                lat_lon = NavitGraphics.CallbackGeoCalc(1,
                        NavitGraphics.Global_dpi_factor
                                * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill),
                        NavitGraphics.Global_dpi_factor
                                * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill));
            } else {
                lat_lon = NavitGraphics.CallbackGeoCalc(1,
                        NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2,
                        NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
            }

            String tmp[] = lat_lon.split(":", 2);
            //System.out.println("tmp=" + lat_lon);
            lat = Float.parseFloat(tmp[0]);
            lon = Float.parseFloat(tmp[1]);
            //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
            Location l = null;
            l = new Location("ZANavi Demo 001");
            l.setLatitude(lat);
            l.setLongitude(lon);
            l.setBearing(0.0f);
            l.setSpeed(0);
            l.setAccuracy(4.0f); // accuracy 4 meters
            // NavitVehicle.update_compass_heading(0.0f);
            NavitVehicle.set_mock_location__fast(l);
        } catch (Exception e) {
        }

        break;
    case 605:
        // DEBUG: toggle Routgraph on/off
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 71);
        Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
        b.putString("s", "" + Navit.Routgraph_enabled);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        break;
    case 606:
        // DEBUG: spill contents of index file(s)
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 83);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        break;
    case 607:
        export_map_points_to_sdcard();
        break;
    case 608:
        import_map_points_from_sdcard();
        break;
    case 609:
        // run yaml tests
        new Thread() {
            public void run() {
                try {
                    ZANaviDebugReceiver.DR_run_all_yaml_tests();
                } catch (Exception e) {
                }
            }
        }.start();
        break;
    case 99:
        try {
            if (wl_navigating != null) {
                //if (wl_navigating.isHeld())
                //{
                wl_navigating.release();
                Log.e("Navit", "WakeLock Nav: release 1");
                //}
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        // exit
        this.onPause();
        this.onStop();
        this.exit();
        //msg = new Message();
        //b = new Bundle();
        //b.putInt("Callback", 5);
        //b.putString("cmd", "quit();");
        //msg.setData(b);
        //N_NavitGraphics.callback_handler.sendMessage(msg);
        break;
    }
    return true;
}

From source file:carnero.cgeo.cgBase.java

public void dropCache(cgeoapplication app, Activity activity, cgCache cache, Handler handler) {
    try {/*from   w w w.  j a  v  a 2  s  . c o m*/
        app.markDropped(cache.geocode);
        app.removeCacheFromCache(cache.geocode);

        handler.sendMessage(new Message());
    } catch (Exception e) {
        Log.e(cgSettings.tag, "cgBase.dropCache: " + e.toString());
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.e("Navit", "onActivityResult");
    switch (requestCode) {
    case Navit.ZANaviIntro_id:
        try {/*from   w  ww  .  jav a 2s  .c  o m*/
            PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(PREF_KEY_FIRST_START, false)
                    .commit();
        } catch (Exception e) {
            e.printStackTrace();
        }

    case Navit.NavitGPXConvChooser_id:
        try {
            Log.e("Navit", "onActivityResult 001");
            if (resultCode == AppCompatActivity.RESULT_OK) {
                String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
                convert_gpx_file_real(in_);
            }
        } catch (Exception e77) {
            e77.printStackTrace();
        }
        break;

    case NavitReplayFileConvChooser_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                final String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
                final Thread replay_gpx_file_001 = new Thread() {
                    @Override
                    public void run() {
                        try {
                            Thread.sleep(2000); // wait 2 seconds before we start
                            String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN)
                                    .format(new Date());
                            ZANaviDebugReceiver.DR_replay_gps_file(in_, date);
                        } catch (Exception e) {
                        }
                    }
                };
                replay_gpx_file_001.start();
            }
        } catch (Exception e77) {
            e77.printStackTrace();
        }
        break;

    case Navit.NavitDeleteSecSelectMap_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                if (!data.getStringExtra("selected_id")
                        .equalsIgnoreCase(NavitDeleteSelectMapActivity.CANCELED_ID)) {
                    System.out.println("Global_Location_update_not_allowed = 1");
                    Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!

                    // remove all sdcard maps
                    Message msg = new Message();
                    Bundle b = new Bundle();
                    b.putInt("Callback", 19);
                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);

                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                    }

                    Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
                    String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer
                            .parseInt(data.getStringExtra("selected_id"))];
                    Log.d("Navit", "delete map full line=" + map_full_line);

                    String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
                    System.out.println("del map file :" + del_map_name);
                    // remove from cat file
                    NavitMapDownloader.remove_from_cat_file(map_full_line);
                    // remove from disk
                    File del_map_name_file = new File(del_map_name);
                    del_map_name_file.delete();
                    for (int jkl = 1; jkl < 51; jkl++) {
                        File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
                        del_map_name_fileSplit.delete();
                    }
                    // also remove index file
                    File del_map_name_file_idx = new File(del_map_name + ".idx");
                    del_map_name_file_idx.delete();
                    // remove also any MD5 files for this map that may be on disk
                    try {
                        String tmp = map_full_line.split(":", 2)[1];
                        if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN)) {
                            tmp = tmp.replace("*", "");
                            tmp = tmp.replace("/", "");
                            tmp = tmp.replace("\\", "");
                            tmp = tmp.replace(" ", "");
                            tmp = tmp.replace(">", "");
                            tmp = tmp.replace("<", "");
                            System.out
                                    .println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
                            File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
                            md5_final_filename.delete();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    // remove map, and zoom out
                    // ***** onStop();
                    // ***** onCreate(getIntent().getExtras());

                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                    }

                    // add all sdcard maps
                    msg = new Message();
                    b = new Bundle();
                    b.putInt("Callback", 20);
                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);

                    final Thread zoom_to_route_004 = new Thread() {
                        int wait = 1;
                        int count = 0;
                        int max_count = 60;

                        @Override
                        public void run() {
                            while (wait == 1) {
                                try {
                                    if ((NavitGraphics.navit_route_status == 17)
                                            || (NavitGraphics.navit_route_status == 33)) {
                                        zoom_to_route();
                                        wait = 0;
                                    } else {
                                        wait = 1;
                                    }

                                    count++;
                                    if (count > max_count) {
                                        wait = 0;
                                    } else {
                                        Thread.sleep(400);
                                    }
                                } catch (Exception e) {
                                }
                            }
                        }
                    };
                    zoom_to_route_004.start();

                    System.out.println("Global_Location_update_not_allowed = 0");
                    Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
                }
            }
        } catch (Exception e) {
            Log.d("Navit", "error on onActivityResult 3");
            e.printStackTrace();
        }
        break;
    case Navit.NavitDownloaderPriSelectMap_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                try {
                    // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
                    // set map id to download
                    Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer
                            .parseInt(data.getStringExtra("selected_id"))];
                    // show the map download progressbar, and download the map
                    if (Navit.download_map_id > -1) {
                        // --------- start a map download (highest level) ---------
                        // --------- start a map download (highest level) ---------
                        // --------- start a map download (highest level) ---------
                        // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app

                        // new method in service
                        Message msg = progress_handler.obtainMessage();
                        // Bundle b = new Bundle();
                        msg.what = 22;
                        progress_handler.sendMessage(msg);

                        // show license for OSM maps
                        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
                        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors",
                                Toast.LENGTH_SHORT).show();
                        // --------- start a map download (highest level) ---------
                        // --------- start a map download (highest level) ---------
                        // --------- start a map download (highest level) ---------
                    }
                } catch (NumberFormatException e) {
                    Log.d("Navit", "NumberFormatException selected_id");
                }
            } else {
                // user pressed back key
            }
        } catch (Exception e) {
            Log.d("Navit", "error on onActivityResult");
            e.printStackTrace();
        }
        break;
    case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
        break;
    case ZANaviVoiceInput_id:
        if (resultCode == AppCompatActivity.RESULT_OK) {
            try {
                String addr = data.getStringExtra("address_string");
                double lat = data.getDoubleExtra("lat", 0);
                double lon = data.getDoubleExtra("lon", 0);
                String hn = "";

                // save last address entry string
                p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr,
                        STREET_SEARCH_STRINGS_SAVE_COUNT);
                saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);

                Boolean partial_match = true;
                Navit.use_index_search = false;

                Navit_last_address_partial_match = partial_match;
                Navit_last_address_search_string = addr;
                Navit_last_address_hn_string = hn;

                Navit_last_address_full_file_search = false;

                // clear results
                Navit.NavitAddressResultList_foundItems.clear();
                Navit.Navit_Address_Result_double_index.clear();
                Navit.NavitSearchresultBarIndex = -1;
                Navit.NavitSearchresultBar_title = "";
                Navit.NavitSearchresultBar_text = "";
                Navit.search_results_towns = 0;
                Navit.search_results_streets = 0;
                Navit.search_results_streets_hn = 0;
                Navit.search_results_poi = 0;

                if (addr.equals("")) {
                    // empty search string entered
                    Toast.makeText(getApplicationContext(), Navit.get_text("No search string"),
                            Toast.LENGTH_LONG).show(); //TRANS
                } else {
                    System.out.println("Global_Location_update_not_allowed = 1");
                    Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!

                    // --> this still does the search // google_online_search_and_set_destination(addr);
                    result_set_destination(lat, lon, addr);

                    System.out.println("Global_Location_update_not_allowed = 0");
                    Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
                }

            } catch (Exception e) {

            }
        }
        break;
    case NavitAddressSearch_id_online:
    case NavitAddressSearch_id_offline:
        Log.e("Navit", "NavitAddressSearch_id_:001");
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                try {
                    String addr = data.getStringExtra("address_string");
                    String hn = "";
                    try {
                        // only from offline mask!
                        hn = data.getStringExtra("hn_string");
                    } catch (Exception e) {
                        hn = "";
                    }

                    // save last address entry string
                    p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr,
                            STREET_SEARCH_STRINGS_SAVE_COUNT);
                    saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);

                    Boolean partial_match = false;
                    try {
                        // only from offline mask!
                        partial_match = data.getStringExtra("partial_match").equals("1");
                    } catch (Exception e) {
                    }

                    Message msg2 = new Message();
                    Bundle b2 = new Bundle();
                    b2.putInt("Callback", 44);
                    msg2.setData(b2);
                    NavitGraphics.callback_handler.sendMessage(msg2);

                    if (requestCode == NavitAddressSearch_id_offline) {
                        search_hide_duplicates = false;
                        try {
                            Boolean hide_dup = data.getStringExtra("hide_dup").equals("1");
                            if (hide_dup) {
                                search_hide_duplicates = true;
                                Message msg = new Message();
                                Bundle b = new Bundle();
                                b.putInt("Callback", 45);
                                msg.setData(b);
                                NavitGraphics.callback_handler.sendMessage(msg);
                            }
                        } catch (Exception e) {
                        }

                        if (Navit.CIDEBUG == 0) {
                            Navit.use_index_search = Navit.allow_use_index_search();
                        }
                    } else {
                        Navit.use_index_search = false;
                    }

                    Navit_last_address_partial_match = partial_match;
                    Navit_last_address_search_string = addr;
                    Navit_last_address_hn_string = hn;

                    try {
                        // only from offline mask!
                        Navit_last_address_full_file_search = data.getStringExtra("full_file_search")
                                .equals("1");
                    } catch (Exception e) {
                        Navit_last_address_full_file_search = false;
                    }

                    try {
                        // only from offline mask!
                        Navit_last_address_search_country_iso2_string = data
                                .getStringExtra("address_country_iso2");

                        Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
                        // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
                        Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
                        p.PREF_search_country = Navit_last_address_search_country_id;
                        setPrefs_search_country();
                    } catch (Exception e) {

                    }

                    // clear results
                    Navit.NavitAddressResultList_foundItems.clear();
                    Navit.Navit_Address_Result_double_index.clear();
                    Navit.NavitSearchresultBarIndex = -1;
                    Navit.NavitSearchresultBar_title = "";
                    Navit.NavitSearchresultBar_text = "";
                    Navit.search_results_towns = 0;
                    Navit.search_results_streets = 0;
                    Navit.search_results_streets_hn = 0;
                    Navit.search_results_poi = 0;

                    if (addr.equals("")) {
                        // empty search string entered
                        Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"),
                                Toast.LENGTH_LONG).show(); //TRANS
                    } else {
                        System.out.println("Global_Location_update_not_allowed = 1");
                        Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!

                        if (requestCode == NavitAddressSearch_id_online) {
                            // online googlemaps search
                            try {
                                Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                            System.out.println("dialog -- 11:003");
                            System.out.println("online googlemaps search");
                            Message msg = progress_handler.obtainMessage();
                            Bundle b = new Bundle();
                            msg.what = 11;
                            b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
                            msg.setData(b);
                            progress_handler.sendMessage(msg);
                        } else if (requestCode == NavitAddressSearch_id_offline) {
                            // offline binfile search

                            if (!Navit.use_index_search) {
                                try {
                                    Log.e("Navit",
                                            "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                // show dialog, and start search for the results
                                // make it indirect, to give our activity a chance to startup
                                // (remember we come straight from another activity and ours is still paused!)
                                System.out.println("dialog -- 11:004");
                                Message msg = progress_handler.obtainMessage();
                                Bundle b = new Bundle();
                                msg.what = 11;
                                b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
                                msg.setData(b);
                                progress_handler.sendMessage(msg);
                            }
                        }
                    }
                } catch (NumberFormatException e) {
                    Log.d("Navit", "NumberFormatException selected_id");
                }
            } else {
                // user pressed back key
                Log.e("Navit", "NavitAddressSearch_id_:900");
            }
        } catch (Exception e) {
            Log.d("Navit", "error on onActivityResult");
            e.printStackTrace();
        }
        Log.e("Navit", "NavitAddressSearch_id_:999");
        break;
    case Navit.NavitAddressResultList_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                try {
                    if (data.getStringExtra("what").equals("view")) {
                        // get the coords for the destination
                        int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));

                        // save last address entry string
                        String addr = data.getStringExtra("address_string");
                        p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr,
                                STREET_SEARCH_STRINGS_SAVE_COUNT);
                        saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx",
                                STREET_SEARCH_STRINGS_SAVE_COUNT);

                        try {
                            Navit.follow_button_off();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }

                        System.out.println("XSOM:009");

                        if (Navit.use_index_search) {
                            show_geo_on_screen_with_zoom_and_delay(
                                    (float) Navit.transform_to_geo_lat(
                                            Navit.NavitAddressResultList_foundItems.get(destination_id).lat),
                                    (float) Navit.transform_to_geo_lon(
                                            Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
                        } else {
                            show_geo_on_screen_with_zoom_and_delay(
                                    Navit.NavitAddressResultList_foundItems.get(destination_id).lat,
                                    Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
                        }
                    } else if (data.getStringExtra("what").equals("set")) {
                        Log.d("Navit", "adress result list id="
                                + Integer.parseInt(data.getStringExtra("selected_id")));

                        // save last address entry string
                        String addr = data.getStringExtra("address_string");
                        p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr,
                                STREET_SEARCH_STRINGS_SAVE_COUNT);
                        saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx",
                                STREET_SEARCH_STRINGS_SAVE_COUNT);

                        // get the coords for the destination
                        int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));

                        String _addr = "";
                        double _lat = 0;
                        double _lon = 0;

                        // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)
                        // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)

                        // ok now set target
                        try {
                            if (Navit.use_index_search) {
                                _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
                                _lat = Navit.transform_to_geo_lat(
                                        Navit.NavitAddressResultList_foundItems.get(destination_id).lat);
                                _lon = Navit.transform_to_geo_lon(
                                        Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
                                //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
                            } else {
                                _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
                                _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat;
                                _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon;
                                //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
                            }
                            // save points
                            //write_map_points();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        route_wrapper(_addr, 0, 0, false, _lat, _lon, true);

                        final Thread zoom_to_route_005 = new Thread() {
                            int wait = 1;
                            int count = 0;
                            int max_count = 60;

                            @Override
                            public void run() {
                                while (wait == 1) {
                                    try {
                                        if ((NavitGraphics.navit_route_status == 17)
                                                || (NavitGraphics.navit_route_status == 33)) {
                                            zoom_to_route();
                                            wait = 0;
                                        } else {
                                            wait = 1;
                                        }

                                        count++;
                                        if (count > max_count) {
                                            wait = 0;
                                        } else {
                                            Thread.sleep(400);
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            }
                        };
                        zoom_to_route_005.start();
                        // zoom_to_route();

                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------
                        if (p.PREF_enable_debug_write_gpx) {
                            write_route_to_gpx_file();
                        }
                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------

                        try {
                            Navit.follow_button_on();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }

                        //                     if (Navit.use_index_search)
                        //                     {
                        //                        show_geo_on_screen((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
                        //                     }
                        //                     else
                        //                     {
                        //                        show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
                        //                     }
                    } else {
                        // -- nothing --
                    }
                } catch (NumberFormatException e) {
                    Log.d("Navit", "NumberFormatException selected_id");
                } catch (Exception e) {

                }
            } else {
                // user pressed back key
            }
        } catch (Exception e) {
            Log.d("Navit", "error on onActivityResult");
            e.printStackTrace();
        }
        break;
    case NavitAddressSearch_id_gmaps:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case NavitAddressSearch_id_sharedest:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {

            }
            Log.d("Navit", "sharedest: finished");
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case NavitGeoCoordEnter_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                // lat lon enter activitiy result

                try {
                    if (data.getStringExtra("what").equals("view")) {
                        // get the coords for the destination
                        float lat = Float.parseFloat(data.getStringExtra("lat"));
                        float lon = Float.parseFloat(data.getStringExtra("lon"));

                        // Log.d("Navit", "coord picker: " + lat);
                        // Log.d("Navit", "coord picker: " + lon);

                        // set nice zoomlevel before we show destination
                        //                     int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
                        //                     //
                        //                     Message msg = new Message();
                        //                     Bundle b = new Bundle();
                        //                     b.putInt("Callback", 33);
                        //                     b.putString("s", Integer.toString(zoom_want));
                        //                     msg.setData(b);
                        //                     try
                        //                     {
                        //                        N_NavitGraphics.callback_handler.sendMessage(msg);
                        //                        Navit.GlobalScaleLevel = zoom_want;
                        //                     }
                        //                     catch (Exception e)
                        //                     {
                        //                        e.printStackTrace();
                        //                     }
                        //                     if (PREF_save_zoomlevel)
                        //                     {
                        //                        setPrefs_zoomlevel();
                        //                     }
                        // set nice zoomlevel before we show destination

                        try {
                            Navit.follow_button_off();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }

                        show_geo_on_screen(lat, lon);
                    } else {
                        // get the coords for the destination
                        float lat = Float.parseFloat(data.getStringExtra("lat"));
                        float lon = Float.parseFloat(data.getStringExtra("lat"));
                        String dest_name = "manual coordinates";

                        // ok now set target
                        try {
                            dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
                            if ((dest_name.equals(" ")) || (dest_name == null)) {
                                dest_name = "manual coordinates";
                            }
                            //                        Navit.remember_destination(dest_name, lat, lon);
                            //                        // save points
                            //                        write_map_points();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        //                     // DEBUG: clear route rectangle list
                        //                     NavitGraphics.route_rects.clear();
                        //
                        //                     if (NavitGraphics.navit_route_status == 0)
                        //                     {
                        //                        Navit.destination_set();
                        //
                        //                        Message msg = new Message();
                        //                        Bundle b = new Bundle();
                        //                        b.putInt("Callback", 3);
                        //                        b.putString("lat", String.valueOf(lat));
                        //                        b.putString("lon", String.valueOf(lon));
                        //                        b.putString("q", dest_name);
                        //                        msg.setData(b);
                        //                        NavitGraphics.callback_handler.sendMessage(msg);
                        //                     }
                        //                     else
                        //                     {
                        //                        Message msg = new Message();
                        //                        Bundle b = new Bundle();
                        //                        b.putInt("Callback", 48);
                        //                        b.putString("lat", String.valueOf(lat));
                        //                        b.putString("lon", String.valueOf(lon));
                        //                        b.putString("q", dest_name);
                        //                        msg.setData(b);
                        //                        NavitGraphics.callback_handler.sendMessage(msg);
                        //                     }
                        //

                        route_wrapper(dest_name, 0, 0, false, lat, lon, true);

                        final Thread zoom_to_route_006 = new Thread() {
                            int wait = 1;
                            int count = 0;
                            int max_count = 60;

                            @Override
                            public void run() {
                                while (wait == 1) {
                                    try {
                                        if ((NavitGraphics.navit_route_status == 17)
                                                || (NavitGraphics.navit_route_status == 33)) {
                                            zoom_to_route();
                                            wait = 0;
                                        } else {
                                            wait = 1;
                                        }

                                        count++;
                                        if (count > max_count) {
                                            wait = 0;
                                        } else {
                                            Thread.sleep(400);
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            }
                        };
                        zoom_to_route_006.start();
                        // zoom_to_route();

                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------
                        if (p.PREF_enable_debug_write_gpx) {
                            write_route_to_gpx_file();
                        }
                        // ---------- DEBUG: write route to file ----------
                        // ---------- DEBUG: write route to file ----------

                        try {
                            Navit.follow_button_on();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }

                        // show_geo_on_screen(lat, lon);
                    }
                } catch (NumberFormatException e) {
                    Log.d("Navit", "NumberFormatException selected_id");
                } catch (Exception e) {

                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case NavitRecentDest_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
                // get the coords for the destination
                int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));

                if (data.getStringExtra("what").equals("view")) {
                    try {
                        Navit.follow_button_off();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }

                    float lat = Navit.map_points.get(destination_id).lat;
                    float lon = Navit.map_points.get(destination_id).lon;
                    show_geo_on_screen_with_zoom_and_delay(lat, lon, 150);
                } else {
                    // ok now set target
                    String dest_name = Navit.map_points.get(destination_id).point_name;
                    float lat = Navit.map_points.get(destination_id).lat;
                    float lon = Navit.map_points.get(destination_id).lon;

                    // System.out.println("XXXXXX:" + lat + " " + lon);

                    route_wrapper(dest_name, 0, 0, false, lat, lon, true);

                    final Thread zoom_to_route_007 = new Thread() {
                        int wait = 1;
                        int count = 0;
                        int max_count = 60;

                        @Override
                        public void run() {
                            while (wait == 1) {
                                try {
                                    if ((NavitGraphics.navit_route_status == 17)
                                            || (NavitGraphics.navit_route_status == 33)) {
                                        zoom_to_route();
                                        wait = 0;
                                    } else {
                                        wait = 1;
                                    }

                                    count++;
                                    if (count > max_count) {
                                        wait = 0;
                                    } else {
                                        Thread.sleep(400);
                                    }
                                } catch (Exception e) {
                                }
                            }
                        }
                    };
                    zoom_to_route_007.start();

                    // ---------- DEBUG: write route to file ----------
                    // ---------- DEBUG: write route to file ----------
                    // ---------- DEBUG: write route to file ----------
                    if (p.PREF_enable_debug_write_gpx) {
                        write_route_to_gpx_file();
                    }
                    // ---------- DEBUG: write route to file ----------
                    // ---------- DEBUG: write route to file ----------

                    try {
                        Navit.follow_button_on();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }

                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;

    case NavitSendFeedback_id:
        try {
            if (resultCode == AppCompatActivity.RESULT_OK) {
                String feedback_text = data.getStringExtra("feedback_text");

                String subject_d_version = "";
                if (Navit_DonateVersion_Installed) {
                    subject_d_version = subject_d_version + "D,";
                }

                if (Navit_Largemap_DonateVersion_Installed) {
                    subject_d_version = subject_d_version + "L,";
                }

                try {
                    int rl = get_reglevel();

                    if (rl > 0) {
                        subject_d_version = "U" + rl + ",";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

                String FD_addon = "";
                if (FDBL) {
                    FD_addon = ",FD";
                }

                sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon
                        + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text);
            }
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"),
                    Toast.LENGTH_SHORT).show(); //TRANS
        }
        break;

    default:
        Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
        try {
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
            // ---------- what is this doing ????? ----------
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    }
    Log.e("Navit", "onActivityResult finished");
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@TargetApi(Build.VERSION_CODES.FROYO)
protected Dialog onCreateDialog(int id) {

    System.out.println("onCreateDialog id=" + id);

    switch (id) {
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
        search_results_wait_offline = new ProgressDialog(this);
        search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait_offline.setTitle("--");
        search_results_wait_offline.setMessage("--");
        search_results_wait_offline.setCancelable(true); // allow to stop search
        search_results_wait_offline.setProgress(0);
        search_results_wait_offline.setMax(10);

        search_results_wait_offline.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                Message msg = new Message();
                Bundle b = new Bundle();
                b.putInt("Callback", 46);
                msg.setData(b);/* ww w.  ja v a 2  s.  co m*/
                try {
                    NavitGraphics.callback_handler.sendMessage(msg);
                } catch (Exception e) {
                }
                Log.e("Navit", "onCancel: search_results_wait offline");
            }
        });

        /*
         * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
         * {
         * public void onClick(DialogInterface dialog, int which)
         * {
         * // Use either finish() or return() to either close the activity or just the dialog
         * return;
         * }
         * });
         */

        DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait offline");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread_offline.stop_me();
            }
        };
        search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
        System.out.println("new SearchResultsThread 001");
        searchresultsThread_offline = new SearchResultsThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        searchresultsThread_offline.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        spinner_thread_offline.start();

        return search_results_wait_offline;
    case Navit.SEARCHRESULTS_WAIT_DIALOG:
        search_results_wait = new ProgressDialog(this);
        search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait.setTitle("--");
        search_results_wait.setMessage("--");
        search_results_wait.setCancelable(false);
        search_results_wait.setProgress(0);
        search_results_wait.setMax(10);

        DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread.stop_me();
            }
        };
        search_results_wait.setOnDismissListener(mOnDismissListener3);
        System.out.println("new SearchResultsThread 002");
        searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
        searchresultsThread.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG);
        spinner_thread.start();

        return search_results_wait;
    case Navit.MAPDOWNLOAD_PRI_DIALOG:
        mapdownloader_dialog_pri = new ProgressDialog(this);
        mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_pri.setTitle("--");
        mapdownloader_dialog_pri.setMessage("--");
        mapdownloader_dialog_pri.setCancelable(false);
        mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
        mapdownloader_dialog_pri.setProgress(0);
        mapdownloader_dialog_pri.setMax(200);

        WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
        dialog_lparams.screenBrightness = 0.1f;
        mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);

        DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow()
                        .getAttributes();
                mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
                dialog.dismiss();
                dialog.cancel();
                progressThread_pri.stop_thread();
            }
        };

        try {
            mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mapdownloader_dialog_pri.dismiss();
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }

        mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
        mapdownloader_pri = new NavitMapDownloader(this);
        progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
        progressThread_pri.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_pri;
    case Navit.MAPDOWNLOAD_SEC_DIALOG:
        mapdownloader_dialog_sec = new ProgressDialog(this);
        mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_sec.setTitle("--");
        mapdownloader_dialog_sec.setMessage("--");

        mapdownloader_dialog_sec.setCancelable(true);
        mapdownloader_dialog_sec.setProgress(0);
        mapdownloader_dialog_sec.setMax(200);
        DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
                dialog.dismiss();
                dialog.cancel();
                progressThread_sec.stop_thread();
            }
        };
        mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
        mapdownloader_sec = new NavitMapDownloader(this);
        progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
        progressThread_sec.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_sec;
    }
    // should never get here!!
    return null;
}

From source file:com.zoffcc.applications.zanavi.Navit.java

public static void follow_button_on() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
    SharedPreferences.Editor editor = prefs.edit();
    Navit.follow_current = Navit.follow_on;
    p.PREF_follow_gps = true;//w w w  .  jav a 2 s .  c o  m
    editor.putBoolean("follow_gps", p.PREF_follow_gps);
    editor.commit();

    // hold all map drawing -----------
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 69);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // hold all map drawing -----------

    msg = Navit_progress_h.obtainMessage();
    b = new Bundle();
    msg.what = 32;
    try {
        Navit_progress_h.sendMessage(msg);
    } catch (Exception e) {
    }

    getPrefs();
    activatePrefs(1);

    // follow mode ON -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 74);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // follow mode ON -----------

    // allow all map drawing -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 70);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // allow all map drawing -----------

    NavitVehicle.set_last_known_pos_fast_provider();

    // JB fix
    //NavitGraphics.NavitAOSDJava_.postInvalidate();
    //System.out.println("xx paint 12 xx");
    NavitGraphics.OSD_new.postInvalidate();
    NavitGraphics.NavitAOverlay_s.postInvalidate();
}

From source file:com.zoffcc.applications.zanavi.Navit.java

public static void follow_button_off() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
    SharedPreferences.Editor editor = prefs.edit();
    Navit.follow_current = Navit.follow_off;
    p.PREF_follow_gps = false;//w w  w . j  a  v  a 2s.  c om
    editor.putBoolean("follow_gps", p.PREF_follow_gps);
    editor.commit();
    getPrefs();
    activatePrefs(1);

    // follow mode OFF -----------
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 75);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // follow mode OFF -----------

    msg = Navit_progress_h.obtainMessage();
    b = new Bundle();
    msg.what = 32;
    try {
        Navit_progress_h.sendMessage(msg);
    } catch (Exception e) {
    }

    // JB fix
    //NavitGraphics.NavitAOSDJava_.postInvalidate();
    //System.out.println("xx paint 13 xx");
    NavitGraphics.OSD_new.postInvalidate();
    NavitGraphics.NavitAOverlay_s.postInvalidate();

}

From source file:com.zoffcc.applications.zanavi.Navit.java

public static void toggle_follow_button() {
    // the "red needle" OSD calls this function only!!
    //Log.e("NavitVehicle", "toggle_follow_button");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
    SharedPreferences.Editor editor = prefs.edit();
    if (p.PREF_follow_gps) {
        Navit.follow_current = Navit.follow_off;
        p.PREF_follow_gps = false;/*from w  w w. ja v a  2s. c om*/

        // follow mode OFF -----------
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 75);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        }

        catch (Exception e) {
            e.printStackTrace();
        }
        // follow mode OFF -----------
    } else {
        Navit.follow_current = Navit.follow_on;
        p.PREF_follow_gps = true;

        // follow mode ON -----------
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 74);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // follow mode ON -----------
    }
    editor.putBoolean("follow_gps", p.PREF_follow_gps);
    editor.commit();
    //if (!PREF_follow_gps)
    //{
    //   // no compass turning without follow mode!
    //   PREF_use_compass_heading_base = false;
    //}
    //if (!PREF_use_compass_heading_base)
    //{
    //   // child is always "false" when parent is "false" !!
    //   PREF_use_compass_heading_always = false;
    //}

    Message msg = Navit_progress_h.obtainMessage();
    Bundle b = new Bundle();
    msg.what = 32;
    try {
        Navit_progress_h.sendMessage(msg);
    } catch (Exception e) {
    }

    // hold all map drawing -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 69);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // hold all map drawing -----------

    getPrefs();
    activatePrefs(1);

    // allow all map drawing -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 70);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // allow all map drawing -----------

    NavitVehicle.set_last_known_pos_fast_provider();

    // JB fix
    //NavitGraphics.NavitAOSDJava_.postInvalidate();
    //System.out.println("xx paint 14 xx");
    NavitGraphics.OSD_new.postInvalidate();
    NavitGraphics.NavitAOverlay_s.postInvalidate();
}