Small refactoring

This commit is contained in:
GaidamakUA 2015-11-16 09:57:34 +02:00
parent 308ec2ccab
commit d8fa057a0d
3 changed files with 13 additions and 17 deletions

View file

@ -18,9 +18,13 @@ import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
import net.osmand.plus.helpers.FontCache;
import java.io.File;
@ -33,7 +37,14 @@ import java.text.MessageFormat;
public class DashErrorFragment extends DashBaseFragment {
public static final String TAG = "DASH_ERROR_FRAGMENT";
public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION =
new DashFragmentData.ShouldShowFunction() {
// If settings null. No changes in setting will be made.
@Override
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
return ErrorBottomSheetDialog.shouldShow(settings, activity);
}
};
private DismissListener dismissCallback;
@Override

View file

@ -72,13 +72,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public static final String SHOULD_SHOW = "should_show";
private static final DashFragmentData.ShouldShowFunction rateUsShouldShow = new DashRateUsFragment.RateUsShouldShow();
private static final DashFragmentData.ShouldShowFunction errorShouldShow = new ErrorShouldShow();
private final DashFragmentData[] fragmentsData = new DashFragmentData[]{
new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class,
rateUsShouldShow, 0, null),
new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class,
errorShouldShow, 30, null),
DashErrorFragment.SHOULD_SHOW_FUNCTION, 30, null),
new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class,
DashNavigationFragment.SHOULD_SHOW_FUNCTION, 40, null),
new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class,
@ -932,15 +931,4 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
return settings.registerBooleanPreference(SHOULD_SHOW + tag, true).makeGlobal().get();
}
}
private static class ErrorShouldShow extends DashFragmentData.ShouldShowFunction {
// If settings null. No changes in setting will be made.
@Override
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) {
return activity.getMyApplication().getAppInitializer()
.checkPreviousRunsForExceptions(activity, settings != null);
}
}
}

View file

@ -28,9 +28,6 @@ import net.osmand.plus.helpers.FontCache;
import java.io.File;
import java.text.MessageFormat;
/**
* Created by GaidamakUA on 11/13/15.
*/
public class ErrorBottomSheetDialog extends BottomSheetDialogFragment {
@Nullable
@Override