integrate viewpagerindicator to display feed reading progress

This commit is contained in:
Andrew Dolgov 2013-04-16 22:00:59 +04:00
parent 5b76e9c2ab
commit f10c37563a
4 changed files with 36 additions and 9 deletions

View File

@ -9,3 +9,4 @@
# Project target. # Project target.
target=android-17 target=android-17
android.library.reference.1=../Android-ViewPagerIndicator/library

View File

@ -1,9 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/article_pager_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/article_pager"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:id="@+id/article_pager"> android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager> </android.support.v4.view.ViewPager>
<com.viewpagerindicator.UnderlinePageIndicator
android:id="@+id/article_titles"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" />
</RelativeLayout>

View File

@ -24,6 +24,8 @@ import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.viewpagerindicator.TitlePageIndicator;
import com.viewpagerindicator.UnderlinePageIndicator;
public class ArticlePager extends Fragment { public class ArticlePager extends Fragment {
@ -93,7 +95,7 @@ public class ArticlePager extends Fragment {
m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager()); m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager());
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager); ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);
int position = m_articles.indexOf(m_article); int position = m_articles.indexOf(m_article);
m_listener.onArticleSelected(m_article, false); m_listener.onArticleSelected(m_article, false);
@ -101,8 +103,13 @@ public class ArticlePager extends Fragment {
m_activity.setProgressBarVisibility(true); m_activity.setProgressBarVisibility(true);
pager.setAdapter(m_adapter); pager.setAdapter(m_adapter);
UnderlinePageIndicator indicator = (UnderlinePageIndicator)view.findViewById(R.id.article_titles);
indicator.setViewPager(pager);
pager.setCurrentItem(position); pager.setCurrentItem(position);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
public void onPageScrollStateChanged(int arg0) { public void onPageScrollStateChanged(int arg0) {

View File

@ -2,6 +2,8 @@ package org.fox.ttrss.offline;
import org.fox.ttrss.R; import org.fox.ttrss.R;
import com.viewpagerindicator.UnderlinePageIndicator;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
@ -171,8 +173,12 @@ public class OfflineArticlePager extends Fragment {
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager); ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);
pager.setAdapter(m_adapter); pager.setAdapter(m_adapter);
UnderlinePageIndicator indicator = (UnderlinePageIndicator)view.findViewById(R.id.article_titles);
indicator.setViewPager(pager);
pager.setCurrentItem(position); pager.setCurrentItem(position);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
public void onPageScrollStateChanged(int arg0) { public void onPageScrollStateChanged(int arg0) {