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:com.money.manager.ex.assetallocation.AssetClassEditFragment.java

private void initializeParentEdit(View view) {
    TextView edit = (TextView) view.findViewById(R.id.parentAssetClass);
    if (edit == null)
        return;/*from   www  .j av a 2s .c  om*/

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // show asset allocation selector.
            // send the allocation id to exclude from the selection list.
            Intent intent = new Intent(getContext(), AssetClassListActivity.class);
            intent.putExtra(AssetClassListActivity.EXTRA_ASSET_CLASS_ID, assetClass.getId());
            startActivityForResult(intent, REQUEST_ASSET_CLASS_PARENT);
        }
    };

    // allow changing parent only on existing items
    if (getActivity().getIntent().getAction().equals(Intent.ACTION_EDIT)) {
        edit.setOnClickListener(onClickListener);
    }

    displayParent();
}

From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.SR167TollRatesFragment.java

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

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_dynamic_toll_rates, null);

    mRecyclerView = root.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new SR167TollRatesItemAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);/*from w  ww.j av  a2  s.c  o m*/

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    mRecyclerView.setPadding(0, 0, 0, 120);

    addDisclaimerView(root);

    directionRadioGroup = root.findViewById(R.id.segment_control);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
    radioGroupDirectionIndex = sharedPref.getInt(getString(R.string.toll_rates_167_travel_direction_key), 0);

    if (radioGroupDirectionIndex == 0) {
        RadioButton leftSegment = root.findViewById(R.id.radio_left);
        leftSegment.setChecked(true);
    } else {
        RadioButton rightSegment = root.findViewById(R.id.radio_right);
        rightSegment.setChecked(true);
    }

    directionRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {

        RadioButton selectedDirection = directionRadioGroup.findViewById(checkedId);

        mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));

        mLayoutManager.scrollToPositionWithOffset(0, 0);
        SharedPreferences sharedPref1 = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sharedPref1.edit();

        radioGroupDirectionIndex = directionRadioGroup.indexOfChild(selectedDirection);

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);
        travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));

        editor.putInt(getString(R.string.toll_rates_167_travel_direction_key), radioGroupDirectionIndex);

        editor.apply();

    });

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);

    mEmptyView = root.findViewById(R.id.empty_list_view);

    TextView header_link = root.findViewById(R.id.header_text);

    // create spannable string for underline
    SpannableString content = new SpannableString(
            getActivity().getResources().getString(R.string.sr167_info_link));
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    header_link.setText(content);

    header_link.setTextColor(getResources().getColor(R.color.primary_default));
    header_link.setOnClickListener(v -> {
        Intent intent = new Intent();
        // GA tracker
        mTracker = ((WsdotApplication) getActivity().getApplication()).getDefaultTracker();
        mTracker.setScreenName("/Toll Rates/Learn about SR-167");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.wsdot.wa.gov/Tolling/SR167HotLanes/HOTtollrates.htm"));
        startActivity(intent);

    });

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(TollRatesViewModel.class);

    viewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                swipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                swipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show();
            }
        }
    });

    viewModel.getSR167TollRateItems().observe(this, tollRateGroups -> {
        if (tollRateGroups != null) {
            mEmptyView.setVisibility(View.GONE);

            Collections.sort(tollRateGroups, new SortTollGroupByLocation());
            Collections.sort(tollRateGroups, new SortTollGroupByDirection());

            tollGroups = new ArrayList<>(tollRateGroups);

            directionRadioGroup.getCheckedRadioButtonId();
            RadioButton selectedDirection = directionRadioGroup
                    .findViewById(directionRadioGroup.getCheckedRadioButtonId());

            mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));
        }
    });

    viewModel.getTravelTimesForETLFor("167").observe(this, travelTimes -> {

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);

        if (travelTimes.size() > 0) {
            travelTimeView.setVisibility(View.VISIBLE);

            this.travelTimes = new ArrayList<>(travelTimes);

            travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));
        } else {

            travelTimeView.setVisibility(View.GONE);
        }
    });

    timer = new Timer();
    timer.schedule(new SR167TollRatesFragment.RatesTimerTask(), 0, 60000); // Schedule rates to update every 60 seconds

    return root;
}

From source file:com.birdeye.MainActivity.java

private void removeAdsDialog() {

    final Dialog dialog = new Dialog(MainActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.progress_pre);

    TextView tv_pay15 = (TextView) dialog.findViewById(R.id.tv_pay15);

    tv_pay15.setOnClickListener(new View.OnClickListener() {
        @Override/*from w ww  .  j a va  2 s . c o  m*/
        public void onClick(View v) {

            if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) {
                showToast(
                        "In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16");
            }

            else {

                //    asdasd

                //  onFuturePaymentPressed(v);
                bp.subscribe(MainActivity.this, SUBSCRIPTION_ID);

            }

            dialog.dismiss();

        }
    });

    dialog.setCancelable(true);

    dialog.show();

}

From source file:com.doomy.decode.ResultDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater mLayoutInflater = LayoutInflater.from(getActivity());
    View mView = mLayoutInflater.inflate(R.layout.view_result, null);

    TextView mTextViewFormat = (TextView) mView.findViewById(R.id.textViewFormat);
    TextView mTextViewContent = (TextView) mView.findViewById(R.id.textViewContent);

    if (mTitle.equals("EAN 13") && mMessage.startsWith("978")) {
        GetResponseTask mGetResponseTask = new GetResponseTask();
        mGetResponseTask.execute(mMessage);

        try {//from   w  ww  . j  a v a2 s  .c  o m
            if (mGetResponseTask.get().equals("")) {
                mTitle = "ISBN";
                mTextViewContent.setText(mMessage);
            } else {
                mTitle = "ISBN";
                mMessage = mGetResponseTask.get();
                SpannableString mSpan = new SpannableString(mMessage);
                mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0);
                mTextViewContent.setText(mSpan);
                mTextViewContent.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        createURLIntent(makeURLSearch(mMessage));
                    }
                });
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    } else if (mTitle.equals("ISBN")) {
        if (!mMessage.startsWith("978")) {
            SpannableString mSpan = new SpannableString(mMessage);
            mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0);
            mTextViewContent.setText(mSpan);
            mTextViewContent.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    createURLIntent(makeURLSearch(mMessage));
                }
            });
        } else {
            mTextViewContent.setText(mMessage);
        }
    } else if (mMessage.startsWith("www") || mMessage.startsWith("http://")
            || mMessage.startsWith("https://")) {
        SpannableString mSpan = new SpannableString(mMessage);
        mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0);
        mTextViewContent.setText(mSpan);
        mTextViewContent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                createURLIntent(mMessage);
            }
        });
    } else {
        mTextViewContent.setText(mMessage);
    }

    if (mKey) {
        SimpleDateFormat mDateFormat = new SimpleDateFormat("dd/MM/yyyy-HH:mm");
        String mDate = mDateFormat.format(new Date());
        Scan mScan = new Scan(mTitle, mMessage, mDate);
        mDB.addOne(mScan);
    }

    mTextViewFormat.setText(mTitle);

    AlertDialog.Builder mAlertBuilder = new AlertDialog.Builder(getActivity(), Utils.setThemeDialog());

    mAlertBuilder.setTitle(getString(R.string.info)).setView(mView).setPositiveButton(getString(R.string.okay),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    if (mListener != null) {
                        mListener.onDialogPositiveClick(ResultDialogFragment.this);
                    }
                }
            });

    return mAlertBuilder.create();
}

From source file:com.coinblesk.client.ui.dialogs.CurrencyDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    final View view = inflater.inflate(R.layout.fragment_currency_dialog, null);

    final Spinner spinner = (Spinner) view.findViewById(R.id.currency_spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), R.layout.spinner_item,
            Constants.CURRENCIES);//from w  w w.  ja v  a 2s  .  c  om
    spinner.setSelection(0, false);
    spinner.setAdapter(adapter);

    final TextView usd = (TextView) view.findViewById(R.id.usd);
    final TextView eur = (TextView) view.findViewById(R.id.eur);

    final TextView btc = (TextView) view.findViewById(R.id.btc);
    final TextView mbtc = (TextView) view.findViewById(R.id.mbtc);
    final TextView ubtc = (TextView) view.findViewById(R.id.ubtc);

    final View[] viewsBTC = new View[] { btc, mbtc, ubtc };
    final View[] viewsFiat = new View[] { usd, eur, spinner };

    final AlertDialog d = new AlertDialog.Builder(getActivity()).setTitle(R.string.change_currency)
            .setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    broadcastExchangeRateChanged(getActivity());
                }
            }).create();

    btc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (View v : viewsBTC) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            view.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setBitcoinScalePrefix(getActivity(), "BTC");
        }
    });

    mbtc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (View v : viewsBTC) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            view.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setBitcoinScalePrefix(getActivity(), "mBTC");
        }
    });

    ubtc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (View v : viewsBTC) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            view.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setBitcoinScalePrefix(getActivity(), "BTC");
        }
    });

    usd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (View v : viewsFiat) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            view.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setCurrency(getActivity(), "USD");
        }
    });

    eur.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (View v : viewsFiat) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            view.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setCurrency(getActivity(), "EUR");
        }
    });

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0) {
                return;
            }
            for (View v : viewsFiat) {
                v.setBackgroundResource(R.drawable.cell_shape);
            }
            spinner.setBackgroundResource(R.drawable.cell_shape_currency);
            SharedPrefUtils.setCurrency(getActivity(), Constants.CURRENCIES[position]);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            //activateSpinner(s, usd, eur);
        }
    });

    loadSettings(getActivity(), btc, mbtc, ubtc, usd, eur, spinner);

    return d;
}

From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java

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

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_dynamic_toll_rates, null);

    mRecyclerView = root.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new I405TollRatesItemAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);/*from   w  ww  .j  a va2  s  .  c om*/

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    mRecyclerView.setPadding(0, 0, 0, 120);

    addDisclaimerView(root);

    directionRadioGroup = root.findViewById(R.id.segment_control);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
    radioGroupDirectionIndex = sharedPref.getInt(getString(R.string.toll_rates_405_travel_direction_key), 0);

    if (radioGroupDirectionIndex == 0) {
        RadioButton leftSegment = root.findViewById(R.id.radio_left);
        leftSegment.setChecked(true);
    } else {
        RadioButton rightSegment = root.findViewById(R.id.radio_right);
        rightSegment.setChecked(true);
    }

    directionRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {

        RadioButton selectedDirection = directionRadioGroup.findViewById(checkedId);

        mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));

        mLayoutManager.scrollToPositionWithOffset(0, 0);
        SharedPreferences sharedPref1 = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sharedPref1.edit();

        radioGroupDirectionIndex = directionRadioGroup.indexOfChild(selectedDirection);

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);
        travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));

        editor.putInt(getString(R.string.toll_rates_405_travel_direction_key), radioGroupDirectionIndex);

        editor.apply();

    });

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);

    mEmptyView = root.findViewById(R.id.empty_list_view);

    TextView header_link = root.findViewById(R.id.header_text);

    // create spannable string for underline
    SpannableString content = new SpannableString(
            getActivity().getResources().getString(R.string.i405_info_link));
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    header_link.setText(content);

    header_link.setTextColor(getResources().getColor(R.color.primary_default));
    header_link.setOnClickListener(v -> {
        Intent intent = new Intent();
        // GA tracker
        mTracker = ((WsdotApplication) getActivity().getApplication()).getDefaultTracker();
        mTracker.setScreenName("/Toll Rates/Learn about I-405");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.wsdot.wa.gov/Tolling/405/rates.htm"));
        startActivity(intent);
    });

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(TollRatesViewModel.class);

    viewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                swipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                swipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show();
            }
        }
    });

    viewModel.getTravelTimesStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                break;
            case SUCCESS:
                root.findViewById(R.id.travel_time_text).setVisibility(View.VISIBLE);
                break;
            case ERROR:
                root.findViewById(R.id.travel_time_text).setVisibility(View.GONE);
            }
        }
    });

    viewModel.getI405TollRateItems().observe(this, tollRateGroups -> {
        if (tollRateGroups != null) {

            mEmptyView.setVisibility(View.GONE);

            Collections.sort(tollRateGroups, new SortTollGroupByLocation());
            Collections.sort(tollRateGroups, new SortTollGroupByDirection());

            tollGroups = new ArrayList<>(tollRateGroups);

            directionRadioGroup.getCheckedRadioButtonId();
            RadioButton selectedDirection = directionRadioGroup
                    .findViewById(directionRadioGroup.getCheckedRadioButtonId());

            mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));
        }
    });

    viewModel.getTravelTimesForETLFor("405").observe(this, travelTimes -> {

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);

        if (travelTimes.size() > 0) {
            travelTimeView.setVisibility(View.VISIBLE);

            this.travelTimes = new ArrayList<>(travelTimes);

            travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));
        } else {
            travelTimeView.setVisibility(View.GONE);
        }
    });

    timer = new Timer();
    timer.schedule(new RatesTimerTask(), 0, 60000); // Schedule rates to update every 60 seconds

    return root;
}

From source file:io.plaidapp.designernews.ui.story.StoryActivity.java

private void bindDescription() {
    final TextView storyComment = header.findViewById(R.id.story_comment);
    if (!TextUtils.isEmpty(story.getComment())) {

        ColorStateList linksColor = ContextCompat.getColorStateList(this, R.color.designer_news_links);
        int highlightColor = ContextCompat.getColor(this, io.plaidapp.R.color.designer_news_link_highlight);

        CharSequence text = HtmlUtils.parseMarkdownAndPlainLinks(story.getComment(), markdown, linksColor,
                highlightColor,//from   w w w  .  jav  a 2 s .co  m
                (src, loadingSpan) -> GlideApp.with(StoryActivity.this).asBitmap().load(src)
                        .transition(BitmapTransitionOptions.withCrossFade())
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(new ImageSpanTarget(storyComment, loadingSpan)));

        HtmlUtils.setTextWithNiceLinks(storyComment, text);

    } else {
        storyComment.setVisibility(View.GONE);
    }

    upvoteStory = header.findViewById(R.id.story_vote_action);
    storyUpvoted(story.getVoteCount());
    upvoteStory.setOnClickListener(v -> upvoteStory());

    final TextView share = header.findViewById(R.id.story_share_action);
    share.setOnClickListener(v -> {
        ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start();
        ShareCompat.IntentBuilder.from(StoryActivity.this).setText(story.getUrl()).setType("text/plain")
                .setSubject(story.getTitle()).startChooser();
    });

    TextView storyPosterTime = header.findViewById(R.id.story_poster_time);
    if (story.getUserDisplayName() != null && story.getUserJob() != null) {
        CharSequence storyPosterTimeText = getStoryPosterTimeText(story.getUserDisplayName(),
                story.getUserJob(), story.getCreatedAt());
        storyPosterTime.setText(storyPosterTimeText);
    }
    ImageView avatar = header.findViewById(R.id.story_poster_avatar);
    if (!TextUtils.isEmpty(story.getUserPortraitUrl())) {
        GlideApp.with(this).load(story.getUserPortraitUrl()).transition(withCrossFade())
                .placeholder(io.plaidapp.R.drawable.avatar_placeholder).circleCrop().into(avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
}

From source file:com.jekyll.wu.widget.FreeSnackBar.java

/**
 * Set the action to be displayed in this {@link FreeSnackBar}.
 *
 * @param text     Text to display//from   w w  w .j  av a 2s .  c  om
 * @param listener callback to be invoked when the action is clicked
 */
@NonNull
public FreeSnackBar setAction(CharSequence text, final View.OnClickListener listener) {
    final TextView tv = mView.getActionView();

    if (TextUtils.isEmpty(text) || listener == null) {
        tv.setVisibility(View.GONE);
        tv.setOnClickListener(null);
    } else {
        tv.setVisibility(View.VISIBLE);
        tv.setText(text);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClick(view);
                // Now dismiss the FreeSnackBar
                dispatchDismiss(Callback.DISMISS_EVENT_ACTION);
            }
        });
    }
    return this;
}

From source file:com.kaku.weac.fragment.AlarmClockOntimeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    LogUtil.d(LOG_TAG, getActivity().toString() + "onCreateView");

    View view = inflater.inflate(R.layout.fm_alarm_clock_ontime, container, false);
    mTimeTv = (TextView) view.findViewById(R.id.ontime_time);
    // //w  w  w.j ava2 s  .  com
    mTimeTv.setText(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
    mCurrentTimeDisplay = mTimeTv.getText().toString();
    // ?
    new Thread(new TimeUpdateThread()).start();

    // 
    TextView tagTv = (TextView) view.findViewById(R.id.ontime_tag);
    tagTv.setText(mAlarmClock.getTag());

    // ??
    TextView napTv = (TextView) view.findViewById(R.id.ontime_nap);
    // ????
    if (mAlarmClock.isNap()) {
        // X???????
        if (mNapTimesRan != mNapTimes) {
            // ??
            napTv.setText(String.format(getString(R.string.touch_here_nap), mNapInterval));
            napTv.setOnClickListener(this);
        } else {
            napTv.setVisibility(View.GONE);
        }
    } else {
        napTv.setVisibility(View.GONE);
    }

    LogUtil.i(LOG_TAG, "??" + mNapTimes);

    // ??
    TextView slidingTipIv = (TextView) view.findViewById(R.id.sliding_tip_tv);
    final AnimationDrawable animationDrawable = (AnimationDrawable) slidingTipIv.getCompoundDrawables()[0];
    // ?4.0
    slidingTipIv.post(new Runnable() {
        @Override
        public void run() {
            animationDrawable.start();
        }
    });

    MySlidingView mySlidingView = (MySlidingView) view.findViewById(R.id.my_sliding_view);
    mySlidingView.setSlidingTipListener(new MySlidingView.SlidingTipListener() {
        @Override
        public void onSlidFinish() {
            // ?
            finishActivity();
        }
    });

    // ??
    if (mAlarmClock.isWeaPrompt()) {
        mWeatherInfoGroup = (ViewGroup) view.findViewById(R.id.weather_info_group);
        mWeatherPbar = (ProgressBar) view.findViewById(R.id.progress_bar);
        mWeatherTypeTv = (TextView) view.findViewById(R.id.weather_type_tv);
        mUmbrellaTv = (TextView) view.findViewById(R.id.umbrella_tv);
        // ?
        initWeather();
    }
    return view;
}

From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java

private void displayTags(SessionDetailModel data) {
    if (data.getTagMetadata() == null || data.getTagsString() == null) {
        mTagsContainer.setVisibility(View.GONE);
        return;/* w ww  . j a  v  a  2s.co m*/
    }

    if (TextUtils.isEmpty(data.getTagsString())) {
        mTagsContainer.setVisibility(View.GONE);
    } else {
        mTagsContainer.setVisibility(View.VISIBLE);
        mTags.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(getContext());
        String[] tagIds = data.getTagsString().split(",");

        List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>();
        for (String tagId : tagIds) {
            if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                continue;
            }

            TagMetadata.Tag tag = data.getTagMetadata().getTag(tagId);
            if (tag == null) {
                continue;
            }

            tags.add(tag);
        }

        if (tags.size() == 0) {
            mTagsContainer.setVisibility(View.GONE);
            return;
        }

        Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR);

        for (final TagMetadata.Tag tag : tags) {
            TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false);
            chipView.setText(tag.getName());
            chipView.setContentDescription(getString(R.string.talkback_button, tag.getName()));
            chipView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(getContext(), ExploreSessionsActivity.class)
                            .putExtra(ExploreSessionsActivity.EXTRA_FILTER_TAG, tag.getId())
                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            });

            mTags.addView(chipView);
        }
    }
}