Search in sources :

Example 26 with UiThread

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();
}
Also used : Intent(android.content.Intent) UiThread(android.support.annotation.UiThread)

Example 27 with UiThread

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);
            }
        }
    }
}
Also used : Rect(android.graphics.Rect) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) UiThread(android.support.annotation.UiThread)

Example 28 with UiThread

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);
}
Also used : Bundle(android.os.Bundle) AbstractQuestAnswerFragment(de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment) UiThread(android.support.annotation.UiThread)

Example 29 with UiThread

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();
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) UiThread(android.support.annotation.UiThread)

Example 30 with UiThread

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();
}
Also used : Rect(android.graphics.Rect) AnyThread(android.support.annotation.AnyThread) PointF(android.graphics.PointF) Bundle(android.os.Bundle) QuestDownloadProgressListener(de.westnordost.streetcomplete.data.download.QuestDownloadProgressListener) AbstractBottomSheetFragment(de.westnordost.streetcomplete.quests.AbstractBottomSheetFragment) OsmQuestAnswerListener(de.westnordost.streetcomplete.quests.OsmQuestAnswerListener) ProgressBar(android.widget.ProgressBar) LocationState(de.westnordost.streetcomplete.location.LocationState) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) LinkMovementMethod(android.text.method.LinkMovementMethod) IBinder(android.os.IBinder) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) QuestController(de.westnordost.streetcomplete.data.QuestController) CheckBox(android.widget.CheckBox) AboutFragment(de.westnordost.streetcomplete.about.AboutFragment) OAuthPrefs(de.westnordost.streetcomplete.oauth.OAuthPrefs) ServiceConnection(android.content.ServiceConnection) View(android.view.View) QuestAutoSyncer(de.westnordost.streetcomplete.data.QuestAutoSyncer) QuestDownloadService(de.westnordost.streetcomplete.data.download.QuestDownloadService) UploadedAnswersCounter(de.westnordost.streetcomplete.statistics.UploadedAnswersCounter) ConnectivityManager(android.net.ConnectivityManager) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) ObjectAnimator(android.animation.ObjectAnimator) Collection(java.util.Collection) QuestChangesUploadProgressListener(de.westnordost.streetcomplete.data.upload.QuestChangesUploadProgressListener) QuestAnswerComponent(de.westnordost.streetcomplete.quests.QuestAnswerComponent) Fragment(android.support.v4.app.Fragment) IntentFilter(android.content.IntentFilter) NetworkInfo(android.net.NetworkInfo) UiThread(android.support.annotation.UiThread) BroadcastReceiver(android.content.BroadcastReceiver) AppCompatActivity(android.support.v7.app.AppCompatActivity) SphericalEarthMath(de.westnordost.streetcomplete.util.SphericalEarthMath) PreferenceManager(android.support.v7.preference.PreferenceManager) FindQuestSourceComponent(de.westnordost.streetcomplete.quests.FindQuestSourceComponent) TextView(android.widget.TextView) CrashReportExceptionHandler(de.westnordost.streetcomplete.tools.CrashReportExceptionHandler) Location(android.location.Location) Nullable(android.support.annotation.Nullable) MapFragment(de.westnordost.streetcomplete.tangram.MapFragment) VisibleQuestListener(de.westnordost.streetcomplete.data.VisibleQuestListener) OsmConnectionException(de.westnordost.osmapi.common.errors.OsmConnectionException) Context(android.content.Context) SlippyMapMath(de.westnordost.streetcomplete.util.SlippyMapMath) AbstractQuestAnswerFragment(de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment) LatLon(de.westnordost.osmapi.map.data.LatLon) Intent(android.content.Intent) Linkify(android.text.util.Linkify) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Element(de.westnordost.osmapi.map.data.Element) QuestsMapFragment(de.westnordost.streetcomplete.tangram.QuestsMapFragment) Quest(de.westnordost.streetcomplete.data.Quest) VersionBannedException(de.westnordost.streetcomplete.data.upload.VersionBannedException) Toast(android.widget.Toast) Menu(android.view.Menu) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) OsmAuthorizationException(de.westnordost.osmapi.common.errors.OsmAuthorizationException) UnsyncedChangesCounter(de.westnordost.streetcomplete.statistics.UnsyncedChangesCounter) QuestChangesUploadService(de.westnordost.streetcomplete.data.upload.QuestChangesUploadService) OsmApiReadResponseException(de.westnordost.osmapi.common.errors.OsmApiReadResponseException) LocationUtil(de.westnordost.streetcomplete.location.LocationUtil) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) Point(android.graphics.Point) QuestUtil(de.westnordost.streetcomplete.quests.QuestUtil) OsmElement(de.westnordost.osmapi.map.data.OsmElement) CreateNoteListener(de.westnordost.streetcomplete.data.osmnotes.CreateNoteListener) FragmentManager(android.support.v4.app.FragmentManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) QuestGroup(de.westnordost.streetcomplete.data.QuestGroup) Toolbar(android.support.v7.widget.Toolbar) MapControlsFragment(de.westnordost.streetcomplete.tangram.MapControlsFragment) CreateNoteFragment(de.westnordost.streetcomplete.data.osmnotes.CreateNoteFragment) SettingsActivity(de.westnordost.streetcomplete.settings.SettingsActivity) FragmentTransaction(android.support.v4.app.FragmentTransaction) Collections(java.util.Collections) LocationRequestFragment(de.westnordost.streetcomplete.location.LocationRequestFragment) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) CheckBox(android.widget.CheckBox) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) UiThread(android.support.annotation.UiThread)

Aggregations

UiThread (android.support.annotation.UiThread)48 View (android.view.View)9 ObjectAnimator (android.animation.ObjectAnimator)6 Animator (android.animation.Animator)5 Drawable (android.graphics.drawable.Drawable)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 Fragment (android.support.v4.app.Fragment)4 MenuItem (android.view.MenuItem)4 ViewPropertyAnimator (android.view.ViewPropertyAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 DialogFragment (android.support.v4.app.DialogFragment)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 Location (android.location.Location)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 RecyclerView (android.support.v7.widget.RecyclerView)2