use of android.support.annotation.UiThread in project bugzy by cpunq.
the class LoginActivity method redirectHome.
@UiThread
private void redirectHome() {
Intent mHome = new Intent(this, HomeActivity.class);
startActivity(mHome);
this.finish();
}
use of android.support.annotation.UiThread in project StreetComplete by westnordost.
the class MainActivity method downloadDisplayedArea.
@UiThread
private void downloadDisplayedArea() {
BoundingBox displayArea;
if ((displayArea = mapFragment.getDisplayedArea(new Rect())) == null) {
Toast.makeText(this, R.string.cannot_find_bbox_or_reduce_tilt, Toast.LENGTH_LONG).show();
} else {
final BoundingBox enclosingBBox = SlippyMapMath.asBoundingBoxOfEnclosingTiles(displayArea, ApplicationConstants.QUEST_TILE_ZOOM);
double areaInSqKm = SphericalEarthMath.enclosedArea(enclosingBBox) / 1000000;
if (areaInSqKm > ApplicationConstants.MAX_DOWNLOADABLE_AREA_IN_SQKM) {
Toast.makeText(this, R.string.download_area_too_big, Toast.LENGTH_LONG).show();
} else {
if (questController.isPriorityDownloadRunning()) {
new AlertDialogBuilder(this).setMessage(R.string.confirmation_cancel_prev_download_title).setPositiveButton(android.R.string.ok, (dialog, which) -> downloadAreaConfirmed(enclosingBBox)).setNegativeButton(android.R.string.cancel, null).show();
} else {
downloadAreaConfirmed(enclosingBBox);
}
}
}
}
use of android.support.annotation.UiThread in project StreetComplete by westnordost.
the class MainActivity method showQuestDetails.
@UiThread
private void showQuestDetails(final Quest quest, final QuestGroup group, final Element element) {
if (getBottomSheetFragment() != null) {
closeBottomSheet();
}
lastLocation = mapFragment.getDisplayedLocation();
mapFragment.addQuestGeometry(quest.getGeometry());
AbstractQuestAnswerFragment f = quest.getType().createForm();
Bundle args = QuestAnswerComponent.createArguments(quest.getId(), group);
if (group == QuestGroup.OSM) {
args.putSerializable(AbstractQuestAnswerFragment.ARG_ELEMENT, (OsmElement) element);
}
args.putSerializable(AbstractQuestAnswerFragment.ARG_GEOMETRY, quest.getGeometry());
args.putString(AbstractQuestAnswerFragment.ARG_QUESTTYPE, quest.getType().getClass().getSimpleName());
args.putFloat(AbstractQuestAnswerFragment.ARG_MAP_ROTATION, mapRotation);
args.putFloat(AbstractQuestAnswerFragment.ARG_MAP_TILT, mapTilt);
f.setArguments(args);
showInBottomSheet(f);
}
use of android.support.annotation.UiThread in project StreetComplete by westnordost.
the class MainActivity method closeBottomSheet.
@UiThread
private void closeBottomSheet() {
// some more info here http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html
if (isDestroyed() || isFinishing() || isChangingConfigurations())
return;
// manually close the keyboard before popping the fragment
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
getSupportFragmentManager().popBackStackImmediate(BOTTOM_SHEET, FragmentManager.POP_BACK_STACK_INCLUSIVE);
mapFragment.setIsFollowingPosition(isFollowingPosition);
mapFragment.removeQuestGeometry();
}
use of android.support.annotation.UiThread in project StreetComplete by westnordost.
the class MainActivity method requestOAuthorized.
@UiThread
private void requestOAuthorized() {
if (dontShowRequestAuthorizationAgain)
return;
View inner = LayoutInflater.from(this).inflate(R.layout.dialog_authorize_now, null, false);
final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain);
new AlertDialogBuilder(this).setView(inner).setPositiveButton(android.R.string.ok, (dialog, which) -> {
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
intent.putExtra(SettingsActivity.EXTRA_LAUNCH_AUTH, true);
startActivity(intent);
}).setNegativeButton(R.string.later, (dialog, which) -> {
dontShowRequestAuthorizationAgain = checkBox.isChecked();
}).show();
}
Aggregations