[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pulltorefresh library #50

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added ActionBar-PullToRefresh library
  • Loading branch information
aagam-shah committed Aug 31, 2013
commit 06a8bf547a5c724bea17c452a88f020a68ba2774
14 changes: 8 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="libs/volley.jar"/>
<classpathentry exported="true" kind="lib" path="libs/gson-2.2.2.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/httpmime-4.1.2.jar"/>
<classpathentry kind="lib" path="libs/tagsoup-1.2.1.jar"/>
<classpathentry kind="lib" path="libs/gson-2.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="libs/httpmime-4.1.2.jar"/>
<classpathentry exported="true" kind="lib" path="libs/tagsoup-1.2.1.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="/ActionBarSherlock/libs/android-support-v4.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="libs/volley.jar"/>
<classpathentry kind="lib" path="libs/gcm.jar"/>
<classpathentry exported="true" kind="lib" path="libs/gcm.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry exported="true" kind="lib" path="/home/star/adt-bundle-linux-x86_64/wordpress/libs/android-support-v4.jar"/>
<classpathentry exported="true" kind="lib" path="/home/star/adt-bundle-linux-x86_64/wordpress/libs/wordpresscom-android-rest-v0.0.3.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
5 changes: 3 additions & 2 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="DefaultLocale" severity="ignore" />
<issue id="MissingTranslation">
<ignore path="res\values\strings.xml" />
<ignore path="res/values/strings.xml" />
</issue>
</lint>
</lint>
5 changes: 3 additions & 2 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ split.density=false
target=android-17
apk-configurations=
android.library=false
android.library.reference.1=../ActionBarSherlock/library
android.library.reference.2=../../../Downloads/android-menudrawer-master/library
android.library.reference.1=../../JakeWharton-ActionBarSherlock-071a61c/actionbarsherlock
android.library.reference.2=../../new/android-menudrawer-master/library

android.library.reference.3=../ActionBar-PullToRefresh/library
5 changes: 0 additions & 5 deletions res/menu/basic_menu.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/menu_refresh"
android:icon="@drawable/ab_icon_refresh"
android:showAsAction="always"
android:title="@string/refresh"/>
<item
android:id="@+id/menu_settings"
android:icon="@android:drawable/ic_menu_preferences"
Expand Down
9 changes: 1 addition & 8 deletions res/menu/posts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >


<item
android:id="@+id/menu_refresh"
android:icon="@drawable/ab_icon_refresh"
android:showAsAction="always"
android:menuCategory="container"
android:orderInCategory="2"
android:title="@string/refresh"/>
<item
android:id="@+id/menu_new_post"
android:icon="@drawable/ab_icon_new"
android:showAsAction="always"
android:menuCategory="container"
android:orderInCategory="3"
android:orderInCategory="2"
android:title="@string/new_post"/>
<item
android:id="@+id/menu_post_search"
Expand Down
1 change: 0 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<string name="uploading">Uploading</string>
<string name="uploading_media_item">Uploading media item #</string>
<string name="gallery_error">Sorry, the media item could not be retrieved.</string>
<string name="refresh">Refresh</string>
<string name="home">Home</string>
<string name="more_tag">More</string>
<string name="blog_not_found">Sorry, an error occurred when attempting to access this blog.</string>
Expand Down
33 changes: 19 additions & 14 deletions src/org/wordpress/android/ui/comments/CommentsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
Expand All @@ -33,9 +34,11 @@
import org.wordpress.android.ui.comments.CommentsListFragment.OnCommentSelectedListener;
import org.wordpress.android.ui.comments.CommentsListFragment.OnContextCommentStatusChangeListener;

import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher;

public class CommentsActivity extends WPActionBarActivity implements
OnCommentSelectedListener, OnCommentStatusChangeListener,
OnAnimateRefreshButtonListener, OnContextCommentStatusChangeListener {
OnAnimateRefreshButtonListener, OnContextCommentStatusChangeListener, PullToRefreshAttacher.OnRefreshListener {

protected int id;
public int ID_DIALOG_MODERATING = 1;
Expand All @@ -45,7 +48,7 @@ public class CommentsActivity extends WPActionBarActivity implements
public ProgressDialog pd;
private CommentsListFragment commentList;
private boolean fromNotification = false;
private MenuItem refreshMenuItem;
private PullToRefreshAttacher pullToRefreshAttacher;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -55,7 +58,7 @@ public void onCreate(Bundle savedInstanceState) {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
setTitle(getString(R.string.tab_comments));

Bundle extras = getIntent().getExtras();
if (extras != null) {
fromNotification = extras.getBoolean("fromNotification");
Expand All @@ -72,7 +75,8 @@ public void onCreate(Bundle savedInstanceState) {
FragmentManager fm = getSupportFragmentManager();
fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
commentList = (CommentsListFragment) fm.findFragmentById(R.id.commentList);

pullToRefreshAttacher = PullToRefreshAttacher.get(this);
pullToRefreshAttacher.addRefreshableView(commentList.getListView(), this);
WordPress.currentComment = null;

attemptToSelectComment();
Expand All @@ -94,23 +98,17 @@ public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.basic_menu, menu);
refreshMenuItem = menu.findItem(R.id.menu_refresh);
if (shouldAnimateRefreshButton) {
shouldAnimateRefreshButton = false;
startAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(true);
}
return true;
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_refresh) {
popCommentDetail();
attemptToSelectComment();
commentList.refreshComments(false, false, false);
return true;
} else if (itemId == android.R.id.home) {
if (itemId == android.R.id.home) {
FragmentManager fm = getSupportFragmentManager();
if (fm.getBackStackEntryCount() > 0) {
popCommentDetail();
Expand Down Expand Up @@ -569,9 +567,9 @@ public void onAnimateRefreshButton(boolean start) {

if (start) {
shouldAnimateRefreshButton = true;
this.startAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(true);
} else {
this.stopAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(false);
}

}
Expand All @@ -595,4 +593,11 @@ public void onSaveInstanceState(Bundle outState) {
}
super.onSaveInstanceState(outState);
}

@Override
public void onRefreshStarted(View view) {
popCommentDetail();
attemptToSelectComment();
commentList.refreshComments(false, false, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ public void refreshComments(final boolean more, final boolean refresh,

if (!loadMore && !doInBackground) {
onAnimateRefreshButton.onAnimateRefreshButton(true);

}
client = new XMLRPCClient(WordPress.currentBlog.getUrl(),
WordPress.currentBlog.getHttpuser(),
Expand Down
26 changes: 18 additions & 8 deletions src/org/wordpress/android/ui/posts/PostsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
import org.wordpress.android.util.WPAlertDialogFragment.OnDialogConfirmListener;
import org.wordpress.android.ui.notifications.NotificationsActivity;

import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher;

public class PostsActivity extends WPActionBarActivity implements OnPostSelectedListener,
OnRefreshListener, OnPostActionListener, OnDetailPostActionListener,
OnDialogConfirmListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener {
OnDialogConfirmListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener, PullToRefreshAttacher.OnRefreshListener {

private PostsListFragment postList;
private static final int ID_DIALOG_DELETING = 1, ID_DIALOG_SHARE = 2, ID_DIALOG_COMMENT = 3;
Expand All @@ -60,10 +62,10 @@ public class PostsActivity extends WPActionBarActivity implements OnPostSelected
public SearchView searchView;
public SearchManager searchManager;
public SearchableInfo searchableInfo;
public PullToRefreshAttacher pullToRefreshAttacher;
public boolean isPage = false;
public String errorMsg = "";
public boolean isRefreshing = false;
private MenuItem refreshMenuItem;
private static final int ACTIVITY_EDIT_POST = 0;
private static final int ACTIVITY_ADD_COMMENT = 1;

Expand Down Expand Up @@ -118,7 +120,8 @@ public void onCreate(Bundle savedInstanceState) {
fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
postList = (PostsListFragment) fm.findFragmentById(R.id.postList);
postList.setListShown(true);

pullToRefreshAttacher = PullToRefreshAttacher.get(this);
pullToRefreshAttacher.addRefreshableView(postList.getListView(), this);
if (extras != null) {
isPage = extras.getBoolean("viewPages");
String errorMessage = extras.getString("errorMessage");
Expand Down Expand Up @@ -278,7 +281,8 @@ protected void onResume() {
protected void onPause() {
super.onPause();
if (isRefreshing)
stopAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(false);
//stopAnimatingRefreshButton(refreshMenuItem);
}

@Override
Expand All @@ -293,7 +297,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.posts, menu);
refreshMenuItem = menu.findItem(R.id.menu_refresh);

searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView)menu.findItem(R.id.menu_post_search).getActionView();
Expand All @@ -307,7 +310,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

if (shouldAnimateRefreshButton) {
shouldAnimateRefreshButton = false;
startAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(!shouldAnimateRefreshButton);
}
return true;
}
Expand Down Expand Up @@ -401,10 +404,11 @@ public void onRefresh(boolean start) {
if (start) {
attemptToSelectPost();
shouldAnimateRefreshButton = true;
startAnimatingRefreshButton(refreshMenuItem);
// startAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshing(true);
isRefreshing = true;
} else {
stopAnimatingRefreshButton(refreshMenuItem);
pullToRefreshAttacher.setRefreshComplete();
isRefreshing = false;
}

Expand Down Expand Up @@ -897,4 +901,10 @@ public boolean onClose() {
postList.closeSearch();
return false;
}

@Override
public void onRefreshStarted(View view) {
checkForLocalChanges(true);
new ApiHelper.RefreshBlogContentTask(this, WordPress.currentBlog).execute(false);
}
}
4 changes: 2 additions & 2 deletions src/org/wordpress/android/ui/posts/PostsListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class PostsListFragment extends ListFragment {
private OnRefreshListener mOnRefreshListener;
private OnPostActionListener mOnPostActionListener;
private PostsActivity mParentActivity;

private ListView listView;
public boolean inDrafts = false;
public List<String> imageUrl = new Vector<String>();
public String errorMsg = "";
Expand Down Expand Up @@ -251,7 +251,7 @@ public boolean loadPosts(boolean loadMore) { // loads posts from the db
}

if (loadedPosts != null || drafts == true) {
ListView listView = getListView();
listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setBackgroundColor(getResources().getColor(R.color.list_row_bg));
listView.setDivider(getResources().getDrawable(R.drawable.list_divider));
Expand Down