Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *//*from  ww w  .  ja v a2 s  .c  om*/
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            PaintDrawable background = new PaintDrawable(Color.GRAY);
            background.setCornerRadius(5);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i] + " | X");
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(5, 2, 5, 2);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:com.hippo.nimingban.ui.ListActivity.java

@Override
public void onClickCommonPosts() {
    AutoWrapLayout layout = new AutoWrapLayout(ListActivity.this);
    final Dialog dialog = new AlertDialog.Builder(this).setView(layout).show();

    List<CommonPost> list = DB.getAllACCommentPost();
    int padding = LayoutUtils.dp2pix(this, 4);
    layout.setPadding(padding, 0, padding, 0);
    LayoutInflater inflater = getLayoutInflater();
    for (final CommonPost cp : list) {
        inflater.inflate(R.layout.item_dialog_comment_post, layout);
        TextView tv = (TextView) layout.getChildAt(layout.getChildCount() - 1);
        tv.setText(cp.name);/*from www .  j  a v a  2  s  .  co m*/
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();

                Intent intent = new Intent(ListActivity.this, PostActivity.class);
                intent.setAction(PostActivity.ACTION_SITE_ID);
                intent.putExtra(PostActivity.KEY_SITE, ACSite.getInstance().getId());
                intent.putExtra(PostActivity.KEY_ID, cp.id);
                startActivity(intent);
            }
        });
    }
}

From source file:com.amaze.filemanager.fragments.preference_fragments.Preffrag.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.reset();/*from ww w . j a  va 2s .co m*/
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    final int th1 = Integer.parseInt(sharedPref.getString("theme", "0"));
    theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1;
    findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).donate();
            return false;
        }
    });
    findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final String[] sort = getResources().getStringArray(R.array.columns);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.gridcolumnno);
            int current = Integer.parseInt(sharedPref.getString("columns", "-1"));
            current = current == -1 ? 0 : current;
            if (current != 0)
                current = current - 1;
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.theme);
            int current = Integer.parseInt(sharedPref.getString("theme", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("theme", "" + which).commit();
                    dialog.dismiss();
                    restartPC(getActivity());
                    return true;
                }
            });
            a.title(R.string.theme);
            a.build().show();
            return true;
        }
    });
    findPreference("colors").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).selectItem(1);
            return true;
        }
    });

    final CheckBx rootmode = (CheckBx) findPreference("rootmode");
    rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            boolean b = sharedPref.getBoolean("rootmode", false);
            if (b) {
                if (RootTools.isAccessGiven()) {
                    rootmode.setChecked(true);

                } else {
                    rootmode.setChecked(false);

                    Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                rootmode.setChecked(false);

            }

            return false;
        }
    });

    // Authors
    Preference preference4 = (Preference) findPreference("authors");
    preference4.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            skin = PreferenceUtils.getPrimaryColorString(sharedPref);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            if (theme == 1)
                a.theme(Theme.DARK);

            a.positiveText(R.string.close);
            a.positiveColor(fab_skin);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.authors, null);
            a.customView(view, true);
            a.title(R.string.authors);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                }
            });
            /*a.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
            });*/
            a.build().show();

            final Intent intent = new Intent(Intent.ACTION_VIEW);

            TextView googlePlus1 = (TextView) view.findViewById(R.id.googlePlus1);
            googlePlus1.setTextColor(Color.parseColor(skin));
            TextView googlePlus2 = (TextView) view.findViewById(R.id.googlePlus2);
            googlePlus2.setTextColor(Color.parseColor(skin));
            TextView git1 = (TextView) view.findViewById(R.id.git1);
            git1.setTextColor(Color.parseColor(skin));
            TextView git2 = (TextView) view.findViewById(R.id.git2);
            git2.setTextColor(Color.parseColor(skin));

            googlePlus1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/u/0/110424067388738907251/"));
                    startActivity(intent);
                }
            });
            googlePlus2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/+VishalNehra/"));
                    startActivity(intent);
                }
            });
            git1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/arpitkh96"));
                    startActivity(intent);
                }
            });
            git2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/vishal0071"));
                    startActivity(intent);
                }
            });

            // icon credits
            TextView textView = (TextView) view.findViewById(R.id.icon_credits);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setLinksClickable(true);
            textView.setText(Html.fromHtml(getActivity().getString(R.string.icon_credits)));

            return false;
        }
    });

    // Changelog
    Preference preference1 = (Preference) findPreference("changelog");
    preference1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.changelog);
            a.content(Html.fromHtml(getActivity().getString(R.string.changelog_version_9)
                    + getActivity().getString(R.string.changelog_change_9)
                    + getActivity().getString(R.string.changelog_version_8)
                    + getActivity().getString(R.string.changelog_change_8)
                    + getActivity().getString(R.string.changelog_version_7)
                    + getActivity().getString(R.string.changelog_change_7)
                    + getActivity().getString(R.string.changelog_version_6)
                    + getActivity().getString(R.string.changelog_change_6)
                    + getActivity().getString(R.string.changelog_version_5)
                    + getActivity().getString(R.string.changelog_change_5)
                    + getActivity().getString(R.string.changelog_version_4)
                    + getActivity().getString(R.string.changelog_change_4)
                    + getActivity().getString(R.string.changelog_version_3)
                    + getActivity().getString(R.string.changelog_change_3)
                    + getActivity().getString(R.string.changelog_version_2)
                    + getActivity().getString(R.string.changelog_change_2)
                    + getActivity().getString(R.string.changelog_version_1)
                    + getActivity().getString(R.string.changelog_change_1)));
            a.negativeText(R.string.close);
            a.positiveText(R.string.fullChangelog);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            a.positiveColor(fab_skin);
            a.negativeColor(fab_skin);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://github.com/arpitkh96/AmazeFileManager/commits/master"));
                    startActivity(intent);
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }
            }).build().show();
            return false;
        }
    });

    // Open Source Licenses
    Preference preference2 = (Preference) findPreference("os");
    //Defining dialog layout
    final Dialog dialog = new Dialog(getActivity(),
            android.R.style.Theme_Holo_Light_DialogWhenLarge_NoActionBar);
    //dialog.setTitle("Open-Source Licenses");
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final View dialog_view = inflater.inflate(R.layout.open_source_licenses, null);
    dialog.setContentView(dialog_view);

    preference2.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {

            WebView wv = (WebView) dialog_view.findViewById(R.id.webView1);
            PreferenceUtils preferenceUtils = new PreferenceUtils();
            wv.loadData(PreferenceUtils.LICENCE_TERMS, "text/html", null);
            dialog.show();
            return false;
        }
    });

    // Feedback
    Preference preference3 = (Preference) findPreference("feedback");
    preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "arpitkh96@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : Amaze File Manager");
            Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show();
            File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt");
            if (f.exists()) {
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
            }
            startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback)));
            return false;
        }
    });

    // rate
    Preference preference5 = (Preference) findPreference("rate");
    preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse("market://details?id=com.amaze.filemanager"));
            startActivity(intent1);
            return false;
        }
    });

    // studio
    Preference studio = findPreference("studio");
    studio.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            COUNT++;
            if (COUNT >= 5) {
                if (toast != null)
                    toast.cancel();
                toast = Toast.makeText(getActivity(), "Studio Mode : " + COUNT, Toast.LENGTH_SHORT);
                toast.show();

                sharedPref.edit().putInt("studio", Integer.parseInt(Integer.toString(COUNT) + "000")).apply();
            } else {
                sharedPref.edit().putInt("studio", 0).apply();
            }
            return false;
        }
    });

    // G+
    gplus = (CheckBx) findPreference("plus_pic");
    gplus.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (gplus.isChecked()) {
                boolean b = checkGplusPermission();
                if (!b)
                    requestGplusPermission();
            }
            return false;
        }
    });
    if (BuildConfig.IS_VERSION_FDROID)
        gplus.setEnabled(false);

    // Colored navigation bar
}

From source file:com.uddchina.youdingdan.MyDateActivity.java

/**
 * popupWindow/*from w  ww .j ava 2s. co m*/
 *
 * @param linearLayout
 */
private void showArea(LinearLayout linearLayout) {
    popuwindowArea = new PopupWindow(linearLayout, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.editone_changeaddress_pop_layout, null);
    popuwindowArea.setContentView(view);
    popuwindowArea.setFocusable(true);
    popuwindowArea.setOutsideTouchable(true);
    popuwindowArea.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
    popuwindowArea.showAtLocation(linearLayout, Gravity.BOTTOM, 0, 0);
    TextView btn_myinfo_cancel = (TextView) view.findViewById(R.id.btn_myinfo_cancel);
    TextView btn_myinfo_sure = (TextView) view.findViewById(R.id.btn_myinfo_sure);
    wv_address_province = (ListView) view.findViewById(R.id.wv_address_province);
    wv_address_city = (ListView) view.findViewById(R.id.wv_address_city);
    wv_address_area = (ListView) view.findViewById(R.id.wv_address_area);
    listenter();
    //?
    btn_myinfo_cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popuwindowArea.dismiss();
        }
    });
    //?
    btn_myinfo_sure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!dictid.equals("")) {
                mSotreareaContent.setText(pri + ci + ar);
                popuwindowArea.dismiss();
            } else {
                ShowToast.ToToast(MyDateActivity.this, "");
            }
        }
    });
}

From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java

private boolean showPickupsInfo(final LocalDate date) {
    final List<PickupInfo> from = DB.pickups().findByFrom(date, true);
    if (!from.isEmpty()) {

        TextView title = ((TextView) bottomSheet.findViewById(R.id.bottom_sheet_title));

        LayoutInflater i = getLayoutInflater();
        LinearLayout list = (LinearLayout) findViewById(R.id.pickup_list);
        list.removeAllViews();/*  w  ww .  java2  s.com*/
        for (final PickupInfo p : from) {

            Medicine m = DB.medicines().findById(p.medicine().getId());
            Patient pat = DB.patients().findById(m.patient().id());

            if (selectedPatientIdx == 0 || pat.id() == selectedPatientId) {

                View v = i.inflate(R.layout.calendar_pickup_list_item, null);
                TextView tv1 = ((TextView) v.findViewById(R.id.textView));
                TextView tv2 = ((TextView) v.findViewById(R.id.textView2));
                ImageView avatar = ((ImageView) v.findViewById(R.id.avatar));
                String interval = getResources().getString(R.string.pickup_interval, p.to().toString(df));

                if (p.taken()) {
                    interval += " ";
                    tv1.setAlpha(0.5f);
                } else {
                    tv1.setAlpha(1f);
                    tv2.setAlpha(1f);
                }

                tv1.setText(p.medicine().name());
                tv2.setText(interval);
                avatar.setImageResource(AvatarMgr.res(pat.avatar()));

                tv1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        p.taken(!p.taken());
                        DB.pickups().save(p);
                        showPickupsInfo(date);
                    }
                });
                list.addView(v);
            }
        }
        nestedScrollView.scrollBy(0, bottomSheet.getHeight());
        showBottomSheet();
        int total = list.getChildCount();
        title.setText(
                total + " " + getResources().getString(R.string.title_pickups_bottom_sheet, date.toString(df)));
        appBarLayout.setExpanded(false, true);
        return true;
    }
    return false;
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *//*from  w  ww .j ava 2  s.  co  m*/
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            int color = (i + 1 == limiter.length ? 0xFFA0A0A0 : 0xFFC0C0C0);
            PaintDrawable background = new PaintDrawable(color);
            background.setCornerRadius(0);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i]);
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(14, 6, 14, 6);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:com.minsheng.app.xunchedai.loan.activities.AddLoanActivity.java

/**
 * ??//from   ww w . j  a v a  2 s . c om
 */
public void initPopupWindowObject(View v) {
    popupWindow = PopupWindowUtils.newPop(this, R.layout.pop_add_loan_activity_object, v);
    TextView tv_borrower = (TextView) popupWindow.getContentView().findViewById(R.id.borrower);
    TextView tv_salesman = (TextView) popupWindow.getContentView().findViewById(R.id.salesman);
    TextView tv_cancel = (TextView) popupWindow.getContentView().findViewById(R.id.cancel);

    tv_borrower.setOnClickListener(this);
    tv_salesman.setOnClickListener(this);
    tv_cancel.setOnClickListener(this);
}

From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.qr_scan));
    } else {//from www . jav  a2  s. c  o  m
        barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
    TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
    timeTextView.setText(formattedTime);

    TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
    View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            metaTextView.setText(metadataText);
            metaTextView.setVisibility(View.VISIBLE);
            metaTextViewLabel.setVisibility(View.VISIBLE);
        }
    }

    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    CharSequence displayContents = resultHandler.getDisplayContents();
    contentsTextView.setText(displayContents);
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL,
            true)) {
        SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
                historyManager, this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
        TextView button = (TextView) buttonView.getChildAt(x);
        if (x < buttonCount) {
            button.setVisibility(View.VISIBLE);
            button.setText(resultHandler.getButtonText(x));
            button.setOnClickListener(new ResultButtonListener(resultHandler, x));
        } else {
            button.setVisibility(View.GONE);
        }
    }

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        if (displayContents != null) {
            clipboard.setText(displayContents);
        }
    }
}

From source file:com.givon.anhao.activity.AnhaoMainActivity.java

private void initPopuptWindow() {
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    View popupWindow = layoutInflater.inflate(R.layout.popup_window, null);

    mPopupWindow = new PopupWindow(popupWindow, AnhaoApplication.mWidth - 80, DensityUtil.dip2px(this, 200));
    mPopupWindow.setFocusable(true);//w w w .j a v  a  2 s.c  om
    // mPopupWindow.setWindowLayoutMode((mScreenWidth-mPopupWindowWidth)/2, mScreenHeight-mPopupWindowHeight);
    TextView popup_dismiss = (TextView) popupWindow.findViewById(R.id.tv_popup_dismiss);
    TextView popup_load = (TextView) popupWindow.findViewById(R.id.tv_load);
    TextView popup_camera = (TextView) popupWindow.findViewById(R.id.tv_photo);
    popup_dismiss.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getPopupWindowInstance();
        }
    });
    popup_load.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // 
            getPopupWindowInstance();
            loadPhotos();

        }
    });
    popup_camera.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // ?
            getPopupWindowInstance();
            selectPicFromCamera();
        }
    });
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {

    case MSG_GET_PAGE:
        String url = (String) msg.obj;
        if (url != null) {
            WallyApplication.getDataProviderInstance().getPageData(url,
                    new DataProvider.OnPageReceivedListener() {
                        @Override
                        public void onPageReceived(ImagePage imagePage) {
                            Message msgObj = uiHandler.obtainMessage();
                            msgObj.what = MSG_PAGE_FETCHED;
                            msgObj.obj = imagePage;
                            uiHandler.sendMessage(msgObj);
                        }/*  ww  w.ja v a 2  s  .  co  m*/

                        @Override
                        public void onError(DataProviderError error) {
                            Message msgObj = uiHandler.obtainMessage();
                            msgObj.what = MSG_PAGE_ERROR;
                            msgObj.obj = error;
                            uiHandler.sendMessage(msgObj);
                        }
                    });
        }
        break;

    case MSG_SAVE_TO_FILE:
        int what = msg.arg1;
        saveToFile(what);
        break;

    case MSG_PAGE_FETCHED:
        imagePage = (ImagePage) msg.obj;
        if (imagePage != null) {
            textViewUploader.setText(imagePage.uploader());
            textViewUploadDate.setText(imagePage.uploadDate());
            textViewSource.setText(imagePage.author().name());
            if (imagePage.author().page() != Uri.EMPTY) {
                textViewSource.setTextColor(getResources().getColor(R.color.Holo_Blue_Dark));
                textViewSource.setTag(imagePage.author());
                textViewSource.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Author author = (Author) v.getTag();
                        if (author.page() != Uri.EMPTY) {
                            Intent browserIntent = new Intent(Intent.ACTION_VIEW, author.page());
                            startActivity(browserIntent);
                        }
                    }
                });
            }
            textViewResolution.setText(imagePage.resolution());
            textViewCategory.setText(imagePage.category());
            textViewRating.setText(imagePage.rating());
            final String imageUrl = imagePage.imagePath().toString();

            if (imagePage.tags().size() > 0) {
                flowLayoutTags.removeAllViews();
                for (final Tag tag : imagePage.tags()) {
                    View tagView = getLayoutInflater().inflate(R.layout.view_tag_item, flowLayoutTags, false);
                    TextView tagTextView = (TextView) tagView.findViewById(R.id.tag_item_text);
                    tagTextView.setText(tag.name());

                    flowLayoutTags.addView(tagView);

                    tagTextView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            WallyApplication.getSearchFragmentMessages().put(SearchFragment.EXTRA_MESSAGE_TAG,
                                    tag.name());
                            Intent intent = new Intent();
                            setResult(RESULT_OK, intent);
                            ImageDetailsActivity.this.finish();
                        }
                    });
                }
            } else {
                findViewById(R.id.image_details_tags_title).setVisibility(View.GONE);
                flowLayoutTags.setVisibility(View.GONE);
            }

            Glide.with(getApplicationContext()).load(imageUrl).placeholder(photoView.getDrawable()).fitCenter()
                    .listener(new RequestListener<String, GlideDrawable>() {
                        @Override
                        public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                                boolean isFirstResource) {
                            hideLoader();
                            //TODO: maybe show a retry button?
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(GlideDrawable resource, String model,
                                Target<GlideDrawable> target, boolean isFromMemoryCache,
                                boolean isFirstResource) {

                            photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);

                            renderTags(((GlideBitmapDrawable) resource.getCurrent()).getBitmap());
                            renderColors(((GlideBitmapDrawable) resource.getCurrent()).getBitmap());
                            photoView.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    toggleZoomImage();
                                }
                            });
                            hideLoader();

                            Size size = fitToWidthAndKeepRatio(imagePage.getImageWidth(),
                                    imagePage.getImageHeight());

                            imageSize = size;

                            setupPaddings(size, true);

                            scrollUpToolbarIfNeeded();

                            return false;
                        }
                    }).into(photoView);

            specsLayout.setAlpha(1.0f);
            specsLayout.scheduleLayoutAnimation();

            enableParallaxEffect(scrollView, photoLayoutHolder);
        }
        break;

    case MSG_PAGE_ERROR:
        DataProviderError dataProviderError = (DataProviderError) msg.obj;
        if (dataProviderError != null) {
            Toast.makeText(ImageDetailsActivity.this,
                    dataProviderError.getHttpStatusCode() + ": " + dataProviderError.getMessage(),
                    Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(ImageDetailsActivity.this, getString(R.string.toast_error_default),
                    Toast.LENGTH_SHORT).show();
        }
        break;

    case MSG_IMAGE_REQUEST_READY_FOR_SETTING:
        Uri savedImageDataForWallpaper = (Uri) msg.obj;
        if (savedImageDataForWallpaper != null) {
            setImageAsWallpaperPicker(savedImageDataForWallpaper);
        }
        break;

    case MSG_IMAGE_REQUEST_SAVED:
        updateSaveButton();
        break;

    case MSG_IMAGE_REQUEST_SAVING:
        if (buttonSave != null) {
            buttonSave.setText(getString(R.string.saving));
            buttonSave.setAlpha(0.50f);
        }
        break;

    case MSG_RENDER_PALETTE:

        Bitmap bitmap1 = (Bitmap) msg.obj;
        Palette palette = Palette.generate(bitmap1);

        Message msgObj = uiHandler.obtainMessage();
        msgObj.what = MSG_SET_IMAGE_AND_PALETTE;
        msgObj.obj = palette;
        uiHandler.sendMessage(msgObj);

        break;

    case MSG_SET_IMAGE_AND_PALETTE:
        Palette renderedPalette = (Palette) msg.obj;
        setColors(renderedPalette);
        break;

    case MSG_SCROLL_UP_SCROLLVIEW:
        int targetScroll = msg.arg1;
        scrollView.smoothScrollTo(0, targetScroll);
        break;

    }
    return false;
}