diff --git a/android/res/layout/article_album_element.xml b/android/res/layout/article_album_element.xml
new file mode 100644
index 0000000..39bf573
--- /dev/null
+++ b/android/res/layout/article_album_element.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
diff --git a/android/res/layout/article_album_element_item.xml b/android/res/layout/article_album_element_item.xml
new file mode 100644
index 0000000..1730d6c
--- /dev/null
+++ b/android/res/layout/article_album_element_item.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
diff --git a/android/res/layout/article_button_element.xml b/android/res/layout/article_button_element.xml
new file mode 100644
index 0000000..b4c36f5
--- /dev/null
+++ b/android/res/layout/article_button_element.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/android/res/layout/article_geotag_element.xml b/android/res/layout/article_geotag_element.xml
new file mode 100644
index 0000000..1cc053c
--- /dev/null
+++ b/android/res/layout/article_geotag_element.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
diff --git a/android/res/layout/article_photo_element.xml b/android/res/layout/article_photo_element.xml
new file mode 100644
index 0000000..1730d6c
--- /dev/null
+++ b/android/res/layout/article_photo_element.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
diff --git a/android/res/layout/article_text_element.xml b/android/res/layout/article_text_element.xml
new file mode 100644
index 0000000..2cc7622
--- /dev/null
+++ b/android/res/layout/article_text_element.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/android/res/layout/button_hview_list_element.xml b/android/res/layout/button_hview_list_element.xml
index ca1de54..7e45ff1 100644
--- a/android/res/layout/button_hview_list_element.xml
+++ b/android/res/layout/button_hview_list_element.xml
@@ -20,7 +20,7 @@
android:scaleType="fitXY" />
diff --git a/android/res/layout/darken_hview_list_element.xml b/android/res/layout/darken_hview_list_element.xml
index d3654b0..745afe8 100644
--- a/android/res/layout/darken_hview_list_element.xml
+++ b/android/res/layout/darken_hview_list_element.xml
@@ -8,7 +8,7 @@
android:showDividers="middle" >
+
+
+
+
+
+
diff --git a/android/res/layout/journal_element.xml b/android/res/layout/journal_element.xml
new file mode 100644
index 0000000..7b01bf7
--- /dev/null
+++ b/android/res/layout/journal_element.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/res/layout/link_content_page_list_element.xml b/android/res/layout/link_content_page_list_element.xml
index 1b17f10..a9b4b42 100644
--- a/android/res/layout/link_content_page_list_element.xml
+++ b/android/res/layout/link_content_page_list_element.xml
@@ -16,7 +16,7 @@
android:layout_height="wrap_content" />
diff --git a/android/res/layout/main_page_list_element.xml b/android/res/layout/main_page_list_element.xml
index 736abd8..c56db76 100644
--- a/android/res/layout/main_page_list_element.xml
+++ b/android/res/layout/main_page_list_element.xml
@@ -15,7 +15,7 @@
android:gravity="top" >
diff --git a/android/res/layout/news_page_list_header.xml b/android/res/layout/news_page_list_header.xml
index fcaaa85..2fe29b5 100644
--- a/android/res/layout/news_page_list_header.xml
+++ b/android/res/layout/news_page_list_header.xml
@@ -9,7 +9,7 @@
tools:context="fishrungames.bashgid.MainPageFragment" >
diff --git a/android/res/layout/search_page_list_element.xml b/android/res/layout/search_page_list_element.xml
index 2a7e4e8..75d08b6 100644
--- a/android/res/layout/search_page_list_element.xml
+++ b/android/res/layout/search_page_list_element.xml
@@ -35,7 +35,7 @@
android:textColor="@color/text_grey" />
diff --git a/android/res/layout/simple_hview_list_element.xml b/android/res/layout/simple_hview_list_element.xml
index 5f84423..ee2bb30 100644
--- a/android/res/layout/simple_hview_list_element.xml
+++ b/android/res/layout/simple_hview_list_element.xml
@@ -18,7 +18,7 @@
android:scaleType="centerCrop" />
articleLayout = new ArrayList();
+
+ public ArticleFragment()
+ {
+ articleName = "";
+ article = null;
+ }
+
+ public ArticleFragment(String articleName)
+ {
+ this.articleName = articleName;
+ RestoreArticle();
+ }
+
+ @Override
+ public void onSaveInstanceState(final Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString("articleName", articleName);
+ }
+
+ public void RestoreArticle()
+ {
+ article = MainActivity.getInstance().articleDataSource.GetArticleFullData(articleName);
+
+ articleLayout.clear();
+
+ articleLayout.add(new ArticleLayoutElement(0, article.title));
+
+ PhotoRecordData zeroPhoto = null;
+
+ if (article.albumArr.size() > 0)
+ {
+ if (article.albumArr.get(0).photoRecordArr.size() > 0)
+ {
+ zeroPhoto = article.albumArr.get(0).photoRecordArr.get(0);
+ }
+
+ }
+
+ if (zeroPhoto != null)
+ {
+ articleLayout.add(new ArticleLayoutElement(2, zeroPhoto.imageUrl));
+ }
+
+
+
+ articleLayout.add(new ArticleLayoutElement(1, article.content));
+
+ if (article.geoLat != 0 && article.geoLon != 0)
+ {
+ articleLayout.add(new ArticleLayoutElement(article.geoLat, article.geoLon));
+ }
+
+ for (int i = 0; i < article.albumArr.size(); i++)
+ {
+ articleLayout.add(new ArticleLayoutElement(i));
+ }
+
+ if (article.externalLink.length() > 0)
+ {
+ articleLayout.add(new ArticleLayoutElement(5, article.externalLink));
+ }
+
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+ if (savedInstanceState != null) {
+ articleName = savedInstanceState.getString("articleName");
+ RestoreArticle();
+ }
+
+ View rootView = inflater.inflate(R.layout.fragment_article_page, container, false);
+
+ listView = (ListView) rootView.findViewById(R.id.listView);
+
+ listAdapter = new ListAdapter(getActivity());
+
+ listView.setAdapter(listAdapter);
+
+ return rootView;
+ }
+
+ public class ListAdapter extends BaseAdapter {
+ private Context mContext;
+
+ public ListAdapter(Context c) {
+ mContext = c;
+ }
+
+ public int getCount() {
+ return articleLayout.size();
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public int getViewTypeCount()
+ {
+ return 6;
+ }
+
+ @Override
+ public int getItemViewType(int position)
+ {
+ return articleLayout.get(position).type;
+
+ }
+
+
+ // create a new ImageView for each item referenced by the Adapter
+ @SuppressLint("InflateParams")
+ public View getView(final int position, View convertView, ViewGroup parent) {
+
+
+ View view;
+ if (convertView == null) { // if it's not recycled, initialize some attributes
+ if (getItemViewType(position) == 0 || getItemViewType(position) == 1)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_text_element, null);
+ }
+ else if (getItemViewType(position) == 2)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_photo_element, null);
+ }
+ else if (getItemViewType(position) == 3)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_geotag_element, null);
+ }
+ else if (getItemViewType(position) == 4)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_album_element, null);
+ }
+ else //if (getItemViewType(position) == 5)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_button_element, null);
+ }
+ } else {
+ view = convertView;
+ }
+
+
+ if (getItemViewType(position) == 0)
+ {
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ textView.setText(articleLayout.get(position).value);
+
+ }
+ else if (getItemViewType(position) == 1)
+ {
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ textView.setText(articleLayout.get(position).value);
+
+ }
+ else if (getItemViewType(position) == 2)
+ {
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ PhotoRecordData photo = MainActivity.getInstance().photoDataSource.GetPhotoByImageUrl(articleLayout.get(position).value);
+
+ ImageManager.getInstance().ApplyImageToImageView(imageView, photo.imageUrl);
+
+ textView.setText(photo.title);
+ }
+ else if (getItemViewType(position) == 3)
+ {
+ //TextView textView = (TextView) view.findViewById(R.id.textView);
+
+ //textView.setText(articleLayout.get(position).value);
+
+ }
+ else if (getItemViewType(position) == 4)
+ {
+ //TextView textView = (TextView) view.findViewById(R.id.textView);
+
+ //textView.setText(articleLayout.get(position).value);
+
+ HListView hListView = (HListView) view.findViewById(R.id.hListView);
+
+ hListView.setAdapter(new MainPageHListViewAdapters.PhotoAlbumElementAdapter(getActivity(), article.albumArr.get(articleLayout.get(position).albumPos)));
+
+ }
+ else if (getItemViewType(position) == 5)
+ {
+ Button button = (Button) view.findViewById(R.id.button);
+
+ button.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(articleLayout.get(position).value));
+ startActivity(i);
+ }
+ });
+ }
+
+
+
+ return view;
+ }
+
+ }
+}
diff --git a/android/src/fishrungames/bashgid/JournalFragment.java b/android/src/fishrungames/bashgid/JournalFragment.java
new file mode 100644
index 0000000..40b6205
--- /dev/null
+++ b/android/src/fishrungames/bashgid/JournalFragment.java
@@ -0,0 +1,141 @@
+package fishrungames.bashgid;
+
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import android.widget.BaseAdapter;
+
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import fishrungames.bashgid.core.AlbumManager;
+import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
+import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
+import fishrungames.networkutils.ImageManager;
+
+public class JournalFragment extends Fragment
+{
+
+ JournalSemiFullData journal;
+ String journalName;
+
+ ListAdapter listAdapter;
+
+ public JournalFragment()
+ {
+ journal = null;
+ journalName = "";
+ }
+
+ public JournalFragment(String journalName)
+ {
+ this.journalName = journalName;
+ RestoreJournal();
+ }
+
+ @Override
+ public void onSaveInstanceState(final Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString("journalName", journalName);
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+ if (savedInstanceState != null) {
+ journalName = savedInstanceState.getString("journalName");
+ RestoreJournal();
+ }
+
+ View rootView = inflater.inflate(R.layout.fragment_photo_album_page, container, false);
+
+ listAdapter = new ListAdapter(getActivity());
+
+ ListView listView = (ListView) rootView.findViewById(R.id.listView);
+
+ listView.setAdapter(listAdapter);
+
+ listView.setOnItemClickListener(new OnItemClickListener(){
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
+ }
+
+ });
+
+ return rootView;
+ }
+
+ void RestoreJournal()
+ {
+ journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData(journalName);
+ }
+
+ public class ListAdapter extends BaseAdapter {
+ private Context mContext;
+
+ public ListAdapter(Context c) {
+ mContext = c;
+ }
+
+ public int getCount() {
+ return journal.articleArr.size();
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ // create a new ImageView for each item referenced by the Adapter
+ @SuppressLint("InflateParams")
+ public View getView(int position, View convertView, ViewGroup parent) {
+
+
+ View view;
+ if (convertView == null) { // if it's not recycled, initialize some attributes
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.journal_element, null);
+
+
+ } else {
+ view = convertView;
+ }
+
+ TextView titleTextView = (TextView)view.findViewById(R.id.titleTextView);
+
+ titleTextView.setText(journal.articleArr.get(position).title);
+
+ TextView dateTextView = (TextView)view.findViewById(R.id.dateTextView);
+
+ dateTextView.setText(journal.articleArr.get(position).dateTime.toString());
+
+ if (journal.previewImageArr.get(position) != null)
+ {
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ ImageManager.getInstance().ApplyImageToImageView(imageView, journal.previewImageArr.get(position));
+
+ }
+ return view;
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/android/src/fishrungames/bashgid/LinkContentFragment.java b/android/src/fishrungames/bashgid/LinkContentFragment.java
index 2814c64..38a857b 100644
--- a/android/src/fishrungames/bashgid/LinkContentFragment.java
+++ b/android/src/fishrungames/bashgid/LinkContentFragment.java
@@ -103,7 +103,7 @@ public class LinkContentFragment extends Fragment {
Button button = (Button) view.findViewById(R.id.button);
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
imageView.setVisibility(View.GONE);
button.setVisibility(View.GONE);
diff --git a/android/src/fishrungames/bashgid/MainActivity.java b/android/src/fishrungames/bashgid/MainActivity.java
index 45d7783..433d5a7 100644
--- a/android/src/fishrungames/bashgid/MainActivity.java
+++ b/android/src/fishrungames/bashgid/MainActivity.java
@@ -208,13 +208,13 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
0,
"Photos",
"Wow 2 photos",
- 0,
- 0,
- "",
+ 50,
+ 50,
+ "http://www.yandex.ru/",
articleTestDate
));
- //articleDataSource.AddAlbumToArticle("TEST", "TESTART");
+ articleDataSource.AddAlbumToArticle("TEST", "TESTART");
AlbumManager.AddExistingArticleToJournal("TESTART", "news");
@@ -412,6 +412,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public void OpenNewsScreen()
{
+
ClearAllFragmentLinks();
newsListFragment = new NewsListFragment();
@@ -420,7 +421,18 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
mNavigationDrawerFragment.EnableDrawer();
- //StartDownloadNewsTask();
+ }
+
+ public void OpenJournalScreen(String journalName)
+ {
+
+ ClearAllFragmentLinks();
+
+ JournalFragment journal = new JournalFragment(journalName);
+
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, journal).commit();
+
+ mNavigationDrawerFragment.EnableDrawer();
}
public void OpenSettingsScreen()
@@ -514,6 +526,18 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, newsRecordFragment, tag).commit();
+ mNavigationDrawerFragment.EnableDrawer();
+
+ }
+ public void OpenArticleScreen(String articleName, String tag)
+ {
+
+ ClearAllFragmentLinks();
+
+ ArticleFragment articleFragment = new ArticleFragment(articleName);
+
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, articleFragment, tag).commit();
+
mNavigationDrawerFragment.EnableDrawer();
}
diff --git a/android/src/fishrungames/bashgid/MainPageFragment.java b/android/src/fishrungames/bashgid/MainPageFragment.java
index 2aa8a4b..8a52167 100644
--- a/android/src/fishrungames/bashgid/MainPageFragment.java
+++ b/android/src/fishrungames/bashgid/MainPageFragment.java
@@ -175,7 +175,7 @@ public class MainPageFragment extends Fragment {
view = convertView;
}
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
Button button = (Button) view.findViewById(R.id.button);
diff --git a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
index 09232ce..210668e 100644
--- a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
+++ b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
@@ -2,6 +2,7 @@ package fishrungames.bashgid;
import java.util.ArrayList;
+import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.HtmlDownloadManager;
import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
@@ -14,12 +15,75 @@ import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class MainPageHListViewAdapters {
+
+ public static class PhotoAlbumElementAdapter extends BaseAdapter {
+
+ private Context mContext;
+ //String albumName;
+ AlbumFullData albumFullData;
+ //ArrayList localHtmlList;
+
+ public PhotoAlbumElementAdapter(Context c, AlbumFullData albumFullData) {
+ this.mContext = c;
+ this.albumFullData = albumFullData;
+
+ //localHtmlList = HtmlDownloadManager.getInstance().getGlobalHtmlList();
+ }
+
+ public int getCount() {
+ return albumFullData.photoRecordArr.size();
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ // create a new ImageView for each item referenced by the Adapter
+ @SuppressLint("InflateParams")
+ public View getView(int position, View convertView, ViewGroup parent) {
+
+
+ View view;
+ if (convertView == null) { // if it's not recycled, initialize some attributes
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_album_element_item, null);
+
+
+ } else {
+ view = convertView;
+ }
+
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ //TextView subTextView = (TextView) view.findViewById(R.id.subTextView);
+
+ //ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ textView.setText(albumFullData.photoRecordArr.get(position).title);
+
+ //subTextView.setText("");
+
+ ImageManager.getInstance().ApplyImageToImageView(imageView, albumFullData.photoRecordArr.get(position).imageUrl);
+
+ //imageButton.setOnClickListener(new ContentButtonOnClickListener(localHtmlList.get(position)));
+
+ return view;
+ }
+
+ }
+
public static class SimpleElementAdapter extends BaseAdapter {
private Context mContext;
@@ -58,13 +122,12 @@ public class MainPageHListViewAdapters {
view = convertView;
}
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
TextView subTextView = (TextView) view.findViewById(R.id.subTextView);
ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
-
textView.setText(localHtmlList.get(position).title);
subTextView.setText("");
@@ -122,7 +185,7 @@ public static class DarkenElementAdapter extends BaseAdapter {
view = convertView;
}
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
TextView subTextView = (TextView) view.findViewById(R.id.subTextView);
diff --git a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
index 832971e..7fc7681 100644
--- a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
+++ b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
@@ -372,7 +372,7 @@ public class NavigationDrawerFragment extends Fragment {
view = convertView;
}
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
textView.setText(titles[position]);
diff --git a/android/src/fishrungames/bashgid/NewsListFragment.java b/android/src/fishrungames/bashgid/NewsListFragment.java
index 4d4331b..1e77eb6 100644
--- a/android/src/fishrungames/bashgid/NewsListFragment.java
+++ b/android/src/fishrungames/bashgid/NewsListFragment.java
@@ -1,12 +1,10 @@
package fishrungames.bashgid;
-import java.util.ArrayList;
import fishrungames.networkutils.ImageManager;
-import fishrungames.bashgid.core.NewsManager;
+import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import fishrungames.bashgid.core.NewsManager.NewsRecord;
-import fishrungames.bashgid.core.db.NewsDataSource;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
@@ -16,10 +14,12 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.ImageButton;
+
+import android.widget.AdapterView;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.AdapterView.OnItemClickListener;
public class NewsListFragment extends Fragment
@@ -29,13 +29,13 @@ public class NewsListFragment extends Fragment
ListAdapter listAdapter;
- ArrayList newsRecordArr;
+ JournalSemiFullData journal;
@SuppressLint("InflateParams") @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_news_page, container, false);
- newsRecordArr = NewsManager.getInstance().getNews();
+ journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData("news");
listView = (ListView) rootView.findViewById(R.id.listView);
@@ -46,6 +46,16 @@ public class NewsListFragment extends Fragment
View header = inflater.inflate(R.layout.news_page_list_header, null);
listView.addHeaderView(header);
+
+ listView.setOnItemClickListener(new OnItemClickListener(){
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
+ }
+
+ });
return rootView;
}
@@ -53,7 +63,8 @@ public class NewsListFragment extends Fragment
public void RefreshNewsList()
{
- newsRecordArr = NewsManager.getInstance().getNews();
+ journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData("news");
+
listAdapter.notifyDataSetChanged();
}
@@ -65,7 +76,7 @@ public class NewsListFragment extends Fragment
}
public int getCount() {
- return newsRecordArr.size();
+ return journal.articleArr.size();
}
public Object getItem(int position) {
@@ -84,29 +95,28 @@ public class NewsListFragment extends Fragment
View view;
if (convertView == null) { // if it's not recycled, initialize some attributes
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.news_page_list_element, null);
+ view = inflater.inflate(R.layout.journal_element, null);
} else {
view = convertView;
}
- ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
+ TextView titleTextView = (TextView)view.findViewById(R.id.titleTextView);
+
+ titleTextView.setText(journal.articleArr.get(position).title);
- Button button = (Button) view.findViewById(R.id.button);
+ TextView dateTextView = (TextView)view.findViewById(R.id.dateTextView);
+
+ dateTextView.setText(journal.articleArr.get(position).dateTime.toString());
+
+ if (journal.previewImageArr.get(position) != null)
+ {
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
- TextView textView = (TextView) view.findViewById(R.id.textView);
-
- ImageManager.getInstance().ApplyImageToImageView(imageButton, newsRecordArr.get(position).imageId);
-
- button.setText(newsRecordArr.get(position).title);
-
- textView.setText(NewsDataSource.iso8601Format.format(newsRecordArr.get(position).pubDate));
-
- button.setOnClickListener(new ButtonOnClickListener(newsRecordArr.get(position)));
-
- imageButton.setOnClickListener(new ButtonOnClickListener(newsRecordArr.get(position)));
+ ImageManager.getInstance().ApplyImageToImageView(imageView, journal.previewImageArr.get(position));
+ }
return view;
}
diff --git a/android/src/fishrungames/bashgid/SearchFragment.java b/android/src/fishrungames/bashgid/SearchFragment.java
index 0f799eb..4fd2b83 100644
--- a/android/src/fishrungames/bashgid/SearchFragment.java
+++ b/android/src/fishrungames/bashgid/SearchFragment.java
@@ -152,7 +152,7 @@ public class SearchFragment extends Fragment implements UpdateAndFinishCallbackI
Button button = (Button) view.findViewById(R.id.button);
- TextView textView = (TextView) view.findViewById(R.id.textView);
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
ImageManager.getInstance().ApplyImageToImageView(imageButton, searchResultArr.get(position).imageId);
diff --git a/android/src/fishrungames/bashgid/core/JournalManager.java b/android/src/fishrungames/bashgid/core/JournalManager.java
index fb74c13..aae2327 100644
--- a/android/src/fishrungames/bashgid/core/JournalManager.java
+++ b/android/src/fishrungames/bashgid/core/JournalManager.java
@@ -1,5 +1,10 @@
package fishrungames.bashgid.core;
+import java.util.ArrayList;
+
+import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
+import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
+
public class JournalManager
{
@@ -26,7 +31,20 @@ public class JournalManager
}
}
- //public static class Jo
+ public static class JournalSemiFullData extends JournalRecordData
+ {
+
+ public ArrayList articleArr;
+ public ArrayList previewImageArr;
+
+ public JournalSemiFullData(JournalRecordData copyFrom)
+ {
+ super(copyFrom);
+ articleArr = new ArrayList();
+ previewImageArr = new ArrayList();
+ }
+
+ }
public static class JournalRecord extends JournalRecordData
diff --git a/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java b/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java
index 283c287..fe650ec 100644
--- a/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java
@@ -387,7 +387,7 @@ public class ArticleDataSource
}
- private ArrayList innerGetAlbumNameArrInArticle(String name, SQLiteDatabase database)
+ public ArrayList innerGetAlbumNameArrInArticle(String name, SQLiteDatabase database)
{
ArrayList result = new ArrayList();
diff --git a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
index f940665..9a78f92 100644
--- a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
@@ -5,9 +5,12 @@ import java.util.Collections;
import fishrungames.bashgid.MainActivity;
+import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
+import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
import fishrungames.bashgid.core.JournalManager;
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
+import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import android.content.ContentValues;
import android.content.Context;
@@ -151,6 +154,77 @@ public class JournalDataSource
return result;
}
+
+ public JournalSemiFullData GetJournalSemiFullData(String name)
+ {
+ JournalSemiFullData result = null;
+
+ SQLiteDatabase database = dbHelper.getWritableDatabase();
+
+ if (database != null)
+ {
+ try
+ {
+
+ result = InnerGetJournalSemiFullData(name, database);
+
+ } finally
+ {
+ dbHelper.close();
+ }
+ }
+
+ return result;
+ }
+
+ public JournalSemiFullData InnerGetJournalSemiFullData(String name, SQLiteDatabase database)
+ {
+
+ JournalSemiFullData result = null;
+
+ JournalRecordData recordData = innerGetJournalByName(name, database);
+
+ if (recordData != null)
+ {
+
+ result = new JournalSemiFullData(recordData);
+
+ ArrayList articleArr = innerGetArticleArrInJournal(name, database);
+
+ for (String article : articleArr)
+ {
+ result.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
+
+ String imageUrl = null;
+
+ //Find first photo in first album (if exist)
+ ArrayList albumArr = MainActivity.getInstance().articleDataSource.innerGetAlbumNameArrInArticle(article, database);
+ if (albumArr.size() > 0)
+ {
+ AlbumFullData album = MainActivity.getInstance().albumDataSource.InnerGetAlbumFullData(albumArr.get(0), database);
+
+ if (album.photoRecordArr.size() > 0)
+ {
+ imageUrl = album.photoRecordArr.get(0).imageUrl;
+ }
+ }
+
+ result.previewImageArr.add(imageUrl);
+
+ }
+/*
+ ArrayList imageUrlArr = innerGetImageUrlArrInAlbum(name, database);
+
+ for (String imageUrl : imageUrlArr)
+ {
+ result.photoRecordArr.add(MainActivity.getInstance().photoDataSource.InnerGetPhotoByImageUrl(imageUrl, database));
+ }*/
+
+ }
+
+ return result;
+ }
+
private boolean innerIsJournalAlreadyExist(String name, SQLiteDatabase database)
{