Skip to content

Commit 3eab11f

Browse files
committed
remove the dependence of AVLoadingIndicatorView.
1 parent d579f00 commit 3eab11f

File tree

12 files changed

+421
-443
lines changed

12 files changed

+421
-443
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/build
77
/captures
88
gradle*
9+
/TODO_list.md
910

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<activity android:name=".ScienceActivity" />
2424
<activity android:name=".PhotoActivity" />
2525
<activity android:name=".StoryActivity" />
26-
<activity android:name=".WebActivity"></activity>
26+
<activity android:name=".WebActivity"/>
27+
<activity android:name=".NestedLayoutActivity"/>
2728
</application>
2829

2930
</manifest>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.lcodecore.twinklingrefreshlayout;
2+
3+
import android.os.Bundle;
4+
import android.os.Handler;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.support.v7.widget.RecyclerView;
7+
import android.support.v7.widget.StaggeredGridLayoutManager;
8+
import android.view.View;
9+
import android.view.WindowManager;
10+
11+
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
12+
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
13+
import com.lcodecore.tkrefreshlayout.header.bezierlayout.BezierLayout;
14+
import com.lcodecore.twinklingrefreshlayout.adapter.PhotoAdapter;
15+
import com.lcodecore.twinklingrefreshlayout.beans.Photo;
16+
17+
import java.util.ArrayList;
18+
import java.util.List;
19+
20+
/**
21+
* Created by lcodecore on 2017/3/4.
22+
*/
23+
24+
public class NestedLayoutActivity extends AppCompatActivity {
25+
private PhotoAdapter photoAdapter;
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
setContentView(R.layout.activity_nested_layout);
31+
32+
setupRecyclerView((RecyclerView) findViewById(R.id.recyclerview));
33+
34+
findViewById(R.id.bt_back).setOnClickListener(new View.OnClickListener() {
35+
@Override
36+
public void onClick(View v) {
37+
finish();
38+
}
39+
});
40+
41+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
42+
}
43+
44+
private void setupRecyclerView(RecyclerView rv) {
45+
rv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
46+
photoAdapter = new PhotoAdapter();
47+
rv.setAdapter(photoAdapter);
48+
49+
final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
50+
// ProgressLayout headerView = new ProgressLayout(this);
51+
BezierLayout headerView = new BezierLayout(this);
52+
refreshLayout.setHeaderView(headerView);
53+
refreshLayout.setWaveHeight(140);
54+
// refreshLayout.setFloatRefresh(true);
55+
// refreshLayout.setPureScrollModeOn(true);
56+
refreshLayout.setOverScrollBottomShow(false);
57+
refreshLayout.setTargetView(rv);
58+
// refreshLayout.setAutoLoadMore(true);
59+
60+
// addHeader();
61+
refreshCard();
62+
63+
64+
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
65+
@Override
66+
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
67+
new Handler().postDelayed(new Runnable() {
68+
@Override
69+
public void run() {
70+
refreshCard();
71+
refreshLayout.finishRefreshing();
72+
}
73+
}, 2000);
74+
}
75+
76+
@Override
77+
public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
78+
new Handler().postDelayed(new Runnable() {
79+
@Override
80+
public void run() {
81+
loadMoreCard();
82+
refreshLayout.finishLoadmore();
83+
}
84+
}, 2000);
85+
}
86+
});
87+
88+
// refreshLayout.startRefresh();
89+
}
90+
91+
void refreshCard() {
92+
List<Photo> photos = new ArrayList<>();
93+
// foods.add(new Food("Preparing Salmon Steak Close Up","BY VIKTOR HANACEK",R.drawable.food1,R.drawable.avatar0));
94+
// foods.add(new Food("Fresh & Healthy Fitness Broccoli Pie with Basil","BY VIKTOR HANACEK",R.drawable.food2,R.drawable.avatar1));
95+
// foods.add(new Food("Enjoying a Tasty Burger","BY VIKTOR HANACEK",R.drawable.food3,R.drawable.avatar2));
96+
// foods.add(new Food("Fresh Strawberries and Blackberries in Little Bowl","BY VIKTOR HANACEK",R.drawable.food4,R.drawable.avatar3));
97+
// foods.add(new Food("Baked Healthy Fitness Broccoli Pie with Basil","BY VIKTOR HANACEK",R.drawable.food5,R.drawable.avatar4));
98+
photos.add(new Photo("chest nut", R.drawable.photo1));
99+
photos.add(new Photo("fish", R.drawable.photo2));
100+
photos.add(new Photo("cat", R.drawable.photo10));
101+
photos.add(new Photo("guitar", R.drawable.photo3));
102+
photos.add(new Photo("common-hazel", R.drawable.photo4));
103+
photos.add(new Photo("cherry", R.drawable.photo5));
104+
photos.add(new Photo("flower details", R.drawable.photo6));
105+
photos.add(new Photo("tree", R.drawable.photo7));
106+
photos.add(new Photo("blue berries", R.drawable.photo8));
107+
photos.add(new Photo("snow man", R.drawable.photo9));
108+
photoAdapter.setDataList(photos);
109+
}
110+
111+
void loadMoreCard() {
112+
List<Photo> photos = new ArrayList<>();
113+
photos.add(new Photo("chest nut", R.drawable.photo1));
114+
photos.add(new Photo("fish", R.drawable.photo2));
115+
photos.add(new Photo("cat", R.drawable.photo10));
116+
photos.add(new Photo("guitar", R.drawable.photo3));
117+
photos.add(new Photo("common-hazel", R.drawable.photo4));
118+
photos.add(new Photo("cherry", R.drawable.photo5));
119+
photos.add(new Photo("flower details", R.drawable.photo6));
120+
photos.add(new Photo("tree", R.drawable.photo7));
121+
photos.add(new Photo("blue berries", R.drawable.photo8));
122+
photos.add(new Photo("snow man", R.drawable.photo9));
123+
//chest nut cat and fish guitar common-hazel cherry flower details tree
124+
//blue berries snow man
125+
// foods.add(new Food(R.drawable.food3));
126+
// foods.add(new Food(R.drawable.food2));
127+
// foods.add(new Food(R.drawable.food1));
128+
photoAdapter.addItems(photos);
129+
}
130+
}

app/src/main/java/com/lcodecore/twinklingrefreshlayout/PhotoActivity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ private void setupRecyclerView(RecyclerView rv) {
5454

5555
// addHeader();
5656
refreshCard();
57-
57+
findViewById(R.id.ib_refresh).setOnClickListener(new View.OnClickListener() {
58+
@Override
59+
public void onClick(View v) {
60+
refreshLayout.startRefresh();
61+
}
62+
});
5863

5964
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
6065
@Override
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/activity_music"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:background="#ECECEC"
8+
android:orientation="vertical"
9+
tools:context="com.lcodecore.twinklingrefreshlayout.NestedLayoutActivity">
10+
11+
<RelativeLayout
12+
android:layout_width="match_parent"
13+
android:layout_height="56dp"
14+
android:background="#1F2426">
15+
16+
<ImageButton
17+
android:id="@+id/bt_back"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:layout_centerVertical="true"
21+
android:layout_marginLeft="12dp"
22+
android:background="@null"
23+
android:src="@drawable/back_pink" />
24+
25+
<TextView
26+
android:id="@+id/tv_spacing"
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:layout_centerInParent="true"
30+
android:text="P H O T O"
31+
android:textColor="#FFEEEE"
32+
android:textSize="14sp"
33+
android:textStyle="bold" />
34+
35+
<ImageButton
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:layout_alignParentRight="true"
39+
android:layout_centerVertical="true"
40+
android:layout_marginRight="12dp"
41+
android:background="@null"
42+
android:src="@drawable/map" />
43+
</RelativeLayout>
44+
45+
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
46+
android:id="@+id/refresh"
47+
android:layout_width="match_parent"
48+
android:layout_height="match_parent">
49+
50+
<LinearLayout
51+
android:layout_width="match_parent"
52+
android:layout_height="match_parent"
53+
android:orientation="vertical">
54+
<RelativeLayout
55+
android:layout_width="match_parent"
56+
android:layout_height="200dp">
57+
58+
<View
59+
android:layout_width="match_parent"
60+
android:layout_height="match_parent"
61+
/>
62+
<TextView
63+
android:id="@+id/tv"
64+
android:layout_width="match_parent"
65+
android:layout_height="40dp"
66+
android:text="我是一个多余的底部控件" />
67+
</RelativeLayout>
68+
69+
<android.support.v7.widget.RecyclerView
70+
android:id="@+id/recyclerview"
71+
android:layout_width="match_parent"
72+
android:layout_height="match_parent"
73+
android:overScrollMode="never" />
74+
</LinearLayout>
75+
76+
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
77+
78+
</LinearLayout>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
android:textStyle="bold" />
3434

3535
<ImageButton
36+
android:id="@+id/ib_refresh"
3637
android:layout_width="wrap_content"
3738
android:layout_height="wrap_content"
3839
android:layout_alignParentRight="true"

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

library/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ android {
3333

3434
dependencies {
3535
compile fileTree(include: ['*.jar'], dir: 'libs')
36-
compile 'com.wang.avi:library:1.0.1'
3736
compile 'com.android.support:appcompat-v7:23.2.0'
3837
compile 'com.android.support:recyclerview-v7:23.2.0'
3938
}

0 commit comments

Comments
 (0)