Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * This is the source code of Telegram for Android v. 1.4.x.
 * It is licensed under GNU GPL v. 2 or later.
 * You should have received a copy of the license in this archive (see LICENSE).
 *
 * Copyright Nikolai Kudashov, 2013-2014.
 */

import android.text.TextPaint;

import android.widget.TextView;

public class Main {
    public static int getTextViewLineCount(TextView textView, String text, int maxWidth) {
        if (textView == null)
            return 0;

        int index = 0;
        int lineCount = 0;
        TextPaint paint = textView.getPaint();
        while (index < text.length()) {
            index += paint.breakText(text, index, text.length(), true, maxWidth, null);
            lineCount++;
        }
        return lineCount;
    }
}