Skip to content

Commit

Permalink
解决部分已知bug,优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
“jdsjlzx” committed Jan 30, 2018
1 parent a771079 commit dca2dfe
Show file tree
Hide file tree
Showing 20 changed files with 421 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,25 @@ public void onScrolled(int dx, int dy) {
mLScrollListener.onScrolled(mScrolledXDistance, mScrolledYDistance);
}

if (mLoadMoreListener != null && mLoadMoreEnabled) {
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount > 0
&& lastVisibleItemPosition >= totalItemCount - 1
&& totalItemCount > visibleItemCount
&& !isNoMore
&& !mRefreshing) {

mFootView.setVisibility(View.VISIBLE);
if (!mLoadingData) {
mLoadingData = true;
mLoadMoreFooter.onLoading();
}

}

}

}

@Override
Expand All @@ -603,30 +622,7 @@ public void onScrollStateChanged(int state) {
mLScrollListener.onScrollStateChanged(state);
}

if (mLoadMoreListener != null && mLoadMoreEnabled) {
if (currentScrollState == RecyclerView.SCROLL_STATE_IDLE) {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount > 0
&& lastVisibleItemPosition >= totalItemCount - 1
&& totalItemCount > visibleItemCount
&& !isNoMore
&& !mRefreshing) {

mFootView.setVisibility(View.VISIBLE);
if (mLoadingData) {
return;
} else {
mLoadingData = true;
mLoadMoreFooter.onLoading();
mLoadMoreListener.onLoadMore();
}

}

}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
mInnerAdapter.onViewDetachedFromWindow(holder);
}

@Override
/*@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
mInnerAdapter.onViewRecycled(holder);
}
}*/


public static class ViewHolder extends RecyclerView.ViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,24 @@ public void onScrolled(int dx, int dy) {
mLScrollListener.onScrolled(mScrolledXDistance, mScrolledYDistance);
}

if (mLoadMoreListener != null && mLoadMoreEnabled) {
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount > 0
&& lastVisibleItemPosition >= totalItemCount - 1
&& totalItemCount > visibleItemCount
&& !isNoMore
&& !mRefreshing) {

mFootView.setVisibility(View.VISIBLE);
if (!mLoadingData) {
mLoadingData = true;
mLoadMoreFooter.onLoading();
}

}

}
}

@Override
Expand All @@ -407,32 +425,6 @@ public void onScrollStateChanged(int state) {
if (mLScrollListener != null) {
mLScrollListener.onScrollStateChanged(state);
}

if (mLoadMoreListener != null && mLoadMoreEnabled) {
if (currentScrollState == RecyclerView.SCROLL_STATE_IDLE) {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount > 0
&& lastVisibleItemPosition >= totalItemCount - 1
&& totalItemCount > visibleItemCount
&& !isNoMore
&& !mRefreshing) {

mFootView.setVisibility(View.VISIBLE);
if (mLoadingData) {
return;
} else {
mLoadingData = true;
mLoadMoreFooter.onLoading();
mLoadMoreListener.onLoadMore();
}

}

}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ public class LoadingFooter extends RelativeLayout implements ILoadMoreFooter {

public LoadingFooter(Context context) {
super(context);
init(context);
init();
}

public LoadingFooter(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
init();
}

public LoadingFooter(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
init();
}

public void init(Context context) {
public void init() {

inflate(context, R.layout.layout_recyclerview_footer, this);
inflate(getContext(), R.layout.layout_recyclerview_footer, this);
setOnClickListener(null);

onReset();//初始为隐藏状态
Expand Down
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
implementation 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
implementation project(path: ':LRecyclerview_library')
implementation 'com.nineoldandroids:library:2.4.0'
compile 'com.github.jdsjlzx:banner:1.0.0'
implementation 'com.github.jdsjlzx:banner:1.0.0'
implementation 'com.android.support:design:27.0.2'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
<activity android:name=".ui.WebViewActivity" />
<activity android:name=".ui.LinearLayoutDelActivity" />
<activity android:name=".ui.CoordinatorLayoutActivity" />
<activity android:name=".ui.AlipayHomeActivity"></activity>
<activity android:name=".ui.AlipayHomeActivity" />
<activity android:name=".ui.AlphaChangeActivity" />
</application>

</manifest>
29 changes: 29 additions & 0 deletions app/src/main/java/com/lzx/demo/adapter/DataAdapter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.lzx.demo.adapter;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.lzx.demo.R;
Expand Down Expand Up @@ -28,6 +31,32 @@ public void onBindItemHolder(SuperViewHolder holder, int position) {
ItemModel item = mDataList.get(position);

TextView titleText = holder.getView(R.id.info_text);
EditText titleEditor = holder.getView(R.id.info_edtor);
titleText.setText(item.title);
titleEditor.addTextChangedListener(textWatcher);
}

@Override
public void onViewRecycled(SuperViewHolder holder) {
super.onViewRecycled(holder);
EditText titleEditor = holder.getView(R.id.info_edtor);
titleEditor.removeTextChangedListener(textWatcher);
}

TextWatcher textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {

}
};
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/lzx/demo/ui/AlipayHomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

Expand Down Expand Up @@ -37,6 +38,7 @@ public class AlipayHomeActivity extends AppCompatActivity implements AppBarLayou
private LRecyclerView mRecyclerView = null;
private LRecyclerViewAdapter mLRecyclerViewAdapter = null;
private DataAdapter mDataAdapter = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -101,6 +103,7 @@ public void run() {

}

//效果不是很完美
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
Log.d("lzx", "verticalOffset=" + verticalOffset);
Expand Down
Loading

0 comments on commit dca2dfe

Please sign in to comment.