示例#1
0
 @SuppressWarnings("unchecked")
 @Override
 public boolean onPreferenceClick(Preference preference) {
   if (preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)) {
     boolean empty = getMyApplication().getResourceManager().getIndexFileNames().isEmpty();
     if (empty) {
       File folder =
           getMyApplication().getSettings().extendOsmandPath(ResourceManager.BACKUP_PATH);
       if (folder.exists() && folder.isDirectory()) {
         String[] l = folder.list();
         empty = l == null || l.length == 0;
       }
     }
     if (empty) {
       startActivity(new Intent(this, OsmandIntents.getDownloadIndexActivity()));
     } else {
       startActivity(new Intent(this, OsmandIntents.getLocalIndexActivity()));
     }
     return true;
   } else if (preference == bidforfix) {
     startActivity(new Intent(this, OsmandBidForFixActivity.class));
     return true;
   } else if (preference == plugins) {
     startActivity(new Intent(this, PluginsActivity.class));
     return true;
   } else if (preference == avoidRouting) {
     showBooleanSettings(
         new String[] {
           getString(R.string.avoid_toll_roads),
           getString(R.string.avoid_ferries),
           getString(R.string.avoid_unpaved),
           getString(R.string.avoid_motorway)
         },
         new OsmandPreference[] {
           osmandSettings.AVOID_TOLL_ROADS,
           osmandSettings.AVOID_FERRIES,
           osmandSettings.AVOID_UNPAVED_ROADS,
           osmandSettings.AVOID_MOTORWAY
         });
     return true;
   } else if (preference == showAlarms) {
     showBooleanSettings(
         new String[] {
           getString(R.string.show_speed_limits),
           getString(R.string.show_cameras),
           getString(R.string.show_lanes)
         },
         new OsmandPreference[] {
           osmandSettings.SHOW_SPEED_LIMITS, osmandSettings.SHOW_CAMERAS, osmandSettings.SHOW_LANES
         });
     return true;
   }
   return false;
 }