implement moving between articles
This commit is contained in:
parent
9decf04ac3
commit
ebb1253ddd
BIN
res/drawable-hdpi/ic_next_article.png
Normal file
BIN
res/drawable-hdpi/ic_next_article.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 473 B |
BIN
res/drawable-hdpi/ic_next_article_disabled.png
Normal file
BIN
res/drawable-hdpi/ic_next_article_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 482 B |
BIN
res/drawable-hdpi/ic_prev_article.png
Normal file
BIN
res/drawable-hdpi/ic_prev_article.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 B |
BIN
res/drawable-hdpi/ic_prev_article_disabled.png
Normal file
BIN
res/drawable-hdpi/ic_prev_article_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 486 B |
70
res/drawable/s_prev_article.svg
Normal file
70
res/drawable/s_prev_article.svg
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="32px"
|
||||||
|
height="32px"
|
||||||
|
id="svg2985"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.0 r9654"
|
||||||
|
sodipodi:docname="s_prev_article.svg"
|
||||||
|
inkscape:export-filename="C:\Users\fox\workspace\org.fox.ttrss\res\drawable-hdpi\s_prev_article.png"
|
||||||
|
inkscape:export-xdpi="90"
|
||||||
|
inkscape:export-ydpi="90">
|
||||||
|
<defs
|
||||||
|
id="defs2987" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="15.836083"
|
||||||
|
inkscape:cx="13.700373"
|
||||||
|
inkscape:cy="14.630233"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:grid-bbox="true"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:window-width="1600"
|
||||||
|
inkscape:window-height="1138"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:snap-global="true">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid2997" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata2990">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<path
|
||||||
|
style="fill:#898989;fill-opacity:1;stroke:none"
|
||||||
|
d="m 23.5,1 -10,15 10,15 -5,0 -10,-15 10,-15 z"
|
||||||
|
id="path2999"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccccccc" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
@ -1,38 +1,141 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<LinearLayout android:id="@+id/article_fragment" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal">
|
android:id="@+id/article_fragment"
|
||||||
<ImageView android:layout_weight="0" android:background="?articleDivider" android:layout_width="wrap_content" android:paddingLeft="4dip" android:layout_height="match_parent"></ImageView>
|
android:layout_width="fill_parent"
|
||||||
<LinearLayout
|
android:layout_height="fill_parent"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:orientation="horizontal" >
|
||||||
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
|
|
||||||
android:id="@+id/linerLayout2"
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/splitter_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" android:orientation="vertical">
|
android:layout_height="match_parent"
|
||||||
<LinearLayout android:background="?articleHeader" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/article_header" android:padding="10dip" android:orientation="vertical">
|
android:layout_weight="0"
|
||||||
<TextView android:singleLine="true" android:layout_weight="1" android:text="{Title}" android:layout_height="wrap_content" android:ellipsize="end" android:layout_width="match_parent" android:id="@+id/title" android:textSize="18dip"></TextView>
|
android:background="?articleDivider"
|
||||||
<LinearLayout
|
android:clickable="true"
|
||||||
android:id="@+id/linearLayout3"
|
android:paddingLeft="4dip" >
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
</ImageView>
|
||||||
android:layout_weight="1">
|
|
||||||
<TextView android:text="{COMMENTS}" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="wrap_content" android:id="@+id/comments"></TextView>
|
<LinearLayout
|
||||||
<TextView android:text="{DATE}" android:gravity="right" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/date"></TextView>
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
</LinearLayout>
|
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
|
||||||
|
android:id="@+id/linerLayout2"
|
||||||
</LinearLayout>
|
android:layout_width="match_parent"
|
||||||
<ImageView android:background="?feedlistDivider" android:paddingTop="2dip" android:layout_weight="0" android:layout_height="wrap_content" android:layout_width="match_parent"></ImageView>
|
android:layout_height="match_parent"
|
||||||
<WebView android:layout_weight="1" android:layout_width="match_parent" android:padding="3dip" android:layout_height="match_parent" android:id="@+id/content"></WebView>
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical" >
|
||||||
<!-- Ad Placeholder -->
|
|
||||||
<com.google.ads.AdView
|
<ImageView
|
||||||
android:id="@+id/ad"
|
android:id="@+id/splitter_horizontal"
|
||||||
android:layout_weight="0"
|
android:layout_width="match_parent"
|
||||||
android:gravity="center"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:layout_weight="0"
|
||||||
android:layout_width="match_parent"
|
android:background="?articleDivider"
|
||||||
android:layout_height="wrap_content"
|
android:clickable="true"
|
||||||
ads:adUnitId="a14ed24fe8c671c"
|
android:paddingTop="4dip" />
|
||||||
ads:adSize="BANNER"
|
|
||||||
ads:loadAdOnCreate="false" />
|
<LinearLayout
|
||||||
</LinearLayout>
|
android:id="@+id/linearLayout5"
|
||||||
</LinearLayout>
|
android:padding="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:layout_gravity="center_vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/prev_article"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:src="@drawable/ic_prev_article" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:id="@+id/article_header"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?articleHeader"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="{Title}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayout3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tags"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="{TAGS}"
|
||||||
|
android:textSize="10sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="{DATE}"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/next_article"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:src="@drawable/ic_next_article" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:background="?feedlistDivider"
|
||||||
|
android:paddingTop="2dip" >
|
||||||
|
</ImageView>
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="3dip" >
|
||||||
|
</WebView>
|
||||||
|
|
||||||
|
<!-- Ad Placeholder -->
|
||||||
|
|
||||||
|
<com.google.ads.AdView
|
||||||
|
android:id="@+id/ad"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
ads:adSize="BANNER"
|
||||||
|
ads:adUnitId="a14ed24fe8c671c"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:gravity="center"
|
||||||
|
ads:loadAdOnCreate="false" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -3,6 +3,9 @@ package org.fox.ttrss;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.fox.ttrss.ArticleOps.RelativeArticle;
|
||||||
|
import org.jsoup.helper.StringUtil;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -10,22 +13,27 @@ import android.preference.PreferenceManager;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.google.ads.AdRequest;
|
import com.google.ads.AdRequest;
|
||||||
import com.google.ads.AdView;
|
import com.google.ads.AdView;
|
||||||
|
|
||||||
public class ArticleFragment extends Fragment {
|
public class ArticleFragment extends Fragment implements OnClickListener {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
private SharedPreferences m_prefs;
|
private SharedPreferences m_prefs;
|
||||||
private Article m_article;
|
private Article m_article;
|
||||||
private ArticleOps m_articleOps;
|
private ArticleOps m_articleOps;
|
||||||
|
private Article m_nextArticle;
|
||||||
|
private Article m_prevArticle;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
@ -35,6 +43,26 @@ public class ArticleFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.article_fragment, container, false);
|
View view = inflater.inflate(R.layout.article_fragment, container, false);
|
||||||
|
|
||||||
|
// TODO change to interface?
|
||||||
|
MainActivity activity = (MainActivity)getActivity();
|
||||||
|
|
||||||
|
if (activity != null) {
|
||||||
|
int orientation = activity.getWindowManager().getDefaultDisplay().getOrientation();
|
||||||
|
|
||||||
|
if (!activity.isSmallScreen()) {
|
||||||
|
if (orientation % 2 == 0) {
|
||||||
|
view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_article != null) {
|
if (m_article != null) {
|
||||||
|
|
||||||
@ -56,6 +84,7 @@ public class ArticleFragment extends Fragment {
|
|||||||
String cssOverride = "";
|
String cssOverride = "";
|
||||||
|
|
||||||
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
|
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
|
||||||
|
web.setBackgroundColor(android.R.color.black);
|
||||||
cssOverride = "body { background : black; color : #f0f0f0}\n";
|
cssOverride = "body { background : black; color : #f0f0f0}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,11 +116,21 @@ public class ArticleFragment extends Fragment {
|
|||||||
dv.setText(df.format(d));
|
dv.setText(df.format(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView cv = (TextView)view.findViewById(R.id.comments);
|
TextView tagv = (TextView)view.findViewById(R.id.tags);
|
||||||
|
|
||||||
// comments are not currently returned by the API
|
if (tagv != null) {
|
||||||
if (cv != null) {
|
if (m_article.tags != null) {
|
||||||
cv.setVisibility(View.GONE);
|
String tagsStr = "";
|
||||||
|
|
||||||
|
for (String tag : m_article.tags)
|
||||||
|
tagsStr += tag + ", ";
|
||||||
|
|
||||||
|
tagsStr = tagsStr.replaceAll(", $", "");
|
||||||
|
|
||||||
|
tagv.setText(tagsStr);
|
||||||
|
} else {
|
||||||
|
tagv.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdView av = (AdView)view.findViewById(R.id.ad);
|
AdView av = (AdView)view.findViewById(R.id.ad);
|
||||||
@ -106,6 +145,27 @@ public class ArticleFragment extends Fragment {
|
|||||||
av.setVisibility(View.GONE);
|
av.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageView next = (ImageView)view.findViewById(R.id.next_article);
|
||||||
|
|
||||||
|
if (next != null) {
|
||||||
|
if (m_nextArticle != null) {
|
||||||
|
next.setOnClickListener(this);
|
||||||
|
} else {
|
||||||
|
next.setImageResource(R.drawable.ic_next_article_disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageView prev = (ImageView)view.findViewById(R.id.prev_article);
|
||||||
|
|
||||||
|
if (prev != null) {
|
||||||
|
if (m_prevArticle != null) {
|
||||||
|
prev.setOnClickListener(this);
|
||||||
|
} else {
|
||||||
|
prev.setImageResource(R.drawable.ic_prev_article_disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
@ -130,6 +190,17 @@ public class ArticleFragment extends Fragment {
|
|||||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||||
m_articleOps = (ArticleOps)activity;
|
m_articleOps = (ArticleOps)activity;
|
||||||
m_article = m_articleOps.getSelectedArticle();
|
m_article = m_articleOps.getSelectedArticle();
|
||||||
|
|
||||||
|
m_prevArticle = m_articleOps.getRelativeArticle(m_article, RelativeArticle.BEFORE);
|
||||||
|
m_nextArticle = m_articleOps.getRelativeArticle(m_article, RelativeArticle.AFTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v.getId() == R.id.next_article) {
|
||||||
|
m_articleOps.openArticle(m_nextArticle, 0);
|
||||||
|
} else if (v.getId() == R.id.prev_article) {
|
||||||
|
m_articleOps.openArticle(m_prevArticle, R.anim.slide_right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package org.fox.ttrss;
|
package org.fox.ttrss;
|
||||||
|
|
||||||
public interface ArticleOps {
|
public interface ArticleOps {
|
||||||
|
public enum RelativeArticle { BEFORE, AFTER };
|
||||||
|
|
||||||
public Article getSelectedArticle();
|
public Article getSelectedArticle();
|
||||||
public void saveArticleUnread(final Article article);
|
public void saveArticleUnread(final Article article);
|
||||||
public void saveArticleMarked(final Article article);
|
public void saveArticleMarked(final Article article);
|
||||||
public void saveArticlePublished(final Article article);
|
public void saveArticlePublished(final Article article);
|
||||||
public void onArticleOpened(Article article);
|
|
||||||
public void updateHeadlines();
|
public void updateHeadlines();
|
||||||
|
public void openArticle(Article article, int compatAnimation);
|
||||||
|
public Article getRelativeArticle(Article article, RelativeArticle ra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,13 +93,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
|
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
Article article = (Article)list.getItemAtPosition(position);
|
Article article = (Article)list.getItemAtPosition(position);
|
||||||
m_articleOps.onArticleOpened(article);
|
m_articleOps.openArticle(article, 0);
|
||||||
|
|
||||||
if (article.unread) {
|
|
||||||
article.unread = false;
|
|
||||||
m_articleOps.saveArticleUnread(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_activeArticleId = article.id;
|
m_activeArticleId = article.id;
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
@ -380,4 +375,20 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArticleList getAllArticles() {
|
||||||
|
return m_articles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveArticleId(int id) {
|
||||||
|
m_activeArticleId = id;
|
||||||
|
m_adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
ListView list = (ListView)getView().findViewById(R.id.headlines);
|
||||||
|
|
||||||
|
if (list != null) {
|
||||||
|
int position = m_adapter.getPosition(m_articleOps.getSelectedArticle());
|
||||||
|
list.setSelection(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,10 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
|
|
||||||
|
public boolean isSmallScreen() {
|
||||||
|
return m_smallScreenMode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
m_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
@ -627,10 +631,21 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openArticle(Article article) {
|
public void openArticle(Article article, int compatAnimation) {
|
||||||
m_selectedArticle = article;
|
m_selectedArticle = article;
|
||||||
|
|
||||||
|
if (article.unread) {
|
||||||
|
article.unread = false;
|
||||||
|
saveArticleUnread(article);
|
||||||
|
}
|
||||||
|
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
|
|
||||||
|
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
||||||
|
|
||||||
|
if (hf != null) {
|
||||||
|
hf.setActiveArticleId(article.id);
|
||||||
|
}
|
||||||
|
|
||||||
ArticleFragment frag = new ArticleFragment();
|
ArticleFragment frag = new ArticleFragment();
|
||||||
|
|
||||||
@ -639,7 +654,10 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
if (m_compatMode) {
|
if (m_compatMode) {
|
||||||
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
|
if (compatAnimation == 0)
|
||||||
|
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
|
||||||
|
else
|
||||||
|
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, compatAnimation));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_smallScreenMode) {
|
if (m_smallScreenMode) {
|
||||||
@ -652,11 +670,6 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArticleOpened(Article article) {
|
|
||||||
openArticle(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Feed getActiveFeed() {
|
public Feed getActiveFeed() {
|
||||||
return m_activeFeed;
|
return m_activeFeed;
|
||||||
}
|
}
|
||||||
@ -714,4 +727,32 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
setLoadingStatus(R.string.login_in_progress, true);
|
setLoadingStatus(R.string.login_in_progress, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Article getRelativeArticle(Article article, RelativeArticle ra) {
|
||||||
|
HeadlinesFragment frag = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
||||||
|
if (frag != null) {
|
||||||
|
ArticleList articles = frag.getAllArticles();
|
||||||
|
for (int i = 0; i < articles.size(); i++) {
|
||||||
|
Article a = articles.get(i);
|
||||||
|
|
||||||
|
if (a.id == article.id) {
|
||||||
|
if (ra == RelativeArticle.AFTER) {
|
||||||
|
try {
|
||||||
|
return articles.get(i+1);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return articles.get(i-1);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user