Skip to content

Commit

Permalink
fixed an bug which cause custom loading hint failure and add some get…
Browse files Browse the repository at this point in the history
…ter of LoadingMoreFooter
  • Loading branch information
af913337456 committed Nov 7, 2017
1 parent e002ec4 commit 3f45e97
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -42,6 +41,9 @@ protected void onCreate(Bundle savedInstanceState) {
View header = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup)findViewById(android.R.id.content),false);
mRecyclerView.addHeaderView(header);

mRecyclerView.getDefaultFootView().setLoadingHint("自定义加载中提示");
mRecyclerView.getDefaultFootView().setNoMoreHint("自定义加载完毕提示");

mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class LoadingMoreFooter extends LinearLayout {
public final static int STATE_LOADING = 0;
public final static int STATE_COMPLETE = 1;
public final static int STATE_NOMORE = 2;

private TextView mText;
private String loadingHint;
private String noMoreHint;
Expand Down Expand Up @@ -64,10 +65,18 @@ public void initView(){

addView(progressCon);
mText = new TextView(getContext());
mText.setText("正在加载...");
loadingHint = (String)getContext().getText(R.string.listview_loading);
noMoreHint = (String)getContext().getText(R.string.nomore_loading);
loadingDoneHint = (String)getContext().getText(R.string.loading_done);
mText.setText(getContext().getString(R.string.listview_loading));

if(loadingHint == null || loadingHint.equals("")){
loadingHint = (String)getContext().getText(R.string.listview_loading);
}
if(noMoreHint == null || noMoreHint.equals("")){
noMoreHint = (String)getContext().getText(R.string.nomore_loading);
}
if(loadingDoneHint == null || loadingDoneHint.equals("")){
loadingDoneHint = (String)getContext().getText(R.string.loading_done);
}

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins( (int)getResources().getDimension(R.dimen.textandiconmargin),0,0,0 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ private void init() {
mFootView.setVisibility(GONE);
}

public LoadingMoreFooter getDefaultFootView(){
if(mFootView == null){
return null;
}
if(mFootView instanceof LoadingMoreFooter){
return ((LoadingMoreFooter) mFootView);
}
return null;
}

public View getFootView(){
return mFootView;
}

public void setFootViewText(String loading, String noMore) {
if(mFootView instanceof LoadingMoreFooter){
((LoadingMoreFooter) mFootView).setLoadingHint(loading);
Expand Down

0 comments on commit 3f45e97

Please sign in to comment.