forked from XRecyclerView/XRecyclerView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
解决以下问题: 1 CollapsingToolbarLayout使用时有冲突 2.不使用加载更多时仍然会空出一个item 3.header乱序 4.更多的sample 5.其它代码方面的优化
- Loading branch information
1 parent
be8443f
commit 8b1085c
Showing
29 changed files
with
943 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.xrecyclerview" > | ||
package="com.example.xrecyclerview"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".GridActivity" | ||
android:label="@string/app_name" > | ||
</activity> | ||
<activity | ||
android:name=".LinearActivity" | ||
android:label="@string/app_name" > | ||
</activity> | ||
android:label="@string/app_name" | ||
android:theme="@style/SupportTheme" /> | ||
<activity | ||
android:name=".GridActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/SupportTheme" /> | ||
<activity | ||
android:name=".StaggeredGridActivity" | ||
android:label="@string/app_name" > | ||
</activity> | ||
android:label="@string/app_name" | ||
android:theme="@style/SupportTheme" /> | ||
<activity | ||
android:name=".EmptyViewActivity" | ||
android:label="@string/app_name" > | ||
</activity> | ||
android:label="@string/app_name" /> | ||
<activity | ||
android:name=".CollapsingToolbarLayoutActivity" | ||
android:theme="@style/SupportTheme" /> | ||
<activity | ||
android:name=".DisableExampleActivity" | ||
android:theme="@style/SupportTheme" /> | ||
<activity | ||
android:name=".MultiHeaderActivity" | ||
android:theme="@style/SupportTheme" | ||
></activity> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
109 changes: 109 additions & 0 deletions
109
app/src/main/java/com/example/xrecyclerview/CollapsingToolbarLayoutActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.example.xrecyclerview; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Handler; | ||
import android.support.design.widget.AppBarLayout; | ||
import android.support.design.widget.CollapsingToolbarLayout; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.LayoutInflater; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Toast; | ||
|
||
import com.jcodecraeer.xrecyclerview.ProgressStyle; | ||
import com.jcodecraeer.xrecyclerview.XRecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class CollapsingToolbarLayoutActivity extends AppCompatActivity { | ||
private XRecyclerView mRecyclerView; | ||
private MyAdapter mAdapter; | ||
private ArrayList<String> listData; | ||
private int refreshTime = 0; | ||
private int times = 0; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_collapsing_toolbar_layout); | ||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
|
||
mRecyclerView = (XRecyclerView)this.findViewById(R.id.recyclerview); | ||
LinearLayoutManager layoutManager = new LinearLayoutManager(this); | ||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL); | ||
mRecyclerView.setLayoutManager(layoutManager); | ||
|
||
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader); | ||
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate); | ||
mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey); | ||
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() { | ||
@Override | ||
public void onRefresh() { | ||
refreshTime ++; | ||
times = 0; | ||
new Handler().postDelayed(new Runnable(){ | ||
public void run() { | ||
|
||
listData.clear(); | ||
for(int i = 0; i < 15 ;i++){ | ||
listData.add("item" + i + "after " + refreshTime + " times of refresh"); | ||
} | ||
mAdapter.notifyDataSetChanged(); | ||
mRecyclerView.refreshComplete(); | ||
} | ||
|
||
}, 1000); //refresh data here | ||
} | ||
|
||
@Override | ||
public void onLoadMore() { | ||
if(times < 2){ | ||
new Handler().postDelayed(new Runnable(){ | ||
public void run() { | ||
mRecyclerView.loadMoreComplete(); | ||
for(int i = 0; i < 15 ;i++){ | ||
listData.add("item" + (i + listData.size()) ); | ||
} | ||
mRecyclerView.loadMoreComplete(); | ||
mAdapter.notifyDataSetChanged(); | ||
} | ||
}, 1000); | ||
} else { | ||
new Handler().postDelayed(new Runnable() { | ||
public void run() { | ||
for(int i = 0; i < 9 ;i++){ | ||
listData.add("item" + (1 + listData.size() ) ); | ||
} | ||
mRecyclerView.setNoMore(true); | ||
mAdapter.notifyDataSetChanged(); | ||
} | ||
}, 1000); | ||
} | ||
times ++; | ||
} | ||
}); | ||
|
||
listData = new ArrayList<String>(); | ||
for(int i = 0; i < 15 ;i++){ | ||
listData.add("item" + i); | ||
} | ||
mAdapter = new MyAdapter(listData); | ||
mRecyclerView.setAdapter(mAdapter); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/example/xrecyclerview/DisableExampleActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.example.xrecyclerview; | ||
|
||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.v7.app.AppCompatActivity; | ||
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; | ||
|
||
import com.jcodecraeer.xrecyclerview.ProgressStyle; | ||
import com.jcodecraeer.xrecyclerview.XRecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class DisableExampleActivity extends AppCompatActivity { | ||
private XRecyclerView mRecyclerView; | ||
private MyAdapter mAdapter; | ||
private ArrayList<String> listData; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_recyclerview); | ||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
|
||
mRecyclerView = (XRecyclerView)this.findViewById(R.id.recyclerview); | ||
LinearLayoutManager layoutManager = new LinearLayoutManager(this); | ||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL); | ||
mRecyclerView.setLayoutManager(layoutManager); | ||
mRecyclerView.setLoadingMoreEnabled(false); | ||
mRecyclerView.setPullRefreshEnabled(false); | ||
listData = new ArrayList<String>(); | ||
for(int i = 0; i < 15 ;i++){ | ||
listData.add("item" + i); | ||
} | ||
mAdapter = new MyAdapter(listData); | ||
mRecyclerView.setAdapter(mAdapter); | ||
|
||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.