Skip to content

Commit

Permalink
2015-3-10
Browse files Browse the repository at this point in the history
  • Loading branch information
guojunyi committed Mar 10, 2015
1 parent cb5d7fd commit 55061b2
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 289 deletions.
4 changes: 2 additions & 2 deletions PullDownListView/.classpath
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
8 changes: 2 additions & 6 deletions PullDownListView/src/com/pulldownlistview/EyeView.java
Expand Up @@ -29,7 +29,8 @@ public class EyeView extends ImageView {
public EyeView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint = new Paint();
mPaint.setAntiAlias(true);
rotateProgress = 0;
progress = 0.0f;
}
Expand All @@ -44,9 +45,6 @@ public void onDraw(Canvas canvas) {
bitmap.recycle();

}

// mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));

}


Expand Down Expand Up @@ -112,8 +110,6 @@ public Bitmap getBitmap(){
temp1.recycle();
temp2.recycle();
mask.recycle();
// origin1.recycle();
// origin2.recycle();
return bitmap;
}

Expand Down
162 changes: 83 additions & 79 deletions PullDownListView/src/com/pulldownlistview/MainActivity.java
@@ -1,6 +1,5 @@
package com.pulldownlistview;


import com.pulldownlistview.PullDownListView.OnPullHeightChangeListener;

import android.app.Activity;
Expand All @@ -12,94 +11,99 @@
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity{
public class MainActivity extends Activity {
final String TAG = "MainActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final PullDownListView pullDownListView = (PullDownListView) this.findViewById(R.id.pullDownListView);
final YProgressView progressViewTop = (YProgressView) this.findViewById(R.id.progressView);

final PullDownListView pullDownListView = (PullDownListView) this
.findViewById(R.id.pullDownListView);
final YProgressView progressView = (YProgressView) this
.findViewById(R.id.progressView);
final EyeView eyeView = (EyeView) this.findViewById(R.id.eyeView);
String[] adapterData = new String[] {"Afghanistan", "Albania", "Algeria",
"American Samoa", "Andorra", "Angola", "Anguilla",
"Antarctica", "Antigua and Barbuda", "Argentina", "Armenia",
"Aruba", "Australia", "Austria", "Azerbaijan", "Bahrain",
"Bangladesh", "Barbados", "Belarus", "Belgium", "Belize",
"Benin", "Bermuda", "Bhutan", "Bolivia",
"Bosnia and Herzegovina", "Botswana", "Bouvet Island"};


pullDownListView.getListView().setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, adapterData));


pullDownListView.setOnPullHeightChangeListener(new OnPullHeightChangeListener(){

@Override
public void onTopHeightChange(int headerHeight, int pullHeight) {
// TODO Auto-generated method stub
Log.e(TAG,"headerHeight:"+headerHeight+" pullHeight:"+pullHeight);

float progress = (float)pullHeight/(float)headerHeight-0.2f;
if(progress>1.0f){
progress = 1.0f;
}

if(!pullDownListView.isRefreshing()){
eyeView.setProgress(progress);
}
}

@Override
public void onBottomHeightChange(int footerHeight, int pullHeight) {
// TODO Auto-generated method stub
Log.e(TAG,"footerHeight:"+footerHeight+" pullHeight:"+pullHeight);

float progress = (float)pullHeight/(float)footerHeight-0.2f;
if(progress>1.0f){
progress = 1.0f;
}
if(!pullDownListView.isRefreshing()){
progressViewTop.setProgress(progress);
}

}

@Override
public void onRefreshing() {
// TODO Auto-generated method stub
progressViewTop.startAnimate();
eyeView.startAnimate();
new Handler().postDelayed(new Runnable(){
String[] adapterData = new String[] { "A", "B", "C", "D", "E", "F",
"G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z" };

pullDownListView.getListView().setAdapter(
new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, adapterData));

pullDownListView
.setOnPullHeightChangeListener(new OnPullHeightChangeListener() {

@Override
public void onTopHeightChange(int headerHeight,
int pullHeight) {
// TODO Auto-generated method stub
float progress = (float) pullHeight
/ (float) headerHeight - 0.2f;
if (progress > 1.0f) {
progress = 1.0f;
}

if (!pullDownListView.isRefreshing()) {
eyeView.setProgress(progress);
}
}

@Override
public void run() {
public void onBottomHeightChange(int footerHeight,
int pullHeight) {
// TODO Auto-generated method stub
pullDownListView.pullUp();
progressViewTop.stopAnimate();
eyeView.stopAnimate();
float progress = (float) pullHeight
/ (float) footerHeight - 0.2f;
if (progress > 1.0f) {
progress = 1.0f;
}
if (!pullDownListView.isRefreshing()) {
progressView.setProgress(progress);
}

}

}, 3000);
}



});

pullDownListView.getListView().setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub

}

});


@Override
public void onRefreshing(final boolean isTop) {
// TODO Auto-generated method stub
if (isTop) {
eyeView.startAnimate();
} else {
progressView.startAnimate();
}

new Handler().postDelayed(new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub
pullDownListView.pullUp();
if (isTop) {
eyeView.stopAnimate();
} else {
progressView.stopAnimate();
}
}

}, 3000);
}

});

pullDownListView.getListView().setOnItemClickListener(
new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub

}

});

}
}

0 comments on commit 55061b2

Please sign in to comment.