implement displaying articlefragment
This commit is contained in:
parent
fd99cbdd0c
commit
acd2786961
@ -2,9 +2,9 @@
|
||||
|
||||
<set>
|
||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:propertyName="x"
|
||||
android:propertyName="width"
|
||||
android:duration="500"
|
||||
android:valueFrom="-400"
|
||||
android:valueFrom="400"
|
||||
android:valueTo="0"
|
||||
android:valueType="intType"/>
|
||||
</set>
|
||||
|
11
res/anim/slide_out_right.xml
Normal file
11
res/anim/slide_out_right.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set>
|
||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:propertyName="x"
|
||||
android:duration="500"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="-400"
|
||||
android:valueType="intType"/>
|
||||
</set>
|
||||
|
@ -1,20 +1,20 @@
|
||||
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:id="@+id/main_flipper">
|
||||
<FrameLayout android:layout_gravity="center_vertical" android:layout_width="match_parent" android:id="@+id/sync_splash" android:layout_height="match_parent">
|
||||
<LinearLayout android:id="@+id/linearLayout1" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
|
||||
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:text="@string/loading_message" android:layout_height="wrap_content"></TextView>
|
||||
<FrameLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_gravity="center_vertical" android:id="@+id/sync_splash">
|
||||
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/linearLayout1" android:gravity="center">
|
||||
<ProgressBar android:id="@+id/loading_progress" style="?android:attr/progressBarStyleLarge" android:layout_height="wrap_content" android:layout_width="wrap_content"></ProgressBar>
|
||||
<TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:text="@string/loading_message" android:id="@+id/loading_message"></TextView>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<LinearLayout android:id="@+id/main" android:layout_width="fill_parent" android:orientation="horizontal" android:layout_height="fill_parent">
|
||||
<fragment android:id="@+id/feeds_fragment" android:name="org.fox.ttrss.FeedsFragment" android:layout_height="match_parent" android:layout_width="300dp">
|
||||
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/main" android:orientation="horizontal">
|
||||
<fragment android:layout_weight="0" android:id="@+id/feeds_fragment" android:layout_height="match_parent" android:layout_width="300dp" android:name="org.fox.ttrss.FeedsFragment">
|
||||
<!-- Preview: layout=@layout/feeds_fragment -->
|
||||
</fragment>
|
||||
<fragment android:id="@+id/headlines_fragment" android:name="org.fox.ttrss.HeadlinesFragment" android:layout_height="match_parent" android:layout_width="wrap_content">
|
||||
<fragment android:layout_weight="1" android:id="@+id/headlines_fragment" android:layout_height="match_parent" android:layout_width="wrap_content" android:name="org.fox.ttrss.HeadlinesFragment">
|
||||
<!-- Preview: layout=@layout/headlines_fragment -->
|
||||
</fragment>
|
||||
<fragment android:id="@+id/article_fragment" android:name="org.fox.ttrss.ArticleFragment" android:layout_height="match_parent" android:layout_width="wrap_content">
|
||||
<fragment android:layout_weight="0" android:id="@+id/article_fragment" android:layout_height="match_parent" android:name="org.fox.ttrss.ArticleFragment" android:layout_width="500dp">
|
||||
<!-- Preview: layout=@layout/article_fragment -->
|
||||
</fragment>
|
||||
</LinearLayout>
|
||||
|
@ -21,12 +21,15 @@ public class ArticleFragment extends Fragment {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
|
||||
protected SharedPreferences m_prefs;
|
||||
protected int m_articleId;
|
||||
|
||||
private int m_articleId;
|
||||
private String m_sessionId;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
m_sessionId = savedInstanceState.getString("sessionId");
|
||||
m_articleId = savedInstanceState.getInt("articleId");
|
||||
}
|
||||
|
||||
@ -35,8 +38,12 @@ public class ArticleFragment extends Fragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void initialize(int articleId) {
|
||||
public void initialize(String sessionId, int articleId, SharedPreferences prefs) {
|
||||
m_articleId = articleId;
|
||||
m_prefs = prefs;
|
||||
m_sessionId = sessionId;
|
||||
|
||||
Log.d(TAG, "Article: " + articleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,6 +55,7 @@ public class ArticleFragment extends Fragment {
|
||||
public void onSaveInstanceState (Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putString("sessionId", m_sessionId);
|
||||
out.putInt("articleId", m_articleId);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.jsoup.Jsoup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
@ -34,6 +35,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
||||
|
||||
private String m_sessionId;
|
||||
private int m_feedId;
|
||||
private int m_activeArticleId;
|
||||
|
||||
private ArticleListAdapter m_adapter;
|
||||
private List<Article> m_articles = new ArrayList<Article>();
|
||||
@ -44,6 +46,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
||||
if (savedInstanceState != null) {
|
||||
m_sessionId = savedInstanceState.getString("sessionId");
|
||||
m_feedId = savedInstanceState.getInt("feedId");
|
||||
m_activeArticleId = savedInstanceState.getInt("activeArticleId");
|
||||
}
|
||||
|
||||
View view = inflater.inflate(R.layout.headlines_fragment, container, false);
|
||||
@ -76,9 +79,32 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> av, View view, int position, long id) {
|
||||
|
||||
ListView list = (ListView)av;
|
||||
|
||||
if (list != null) {
|
||||
Article article = (Article)list.getItemAtPosition(position);
|
||||
|
||||
viewArticle(article.id);
|
||||
}
|
||||
}
|
||||
|
||||
public void viewArticle(int articleId) {
|
||||
ArticleFragment frag = new ArticleFragment();
|
||||
frag.initialize(m_sessionId, articleId, m_prefs);
|
||||
|
||||
if (frag != null) {
|
||||
m_activeArticleId = articleId;
|
||||
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
|
||||
ft.show(getFragmentManager().findFragmentById(R.id.article_fragment));
|
||||
//ft.hide(getFragmentManager().findFragmentById(R.id.feeds_fragment));
|
||||
ft.replace(R.id.article_fragment, frag);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void initialize(String sessionId, int feedId, SharedPreferences prefs) {
|
||||
m_sessionId = sessionId;
|
||||
m_feedId = feedId;
|
||||
@ -112,6 +138,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
||||
|
||||
out.putString("sessionId", m_sessionId);
|
||||
out.putInt("feedId", m_feedId);
|
||||
out.putInt("activeArticleId", m_activeArticleId);
|
||||
}
|
||||
|
||||
private class HeadlinesRequest extends ApiRequest {
|
||||
|
Loading…
Reference in New Issue
Block a user