major update

This commit is contained in:
Vladislav Khorev 2015-06-11 06:17:27 +00:00
parent 5fd5dd703b
commit d54aa3e2c1
31 changed files with 850 additions and 48 deletions

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/bkg1"
android:orientation="vertical"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:showDividers="middle" >
<it.sephiroth.android.library.widget.HListView
android:id="@+id/hListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</it.sephiroth.android.library.widget.HListView>
</LinearLayout>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Перейти на сайт..." />
</LinearLayout>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
tilesource="Mapnik" />
</LinearLayout>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<TextView
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>

View File

@ -20,7 +20,7 @@
android:scaleType="fitXY" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />

View File

@ -8,7 +8,7 @@
android:showDividers="middle" >
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"

View File

@ -16,7 +16,7 @@
android:contentDescription="@string/icon" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"

View File

@ -0,0 +1,22 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="@color/bkg2"
android:orientation="vertical"
tools:context="fishrungames.bashgid.MainPageFragment" >
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:divider="@drawable/transparent"
android:dividerHeight="18dp"
android:paddingBottom="16dp" >
</ListView>
</LinearLayout>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="horizontal"
android:showDividers="middle" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/titleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/dateTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp" />
</LinearLayout>

View File

@ -16,7 +16,7 @@
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View File

@ -15,7 +15,7 @@
android:gravity="top" >
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View File

@ -18,7 +18,7 @@
android:src="@drawable/bashgid_logo_main" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"

View File

@ -35,7 +35,7 @@
android:textColor="@color/text_grey" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View File

@ -9,7 +9,7 @@
tools:context="fishrungames.bashgid.MainPageFragment" >
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"

View File

@ -18,7 +18,7 @@
android:scaleType="fitXY" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />

View File

@ -35,7 +35,7 @@
android:textColor="@color/text_grey" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View File

@ -18,7 +18,7 @@
android:scaleType="centerCrop" />
<TextView
android:id="@+id/textView"
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"

View File

@ -0,0 +1,299 @@
package fishrungames.bashgid;
import it.sephiroth.android.library.widget.HListView;
import java.util.ArrayList;
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
import fishrungames.networkutils.ImageManager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ArticleFragment extends Fragment
{
public static class ArticleLayoutElement
{
public int type; //0 title; 1 text; 2 photo; 3 geotag; 4 photo_album; 5 button
public String value;
public double geoLat;
public double geoLon;
public int albumPos;
public ArticleLayoutElement(int type, String value)
{
this.type = type;
this.value = value;
this.geoLat = 0;
this.geoLon = 0;
this.albumPos = -1;
}
public ArticleLayoutElement(double geoLat, double geoLon)
{
this.type = 3;
this.value = "";
this.geoLat = geoLat;
this.geoLon = geoLon;
this.albumPos = -1;
}
public ArticleLayoutElement(int albumPos)
{
this.type = 4;
this.value = "";
this.geoLat = 0;
this.geoLon = 0;
this.albumPos = albumPos;
}
}
ListView listView;
ListAdapter listAdapter;
String articleName;
ArticleFullData article;
ArrayList<ArticleLayoutElement> articleLayout = new ArrayList<ArticleLayoutElement>();
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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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<TextFileRecord> 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);

View File

@ -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]);

View File

@ -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<NewsRecord> 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;
}

View File

@ -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);

View File

@ -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<ArticleRecordData> articleArr;
public ArrayList<String> previewImageArr;
public JournalSemiFullData(JournalRecordData copyFrom)
{
super(copyFrom);
articleArr = new ArrayList<ArticleRecordData>();
previewImageArr = new ArrayList<String>();
}
}
public static class JournalRecord extends JournalRecordData

View File

@ -387,7 +387,7 @@ public class ArticleDataSource
}
private ArrayList<String> innerGetAlbumNameArrInArticle(String name, SQLiteDatabase database)
public ArrayList<String> innerGetAlbumNameArrInArticle(String name, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();

View File

@ -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<String> 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<String> 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<String> 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)
{