Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
颜路 committed Jul 23, 2014
0 parents commit 43c14a7
Show file tree
Hide file tree
Showing 28 changed files with 1,628 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gradle
/local.properties
/.idea/workspace.xml
.DS_Store
/build
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

def AAVersion = '3.0.1'

apt {
arguments {
androidManifestFile variant.processResources.manifestFile
// resourcePackageName 'com.dahuo.android.demo'

// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
resourcePackageName android.defaultConfig.packageName

// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}

configurations {
apt
}

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
applicationId "com.dahuo.learn.swiperefreshandload"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"

compile 'com.android.support:appcompat-v7:19.+'


}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/captain_miao/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dahuo.learn.swiperefreshandload;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
25 changes: 25 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dahuo.learn.swiperefreshandload" >

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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=".TextActivity"
android:label="@string/app_name" >
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.dahuo.learn.swiperefreshandload;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.dahuo.learn.swiperefreshandload.view.SwipeRefreshAndLoadLayout;

import java.util.ArrayList;


public class MainActivity extends Activity implements SwipeRefreshAndLoadLayout.OnRefreshListener {

protected ListView mListView;
private ArrayAdapter<String> mListAdapter;
SwipeRefreshAndLoadLayout mSwipeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_main);

mListView = (ListView) findViewById(R.id.list);
mListAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
mListView.setAdapter(mListAdapter);


mSwipeLayout = (SwipeRefreshAndLoadLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
mSwipeLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
mSwipeLayout.setmMode(SwipeRefreshAndLoadLayout.Mode.BOTH);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
startActivity(new Intent(this, TextActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}


ArrayList<String> values = new ArrayList<String>() {{
add("Android");
add("iPhone");
add("WindowsMobile");
add("Blackberry");
// add("WebOS");
// add("Ubuntu");
// add("Windows7");
// add("Max OS X");
// add("Linux");
// add("OS/2");
// add("Ubuntu");
// add("Windows7");
// add("Max OS X");
// add("Linux");
// add("OS/2");
// add("Ubuntu");
// add("Windows7");
// add("Max OS X");
// add("Linux");
// add("OS/2");
// add("Android");
// add("iPhone");
// add("WindowsMobile");
}};

@Override
public void onRefresh() {
values.add(0, "Add " + values.size());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeLayout.setRefreshing(false);
mListAdapter.notifyDataSetChanged();
}
}, 1000);
}

@Override
public void onLoadMore() {
values.add("Add " + values.size());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeLayout.setRefreshing(false);
mListAdapter.notifyDataSetChanged();
}
}, 1000);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.dahuo.learn.swiperefreshandload;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

import com.dahuo.learn.swiperefreshandload.view.SwipeRefreshAndLoadLayout;

import java.util.ArrayList;


public class TextActivity extends Activity implements SwipeRefreshAndLoadLayout.OnRefreshListener {

protected TextView mTextView;
SwipeRefreshAndLoadLayout mSwipeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_textview);

mTextView = (TextView) findViewById(R.id.tv);

updateText();
mSwipeLayout = (SwipeRefreshAndLoadLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
mSwipeLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
}


ArrayList<String> values = new ArrayList<String>() {{
add("Android");
add("iPhone");
add("WindowsMobile");
add("Blackberry");
add("WebOS");
add("Ubuntu");
add("Windows7");
add("Max OS X");
add("Linux");
add("OS/2");
add("Ubuntu");
add("Windows7");
add("Max OS X");
add("Linux");
add("OS/2");
add("Ubuntu");
add("Windows7");
add("Max OS X");
add("Linux");
add("OS/2");
add("Android");
add("iPhone");
}};

@Override
public void onRefresh() {
values.add(0, "Add " + values.size());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateText();
mSwipeLayout.setRefreshing(false);
}
}, 5000);
}

@Override
public void onLoadMore() {
values.add("Add " + values.size());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateText();
mSwipeLayout.setRefreshing(false);
}
}, 5000);
}


public void updateText(){
StringBuilder sb = new StringBuilder();
for (String v : values) {
sb.append(v).append("\n");
}
mTextView.setText(sb);
}
}
Loading

0 comments on commit 43c14a7

Please sign in to comment.