Skip to content

Commit 08bac3f

Browse files
committed
Merge branch 'release/1.0.5'
2 parents 307282b + e5c59ba commit 08bac3f

20 files changed

+305
-74
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ Removed attributes from AndroidManifest, because they may conflict with the ones
1919

2020
1.0.4
2121
-----
22-
Added support for Android O
22+
Use latest build tools and target Android O
23+
24+
1.0.5
25+
-----
26+
- Added support for Android O
27+
- Added RecyclerView Demo

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Demo
88
----
99
This repository also contains a demo project.
1010

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

1313
Add dependency
1414
--------------
@@ -32,7 +32,7 @@ library dependency
3232

3333
```groovy
3434
dependencies {
35-
compile 'at.blogc:expandabletextview:1.0.4'
35+
compile 'at.blogc:expandabletextview:1.0.5'
3636
}
3737
```
3838

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

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

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

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

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

8787
// toggle the ExpandableTextView
88-
buttonToggle.setOnClickListener(new View.OnClickListener()
89-
{
90-
@Override
91-
public void onClick(final View v)
88+
buttonToggle.setOnClickListener(new View.OnClickListener()
9289
{
93-
expandableTextView.toggle();
94-
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.collapse : R.string.expand);
95-
}
96-
});
90+
@Override
91+
public void onClick(final View v)
92+
{
93+
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
94+
expandableTextView.toggle();
95+
}
96+
});
9797

9898
// but, you can also do the checks yourself
9999
buttonToggle.setOnClickListener(new View.OnClickListener()

app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ android {
1919
}
2020
}
2121

22+
ext {
23+
supportLibraryVersion = '26.1.0'
24+
}
25+
2226
dependencies {
2327
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
28+
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
29+
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
2530
compile 'com.android.support:support-annotations:25.3.1'
2631
compile project(':expandabletextview')
2732

app/src/main/java/at/blogc/android/activities/MainActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import at.blogc.android.views.R;
1313

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

40-
final ExpandableTextView expandableTextView = (ExpandableTextView) this.findViewById(R.id.expandableTextView);
41-
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);
40+
final ExpandableTextView expandableTextView = this.findViewById(R.id.expandableTextView);
41+
final Button buttonToggle = this.findViewById(R.id.button_toggle);
4242

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package at.blogc.android.activities;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.support.v7.widget.LinearLayoutManager;
7+
import android.support.v7.widget.RecyclerView;
8+
9+
import at.blogc.android.adapters.RecyclerViewAdapter;
10+
import at.blogc.android.views.R;
11+
12+
/**
13+
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
14+
*
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
*
19+
* http://www.apache.org/licenses/LICENSE-2.0
20+
*
21+
* Unless required by applicable law or agreed to in writing, software
22+
* distributed under the License is distributed on an "AS IS" BASIS,
23+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
* See the License for the specific language governing permissions and
25+
* limitations under the License.
26+
*/
27+
public class RecyclerViewActivity extends AppCompatActivity
28+
{
29+
private RecyclerView recyclerView;
30+
31+
@Override
32+
protected void onCreate(@Nullable final Bundle savedInstanceState)
33+
{
34+
super.onCreate(savedInstanceState);
35+
this.setContentView(R.layout.activity_recyclerview);
36+
37+
// find views
38+
this.recyclerView = this.findViewById(R.id.recyclerview);
39+
40+
// create layout manager
41+
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
42+
this.recyclerView.setLayoutManager(layoutManager);
43+
44+
// bind adapter to recyclerview
45+
final RecyclerViewAdapter adapter = new RecyclerViewAdapter();
46+
this.recyclerView.setAdapter(adapter);
47+
}
48+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package at.blogc.android.adapters;
2+
3+
import android.content.Context;
4+
import android.support.annotation.NonNull;
5+
import android.support.v7.widget.RecyclerView;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import at.blogc.android.adapters.viewholders.ExpandableTextViewHolder;
11+
import at.blogc.android.views.R;
12+
13+
/**
14+
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
15+
*
16+
* Licensed under the Apache License, Version 2.0 (the "License");
17+
* you may not use this file except in compliance with the License.
18+
* You may obtain a copy of the License at
19+
*
20+
* http://www.apache.org/licenses/LICENSE-2.0
21+
*
22+
* Unless required by applicable law or agreed to in writing, software
23+
* distributed under the License is distributed on an "AS IS" BASIS,
24+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25+
* See the License for the specific language governing permissions and
26+
* limitations under the License.
27+
*/
28+
public class RecyclerViewAdapter extends RecyclerView.Adapter<ExpandableTextViewHolder>
29+
{
30+
private LayoutInflater layoutInflater;
31+
32+
private LayoutInflater getLayoutInflater(@NonNull final Context context)
33+
{
34+
if (this.layoutInflater == null)
35+
{
36+
this.layoutInflater = LayoutInflater.from(context);
37+
}
38+
39+
return this.layoutInflater;
40+
}
41+
42+
@Override
43+
public ExpandableTextViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType)
44+
{
45+
final View itemView = this.getLayoutInflater(parent.getContext()).inflate(R.layout.listitem_recyclerview, parent, false);
46+
47+
return new ExpandableTextViewHolder(itemView);
48+
}
49+
50+
@Override
51+
public void onBindViewHolder(final ExpandableTextViewHolder holder, final int position)
52+
{
53+
holder.bindPosition(position);
54+
}
55+
56+
@Override
57+
public int getItemCount()
58+
{
59+
return 100;
60+
}
61+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package at.blogc.android.adapters.viewholders;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
import android.view.View;
5+
import android.view.animation.OvershootInterpolator;
6+
import android.widget.Button;
7+
8+
import at.blogc.android.views.ExpandableTextView;
9+
import at.blogc.android.views.R;
10+
11+
/**
12+
* Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
13+
*
14+
* Licensed under the Apache License, Version 2.0 (the "License");
15+
* you may not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
public class ExpandableTextViewHolder extends RecyclerView.ViewHolder
27+
implements View.OnClickListener
28+
{
29+
private final ExpandableTextView expandableTextView;
30+
private final Button buttonToggle;
31+
32+
public ExpandableTextViewHolder(final View itemView)
33+
{
34+
super(itemView);
35+
36+
// find views
37+
this.expandableTextView = itemView.findViewById(R.id.expandableTextView);
38+
this.buttonToggle = itemView.findViewById(R.id.button_toggle);
39+
40+
// set interpolators for both expanding and collapsing animations
41+
this.expandableTextView.setInterpolator(new OvershootInterpolator());
42+
43+
// toggle the ExpandableTextView
44+
this.buttonToggle.setOnClickListener(this);
45+
}
46+
47+
public void bindPosition(final int position)
48+
{
49+
final String loremIpsum = position + ": " + this.itemView.getContext().getString(R.string.lorem_ipsum);
50+
this.expandableTextView.setText(loremIpsum);
51+
}
52+
53+
//region View.OnClickListener interface
54+
55+
@Override
56+
public void onClick(final View v)
57+
{
58+
this.buttonToggle.setText(this.expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
59+
this.expandableTextView.toggle();
60+
}
61+
62+
//endregion
63+
}

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<android.support.v7.widget.RecyclerView
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:id="@+id/recyclerview"
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"/>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<RelativeLayout
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:paddingBottom="@dimen/activity_vertical_margin"
22+
android:paddingLeft="@dimen/activity_horizontal_margin"
23+
android:paddingRight="@dimen/activity_horizontal_margin"
24+
android:paddingTop="@dimen/activity_vertical_margin">
25+
26+
<at.blogc.android.views.ExpandableTextView
27+
android:id="@+id/expandableTextView"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
android:text="@string/lorem_ipsum"
31+
android:maxLines="5"
32+
android:ellipsize="end"
33+
app:animation_duration="750"/>
34+
35+
<Button
36+
android:id="@+id/button_toggle"
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:layout_below="@+id/expandableTextView"
40+
android:layout_marginTop="@dimen/activity_vertical_margin"
41+
android:text="@string/expand"/>
42+
43+
</RelativeLayout>

app/src/main/res/values-w820dp/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

app/src/main/res/values/lorem_ipsum.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
2+
<!-- Copyright (C) 2017 Cliff Ophalvens (Blogc.at)
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)