Skip to content

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cliffus committed Oct 17, 2017
2 parents 307282b + e5c59ba commit 08bac3f
Show file tree
Hide file tree
Showing 20 changed files with 305 additions and 74 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ Removed attributes from AndroidManifest, because they may conflict with the ones

1.0.4
-----
Added support for Android O
Use latest build tools and target Android O

1.0.5
-----
- Added support for Android O
- Added RecyclerView Demo
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Demo
----
This repository also contains a demo project.

![Demo](https://raw.githubusercontent.com/Blogcat/Android-ExpandableTextView/release/1.0.4/demo.gif)
![Demo](https://raw.githubusercontent.com/Blogcat/Android-ExpandableTextView/master/demo.gif)

Add dependency
--------------
Expand All @@ -32,7 +32,7 @@ library dependency

```groovy
dependencies {
compile 'at.blogc:expandabletextview:1.0.4'
compile 'at.blogc:expandabletextview:1.0.5'
}
```

Expand All @@ -55,7 +55,7 @@ Using the ExpandableTextView is very easy, it's just a regular TextView with som
android:text="@string/lorem_ipsum"
android:maxLines="5"
android:ellipsize="end"
app:animation_duration="1000"/>
app:animation_duration="750"/>

<!-- Optional parameter animation_duration: sets the duration of the expand animation -->

Expand All @@ -75,7 +75,7 @@ final ExpandableTextView expandableTextView = (ExpandableTextView) this.findView
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);

// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
expandableTextView.setAnimationDuration(1000L);
expandableTextView.setAnimationDuration(750L);

// set interpolators for both expanding and collapsing animations
expandableTextView.setInterpolator(new OvershootInterpolator());
Expand All @@ -85,15 +85,15 @@ expandableTextView.setExpandInterpolator(new OvershootInterpolator());
expandableTextView.setCollapseInterpolator(new OvershootInterpolator());

// toggle the ExpandableTextView
buttonToggle.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View v)
buttonToggle.setOnClickListener(new View.OnClickListener()
{
expandableTextView.toggle();
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.collapse : R.string.expand);
}
});
@Override
public void onClick(final View v)
{
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
expandableTextView.toggle();
}
});

// but, you can also do the checks yourself
buttonToggle.setOnClickListener(new View.OnClickListener()
Expand Down
7 changes: 6 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ android {
}
}

ext {
supportLibraryVersion = '26.1.0'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile 'com.android.support:support-annotations:25.3.1'
compile project(':expandabletextview')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import at.blogc.android.views.R;

/**
* Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -37,8 +37,8 @@ protected void onCreate(final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_main);

final ExpandableTextView expandableTextView = (ExpandableTextView) this.findViewById(R.id.expandableTextView);
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);
final ExpandableTextView expandableTextView = this.findViewById(R.id.expandableTextView);
final Button buttonToggle = this.findViewById(R.id.button_toggle);

// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
expandableTextView.setAnimationDuration(750L);
Expand All @@ -57,8 +57,8 @@ protected void onCreate(final Bundle savedInstanceState)
@Override
public void onClick(final View v)
{
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
expandableTextView.toggle();
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.collapse : R.string.expand);
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package at.blogc.android.activities;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import at.blogc.android.adapters.RecyclerViewAdapter;
import at.blogc.android.views.R;

/**
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
*
* 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.
*/
public class RecyclerViewActivity extends AppCompatActivity
{
private RecyclerView recyclerView;

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_recyclerview);

// find views
this.recyclerView = this.findViewById(R.id.recyclerview);

// create layout manager
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
this.recyclerView.setLayoutManager(layoutManager);

// bind adapter to recyclerview
final RecyclerViewAdapter adapter = new RecyclerViewAdapter();
this.recyclerView.setAdapter(adapter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package at.blogc.android.adapters;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import at.blogc.android.adapters.viewholders.ExpandableTextViewHolder;
import at.blogc.android.views.R;

/**
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
*
* 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.
*/
public class RecyclerViewAdapter extends RecyclerView.Adapter<ExpandableTextViewHolder>
{
private LayoutInflater layoutInflater;

private LayoutInflater getLayoutInflater(@NonNull final Context context)
{
if (this.layoutInflater == null)
{
this.layoutInflater = LayoutInflater.from(context);
}

return this.layoutInflater;
}

@Override
public ExpandableTextViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType)
{
final View itemView = this.getLayoutInflater(parent.getContext()).inflate(R.layout.listitem_recyclerview, parent, false);

return new ExpandableTextViewHolder(itemView);
}

@Override
public void onBindViewHolder(final ExpandableTextViewHolder holder, final int position)
{
holder.bindPosition(position);
}

@Override
public int getItemCount()
{
return 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package at.blogc.android.adapters.viewholders;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import android.widget.Button;

import at.blogc.android.views.ExpandableTextView;
import at.blogc.android.views.R;

/**
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
*
* 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.
*/
public class ExpandableTextViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener
{
private final ExpandableTextView expandableTextView;
private final Button buttonToggle;

public ExpandableTextViewHolder(final View itemView)
{
super(itemView);

// find views
this.expandableTextView = itemView.findViewById(R.id.expandableTextView);
this.buttonToggle = itemView.findViewById(R.id.button_toggle);

// set interpolators for both expanding and collapsing animations
this.expandableTextView.setInterpolator(new OvershootInterpolator());

// toggle the ExpandableTextView
this.buttonToggle.setOnClickListener(this);
}

public void bindPosition(final int position)
{
final String loremIpsum = position + ": " + this.itemView.getContext().getString(R.string.lorem_ipsum);
this.expandableTextView.setText(loremIpsum);
}

//region View.OnClickListener interface

@Override
public void onClick(final View v)
{
this.buttonToggle.setText(this.expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
this.expandableTextView.toggle();
}

//endregion
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_recyclerview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
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.
-->
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
43 changes: 43 additions & 0 deletions app/src/main/res/layout/listitem_recyclerview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
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.
-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<at.blogc.android.views.ExpandableTextView
android:id="@+id/expandableTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lorem_ipsum"
android:maxLines="5"
android:ellipsize="end"
app:animation_duration="750"/>

<Button
android:id="@+id/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/expandableTextView"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="@string/expand"/>

</RelativeLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values-w820dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/lorem_ipsum.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 08bac3f

Please sign in to comment.