Skip to content

iamageo/AnotherReadMoreLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

93 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

banner_lib

License API repo size

forks stars

🏁 Including in your project

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
  implementation 'com.github.iamageo:another-read-more-lib:1.0.3'
}

πŸ›  Library Attributes

Attributes Type Default Description
textLength Int 0 Minimal text to show labels.
textLengthType Int TYPE_LINE(1) or TYPE_CHARACTER(2) 0 Indicates whether text trimming should be done by number of characters or by number of lines.
moreLabel String none text of more label.
lessLabel String none text of less label.
moreLabelColor Int Color.BLACK Color from moreLabel.
lessLabelColor Int Color.BLACK Color from lessLabel.
underlineVisible Boolean true Show/hide underline in more and less labels.

✨ Basic example for Kotlin

val tv = findViewById<TextView>(R.id.mTextView)
        
val anotherReadMore: AnotherReadMore = AnotherReadMore.Builder(this)
    .textLength(100, AnotherReadMore.TYPE_LINE)
    .moreLabel("mais")
    .lessLabel("menos")
    .build()

anotherReadMore.addReadMoreTo(tv,"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")

Example with RecyclerView

internal class SimpleAnotherAdapter internal constructor(private val context: Context) :
    RecyclerView.Adapter<SimpleAnotherAdapter.ViewHolder>() {

    private val anotherReadMore: AnotherReadMore = AnotherReadMore.Builder(context)
        .build()

    internal class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
        var mTextView: TextView = v.findViewById(R.id.tv)
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ViewHolder {
        val v = LayoutInflater.from(parent.context)
            .inflate(R.layout.item, parent, false) as View
        return ViewHolder(v)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        if (position % 2 == 0) {
            anotherReadMore.addReadMoreTo(
                holder.mTextView,
                Html.fromHtml(context.getString(R.string.big_text))
            )
        } else {
            anotherReadMore.addReadMoreTo(
                holder.mTextView,
                Html.fromHtml(context.getString(R.string.big_text)).toString()
            )
        }
    }

    override fun getItemCount(): Int {
        return 30
    }
}

License



    Copyright 2022 Geovani Amaral

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.