Search in sources :

Example 1 with WebIntentBuilder

use of com.klinker.android.twitter.utils.WebIntentBuilder in project Talon-for-Twitter by klinker24.

the class TouchableSpan method onClick.

@Override
public void onClick(View widget) {
    if (Patterns.WEB_URL.matcher(mValue).find()) {
        String url = "http://" + full.replace("http://", "").replace("https://", "").replace("\"", "");
        new WebIntentBuilder(mContext).setUrl(url).setShouldForceExternal(extBrowser).build().start();
    } else if (Regex.HASHTAG_PATTERN.matcher(mValue).find()) {
        // found a hashtag, so open the hashtag search
        Intent search;
        if (!fromLauncher) {
            search = new Intent(mContext, SearchedTrendsActivity.class);
        } else {
            search = new Intent("android.intent.action.MAIN");
            search.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.drawer_activities.discover.trends.LauncherSearchedTrends"));
            search.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            search.putExtra("current_account", settings.currentAccount);
        }
        search.setAction(Intent.ACTION_SEARCH);
        search.putExtra(SearchManager.QUERY, full);
        mContext.startActivity(search);
    } else if (Regex.MENTION_PATTERN.matcher(mValue).find()) {
        Intent user;
        if (!fromLauncher) {
            user = new Intent(mContext, ProfilePager.class);
        } else {
            user = new Intent("android.intent.action.MAIN");
            user.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.profile_viewer.LauncherProfilePager"));
            user.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            user.putExtra("current_account", settings.currentAccount);
        }
        user.putExtra("screenname", full.replace("@", "").replaceAll(" ", ""));
        user.putExtra("proPic", "");
        mContext.startActivity(user);
    } else if (Regex.CASHTAG_PATTERN.matcher(mValue).find()) {
        // found a cashtag, so open the search
        Intent search;
        if (!fromLauncher) {
            search = new Intent(mContext, SearchedTrendsActivity.class);
        } else {
            search = new Intent("android.intent.action.MAIN");
            search.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.drawer_activities.discover.trends.LauncherSearchedTrends"));
            search.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            search.putExtra("current_account", settings.currentAccount);
        }
        search.setAction(Intent.ACTION_SEARCH);
        search.putExtra(SearchManager.QUERY, full);
        mContext.startActivity(search);
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            TouchableMovementMethod.touched = false;
        }
    }, 500);
}
Also used : WebIntentBuilder(com.klinker.android.twitter.utils.WebIntentBuilder) ProfilePager(com.klinker.android.twitter.activities.profile_viewer.ProfilePager) Handler(android.os.Handler) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 ProfilePager (com.klinker.android.twitter.activities.profile_viewer.ProfilePager)1 WebIntentBuilder (com.klinker.android.twitter.utils.WebIntentBuilder)1