Example usage for android.widget TextView setLinksClickable

List of usage examples for android.widget TextView setLinksClickable

Introduction

In this page you can find the example usage for android.widget TextView setLinksClickable.

Prototype

@android.view.RemotableViewMethod
public final void setLinksClickable(boolean whether) 

Source Link

Document

Sets whether the movement method will automatically be set to LinkMovementMethod if #setAutoLinkMask has been set to nonzero and links are detected in #setText .

Usage

From source file:Main.java

/**
 * Make UI TextView a html link./*from ww  w .  ja  v  a 2  s .  c  o m*/
 * 
 * @param context the context
 * @param textView the text view
 * @param html the html containing link info
 */
public static void makeTextViewAHTMLLink(final Context context, TextView textView, String html) {
    textView.setLinksClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    CharSequence sequence = Html.fromHtml(html);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(sequence);
    URLSpan[] urls = spannableStringBuilder.getSpans(0, sequence.length(), URLSpan.class);
    for (final URLSpan urlSpan : urls) {
        int start = spannableStringBuilder.getSpanStart(urlSpan);
        int end = spannableStringBuilder.getSpanEnd(urlSpan);
        int flags = spannableStringBuilder.getSpanFlags(urlSpan);
        ClickableSpan clickable = new ClickableSpan() {
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlSpan.getURL()));
                context.startActivity(intent);
            }

            @Override
            public void updateDrawState(TextPaint textPaint) {
                super.updateDrawState(textPaint);
                textPaint.setUnderlineText(false);
            }
        };
        spannableStringBuilder.removeSpan(urlSpan);
        spannableStringBuilder.setSpan(clickable, start, end, flags);
    }
    textView.setText(spannableStringBuilder);
}

From source file:com.slushpupie.deskclock.ChangelogDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Standard AlertDialog does not support HTML-style links.
    // So rebuild the ScrollView->TextView with the appropriate
    // settings and set the view directly.
    TextView tv = new TextView(getActivity());
    tv.setPadding(5, 5, 5, 5);/*from w ww.  java  2  s  .c om*/
    tv.setLinksClickable(true);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setText(R.string.changeLog);
    tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    ScrollView sv = new ScrollView(getActivity());
    sv.setPadding(14, 2, 10, 12);
    sv.addView(tv);
    builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle).setPositiveButton(R.string.ok,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ((DeskClock) getActivity()).acknoledgeChangelog();
                }
            });
    return builder.create();
}

From source file:open.currency.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setToolbarEnabled(true);/*from  w w w  . ja va  2s . com*/

    String desGithub = "Visit the  <a href='http://openappsproject.github.io/OpenCurrency/'>project page</a> to get more information about OpenCurrency.<br/><br/> 2015 - 2016 OpenAppsProject";
    TextView desTV = (TextView) findViewById(R.id.link_github);
    desTV.setLinksClickable(true);
    desTV.setMovementMethod(LinkMovementMethod.getInstance());
    desTV.setText(Html.fromHtml(desGithub));

    currencyArray = getResources().getStringArray(R.array.currencies);

    currency1 = (EditText) findViewById(R.id.currency1);
    currency2 = (EditText) findViewById(R.id.currency2);

    tilCur1 = (TextInputLayout) findViewById(R.id.tilCur1);
    tilCur2 = (TextInputLayout) findViewById(R.id.tilCur2);

    Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
    Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.currencies,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    lastEdited = 1;
    currency1.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            lastEdited = 1;
        }
    });
    currency2.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            lastEdited = 2;
        }
    });

    spinner1.setAdapter(adapter);
    spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            cur1 = position;
            tilCur1.setHint(currencyArray[position]);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    spinner2.setAdapter(adapter);
    spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            cur2 = position;
            tilCur2.setHint(currencyArray[position]);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    setFabEnabled(true);
    setFabDrawable(ContextCompat.getDrawable(this, R.drawable.ic_check_white_48dp));
    setFabListener(new View.OnClickListener() {

        Double inputValue = Double.valueOf("0");

        @Override
        public void onClick(View v) {
            currency1.setEnabled(false);
            currency2.setEnabled(false);
            try {
                if (lastEdited == 1) {
                    inputValue = Double.valueOf(currency1.getText().toString());
                } else {
                    inputValue = Double.valueOf(currency2.getText().toString());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (inputValue.equals(Double.valueOf("0"))) {
                Snackbar.make(v, R.string.empty_value, Snackbar.LENGTH_LONG).show();
                currency1.setEnabled(true);
                currency2.setEnabled(true);
            } else if (cur1 == cur2) {
                Snackbar.make(v, R.string.sam_cur, Snackbar.LENGTH_LONG).show();
                currency1.setEnabled(true);
                currency2.setEnabled(true);
            } else {
                Action<Double> doCalculate = new Action<Double>() {
                    @NonNull
                    @Override
                    public String id() {
                        return "calculate";
                    }

                    @Nullable
                    @Override
                    protected Double run() throws InterruptedException {
                        if (lastEdited == 1) {
                            return calculate(currencyArray[cur1], currencyArray[cur2], inputValue);
                        } else {
                            return calculate(currencyArray[cur2], currencyArray[cur1], inputValue);
                        }
                    }

                    @Override
                    protected void done(@Nullable Double result) {
                        if (result != null) {
                            if (lastEdited == 1) {
                                currency2.setText(String.valueOf(result));
                            } else {
                                currency1.setText(String.valueOf(result));
                            }
                        }
                        currency1.setEnabled(true);
                        currency2.setEnabled(true);
                    }
                };
                doCalculate.execute();
            }
        }
    });
}

From source file:org.telegram.ui.IdenticonActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*from ww  w  .j a va 2s . com*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new LinearLayout(context);
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setWeightSum(100);
    linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20),
            AndroidUtilities.dp(20));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    ImageView identiconView = new ImageView(context);
    identiconView.setScaleType(ImageView.ScaleType.FIT_XY);
    frameLayout.addView(identiconView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background));
    frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    TextView textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLinksClickable(true);
    textView.setClickable(true);
    textView.setMovementMethod(new LinkMovementMethodMy());
    //textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
    textView.setGravity(Gravity.CENTER);
    frameLayout.addView(textView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
    if (encryptedChat != null) {
        IdenticonDrawable drawable = new IdenticonDrawable();
        identiconView.setImageDrawable(drawable);
        drawable.setEncryptedChat(encryptedChat);
        TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
        SpannableStringBuilder hash = new SpannableStringBuilder();
        if (encryptedChat.key_hash.length > 16) {
            String hex = Utilities.bytesToHex(encryptedChat.key_hash);
            for (int a = 0; a < 32; a++) {
                if (a != 0) {
                    if (a % 8 == 0) {
                        hash.append('\n');
                    } else if (a % 4 == 0) {
                        hash.append(' ');
                    }
                }
                hash.append(hex.substring(a * 2, a * 2 + 2));
                hash.append(' ');
            }
            hash.append("\n\n");
        }
        hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription",
                R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
        final String url = "telegram.org";
        int index = hash.toString().indexOf(url);
        if (index != -1) {
            hash.setSpan(
                    new URLSpanReplacement(
                            LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)),
                    index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        textView.setText(hash);
    }

    return fragmentView;
}

From source file:org.wheelmap.android.fragment.LoginDialogFragment.java

@Override
public void onResume() {
    super.onResume();

    AlertDialog dialog = (AlertDialog) getDialog();
    Button button = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    button.setOnClickListener(this);

    TextView forgot_password = (TextView) dialog.findViewById(R.id.login_forgot_password);
    String forgot_password_format = "<a href=\"http://wheelmap.org/users/password/new\">%s</a>";
    forgot_password.setText(Html.fromHtml(String.format(forgot_password_format, forgot_password.getText())));
    forgot_password.setLinksClickable(true);
    forgot_password.setMovementMethod(LinkMovementMethod.getInstance());

    TextView login2 = (TextView) dialog.findViewById(R.id.login_login_2);
    String login2_format = "<a href=\"" + getString(R.string.login_link_wheelmap) + "\">%s</a>";
    login2.setText(Html.fromHtml(String.format(login2_format, login2.getText())));
    login2.setLinksClickable(true);//from ww  w  . j a v  a 2  s. co m
    login2.setMovementMethod(LinkMovementMethod.getInstance());

    mEmailText = (EditText) dialog.findViewById(R.id.login_email);
    mPasswordText = (EditText) dialog.findViewById(R.id.login_password);

    mEmailText.setText("");
    mPasswordText.setText("");

    mEmailText = (EditText) dialog.findViewById(R.id.login_email);
    mEmailText.setOnEditorActionListener(this);
    mPasswordText = (EditText) dialog.findViewById(R.id.login_password);
    mPasswordText.setOnEditorActionListener(this);

    load();

}

From source file:org.wheelmap.android.fragment.LoginFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_dialog_login, container, false);

    v.findViewById(R.id.button_login).setOnClickListener(new OnClickListener() {
        @Override//w w  w .j ava  2s  .  c  o  m
        public void onClick(View v) {
            login();
        }
    });

    TextView forgot_password = (TextView) v.findViewById(R.id.login_forgot_password);
    String forgot_password_format = "<a href=\"http://wheelmap.org/users/password/new\">%s</a>";
    forgot_password.setText(Html.fromHtml(String.format(forgot_password_format, forgot_password.getText())));
    forgot_password.setLinksClickable(true);
    forgot_password.setMovementMethod(LinkMovementMethod.getInstance());

    TextView login2 = (TextView) v.findViewById(R.id.login_login_2);
    String login2_format = "<a href=\"" + getString(R.string.login_link_wheelmap) + "\">%s</a>";
    login2.setText(Html.fromHtml(String.format(login2_format, login2.getText())));
    login2.setLinksClickable(true);
    login2.setMovementMethod(LinkMovementMethod.getInstance());

    mEmailText = (EditText) v.findViewById(R.id.login_email);
    mPasswordText = (EditText) v.findViewById(R.id.login_password);
    mLoginRegister = (Button) v.findViewById(R.id.button_login_register);

    // mEmailText.setText("");
    //mPasswordText.setText("");

    if (!UtilsMisc.isTablet(getActivity().getApplicationContext())) {
        View scrollView = v.findViewById(R.id.scrollView);
        ViewGroup.LayoutParams params = scrollView.getLayoutParams();
        params.height = ViewGroup.LayoutParams.MATCH_PARENT;
        scrollView.setLayoutParams(params);
    }

    mLoginRegister.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uriUrl = Uri.parse("http://wheelmap.org/en/oauth/register_osm");
            Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
            startActivity(launchBrowser);
        }
    });

    return v;
}

From source file:org.inftel.ssa.mobile.ui.fragments.ProjectDetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data.moveToFirst()) {
        mProjectId = data.getString(data.getColumnIndex(Projects._ID));
        name = data.getString(data.getColumnIndex(Projects.PROJECT_NAME));
        summary = data.getString(data.getColumnIndex(Projects.PROJECT_SUMMARY));
        description = data.getString(data.getColumnIndex(Projects.PROJECT_DESCRIPTION));
        opened = data.getString(data.getColumnIndex(Projects.PROJECT_OPENED));
        started = data.getString(data.getColumnIndex(Projects.PROJECT_STARTED));
        closed = data.getString(data.getColumnIndex(Projects.PROJECT_CLOSE));
        company = data.getString(data.getColumnIndex(Projects.PROJECT_COMPANY));
        license = data.getString(data.getColumnIndex(Projects.PROJECT_LICENSE));
        labels = data.getString(data.getColumnIndex(Projects.PROJECT_LABELS));
        links = data.getString(data.getColumnIndex(Projects.PROJECT_LINKS));

        // taskChart(mProjectId);

        // Update UI
        mHandler.post(new Runnable() {
            public void run() {

                // Header
                ((TextView) getView().findViewById(R.id.detail_title)).setText(name);
                ((TextView) getView().findViewById(R.id.detail_subtitle)).setText(summary);

                // Tab description
                if (description != null) {
                    ((TextView) getView().findViewById(R.id.project_detail_description))
                            .setText(Html.fromHtml(description));
                }//from w  w  w  .j a v a2s.  co m

                // Tab links
                // TODO Ver como llegan los links y aplicarle formato
                String link = "<a href='http://www.masterinftel.uma.es/'>Master Inftel</a>";
                TextView l = (TextView) getView().findViewById(R.id.empty_links);
                l.setText(Html.fromHtml(link));
                l.setMovementMethod(LinkMovementMethod.getInstance());
                l.setLinksClickable(true);

                // Tab Information
                ((TextView) getView().findViewById(R.id.lblOpened)).setText(formatDate(opened));
                ((TextView) getView().findViewById(R.id.lblStarted)).setText(formatDate(started));
                ((TextView) getView().findViewById(R.id.lblClosed)).setText(formatDate(closed));
                ((TextView) getView().findViewById(R.id.lblCompany)).setText(company);
                ((TextView) getView().findViewById(R.id.lblLicense)).setText(license);
                ((TextView) getView().findViewById(R.id.lblLabels)).setText(labels);

            }
        });
    }

}

From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i(TAG, "onCreate() called");

    // Disable screenshots in release builds
    if (!BuildConfig.DEBUG) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    }/*from  w  w  w. ja v  a 2s.  co m*/

    setContentView(R.layout.enroll_activity_start);
    setTitle(R.string.app_name_enroll);

    enableContinueButton();

    screen = SCREEN_START;
    updateProgressCounter();

    String helpHtml = getString(R.string.se_connect_mno);

    TextView helpTextView = (TextView) findViewById(R.id.se_feedback_text);
    if (helpTextView != null) { // Can be null if we are on error screen
        helpTextView.setText(Html.fromHtml(helpHtml));
        helpTextView.setMovementMethod(LinkMovementMethod.getInstance());
        helpTextView.setLinksClickable(true);
    }
}

From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java

@Override
public void onClick(View view) {
    if (view == btnGoBack) {
        if (isAtFavorites) {
            isAtFavorites = false;/*from ww w. jav a  2s.co m*/
            doSearch();
        } else {
            finish(0, view, true);
        }
    } else if (view == btnFavorite) {
        isAtFavorites = true;
        radioStationList.cancel();
        radioStationList.fetchFavorites(getApplication());
        updateButtons();
    } else if (view == btnSearch) {
        final Context ctx = getHostActivity();
        final LinearLayout l = (LinearLayout) UI.createDialogView(ctx, null);

        LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        chkGenre = new RadioButton(ctx);
        chkGenre.setText(R.string.genre);
        chkGenre.setChecked(Player.lastRadioSearchWasByGenre);
        chkGenre.setOnClickListener(this);
        chkGenre.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        chkGenre.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        btnGenre = new Spinner(ctx);
        btnGenre.setContentDescription(ctx.getText(R.string.genre));
        btnGenre.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad << 1;
        chkTerm = new RadioButton(ctx);
        chkTerm.setText(R.string.search_term);
        chkTerm.setChecked(!Player.lastRadioSearchWasByGenre);
        chkTerm.setOnClickListener(this);
        chkTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        chkTerm.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        txtTerm = new EditText(ctx);
        txtTerm.setContentDescription(ctx.getText(R.string.search_term));
        txtTerm.setText(Player.radioSearchTerm == null ? "" : Player.radioSearchTerm);
        txtTerm.setOnClickListener(this);
        txtTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        txtTerm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        txtTerm.setSingleLine();
        txtTerm.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        p.bottomMargin = UI._DLGsppad;
        final TextView lbl = new TextView(ctx);
        lbl.setAutoLinkMask(0);
        lbl.setLinksClickable(true);
        //http://developer.android.com/design/style/color.html
        lbl.setLinkTextColor(new BgColorStateList(UI.isAndroidThemeLight() ? 0xff0099cc : 0xff33b5e5));
        lbl.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._14sp);
        lbl.setGravity(Gravity.CENTER_HORIZONTAL);
        lbl.setText(SafeURLSpan.parseSafeHtml(getText(R.string.by_dir_xiph_org)));
        lbl.setMovementMethod(LinkMovementMethod.getInstance());
        lbl.setLayoutParams(p);

        l.addView(chkGenre);
        l.addView(btnGenre);
        l.addView(chkTerm);
        l.addView(txtTerm);
        l.addView(lbl);

        btnGenre.setAdapter(this);
        btnGenre.setSelection(getValidGenre(Player.radioLastGenre));
        defaultTextColors = txtTerm.getTextColors();

        UI.prepareDialogAndShow((new AlertDialog.Builder(ctx)).setTitle(getText(R.string.search)).setView(l)
                .setPositiveButton(R.string.search, this).setNegativeButton(R.string.cancel, this)
                .setOnCancelListener(this).create());
    } else if (view == btnGoBackToPlayer) {
        finish(-1, view, false);
    } else if (view == btnAdd) {
        addPlaySelectedItem(false);
    } else if (view == btnPlay) {
        addPlaySelectedItem(true);
    } else if (view == chkGenre || view == btnGenre) {
        chkGenre.setChecked(true);
        chkTerm.setChecked(false);
    } else if (view == chkTerm || view == txtTerm) {
        chkGenre.setChecked(false);
        chkTerm.setChecked(true);
    } else if (view == list) {
        if (!isAtFavorites && !loading && (radioStationList == null || radioStationList.getCount() == 0))
            onClick(btnFavorite);
    }
}

From source file:de.mprengemann.hwr.timetabel.TimetableActivity.java

@SuppressWarnings("deprecation")
@Override/*from www  .  j a v a2s  .  c  o m*/
protected Dialog onCreateDialog(int id) {

    AlertDialog.Builder builder;

    switch (id) {
    case NEW_TIMETABLEPLAN:
        builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.dialog_new_message);
        builder.setTitle(R.string.dialog_new_title);
        builder.setCancelable(false);
        builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                subjectFragment.clear();
                getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

                refreshItem.setVisible(false);

                Parser p = new Parser(TimetableActivity.this, parsingListener);
                p.execute();
            }
        });
        builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TimetableActivity.this);

                Calendar calendar = Calendar.getInstance();

                Editor edit = prefs.edit();
                edit.putLong(getString(R.string.prefs_lastUpdated_user), calendar.getTimeInMillis());

                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);

                edit.putLong(getString(R.string.prefs_lastUpdated), calendar.getTimeInMillis());
                edit.commit();

                dialog.cancel();
            }
        });
        return builder.create();
    case LICENSE_DIALOG:
        builder = new AlertDialog.Builder(this);

        TextView textView = new TextView(this);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setText(R.string.text_license);
        textView.setLinksClickable(true);
        textView.setPadding(10, 10, 10, 10);

        builder.setView(textView);
        builder.setTitle(R.string.menu_license);
        builder.setCancelable(true);
        builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        return builder.create();
    default:
        return super.onCreateDialog(id);
    }
}