Skip to content
This repository has been archived by the owner on Jan 8, 2018. It is now read-only.

Commit

Permalink
Merge pull request chrisbanes#65 from doubleencore/subheader
Browse files Browse the repository at this point in the history
Adding subheader support for last updated times
  • Loading branch information
Chris Banes committed Apr 24, 2012
2 parents 8ecac72 + f856400 commit a7643af
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
33 changes: 24 additions & 9 deletions library/res/layout/pull_to_refresh_header.xml
Expand Up @@ -5,15 +5,32 @@
android:paddingTop="10dp"
android:paddingBottom="10dip">

<TextView
android:id="@+id/pull_to_refresh_text"
android:text="@string/pull_to_refresh_pull_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center">

<TextView
android:id="@+id/pull_to_refresh_text"
android:text="@string/pull_to_refresh_pull_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

<TextView
android:id="@+id/pull_to_refresh_sub_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="11sp"
android:visibility="gone" />

</LinearLayout>

<ProgressBar
android:id="@+id/pull_to_refresh_progress"
android:indeterminate="true"
Expand All @@ -33,6 +50,4 @@
android:layout_marginRight="20dip"
android:layout_centerVertical="true" />



</RelativeLayout>
Expand Up @@ -855,4 +855,8 @@ public static interface OnLastItemVisibleListener {
public void setLongClickable(boolean longClickable) {
getRefreshableView().setLongClickable(longClickable);
}

public void setSubHeaderText(String text) {
mHeaderLayout.setSubHeaderText(text);
}
}
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -25,6 +27,7 @@ public class LoadingLayout extends FrameLayout {
private final ImageView mHeaderImage;
private final ProgressBar mHeaderProgress;
private final TextView mHeaderText;
private final TextView mSubHeaderText;

private String mPullLabel;
private String mRefreshingLabel;
Expand All @@ -37,6 +40,7 @@ public LoadingLayout(Context context, final int mode, String releaseLabel, Strin
super(context);
ViewGroup header = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header, this);
mHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_text);
mSubHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_sub_text);
mHeaderImage = (ImageView) header.findViewById(R.id.pull_to_refresh_image);
mHeaderProgress = (ProgressBar) header.findViewById(R.id.pull_to_refresh_progress);

Expand Down Expand Up @@ -74,13 +78,18 @@ public LoadingLayout(Context context, final int mode, String releaseLabel, Strin
}

public void reset() {
mHeaderText.setText(mPullLabel);
mHeaderText.setText(Html.fromHtml(mPullLabel));
mHeaderImage.setVisibility(View.VISIBLE);
mHeaderProgress.setVisibility(View.GONE);
if (TextUtils.isEmpty(mSubHeaderText.getText())) {
mSubHeaderText.setVisibility(View.GONE);
} else {
mSubHeaderText.setVisibility(View.VISIBLE);
}
}

public void releaseToRefresh() {
mHeaderText.setText(mReleaseLabel);
mHeaderText.setText(Html.fromHtml(mReleaseLabel));
mHeaderImage.clearAnimation();
mHeaderImage.startAnimation(mRotateAnimation);
}
Expand All @@ -90,10 +99,11 @@ public void setPullLabel(String pullLabel) {
}

public void refreshing() {
mHeaderText.setText(mRefreshingLabel);
mHeaderText.setText(Html.fromHtml(mRefreshingLabel));
mHeaderImage.clearAnimation();
mHeaderImage.setVisibility(View.INVISIBLE);
mHeaderProgress.setVisibility(View.VISIBLE);
mSubHeaderText.setVisibility(View.GONE);
}

public void setRefreshingLabel(String refreshingLabel) {
Expand All @@ -105,13 +115,22 @@ public void setReleaseLabel(String releaseLabel) {
}

public void pullToRefresh() {
mHeaderText.setText(mPullLabel);
mHeaderText.setText(Html.fromHtml(mPullLabel));
mHeaderImage.clearAnimation();
mHeaderImage.startAnimation(mResetRotateAnimation);
}

public void setTextColor(int color) {
mHeaderText.setTextColor(color);
mSubHeaderText.setTextColor(color);
}

public void setSubHeaderText(String text) {
mSubHeaderText.setText(Html.fromHtml(text));
if (TextUtils.isEmpty(text)) {
mSubHeaderText.setVisibility(View.GONE);
} else {
mSubHeaderText.setVisibility(View.VISIBLE);
}
}

}

0 comments on commit a7643af

Please sign in to comment.