Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

In this page you can find the example usage for android.graphics Typeface BOLD.

Prototype

int BOLD

To view the source code for android.graphics Typeface BOLD.

Click Source Link

Usage

From source file:com.lyue.aw_jitpack_aar.app.zxing.zxing.view.ViewfinderView.java

@Override
public void onDraw(Canvas canvas) {
    //CameraManager
    Rect frame = CameraManager.get().getFramingRect();
    if (frame == null) {
        return;//from  ww w  . ja v a  2  s .  co m
    }

    //
    if (!isFirst) {
        isFirst = true;
        slideTop = frame.top;
        slideBottom = frame.bottom;
    }

    //
    int width = canvas.getWidth();
    int height = canvas.getHeight();

    paint.setColor(resultBitmap != null ? resultColor : maskColor);

    //
    //
    canvas.drawRect(0, 0, width, frame.top, paint);
    canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
    canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint);
    canvas.drawRect(0, frame.bottom + 1, width, height, paint);

    if (resultBitmap != null) {
        // Draw the opaque result bitmap over the scanning rectangle
        paint.setAlpha(OPAQUE);
        canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
    } else {

        //8
        paint.setColor(Color.GREEN);
        canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate, frame.top + CORNER_WIDTH, paint);
        canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top + ScreenRate, paint);
        canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right, frame.top + CORNER_WIDTH, paint);
        canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top + ScreenRate, paint);
        canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left + ScreenRate, frame.bottom, paint);
        canvas.drawRect(frame.left, frame.bottom - ScreenRate, frame.left + CORNER_WIDTH, frame.bottom, paint);
        canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH, frame.right, frame.bottom,
                paint);
        canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate, frame.right, frame.bottom,
                paint);

        //,SPEEN_DISTANCE

        slideTop += SPEEN_DISTANCE;
        if (slideTop >= frame.bottom) {
            slideTop = frame.top;
        }
        Rect lineRect = new Rect();
        lineRect.left = frame.left;
        lineRect.right = frame.right;
        lineRect.top = slideTop;
        lineRect.bottom = slideTop + 18;
        canvas.drawBitmap(
                ((BitmapDrawable) (getResources().getDrawable(R.drawable.aar_qrcode_scan_line))).getBitmap(),
                null, lineRect, paint);

        //
        paint.setColor(Color.WHITE);
        paint.setTextSize(TEXT_SIZE * density);
        paint.setAlpha(0x40);
        paint.setTypeface(Typeface.create("System", Typeface.BOLD));
        String text = getResources().getString(R.string.scan_text);
        float textWidth = paint.measureText(text);

        canvas.drawText(text, (width - textWidth) / 2,
                (float) (frame.bottom + (float) TEXT_PADDING_TOP * density), paint);

        Collection<ResultPoint> currentPossible = possibleResultPoints;
        Collection<ResultPoint> currentLast = lastPossibleResultPoints;
        if (currentPossible.isEmpty()) {
            lastPossibleResultPoints = null;
        } else {
            possibleResultPoints = new HashSet<ResultPoint>(5);
            lastPossibleResultPoints = currentPossible;
            paint.setAlpha(OPAQUE);
            paint.setColor(resultPointColor);
            for (ResultPoint point : currentPossible) {
                canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 6.0f, paint);
            }
        }
        if (currentLast != null) {
            paint.setAlpha(OPAQUE / 2);
            paint.setColor(resultPointColor);
            for (ResultPoint point : currentLast) {
                canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 3.0f, paint);
            }
        }

        //
        postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom);

    }
}

From source file:com.eeshana.icstories.activities.UploadVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this will copy the license file and the demo video file.
    // to the videokit work folder location.
    // without the license file the library will not work.
    //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
    setContentView(R.layout.upload_video_activity);

    height = SignInActivity.getScreenHeight(UploadVideoActivity.this);
    width = SignInActivity.getScreenWidth(UploadVideoActivity.this);
    mProgressDialog = new ProgressDialog(UploadVideoActivity.this);
    pDialog = new ProgressDialog(UploadVideoActivity.this);
    showCustomToast = new ShowCustomToast();
    connectionDetector = new ConnectionDetector(UploadVideoActivity.this);
    //      mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT);
    //      mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast);
    prefs = getSharedPreferences("PREF", MODE_PRIVATE);
    regId = prefs.getString("regid", "NA");
    SharedPreferences pref = getSharedPreferences("DB", 0);
    userid = pref.getString("userid", "1");
    SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0);
    assignment_id = assign_prefs.getString("ASSIGN_ID", "");
    videoPath = getIntent().getStringExtra("VIDEOPATH");

    //      iCTextView=(TextView) findViewById(R.id.tvIC);
    //      iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD);
    //      storiesTextView=(TextView) findViewById(R.id.tvStories);
    //      storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD);
    //      watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory);
    //      watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC);

    //      logoImageView=(ImageView) findViewById(R.id.ivLogo);
    //      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5));
    //      lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //      lp.setMargins(0, 0, 0, 0);
    //      logoImageView.setLayoutParams(lp);

    uploadtTextView = (TextView) findViewById(R.id.tvUpload);
    uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    //      extension=getIntent().getStringExtra("EXTENSION");
    //      folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder";
    //      if (!FileUtils.checkIfFolderExists(folderPath)) {
    //         boolean isFolderCreated = FileUtils.createFolder(folderPath);
    //         Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated);
    //         if (isFolderCreated) {
    ///* ww  w. j  av a 2s.co  m*/
    //         }
    //      }
    //command for rotating video 90 degree
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension;

    //Change Video Resolution:
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension;

    //command for compressing video 
    //      String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension;
    //      setCommand(commandStr);
    //      runTranscoing();

    thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println("THUMB IMG  in uplaod== " + thumb);

    titleEditText = (EditText) findViewById(R.id.etTitle);
    titleEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    descriptionEditText = (EditText) findViewById(R.id.etDescripton);
    descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    locationEditText = (EditText) findViewById(R.id.etLocation);
    locationEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton = (Button) findViewById(R.id.buttonCheck);
    isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton.setOnClickListener(this);
    dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment);
    dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    uploadButton = (Button) findViewById(R.id.buttonUpload);
    uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload);
    RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17);
    lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment);
    lp9.setMargins(width / 7, 30, width / 7, 0);
    uploadRelativeLayout.setLayoutParams(lp9);
    uploadButton.setOnClickListener(this);

    //bottom bar

    homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome);
    homeRelativeLayout.setBackgroundResource(R.drawable.press_border);
    homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome);
    homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    homeTextView.setTextColor(Color.parseColor("#fffffe"));
    RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp4.addRule(RelativeLayout.ALIGN_LEFT);
    homeRelativeLayout.setLayoutParams(lp4);
    homeRelativeLayout.setOnClickListener(this);

    wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall);
    wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall);
    wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome);
    wallRelativeLayout.setLayoutParams(lp5);
    wallRelativeLayout.setOnClickListener(this);

    settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings);
    settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings);
    settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall);
    settingsRelativeLayout.setLayoutParams(lp6);
    settingsRelativeLayout.setOnClickListener(this);

    // current location
    locationDialog = new Dialog(UploadVideoActivity.this);
    locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    locationDialog.setContentView(R.layout.location_dialog);
    locationDialog.setCancelable(true);
    LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1);
    okButton = (Button) dialogLayout.findViewById(R.id.OkBtn);
    okButton.setOnClickListener(this);
    cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn);
    cancelButton.setOnClickListener(this);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    if (network_enabled) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    } else {
        showCustomToast.showToast(UploadVideoActivity.this,
                "Could not find current location. Please enable location services of your device.");
    }
    //      else if(gps_enabled == false){
    //         locationDialog.show();
    //      }
}

From source file:net.kourlas.voipms_sms.adapters.ConversationsRecyclerViewAdapter.java

@Override
public void onBindViewHolder(ConversationViewHolder conversationViewHolder, int position) {
    Message message = messages.get(position);

    ViewSwitcher viewSwitcher = conversationViewHolder.getViewSwitcher();
    viewSwitcher.setDisplayedChild(isItemChecked(position) ? 1 : 0);

    QuickContactBadge contactBadge = conversationViewHolder.getContactBadge();
    contactBadge.assignContactFromPhone(message.getContact(), true);

    String photoUri = Utils.getContactPhotoUri(applicationContext, message.getContact());
    if (photoUri != null) {
        contactBadge.setImageURI(Uri.parse(photoUri));
    } else {/*w ww.  j a  v a2 s . c  o  m*/
        contactBadge.setImageToDefault();
    }

    TextView contactTextView = conversationViewHolder.getContactTextView();
    String contactName = Utils.getContactName(applicationContext, message.getContact());
    SpannableStringBuilder contactTextBuilder = new SpannableStringBuilder();
    if (contactName != null) {
        contactTextBuilder.append(contactName);
    } else {
        contactTextBuilder.append(Utils.getFormattedPhoneNumber(message.getContact()));
    }
    if (!filterConstraint.equals("")) {
        int index = contactTextBuilder.toString().toLowerCase().indexOf(filterConstraint.toLowerCase());
        if (index != -1) {
            contactTextBuilder.setSpan(
                    new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)),
                    index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
        }
    }
    contactTextView.setText(contactTextBuilder);

    final TextView messageTextView = conversationViewHolder.getMessageTextView();
    SpannableStringBuilder messageTextBuilder = new SpannableStringBuilder();

    int index = message.getText().toLowerCase().indexOf(filterConstraint.toLowerCase());
    if (!filterConstraint.equals("") && index != -1) {
        int nonMessageOffset = index;
        if (message.getType() == Message.Type.OUTGOING) {
            messageTextBuilder.insert(0,
                    applicationContext.getString(R.string.conversations_message_you) + " ");
            nonMessageOffset += 5;
        }

        int substringOffset = index - 20;
        if (substringOffset > 0) {
            messageTextBuilder.append("...");
            nonMessageOffset += 3;

            while (message.getText().charAt(substringOffset) != ' ' && substringOffset < index - 1) {
                substringOffset += 1;
            }
            substringOffset += 1;
        } else {
            substringOffset = 0;
        }

        messageTextBuilder.append(message.getText().substring(substringOffset));
        messageTextBuilder.setSpan(
                new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)),
                nonMessageOffset - substringOffset,
                nonMessageOffset - substringOffset + filterConstraint.length(),
                SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
    } else {
        if (message.getType() == Message.Type.OUTGOING) {
            messageTextBuilder.append(applicationContext.getString(R.string.conversations_message_you));
            messageTextBuilder.append(" ");
        }
        messageTextBuilder.append(message.getText());
    }
    messageTextView.setText(messageTextBuilder);

    if (message.isUnread()) {
        contactTextView.setTypeface(null, Typeface.BOLD);
        messageTextView.setTypeface(null, Typeface.BOLD);
    } else {
        contactTextView.setTypeface(null, Typeface.NORMAL);
        messageTextView.setTypeface(null, Typeface.NORMAL);
    }

    // Set date line
    TextView dateTextView = conversationViewHolder.getDateTextView();
    if (message.isDraft()) {
        SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder();
        dateTextBuilder.append(applicationContext.getString(R.string.conversations_message_draft));
        dateTextBuilder.setSpan(new StyleSpan(Typeface.ITALIC), 0, dateTextBuilder.length(),
                Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        dateTextView.setText(dateTextBuilder);
    } else if (!message.isDelivered()) {
        if (!message.isDeliveryInProgress()) {
            SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder();
            dateTextBuilder.append(applicationContext.getString(R.string.conversations_message_not_sent));
            dateTextBuilder.setSpan(
                    new ForegroundColorSpan(
                            ContextCompat.getColor(applicationContext, android.R.color.holo_red_dark)),
                    0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            dateTextView.setText(dateTextBuilder);
        } else {
            dateTextView.setText(applicationContext.getString(R.string.conversations_message_sending));
        }
    } else {
        dateTextView.setText(Utils.getFormattedDate(applicationContext, message.getDate(), true));
    }
}

From source file:com.snappy.VoiceActivity.java

private void setInitComments() {
    // for comment
    // **********************************************
    mLvComments = (ListView) findViewById(R.id.lvPhotoComments);
    mLvComments.setCacheColorHint(0);//  w  w  w .  ja va2  s.  c  o m

    final EditText etComment = (EditText) findViewById(R.id.etComment);
    etComment.setTypeface(SpikaApp.getTfMyriadPro());

    mMessage = (Message) getIntent().getSerializableExtra("message");

    mComments = new ArrayList<Comment>();

    new GetCommentsAsync(VoiceActivity.this, mMessage, mComments, mCommentsAdapter, mLvComments, true)
            .execute(mMessage.getId());
    scrollListViewToBottom();

    Button btnSendComment = (Button) findViewById(R.id.btnSendComment);
    btnSendComment.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);

    btnSendComment.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String commentText = etComment.getText().toString();
            if (!commentText.equals("")) {
                Comment comment = CommentManagement.createComment(commentText, mMessage.getId());
                scrollListViewToBottom();

                CouchDB.createCommentAsync(comment, new CreateCommentFinish(), VoiceActivity.this, true);

                etComment.setText("");
                Utils.hideKeyboard(VoiceActivity.this);

            }

        }
    });

    // **********************************************
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.PlusStreamRowViewBinder.java

public static void bindActivityView(final View rootView, Activity activity, ImageLoader imageLoader,
        boolean singleSourceMode) {
    // Prepare view holder.
    ViewHolder tempViews = (ViewHolder) rootView.getTag();
    final ViewHolder views;
    if (tempViews != null) {
        views = tempViews;//  www  .  j av  a 2 s  .  co  m
    } else {
        views = new ViewHolder();
        rootView.setTag(views);

        // Author and metadata box
        views.authorContainer = rootView.findViewById(R.id.stream_author_container);
        views.userImage = (ImageView) rootView.findViewById(R.id.stream_user_image);
        views.userName = (TextView) rootView.findViewById(R.id.stream_user_name);
        views.time = (TextView) rootView.findViewById(R.id.stream_time);

        // Author's content
        views.content = (TextView) rootView.findViewById(R.id.stream_content);

        // Original share box
        views.originalContainer = rootView.findViewById(R.id.stream_original_container);
        views.originalAuthor = (TextView) rootView.findViewById(R.id.stream_original_author);
        views.originalContent = (TextView) rootView.findViewById(R.id.stream_original_content);

        // Media box
        views.mediaContainer = rootView.findViewById(R.id.stream_media_container);
        views.mediaBackground = (ImageView) rootView.findViewById(R.id.stream_media_background);
        views.mediaOverlay = (ImageView) rootView.findViewById(R.id.stream_media_overlay);
        views.mediaTitle = (TextView) rootView.findViewById(R.id.stream_media_title);
        views.mediaSubtitle = (TextView) rootView.findViewById(R.id.stream_media_subtitle);

        // Interactions box
        views.interactionsContainer = rootView.findViewById(R.id.stream_interactions_container);
        views.plusOnes = (TextView) rootView.findViewById(R.id.stream_plus_ones);
        views.shares = (TextView) rootView.findViewById(R.id.stream_shares);
        views.comments = (TextView) rootView.findViewById(R.id.stream_comments);
    }

    final Context context = rootView.getContext();
    final Resources res = context.getResources();

    // Determine if this is a reshare (affects how activity fields are to be interpreted).
    Activity.PlusObject.Actor originalAuthor = activity.getObject().getActor();
    boolean isReshare = "share".equals(activity.getVerb()) && originalAuthor != null;

    // Author and metadata box
    views.authorContainer.setVisibility(singleSourceMode ? View.GONE : View.VISIBLE);
    views.userName.setText(activity.getActor().getDisplayName());

    // Find user profile image url
    String userImageUrl = null;
    if (activity.getActor().getImage() != null) {
        userImageUrl = activity.getActor().getImage().getUrl();
    }

    // Load image from network in background thread using Volley library
    imageLoader.get(userImageUrl, views.userImage, PLACEHOLDER_USER_IMAGE);

    long thenUTC = activity.getUpdated().getValue() + activity.getUpdated().getTimeZoneShift() * 60000;
    views.time.setText(DateUtils.getRelativeTimeSpanString(thenUTC, System.currentTimeMillis(),
            DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_RELATIVE));

    // Author's additional content
    String selfContent = isReshare ? activity.getAnnotation() : activity.getObject().getContent();
    views.content.setMaxLines(singleSourceMode ? 1000 : 5);
    if (!TextUtils.isEmpty(selfContent)) {
        views.content.setVisibility(View.VISIBLE);
        views.content.setText(Html.fromHtml(selfContent));
    } else {
        views.content.setVisibility(View.GONE);
    }

    // Original share box
    if (isReshare) {
        views.originalContainer.setVisibility(View.VISIBLE);

        // Set original author text, highlight author name
        final String author = res.getString(R.string.stream_originally_shared, originalAuthor.getDisplayName());
        final SpannableStringBuilder spannableAuthor = new SpannableStringBuilder(author);
        spannableAuthor.setSpan(new StyleSpan(Typeface.BOLD),
                author.length() - originalAuthor.getDisplayName().length(), author.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        views.originalAuthor.setText(spannableAuthor, TextView.BufferType.SPANNABLE);

        String originalContent = activity.getObject().getContent();
        views.originalContent.setMaxLines(singleSourceMode ? 1000 : 3);
        if (!TextUtils.isEmpty(originalContent)) {
            views.originalContent.setVisibility(View.VISIBLE);
            views.originalContent.setText(Html.fromHtml(originalContent));
        } else {
            views.originalContent.setVisibility(View.GONE);
        }
    } else {
        views.originalContainer.setVisibility(View.GONE);
    }

    // Media box

    // Set media content.
    List<Activity.PlusObject.Attachments> attachments = activity.getObject().getAttachments();
    if (attachments != null && attachments.size() > 0) {
        Activity.PlusObject.Attachments attachment = attachments.get(0);
        String objectType = attachment.getObjectType();
        String imageUrl = attachment.getImage() != null ? attachment.getImage().getUrl() : null;
        if (imageUrl == null && attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) {
            Thumbnails thumb = attachment.getThumbnails().get(0);
            imageUrl = thumb.getImage() != null ? thumb.getImage().getUrl() : null;
        }

        // Load image from network in background thread using Volley library
        imageLoader.get(imageUrl, views.mediaBackground, PLACEHOLDER_MEDIA_IMAGE);

        boolean overlayStyle = false;

        views.mediaOverlay.setImageDrawable(null);
        if (("photo".equals(objectType) || "video".equals(objectType) || "album".equals(objectType))
                && !TextUtils.isEmpty(imageUrl)) {
            overlayStyle = true;
            views.mediaOverlay
                    .setImageResource("video".equals(objectType) ? R.drawable.ic_stream_media_overlay_video
                            : R.drawable.ic_stream_media_overlay_photo);

        } else if ("article".equals(objectType) || "event".equals(objectType)) {
            overlayStyle = false;
            views.mediaTitle.setText(attachment.getDisplayName());
            if (!TextUtils.isEmpty(attachment.getUrl())) {
                Uri uri = Uri.parse(attachment.getUrl());
                views.mediaSubtitle.setText(uri.getHost());
            } else {
                views.mediaSubtitle.setText("");
            }
        }

        views.mediaContainer.setVisibility(View.VISIBLE);
        views.mediaContainer.setBackgroundResource(
                overlayStyle ? R.color.plus_stream_media_background : android.R.color.black);
        if (overlayStyle) {
            views.mediaBackground.clearColorFilter();
        } else {
            views.mediaBackground.setColorFilter(res.getColor(R.color.plus_media_item_tint));
        }
        views.mediaOverlay.setVisibility(overlayStyle ? View.VISIBLE : View.GONE);
        views.mediaTitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE);
        views.mediaSubtitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE);
    } else {
        views.mediaContainer.setVisibility(View.GONE);
        views.mediaBackground.setImageDrawable(null);
        views.mediaOverlay.setImageDrawable(null);
    }

    // Interactions box
    final int plusOneCount = (activity.getObject().getPlusoners() != null)
            ? activity.getObject().getPlusoners().getTotalItems().intValue()
            : 0;
    if (plusOneCount > 0) {
        views.plusOnes.setVisibility(View.VISIBLE);
        views.plusOnes.setText(getPlusOneString(plusOneCount));
    } else {
        views.plusOnes.setVisibility(View.GONE);
    }

    final int commentCount = (activity.getObject().getReplies() != null)
            ? activity.getObject().getReplies().getTotalItems().intValue()
            : 0;
    if (commentCount > 0) {
        views.comments.setVisibility(View.VISIBLE);
        views.comments.setText(Integer.toString(commentCount));
    } else {
        views.comments.setVisibility(View.GONE);
    }

    final int resharerCount = (activity.getObject().getResharers() != null)
            ? activity.getObject().getResharers().getTotalItems().intValue()
            : 0;
    if (resharerCount > 0) {
        views.shares.setVisibility(View.VISIBLE);
        views.shares.setText(Integer.toString(resharerCount));
    } else {
        views.shares.setVisibility(View.GONE);
    }

    views.interactionsContainer.setVisibility(
            (plusOneCount > 0 || commentCount > 0 || resharerCount > 0) ? View.VISIBLE : View.GONE);
}

From source file:com.morlunk.mumbleclient.channel.ChannelListAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    final Node node = mNodes.get(position);
    if (node.isChannel()) {
        final IChannel channel = node.getChannel();
        final ChannelViewHolder cvh = (ChannelViewHolder) viewHolder;
        cvh.itemView.setOnClickListener(new View.OnClickListener() {
            @Override//from ww w .  j  ava 2  s  .c  om
            public void onClick(View v) {
                if (mChannelClickListener != null) {
                    mChannelClickListener.onChannelClick(channel);
                }
            }
        });

        final boolean expandUsable = channel.getSubchannels().size() > 0
                || channel.getSubchannelUserCount() > 0;
        cvh.mChannelExpandToggle.setImageResource(
                node.isExpanded() ? R.drawable.ic_action_expanded : R.drawable.ic_action_collapsed);
        cvh.mChannelExpandToggle.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mExpandedChannels.put(channel.getId(), !node.isExpanded());
                updateChannels(); // FIXME: very inefficient.
                notifyDataSetChanged();
            }
        });
        // Dim channel expand toggle when no subchannels exist
        cvh.mChannelExpandToggle.setEnabled(expandUsable);
        cvh.mChannelExpandToggle.setVisibility(expandUsable ? View.VISIBLE : View.INVISIBLE);

        cvh.mChannelName.setText(channel.getName());

        int nameTypeface = Typeface.NORMAL;
        if (mService != null && mService.getConnectionState() == JumbleService.ConnectionState.CONNECTED) {
            if (channel.equals(mService.getSessionChannel())) {
                nameTypeface |= Typeface.BOLD;
                // Always italicize our current channel if it has a link.
                if (channel.getLinks().size() > 0) {
                    nameTypeface |= Typeface.ITALIC;
                }
            }
            // Italicize channels in a link with our current channel.
            if (channel.getLinks().contains(mService.getSessionChannel())) {
                nameTypeface |= Typeface.ITALIC;
            }
        }
        cvh.mChannelName.setTypeface(null, nameTypeface);

        if (mShowChannelUserCount) {
            cvh.mChannelUserCount.setVisibility(View.VISIBLE);
            int userCount = channel.getSubchannelUserCount();
            cvh.mChannelUserCount.setText(String.format("%d", userCount));
        } else {
            cvh.mChannelUserCount.setVisibility(View.GONE);
        }

        // Pad the view depending on channel's nested level.
        DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
        float margin = node.getDepth() * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
        cvh.mChannelHolder.setPadding((int) margin, cvh.mChannelHolder.getPaddingTop(),
                cvh.mChannelHolder.getPaddingRight(), cvh.mChannelHolder.getPaddingBottom());

        cvh.mJoinButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mService.joinChannel(channel.getId());
            }
        });

        cvh.mMoreButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ChannelMenu menu = new ChannelMenu(mContext, channel, mService, mDatabase, mFragmentManager);
                menu.showPopup(v);
            }
        });

        cvh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                cvh.mMoreButton.performClick();
                return true;
            }
        });
    } else if (node.isUser()) {
        final IUser user = node.getUser();
        final UserViewHolder uvh = (UserViewHolder) viewHolder;
        uvh.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mUserClickListener != null) {
                    mUserClickListener.onUserClick(user);
                }
            }
        });

        uvh.mUserName.setText(user.getName());
        uvh.mUserName.setTypeface(null,
                user.getSession() == mService.getSession() ? Typeface.BOLD : Typeface.NORMAL);

        uvh.mUserTalkHighlight.setImageDrawable(getTalkStateDrawable(user));
        uvh.mTalkingIndicator.setAlpha(
                (user.getTalkState() == TalkState.TALKING || user.getTalkState() == TalkState.WHISPERING
                        || user.getTalkState() == TalkState.SHOUTING) ? 1 : 0);

        // Pad the view depending on channel's nested level.
        DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
        float margin = (node.getDepth() + 1)
                * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
        uvh.mUserHolder.setPadding((int) margin, uvh.mUserHolder.getPaddingTop(),
                uvh.mUserHolder.getPaddingRight(), uvh.mUserHolder.getPaddingBottom());

        uvh.mMoreButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserMenu menu = new UserMenu(mContext, user, (PlumbleService) mService, mFragmentManager,
                        ChannelListAdapter.this);
                menu.showPopup(v);
            }
        });

        uvh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                uvh.mMoreButton.performClick();
                return true;
            }
        });
    }
}

From source file:com.xda.one.ui.widget.TabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set
 * via//  ww w  .jav  a2s . c  o m
 * {@link #setCustomTabView(int, int)}.
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);

    // Modified for XDA One
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceSmallInverse, typedValue, true);
    textView.setTextAppearance(getContext(), typedValue.resourceId);
    getContext().getTheme().resolveAttribute(android.R.attr.textColorPrimaryInverse, typedValue, true);
    textView.setTextColor(getResources().getColor(typedValue.resourceId));
    textView.setTypeface(null, Typeface.BOLD);

    // Customized for app
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(0, MATCH_PARENT, 1f / mViewPager.getAdapter().getCount()));
    textView.setSingleLine();
    AutofitHelper.create(textView);

    // Modified for XDA One
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    textView.setBackgroundResource(typedValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView vKeyId = (TextView) view.findViewById(R.id.subkey_item_key_id);
    TextView vKeyDetails = (TextView) view.findViewById(R.id.subkey_item_details);
    TextView vKeyExpiry = (TextView) view.findViewById(R.id.subkey_item_expiry);
    ImageView vCertifyIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_certify);
    ImageView vSignIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_sign);
    ImageView vEncryptIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_encrypt);
    ImageView vAuthenticateIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_authenticate);
    ImageView vEditImage = (ImageView) view.findViewById(R.id.subkey_item_edit_image);
    ImageView vStatus = (ImageView) view.findViewById(R.id.subkey_item_status);

    // not used:/*from  w w  w .  j  ava 2s.  c o m*/
    ImageView deleteImage = (ImageView) view.findViewById(R.id.subkey_item_delete_button);
    deleteImage.setVisibility(View.GONE);

    long keyId = cursor.getLong(INDEX_KEY_ID);
    vKeyId.setText(KeyFormattingUtils.beautifyKeyId(keyId));

    // may be set with additional "stripped" later on
    SpannableStringBuilder algorithmStr = new SpannableStringBuilder();
    algorithmStr.append(KeyFormattingUtils.getAlgorithmInfo(context, cursor.getInt(INDEX_ALGORITHM),
            cursor.getInt(INDEX_KEY_SIZE), cursor.getString(INDEX_KEY_CURVE_OID)));

    SubkeyChange change = mSaveKeyringParcel != null ? mSaveKeyringParcel.getSubkeyChange(keyId) : null;

    if (change != null && (change.mDummyStrip || change.mMoveKeyToSecurityToken)) {
        if (change.mDummyStrip) {
            algorithmStr.append(", ");
            final SpannableString boldStripped = new SpannableString(context.getString(R.string.key_stripped));
            boldStripped.setSpan(new StyleSpan(Typeface.BOLD), 0, boldStripped.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldStripped);
        }
        if (change.mMoveKeyToSecurityToken) {
            algorithmStr.append(", ");
            final SpannableString boldDivert = new SpannableString(context.getString(R.string.key_divert));
            boldDivert.setSpan(new StyleSpan(Typeface.BOLD), 0, boldDivert.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldDivert);
        }
    } else {
        switch (SecretKeyType.fromNum(cursor.getInt(INDEX_HAS_SECRET))) {
        case GNU_DUMMY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_stripped));
            break;
        case DIVERT_TO_CARD:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_divert));
            break;
        case PASSPHRASE_EMPTY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_no_passphrase));
            break;
        case UNAVAILABLE:
            // don't show this on pub keys
            //algorithmStr += ", " + context.getString(R.string.key_unavailable);
            break;
        }
    }
    vKeyDetails.setText(algorithmStr, TextView.BufferType.SPANNABLE);

    boolean isMasterKey = cursor.getInt(INDEX_RANK) == 0;
    if (isMasterKey) {
        vKeyId.setTypeface(null, Typeface.BOLD);
    } else {
        vKeyId.setTypeface(null, Typeface.NORMAL);
    }

    // Set icons according to properties
    vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE);
    vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE);
    vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : View.GONE);
    vAuthenticateIcon.setVisibility(cursor.getInt(INDEX_CAN_AUTHENTICATE) != 0 ? View.VISIBLE : View.GONE);

    boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;

    Date expiryDate = null;
    if (!cursor.isNull(INDEX_EXPIRY)) {
        expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000);
    }

    // for edit key
    if (mSaveKeyringParcel != null) {
        boolean revokeThisSubkey = (mSaveKeyringParcel.mRevokeSubKeys.contains(keyId));

        if (revokeThisSubkey) {
            if (!isRevoked) {
                isRevoked = true;
            }
        }

        SaveKeyringParcel.SubkeyChange subkeyChange = mSaveKeyringParcel.getSubkeyChange(keyId);
        if (subkeyChange != null) {
            if (subkeyChange.mExpiry == null || subkeyChange.mExpiry == 0L) {
                expiryDate = null;
            } else {
                expiryDate = new Date(subkeyChange.mExpiry * 1000);
            }
        }

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

    boolean isExpired;
    if (expiryDate != null) {
        isExpired = expiryDate.before(new Date());
        Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiryCal.setTime(expiryDate);
        // convert from UTC to time zone of device
        expiryCal.setTimeZone(TimeZone.getDefault());

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": "
                + DateFormat.getDateFormat(context).format(expiryCal.getTime()));
    } else {
        isExpired = false;

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none));
    }

    // if key is expired or revoked...
    boolean isInvalid = isRevoked || isExpired;
    if (isInvalid) {
        vStatus.setVisibility(View.VISIBLE);

        vCertifyIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vSignIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vEncryptIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vAuthenticateIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);

        if (isRevoked) {
            vStatus.setImageResource(R.drawable.status_signature_revoked_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        } else if (isExpired) {
            vStatus.setImageResource(R.drawable.status_signature_expired_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        }
    } else {
        vStatus.setVisibility(View.GONE);

        vKeyId.setTextColor(mDefaultTextColor);
        vKeyDetails.setTextColor(mDefaultTextColor);
        vKeyExpiry.setTextColor(mDefaultTextColor);

        vCertifyIcon.clearColorFilter();
        vSignIcon.clearColorFilter();
        vEncryptIcon.clearColorFilter();
        vAuthenticateIcon.clearColorFilter();
    }
    vKeyId.setEnabled(!isInvalid);
    vKeyDetails.setEnabled(!isInvalid);
    vKeyExpiry.setEnabled(!isInvalid);
}

From source file:org.sufficientlysecure.keychain.ui.CertifyFingerprintFragment.java

private void displayWordConfirm(byte[] fingerprintBlob) {
    //        String fingerprint = ExperimentalWordConfirm.getWords(getActivity(), fingerprintBlob);

    String fingerprint;/* w w w.j av  a  2  s .  com*/
    try {
        fingerprint = new SentenceConfirm(getActivity()).fromBytes(fingerprintBlob, 20);
    } catch (IOException e) {
        fingerprint = "-";
        Log.e(Constants.TAG, "Problem when creating sentence!", e);
    }

    mFingerprint.setTextSize(18);
    mFingerprint.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    mFingerprint.setText(fingerprint);
}

From source file:com.kmagic.solitaire.DrawMaster.java

/**
 * Get paint for text use//from   w w  w.  j ava 2s.  co  m
 * @return red paint object
 */
public static Paint getTextPaint(final float fontSize, final Paint.Align align) {
    Paint paint = getPaint();
    paint.setTextSize(fontSize);
    paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    paint.setTextAlign(align);
    return (paint);
}