package net.squanchy.navigation;

import android.content.Context;
import android.content.Intent;

import net.squanchy.eventdetails.EventDetailsActivity;
import net.squanchy.search.SearchActivity;
import net.squanchy.speaker.SpeakerDetailsActivity;

public class Navigator {

    private final Context context;

    public Navigator(Context context) {
        this.context = context;
    }

    public void toEventDetails(String eventId) {
        Intent intent = EventDetailsActivity.createIntent(context, eventId);
        context.startActivity(intent);
    }

    public void toSpeakerDetails(String speakerId) {
        Intent intent = SpeakerDetailsActivity.createIntent(context, speakerId);
        context.startActivity(intent);
    }

    public void toSearch() {
        context.startActivity(new Intent(context, SearchActivity.class));
    }
}

@@ -89,16 +89,40 @@
 .Intent;
+%0Aimport android.net.Uri;
 %0A%0Aimport
@@ -867,11 +867,726 @@
 );%0A    %7D
+%0A%0A    public void toTwitterProfile(String username) %7B%0A        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(%22twitter://user?screen_name=%22 + username));%0A        if (canResolve(intent)) %7B%0A            context.startActivity(intent);%0A        %7D else %7B%0A            toExternalUrl(%22https://twitter.com/%22 + username);%0A            context.startActivity(intent);%0A        %7D%0A    %7D%0A%0A    private boolean canResolve(Intent intent) %7B%0A        return context.getPackageManager()%0A                .queryIntentActivities(intent, 0)%0A                .isEmpty();%0A    %7D%0A%0A    public void toExternalUrl(String url) %7B%0A        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));%0A        context.startActivity(intent);%0A    %7D
 %0A%7D%0A

Add support for navigating to Twitter profile and external URL