Example usage for android.widget TextView setTextColor

List of usage examples for android.widget TextView setTextColor

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setTextColor(ColorStateList colors) 

Source Link

Document

Sets the text color.

Usage

From source file:com.breadwallet.tools.adapter.TransactionListAdapter.java

public View getTxView(View tmpLayout, int position) {
    TextView sentReceivedTextView = (TextView) tmpLayout.findViewById(R.id.transaction_sent_received_label);
    TextView dateTextView = (TextView) tmpLayout.findViewById(R.id.transaction_date);
    TextView bitsTextView = (TextView) tmpLayout.findViewById(R.id.transaction_amount_bits);
    TextView dollarsTextView = (TextView) tmpLayout.findViewById(R.id.transaction_amount_dollars);
    TextView bitsTotalTextView = (TextView) tmpLayout.findViewById(R.id.transaction_amount_bits_total);
    TextView dollarsTotalTextView = (TextView) tmpLayout.findViewById(R.id.transaction_amount_dollars_total);
    Utils.overrideFonts(sentReceivedTextView, dateTextView, bitsTextView, dollarsTextView, bitsTotalTextView,
            dollarsTotalTextView);/*  w w w .  j  av a  2  s . c om*/
    tmpLayout.setBackgroundResource(R.drawable.clickable_layout);

    bitsTextView.setVisibility(BreadWalletApp.unlocked ? View.VISIBLE : View.INVISIBLE);
    bitsTotalTextView.setVisibility(BreadWalletApp.unlocked ? View.VISIBLE : View.INVISIBLE);
    dollarsTextView.setVisibility(BreadWalletApp.unlocked ? View.VISIBLE : View.INVISIBLE);
    dollarsTotalTextView.setVisibility(BreadWalletApp.unlocked ? View.VISIBLE : View.INVISIBLE);

    final TransactionListItem item = data.get(position);

    tmpLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) activity.getFragmentManager()
                        .findFragmentByTag(FragmentSettingsAll.class.getName());
                FragmentTransactionExpanded fragmentTransactionExpanded = new FragmentTransactionExpanded();
                fragmentTransactionExpanded.setCurrentObject(item);
                BRAnimator.animateSlideToLeft((MainActivity) activity, fragmentTransactionExpanded,
                        fragmentSettingsAll);
            }
        }
    });

    boolean received = item.getSent() == 0;
    int blockHeight = item.getBlockHeight();

    int confirms = blockHeight == Integer.MAX_VALUE ? 0
            : SharedPreferencesManager.getLastBlockHeight(activity) - blockHeight + 1;

    if (item.getSent() > 0 && item.getSent() == item.getReceived()) {
        sentReceivedTextView.setBackgroundResource(R.drawable.unconfirmed_label);
        sentReceivedTextView.setText(R.string.moved);
        sentReceivedTextView.setTextColor(unconfirmedColor);
    } else if (blockHeight != Integer.MAX_VALUE && confirms >= 6) {
        sentReceivedTextView
                .setBackgroundResource(received ? R.drawable.received_label : R.drawable.sent_label);
        sentReceivedTextView.setText(received ? R.string.received : R.string.sent);
        sentReceivedTextView.setTextColor(received ? receivedColor : sentColor);
    } else {
        sentReceivedTextView.setBackgroundResource(R.drawable.unconfirmed_label);
        sentReceivedTextView.setTextColor(unconfirmedColor);
        if (!BRWalletManager.getInstance(activity).transactionIsVerified(item.getHexId())) {
            sentReceivedTextView.setText(R.string.unverified);
        } else {
            int confsNr = confirms >= 0 && confirms <= 5 ? confirms : 0;
            String message = confsNr == 0 ? activity.getString(R.string.nr_confirmations0)
                    : (confsNr == 1 ? activity.getString(R.string.nr_confirmations1)
                            : String.format(activity.getString(R.string.nr_confirmations), confsNr));

            sentReceivedTextView.setText(message);
        }
    }

    long itemTimeStamp = item.getTimeStamp();
    dateTextView.setText(itemTimeStamp != 0 ? Utils.getFormattedDateFromLong(itemTimeStamp * 1000)
            : Utils.getFormattedDateFromLong(System.currentTimeMillis()));

    long satoshisAmount = received ? item.getReceived() : (item.getSent() - item.getReceived()) * -1;

    bitsTextView.setText(BRStringFormatter.getFormattedCurrencyString("BTC", satoshisAmount));
    dollarsTextView.setText(String.format("(%s)",
            BRStringFormatter.getExchangeForAmount(SharedPreferencesManager.getRate(activity),
                    SharedPreferencesManager.getIso(activity), new BigDecimal(satoshisAmount), activity)));
    long satoshisAfterTx = item.getBalanceAfterTx();

    bitsTotalTextView.setText(BRStringFormatter.getFormattedCurrencyString("BTC", satoshisAfterTx));
    dollarsTotalTextView.setText(String.format("(%s)",
            BRStringFormatter.getExchangeForAmount(SharedPreferencesManager.getRate(activity),
                    SharedPreferencesManager.getIso(activity), new BigDecimal(satoshisAfterTx), activity)));
    return tmpLayout;
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

public LinearLayout createResourceEmptyView() {

    LinearLayout scrollChild = new LinearLayout(this);
    scrollChild.setPadding(10, 0, 10, 0);
    resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
    TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
    title.setText("Sorry! No Results Found");
    title.setTextColor(getResources().getColor(R.color.Grey));
    title.setPadding(50, 50, 0, 10);//from  www  .  j ava2 s.  com
    title.setTextSize(25);

    scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    scrollChild.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
    return scrollChild;
}

From source file:com.android.dialer.DialtactsFragment.java

/**
 * @author bbk wangchunhe/*from   w w  w  . jav a2  s  .  c  o  m*/
 * @Date 2016/07/15
 * add PopupWindow OnClickListener
 * @param popupWindow
 */
private void popupWindowItemSelect(final PopupWindow popupWindow) {
    View contentView = popupWindow.getContentView();
    RelativeLayout callLogsContainer = (RelativeLayout) contentView
            .findViewById(R.id.dialtacts_popupwindow_all_calls_cantainer);
    final TextView callLogsTxt = (TextView) contentView.findViewById(R.id.dialtacts_popupwindow_all_calls_txt);
    final ImageView callLogsImage = (ImageView) contentView
            .findViewById(R.id.dialtacts_popupwindow_all_calls_image);

    RelativeLayout callLogMissedContainer = (RelativeLayout) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_container);
    final TextView callLogMissedTxt = (TextView) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_txt);
    final ImageView callLogMissedImage = (ImageView) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_image);

    ColorStateList colorStateListTxt = getActivity().getColorStateList(R.color.popupwindows_item_text_color);
    ColorStateList colorStateListImage = getActivity().getColorStateList(R.color.popupwindows_item_image_color);

    callLogsImage.setImageTintList(colorStateListImage);
    callLogMissedImage.setImageTintList(colorStateListImage);

    callLogsTxt.setTextColor(colorStateListTxt);
    callLogMissedTxt.setTextColor(colorStateListTxt);

    if (!callLogMissedImage.isSelected()) {
        callLogsImage.setSelected(true);
        callLogsTxt.setSelected(true);
    }

    callLogsContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            callLogsImage.setSelected(true);
            callLogsTxt.setSelected(true);
            callLogMissedImage.setSelected(false);
            callLogMissedTxt.setSelected(false);
            showCallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL);
            //                mActionbarNameTxt.setText(getString(R.string.all_calls));
            //                mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log);
            Log.e(TAG, " action Name  --1" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mDialtactsActionBarController.setActionName(getString(R.string.all_calls));
            Log.e(TAG, " action Name  --2" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mCallLogSelectPopupWindow.dismiss();

        }
    });

    callLogMissedContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            callLogsImage.setSelected(false);
            callLogsTxt.setSelected(false);
            callLogMissedImage.setSelected(true);
            callLogMissedTxt.setSelected(true);
            showCallLogFragment(Calls.MISSED_TYPE);
            //                mActionbarNameTxt.setText(getString(R.string.call_log_missed));
            //                mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log);
            Log.e(TAG, " action Name  --3" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mDialtactsActionBarController.setActionName(getString(R.string.call_log_missed));
            Log.e(TAG, " action Name  --4" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mCallLogSelectPopupWindow.dismiss();

        }
    });

}

From source file:com.android.mms.ui.MessageUtils.java

public static void setSubIconAndLabel(int subId, String subName, TextView subView) {
    Log.i(TAG, "setSubIconAndLabel subId=" + subId);
    int textColor = 0;
    if (subView == null) {
        return;/*  ww  w.j av a2s .c  o m*/
    }
    int activeSubCount = SubscriptionManager.from(MmsApp.getApplication()).getActiveSubscriptionInfoCount();

    if (subName == null && activeSubCount > 1) {
        SubscriptionInfo subInfo = SubscriptionManager.from(MmsApp.getApplication())
                .getActiveSubscriptionInfo(subId);
        Log.d(TAG, "subInfo=" + subInfo);
        if (null != subInfo) {
            if ((subInfo.getSimSlotIndex() == SubscriptionManager.SIM_NOT_INSERTED)
                    || (subInfo.getSimSlotIndex() == SubscriptionManager.INVALID_SUBSCRIPTION_ID)) {
                Log.i(TAG, "current not insert sim card");
            } else {
                subName = subInfo.getDisplayName().toString();
                textColor = subInfo.getIconTint();
            }
        } else {
            Log.i(TAG, "subInfo is null ");
        }
    }

    if (subName == null || activeSubCount <= 1) {
        subView.setVisibility(View.GONE);
    } else {
        subView.setVisibility(View.VISIBLE);
        subView.setTextColor(textColor);
        subView.setText(subName);
    }
}

From source file:com.android.argb.edhlc.Utils.java

public static void createRecordListElement(Activity parent, Record currentRecord,
        String highlightedPlayerName) {
    TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard);
    LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard);
    TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard);
    TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard);
    TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard);

    View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard);

    LinearLayout linearSecondLineRecordCard = (LinearLayout) parent
            .findViewById(R.id.linearSecondLineRecordCard);
    TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard);
    TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard);
    TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard);

    View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard);

    LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard);
    TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard);
    TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard);
    TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard);

    View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard);

    LinearLayout linearFourthLineRecordCard = (LinearLayout) parent
            .findViewById(R.id.linearFourthLineRecordCard);
    TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard);
    TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard);
    TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard);

    Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL);
    Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL);
    int colorAccent = ContextCompat.getColor(parent, R.color.accent_color);
    int colorSecondary = ContextCompat.getColor(parent, R.color.secondary_text);

    textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate()));

    switch (currentRecord.getTotalPlayers()) {
    case 2://w  w w .  j a va  2s . c  om
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.GONE);
        linearFourthLineRecordCard.setVisibility(View.GONE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.GONE);
        divider3RecordCard.setVisibility(View.GONE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;

    case 3:
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.VISIBLE);
        linearFourthLineRecordCard.setVisibility(View.GONE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.VISIBLE);
        divider3RecordCard.setVisibility(View.GONE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName());
        textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textThirdDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textThirdIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;

    case 4:
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.VISIBLE);
        linearFourthLineRecordCard.setVisibility(View.VISIBLE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.VISIBLE);
        divider3RecordCard.setVisibility(View.VISIBLE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName());
        textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName());

        textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName());
        textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textThirdDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textThirdIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textFourthDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFourthPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFourthIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFourthIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;
    }
}

From source file:com.android.argb.edhlc.Utils.java

public static void createRecordListElement(View parent, Record currentRecord, String highlightedPlayerName) {
    RelativeLayout selectedRecord = (RelativeLayout) parent.findViewById(R.id.selectedRecord);
    selectedRecord.setVisibility(currentRecord.isSelected() ? View.VISIBLE : View.GONE);

    TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard);
    LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard);
    TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard);
    TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard);
    TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard);

    View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard);

    LinearLayout linearSecondLineRecordCard = (LinearLayout) parent
            .findViewById(R.id.linearSecondLineRecordCard);
    TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard);
    TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard);
    TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard);

    View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard);

    LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard);
    TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard);
    TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard);
    TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard);

    View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard);

    LinearLayout linearFourthLineRecordCard = (LinearLayout) parent
            .findViewById(R.id.linearFourthLineRecordCard);
    TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard);
    TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard);
    TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard);

    Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL);
    Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL);
    int colorAccent = ContextCompat.getColor(parent.getContext(), R.color.accent_color);
    int colorSecondary = ContextCompat.getColor(parent.getContext(), R.color.secondary_text);

    textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate()));

    switch (currentRecord.getTotalPlayers()) {
    case 2://from ww  w  .  ja v  a2 s  .c  o  m
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.GONE);
        linearFourthLineRecordCard.setVisibility(View.GONE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.GONE);
        divider3RecordCard.setVisibility(View.GONE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;

    case 3:
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.VISIBLE);
        linearFourthLineRecordCard.setVisibility(View.GONE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.VISIBLE);
        divider3RecordCard.setVisibility(View.GONE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName());
        textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textThirdDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textThirdIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;

    case 4:
        linearFirstLineRecordCard.setVisibility(View.VISIBLE);
        linearSecondLineRecordCard.setVisibility(View.VISIBLE);
        linearThirdLineRecordCard.setVisibility(View.VISIBLE);
        linearFourthLineRecordCard.setVisibility(View.VISIBLE);

        divider1RecordCard.setVisibility(View.VISIBLE);
        divider2RecordCard.setVisibility(View.VISIBLE);
        divider3RecordCard.setVisibility(View.VISIBLE);

        textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName());
        textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName());

        textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName());
        textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName());

        textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName());
        textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName());

        textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName());
        textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName());

        if (highlightedPlayerName != null) {
            textFirstDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFirstIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFirstIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textSecondDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textSecondIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textSecondIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textThirdDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textThirdIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textThirdIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);

            textFourthDeckRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFourthPlayerRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
            textFourthIndicatorRecordCard.setTextColor(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? colorAccent
                            : colorSecondary);
            textFourthIndicatorRecordCard.setTypeface(
                    highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName())
                            ? typefaceMedium
                            : typefaceNormal);
        }
        break;
    }
}

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity,
        HttpClient client, RedditSettings settings,
        ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) {

    Resources res = activity.getResources();

    TextView titleView = (TextView) view.findViewById(R.id.title);
    TextView votesView = (TextView) view.findViewById(R.id.votes);
    TextView numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit);
    TextView nsfwView = (TextView) view.findViewById(R.id.nsfw);
    //        TextView submissionTimeView = (TextView) view.findViewById(R.id.submissionTime);
    ImageView voteUpView = (ImageView) view.findViewById(R.id.vote_up_image);
    ImageView voteDownView = (ImageView) view.findViewById(R.id.vote_down_image);
    View thumbnailContainer = view.findViewById(R.id.thumbnail_view);
    FrameLayout thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame);
    ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail);
    ProgressBar indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress);

    // Set the title and domain using a SpannableStringBuilder
    SpannableStringBuilder builder = new SpannableStringBuilder();
    String title = item.getTitle();
    if (title == null)
        title = "";
    SpannableString titleSS = new SpannableString(title);
    int titleLen = title.length();
    titleSS.setSpan(/*from w  w  w . j av a 2  s . co  m*/
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)),
            0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    String domain = item.getDomain();
    if (domain == null)
        domain = "";
    int domainLen = domain.length();
    SpannableString domainSS = new SpannableString("(" + item.getDomain() + ")");
    domainSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)),
            0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (Util.isLightTheme(settings.getTheme())) {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    builder.append(titleSS).append(" ").append(domainSS);
    titleView.setText(builder);

    votesView.setText("" + item.getScore());
    numCommentsSubredditView.setText(Util.showNumComments(item.getNum_comments()) + "  " + item.getSubreddit());

    if (item.isOver_18()) {
        nsfwView.setVisibility(View.VISIBLE);
    } else {
        nsfwView.setVisibility(View.GONE);
    }

    // Set the up and down arrow colors based on whether user likes
    if (settings.isLoggedIn()) {
        if (item.getLikes() == null) {
            voteUpView.setImageResource(R.drawable.vote_up_gray);
            voteDownView.setImageResource(R.drawable.vote_down_gray);
            votesView.setTextColor(res.getColor(R.color.gray_75));
        } else if (item.getLikes() == true) {
            voteUpView.setImageResource(R.drawable.vote_up_red);
            voteDownView.setImageResource(R.drawable.vote_down_gray);
            votesView.setTextColor(res.getColor(R.color.arrow_red));
        } else {
            voteUpView.setImageResource(R.drawable.vote_up_gray);
            voteDownView.setImageResource(R.drawable.vote_down_blue);
            votesView.setTextColor(res.getColor(R.color.arrow_blue));
        }
    } else {
        voteUpView.setImageResource(R.drawable.vote_up_gray);
        voteDownView.setImageResource(R.drawable.vote_down_gray);
        votesView.setTextColor(res.getColor(R.color.gray_75));
    }

    // Thumbnails open links
    if (thumbnailContainer != null) {
        if (Common.shouldLoadThumbnails(activity, settings)) {
            thumbnailContainer.setVisibility(View.VISIBLE);

            if (item.getUrl() != null) {
                OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory
                        .getThumbnailOnClickListener(item, activity);
                if (thumbnailOnClickListener != null) {
                    thumbnailFrame.setOnClickListener(thumbnailOnClickListener);
                }
            }

            // Show thumbnail based on ThingInfo
            if ("default".equals(item.getThumbnail()) || "self".equals(item.getThumbnail())
                    || StringUtils.isEmpty(item.getThumbnail())) {
                indeterminateProgressBar.setVisibility(View.GONE);
                thumbnailImageView.setVisibility(View.VISIBLE);
                thumbnailImageView.setImageResource(R.drawable.go_arrow);
            } else {
                indeterminateProgressBar.setVisibility(View.GONE);
                thumbnailImageView.setVisibility(View.VISIBLE);
                if (item.getThumbnailBitmap() != null) {
                    thumbnailImageView.setImageBitmap(item.getThumbnailBitmap());
                } else {
                    thumbnailImageView.setImageBitmap(null);
                    new ShowThumbnailsTask(activity, client, R.drawable.go_arrow)
                            .execute(new ThumbnailLoadAction(item, thumbnailImageView, position));
                }
            }

            // Set thumbnail background based on current theme
            if (Util.isLightTheme(settings.getTheme()))
                thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light);
            else
                thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark);
        } else {
            // if thumbnails disabled, hide thumbnail icon
            thumbnailContainer.setVisibility(View.GONE);
        }
    }
}

From source file:com.b44t.ui.Components.PasscodeView.java

public PasscodeView(final Context context) {
    super(context);

    setWillNotDraw(false);//from ww  w  .ja  va  2s.  c o  m
    setVisibility(GONE);

    backgroundFrameLayout = new FrameLayout(context);
    addView(backgroundFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    backgroundFrameLayout.setLayoutParams(layoutParams);

    passwordFrameLayout = new FrameLayout(context);
    addView(passwordFrameLayout);
    layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    passwordFrameLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */);
    passwordFrameLayout.addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    if (AndroidUtilities.density < 1) {
        layoutParams.width = AndroidUtilities.dp(30);
        layoutParams.height = AndroidUtilities.dp(30);
    } else {
        layoutParams.width = AndroidUtilities.dp(40);
        layoutParams.height = AndroidUtilities.dp(40);
    }
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    layoutParams.bottomMargin = AndroidUtilities.dp(100);
    imageView.setLayoutParams(layoutParams);

    passcodeTextView = new TextView(context);
    passcodeTextView.setTextColor(0xffffffff);
    passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordFrameLayout.addView(passcodeTextView);
    layoutParams = (LayoutParams) passcodeTextView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(62);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passcodeTextView.setLayoutParams(layoutParams);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
    passwordEditText.setTextColor(0xffffffff);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setBackgroundDrawable(null);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    passwordFrameLayout.addView(passwordEditText);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText.setLayoutParams(layoutParams);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processDone(false);
                return true;
            }
            return false;
        }
    });
    passwordEditText.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) {
            if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) {
                processDone(false);
            }
        }
    });
    passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.passcode_check);
    checkImage.setScaleType(ImageView.ScaleType.CENTER);
    checkImage.setBackgroundResource(R.drawable.bar_selector_lock);
    passwordFrameLayout.addView(checkImage);
    layoutParams = (LayoutParams) checkImage.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(60);
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    layoutParams.rightMargin = AndroidUtilities.dp(10);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    checkImage.setLayoutParams(layoutParams);
    checkImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            processDone(false);
        }
    });

    FrameLayout lineFrameLayout = new FrameLayout(context);
    lineFrameLayout.setBackgroundColor(0x26ffffff);
    passwordFrameLayout.addView(lineFrameLayout);
    layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
    layoutParams.leftMargin = AndroidUtilities.dp(20);
    layoutParams.rightMargin = AndroidUtilities.dp(20);
    lineFrameLayout.setLayoutParams(layoutParams);

    numbersFrameLayout = new FrameLayout(context);
    addView(numbersFrameLayout);
    layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    numbersFrameLayout.setLayoutParams(layoutParams);

    lettersTextViews = new ArrayList<>(10);
    numberTextViews = new ArrayList<>(10);
    numberFrameLayouts = new ArrayList<>(10);
    for (int a = 0; a < 10; a++) {
        TextView textView = new TextView(context);
        textView.setTextColor(0xffffffff);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
        textView.setGravity(Gravity.CENTER);
        textView.setText(String.format(Locale.US, "%d", a));
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(50);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        numberTextViews.add(textView);

        textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
        textView.setTextColor(0x7fffffff);
        textView.setGravity(Gravity.CENTER);
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(20);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        switch (a) {
        case 0:
            textView.setText("+");
            break;
        case 2:
            textView.setText("ABC");
            break;
        case 3:
            textView.setText("DEF");
            break;
        case 4:
            textView.setText("GHI");
            break;
        case 5:
            textView.setText("JKL");
            break;
        case 6:
            textView.setText("MNO");
            break;
        case 7:
            textView.setText("PQRS");
            break;
        case 8:
            textView.setText("TUV");
            break;
        case 9:
            textView.setText("WXYZ");
            break;
        default:
            break;
        }
        lettersTextViews.add(textView);
    }
    eraseView = new ImageView(context);
    eraseView.setScaleType(ImageView.ScaleType.CENTER);
    eraseView.setImageResource(R.drawable.passcode_delete);
    numbersFrameLayout.addView(eraseView);
    layoutParams = (LayoutParams) eraseView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(50);
    layoutParams.height = AndroidUtilities.dp(50);
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    eraseView.setLayoutParams(layoutParams);
    for (int a = 0; a < 11; a++) {
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundResource(R.drawable.bar_selector_lock);
        frameLayout.setTag(a);
        if (a == 10) {
            frameLayout.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    passwordEditText.setText("");
                    return true;
                }
            });
        }
        frameLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int tag = (Integer) v.getTag();
                switch (tag) {
                case 0:
                    appendCharacter("0");
                    break;
                case 1:
                    appendCharacter("1");
                    break;
                case 2:
                    appendCharacter("2");
                    break;
                case 3:
                    appendCharacter("3");
                    break;
                case 4:
                    appendCharacter("4");
                    break;
                case 5:
                    appendCharacter("5");
                    break;
                case 6:
                    appendCharacter("6");
                    break;
                case 7:
                    appendCharacter("7");
                    break;
                case 8:
                    appendCharacter("8");
                    break;
                case 9:
                    appendCharacter("9");
                    break;
                case 10:
                    String text = passwordEditText.getText().toString();
                    if (text.length() > 0) {
                        passwordEditText.setText(text.substring(0, text.length() - 1));
                    }
                    break;
                }
                if (passwordEditText.getText().toString().length() == 4) {
                    processDone(false);
                }
            }
        });
        numberFrameLayouts.add(frameLayout);
    }
    for (int a = 10; a >= 0; a--) {
        FrameLayout frameLayout = numberFrameLayouts.get(a);
        numbersFrameLayout.addView(frameLayout);
        layoutParams = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(100);
        layoutParams.height = AndroidUtilities.dp(100);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        frameLayout.setLayoutParams(layoutParams);
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public void fillHighlightList() {
    Theme theme = getCurrentTheme();/*from w w w .  j  av  a 2 s .com*/
    int textColor = theme.foregroundColor;
    this.listView.removeAllViews();
    Highlights highlights = sd.fetchAllHighlights(this.bookCode);
    for (int i = 0; i < highlights.getSize(); i++) {
        Highlight highlight = highlights.getHighlight(i);
        SkyLayout item = new SkyLayout(this);
        int ci = highlight.chapterIndex;
        if (rv.isRTL()) {
            ci = rv.getNumberOfChapters() - ci - 1;
        }
        String chapterTitle = rv.getChapterTitle(ci);
        if (chapterTitle == null || chapterTitle.isEmpty())
            chapterTitle = "Chapter " + ci;

        TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor);
        setFrame(chapterLabel, ps(20), ps(5), this.listView.getWidth() - ps(20), ps(40));
        item.addView(chapterLabel);

        GradientDrawable textGrad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { getBrighterColor(highlight.color), getDarkerColor(highlight.color) });
        TextView textLabel = this.makeLabel(9899, highlight.text, Gravity.LEFT, 16, Color.BLACK);
        setFrame(textLabel, ps(20), ps(5 + 40 + 5), this.listView.getWidth() - ps(20), ps(70));
        textLabel.setBackgroundDrawable(textGrad);
        textLabel.getBackground().setAlpha(180);

        item.addView(textLabel);

        int noteHeight = 0;

        if (highlight.isNote && highlight.note != null && highlight.note.length() != 0
                && !highlight.note.equalsIgnoreCase("null")) {
            TextView noteLabel = this.makeLabel(9899, highlight.note, Gravity.LEFT, 16, Color.BLACK);
            noteLabel.setTextColor(getDarkerColor(highlight.color));
            noteHeight = 70;
            setFrame(noteLabel, ps(20), ps(5 + 40 + 5 + 70 + 5), this.listView.getWidth() - ps(20),
                    ps(noteHeight));
            item.addView(noteLabel);
        }

        TextView dateLabel = this.makeLabel(9899, highlight.datetime, Gravity.RIGHT, 12, textColor);
        int lw = this.listView.getWidth();
        setFrame(dateLabel, 0, ps(5 + 40 + 5 + 70 + 5 + noteHeight + 5), lw, ps(40));
        item.addView(dateLabel);

        int itemHeight = ps(5 + 40 + 5 + 90 + 5 + noteHeight + 5 + 15 + 5);

        View lineView = new View(this);
        lineView.setBackgroundColor(Color.LTGRAY);
        setFrame(lineView, 0, itemHeight - ps(1), this.listView.getWidth(), ps(1));
        item.addView(lineView);

        setFrame(item, 0, 0, listView.getWidth(), itemHeight);
        item.setSkyLayoutListener(highlightListDelegate);
        item.setId(highlight.code);
        item.data = highlight;

        Button deleteButton = new Button(this);
        GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { 0xffcf666e, 0xff671521 });
        grad.setStroke(ps(2), 0xff282828);
        deleteButton.setBackgroundDrawable(grad);
        deleteButton.setText(getString(R.string.delete));
        deleteButton.setTypeface(null, Typeface.BOLD);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setTextSize(12);
        deleteButton.setId(highlight.code);
        deleteButton.setVisibility(View.INVISIBLE);
        deleteButton.setVisibility(View.GONE);
        deleteButton.setOnClickListener(deleteHighlightDelegate);
        int dw = ps(120);
        int dh = ps(50);
        setFrame(deleteButton, this.listView.getWidth() - dw, (itemHeight - dh) / 2, dw, dh);
        item.deleteControl = deleteButton;
        item.addView(deleteButton);

        this.listView.addView(item);
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public TextView makeLabel(int id, String text, int gravity, float textSize, int textColor) {
    TextView label = new TextView(this);
    label.setId(id);//from  www .  java 2 s  . c o m
    label.setGravity(gravity);
    label.setBackgroundColor(Color.TRANSPARENT);
    label.setText(text);
    label.setTextColor(textColor);
    label.setTextSize(textSize);
    return label;
}