Fix navigate action menu & put read time out for tiles

This commit is contained in:
vshcherb 2014-03-08 15:50:07 +01:00
parent 7da3962f2d
commit 016f4acd3b
4 changed files with 61 additions and 63 deletions

View file

@ -27,7 +27,8 @@ public class MapTileDownloader {
public static int TILE_DOWNLOAD_THREADS = 4;
public static int TILE_DOWNLOAD_SECONDS_TO_WORK = 25;
public static final long TIMEOUT_AFTER_EXCEEDING_LIMIT_ERRORS = 15000;
public static final int TILE_DOWNLOAD_MAX_ERRORS_PER_TIMEOUT = 25;
public static final int TILE_DOWNLOAD_MAX_ERRORS_PER_TIMEOUT = 50;
private static final int CONNECTION_TIMEOUT = 10000;
private static MapTileDownloader downloader = null;
@ -187,7 +188,8 @@ public class MapTileDownloader {
URL url = new URL(request.url);
URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", USER_AGENT); //$NON-NLS-1$
connection.setConnectTimeout(35000);
connection.setConnectTimeout(CONNECTION_TIMEOUT);
connection.setReadTimeout(CONNECTION_TIMEOUT);
BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream(), 8 * 1024);
FileOutputStream stream = null;
try {

View file

@ -170,6 +170,7 @@ public class RoutingConfiguration {
}
}
}
is.close();
return config;
}

View file

@ -282,30 +282,6 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
}
}
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// ActionBar.TabListener tl = new ActionBar.TabListener() {
//
// @Override
// public void onTabSelected(Tab tab, android.support.v4.app.FragmentTransaction ft) {
// osmandSettings.APPLICATION_MODE.set(modes.get(tab.getPosition()));
// createUI();
// updateAllSettings();
//
// }
//
// @Override
// public void onTabUnselected(Tab tab, android.support.v4.app.FragmentTransaction ft) {
// }
//
// @Override
// public void onTabReselected(Tab tab, android.support.v4.app.FragmentTransaction ft) {
// }
//
// };
// for (ApplicationMode a : modes) {
// Tab t = getSupportActionBar().newTab().setText(a.toHumanString(getMyApplication())).setTabListener(tl);
// getSupportActionBar().addTab(t);
// }
List<String> s = new ArrayList<String>();
for (ApplicationMode a : modes) {
s.add(a.toHumanString(getMyApplication()));
@ -348,7 +324,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
protected void profileDialog() {
Builder b = new AlertDialog.Builder(this);
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
View v = NavigateAction.prepareAppModeView(this, selected, false, null, false,
View v = NavigateAction.prepareAppModeView(this, selected, false, null, true,
new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -397,6 +397,7 @@ public class NavigateAction {
ViewGroup parent, final boolean singleSelection, final View.OnClickListener onClickListener) {
LinearLayout ll = (LinearLayout) a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
final ToggleButton[] buttons = createToggles(values, ll, a);
final boolean[] selectionChangeLoop = new boolean[] {false};
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] != null) {
final int ind = i;
@ -406,16 +407,42 @@ public class NavigateAction {
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (selectionChangeLoop[0]) {
return;
}
selectionChangeLoop[0] = true;
try {
handleSelection(values, selected, singleSelection, buttons, ind, buttonAppMode, isChecked);
if (onClickListener != null) {
onClickListener.onClick(null);
}
} finally {
selectionChangeLoop[0] = false;
}
}
});
}
}
return ll;
}
private static void handleSelection(final List<ApplicationMode> values,
final Set<ApplicationMode> selected, final boolean singleSelection,
final ToggleButton[] buttons, final int ind, final ApplicationMode buttonAppMode,
boolean isChecked) {
if (singleSelection) {
if (isChecked) {
selected.clear();
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
if (ind == j) {
boolean selectedState = ind == j;
if (selectedState) {
selected.add(values.get(j));
}
if (buttons[j].isChecked() != (ind == j)) {
buttons[j].setChecked(ind == j);
if (buttons[j].isChecked() != selectedState) {
buttons[j].setChecked(selectedState);
}
}
}
@ -441,14 +468,6 @@ public class NavigateAction {
selected.remove(buttonAppMode);
}
}
if(onClickListener != null) {
onClickListener.onClick(null);
}
}
});
}
}
return ll;
}
private Spinner setupFromSpinner(final Location mapView, String name, View view, DirectionDialogStyle style) {