diff --git a/android/assets/urllist.xml b/android/assets/urllist.xml
deleted file mode 100644
index d5f3de3..0000000
--- a/android/assets/urllist.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
- http://www.shulgan-tash.ru/about/
- http://www.shulgan-tash.ru
- shulgantash.html
- ST_DIV_CLASS
- post-content
- Шульганташ
- http://www.shulgan-tash.ru/wp-content/uploads/2013/07/MG_0164-FullHD.jpg
-
-
- http://www.bashnl.ru/o-biblioteke/
- http://www.bashnl.ru
- bashnl.html
- ST_ARTICLE
- article
- Библиотека имени Заки Валиди
- http://upload.wikimedia.org/wikipedia/commons/f/f6/Library_Zaki-Validi.jpg
-
-
- http://tv-rb.ru/o-kompanii/
- http://tv-rb.ru
- tv-rb.html
- ST_DIV_CLASS
- page-main-content
- БСТ - О компании
- http://tv-rb.ru/upload/medialibrary/4b6/4b6e96a91e32ed74ca239b0fca90d4a5.jpg
-
-
-
- http://skikandry.ru/index/recreation
- http://skikandry.ru
- skikandry.html
- ST_DIV_ID
- article
- Кандрыкуль
- http://skikandry.ru/assets/images/photo/kandry-kul.jpg
-
-
- http://www.iremel.net/
- http://www.iremel.net
- iremel.net.html
- ST_DIV_CLASS
- content-all
- Гора Иремель
- http://www.iremel.net/uploads/iremel/p1000694.jpg
-
-
- http://invest.bashkortostan.ru/pages/11
- http://invest.bashkortostan.ru
- invest.bashkortostan.html
- ST_DIV_CLASS
- page-content
- Преимущества Башкортостана
- http://invest.bashkortostan.ru/uploads/picture/picture/50/normal_republic.png
-
-
-
-
-
diff --git a/android/ic_launcher-web.png b/android/ic_launcher-web.png
index a18cbb4..3a3c3f6 100644
Binary files a/android/ic_launcher-web.png and b/android/ic_launcher-web.png differ
diff --git a/android/res/drawable-hdpi/logo.png b/android/res/drawable-hdpi/logo.png
new file mode 100644
index 0000000..cc5b583
Binary files /dev/null and b/android/res/drawable-hdpi/logo.png differ
diff --git a/android/res/drawable-ldpi/logo.png b/android/res/drawable-ldpi/logo.png
new file mode 100644
index 0000000..a28bd14
Binary files /dev/null and b/android/res/drawable-ldpi/logo.png differ
diff --git a/android/res/drawable-ldpi/see_more_small.png b/android/res/drawable-ldpi/see_more_small.png
new file mode 100644
index 0000000..c25b48f
Binary files /dev/null and b/android/res/drawable-ldpi/see_more_small.png differ
diff --git a/android/res/drawable-mdpi/logo.png b/android/res/drawable-mdpi/logo.png
new file mode 100644
index 0000000..a28bd14
Binary files /dev/null and b/android/res/drawable-mdpi/logo.png differ
diff --git a/android/res/drawable-mdpi/see_more_small.png b/android/res/drawable-mdpi/see_more_small.png
new file mode 100644
index 0000000..c25b48f
Binary files /dev/null and b/android/res/drawable-mdpi/see_more_small.png differ
diff --git a/android/res/drawable-xhdpi/logo.png b/android/res/drawable-xhdpi/logo.png
new file mode 100644
index 0000000..cc5b583
Binary files /dev/null and b/android/res/drawable-xhdpi/logo.png differ
diff --git a/android/res/drawable-xxhdpi/logo.png b/android/res/drawable-xxhdpi/logo.png
new file mode 100644
index 0000000..cc5b583
Binary files /dev/null and b/android/res/drawable-xxhdpi/logo.png differ
diff --git a/android/res/drawable/button_background.xml b/android/res/drawable/button_background.xml
deleted file mode 100644
index 33f3967..0000000
--- a/android/res/drawable/button_background.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/h_line.png b/android/res/drawable/h_line.png
deleted file mode 100644
index d56d99e..0000000
Binary files a/android/res/drawable/h_line.png and /dev/null differ
diff --git a/android/res/drawable/img_culture1.jpg b/android/res/drawable/img_culture1.jpg
deleted file mode 100644
index 4b72a3a..0000000
Binary files a/android/res/drawable/img_culture1.jpg and /dev/null differ
diff --git a/android/res/drawable/img_culture1_button.xml b/android/res/drawable/img_culture1_button.xml
deleted file mode 100644
index 2b7e551..0000000
--- a/android/res/drawable/img_culture1_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_culture1_highlighted.xml b/android/res/drawable/img_culture1_highlighted.xml
deleted file mode 100644
index 02edba6..0000000
--- a/android/res/drawable/img_culture1_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_culture2.jpg b/android/res/drawable/img_culture2.jpg
deleted file mode 100644
index ece8ddd..0000000
Binary files a/android/res/drawable/img_culture2.jpg and /dev/null differ
diff --git a/android/res/drawable/img_culture2_button.xml b/android/res/drawable/img_culture2_button.xml
deleted file mode 100644
index 77893ef..0000000
--- a/android/res/drawable/img_culture2_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_culture2_highlighted.xml b/android/res/drawable/img_culture2_highlighted.xml
deleted file mode 100644
index af065b8..0000000
--- a/android/res/drawable/img_culture2_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_culture3.jpg b/android/res/drawable/img_culture3.jpg
deleted file mode 100644
index f231ccc..0000000
Binary files a/android/res/drawable/img_culture3.jpg and /dev/null differ
diff --git a/android/res/drawable/img_culture3_button.xml b/android/res/drawable/img_culture3_button.xml
deleted file mode 100644
index b8cef8d..0000000
--- a/android/res/drawable/img_culture3_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_culture3_highlighted.xml b/android/res/drawable/img_culture3_highlighted.xml
deleted file mode 100644
index 81aecdf..0000000
--- a/android/res/drawable/img_culture3_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education1.jpg b/android/res/drawable/img_education1.jpg
deleted file mode 100644
index 2f58eee..0000000
Binary files a/android/res/drawable/img_education1.jpg and /dev/null differ
diff --git a/android/res/drawable/img_education1_button.xml b/android/res/drawable/img_education1_button.xml
deleted file mode 100644
index a98cbe8..0000000
--- a/android/res/drawable/img_education1_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education1_highlighted.xml b/android/res/drawable/img_education1_highlighted.xml
deleted file mode 100644
index 0689127..0000000
--- a/android/res/drawable/img_education1_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education2.jpg b/android/res/drawable/img_education2.jpg
deleted file mode 100644
index a4aeaad..0000000
Binary files a/android/res/drawable/img_education2.jpg and /dev/null differ
diff --git a/android/res/drawable/img_education2_button.xml b/android/res/drawable/img_education2_button.xml
deleted file mode 100644
index b991317..0000000
--- a/android/res/drawable/img_education2_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education2_highlighted.xml b/android/res/drawable/img_education2_highlighted.xml
deleted file mode 100644
index 2b0394c..0000000
--- a/android/res/drawable/img_education2_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education3.jpg b/android/res/drawable/img_education3.jpg
deleted file mode 100644
index bd3f7e1..0000000
Binary files a/android/res/drawable/img_education3.jpg and /dev/null differ
diff --git a/android/res/drawable/img_education3_button.xml b/android/res/drawable/img_education3_button.xml
deleted file mode 100644
index 59d17de..0000000
--- a/android/res/drawable/img_education3_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_education3_highlighted.xml b/android/res/drawable/img_education3_highlighted.xml
deleted file mode 100644
index 36410a8..0000000
--- a/android/res/drawable/img_education3_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor1.jpg b/android/res/drawable/img_for_investor1.jpg
deleted file mode 100644
index f5ff3d0..0000000
Binary files a/android/res/drawable/img_for_investor1.jpg and /dev/null differ
diff --git a/android/res/drawable/img_for_investor1_button.xml b/android/res/drawable/img_for_investor1_button.xml
deleted file mode 100644
index 90dc123..0000000
--- a/android/res/drawable/img_for_investor1_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor1_highlighted.xml b/android/res/drawable/img_for_investor1_highlighted.xml
deleted file mode 100644
index c891659..0000000
--- a/android/res/drawable/img_for_investor1_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor2.jpg b/android/res/drawable/img_for_investor2.jpg
deleted file mode 100644
index a274aba..0000000
Binary files a/android/res/drawable/img_for_investor2.jpg and /dev/null differ
diff --git a/android/res/drawable/img_for_investor2_button.xml b/android/res/drawable/img_for_investor2_button.xml
deleted file mode 100644
index 3ff3ac2..0000000
--- a/android/res/drawable/img_for_investor2_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor2_highlighted.xml b/android/res/drawable/img_for_investor2_highlighted.xml
deleted file mode 100644
index 96e896c..0000000
--- a/android/res/drawable/img_for_investor2_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor3.jpg b/android/res/drawable/img_for_investor3.jpg
deleted file mode 100644
index 63a1cea..0000000
Binary files a/android/res/drawable/img_for_investor3.jpg and /dev/null differ
diff --git a/android/res/drawable/img_for_investor3_button.xml b/android/res/drawable/img_for_investor3_button.xml
deleted file mode 100644
index 79dfd63..0000000
--- a/android/res/drawable/img_for_investor3_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor3_highlighted.xml b/android/res/drawable/img_for_investor3_highlighted.xml
deleted file mode 100644
index 9af62a9..0000000
--- a/android/res/drawable/img_for_investor3_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor4.jpg b/android/res/drawable/img_for_investor4.jpg
deleted file mode 100644
index 7d8c220..0000000
Binary files a/android/res/drawable/img_for_investor4.jpg and /dev/null differ
diff --git a/android/res/drawable/img_for_investor4_button.xml b/android/res/drawable/img_for_investor4_button.xml
deleted file mode 100644
index 2e6a80c..0000000
--- a/android/res/drawable/img_for_investor4_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_for_investor4_highlighted.xml b/android/res/drawable/img_for_investor4_highlighted.xml
deleted file mode 100644
index 9cf053a..0000000
--- a/android/res/drawable/img_for_investor4_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist1.jpg b/android/res/drawable/img_tourist1.jpg
deleted file mode 100644
index 0a140eb..0000000
Binary files a/android/res/drawable/img_tourist1.jpg and /dev/null differ
diff --git a/android/res/drawable/img_tourist1_button.xml b/android/res/drawable/img_tourist1_button.xml
deleted file mode 100644
index 4c6a9a0..0000000
--- a/android/res/drawable/img_tourist1_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist1_highlighted.xml b/android/res/drawable/img_tourist1_highlighted.xml
deleted file mode 100644
index 7d60da7..0000000
--- a/android/res/drawable/img_tourist1_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist2.jpg b/android/res/drawable/img_tourist2.jpg
deleted file mode 100644
index 4a65f2e..0000000
Binary files a/android/res/drawable/img_tourist2.jpg and /dev/null differ
diff --git a/android/res/drawable/img_tourist2_button.xml b/android/res/drawable/img_tourist2_button.xml
deleted file mode 100644
index e7c59b2..0000000
--- a/android/res/drawable/img_tourist2_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist2_highlighted.xml b/android/res/drawable/img_tourist2_highlighted.xml
deleted file mode 100644
index 7fb6f9d..0000000
--- a/android/res/drawable/img_tourist2_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist3.jpg b/android/res/drawable/img_tourist3.jpg
deleted file mode 100644
index 386127e..0000000
Binary files a/android/res/drawable/img_tourist3.jpg and /dev/null differ
diff --git a/android/res/drawable/img_tourist3_button.xml b/android/res/drawable/img_tourist3_button.xml
deleted file mode 100644
index 4c8146a..0000000
--- a/android/res/drawable/img_tourist3_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist3_highlighted.xml b/android/res/drawable/img_tourist3_highlighted.xml
deleted file mode 100644
index afe94cf..0000000
--- a/android/res/drawable/img_tourist3_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist4.jpg b/android/res/drawable/img_tourist4.jpg
deleted file mode 100644
index 5e67b8a..0000000
Binary files a/android/res/drawable/img_tourist4.jpg and /dev/null differ
diff --git a/android/res/drawable/img_tourist4_button.xml b/android/res/drawable/img_tourist4_button.xml
deleted file mode 100644
index af68c4c..0000000
--- a/android/res/drawable/img_tourist4_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/img_tourist4_highlighted.xml b/android/res/drawable/img_tourist4_highlighted.xml
deleted file mode 100644
index 6ec11e4..0000000
--- a/android/res/drawable/img_tourist4_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/logo.png b/android/res/drawable/logo.png
index cc5b583..a28bd14 100644
Binary files a/android/res/drawable/logo.png and b/android/res/drawable/logo.png differ
diff --git a/android/res/drawable/see_more.png b/android/res/drawable/see_more.png
deleted file mode 100644
index 3f228cf..0000000
Binary files a/android/res/drawable/see_more.png and /dev/null differ
diff --git a/android/res/drawable/see_more_button.xml b/android/res/drawable/see_more_button.xml
deleted file mode 100644
index 869c8b1..0000000
--- a/android/res/drawable/see_more_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/see_more_highlighted.xml b/android/res/drawable/see_more_highlighted.xml
deleted file mode 100644
index 9a889a7..0000000
--- a/android/res/drawable/see_more_highlighted.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/drawable/test_drawer_icon.png b/android/res/drawable/test_drawer_icon.png
deleted file mode 100644
index f17c614..0000000
Binary files a/android/res/drawable/test_drawer_icon.png and /dev/null differ
diff --git a/android/res/layout/books_page_list_element.xml b/android/res/layout/books_page_list_element.xml
deleted file mode 100644
index a1b45df..0000000
--- a/android/res/layout/books_page_list_element.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/button_hview_list_element.xml b/android/res/layout/button_hview_list_element.xml
deleted file mode 100644
index 7e45ff1..0000000
--- a/android/res/layout/button_hview_list_element.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/darken_hview_list_element.xml b/android/res/layout/darken_hview_list_element.xml
deleted file mode 100644
index 745afe8..0000000
--- a/android/res/layout/darken_hview_list_element.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_book_record_page.xml b/android/res/layout/fragment_book_record_page.xml
deleted file mode 100644
index 58b07d4..0000000
--- a/android/res/layout/fragment_book_record_page.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_books_page.xml b/android/res/layout/fragment_books_page.xml
deleted file mode 100644
index f1f7f0d..0000000
--- a/android/res/layout/fragment_books_page.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_html_viewer.xml b/android/res/layout/fragment_html_viewer.xml
deleted file mode 100644
index d5d40ab..0000000
--- a/android/res/layout/fragment_html_viewer.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
diff --git a/android/res/layout/fragment_link_content_page.xml b/android/res/layout/fragment_link_content_page.xml
deleted file mode 100644
index 5024376..0000000
--- a/android/res/layout/fragment_link_content_page.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_map_page.xml b/android/res/layout/fragment_map_page.xml
deleted file mode 100644
index 9fdb94a..0000000
--- a/android/res/layout/fragment_map_page.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_news_record_page.xml b/android/res/layout/fragment_news_record_page.xml
deleted file mode 100644
index 44d31d3..0000000
--- a/android/res/layout/fragment_news_record_page.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_streetview_page.xml b/android/res/layout/fragment_streetview_page.xml
deleted file mode 100644
index 4bfffcc..0000000
--- a/android/res/layout/fragment_streetview_page.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
diff --git a/android/res/layout/link_content_page_list_element.xml b/android/res/layout/link_content_page_list_element.xml
deleted file mode 100644
index a9b4b42..0000000
--- a/android/res/layout/link_content_page_list_element.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/layout/main_page_list_element.xml b/android/res/layout/main_page_list_element.xml
index 6bd0b7f..29dbb92 100644
--- a/android/res/layout/main_page_list_element.xml
+++ b/android/res/layout/main_page_list_element.xml
@@ -32,7 +32,7 @@
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="right"
+ android:layout_gravity="right|center_vertical"
android:layout_marginBottom="@dimen/medium_margin"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_marginTop="@dimen/medium_margin"
@@ -44,7 +44,7 @@
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="right"
+ android:layout_gravity="right|center_vertical"
android:layout_margin="@dimen/medium_margin"
android:background="@drawable/transparent"
android:src="@drawable/see_more_small" />
diff --git a/android/res/layout/news_list_element.xml b/android/res/layout/news_list_element.xml
deleted file mode 100644
index 69c4b74..0000000
--- a/android/res/layout/news_list_element.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/res/menu/main.xml b/android/res/menu/main.xml
deleted file mode 100644
index 510ec97..0000000
--- a/android/res/menu/main.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
diff --git a/android/res/values-w820dp/dimens.xml b/android/res/values-w820dp/dimens.xml
deleted file mode 100644
index f9f069f..0000000
--- a/android/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- 64dp
-
-
diff --git a/android/src/fishrungames/bashgid/AlbumListFragment.java b/android/src/fishrungames/bashgid/AlbumListFragment.java
index 2f0236b..3c8a268 100644
--- a/android/src/fishrungames/bashgid/AlbumListFragment.java
+++ b/android/src/fishrungames/bashgid/AlbumListFragment.java
@@ -1,13 +1,11 @@
package fishrungames.bashgid;
-
import java.util.ArrayList;
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
import fishrungames.networkutils.ImageManager;
-
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.AsyncTask;
@@ -27,7 +25,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
-
public class AlbumListFragment extends Fragment
{
@@ -36,27 +33,27 @@ public class AlbumListFragment extends Fragment
GridView gridView;
ArrayList albumArr;
-
+
ProgressBar progressBar;
-
+
public AlbumListFragment()
{
RestoreAlbumList();
}
-
+
public AlbumListFragment(ArrayList albumArr)
{
this.albumArr = albumArr;
}
-
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
View rootView = inflater.inflate(R.layout.fragment_video_page, container, false);
-
- progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
-
+
+ progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
+
progressBar.setVisibility(View.VISIBLE);
gridView = (GridView) rootView.findViewById(R.id.gridView);
@@ -78,40 +75,39 @@ public class AlbumListFragment extends Fragment
return rootView;
}
-
+
public void RestoreAlbumList()
{
albumArr = new ArrayList();
-
+
DatabaseGetAlbumListTask task = new DatabaseGetAlbumListTask();
task.mHandler = MainActivity.getInstance().mHandler;
task.execute();
}
-
+
public void SetAlbumList(ArrayList albumArr)
{
progressBar.setVisibility(View.GONE);
this.albumArr = albumArr;
-
+
listAdapter.notifyDataSetChanged();
}
-
-
+
public static class DatabaseGetAlbumListTask extends AsyncTask
{
ArrayList albumArr;
-
+
public Handler mHandler;
protected Long doInBackground(String... queryArr)
{
-
+
albumArr = MainActivity.getInstance().albumDataSource.GetAllAlbumShortDataExceptHidden();
-
+
return (long) 0;
}
@@ -131,43 +127,47 @@ public class AlbumListFragment extends Fragment
}
}
-
-
- public class ListAdapter extends BaseAdapter {
+ public class ListAdapter extends BaseAdapter
+ {
private Context mContext;
- public ListAdapter(Context c) {
+ public ListAdapter(Context c)
+ {
mContext = c;
}
- public int getCount() {
+ public int getCount()
+ {
return albumArr.size();
}
- public Object getItem(int position) {
+ public Object getItem(int position)
+ {
return null;
}
- public long getItemId(int position) {
+ 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) {
-
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
View view;
- if (convertView == null) { // if it's not recycled, initialize some attributes
+ 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.video_page_list_element, null);
-
- } else {
+ } else
+ {
view = convertView;
}
- ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
ImageManager.getInstance().ApplyImageToImageView(imageView, albumArr.get(position).firstImageUrl);
diff --git a/android/src/fishrungames/bashgid/ArticleFragment.java b/android/src/fishrungames/bashgid/ArticleFragment.java
index e1b2755..a0836b8 100644
--- a/android/src/fishrungames/bashgid/ArticleFragment.java
+++ b/android/src/fishrungames/bashgid/ArticleFragment.java
@@ -1,6 +1,5 @@
package fishrungames.bashgid;
-
import it.sephiroth.android.library.widget.AdapterView.OnItemClickListener;
import it.sephiroth.android.library.widget.HListView;
@@ -12,14 +11,11 @@ import org.osmdroid.api.IMapController;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
-import fishrungames.bashgid.OsmMapHolderFragment.CustomItemizedOverlay;
import fishrungames.bashgid.OsmMapHolderFragment.NoInteractionOverlay;
import fishrungames.bashgid.core.ArticleManager;
-import fishrungames.bashgid.core.DatabaseGetAlbumTask;
+
import fishrungames.bashgid.core.DatabaseGetArticleTask;
-import fishrungames.bashgid.core.LocationHolder;
-import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
-import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
+
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
import fishrungames.networkutils.ImageManager;
@@ -29,10 +25,9 @@ import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.net.Uri;
-import android.os.AsyncTask;
+
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
+
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -43,31 +38,28 @@ import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.AdapterView;
import android.widget.Button;
-import android.widget.EditText;
+
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-
-
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 6 phone
+ public int type; // 0 title; 1 text; 2 photo; 3 geotag; 4 photo_album; 5
+ // button 6 phone
public String value;
-
-
+
public double geoLat;
public double geoLon;
-
+
public int albumPos;
-
+
public ArticleLayoutElement(int type, String value)
{
this.type = type;
@@ -76,8 +68,7 @@ public class ArticleFragment extends Fragment
this.geoLon = 0;
this.albumPos = -1;
}
-
-
+
public ArticleLayoutElement(double geoLat, double geoLon)
{
this.type = 3;
@@ -86,7 +77,7 @@ public class ArticleFragment extends Fragment
this.geoLon = geoLon;
this.albumPos = -1;
}
-
+
public ArticleLayoutElement(int albumPos)
{
this.type = 4;
@@ -96,8 +87,9 @@ public class ArticleFragment extends Fragment
this.albumPos = albumPos;
}
}
-
- public class MapOverlay extends org.osmdroid.views.overlay.Overlay {
+
+ public class MapOverlay extends org.osmdroid.views.overlay.Overlay
+ {
public MapOverlay(Context ctx)
{
@@ -107,58 +99,59 @@ public class ArticleFragment extends Fragment
@Override
protected void draw(Canvas arg0, MapView arg1, boolean arg2)
{
-
+
}
-
+
@Override
- public boolean onTouchEvent(final MotionEvent event, final MapView mapView) {
+ public boolean onTouchEvent(final MotionEvent event, final MapView mapView)
+ {
+ MainActivity.getInstance().SetLastArticleName(articleName);
+
if (event.getAction() == MotionEvent.ACTION_UP)
{
- MainActivity.getInstance().OpenMapScreen(article);
+ MainActivity.getInstance().OpenMapScreen(article, MainActivity.TAG_BACK_TO_ARTICLEFRAGMENT);
}
- return true;
- }
+ return true;
+ }
-
}
-
-
-
+
ListView listView;
ListAdapter listAdapter;
-
+
ProgressBar progressBar;
-
+
String articleName;
ArticleFullData article;
ArrayList articleLayout = new ArrayList();
-
+
public ArticleFragment()
{
articleName = "";
article = null;
}
-
+
public ArticleFragment(String articleName)
{
this.articleName = articleName;
RestoreArticle();
ReloadLayout();
}
-
+
public ArticleFragment(ArticleFullData article)
{
this.articleName = article.name;
this.article = article;
ReloadLayout();
}
-
+
@Override
- public void onSaveInstanceState(final Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putString("articleName", articleName);
- }
-
+ public void onSaveInstanceState(final Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ outState.putString("articleName", articleName);
+ }
+
public void RestoreArticle()
{
DatabaseGetArticleTask task = new DatabaseGetArticleTask();
@@ -167,342 +160,332 @@ public class ArticleFragment extends Fragment
task.execute(articleName);
}
-
public void ReloadLayout()
{
articleLayout.clear();
-
+
if (article != null)
{
-
- articleLayout.add(new ArticleLayoutElement(0, article.title));
-
- PhotoRecordData zeroPhoto = null;
-
- if (article.albumArr.size() > 0)
- {
- if (article.albumArr.get(0).photoRecordArr.size() > 0)
+
+ articleLayout.add(new ArticleLayoutElement(0, article.title));
+
+ PhotoRecordData zeroPhoto = null;
+
+ if (article.albumArr.size() > 0)
{
- zeroPhoto = article.albumArr.get(0).photoRecordArr.get(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.phone.length() > 0)
- {
- articleLayout.add(new ArticleLayoutElement(6, article.phone));
-
- }
-
- 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));
- }
-
+
+ if (zeroPhoto != null)
+ {
+ articleLayout.add(new ArticleLayoutElement(2, zeroPhoto.imageUrl));
+ }
+
+ articleLayout.add(new ArticleLayoutElement(1, article.content));
+
+ if (article.phone.length() > 0)
+ {
+ articleLayout.add(new ArticleLayoutElement(6, article.phone));
+
+ }
+
+ 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));
+ }
+
}
}
-
+
public void SetArticle(ArticleFullData article)
{
progressBar.setVisibility(View.GONE);
-
+
this.article = article;
-
+
ReloadLayout();
-
+
listAdapter.notifyDataSetChanged();
}
-
-
+
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- if (savedInstanceState != null) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
+ if (savedInstanceState != null)
+ {
articleName = savedInstanceState.getString("articleName");
RestoreArticle();
ReloadLayout();
- }
-
+ }
+
View rootView = inflater.inflate(R.layout.fragment_article_page, container, false);
-
- progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
-
+
+ progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
+
progressBar.setVisibility(View.VISIBLE);
-
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 class ListAdapter extends BaseAdapter
+ {
+ private Context mContext;
- public int getCount() {
- return articleLayout.size();
- }
+ public ListAdapter(Context c)
+ {
+ mContext = c;
+ }
- public Object getItem(int position) {
- return null;
- }
+ public int getCount()
+ {
+ return articleLayout.size();
+ }
- public long getItemId(int position) {
- return 0;
- }
-
- @Override
- public int getViewTypeCount()
- {
+ public Object getItem(int position)
+ {
+ return null;
+ }
+
+ public long getItemId(int position)
+ {
+ return 0;
+ }
+
+ @Override
+ public int getViewTypeCount()
+ {
return 7;
- }
-
- @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 //if (getItemViewType(position) == 6)
- {
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.article_phone_element, null);
- }
- } else {
- view = convertView;
- }
-
-
- if (getItemViewType(position) == 0)
- {
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- textView.setText(articleLayout.get(position).value);
-
- if (article.type == ArticleManager.ARTICLE_TYPE_NEWS)
- {
- textView.setTextSize(getResources().getDimension(R.dimen.xlarge_text_size));
- }
- else
- {
- textView.setTextSize(getResources().getDimension(R.dimen.xxlarge_text_size));
- }
-
- textView.setTypeface(null, Typeface.BOLD);
- textView.setGravity(Gravity.CENTER_HORIZONTAL);
-
- }
- else if (getItemViewType(position) == 1)
- {
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- textView.setText(articleLayout.get(position).value);
-
- textView.setTextSize(getResources().getDimension(R.dimen.article_content_text_size));
- textView.setTypeface(null, Typeface.NORMAL);
- textView.setGravity(Gravity.LEFT);
-
- }
- 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)
- {
- double geoLat = articleLayout.get(position).geoLat;
- double geoLon = articleLayout.get(position).geoLon;
-
- TextView addressTextView = (TextView) view.findViewById(R.id.addressTextView);
- TextView hintTextView = (TextView) view.findViewById(R.id.hintTextView);
-
- if (article.address.length() > 0)
- {
- addressTextView.setText(article.address);
- addressTextView.setVisibility(View.VISIBLE);
-
- hintTextView.setVisibility(View.VISIBLE);
-
- final String copied_text = getResources().getString(R.string.copied_text);
-
- addressTextView.setOnLongClickListener(new OnLongClickListener(){
+ @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
+ // if (getItemViewType(position) == 6)
+ {
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.article_phone_element, null);
+ }
+ } else
+ {
+ view = convertView;
+ }
+
+ if (getItemViewType(position) == 0)
+ {
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ textView.setText(articleLayout.get(position).value);
+
+ if (article.type == ArticleManager.ARTICLE_TYPE_NEWS)
+ {
+ textView.setTextSize(getResources().getDimension(R.dimen.xlarge_text_size));
+ } else
+ {
+ textView.setTextSize(getResources().getDimension(R.dimen.xxlarge_text_size));
+ }
+
+ textView.setTypeface(null, Typeface.BOLD);
+ textView.setGravity(Gravity.CENTER_HORIZONTAL);
+
+ } else if (getItemViewType(position) == 1)
+ {
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ textView.setText(articleLayout.get(position).value);
+
+ textView.setTextSize(getResources().getDimension(R.dimen.article_content_text_size));
+ textView.setTypeface(null, Typeface.NORMAL);
+ textView.setGravity(Gravity.LEFT);
+
+ } 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)
+ {
+ double geoLat = articleLayout.get(position).geoLat;
+ double geoLon = articleLayout.get(position).geoLon;
+
+ TextView addressTextView = (TextView) view.findViewById(R.id.addressTextView);
+ TextView hintTextView = (TextView) view.findViewById(R.id.hintTextView);
+
+ if (article.address.length() > 0)
+ {
+ addressTextView.setText(article.address);
+ addressTextView.setVisibility(View.VISIBLE);
+
+ hintTextView.setVisibility(View.VISIBLE);
+
+ final String copied_text = getResources().getString(R.string.copied_text);
+
+ addressTextView.setOnLongClickListener(new OnLongClickListener()
+ {
@Override
public boolean onLongClick(View v)
{
-
-
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
- android.text.ClipboardManager clipboard = (android.text.ClipboardManager) MainActivity.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
- clipboard.setText(article.address);
- } else {
- android.content.ClipboardManager clipboard = (android.content.ClipboardManager) MainActivity.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
- android.content.ClipData clip = android.content.ClipData.newPlainText(copied_text, article.address);
- clipboard.setPrimaryClip(clip);
+
+ if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
+ {
+ android.text.ClipboardManager clipboard = (android.text.ClipboardManager) MainActivity.getInstance().getSystemService(
+ Context.CLIPBOARD_SERVICE);
+ clipboard.setText(article.address);
+ } else
+ {
+ android.content.ClipboardManager clipboard = (android.content.ClipboardManager) MainActivity.getInstance().getSystemService(
+ Context.CLIPBOARD_SERVICE);
+ android.content.ClipData clip = android.content.ClipData.newPlainText(copied_text, article.address);
+ clipboard.setPrimaryClip(clip);
}
-
+
CharSequence text = getResources().getString(R.string.text_is_copied);
Toast toast = Toast.makeText(MainActivity.getInstance(), text, Toast.LENGTH_SHORT);
toast.show();
-
+
return true;
}
-
- });
- //editText.setKeyListener(null);
-
- }
- else
- {
- addressTextView.setVisibility(View.GONE);
- hintTextView.setVisibility(View.GONE);
- }
-
- MapView mapView = (MapView) view.findViewById(R.id.mapview);
-
- mapView.setMaxZoomLevel(20);
- mapView.setMinZoomLevel(4);
-
- //mapView.setBuiltInZoomControls(true);
- //mapView.setMultiTouchControls(true);
-
-
- IMapController mapController = mapView.getController();
-
-
- GeoPoint markerPoint = new GeoPoint(geoLat, geoLon);
-
- mapController.setZoom(16);
- mapController.animateTo(markerPoint);
-
-
- ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
- NoInteractionOverlay itemizedOverlay = new NoInteractionOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy);
-
- itemizedOverlay.addOverlayItem(markerPoint);
-
- mapView.getOverlays().add(itemizedOverlay);
-
-
- MapOverlay mapOverlay = new MapOverlay(getActivity());
-
- mapView.getOverlays().add(mapOverlay);
-
-
- }
- else if (getItemViewType(position) == 4)
- {
-
- TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView);
-
- titleTextView.setText(article.albumArr.get(articleLayout.get(position).albumPos).title);
-
- TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView);
-
- contentTextView.setText(article.albumArr.get(articleLayout.get(position).albumPos).description);
-
- HListView hListView = (HListView) view.findViewById(R.id.hListView);
-
- hListView.setAdapter(new MainPageHListViewAdapters.PhotoAlbumElementAdapter(getActivity(), article.albumArr.get(articleLayout.get(position).albumPos)));
-
- hListView.setOnItemClickListener(new OnItemClickListener(){
+ });
+ // editText.setKeyListener(null);
+
+ } else
+ {
+ addressTextView.setVisibility(View.GONE);
+ hintTextView.setVisibility(View.GONE);
+ }
+
+ MapView mapView = (MapView) view.findViewById(R.id.mapview);
+
+ mapView.setMaxZoomLevel(20);
+ mapView.setMinZoomLevel(4);
+
+ // mapView.setBuiltInZoomControls(true);
+ // mapView.setMultiTouchControls(true);
+
+ IMapController mapController = mapView.getController();
+
+ GeoPoint markerPoint = new GeoPoint(geoLat, geoLon);
+
+ mapController.setZoom(16);
+ mapController.animateTo(markerPoint);
+
+ ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
+ NoInteractionOverlay itemizedOverlay = new NoInteractionOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy);
+
+ itemizedOverlay.addOverlayItem(markerPoint);
+
+ mapView.getOverlays().add(itemizedOverlay);
+
+ MapOverlay mapOverlay = new MapOverlay(getActivity());
+
+ mapView.getOverlays().add(mapOverlay);
+
+ } else if (getItemViewType(position) == 4)
+ {
+
+ TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView);
+
+ titleTextView.setText(article.albumArr.get(articleLayout.get(position).albumPos).title);
+
+ TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView);
+
+ contentTextView.setText(article.albumArr.get(articleLayout.get(position).albumPos).description);
+
+ HListView hListView = (HListView) view.findViewById(R.id.hListView);
+
+ hListView.setAdapter(new MainPageHListViewAdapters.PhotoAlbumElementAdapter(getActivity(),
+ article.albumArr.get(articleLayout.get(position).albumPos)));
+
+ hListView.setOnItemClickListener(new OnItemClickListener()
+ {
@Override
public void onItemClick(it.sephiroth.android.library.widget.AdapterView> parent, View view, int innerPosition, long id)
{
MainActivity.getInstance().SetLastArticleName(articleName);
-
+
String albumName = article.albumArr.get(articleLayout.get(position).albumPos).name;
- MainActivity.getInstance().OpenPhotoScreen(albumName, innerPosition, MainActivity.TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT);
-
+ MainActivity.getInstance().OpenPhotoScreen(albumName, innerPosition, MainActivity.TAG_BACK_TO_ARTICLEFRAGMENT);
+
}
});
-
- }
- else if (getItemViewType(position) == 5)
- {
- Button button = (Button) view.findViewById(R.id.button);
-
- if (article.externalLinkText.length() > 0)
- {
- button.setText(article.externalLinkText);
- }
- else
- {
- button.setText(R.string.go_to_website);
- }
-
- button.setOnClickListener(new OnClickListener()
- {
+
+ } else if (getItemViewType(position) == 5)
+ {
+ Button button = (Button) view.findViewById(R.id.button);
+
+ if (article.externalLinkText.length() > 0)
+ {
+ button.setText(article.externalLinkText);
+ } else
+ {
+ button.setText(R.string.go_to_website);
+ }
+
+ button.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
@@ -510,19 +493,17 @@ public class ArticleFragment extends Fragment
i.setData(Uri.parse(articleLayout.get(position).value));
startActivity(i);
}
- });
- }
- else if (getItemViewType(position) == 6)
- {
- Button button = (Button) view.findViewById(R.id.button);
-
- final String phone = article.phone;
-
- button.setText(phone);
-
-
- button.setOnClickListener(new OnClickListener()
- {
+ });
+ } else if (getItemViewType(position) == 6)
+ {
+ Button button = (Button) view.findViewById(R.id.button);
+
+ final String phone = article.phone;
+
+ button.setText(phone);
+
+ button.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
@@ -531,13 +512,11 @@ public class ArticleFragment extends Fragment
intent.setData(Uri.parse(uri));
MainActivity.getInstance().startActivity(intent);
}
- });
- }
-
-
+ });
+ }
- return view;
- }
+ return view;
+ }
}
}
diff --git a/android/src/fishrungames/bashgid/BookRecordFragment.java b/android/src/fishrungames/bashgid/BookRecordFragment.java
deleted file mode 100644
index e9c22f6..0000000
--- a/android/src/fishrungames/bashgid/BookRecordFragment.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package fishrungames.bashgid;
-
-
-import fishrungames.networkutils.ImageManager;
-import fishrungames.bashgid.core.BookManager.BookRecord;
-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.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-
-public class BookRecordFragment extends Fragment
-{
-
- BookRecord bookRecord;
-
- public BookRecordFragment(BookRecord bookRecord)
- {
- this.bookRecord = bookRecord;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_book_record_page, container, false);
-
- TextView nameTextView = (TextView) rootView.findViewById(R.id.nameTextView);
- nameTextView.setText(bookRecord.name);
-
- TextView authorTextView = (TextView) rootView.findViewById(R.id.authorTextView);
- authorTextView.setText(bookRecord.author);
-
- TextView descriptionTextView = (TextView) rootView.findViewById(R.id.descriptionTextView);
- descriptionTextView.setText(bookRecord.description);
-
- TextView priceTextView = (TextView) rootView.findViewById(R.id.priceTextView);
- priceTextView.setText(getResources().getString(R.string.price) + Integer.toString(bookRecord.price) + " " + getResources().getString(R.string.rub));
-
- ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView);
-
- if (bookRecord.imageUrl.length() == 0)
- {
- imageView.setImageResource(R.drawable.no_picture);
- }
- else
- {
- ImageManager.getInstance().ApplyImageToImageView(imageView, bookRecord.imageUrl);
- }
-
- //ImageManager.getInstance().ApplyImageToImageView(imageView, realImageUrl);
-
- //Button buyButton = (Button) rootView.findViewById(R.id.buyButton);
- //Button readButton = (Button) rootView.findViewById(R.id.readButton);
-
- return rootView;
- }
-
-
-}
diff --git a/android/src/fishrungames/bashgid/BooksFragment.java b/android/src/fishrungames/bashgid/BooksFragment.java
deleted file mode 100644
index 6d5441a..0000000
--- a/android/src/fishrungames/bashgid/BooksFragment.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package fishrungames.bashgid;
-
-
-import java.util.ArrayList;
-
-import fishrungames.bashgid.core.BookManager;
-import fishrungames.networkutils.ImageManager;
-import fishrungames.networkutils.UniversalActionWithCallback;
-import fishrungames.networkutils.interfaces.RemoveCallbackInterface;
-import fishrungames.networkutils.interfaces.UpdateAndFinishCallbackInterface;
-
-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.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.BaseAdapter;
-import android.widget.GridView;
-import android.widget.ImageView;
-
-import android.widget.TextView;
-
-
-public class BooksFragment extends Fragment implements UpdateAndFinishCallbackInterface
-{
-
- ListAdapter listAdapter;
-
- GridView gridView;
-
- ArrayList bookRecordArr;
-
- RemoveCallbackInterface removeCallback = null;
- Object removeCallbackSynchronizer = new Object();
-
-
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-
- bookRecordArr = BookManager.getInstance().getBooks();
-
- removeCallback = UniversalActionWithCallback.PerformActionIfNotPerforming(BookManager.getInstance(), null, this, "BookManager");
-
-
- View rootView = inflater.inflate(R.layout.fragment_books_page, container, false);
-
- gridView = (GridView) rootView.findViewById(R.id.gridView);
-
- listAdapter = new ListAdapter(getActivity());
-
- gridView.setAdapter(listAdapter);
-
- gridView.setOnItemClickListener(new OnItemClickListener()
- {
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id)
- {
- MainActivity.getInstance().OpenBookRecordScreen(bookRecordArr.get(position), MainActivity.TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT);
- }
-
- });
-
- RefreshBookList();
-
- return rootView;
- }
-
- @Override
- public void onDestroyView()
- {
- synchronized (removeCallbackSynchronizer)
- {
- if (removeCallback != null)
- {
- removeCallback.RemoveCallback();
- removeCallback = null;
- }
- }
- super.onDestroyView();
- }
-
- public void RefreshBookList()
- {
- bookRecordArr = BookManager.getInstance().getBooks();
-
- listAdapter.notifyDataSetChanged();
- }
-
- @Override
- public void OnFinished()
- {
- synchronized (removeCallbackSynchronizer)
- {
- removeCallback = null;
- }
-
- }
-
- @Override
- public void OnUpdated(Bundle result)
- {
- getActivity().runOnUiThread(new Runnable() {
-
- @Override
- public void run()
- {
- RefreshBookList();
- }
-
- });
- }
-
- public class ListAdapter extends BaseAdapter {
- private Context mContext;
-
- public ListAdapter(Context c) {
- mContext = c;
- }
-
- public int getCount() {
- return bookRecordArr.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.books_page_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
- TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
- TextView authorTextView = (TextView) view.findViewById(R.id.authorTextView);
-
- if (bookRecordArr.get(position).imageUrl.length() == 0)
- {
- imageView.setImageResource(R.drawable.no_picture);
- }
- else
- {
- ImageManager.getInstance().ApplyImageToImageView(imageView, bookRecordArr.get(position).imageUrl);
- }
-
- nameTextView.setText(bookRecordArr.get(position).name);
-
- authorTextView.setText(bookRecordArr.get(position).author);
-
- return view;
- }
-
- }
-}
diff --git a/android/src/fishrungames/bashgid/CatalogFragment.java b/android/src/fishrungames/bashgid/CatalogFragment.java
index 2e19ea5..4ff853d 100644
--- a/android/src/fishrungames/bashgid/CatalogFragment.java
+++ b/android/src/fishrungames/bashgid/CatalogFragment.java
@@ -7,10 +7,9 @@ import fishrungames.bashgid.core.DatabaseGetJournalListTask;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import android.annotation.SuppressLint;
import android.content.Context;
-import android.os.AsyncTask;
+
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
+
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
@@ -25,165 +24,167 @@ import android.widget.TextView;
public class CatalogFragment extends Fragment
{
-
+
ListView listView;
ListAdapter listAdapter;
ProgressBar progressBar;
-
- ArrayList journalList;
-
+
+ ArrayList journalList;
+
DatabaseGetJournalListTask databaseGetJournalListTask = null;
-
+
public CatalogFragment()
{
RestoreJournalList();
}
-
+
public CatalogFragment(ArrayList journalList)
{
this.journalList = journalList;
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
View rootView = inflater.inflate(R.layout.fragment_catalog_page, container, false);
-
- progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
-
-
+
+ progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
+
progressBar.setVisibility(View.VISIBLE);
-
+
listView = (ListView) rootView.findViewById(R.id.listView);
-
+
listAdapter = new ListAdapter(getActivity());
-
+
listView.setAdapter(listAdapter);
-
+
return rootView;
}
-
+
@Override
- public void onDestroyView ()
+ public void onDestroyView()
{
-
+
if (databaseGetJournalListTask != null)
{
databaseGetJournalListTask.cancel(false);
databaseGetJournalListTask = null;
}
-
+
super.onDestroyView();
}
-
+
public void RestoreJournalList()
{
journalList = new ArrayList();
-
+
databaseGetJournalListTask = new DatabaseGetJournalListTask();
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
databaseGetJournalListTask.execute();
}
-
+
public void SetJournalList(ArrayList journalList)
{
databaseGetJournalListTask = null;
-
+
progressBar.setVisibility(View.GONE);
-
+
this.journalList = journalList;
-
+
listAdapter.notifyDataSetChanged();
}
-
-
-
- public class ListAdapter extends BaseAdapter {
- private Context mContext;
- public ListAdapter(Context c) {
- mContext = c;
- }
+ public class ListAdapter extends BaseAdapter
+ {
+ private Context mContext;
- public int getCount() {
- return journalList.size();
- }
+ public ListAdapter(Context c)
+ {
+ mContext = c;
+ }
- public Object getItem(int position) {
- return null;
- }
+ public int getCount()
+ {
+ return journalList.size();
+ }
- public long getItemId(int position) {
- return 0;
- }
+ public Object getItem(int position)
+ {
+ return null;
+ }
- // 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
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.main_page_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
-
- Button button = (Button) view.findViewById(R.id.button);
- ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
-
- HListView hListView = (HListView) view.findViewById(R.id.hListView);
-
- hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
+ public long getItemId(int position)
+ {
+ return 0;
+ }
- textView.setText(journalList.get(position).title);
-
- if (journalList.get(position).description.length() > 0)
- {
- descriptionTextView.setText(journalList.get(position).description);
-
- descriptionTextView.setVisibility(View.VISIBLE);
- }
- else
- {
- descriptionTextView.setVisibility(View.GONE);
- }
-
-
- button.setText(R.string.see_all);
-
- button.setOnClickListener(new OnClickListener()
- {
+ // 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
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.main_page_list_element, null);
+
+ } else
+ {
+ view = convertView;
+ }
+
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
+
+ Button button = (Button) view.findViewById(R.id.button);
+ ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
+
+ HListView hListView = (HListView) view.findViewById(R.id.hListView);
+
+ hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
+
+ textView.setText(journalList.get(position).title);
+
+ if (journalList.get(position).description.length() > 0)
+ {
+ descriptionTextView.setText(journalList.get(position).description);
+
+ descriptionTextView.setVisibility(View.VISIBLE);
+ } else
+ {
+ descriptionTextView.setVisibility(View.GONE);
+ }
+
+ button.setText(R.string.see_all);
+
+ button.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
- MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT);
+ MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_BACK_TO_CATALOGFRAGMENT);
}
-
- });
- imageButton.setOnClickListener(new OnClickListener()
- {
+ });
+
+ imageButton.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
- MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT);
+ MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_BACK_TO_CATALOGFRAGMENT);
}
-
- });
- return view;
- }
+
+ });
+ return view;
+ }
}
-
+
}
\ No newline at end of file
diff --git a/android/src/fishrungames/bashgid/HtmlViewerFragment.java b/android/src/fishrungames/bashgid/HtmlViewerFragment.java
deleted file mode 100644
index 45f2f20..0000000
--- a/android/src/fishrungames/bashgid/HtmlViewerFragment.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package fishrungames.bashgid;
-
-import fishrungames.networkutils.ContextHolder;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.WebView;
-
-public class HtmlViewerFragment extends Fragment
-{
-
- public String url = "";
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- View rootView = inflater.inflate(R.layout.fragment_html_viewer, container, false);
-
- WebView webView = (WebView)rootView.findViewById(R.id.webView);
-
- webView.loadUrl("file:///" + ContextHolder.getContext().getFilesDir().getAbsolutePath() + "/" + url);
-
- return rootView;
- }
-}
diff --git a/android/src/fishrungames/bashgid/JournalFragment.java b/android/src/fishrungames/bashgid/JournalFragment.java
index 14cac1e..362b3d2 100644
--- a/android/src/fishrungames/bashgid/JournalFragment.java
+++ b/android/src/fishrungames/bashgid/JournalFragment.java
@@ -97,24 +97,19 @@ public class JournalFragment extends Fragment
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
- /*
- if (journal.geoCategory == 1)
- {
- position = position - 1; // because there is header for geo objects
- }*/
-
+ MainActivity.getInstance().SetLastJournalName(journalName);
if (position == 0)
{
if (journal.geoCategory == 1)
{
- MainActivity.getInstance().OpenMapScreen(journalName);
+ MainActivity.getInstance().OpenMapScreen(journalName, MainActivity.TAG_BACK_TO_JOURNALFRAGMENT);
}
}
else
{
- MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position-1).name, MainActivity.TAG_TO_MAINFRAGMENT);
+ MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position-1).name, MainActivity.TAG_BACK_TO_JOURNALFRAGMENT);
}
}
});
diff --git a/android/src/fishrungames/bashgid/LinkContentFragment.java b/android/src/fishrungames/bashgid/LinkContentFragment.java
deleted file mode 100644
index 38a857b..0000000
--- a/android/src/fishrungames/bashgid/LinkContentFragment.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package fishrungames.bashgid;
-
-
-import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
-
-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 LinkContentFragment extends Fragment {
-
-
-
- public TextFileRecord contentRecord;
-
- //String content;
-
- View rootView;
- TextView titleTextView;
- ImageView imageView;
- TextView textView;
- Button button;
-
- ListView listView;
-
- ListAdapter listAdapter;
-
- public LinkContentFragment(TextFileRecord contentRecord)
- {
- this.contentRecord = contentRecord;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- rootView = inflater.inflate(R.layout.fragment_link_content_page, container, false);
-
-
- listView = (ListView) rootView.findViewById(R.id.listView);
-
- listAdapter = new ListAdapter(getActivity());
-
- listView.setAdapter(listAdapter);
-
- //content = FileFunctions.ReadTextFromFile(contentRecord.localUrl + ".txt");
-
- return rootView;
- }
-
- @Override
- public void onResume()
- {
- super.onResume();
-
- }
-
- public class ListAdapter extends BaseAdapter {
- private Context mContext;
-
- public ListAdapter(Context c) {
- mContext = c;
- }
-
- public int getCount() {
- return contentRecord.contentArr.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(final 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.link_content_page_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
-
- Button button = (Button) view.findViewById(R.id.button);
-
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- imageView.setVisibility(View.GONE);
- button.setVisibility(View.GONE);
- textView.setVisibility(View.GONE);
-
- if (contentRecord.contentArr.get(position).docPartType == TextFileRecord.DocPart.DocPartType.DPT_TEXT)
- {
- textView.setVisibility(View.VISIBLE);
- textView.setText(contentRecord.contentArr.get(position).value);
- textView.setTextSize(20);
- }
- else if (contentRecord.contentArr.get(position).docPartType == TextFileRecord.DocPart.DocPartType.DPT_IMAGE)
- {
- imageView.setVisibility(View.VISIBLE);
- ImageManager.getInstance().ApplyImageToImageView(imageView, contentRecord.contentArr.get(position).value);
- }
- else if (contentRecord.contentArr.get(position).docPartType == TextFileRecord.DocPart.DocPartType.DPT_BUTTON)
- {
- button.setVisibility(View.VISIBLE);
- button.setText(R.string.go_to_website);
- button.setOnClickListener(new OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- Uri uri = Uri.parse(contentRecord.contentArr.get(position).value);
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
- }
-
- });
- }
-
- /*
- ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
-
- Button button = (Button) view.findViewById(R.id.button);
-
- 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)));
- */
- return view;
- }
-
- }
-}
diff --git a/android/src/fishrungames/bashgid/MainActivity.java b/android/src/fishrungames/bashgid/MainActivity.java
index 5747a29..ed38404 100644
--- a/android/src/fishrungames/bashgid/MainActivity.java
+++ b/android/src/fishrungames/bashgid/MainActivity.java
@@ -1,10 +1,10 @@
package fishrungames.bashgid;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Locale;
-
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
@@ -22,7 +22,6 @@ import fishrungames.bashgid.core.db.ArticleDataSource;
import fishrungames.bashgid.core.db.BashgidSqliteHelper;
import fishrungames.bashgid.core.db.ChannelDataSource;
import fishrungames.bashgid.core.db.JournalDataSource;
-import fishrungames.bashgid.core.db.NewsDataSource;
import fishrungames.bashgid.core.db.PhotoDataSource;
import fishrungames.bashgid.core.db.TranslationDataSource;
import fishrungames.bashgid.core.db.VideoDataSource;
@@ -33,7 +32,6 @@ import fishrungames.networkutils.ImageManager;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
-
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@@ -42,12 +40,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-//import android.support.v4.view.MenuCompat;
-//import android.support.v4.view.MenuItemCompat;
-
-
-
-
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -60,60 +52,62 @@ import android.support.v4.widget.DrawerLayout;
public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks
{
- public static final String TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT";
- public static final String TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT";
- public static final String TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT = "TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT";
-
- public static final String TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT = "TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT";
- public static final String TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT = "TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT";
- public static final String TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT = "TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT";
-
- public static final String TAG_FROM_CATALOGFRAGMENT_TO_ARTICLEFRAGMENT = "TAG_FROM_CATALOGFRAGMENT_TO_ARTICLEFRAGMENT";
- public static final String TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT = "TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT";
-
- public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
- public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
- public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
- public static final String TAG_TO_MAPFRAGMENT = "MapFragment";
+ public static final String TAG_BACK_TO_MAINFRAGMENT = "TAG_BACK_TO_MAINFRAGMENT";
+ public static final String TAG_BACK_TO_CATALOGFRAGMENT = "TAG_BACK_TO_CATALOGFRAGMENT";
+ public static final String TAG_BACK_TO_ALBUMLISTFRAGMENT = "TAG_BACK_TO_ALBUMLISTFRAGMENT";
+
+ public static final String TAG_BACK_TO_JOURNALFRAGMENT = "TAG_BACK_TO_JOURNALFRAGMENT";
+ public static final String TAG_BACK_TO_ARTICLEFRAGMENT = "TAG_BACK_TO_ARTICLEFRAGMENT";
+ public static final String TAG_BACK_TO_ALBUMFRAGMENT = "TAG_BACK_TO_ALBUMFRAGMENT";
+ public static final String TAG_BACK_TO_CHANNELFRAGMENT = "TAG_BACK_TO_CHANNELFRAGMENT";
+
+ public static final String TAG_BACK_TO_SEARCHFRAGMENT = "TAG_BACK_TO_SEARCHFRAGMENT";
+ public static final String TAG_BACK_TO_MAPFRAGMENT = "TAG_BACK_TO_MAPFRAGMENT";
+
+ public static final String TAG_BACK_TO_NEWSLISTFRAGMENT = "TAG_BACK_TO_NEWSLISTFRAGMENT";
+
+
+
+
+
+
public static final String PREFS_MAIN = "PREFS_MAIN";
public static final int NEWS_DOWNLOADER_STATE_UPDATE = 10;
public static final int NEWS_DOWNLOADER_STATE_FINISHED = 11;
-
+
public static final int DATABASE_DOWNLOADER_STATE_UPDATE = 12;
public static final int DATABASE_DOWNLOADER_STATE_FINISHED = 13;
-
+
public static final int DATABASE_GET_ALBUM_STATE_UPDATE = 14;
public static final int DATABASE_GET_ALBUM_STATE_FINISHED = 15;
-
+
public static final int DATABASE_GET_ALBUM_LIST_STATE_UPDATE = 16;
public static final int DATABASE_GET_ALBUM_LIST_STATE_FINISHED = 17;
-
+
public static final int DATABASE_GET_ARTICLE_STATE_UPDATE = 18;
public static final int DATABASE_GET_ARTICLE_STATE_FINISHED = 19;
-
+
public static final int DATABASE_GET_JOURNAL_STATE_UPDATE = 20;
public static final int DATABASE_GET_JOURNAL_STATE_FINISHED = 21;
-
+
public static final int DATABASE_GET_CHANNEL_STATE_UPDATE = 22;
public static final int DATABASE_GET_CHANNEL_STATE_FINISHED = 23;
-
+
public static final int DATABASE_GET_VIDEO_STATE_UPDATE = 24;
public static final int DATABASE_GET_VIDEO_STATE_FINISHED = 25;
-
+
public static final int DATABASE_GET_JOURNAL_LIST_STATE_UPDATE = 26;
public static final int DATABASE_GET_JOURNAL_LIST_STATE_FINISHED = 27;
-
+
public static final int DATABASE_SEARCH_ARTICLE_STATE_UPDATE = 28;
public static final int DATABASE_SEARCH_ARTICLE_STATE_FINISHED = 29;
-
+
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_UPDATE = 30;
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED = 31;
-
-
MainPageFragment mainPageFragment = null;
NewsListFragment newsListFragment = null;
@@ -121,16 +115,16 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
AlbumListFragment albumListFragment = null;
PhotoAlbumFragment photoAlbumFragment = null;
PhotoFragment photoFragment = null;
-
+
ArticleFragment articleFragment = null;
JournalFragment journalFragment = null;
-
+
VideoListFragment videoListFragment = null;
VideoRecordFragment videoRecordFragment = null;
OsmMapHolderFragment mapHolderFragment = null;
-
+
SearchFragment searchFragment = null;
-
+
CatalogFragment catalogFragment = null;
static MainActivity instance = null;
@@ -138,19 +132,20 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
private NavigationDrawerFragment mNavigationDrawerFragment = null;
public BashgidSqliteHelper dbHelper = null;
-
- public NewsDataSource newsDataSource = null;
+
public PhotoDataSource photoDataSource = null;
public AlbumDataSource albumDataSource = null;
public ArticleDataSource articleDataSource = null;
public VideoDataSource videoDataSource = null;
public ChannelDataSource channelDataSource = null;
-
+
public JournalDataSource journalDataSource = null;
-
+
public TranslationDataSource translationDataSource = null;
+ public static final SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
+
public Handler mHandler;
@Override
@@ -159,36 +154,33 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
super.onCreate(savedInstanceState);
ImageManager.getInstance().PredefinedImageId.put("R.drawable.no_picture", R.drawable.no_picture);
-
+
setContentView(R.layout.activity_main);
SetupDrawer();
ImageManager.getInstance().alwaysUpdateImagesWithoutHash = false;
- getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new WelcomeFragment(), TAG_TO_WELCOMEFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new WelcomeFragment(), null).commit();
instance = this;
ContextHolder.setContext(instance);
-
+
dbHelper = new BashgidSqliteHelper(this);
-
- newsDataSource = new NewsDataSource(this, dbHelper);
-
+
photoDataSource = new PhotoDataSource(this, dbHelper);
albumDataSource = new AlbumDataSource(this, dbHelper);
-
+
articleDataSource = new ArticleDataSource(this, dbHelper);
-
+
videoDataSource = new VideoDataSource(this, dbHelper);
-
+
channelDataSource = new ChannelDataSource(this, dbHelper);
-
+
journalDataSource = new JournalDataSource(this, dbHelper);
-
+
translationDataSource = new TranslationDataSource(this, dbHelper);
-
mHandler = new Handler(Looper.getMainLooper())
{
@@ -212,39 +204,38 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
break;
case DATABASE_GET_ALBUM_STATE_UPDATE:
case DATABASE_GET_ALBUM_STATE_FINISHED:
- UpdateOnAlbumLoaded((AlbumFullData)inputMessage.obj);
+ UpdateOnAlbumLoaded((AlbumFullData) inputMessage.obj);
break;
case DATABASE_GET_ALBUM_LIST_STATE_UPDATE:
case DATABASE_GET_ALBUM_LIST_STATE_FINISHED:
-
+
ArrayList albumShortList = (ArrayList) inputMessage.obj;
-
+
UpdateOnAlbumListLoaded(albumShortList);
break;
case DATABASE_GET_ARTICLE_STATE_UPDATE:
case DATABASE_GET_ARTICLE_STATE_FINISHED:
- UpdateOnArticleLoaded((ArticleFullData)inputMessage.obj);
+ UpdateOnArticleLoaded((ArticleFullData) inputMessage.obj);
break;
case DATABASE_GET_JOURNAL_STATE_UPDATE:
case DATABASE_GET_JOURNAL_STATE_FINISHED:
- UpdateOnJournalLoaded((JournalSemiFullData)inputMessage.obj);
+ UpdateOnJournalLoaded((JournalSemiFullData) inputMessage.obj);
break;
case DATABASE_GET_CHANNEL_STATE_UPDATE:
case DATABASE_GET_CHANNEL_STATE_FINISHED:
- UpdateOnChannelLoaded((ChannelFullData)inputMessage.obj);
+ UpdateOnChannelLoaded((ChannelFullData) inputMessage.obj);
break;
-
+
case DATABASE_GET_VIDEO_STATE_UPDATE:
case DATABASE_GET_VIDEO_STATE_FINISHED:
- UpdateOnVideoLoaded((VideoRecordData)inputMessage.obj);
+ UpdateOnVideoLoaded((VideoRecordData) inputMessage.obj);
break;
-
+
case DATABASE_GET_JOURNAL_LIST_STATE_UPDATE:
case DATABASE_GET_JOURNAL_LIST_STATE_FINISHED:
UpdateOnJournalListLoaded((ArrayList) inputMessage.obj);
break;
-
-
+
case DATABASE_SEARCH_ARTICLE_STATE_UPDATE:
case DATABASE_SEARCH_ARTICLE_STATE_FINISHED:
UpdateOnArticleSearchPerformed((ArrayList) inputMessage.obj);
@@ -254,97 +245,16 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
case DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED:
UpdateOnGeoJournalListLoaded((ArrayList) inputMessage.obj);
break;
-
+
default:
super.handleMessage(inputMessage);
}
}
};
-
- /*
- albumDataSource.CreateNewAlbum(new AlbumRecordData("TEST", "Vk Photos", "Wow"));
-
-
- Date articleTestDate = new Date();
- Date articleTestDate2 = new Date();
-
- try
- {
- articleTestDate = ArticleManager.iso8601Format.parse("2015-05-30 9:00:00");
- articleTestDate2 = ArticleManager.iso8601Format.parse("2015-05-30 9:30:00");
- } catch (ParseException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- AlbumManager.DownloadAndAddPhotoToAlbum(new PhotoRecordData(
- "Lilia",
- "Lilia photo",
- "http://pp.vk.me/c622725/v622725384/3290f/hfnoyPHe5y8.jpg",
- "",
- 0,
- 0), "TEST");
-
-
- AlbumManager.DownloadAndAddPhotoToAlbum(new PhotoRecordData(
- "Vlad 2",
- "Vlad's photo",
- "http://pp.vk.me/c623226/v623226718/2af84/NeEYYIlnR-I.jpg",
- "",
- 0,
- 0
- ), "TEST");
-
- articleDataSource.CreateNewArticle(new ArticleRecordData(
- "TESTART",
- 0,
- "Photos",
- "Wow 2 photos",
- 54.779610,
- 56.032101,
- "http://www.yandex.ru/",
- articleTestDate
- ));
-
- articleDataSource.AddAlbumToArticle("TEST", "TESTART");
-
- //AlbumManager.AddExistingArticleToJournal("TESTART", "news");
-
-
- AlbumManager.AddExistingArticleToJournal("TESTART", "map");
-
- AlbumManager.AddExistingArticleToJournal("TESTART", "investor");
-
- AlbumManager.AddNewVideoToChannel(new VideoRecordData(
- VideoManager.VIDEO_TYPE_YOUTUBE,
- "http://www.youtube.com/watch?v=dQw4w9WgXcQ",
- "Rickroll",
- "Mega Rickroll",
- "http://img.youtube.com/vi/dQw4w9WgXcQ/0.jpg",
- ""), "main");
-
- AlbumManager.AddNewArticleToJournal(new ArticleRecordData(
- "testArticle2",
- ArticleManager.ARTICLE_TYPE_NORMAL,
- "My article",
- "Wow content lol",
- 0,
- 0,
- "http://fishrungames.ru",
- articleTestDate2
- ), "investor");
-
- //articleDataSource.AddAlbumToArticle("TEST", "testArticle2");
- //articleDataSource.AddChannelToArticle("main", "testArticle2");
-
- translationDataSource.CreateNewTranslation(new TranslationRecordData("Wow 2 photos", "Wow 2 photos", "Вау 2 фото", "哇2张照片"));
- translationDataSource.CreateNewTranslation(new TranslationRecordData("Rickroll", "Rickroll", "Рикролл", "笑话"));
- */
DownloadDatabase();
-
+
}
public static MainActivity getInstance()
@@ -352,12 +262,12 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
return instance;
}
-
- public void DownloadImageArr(String [] imageUrlArr)
+
+ public void DownloadImageArr(String[] imageUrlArr)
{
Bundle innerQuery = new Bundle();
-
+
innerQuery.putStringArray("imageUrlArr", imageUrlArr);
ImageDownloadTask task = new ImageDownloadTask();
@@ -366,12 +276,12 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
task.execute(innerQuery);
}
-
- public void DownloadImageArr(String [] imageUrlArr, String [] imageHashArr)
+
+ public void DownloadImageArr(String[] imageUrlArr, String[] imageHashArr)
{
Bundle innerQuery = new Bundle();
-
+
innerQuery.putStringArray("imageUrlArr", imageUrlArr);
innerQuery.putStringArray("imageHashArr", imageHashArr);
@@ -381,18 +291,18 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
task.execute(innerQuery);
}
-
+
public void DownloadImage(String imageUrl)
{
- this.DownloadImageArr(new String []{imageUrl});
+ this.DownloadImageArr(new String[] { imageUrl });
}
-
+
public void DownloadImage(String imageUrl, String imageHash)
{
- this.DownloadImageArr(new String []{imageUrl}, new String []{imageHash});
+ this.DownloadImageArr(new String[] { imageUrl }, new String[] { imageHash });
}
-
+
public void DownloadDatabase()
{
DatabaseDownloadTask task = new DatabaseDownloadTask();
@@ -406,23 +316,23 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
{
mainPageFragment = null;
newsListFragment = null;
-
+
albumListFragment = null;
photoAlbumFragment = null;
photoFragment = null;
-
+
articleFragment = null;
journalFragment = null;
-
+
videoListFragment = null;
videoRecordFragment = null;
mapHolderFragment = null;
-
+
searchFragment = null;
catalogFragment = null;
-
- InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
+
+ InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
}
public void StartDownloadImagesTask(ArrayList imageUrlArr, ArrayList imageHashArr)
@@ -437,11 +347,11 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
task.execute(query);
}
-
+
public void StartDownloadNewsTask()
{
NewsDownloadTask task = new NewsDownloadTask();
-
+
task.mHandler = mHandler;
task.execute();
@@ -453,7 +363,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
{
mainPageFragment.RefreshAdapter();
}
-
+
if (newsListFragment != null)
{
newsListFragment.RefreshAdapter();
@@ -466,167 +376,156 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
{
mainPageFragment.RefreshJournal();
}
-
+
if (newsListFragment != null)
{
newsListFragment.RefreshJournal();
}
}
-
+
public void UpdateOnDatabaseDownloaded()
{
-
+
}
-
+
public void UpdateOnAlbumLoaded(AlbumFullData album)
- {
+ {
if (photoFragment != null)
{
photoFragment.SetAlbum(album);
}
-
+
if (photoAlbumFragment != null)
{
photoAlbumFragment.SetAlbum(album);
}
}
-
+
public void UpdateOnArticleLoaded(ArticleFullData article)
- {
+ {
if (articleFragment != null)
{
articleFragment.SetArticle(article);
}
-
+
if (mapHolderFragment != null)
{
mapHolderFragment.SetArticle(article);
}
}
-
+
public void UpdateOnAlbumListLoaded(ArrayList albumList)
- {
+ {
if (albumListFragment != null)
{
albumListFragment.SetAlbumList(albumList);
}
}
-
-
+
public void UpdateOnJournalLoaded(JournalSemiFullData journal)
- {
+ {
if (journalFragment != null)
{
journalFragment.SetJournal(journal);
}
-
+
if (newsListFragment != null)
{
newsListFragment.SetJournal(journal);
- }
-
+ }
+
if (mainPageFragment != null)
{
mainPageFragment.SetJournal(journal);
- }
-
+ }
+
if (mapHolderFragment != null)
{
mapHolderFragment.SetJournal(journal);
- }
-
+ }
+
}
-
-
-
-
+
public void UpdateOnChannelLoaded(ChannelFullData channel)
- {
-
+ {
+
if (videoListFragment != null)
{
videoListFragment.SetChannel(channel);
}
}
-
-
+
public void UpdateOnVideoLoaded(VideoRecordData video)
- {
-
+ {
+
if (videoRecordFragment != null)
{
videoRecordFragment.SetVideo(video);
}
}
-
+
public void UpdateOnJournalListLoaded(ArrayList journalList)
- {
-
+ {
+
if (catalogFragment != null)
{
catalogFragment.SetJournalList(journalList);
}
-
+
if (mainPageFragment != null)
{
mainPageFragment.SetJournalList(journalList);
}
-
+
}
-
-
+
public void UpdateOnGeoJournalListLoaded(ArrayList journalList)
- {
-
+ {
+
if (mapHolderFragment != null)
{
mapHolderFragment.SetGeoJournals(journalList);
}
-
+
}
-
-
-
+
public void UpdateOnArticleSearchPerformed(ArrayList articleArr)
- {
-
+ {
+
if (searchFragment != null)
{
searchFragment.SetSearchResult(articleArr);
}
}
-
-
+
public void OnSearchPressed()
{
if (searchFragment != null)
{
return;
}
-
+
if (journalFragment != null)
{
if (journalFragment.journal == null)
{
OpenSearchScreen(journalFragment.journalName, "");
- }
- else
+ } else
{
OpenSearchScreen(journalFragment.journalName, journalFragment.journal.title);
}
return;
}
-
+
if (newsListFragment != null)
{
String newsTitle = getResources().getString(R.string.news_header);
OpenSearchScreen("news", newsTitle);
return;
}
-
+
OpenSearchScreen();
}
-
public void OnSelectEnglish(View view)
{
@@ -669,59 +568,53 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
OpenMainScreen();
}
- public void OnSelectSemiDetails(Integer pos)
- {
- // getSupportFragmentManager().beginTransaction().add(R.id.fragment_container,
- // new SemiDetailsFragment()).addToBackStack(null).commit();
- }
-
public void OpenMainScreen()
{
ClearAllFragmentLinks();
-
+
mainPageFragment = new MainPageFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mainPageFragment).commit();
mNavigationDrawerFragment.EnableDrawer();
-
+
}
public void OpenNewsScreen()
{
-
+
ClearAllFragmentLinks();
-
+
newsListFragment = new NewsListFragment();
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, newsListFragment).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, newsListFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
-
+
}
-
+
public void OpenCatalogScreen()
{
-
+
ClearAllFragmentLinks();
-
+
catalogFragment = new CatalogFragment();
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, catalogFragment).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, catalogFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
-
+
}
-
+
public void OpenJournalScreen(String journalName, String tag)
{
ClearAllFragmentLinks();
-
+
journalFragment = new JournalFragment(journalName);
-
+
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, journalFragment, tag).commit();
-
+
mNavigationDrawerFragment.EnableDrawer();
}
@@ -737,76 +630,74 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public void OpenSearchScreen()
{
ClearAllFragmentLinks();
-
+
searchFragment = new SearchFragment();
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
+
public void OpenSearchScreen(String query)
{
ClearAllFragmentLinks();
-
+
searchFragment = new SearchFragment(query);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
+
+ mNavigationDrawerFragment.EnableDrawer();
+ }
+
+ public void OpenSearchScreen(String journalName, String journalTitle)
+ {
+ ClearAllFragmentLinks();
+
+ searchFragment = new SearchFragment(journalName, journalTitle);
+
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
- public void OpenSearchScreen(String journalName, String journalTitle)
+ public void OpenSearchScreen(String query, String journalName, String journalTitle)
{
ClearAllFragmentLinks();
-
- searchFragment = new SearchFragment(journalName, journalTitle);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_TO_MAINFRAGMENT).commit();
+ searchFragment = new SearchFragment(query, journalName, journalTitle);
+
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
- public void OpenMapScreen(String filter)
+ public void OpenMapScreen(String filter, String tag)
{
ClearAllFragmentLinks();
mapHolderFragment = new OsmMapHolderFragment(0, filter);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mapHolderFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mapHolderFragment, tag).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
- /*
- public void OpenMapScreenByArticleName(String articleName)
- {
- ClearAllFragmentLinks();
- mapHolderFragment = new OsmMapHolderFragment(1, articleName);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mapHolderFragment, TAG_TO_MAINFRAGMENT).commit();
-
- mNavigationDrawerFragment.EnableDrawer();
- }*/
-
- public void OpenMapScreen(ArticleFullData articleFullData)
+ public void OpenMapScreen(ArticleFullData articleFullData, String tag)
{
ClearAllFragmentLinks();
mapHolderFragment = new OsmMapHolderFragment(articleFullData);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mapHolderFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mapHolderFragment, tag).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
-
public void OpenPhotoAlbumListScreen()
{
ClearAllFragmentLinks();
-
+
albumListFragment = new AlbumListFragment();
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, albumListFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, albumListFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
@@ -814,30 +705,29 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public void OpenPhotoAlbumScreen(String albumName)
{
ClearAllFragmentLinks();
-
+
photoAlbumFragment = new PhotoAlbumFragment(albumName);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, photoAlbumFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, photoAlbumFragment, TAG_BACK_TO_ALBUMLISTFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
-
+
public void OpenPhotoScreen(String albumName, int position, String tag)
{
ClearAllFragmentLinks();
-
+
photoFragment = new PhotoFragment(albumName, position);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, photoFragment, tag).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
+
public void OpenPhotoScreen(AlbumFullData album, int position, String tag)
{
ClearAllFragmentLinks();
-
+
photoFragment = new PhotoFragment(album, position);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, photoFragment, tag).commit();
@@ -847,30 +737,28 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public void OpenArticleScreen(String articleName, String tag)
{
-
+
ClearAllFragmentLinks();
-
+
articleFragment = new ArticleFragment(articleName);
-
+
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, articleFragment, tag).commit();
mNavigationDrawerFragment.EnableDrawer();
}
-
-
public void OpenVideoListScreen(String channelName)
{
ClearAllFragmentLinks();
videoListFragment = new VideoListFragment(channelName);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, videoListFragment, TAG_TO_MAINFRAGMENT).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, videoListFragment, TAG_BACK_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
- public void OpenVideoRecordScreen(VideoRecordData video, String tag)
+ public void OpenVideoRecordScreen(VideoRecordData video)
{
// Xperimental -- addToBackStack provoke error "Class not found". Need
// to resolve somehow!
@@ -883,7 +771,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
videoRecordFragment = new VideoRecordFragment(video);
- getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, videoRecordFragment, tag).commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, videoRecordFragment, TAG_BACK_TO_CHANNELFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
@@ -895,7 +783,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
mainPageFragment.RefreshJournal();
}
}
-
@Override
public void onAttachFragment(Fragment fragment)
@@ -952,32 +839,23 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
} else if (position == 2)
{
OpenNewsScreen();
-
- }
- else if (position == 3)
+
+ } else if (position == 3)
{
OpenCatalogScreen();
} else if (position == 4)
{
- OpenMapScreen("map");
+ OpenMapScreen("map", MainActivity.TAG_BACK_TO_MAINFRAGMENT);
} else if (position == 5)
{
OpenVideoListScreen("main");
} else if (position == 6)
{
- OpenPhotoAlbumListScreen();
- }
- /*
- else if (position == 7)
+ OpenPhotoAlbumListScreen();
+ } else if (position == 7)
{
- //OpenBooksScreen();
- OpenJournalScreen("books", MainActivity.TAG_TO_MAINFRAGMENT);
- }*/
- else if (position == 7)
- {
- OpenJournalScreen("investor", MainActivity.TAG_TO_MAINFRAGMENT);
- }
- else if (position == 8)
+ OpenJournalScreen("investor", MainActivity.TAG_BACK_TO_MAINFRAGMENT);
+ } else if (position == 8)
{
OpenSettingsScreen();
}
@@ -987,92 +865,67 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public void onBackPressed()
{
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT) != null)
+
+
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_MAPFRAGMENT) != null)
{
- OpenMainScreen();
-
- return;
- }
-
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT) != null)
- {
- OpenVideoListScreen("main");
-
- return;
- }
-
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT) != null)
- {
- OpenSearchScreen();
-
+ OpenMapScreen(GetLastMapFilterName(), TAG_BACK_TO_MAINFRAGMENT);
return;
}
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT) != null)
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_NEWSLISTFRAGMENT) != null)
+ {
+ OpenNewsScreen();
+ return;
+ }
+
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_SEARCHFRAGMENT) != null)
+ {
+ OpenSearchScreen(GetLastSearchQuery(), GetLastJournalName(), GetLastJournalTitle());
+ return;
+ }
+
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_JOURNALFRAGMENT) != null)
+ {
+ OpenJournalScreen(GetLastJournalName(), TAG_BACK_TO_MAINFRAGMENT);
+ return;
+ }
+
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_ARTICLEFRAGMENT) != null)
+ {
+ OpenArticleScreen(GetLastArticleName(), TAG_BACK_TO_MAINFRAGMENT);
+ return;
+ }
+
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_ALBUMFRAGMENT) != null)
{
OpenPhotoAlbumScreen(GetLastAlbumName());
return;
}
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT) != null)
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_CHANNELFRAGMENT) != null)
{
- OpenArticleScreen(GetLastArticleName(), TAG_TO_MAINFRAGMENT);
+ OpenVideoListScreen(GetLastChannelName());
return;
- }
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT) != null)
- {
- OpenMapScreen(GetLastMapFilterName());
- return;
- }
+ }
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_CATALOGFRAGMENT_TO_ARTICLEFRAGMENT) != null)
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_CATALOGFRAGMENT) != null)
{
OpenCatalogScreen();
-
return;
}
- if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT) != null)
- {
- OpenCatalogScreen();
-
- return;
- }
-
-
- if (getSupportFragmentManager().findFragmentByTag(TAG_TO_SEARCHFRAGMENT) != null)
+ if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_MAINFRAGMENT) != null)
{
OpenMainScreen();
-
- return;
- }
-
- if (getSupportFragmentManager().findFragmentByTag(TAG_TO_MAINFRAGMENT) != null)
- {
- OpenMainScreen();
-
return;
}
-
- if (getSupportFragmentManager().findFragmentByTag(TAG_TO_MAPFRAGMENT) != null)
- {
- OpenMapScreen("map");
-
- return;
- }
-
super.onBackPressed();
- /*
- * AddToBackStack is falling. Here is workaround
- * if(getSupportFragmentManager().getBackStackEntryCount() != 0) {
- * getSupportFragmentManager().popBackStack(); } else {
- * super.onBackPressed(); }
- */
}
-
+
public void SetLastAlbumName(String lastAlbumName)
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
@@ -1081,13 +934,28 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
editor.putString("lastAlbumName", lastAlbumName);
editor.commit();
}
-
+
public String GetLastAlbumName()
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
return settings.getString("lastAlbumName", "");
}
+ public void SetLastChannelName(String lastChannelName)
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("lastChannelName", lastChannelName);
+ editor.commit();
+ }
+
+ public String GetLastChannelName()
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+ return settings.getString("lastChannelName", "");
+ }
+
public void SetLastArticleName(String lastArticleName)
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
@@ -1096,13 +964,62 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
editor.putString("lastArticleName", lastArticleName);
editor.commit();
}
-
+
public String GetLastArticleName()
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
return settings.getString("lastArticleName", "");
}
+
+
+ public void SetLastJournalName(String lastJournalName)
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("lastJournalName", lastJournalName);
+ editor.commit();
+ }
+
+
+ public String GetLastJournalName()
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+ return settings.getString("lastJournalName", "");
+ }
+
+
+ public void SetLastJournalTitle(String lastJournalTitle)
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("lastJournalTitle", lastJournalTitle);
+ editor.commit();
+ }
+
+ public String GetLastJournalTitle()
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+ return settings.getString("lastJournalTitle", "");
+ }
+
+ public void SetLastSearchQuery(String searchQuery)
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString("searchQuery", searchQuery);
+ editor.commit();
+ }
+
+ public String GetLastSearchQuery()
+ {
+ SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
+ return settings.getString("searchQuery", "");
+ }
+
public void SetLastMapFilterName(String lastMapFilterName)
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
@@ -1111,7 +1028,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
editor.putString("lastMapFilterName", lastMapFilterName);
editor.commit();
}
-
+
public String GetLastMapFilterName()
{
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
@@ -1131,5 +1048,4 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
super.onPause();
}
-
}
diff --git a/android/src/fishrungames/bashgid/MainPageFragment.java b/android/src/fishrungames/bashgid/MainPageFragment.java
index b6a702e..d828eed 100644
--- a/android/src/fishrungames/bashgid/MainPageFragment.java
+++ b/android/src/fishrungames/bashgid/MainPageFragment.java
@@ -2,15 +2,12 @@ package fishrungames.bashgid;
import java.util.ArrayList;
-import fishrungames.networkutils.ImageManager;
-
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
import fishrungames.bashgid.core.DatabaseGetJournalTask;
import fishrungames.bashgid.core.JournalManager;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
-
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
@@ -29,55 +26,56 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import it.sephiroth.android.library.widget.HListView;
-public class MainPageFragment extends Fragment {
-
-
+public class MainPageFragment extends Fragment
+{
+
ArrayList journalList = new ArrayList();
-
+
ListView listView;
ListAdapter listAdapter;
View header;
ProgressBar progressBar;
EditText searchEditText;
-
+
JournalSemiFullData newsJournal;
-
+
DatabaseGetJournalTask databaseGetJournalTask = null;
DatabaseGetJournalListTask databaseGetJournalListTask = null;
-
+
public MainPageFragment()
{
}
@SuppressLint("InflateParams")
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- journalList.clear();
-
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
+ journalList.clear();
+
RestoreJournalList();
-
+
View rootView = inflater.inflate(R.layout.fragment_main_page, container, false);
-
+
listView = (ListView) rootView.findViewById(R.id.listView);
-
+
listAdapter = new ListAdapter(getActivity());
-
+
header = inflater.inflate(R.layout.main_page_header, null);
-
+
RestoreJournal();
MainActivity.getInstance().StartDownloadNewsTask();
-
+
listView.addHeaderView(header);
-
+
listView.setAdapter(listAdapter);
-
- progressBar = (ProgressBar)header.findViewById(R.id.progressBar);
-
+
+ progressBar = (ProgressBar) header.findViewById(R.id.progressBar);
+
progressBar.setVisibility(View.VISIBLE);
-
+
Button moreNewsButton = (Button) header.findViewById(R.id.moreNewsButton);
-
+
moreNewsButton.setOnClickListener(new OnClickListener()
{
@@ -86,13 +84,12 @@ public class MainPageFragment extends Fragment {
{
MainActivity.getInstance().OpenNewsScreen();
}
- }
- );
-
+ });
+
searchEditText = (EditText) header.findViewById(R.id.searchEditText);
-
+
Button searchButton = (Button) header.findViewById(R.id.searchButton);
-
+
searchButton.setOnClickListener(new OnClickListener()
{
@@ -102,264 +99,250 @@ public class MainPageFragment extends Fragment {
String query = searchEditText.getText().toString();
MainActivity.getInstance().OpenSearchScreen(query);
}
- }
- );
-
+ });
+
return rootView;
}
-
+
@Override
- public void onDestroyView ()
+ public void onDestroyView()
{
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
databaseGetJournalTask = null;
}
-
+
if (databaseGetJournalListTask != null)
{
databaseGetJournalListTask.cancel(false);
databaseGetJournalListTask = null;
}
-
+
super.onDestroyView();
}
-
void RestoreJournal()
{
newsJournal = JournalManager.CreateEmptyJournal();
-
+
RefreshJournal();
}
-
+
void RefreshJournal()
{
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
}
-
+
databaseGetJournalTask = new DatabaseGetJournalTask();
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
Bundle bundle = new Bundle();
-
+
bundle.putString("journalName", "news");
-
+
bundle.putInt("count", 3);
databaseGetJournalTask.execute(bundle);
}
-
+
public void SetJournal(JournalSemiFullData journal)
{
databaseGetJournalTask = null;
-
- //Xperimental
+
+ // Xperimental
if (journal != null)
{
- progressBar.setVisibility(View.GONE);
-
- newsJournal = journal;
-
- //ImageButton news1ImageButton = (ImageButton) header.findViewById(R.id.news1ImageButton);
- //ImageButton news2ImageButton = (ImageButton) header.findViewById(R.id.news2ImageButton);
- //ImageButton news3ImageButton = (ImageButton) header.findViewById(R.id.news3ImageButton);
-
- Button news1Button = (Button)header.findViewById(R.id.news1Button);
- Button news2Button = (Button)header.findViewById(R.id.news2Button);
- Button news3Button = (Button)header.findViewById(R.id.news3Button);
-
- if (newsJournal.articleArr.size() > 0)
- {
- //ImageManager.getInstance().ApplyImageToImageView(news1ImageButton, newsJournal.articleArr.get(0).previewImageUrl);
- news1Button.setText(newsJournal.articleArr.get(0).title);
-
- //news1ImageButton.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(0).name));
- news1Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(0).name));
- }
- else
- {
- //news1ImageButton.setImageResource(R.drawable.transparent);
- news1Button.setText(R.string.news_record_not_available);
- //news1ImageButton.setOnClickListener(null);
- news1Button.setOnClickListener(null);
- }
-
- if (newsJournal.articleArr.size() > 1)
- {
- //ImageManager.getInstance().ApplyImageToImageView(news2ImageButton, newsJournal.articleArr.get(1).previewImageUrl);
- news2Button.setText(newsJournal.articleArr.get(1).title);
- //news2ImageButton.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(1).name));
- news2Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(1).name));
- }
- else
- {
- //news2ImageButton.setImageResource(R.drawable.transparent);
- news2Button.setText(R.string.news_record_not_available);
- //news2ImageButton.setOnClickListener(null);
- news2Button.setOnClickListener(null);
- }
-
- if (newsJournal.articleArr.size() > 2)
- {
- //ImageManager.getInstance().ApplyImageToImageView(news3ImageButton, newsJournal.articleArr.get(2).previewImageUrl);
- news3Button.setText(newsJournal.articleArr.get(2).title);
- //news3ImageButton.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(2).name));
- news3Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(2).name));
- }
- else
- {
- //news3ImageButton.setImageResource(R.drawable.transparent);
- news3Button.setText(R.string.news_record_not_available);
- //news3ImageButton.setOnClickListener(null);
- news3Button.setOnClickListener(null);
- }
+ progressBar.setVisibility(View.GONE);
+
+ newsJournal = journal;
+
+ Button news1Button = (Button) header.findViewById(R.id.news1Button);
+ Button news2Button = (Button) header.findViewById(R.id.news2Button);
+ Button news3Button = (Button) header.findViewById(R.id.news3Button);
+
+ if (newsJournal.articleArr.size() > 0)
+ {
+
+ news1Button.setText(newsJournal.articleArr.get(0).title);
+
+ news1Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(0).name));
+ } else
+ {
+
+ news1Button.setText(R.string.news_record_not_available);
+
+ news1Button.setOnClickListener(null);
+ }
+
+ if (newsJournal.articleArr.size() > 1)
+ {
+
+ news2Button.setText(newsJournal.articleArr.get(1).title);
+
+ news2Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(1).name));
+ } else
+ {
+
+ news2Button.setText(R.string.news_record_not_available);
+ news2Button.setOnClickListener(null);
+ }
+
+ if (newsJournal.articleArr.size() > 2)
+ {
+
+ news3Button.setText(newsJournal.articleArr.get(2).title);
+ news3Button.setOnClickListener(new NewsButtonOnClickListener(newsJournal.articleArr.get(2).name));
+ } else
+ {
-
-
- listAdapter.notifyDataSetChanged();
-
+ news3Button.setText(R.string.news_record_not_available);
+ news3Button.setOnClickListener(null);
+ }
+
+ listAdapter.notifyDataSetChanged();
+
}
-
+
}
-
+
public void RefreshAdapter()
{
listAdapter.notifyDataSetChanged();
}
-
+
public void RestoreJournalList()
{
journalList = new ArrayList();
-
+
if (databaseGetJournalListTask != null)
{
databaseGetJournalListTask.cancel(false);
}
-
+
databaseGetJournalListTask = new DatabaseGetJournalListTask();
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
-
+
databaseGetJournalListTask.execute("featured");
}
-
+
public void SetJournalList(ArrayList journalList)
{
databaseGetJournalListTask = null;
-
+
progressBar.setVisibility(View.GONE);
-
+
this.journalList = journalList;
-
+
listAdapter.notifyDataSetChanged();
}
-
-
- public class ListAdapter extends BaseAdapter {
- private Context mContext;
- public ListAdapter(Context c) {
- mContext = c;
- }
+ public class ListAdapter extends BaseAdapter
+ {
+ private Context mContext;
- public int getCount() {
- return journalList.size();
- }
+ public ListAdapter(Context c)
+ {
+ mContext = c;
+ }
- public Object getItem(int position) {
- return null;
- }
+ public int getCount()
+ {
+ return journalList.size();
+ }
- public long getItemId(int position) {
- return 0;
- }
+ public Object getItem(int position)
+ {
+ return null;
+ }
- // 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
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.main_page_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
- TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
-
- Button button = (Button) view.findViewById(R.id.button);
-
- ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
-
- HListView hListView = (HListView) view.findViewById(R.id.hListView);
-
- hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
+ public long getItemId(int position)
+ {
+ return 0;
+ }
- textView.setText(journalList.get(position).title);
-
- if (journalList.get(position).description.length() > 0)
- {
- descriptionTextView.setText(journalList.get(position).description);
-
- descriptionTextView.setVisibility(View.VISIBLE);
- }
- else
- {
- descriptionTextView.setVisibility(View.GONE);
- }
-
-
-
- button.setText(R.string.see_all);
+ // create a new ImageView for each item referenced by the Adapter
+ @SuppressLint("InflateParams")
+ public View getView(final int position, View convertView, ViewGroup parent)
+ {
- button.setOnClickListener(new OnClickListener()
- {
+ 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.main_page_list_element, null);
+
+ } else
+ {
+ view = convertView;
+ }
+
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+ TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
+
+ Button button = (Button) view.findViewById(R.id.button);
+
+ ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
+
+ HListView hListView = (HListView) view.findViewById(R.id.hListView);
+
+ hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
+
+ textView.setText(journalList.get(position).title);
+
+ if (journalList.get(position).description.length() > 0)
+ {
+ descriptionTextView.setText(journalList.get(position).description);
+
+ descriptionTextView.setVisibility(View.VISIBLE);
+ } else
+ {
+ descriptionTextView.setVisibility(View.GONE);
+ }
+
+ button.setText(R.string.see_all);
+
+ button.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
- if (databaseGetJournalTask != null)
- {
- databaseGetJournalTask.cancel(false);
+ if (databaseGetJournalTask != null)
+ {
+ databaseGetJournalTask.cancel(false);
+ }
+ MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_BACK_TO_MAINFRAGMENT);
}
- MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_TO_MAINFRAGMENT);
- }
- });
-
- imageButton.setOnClickListener(new OnClickListener()
- {
+ });
+
+ imageButton.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
- if (databaseGetJournalTask != null)
- {
- databaseGetJournalTask.cancel(false);
+ if (databaseGetJournalTask != null)
+ {
+ databaseGetJournalTask.cancel(false);
+ }
+ MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_BACK_TO_MAINFRAGMENT);
}
- MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_TO_MAINFRAGMENT);
- }
- });
-
-
- return view;
- }
+ });
+
+ return view;
+ }
}
-
-
+
public class NewsButtonOnClickListener implements OnClickListener
{
-
+
String articleName;
-
+
public NewsButtonOnClickListener(String articleName)
{
this.articleName = articleName;
@@ -373,12 +356,11 @@ public class MainPageFragment extends Fragment {
databaseGetJournalTask.cancel(false);
databaseGetJournalTask = null;
}
- //MainActivity.getInstance().OpenNewsRecordScreen(articleName, MainActivity.TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT);
- MainActivity.getInstance().OpenArticleScreen(articleName, MainActivity.TAG_TO_MAINFRAGMENT);
-
+ MainActivity.getInstance().OpenArticleScreen(articleName, MainActivity.TAG_BACK_TO_MAINFRAGMENT);
+
}
-
+
}
-
+
}
diff --git a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
index 74b9b0e..140d5ab 100644
--- a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
+++ b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java
@@ -1,12 +1,8 @@
package fishrungames.bashgid;
-import java.util.ArrayList;
-
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
-import fishrungames.bashgid.core.HtmlDownloadManager;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
-import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
import fishrungames.networkutils.ImageManager;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -17,266 +13,139 @@ 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 class MainPageHListViewAdapters
+{
- public PhotoAlbumElementAdapter(Context c, AlbumFullData albumFullData) {
- this.mContext = c;
- this.albumFullData = albumFullData;
+ public static class PhotoAlbumElementAdapter extends BaseAdapter
+ {
- //localHtmlList = HtmlDownloadManager.getInstance().getGlobalHtmlList();
- }
+ private Context mContext;
- public int getCount() {
- return albumFullData.photoRecordArr.size();
- }
+ AlbumFullData albumFullData;
- public Object getItem(int position) {
- return null;
- }
+ public PhotoAlbumElementAdapter(Context c, AlbumFullData albumFullData)
+ {
+ this.mContext = c;
+ this.albumFullData = albumFullData;
+ }
- public long getItemId(int position) {
- return 0;
- }
+ public int getCount()
+ {
+ return albumFullData.photoRecordArr.size();
+ }
- // 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 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;
+ }
+
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ ImageManager.getInstance().ApplyImageToImageView(imageView, albumFullData.photoRecordArr.get(position).imageUrl);
+
+ return view;
+ }
}
-
-public static class JournalElementAdapter extends BaseAdapter {
-
- private Context mContext;
- //String albumName;
- JournalSemiFullData journal;
- //ArrayList localHtmlList;
- public JournalElementAdapter(Context c, JournalSemiFullData journal) {
- this.mContext = c;
- this.journal = journal;
+ public static class JournalElementAdapter extends BaseAdapter
+ {
- //localHtmlList = HtmlDownloadManager.getInstance().getGlobalHtmlList();
- }
+ private Context mContext;
- public int getCount() {
- return journal.articleArr.size();
- }
+ JournalSemiFullData journal;
- public Object getItem(int position) {
- return null;
- }
+ public JournalElementAdapter(Context c, JournalSemiFullData journal)
+ {
+ this.mContext = c;
+ this.journal = journal;
- public long getItemId(int position) {
- return 0;
- }
+ }
- // 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
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.simple_hview_list_element, 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);
+ public int getCount()
+ {
+ return journal.articleArr.size();
+ }
-
- textView.setText(journal.articleArr.get(position).title);
-
- subTextView.setText(journal.articleArr.get(position).dateTime.toString());
-
- String imageUrl = journal.articleArr.get(position).previewImageUrl;
-
- ImageManager.getInstance().ApplyImageToImageView(imageButton, imageUrl);
-
- imageButton.setOnClickListener(new OnClickListener()
- {
+ 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(final 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.simple_hview_list_element, 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);
+
+ textView.setText(journal.articleArr.get(position).title);
+
+ subTextView.setText(journal.articleArr.get(position).dateTime.toString());
+
+ String imageUrl = journal.articleArr.get(position).previewImageUrl;
+
+ ImageManager.getInstance().ApplyImageToImageView(imageButton, imageUrl);
+
+ imageButton.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
- MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_CATALOGFRAGMENT_TO_ARTICLEFRAGMENT);
+ MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name,
+ MainActivity.TAG_BACK_TO_MAINFRAGMENT);
}
-
- });
-
- return view;
- }
+
+ });
+
+ return view;
+ }
}
-
-/*
- public static class SimpleElementAdapter extends BaseAdapter {
-
- private Context mContext;
- ArrayList localHtmlList;
-
- public SimpleElementAdapter(Context c) {
- mContext = c;
-
- localHtmlList = HtmlDownloadManager.getInstance().getGlobalHtmlList();
- }
-
- public int getCount() {
- return localHtmlList.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.simple_hview_list_element, 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);
-
- textView.setText(localHtmlList.get(position).title);
-
- subTextView.setText("");
-
- ImageManager.getInstance().ApplyImageToImageView(imageButton, localHtmlList.get(position).topicImg);
-
- imageButton.setOnClickListener(new ContentButtonOnClickListener(localHtmlList.get(position)));
-
- return view;
- }
-
- }*/
-
-/*
-
-public static class DarkenElementAdapter extends BaseAdapter {
-
- String [] textsArray;
- String [] subTextsArray;
- int [] imgIdArray;
-
- private Context mContext;
-
- public DarkenElementAdapter(Context c, String [] textsArray, String [] subTextsArray, int [] imgIdArray) {
- mContext = c;
- this.textsArray = textsArray;
- this.subTextsArray = subTextsArray;
- this.imgIdArray = imgIdArray;
-
- }
-
- public int getCount() {
- return textsArray.length;
- }
-
- 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.darken_hview_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- TextView subTextView = (TextView) view.findViewById(R.id.subTextView);
-
- LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.linearLayout);
-
- textView.setText(textsArray[position]);
-
- subTextView.setText(subTextsArray[position]);
-
- linearLayout.setBackgroundResource(imgIdArray[position]);
-
- return view;
- }
-
- }*/
-
-
-
}
diff --git a/android/src/fishrungames/bashgid/MapHolderFragment.java b/android/src/fishrungames/bashgid/MapHolderFragment.java
deleted file mode 100644
index d0387a0..0000000
--- a/android/src/fishrungames/bashgid/MapHolderFragment.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package fishrungames.bashgid;
-
-
-import com.google.android.gms.maps.GoogleMap;
-
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
-import com.google.android.gms.maps.OnMapReadyCallback;
-import com.google.android.gms.maps.SupportMapFragment;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.Marker;
-import com.google.android.gms.maps.model.MarkerOptions;
-
-import fishrungames.bashgid.core.LocationHolder;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-
-public class MapHolderFragment extends Fragment implements OnMapReadyCallback
-{
-
- GoogleMap mMap = null;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- View rootView = inflater.inflate(R.layout.fragment_map_page, container, false);
-
- SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map);
-
- mapFragment.getMapAsync(this);
-
-
- return rootView;
- }
-
- @Override
- public void onMapReady(GoogleMap map)
- {
- mMap = map;
- mMap.setMyLocationEnabled(true);
- mMap.getUiSettings().setRotateGesturesEnabled(false);
-
- mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE), LocationHolder.CONST_UFA_ZOOM));
-
-
- LatLng ufaPanoramas = new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
- /*Marker marker =*/ mMap.addMarker(new MarkerOptions()
- .position(ufaPanoramas)
- .title("Ufa")
- .snippet("City center"));
-
-
- mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener()
- {
-
- @Override
- public void onInfoWindowClick(Marker marker)
- {
- MainActivity.getInstance().OpenStreetViewScreen(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
- }
-
- });
-
-
- }
-}
diff --git a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
index 53c44c0..9a6c173 100644
--- a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
+++ b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java
@@ -1,6 +1,5 @@
package fishrungames.bashgid;
-
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
@@ -29,371 +28,406 @@ import android.widget.ListView;
import android.widget.TextView;
/**
- * Fragment used for managing interactions for and presentation of a navigation drawer.
- * See the
- * design guidelines for a complete explanation of the behaviors implemented here.
+ * Fragment used for managing interactions for and presentation of a navigation
+ * drawer. See the design guidelines for a complete explanation of the behaviors
+ * implemented here.
*/
-public class NavigationDrawerFragment extends Fragment {
+public class NavigationDrawerFragment extends Fragment
+{
- /**
- * Remember the position of the selected item.
- */
- private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
+ /**
+ * Remember the position of the selected item.
+ */
+ private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
- /**
- * Per the design guidelines, you should show the drawer on launch until the user manually
- * expands it. This shared preference tracks this.
- */
- private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
+ /**
+ * Per the design guidelines, you should show the drawer on launch until the
+ * user manually expands it. This shared preference tracks this.
+ */
+ private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
- /**
- * A pointer to the current callbacks instance (the Activity).
- */
- private NavigationDrawerCallbacks mCallbacks;
+ /**
+ * A pointer to the current callbacks instance (the Activity).
+ */
+ private NavigationDrawerCallbacks mCallbacks;
- /**
- * Helper component that ties the action bar to the navigation drawer.
- */
- private ActionBarDrawerToggle mDrawerToggle;
+ /**
+ * Helper component that ties the action bar to the navigation drawer.
+ */
+ private ActionBarDrawerToggle mDrawerToggle;
- private DrawerLayout mDrawerLayout;
- private ListView mDrawerListView;
- private View mFragmentContainerView;
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerListView;
+ private View mFragmentContainerView;
- private int mCurrentSelectedPosition = 0;
- private boolean mFromSavedInstanceState;
- private boolean mUserLearnedDrawer;
-
- private DrawerAdapter drawerAdapter;
+ private int mCurrentSelectedPosition = 0;
+ private boolean mFromSavedInstanceState;
+ private boolean mUserLearnedDrawer;
- public NavigationDrawerFragment() {
- }
+ private DrawerAdapter drawerAdapter;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public NavigationDrawerFragment()
+ {
+ }
- // Read in the flag indicating whether or not the user has demonstrated awareness of the
- // drawer. See PREF_USER_LEARNED_DRAWER for details.
- //SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
-
- //Don't need this shit
- //mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
- mUserLearnedDrawer = true;
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
- if (savedInstanceState != null) {
- mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
- mFromSavedInstanceState = true;
- }
+ // Read in the flag indicating whether or not the user has demonstrated
+ // awareness of the
+ // drawer. See PREF_USER_LEARNED_DRAWER for details.
+ // SharedPreferences sp =
+ // PreferenceManager.getDefaultSharedPreferences(getActivity());
- // Select either the default item (0) or the last selected item.
- selectItem(mCurrentSelectedPosition);
-
- }
+ // Don't need this shit
+ // mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
+ mUserLearnedDrawer = true;
- @Override
- public void onActivityCreated (Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- // Indicate that this fragment would like to influence the set of actions in the action bar.
- setHasOptionsMenu(true);
- }
+ if (savedInstanceState != null)
+ {
+ mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
+ mFromSavedInstanceState = true;
+ }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mDrawerListView = (ListView) inflater.inflate(
- R.layout.fragment_navigation_drawer, container, false);
- mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- selectItem(position);
- }
- });
-
-
- drawerAdapter = new DrawerAdapter(getActivity());
-
- mDrawerListView.setAdapter(drawerAdapter);
-
- mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
- return mDrawerListView;
- }
+ // Select either the default item (0) or the last selected item.
+ selectItem(mCurrentSelectedPosition);
- public boolean isDrawerOpen() {
- return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView);
- }
-
+ }
- public void EnableDrawer()
- {
- mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
- }
-
-
- /**
- * Users of this fragment must call this method to set up the navigation drawer interactions.
- *
- * @param fragmentId The android:id of this fragment in its activity's layout.
- * @param drawerLayout The DrawerLayout containing this fragment's UI.
- */
- public void setUp(int fragmentId, DrawerLayout drawerLayout) {
- mFragmentContainerView = getActivity().findViewById(fragmentId);
- mDrawerLayout = drawerLayout;
-
-
- // set a custom shadow that overlays the main content when the drawer opens
- mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
- // set up the drawer's list view with items and click listener
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+ // Indicate that this fragment would like to influence the set of
+ // actions in the action bar.
+ setHasOptionsMenu(true);
+ }
- ActionBar actionBar = getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
+ mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
+ {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ selectItem(position);
+ }
+ });
- // ActionBarDrawerToggle ties together the the proper interactions
- // between the navigation drawer and the action bar app icon.
+ drawerAdapter = new DrawerAdapter(getActivity());
- mDrawerToggle = new ActionBarDrawerToggle(
- getActivity(), /* host Activity */
- mDrawerLayout, /* DrawerLayout object */
- R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
- R.string.navigation_drawer_close /* "close drawer" description for accessibility */
- ) {
- @Override
- public void onDrawerClosed(View drawerView) {
- super.onDrawerClosed(drawerView);
- if (!isAdded()) {
- return;
- }
+ mDrawerListView.setAdapter(drawerAdapter);
- //getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
- }
+ mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
+ return mDrawerListView;
+ }
- @Override
- public void onDrawerOpened(View drawerView) {
- super.onDrawerOpened(drawerView);
- if (!isAdded()) {
- return;
- }
+ public boolean isDrawerOpen()
+ {
+ return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView);
+ }
- if (!mUserLearnedDrawer) {
- // The user manually opened the drawer; store this flag to prevent auto-showing
- // the navigation drawer automatically in the future.
- mUserLearnedDrawer = true;
- SharedPreferences sp = PreferenceManager
- .getDefaultSharedPreferences(getActivity());
- sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).commit();
- }
+ public void EnableDrawer()
+ {
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
+ }
- //getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
- }
- };
+ /**
+ * Users of this fragment must call this method to set up the navigation
+ * drawer interactions.
+ *
+ * @param fragmentId
+ * The android:id of this fragment in its activity's layout.
+ * @param drawerLayout
+ * The DrawerLayout containing this fragment's UI.
+ */
+ public void setUp(int fragmentId, DrawerLayout drawerLayout)
+ {
+ mFragmentContainerView = getActivity().findViewById(fragmentId);
+ mDrawerLayout = drawerLayout;
- // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
- // per the navigation drawer design guidelines.
- if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
- mDrawerLayout.openDrawer(mFragmentContainerView);
- }
+ // set a custom shadow that overlays the main content when the drawer
+ // opens
+ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
+ // set up the drawer's list view with items and click listener
- // Defer code dependent on restoration of previous instance state.
- mDrawerLayout.post(new Runnable() {
- @Override
- public void run() {
- mDrawerToggle.syncState();
- }
- });
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
- mDrawerLayout.setDrawerListener(mDrawerToggle);
-
- mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
-
- drawerAdapter.notifyDataSetChanged();
-
- }
+ // ActionBarDrawerToggle ties together the the proper interactions
+ // between the navigation drawer and the action bar app icon.
- private void selectItem(int position) {
- mCurrentSelectedPosition = position;
- if (mDrawerListView != null) {
- mDrawerListView.setItemChecked(position, true);
- }
- if (mDrawerLayout != null) {
- mDrawerLayout.closeDrawer(mFragmentContainerView);
- }
- if (mCallbacks != null) {
- mCallbacks.onNavigationDrawerItemSelected(position);
- }
- }
+ mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
+ mDrawerLayout, /* DrawerLayout object */
+ R.string.navigation_drawer_open, /*
+ * "open drawer" description for
+ * accessibility
+ */
+ R.string.navigation_drawer_close /*
+ * "close drawer" description for
+ * accessibility
+ */
+ )
+ {
+ @Override
+ public void onDrawerClosed(View drawerView)
+ {
+ super.onDrawerClosed(drawerView);
+ if (!isAdded())
+ {
+ return;
+ }
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- try {
- mCallbacks = (NavigationDrawerCallbacks) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
- }
- }
+ // getActivity().supportInvalidateOptionsMenu(); // calls
+ // onPrepareOptionsMenu()
+ }
- @Override
- public void onDetach() {
- super.onDetach();
- mCallbacks = null;
- }
+ @Override
+ public void onDrawerOpened(View drawerView)
+ {
+ super.onDrawerOpened(drawerView);
+ if (!isAdded())
+ {
+ return;
+ }
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
- }
+ if (!mUserLearnedDrawer)
+ {
+ // The user manually opened the drawer; store this flag to
+ // prevent auto-showing
+ // the navigation drawer automatically in the future.
+ mUserLearnedDrawer = true;
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).commit();
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- // Forward the new configuration the drawer toggle component.
- mDrawerToggle.onConfigurationChanged(newConfig);
- }
+ // getActivity().supportInvalidateOptionsMenu(); // calls
+ // onPrepareOptionsMenu()
+ }
+ };
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- // If the drawer is open, show the global app actions in the action bar. See also
- // showGlobalContextActionBar, which controls the top-left area of the action bar.
-
- showGlobalContextActionBar();
-
- super.onCreateOptionsMenu(menu, inflater);
-
- }
+ // If the user hasn't 'learned' about the drawer, open it to introduce
+ // them to the drawer,
+ // per the navigation drawer design guidelines.
+ if (!mUserLearnedDrawer && !mFromSavedInstanceState)
+ {
+ mDrawerLayout.openDrawer(mFragmentContainerView);
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- //Xperimental -- check if we need options or not
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
-
- if (item.getItemId() == R.id.action_search) {
+ // Defer code dependent on restoration of previous instance state.
+ mDrawerLayout.post(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mDrawerToggle.syncState();
+ }
+ });
- return true;
- }
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
- return super.onOptionsItemSelected(item);
- }
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
- /**
- * Per the navigation drawer design guidelines, updates the action bar to show the global app
- * 'context', rather than just what's in the current screen.
- */
- private void showGlobalContextActionBar() {
- ActionBar actionBar = getActionBar();
- actionBar.setDisplayShowTitleEnabled(true);
- //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- actionBar.setTitle(R.string.app_name);
- }
+ drawerAdapter.notifyDataSetChanged();
- private ActionBar getActionBar() {
- return ((ActionBarActivity) getActivity()).getSupportActionBar();
- }
+ }
- /**
- * Callbacks interface that all activities using this fragment must implement.
- */
- public static interface NavigationDrawerCallbacks {
- /**
- * Called when an item in the navigation drawer is selected.
- */
- void onNavigationDrawerItemSelected(int position);
- }
-
-
+ private void selectItem(int position)
+ {
+ mCurrentSelectedPosition = position;
+ if (mDrawerListView != null)
+ {
+ mDrawerListView.setItemChecked(position, true);
+ }
+ if (mDrawerLayout != null)
+ {
+ mDrawerLayout.closeDrawer(mFragmentContainerView);
+ }
+ if (mCallbacks != null)
+ {
+ mCallbacks.onNavigationDrawerItemSelected(position);
+ }
+ }
- public class DrawerAdapter extends BaseAdapter {
- private Context mContext;
+ @Override
+ public void onAttach(Activity activity)
+ {
+ super.onAttach(activity);
+ try
+ {
+ mCallbacks = (NavigationDrawerCallbacks) activity;
+ } catch (ClassCastException e)
+ {
+ throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
+ }
+ }
-
- final int [] titles = {
- R.string.drawer_header,
- R.string.drawer_guide,
- R.string.drawer_news,
- R.string.drawer_catalogue,
- R.string.drawer_map,
- R.string.drawer_video,
- R.string.drawer_photo_gallery,
- //R.string.drawer_books,
- R.string.drawer_for_investor,
- R.string.drawer_settings
- };
-
- final int [] iconIds = {
- R.drawable.drawer_bashgid_logo,
- R.drawable.drawer_agenda,
- R.drawable.drawer_news,
- R.drawable.drawer_bookmark,
- R.drawable.drawer_pushpin,
- R.drawable.drawer_tv,
- R.drawable.drawer_photography,
- //R.drawable.drawer_books,
- R.drawable.drawer_id,
- R.drawable.drawer_gear
- };
+ @Override
+ public void onDetach()
+ {
+ super.onDetach();
+ mCallbacks = null;
+ }
- public DrawerAdapter(Context c) {
- mContext = c;
- }
+ @Override
+ public void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
+ }
- public int getCount() {
- return titles.length;
- }
+ @Override
+ public void onConfigurationChanged(Configuration newConfig)
+ {
+ super.onConfigurationChanged(newConfig);
+ // Forward the new configuration the drawer toggle component.
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
- public Object getItem(int position) {
- return null;
- }
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
+ {
+ // If the drawer is open, show the global app actions in the action bar.
+ // See also
+ // showGlobalContextActionBar, which controls the top-left area of the
+ // action bar.
- public long getItemId(int position) {
- return 0;
- }
+ showGlobalContextActionBar();
- // create a new ImageView for each item referenced by the Adapter
- 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.drawer_list_element, null);
-
-
- } else {
- view = convertView;
- }
-
- TextView textView = (TextView) view.findViewById(R.id.dateTextView);
-
- textView.setText(titles[position]);
-
- ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
-
- imageView.setImageResource(iconIds[position]);
-
- if (position == 0)
- {
- LayoutParams params = imageView.getLayoutParams();
- params.width = 96;
- params.height = 96;
- imageView.setLayoutParams(params);
-
- textView.setTypeface(null, Typeface.BOLD);
- }
- else
- {
- LayoutParams params = imageView.getLayoutParams();
- params.width = 48;
- params.height = 48;
- imageView.setLayoutParams(params);
-
- textView.setTypeface(null, Typeface.NORMAL);
- }
-
- return view;
- }
+ super.onCreateOptionsMenu(menu, inflater);
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+
+ // Xperimental -- check if we need options or not
+ if (mDrawerToggle.onOptionsItemSelected(item))
+ {
+ return true;
+ }
+
+ if (item.getItemId() == R.id.action_search)
+ {
+
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * Per the navigation drawer design guidelines, updates the action bar to
+ * show the global app 'context', rather than just what's in the current
+ * screen.
+ */
+ private void showGlobalContextActionBar()
+ {
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayShowTitleEnabled(true);
+ // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ actionBar.setTitle(R.string.app_name);
+ }
+
+ private ActionBar getActionBar()
+ {
+ return ((ActionBarActivity) getActivity()).getSupportActionBar();
+ }
+
+ /**
+ * Callbacks interface that all activities using this fragment must
+ * implement.
+ */
+ public static interface NavigationDrawerCallbacks
+ {
+ /**
+ * Called when an item in the navigation drawer is selected.
+ */
+ void onNavigationDrawerItemSelected(int position);
+ }
+
+ public class DrawerAdapter extends BaseAdapter
+ {
+ private Context mContext;
+
+ final int[] titles = { R.string.drawer_header, R.string.drawer_guide, R.string.drawer_news, R.string.drawer_catalogue, R.string.drawer_map,
+ R.string.drawer_video, R.string.drawer_photo_gallery, R.string.drawer_for_investor, R.string.drawer_settings };
+
+ final int[] iconIds = { R.drawable.drawer_bashgid_logo, R.drawable.drawer_agenda, R.drawable.drawer_news, R.drawable.drawer_bookmark,
+ R.drawable.drawer_pushpin, R.drawable.drawer_tv, R.drawable.drawer_photography, R.drawable.drawer_id, R.drawable.drawer_gear };
+
+ public DrawerAdapter(Context c)
+ {
+ mContext = c;
+ }
+
+ public int getCount()
+ {
+ return titles.length;
+ }
+
+ 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
+ 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.drawer_list_element, null);
+
+ } else
+ {
+ view = convertView;
+ }
+
+ TextView textView = (TextView) view.findViewById(R.id.dateTextView);
+
+ textView.setText(titles[position]);
+
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ imageView.setImageResource(iconIds[position]);
+
+ int drawerImageSize = (int) mContext.getResources().getDimension(R.dimen.drawer_image_size);
+
+ if (position == 0)
+ {
+ LayoutParams params = imageView.getLayoutParams();
+ params.width = drawerImageSize * 2;
+ params.height = drawerImageSize * 2;
+ imageView.setLayoutParams(params);
+
+ textView.setTypeface(null, Typeface.BOLD);
+ } else
+ {
+ LayoutParams params = imageView.getLayoutParams();
+ params.width = drawerImageSize;
+ params.height = drawerImageSize;
+ imageView.setLayoutParams(params);
+
+ textView.setTypeface(null, Typeface.NORMAL);
+ }
+
+ return view;
+ }
}
}
diff --git a/android/src/fishrungames/bashgid/NewsListFragment.java b/android/src/fishrungames/bashgid/NewsListFragment.java
index bbf942a..2c92d56 100644
--- a/android/src/fishrungames/bashgid/NewsListFragment.java
+++ b/android/src/fishrungames/bashgid/NewsListFragment.java
@@ -1,130 +1,126 @@
package fishrungames.bashgid;
-
-
import java.util.Collections;
-import java.util.LinkedHashSet;
+
import java.util.Set;
import java.util.TreeSet;
-import fishrungames.networkutils.ImageManager;
import fishrungames.bashgid.core.ArticleManager;
-import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
import fishrungames.bashgid.core.DatabaseGetJournalTask;
import fishrungames.bashgid.core.JournalManager;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
-import fishrungames.bashgid.core.NewsManager.NewsRecord;
+
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.View.OnClickListener;
+
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.AdapterView;
-import android.widget.ImageView;
+
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
-
public class NewsListFragment extends Fragment
{
ListView listView;
-
+
ListAdapter listAdapter;
-
+
JournalSemiFullData journal;
-
+
ProgressBar progressBar;
-
+
TextView footerTextView;
-
+
DatabaseGetJournalTask databaseGetJournalTask = null;
-
- @SuppressLint("InflateParams") @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
+
+ @SuppressLint("InflateParams")
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
RestoreJournal();
-
+
View rootView = inflater.inflate(R.layout.fragment_news_page, container, false);
-
+
listView = (ListView) rootView.findViewById(R.id.listView);
-
+
View header = inflater.inflate(R.layout.news_page_list_header, null);
-
+
listView.addHeaderView(header);
-
- progressBar = (ProgressBar)header.findViewById(R.id.progressBar);
-
+
+ progressBar = (ProgressBar) header.findViewById(R.id.progressBar);
+
progressBar.setVisibility(View.VISIBLE);
-
View footer = inflater.inflate(R.layout.news_page_list_footer, null);
-
+
listView.addFooterView(footer);
-
- footerTextView = (TextView)footer.findViewById(R.id.footerTextView);
-
+
+ footerTextView = (TextView) footer.findViewById(R.id.footerTextView);
+
listAdapter = new ListAdapter(getActivity());
-
+
listView.setAdapter(listAdapter);
-
-
- listView.setOnItemClickListener(new OnItemClickListener(){
+
+ listView.setOnItemClickListener(new OnItemClickListener()
+ {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
- //Add position + 1, because first element of list is always title
+ // Add position + 1, because first element of list is always
+ // title
if (position == journal.articleArr.size() + 1)
{
footerTextView.setText(R.string.news_are_loading);
LoadMoreNews();
- }
- else if (position > 0)
+ } else if (position > 0)
{
- MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position-1).name, MainActivity.TAG_TO_MAINFRAGMENT);
+ MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position - 1).name, MainActivity.TAG_BACK_TO_NEWSLISTFRAGMENT);
}
-
+
}
-
+
});
-
+
return rootView;
}
-
+
@Override
- public void onDestroyView ()
+ public void onDestroyView()
{
-
+
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
databaseGetJournalTask = null;
}
-
+
super.onDestroyView();
}
-
+
public void RefreshAdapter()
{
listAdapter.notifyDataSetChanged();
}
-
+
void RestoreJournal()
{
journal = JournalManager.CreateEmptyJournal();
-
+
RefreshJournal();
}
-
+
void RefreshJournal()
{
databaseGetJournalTask = new DatabaseGetJournalTask();
@@ -132,119 +128,106 @@ public class NewsListFragment extends Fragment
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
Bundle bundle = new Bundle();
-
+
bundle.putString("journalName", "news");
-
+
bundle.putInt("count", 20);
databaseGetJournalTask.execute(bundle);
}
-
+
void LoadMoreNews()
{
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
}
-
+
databaseGetJournalTask = new DatabaseGetJournalTask();
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
Bundle bundle = new Bundle();
-
+
bundle.putString("journalName", "news");
-
- bundle.putString("startAfterArticleName", journal.articleArr.get(journal.articleArr.size()-1).name);
-
+
+ bundle.putString("startAfterArticleName", journal.articleArr.get(journal.articleArr.size() - 1).name);
+
bundle.putInt("count", 10);
databaseGetJournalTask.execute(bundle);
}
-
+
public void SetJournal(JournalSemiFullData journal)
{
progressBar.setVisibility(View.GONE);
-
-
+
this.journal.articleArr.addAll(journal.articleArr);
-
+
Set articleSet = new TreeSet(new ArticleManager.ArticleShortDataSortComparator());
articleSet.addAll(this.journal.articleArr);
this.journal.articleArr.clear();
this.journal.articleArr.addAll(articleSet);
-
+
Collections.sort(this.journal.articleArr, new ArticleManager.ArticleShortDataTimeSortComparator());
-
- //this.journal.previewImageArr.addAll(journal.previewImageArr);
-
-
+
footerTextView.setText(R.string.news_load_more);
-
+
listAdapter.notifyDataSetChanged();
-
- }
-
-
- 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.news_page_list_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());
-
- /*ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
-
- if (journal.articleArr.get(position).previewImageUrl != null)
- {
-
-
- ImageManager.getInstance().ApplyImageToImageView(imageView, journal.articleArr.get(position).previewImageUrl);
-
- }
- else
- {
- imageView.setImageResource(R.drawable.transparent);
- }*/
- return view;
- }
}
-
+ 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.news_page_list_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());
+
+ return view;
+ }
+
+ }
+
}
diff --git a/android/src/fishrungames/bashgid/NewsRecordFragment.java b/android/src/fishrungames/bashgid/NewsRecordFragment.java
deleted file mode 100644
index 030a4ae..0000000
--- a/android/src/fishrungames/bashgid/NewsRecordFragment.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package fishrungames.bashgid;
-
-
-import fishrungames.networkutils.ImageManager;
-import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.WebView;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-
-public class NewsRecordFragment extends ArticleFragment
-{
-
- TextView titleTextView;
-
- WebView webView;
-
- public NewsRecordFragment()
- {
- super();
- }
-
- public NewsRecordFragment(String articleName)
- {
- super(articleName);
- }
-
- public NewsRecordFragment(ArticleFullData article)
- {
- super(article);
- }
-
- @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_news_record_page, container, false);
-
- titleTextView = (TextView) rootView.findViewById(R.id.titleTextView);
-
- webView = (WebView) rootView.findViewById(R.id.webView);
-
- webView.getSettings().setJavaScriptEnabled(false);
-
- return rootView;
- }
-
- @Override
- public void SetArticle(ArticleFullData article)
- {
- this.article = article;
-
- titleTextView.setText(article.title);
-
- String htmlCode = "" + article.content + "";
-
- webView.loadDataWithBaseURL(null, htmlCode, "text/html", "UTF-8", null);
-
- }
-
-}
diff --git a/android/src/fishrungames/bashgid/OsmMapHolderFragment.java b/android/src/fishrungames/bashgid/OsmMapHolderFragment.java
index 6052ad1..352139f 100644
--- a/android/src/fishrungames/bashgid/OsmMapHolderFragment.java
+++ b/android/src/fishrungames/bashgid/OsmMapHolderFragment.java
@@ -128,7 +128,6 @@ public class OsmMapHolderFragment extends Fragment
DetailsOverlayItem item = mOverlayItems.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.getInstance());
dialog.setTitle(item.getTitle());
- // dialog.setMessage(item.getSnippet());
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -136,8 +135,8 @@ public class OsmMapHolderFragment extends Fragment
ImageView image = (ImageView) dialogInnerView.findViewById(R.id.imageView);
TextView textView = (TextView) dialogInnerView.findViewById(R.id.addressTextView);
- TextView hintTextView = (TextView) dialogInnerView.findViewById(R.id.hintTextView);
-
+ TextView hintTextView = (TextView) dialogInnerView.findViewById(R.id.hintTextView);
+
Button button = (Button) dialogInnerView.findViewById(R.id.button);
ImageManager.getInstance().ApplyImageToImageView(image, item.getSnippet());
@@ -217,8 +216,14 @@ public class OsmMapHolderFragment extends Fragment
{
public void onClick(DialogInterface dialog, int id)
{
- MainActivity.getInstance().SetLastMapFilterName(journalName);
- MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT);
+ if (journalName != null && journalName.length() > 0)
+ {
+ MainActivity.getInstance().SetLastMapFilterName(journalName);
+ MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_BACK_TO_MAPFRAGMENT);
+ } else
+ {
+ MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_BACK_TO_MAINFRAGMENT);
+ }
}
});
@@ -347,8 +352,6 @@ public class OsmMapHolderFragment extends Fragment
outState.putInt("filterType", filterType);
}
-
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
@@ -414,10 +417,8 @@ public class OsmMapHolderFragment extends Fragment
{
}
-
});
-
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
{
titleTextView.setText(R.string.map_is_loading);
@@ -429,7 +430,7 @@ public class OsmMapHolderFragment extends Fragment
titleTextView.setText(R.string.map_is_loaded);
RestoreGeoJournals();
}
-
+
return rootView;
}
@@ -446,7 +447,6 @@ public class OsmMapHolderFragment extends Fragment
void RestoreJournal()
{
- // journal = JournalManager.CreateEmptyJournal();
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
diff --git a/android/src/fishrungames/bashgid/PhotoAlbumFragment.java b/android/src/fishrungames/bashgid/PhotoAlbumFragment.java
index e0bf509..65ae3d1 100644
--- a/android/src/fishrungames/bashgid/PhotoAlbumFragment.java
+++ b/android/src/fishrungames/bashgid/PhotoAlbumFragment.java
@@ -83,7 +83,7 @@ public class PhotoAlbumFragment extends Fragment
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
MainActivity.getInstance().SetLastAlbumName(albumName);
- MainActivity.getInstance().OpenPhotoScreen(album, position, MainActivity.TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT);
+ MainActivity.getInstance().OpenPhotoScreen(album, position, MainActivity.TAG_BACK_TO_ALBUMFRAGMENT);
}
diff --git a/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java b/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java
index 8683209..ca32be7 100644
--- a/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java
+++ b/android/src/fishrungames/bashgid/PhotoFragmentAdapter.java
@@ -23,12 +23,10 @@ public class PhotoFragmentAdapter extends PagerAdapter {
AlbumFullData album;
- //int currentPhoto;
- public PhotoFragmentAdapter(Context context, AlbumFullData album/*, int currentPhoto*/) {
+ public PhotoFragmentAdapter(Context context, AlbumFullData album) {
this.context = context;
this.album = album;
- //this.currentPhoto = currentPhoto;
}
@Override
@@ -59,7 +57,6 @@ public class PhotoFragmentAdapter extends PagerAdapter {
descriptionTextView.setText(album.photoRecordArr.get(position).description);
-
ImageView image = (ImageView) viewLayout.findViewById(R.id.image);
ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl);
diff --git a/android/src/fishrungames/bashgid/SearchFragment.java b/android/src/fishrungames/bashgid/SearchFragment.java
index 4138e5f..0f53167 100644
--- a/android/src/fishrungames/bashgid/SearchFragment.java
+++ b/android/src/fishrungames/bashgid/SearchFragment.java
@@ -1,21 +1,14 @@
package fishrungames.bashgid;
-
import java.util.ArrayList;
import java.util.Locale;
-import fishrungames.bashgid.core.ArticleManager;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
-import fishrungames.bashgid.core.DatabaseGetJournalTask;
+
import fishrungames.bashgid.core.DatabaseSearchArticleTask;
-import fishrungames.bashgid.core.NewsManager;
-import fishrungames.bashgid.core.NewsManager.NewsRecord;
-import fishrungames.bashgid.core.db.NewsDataSource;
+
import fishrungames.networkutils.ImageManager;
-import fishrungames.networkutils.UniversalActionWithCallback;
-import fishrungames.networkutils.interfaces.RemoveCallbackInterface;
-import fishrungames.networkutils.interfaces.UpdateAndFinishCallbackInterface;
-import fishrungames.bashgid.core.NewsSearchRunnable;
+
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
@@ -24,13 +17,13 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
+
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
-import android.widget.Button;
+
import android.widget.EditText;
-import android.widget.ImageButton;
+
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -40,28 +33,28 @@ public class SearchFragment extends Fragment
{
ListView listView;
-
+
ListAdapter listAdapter;
-
+
TextView hintTextView;
-
+
EditText searchEditText;
-
+
ArrayList searchResultArr = new ArrayList();
-
+
String journalName;
String journalTitle;
String query;
-
+
DatabaseSearchArticleTask databaseSearchArticleTask = null;
-
+
public SearchFragment()
{
this.journalName = "";
this.journalTitle = "";
- this.query = "";
+ this.query = "";
}
-
+
public SearchFragment(String query)
{
this.journalName = "";
@@ -69,258 +62,219 @@ public class SearchFragment extends Fragment
this.journalTitle = "";
this.query = query;
}
-
+
public SearchFragment(String journalName, String journalTitle)
{
this.journalName = journalName;
this.journalTitle = journalTitle;
- this.query = "";
+ this.query = "";
}
+ public SearchFragment(String query, String journalName, String journalTitle)
+ {
+ this.journalName = journalName;
+ this.journalTitle = journalTitle;
+ this.query = query;
+ }
+
@Override
- public void onSaveInstanceState(final Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putString("journalName", journalName);
- outState.putString("journalTitle", journalTitle);
- outState.putString("query", query);
- }
-
- @SuppressLint("InflateParams") @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- if (savedInstanceState != null) {
+ public void onSaveInstanceState(final Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ outState.putString("journalName", journalName);
+ outState.putString("journalTitle", journalTitle);
+ outState.putString("query", query);
+ }
+
+ @SuppressLint("InflateParams")
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
+ if (savedInstanceState != null)
+ {
journalName = savedInstanceState.getString("journalName");
journalTitle = savedInstanceState.getString("journalTitle");
query = savedInstanceState.getString("query");
-
- }
-
+
+ }
+
View rootView = inflater.inflate(R.layout.fragment_search_page, container, false);
-
+
listView = (ListView) rootView.findViewById(R.id.listView);
-
+
View header = inflater.inflate(R.layout.search_page_list_header, null);
-
+
TextView addressTextView = (TextView) header.findViewById(R.id.addressTextView);
-
-
+
if (journalTitle == null || journalTitle.length() == 0)
{
addressTextView.setText(R.string.search_everywhere);
- }
- else
+ } else
{
String search_in = this.getResources().getString(R.string.search_in);
-
+
search_in = search_in.replace("%%", journalTitle);
-
+
addressTextView.setText(search_in);
}
-
+
hintTextView = (TextView) header.findViewById(R.id.hintTextView);
-
-
+
searchEditText = (EditText) header.findViewById(R.id.editText);
-
+
searchEditText.setText(query);
-
- searchEditText.addTextChangedListener(new TextWatcher(){
-
- public void afterTextChanged(Editable s) {
+
+ searchEditText.addTextChangedListener(new TextWatcher()
+ {
+
+ public void afterTextChanged(Editable s)
+ {
query = searchEditText.getText().toString();
-
+
CallUpdateNews();
-
- }
-
- public void beforeTextChanged(CharSequence s, int start, int count, int after){}
- public void onTextChanged(CharSequence s, int start, int before, int count){}
- });
-
+
+ }
+
+ public void beforeTextChanged(CharSequence s, int start, int count, int after)
+ {
+ }
+
+ public void onTextChanged(CharSequence s, int start, int before, int count)
+ {
+ }
+ });
+
listView.addHeaderView(header);
-
+
listAdapter = new ListAdapter(getActivity());
-
+
listView.setAdapter(listAdapter);
-
- listView.setOnItemClickListener(new OnItemClickListener(){
+
+ listView.setOnItemClickListener(new OnItemClickListener()
+ {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
- MainActivity.getInstance().OpenArticleScreen(searchResultArr.get(position-1).name, MainActivity.TAG_TO_MAINFRAGMENT);
+
+ MainActivity.getInstance().SetLastJournalName(journalName);
+ MainActivity.getInstance().SetLastJournalTitle(journalTitle);
+
+ MainActivity.getInstance().SetLastSearchQuery(query);
+ MainActivity.getInstance().OpenArticleScreen(searchResultArr.get(position - 1).name, MainActivity.TAG_BACK_TO_SEARCHFRAGMENT);
}
});
-
+
CallUpdateNews();
-
+
return rootView;
}
-
-
+
public void SetSearchResult(ArrayList articleArr)
{
searchResultArr = articleArr;
listAdapter.notifyDataSetChanged();
-
+
String searchResultCount = getResources().getString(R.string.search_result_count);
-
+
searchResultCount = searchResultCount.replace("%%", Integer.toString(articleArr.size()));
-
+
hintTextView.setText(searchResultCount);
}
-
-
-
- public class ListAdapter extends BaseAdapter {
- private Context mContext;
- public ListAdapter(Context c) {
- mContext = c;
- }
+ public class ListAdapter extends BaseAdapter
+ {
+ private Context mContext;
- public int getCount() {
- return searchResultArr.size();
- }
+ public ListAdapter(Context c)
+ {
+ mContext = c;
+ }
- public Object getItem(int position) {
- return null;
- }
+ public int getCount()
+ {
+ return searchResultArr.size();
+ }
- public long getItemId(int position) {
- return 0;
- }
+ public Object getItem(int position)
+ {
+ return null;
+ }
- // 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.search_page_list_element, null);
-
- } else {
- view = convertView;
- }
-
- ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
-
- Button button = (Button) view.findViewById(R.id.button);
-
- TextView dateTextView = (TextView) view.findViewById(R.id.dateTextView);
-
- ImageManager.getInstance().ApplyImageToImageView(imageButton, searchResultArr.get(position).previewImageUrl);
-
- button.setText(searchResultArr.get(position).title);
-
- dateTextView.setText(NewsDataSource.iso8601Format.format(searchResultArr.get(position).dateTime));
-
-
-
- button.setOnClickListener(new ButtonOnClickListener(searchResultArr.get(position).name, searchResultArr.get(position).type));
-
- imageButton.setOnClickListener(new ButtonOnClickListener(searchResultArr.get(position).name, searchResultArr.get(position).type));
-
- return view;*/
-
- 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(searchResultArr.get(position).title);
-
- TextView dateTextView = (TextView)view.findViewById(R.id.dateTextView);
-
- dateTextView.setText(NewsDataSource.iso8601Format.format(searchResultArr.get(position).dateTime));
-
- ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
-
- if (searchResultArr.get(position).previewImageUrl != null)
- {
- ImageManager.getInstance().ApplyImageToImageView(imageView, searchResultArr.get(position).previewImageUrl);
- }
- else
- {
- imageView.setImageResource(R.drawable.transparent);
- }
- return view;
- }
+ 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(searchResultArr.get(position).title);
+
+ TextView dateTextView = (TextView) view.findViewById(R.id.dateTextView);
+
+ dateTextView.setText(MainActivity.iso8601Format.format(searchResultArr.get(position).dateTime));
+
+ ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+
+ if (searchResultArr.get(position).previewImageUrl != null)
+ {
+ ImageManager.getInstance().ApplyImageToImageView(imageView, searchResultArr.get(position).previewImageUrl);
+ } else
+ {
+ imageView.setImageResource(R.drawable.transparent);
+ }
+ return view;
+ }
}
-
public void CallUpdateNews()
{
-
-
+
if (query.length() >= 3 || Locale.getDefault() == Locale.CHINA)
{
if (databaseSearchArticleTask != null)
{
databaseSearchArticleTask.cancel(false);
}
-
+
databaseSearchArticleTask = new DatabaseSearchArticleTask();
databaseSearchArticleTask.mHandler = MainActivity.getInstance().mHandler;
Bundle bundle = new Bundle();
-
+
bundle.putString("journalName", journalName);
bundle.putString("query", query);
-
+
databaseSearchArticleTask.execute(bundle);
-
+
hintTextView.setText(R.string.search_is_performing);
- }
- else
+ } else
{
searchResultArr.clear();
listAdapter.notifyDataSetChanged();
-
+
hintTextView.setText(R.string.search_at_least_3_symbols);
}
}
-
- /*
- public static class ButtonOnClickListener implements OnClickListener
- {
-
- //NewsRecord newsRecord;
- String articleName;
- int articleType;
-
- public ButtonOnClickListener(String articleName, int articleType)
- {
- this.articleName = articleName;
- this.articleType = articleType;
- //this.newsRecord = newsRecord;
- }
-
- @Override
- public void onClick(View v)
- {
-
- MainActivity.getInstance().OpenArticleScreen(articleName, MainActivity.TAG_TO_MAINFRAGMENT);
-
-
-
- }
-
- }*/
-
-
}
diff --git a/android/src/fishrungames/bashgid/SettingsFragment.java b/android/src/fishrungames/bashgid/SettingsFragment.java
index 1264d9c..ecdffab 100644
--- a/android/src/fishrungames/bashgid/SettingsFragment.java
+++ b/android/src/fishrungames/bashgid/SettingsFragment.java
@@ -1,6 +1,5 @@
package fishrungames.bashgid;
-
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -11,16 +10,16 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
-
public class SettingsFragment extends Fragment
{
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+
View rootView = inflater.inflate(R.layout.fragment_settings_page, container, false);
-
- Button callSupportButton = (Button)rootView.findViewById(R.id.callSupportButton);
+
+ Button callSupportButton = (Button) rootView.findViewById(R.id.callSupportButton);
callSupportButton.setOnClickListener(new OnClickListener()
{
@@ -33,11 +32,10 @@ public class SettingsFragment extends Fragment
intent.setData(Uri.parse(uri));
MainActivity.getInstance().startActivity(intent);
}
-
+
});
-
-
- Button visitKitapButton = (Button)rootView.findViewById(R.id.visitKitapButton);
+
+ Button visitKitapButton = (Button) rootView.findViewById(R.id.visitKitapButton);
visitKitapButton.setOnClickListener(new OnClickListener()
{
@@ -49,8 +47,8 @@ public class SettingsFragment extends Fragment
startActivity(i);
}
});
-
- Button visitDeveloperButton = (Button)rootView.findViewById(R.id.visitDeveloperButton);
+
+ Button visitDeveloperButton = (Button) rootView.findViewById(R.id.visitDeveloperButton);
visitDeveloperButton.setOnClickListener(new OnClickListener()
{
@@ -62,9 +60,8 @@ public class SettingsFragment extends Fragment
startActivity(i);
}
});
-
-
- Button visitTranslatorButton = (Button)rootView.findViewById(R.id.visitTranslatorButton);
+
+ Button visitTranslatorButton = (Button) rootView.findViewById(R.id.visitTranslatorButton);
visitTranslatorButton.setOnClickListener(new OnClickListener()
{
diff --git a/android/src/fishrungames/bashgid/StreetViewHolderFragment.java b/android/src/fishrungames/bashgid/StreetViewHolderFragment.java
deleted file mode 100644
index 76ac607..0000000
--- a/android/src/fishrungames/bashgid/StreetViewHolderFragment.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package fishrungames.bashgid;
-
-
-import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback;
-import com.google.android.gms.maps.StreetViewPanorama;
-
-import com.google.android.gms.maps.SupportStreetViewPanoramaFragment;
-import com.google.android.gms.maps.model.LatLng;
-
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-
-public class StreetViewHolderFragment extends Fragment implements OnStreetViewPanoramaReadyCallback
-{
-
- double lat = 0;
- double lon = 0;
-
- public StreetViewHolderFragment()
- {
-
- }
-
- public StreetViewHolderFragment(double lat, double lon)
- {
- this.lat = lat;
- this.lon = lon;
- }
-
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- View rootView = inflater.inflate(R.layout.fragment_streetview_page, container, false);
-
- SupportStreetViewPanoramaFragment streetViewPanoramaFragment = (SupportStreetViewPanoramaFragment) getChildFragmentManager().findFragmentById(R.id.streetviewpanorama);
-
- streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);
-
-
- return rootView;
- }
-
- @Override
- public void onStreetViewPanoramaReady(StreetViewPanorama svp)
- {
- svp.setPosition(new LatLng(lat, lon));
- }
-
-}
diff --git a/android/src/fishrungames/bashgid/VideoListFragment.java b/android/src/fishrungames/bashgid/VideoListFragment.java
index 575b1b1..3fd82b3 100644
--- a/android/src/fishrungames/bashgid/VideoListFragment.java
+++ b/android/src/fishrungames/bashgid/VideoListFragment.java
@@ -90,7 +90,10 @@ public class VideoListFragment extends Fragment
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
- MainActivity.getInstance().OpenVideoRecordScreen(channelFullData.videoRecordArr.get(position), MainActivity.TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT);
+
+ MainActivity.getInstance().SetLastChannelName(channelName);
+
+ MainActivity.getInstance().OpenVideoRecordScreen(channelFullData.videoRecordArr.get(position));
}
});
@@ -115,7 +118,6 @@ public class VideoListFragment extends Fragment
this.channelFullData = channelFullData;
listAdapter.notifyDataSetChanged();
- //channelFullData = MainActivity.getInstance().channelDataSource.GetChannelFullData(channelName);
}
diff --git a/android/src/fishrungames/bashgid/VideoRecordFragment.java b/android/src/fishrungames/bashgid/VideoRecordFragment.java
index fd0c28d..87e36ca 100644
--- a/android/src/fishrungames/bashgid/VideoRecordFragment.java
+++ b/android/src/fishrungames/bashgid/VideoRecordFragment.java
@@ -1,9 +1,8 @@
package fishrungames.bashgid;
-import fishrungames.bashgid.core.AlbumManager;
-import fishrungames.bashgid.core.DatabaseGetAlbumTask;
+
import fishrungames.bashgid.core.VideoManager;
-import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
+
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
import fishrungames.networkutils.ImageManager;
diff --git a/android/src/fishrungames/bashgid/core/AlbumManager.java b/android/src/fishrungames/bashgid/core/AlbumManager.java
index 2bd7876..cae7d26 100644
--- a/android/src/fishrungames/bashgid/core/AlbumManager.java
+++ b/android/src/fishrungames/bashgid/core/AlbumManager.java
@@ -64,17 +64,6 @@ public class AlbumManager
}
}
- public static class AlbumRecord extends AlbumRecordData
- {
- public int id;
-
- public AlbumRecord(int id, String name, String title, String description, int hidden)
- {
- super(name, title, description, hidden);
- this.id = id;
- }
- }
-
public static AlbumFullData CreateEmptyAlbum()
{
AlbumFullData result = new AlbumFullData(new AlbumRecordData("", "", "", 1));
diff --git a/android/src/fishrungames/bashgid/core/ArticleManager.java b/android/src/fishrungames/bashgid/core/ArticleManager.java
index 27b89ef..88e7ef0 100644
--- a/android/src/fishrungames/bashgid/core/ArticleManager.java
+++ b/android/src/fishrungames/bashgid/core/ArticleManager.java
@@ -8,7 +8,6 @@ import java.util.Locale;
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
-import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
public class ArticleManager
{
@@ -67,16 +66,6 @@ public class ArticleManager
}
}
- public static class ArticleRecord extends ArticleRecordData
- {
- public int id;
-
- public ArticleRecord(int id, ArticleRecordData recordData)
- {
- super(recordData);
- this.id = id;
- }
- }
public static class ArticleFullData extends ArticleRecordData
{
@@ -99,8 +88,6 @@ public class ArticleManager
{
super(recordData);
previewImageUrl = "";
- //albumArr = new ArrayList();
- //channelArr = new ArrayList();
}
}
diff --git a/android/src/fishrungames/bashgid/core/BookManager.java b/android/src/fishrungames/bashgid/core/BookManager.java
deleted file mode 100644
index 78a1ad6..0000000
--- a/android/src/fishrungames/bashgid/core/BookManager.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package fishrungames.bashgid.core;
-
-import java.util.ArrayList;
-
-import android.os.Bundle;
-
-import fishrungames.networkutils.ImageManager;
-import fishrungames.networkutils.UpdateCallbackHolder;
-import fishrungames.networkutils.interfaces.NetworkActionInterface;
-
-
-public class BookManager implements NetworkActionInterface
-{
-
- public static class BookRecord
- {
- public String name;
- public String author;
- public String imageUrl;
- public Integer price;
- public String description;
-
- public BookRecord(String name, String author, String imageUrl, Integer price, String description)
- {
- this.name = name;
- this.author = author;
- this.imageUrl = imageUrl;
- this.price = price;
- this.description = description;
- }
- }
-
- private ArrayList BookArr = new ArrayList();
-
- public static BookManager instance = null;
-
- public static BookManager getInstance()
- {
- if (instance == null)
- {
- instance = new BookManager();
- }
-
- return instance;
- }
-
- public BookManager()
- {
- initBooks();
- }
-
-
- public ArrayList getBooks()
- {
- ArrayList books = new ArrayList();
-
- synchronized(BookArr)
- {
- books.addAll(BookArr);
- }
-
- return books;
- }
-
- private void initBooks()
- {
- BookArr.add(new BookRecord("Репка", "", "http://www.kitap-ufa.ru/upload/iblock/079/575.jpg", 40, "Русская народная сказка..."));
- BookArr.add(new BookRecord("Уроки поэзии", "Рахматуллин С.И.", "http://www.kitap-ufa.ru/upload/iblock/6e7/012.jpg", 85, "В книгу вошли стихотворные произведения..."));
- BookArr.add(new BookRecord("Новые валенки", "Калимуллина Г.К.", "http://www.kitap-ufa.ru/upload/iblock/edd/010.jpg", 75, "Детство - самая прекрасная, веселая и интересная пора в жизни человека..."));
- BookArr.add(new BookRecord("В стране Урала", "Рафиков Б.З.", "", 90, "Эта книга настоящего мастера пера не оставит..."));
- }
-
- @Override
- public void InThreadAction(Bundle query, UpdateCallbackHolder callbackHolder)
- {
-
- /*
- ArrayList imageToDownloadList = new ArrayList();
-
- for (int i = 0; i < BookArr.size(); i++)
- {
- imageToDownloadList.add(BookArr.get(i).imageUrl);
- }
-
- Bundle innerQuery = new Bundle();
-
- innerQuery.putStringArray("imageUrlArr", imageToDownloadList.toArray(new String[imageToDownloadList.size()]));
-
- ImageManager.getInstance().InThreadAction(innerQuery, callbackHolder);
-
- callbackHolder.OnUpdated(null);
- */
- }
-}
diff --git a/android/src/fishrungames/bashgid/core/ChannelManager.java b/android/src/fishrungames/bashgid/core/ChannelManager.java
index 70f1dc4..52be1e7 100644
--- a/android/src/fishrungames/bashgid/core/ChannelManager.java
+++ b/android/src/fishrungames/bashgid/core/ChannelManager.java
@@ -2,13 +2,6 @@ package fishrungames.bashgid.core;
import java.util.ArrayList;
-
-import fishrungames.bashgid.MainActivity;
-import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
-import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
-import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
-
-
public class ChannelManager
{
@@ -49,52 +42,12 @@ public class ChannelManager
}
- public static class ChannelRecord extends ChannelRecordData
- {
- public int id;
-
- public ChannelRecord(int id, String name, String title, String description, int hidden)
- {
- super(name, title, description, hidden);
- this.id = id;
- }
- }
-
public static ChannelFullData CreateEmptyChannel()
{
ChannelFullData result = new ChannelFullData(new ChannelRecordData("", "", "", 0));
return result;
}
-
- /*
-
- public static void DownloadAndAddPhoto(PhotoRecordData recordData)
- {
- MainActivity.getInstance().DownloadImage(recordData.imageUrl, recordData.imageHash);
- MainActivity.getInstance().photoDataSource.AddOrReplacePhoto(recordData);
- }
-
- public static void AddExistingPhotoToAlbum(String imageUrl, String albumName)
- {
- if (!MainActivity.getInstance().albumDataSource.IsAlbumAlreadyExist(albumName))
- {
- MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(albumName, albumName, ""));
- }
-
- MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, albumName);
- }
-
- public static void DownloadAndAddPhotoToAlbum(PhotoRecordData recordData, String albumName)
- {
- DownloadAndAddPhoto(recordData);
-
- AddExistingPhotoToAlbum(recordData.imageUrl, albumName);
-
- }
- */
-
-
}
diff --git a/android/src/fishrungames/bashgid/core/DatabaseDownloadTask.java b/android/src/fishrungames/bashgid/core/DatabaseDownloadTask.java
index 289ae32..35d8f87 100644
--- a/android/src/fishrungames/bashgid/core/DatabaseDownloadTask.java
+++ b/android/src/fishrungames/bashgid/core/DatabaseDownloadTask.java
@@ -42,41 +42,22 @@ public class DatabaseDownloadTask extends AsyncTask
protected Long doInBackground(Bundle... queryArr)
{
- /*
-
- ParseJsonPhoto(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=photo/json"));
- ParseJsonAlbum(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=album/json"));
- ParseJsonPhotoAlbumRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=photoAlbumRelation/json"));
-
- ParseJsonVideo(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=video/json"));
- ParseJsonChannel(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=channel/json"));
- ParseJsonVideoChannelRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=videoChannelRelation/json"));
-
- ParseJsonArticle(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=article/json"));
- ParseJsonJournal(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=journal/json"));
- ParseJsonAlbumArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=albumArticleRelation/json"));
- ParseJsonChannelArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=channelArticleRelation/json"));
- ParseJsonArticleJournalRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=articleJournalRelation/json"));
- ParseJsonTranslation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=translation/json"));
- */
-
+
ParseJsonPhoto(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photo/json"));
ParseJsonAlbum(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=album/json"));
ParseJsonPhotoAlbumRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photoAlbumRelation/json"));
-
+
ParseJsonVideo(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=video/json"));
ParseJsonChannel(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channel/json"));
ParseJsonVideoChannelRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=videoChannelRelation/json"));
-
+
ParseJsonArticle(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=article/json"));
ParseJsonJournal(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=journal/json"));
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=albumArticleRelation/json"));
ParseJsonChannelArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channelArticleRelation/json"));
ParseJsonArticleJournalRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=articleJournalRelation/json"));
ParseJsonTranslation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=translation/json"));
-
-
-
+
return (long) 0;
}
@@ -94,413 +75,405 @@ public class DatabaseDownloadTask extends AsyncTask
completeMessage.sendToTarget();
}
-
-
+
private String getJsonFromUrl(String url_select)
{
- ArrayList param = new ArrayList();
-
- InputStream inputStream = null;
+ ArrayList param = new ArrayList();
- try {
- // Set up HTTP post
+ InputStream inputStream = null;
- // HttpClient is more then less deprecated. Need to change to URLConnection
- HttpClient httpClient = new DefaultHttpClient();
+ try
+ {
+ // Set up HTTP post
- HttpPost httpPost = new HttpPost(url_select);
- httpPost.setEntity(new UrlEncodedFormEntity(param));
- HttpResponse httpResponse = httpClient.execute(httpPost);
- HttpEntity httpEntity = httpResponse.getEntity();
+ // HttpClient is more then less deprecated. Need to change to
+ // URLConnection
+ HttpClient httpClient = new DefaultHttpClient();
- // Read content & Log
- inputStream = httpEntity.getContent();
- } catch (UnsupportedEncodingException e1) {
- Log.e("UnsupportedEncodingException", e1.toString());
- e1.printStackTrace();
- } catch (ClientProtocolException e2) {
- Log.e("ClientProtocolException", e2.toString());
- e2.printStackTrace();
- } catch (IllegalStateException e3) {
- Log.e("IllegalStateException", e3.toString());
- e3.printStackTrace();
- } catch (IOException e4) {
- Log.e("IOException", e4.toString());
- e4.printStackTrace();
- }
- // Convert response to string using String Builder
- try {
- BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"), 8);
- StringBuilder sBuilder = new StringBuilder();
+ HttpPost httpPost = new HttpPost(url_select);
+ httpPost.setEntity(new UrlEncodedFormEntity(param));
+ HttpResponse httpResponse = httpClient.execute(httpPost);
+ HttpEntity httpEntity = httpResponse.getEntity();
- String line = null;
- while ((line = bReader.readLine()) != null) {
- sBuilder.append(line + "\n");
- }
+ // Read content & Log
+ inputStream = httpEntity.getContent();
+ } catch (UnsupportedEncodingException e1)
+ {
+ Log.e("UnsupportedEncodingException", e1.toString());
+ e1.printStackTrace();
+ } catch (ClientProtocolException e2)
+ {
+ Log.e("ClientProtocolException", e2.toString());
+ e2.printStackTrace();
+ } catch (IllegalStateException e3)
+ {
+ Log.e("IllegalStateException", e3.toString());
+ e3.printStackTrace();
+ } catch (IOException e4)
+ {
+ Log.e("IOException", e4.toString());
+ e4.printStackTrace();
+ }
+ // Convert response to string using String Builder
+ try
+ {
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"), 8);
+ StringBuilder sBuilder = new StringBuilder();
- inputStream.close();
- String result = sBuilder.toString();
-
- return result;
-
+ String line = null;
+ while ((line = bReader.readLine()) != null)
+ {
+ sBuilder.append(line + "\n");
+ }
+
+ inputStream.close();
+ String result = sBuilder.toString();
+
+ return result;
+
+ } catch (Exception e)
+ {
+ Log.e("StringBuilding & BufferedReader", "Error converting result " + e.toString());
+ }
+
+ return "";
- } catch (Exception e) {
- Log.e("StringBuilding & BufferedReader", "Error converting result " + e.toString());
- }
-
- return "";
-
}
-
-
+
private void ParseJsonPhoto(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String title = jObject.getString("title");
- String description = jObject.getString("description");
- String imageUrl = jObject.getString("imageUrl");
- String imageHash = jObject.getString("imageHash");
- double geoLat = jObject.getDouble("geoLat");
- double geoLon = jObject.getDouble("geoLon");
-
- MainActivity.getInstance().photoDataSource.AddOrReplacePhoto(new PhotoRecordData(
- title,
- description,
- imageUrl,
- imageHash,
- geoLat,
- geoLon));
+ JSONObject jObject = jArray.getJSONObject(i);
- MainActivity.getInstance().DownloadImage(imageUrl, imageHash);
-
+ String title = jObject.getString("title");
+ String description = jObject.getString("description");
+ String imageUrl = jObject.getString("imageUrl");
+ String imageHash = jObject.getString("imageHash");
+ double geoLat = jObject.getDouble("geoLat");
+ double geoLon = jObject.getDouble("geoLon");
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ MainActivity.getInstance().photoDataSource.AddOrReplacePhoto(new PhotoRecordData(title, description, imageUrl, imageHash, geoLat, geoLon));
+
+ MainActivity.getInstance().DownloadImage(imageUrl, imageHash);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonAlbum(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String name = jObject.getString("name");
- String title = jObject.getString("title");
- String description = jObject.getString("description");
- int hidden = jObject.getInt("hidden");
-
- MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(
- name,
- title,
- description,
- hidden));
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String name = jObject.getString("name");
+ String title = jObject.getString("title");
+ String description = jObject.getString("description");
+ int hidden = jObject.getInt("hidden");
+
+ MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(name, title, description, hidden));
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonPhotoAlbumRelation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String imageUrl = jObject.getString("imageUrl");
- String name = jObject.getString("name");
-
- MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, name);
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String imageUrl = jObject.getString("imageUrl");
+ String name = jObject.getString("name");
+
+ MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, name);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonVideo(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- int type = jObject.getInt("type");
- String videoUrl = jObject.getString("videoUrl");
-
- String title = jObject.getString("title");
- String description = jObject.getString("description");
- String previewImageUrl = jObject.getString("previewImageUrl");
- String previewImageHash = jObject.getString("previewImageHash");
-
- MainActivity.getInstance().videoDataSource.AddOrReplaceVideo(new VideoRecordData(
- type,
- videoUrl,
- title,
- description,
- previewImageUrl,
- previewImageHash
- ));
+ JSONObject jObject = jArray.getJSONObject(i);
- MainActivity.getInstance().DownloadImage(previewImageUrl, previewImageHash);
-
+ int type = jObject.getInt("type");
+ String videoUrl = jObject.getString("videoUrl");
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String title = jObject.getString("title");
+ String description = jObject.getString("description");
+ String previewImageUrl = jObject.getString("previewImageUrl");
+ String previewImageHash = jObject.getString("previewImageHash");
+
+ MainActivity.getInstance().videoDataSource.AddOrReplaceVideo(new VideoRecordData(type, videoUrl, title, description, previewImageUrl,
+ previewImageHash));
+
+ MainActivity.getInstance().DownloadImage(previewImageUrl, previewImageHash);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
-
+
private void ParseJsonChannel(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String name = jObject.getString("name");
- String title = jObject.getString("title");
- String description = jObject.getString("description");
- int hidden = jObject.getInt("hidden");
-
- MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(
- name,
- title,
- description,
- hidden));
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String name = jObject.getString("name");
+ String title = jObject.getString("title");
+ String description = jObject.getString("description");
+ int hidden = jObject.getInt("hidden");
+
+ MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(name, title, description, hidden));
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonVideoChannelRelation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String videoUrl = jObject.getString("videoUrl");
- String name = jObject.getString("name");
-
- MainActivity.getInstance().channelDataSource.AddVideoToChannel(videoUrl, name);
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String videoUrl = jObject.getString("videoUrl");
+ String name = jObject.getString("name");
+
+ MainActivity.getInstance().channelDataSource.AddVideoToChannel(videoUrl, name);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
-
+
private void ParseJsonArticle(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- try
+ for (int i = 0; i < jArray.length(); i++)
+ {
+
+ try
{
- JSONObject jObject = jArray.getJSONObject(i);
+ JSONObject jObject = jArray.getJSONObject(i);
+
+ String name = jObject.getString("name");
+ int type = jObject.getInt("type");
+ String title = jObject.getString("title");
+ String content = jObject.getString("content");
+ double geoLat = jObject.getDouble("geoLat");
+ double geoLon = jObject.getDouble("geoLon");
+ String address = jObject.getString("address");
+ String phone = jObject.getString("phone");
+ String externalLink = jObject.getString("externalLink");
+ String externalLinkText = jObject.getString("externalLinkText");
+ Date dateTime = ArticleManager.iso8601Format.parse(jObject.getString("dateTime"));
+ int hidden = jObject.getInt("hidden");
+
+ MainActivity.getInstance().articleDataSource.CreateNewArticle(new ArticleRecordData(name, type, title, content, geoLat, geoLon, address,
+ phone, externalLink, externalLinkText, dateTime, hidden));
- String name = jObject.getString("name");
- int type = jObject.getInt("type");
- String title = jObject.getString("title");
- String content = jObject.getString("content");
- double geoLat = jObject.getDouble("geoLat");
- double geoLon = jObject.getDouble("geoLon");
- String address = jObject.getString("address");
- String phone = jObject.getString("phone");
- String externalLink = jObject.getString("externalLink");
- String externalLinkText = jObject.getString("externalLinkText");
- Date dateTime = ArticleManager.iso8601Format.parse(jObject.getString("dateTime"));
- int hidden = jObject.getInt("hidden");
-
- MainActivity.getInstance().articleDataSource.CreateNewArticle(new ArticleRecordData(
- name,
- type,
- title,
- content,
- geoLat,
- geoLon,
- address,
- phone,
- externalLink,
- externalLinkText,
- dateTime,
- hidden));
-
-
} catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonJournal(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String name = jObject.getString("name");
- String title = jObject.getString("title");
- String description = jObject.getString("description");
- int hidden = jObject.getInt("hidden");
- int geoCategory = jObject.getInt("geoCategory");
- int main = jObject.getInt("main");
-
- MainActivity.getInstance().journalDataSource.CreateNewJournal(new JournalRecordData(
- name,
- title,
- description,
- hidden,
- geoCategory,
- main));
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String name = jObject.getString("name");
+ String title = jObject.getString("title");
+ String description = jObject.getString("description");
+ int hidden = jObject.getInt("hidden");
+ int geoCategory = jObject.getInt("geoCategory");
+ int main = jObject.getInt("main");
+
+ MainActivity.getInstance().journalDataSource.CreateNewJournal(new JournalRecordData(name, title, description, hidden, geoCategory, main));
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
-
+
private void ParseJsonAlbumArticleRelation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String albumName = jObject.getString("albumName");
- String articleName = jObject.getString("articleName");
-
- MainActivity.getInstance().articleDataSource.AddAlbumToArticle(albumName, articleName);
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String albumName = jObject.getString("albumName");
+ String articleName = jObject.getString("articleName");
+
+ MainActivity.getInstance().articleDataSource.AddAlbumToArticle(albumName, articleName);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonChannelArticleRelation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String channelName = jObject.getString("channelName");
- String articleName = jObject.getString("articleName");
-
- MainActivity.getInstance().articleDataSource.AddChannelToArticle(channelName, articleName);
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String channelName = jObject.getString("channelName");
+ String articleName = jObject.getString("articleName");
+
+ MainActivity.getInstance().articleDataSource.AddChannelToArticle(channelName, articleName);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonArticleJournalRelation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String articleName = jObject.getString("articleName");
- String journalName = jObject.getString("journalName");
-
- MainActivity.getInstance().journalDataSource.AddArticleToJournal(articleName, journalName);
-
+ JSONObject jObject = jArray.getJSONObject(i);
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ String articleName = jObject.getString("articleName");
+ String journalName = jObject.getString("journalName");
+
+ MainActivity.getInstance().journalDataSource.AddArticleToJournal(articleName, journalName);
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
-
+
private void ParseJsonTranslation(String jsonCode)
{
- try {
- JSONArray jArray = new JSONArray(jsonCode);
-
- for(int i=0; i < jArray.length(); i++) {
+ try
+ {
+ JSONArray jArray = new JSONArray(jsonCode);
- JSONObject jObject = jArray.getJSONObject(i);
+ for (int i = 0; i < jArray.length(); i++)
+ {
- String name = jObject.getString("name");
- String textEn = jObject.getString("textEn");
- String textRu = jObject.getString("textRu");
- String textZh = jObject.getString("textZh");
- String textEnUp = jObject.getString("textEnUp");
- String textRuUp = jObject.getString("textRuUp");
- String textZhUp = jObject.getString("textZhUp");
-
- MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh, textEnUp, textRuUp, textZhUp));
-
- } // End Loop
-
- } catch (JSONException e) {
- Log.e("JSONException", "Error: " + e.toString());
- }
+ JSONObject jObject = jArray.getJSONObject(i);
+
+ String name = jObject.getString("name");
+ String textEn = jObject.getString("textEn");
+ String textRu = jObject.getString("textRu");
+ String textZh = jObject.getString("textZh");
+ String textEnUp = jObject.getString("textEnUp");
+ String textRuUp = jObject.getString("textRuUp");
+ String textZhUp = jObject.getString("textZhUp");
+
+ MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh, textEnUp,
+ textRuUp, textZhUp));
+
+ } // End Loop
+
+ } catch (JSONException e)
+ {
+ Log.e("JSONException", "Error: " + e.toString());
+ }
}
}
\ No newline at end of file
diff --git a/android/src/fishrungames/bashgid/core/DatabaseGetGeoJournalListTask.java b/android/src/fishrungames/bashgid/core/DatabaseGetGeoJournalListTask.java
index fcbbcad..962dbc9 100644
--- a/android/src/fishrungames/bashgid/core/DatabaseGetGeoJournalListTask.java
+++ b/android/src/fishrungames/bashgid/core/DatabaseGetGeoJournalListTask.java
@@ -7,7 +7,6 @@ import android.os.Handler;
import android.os.Message;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
-import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
public class DatabaseGetGeoJournalListTask extends AsyncTask
{
diff --git a/android/src/fishrungames/bashgid/core/DatabaseGetJournalListTask.java b/android/src/fishrungames/bashgid/core/DatabaseGetJournalListTask.java
index ce2238f..5e69f66 100644
--- a/android/src/fishrungames/bashgid/core/DatabaseGetJournalListTask.java
+++ b/android/src/fishrungames/bashgid/core/DatabaseGetJournalListTask.java
@@ -17,9 +17,7 @@ ArrayList journalList;
protected Long doInBackground(String... queryArr)
{
-
- //String superJournal = "";
-
+
if (queryArr.length > 0)
{
journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3); //Xperimental -- need to pass exactly how many articles
diff --git a/android/src/fishrungames/bashgid/core/DatabaseSearchArticleTask.java b/android/src/fishrungames/bashgid/core/DatabaseSearchArticleTask.java
index 65a5301..f1bceb6 100644
--- a/android/src/fishrungames/bashgid/core/DatabaseSearchArticleTask.java
+++ b/android/src/fishrungames/bashgid/core/DatabaseSearchArticleTask.java
@@ -1,6 +1,5 @@
package fishrungames.bashgid.core;
-
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Locale;
@@ -14,57 +13,54 @@ import android.os.Message;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
-import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
public class DatabaseSearchArticleTask extends AsyncTask
{
public Handler mHandler;
-
+
ArrayList articleArr = new ArrayList();
-
+
ArrayList translationNamesArr = new ArrayList();
protected Long doInBackground(Bundle... queryArr)
{
String query = queryArr[0].getString("query");
-
+
String journalName = queryArr[0].getString("journalName");
-
+
query = query.toUpperCase(Locale.getDefault());
if (Locale.getDefault().equals(new Locale("ru")))
{
-
+
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchRussian(query);
- }
- else if (Locale.getDefault() == Locale.CHINA)
+ } else if (Locale.getDefault() == Locale.CHINA)
{
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchChinese(query);
- }
- else
+ } else
{
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchEnglish(query);
}
-
+
if (journalName != null && journalName.length() > 0)
{
for (String translationName : translationNamesArr)
{
articleArr.addAll(MainActivity.getInstance().articleDataSource.SearchArticleByTitleOrTextInJournal(translationName, journalName));
}
- }
- else
+ } else
{
for (String translationName : translationNamesArr)
{
articleArr.addAll(MainActivity.getInstance().articleDataSource.SearchArticleByTitleOrText(translationName));
}
}
-
- //Remove duplicates
-
- Set articleSet = new TreeSet(new Comparator() {
+
+ // Remove duplicates
+
+ Set articleSet = new TreeSet(new Comparator()
+ {
@Override
public int compare(ArticleShortData lhs, ArticleShortData rhs)
@@ -72,13 +68,13 @@ public class DatabaseSearchArticleTask extends AsyncTask
return lhs.name.compareTo(rhs.name);
}
});
-
+
articleSet.addAll(articleArr);
-
+
articleArr.clear();
-
+
articleArr.addAll(articleSet);
-
+
return (long) 0;
}
@@ -96,6 +92,5 @@ public class DatabaseSearchArticleTask extends AsyncTask
completeMessage.sendToTarget();
}
-
}
\ No newline at end of file
diff --git a/android/src/fishrungames/bashgid/core/HtmlDownloadManager.java b/android/src/fishrungames/bashgid/core/HtmlDownloadManager.java
deleted file mode 100644
index 30a899f..0000000
--- a/android/src/fishrungames/bashgid/core/HtmlDownloadManager.java
+++ /dev/null
@@ -1,366 +0,0 @@
-package fishrungames.bashgid.core;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.os.Bundle;
-
-import fishrungames.networkutils.ContextHolder;
-import fishrungames.networkutils.DownloadFunctions;
-import fishrungames.networkutils.FileFunctions;
-import fishrungames.networkutils.ImageManager;
-import fishrungames.networkutils.SimplePropertyTree;
-import fishrungames.networkutils.UniversalActionWithCallback;
-import fishrungames.networkutils.UpdateCallbackHolder;
-import fishrungames.networkutils.interfaces.NetworkActionInterface;
-import fishrungames.networkutils.interfaces.RemoveCallbackInterface;
-import fishrungames.networkutils.interfaces.UpdateAndFinishCallbackInterface;
-
-public class HtmlDownloadManager implements NetworkActionInterface
-{
-
-
-
- public static class TextFileRecord
- {
- public String url;
- public String baseUrl;
- public String localUrl;
-
-
- public static class DocPart
- {
- public enum DocPartType
- {
- DPT_TEXT,
- DPT_IMAGE,
- DPT_BUTTON
- }
-
- public DocPartType docPartType;
- public String value;
-
- public DocPart(DocPartType docPartType, String value)
- {
- this.docPartType = docPartType;
- this.value = value;
- }
- }
-
- public ArrayList contentArr = new ArrayList();
-
- public enum SeparatorType
- {
- ST_DIV_ID,
- ST_DIV_CLASS,
- ST_ARTICLE
- }
-
- public SeparatorType separator;
-
- public String separatorValue;
-
- public String title;
- public String topicImg;
-
- public TextFileRecord(String url, String baseUrl, String localUrl, SeparatorType separator, String separatorValue, String title, String topicImg)
- {
- this.url = url;
- this.baseUrl = baseUrl;
- this.localUrl = localUrl;
- this.separator = separator;
- this.separatorValue = separatorValue;
- this.title = title;
- this.topicImg = topicImg;
-
- }
- }
-
- private static HtmlDownloadManager instance = null;
-
- public static HtmlDownloadManager getInstance()
- {
- if (instance == null)
- {
- instance = new HtmlDownloadManager();
- }
-
- return instance;
- }
-
- public static RemoveCallbackInterface DownloadHtmlFiles(UpdateAndFinishCallbackInterface callback)
- {
- return UniversalActionWithCallback.PerformActionIfNotPerforming(HtmlDownloadManager.getInstance(), null, callback, "TextFileDownloadManager");
- }
-
-
- private ArrayList GlobelHtmlUrlList = new ArrayList();
-
- @Override
- public void InThreadAction(Bundle query, UpdateCallbackHolder callbackHolder)
- {
-
- InputStream is = null;
- SimplePropertyTree ptree = null;
- try
- {
- is = ContextHolder.getContext().getAssets().open("urllist.xml");
- ptree = SimplePropertyTree.parse(is);
-
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (XmlPullParserException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally
- {
- if (is != null)
- {
- try
- {
- is.close();
- } catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- if (ptree != null)
- {
- ArrayList htmlUrlList = getListFromPropertyTree(ptree);
-
- if (htmlUrlList.size() > 0)
- {
- for (int i = 0; i < htmlUrlList.size(); i++)
- {
- String fileContent = DownloadFunctions.getXmlFromUrl(htmlUrlList.get(i).url);
-
- if (fileContent != null)
- {
-
- Document doc = Jsoup.parse(fileContent);
-
- Elements linkElements = doc.getElementsByTag("link");
-
- linkElements.remove();
-
- Elements scriptElements = doc.getElementsByTag("script");
-
- scriptElements.remove();
-
- Elements hiddenElements = doc.getElementsByAttributeValue("style", "display: none;");
-
- hiddenElements.remove();
-
- Elements styleElements = doc.getElementsByTag("style");
-
- styleElements.remove();
-
- Elements aElements = doc.getElementsByTag("a");
-
- for (Element a : aElements)
- {
- a.removeAttr("href");
- a.attributes().put("href", "#");
- }
-
-
- Elements imgElements = doc.getElementsByTag("img");
-
- for (Element img : imgElements)
- {
- String link = ImageTagToLink(htmlUrlList.get(i).baseUrl, img);
-
-
- if (!link.equals(""))
- {
- ImageManager.getInstance().AddImageToLibrary(link);
- }
-
- }
-
- Element body = doc.body();
-
- Element mainDiv;
-
- if (htmlUrlList.get(i).separator == TextFileRecord.SeparatorType.ST_DIV_ID)
- {
- mainDiv = body.getElementById(htmlUrlList.get(i).separatorValue).clone();
- } else if (htmlUrlList.get(i).separator == TextFileRecord.SeparatorType.ST_DIV_CLASS)
- {
- mainDiv = body.getElementsByClass(htmlUrlList.get(i).separatorValue).first().clone();
- } else
- {
- mainDiv = body.getElementsByTag(htmlUrlList.get(i).separatorValue).first().clone();
- }
-
- body.children().remove();
-
- body.appendChild(mainDiv);
-
- String newHtmlCode = doc.html();
-
- Elements mainDivElements = mainDiv.children();
-
- htmlUrlList.get(i).contentArr.add(new TextFileRecord.DocPart(TextFileRecord.DocPart.DocPartType.DPT_TEXT, htmlUrlList.get(i).title));
-
- for (Element subDiv : mainDivElements)
- {
- String text = subDiv.text();
- Elements subDivImgArr = subDiv.getElementsByTag("img");
-
- for (Element subDivImg : subDivImgArr)
- {
- String imageLink = ImageTagToLink(htmlUrlList.get(i).baseUrl, subDivImg);
-
- if (!imageLink.equals(""))
- {
- //Xperimental
- //AlbumManager.getInstance().AddPhotoToAlbum(htmlUrlList.get(i).title, "", imageLink);
- htmlUrlList.get(i).contentArr.add(new TextFileRecord.DocPart(TextFileRecord.DocPart.DocPartType.DPT_IMAGE, imageLink));
- }
- }
-
- if (!text.equals(""))
- {
- htmlUrlList.get(i).contentArr.add(new TextFileRecord.DocPart(TextFileRecord.DocPart.DocPartType.DPT_TEXT, text));
- }
-
- }
-
- htmlUrlList.get(i).contentArr.add(new TextFileRecord.DocPart(TextFileRecord.DocPart.DocPartType.DPT_BUTTON, htmlUrlList.get(i).localUrl));
-
- FileFunctions.WriteTextToFile(htmlUrlList.get(i).localUrl, newHtmlCode);
-
- }
-
- }
- }
-
-
- synchronized(GlobelHtmlUrlList)
- {
- GlobelHtmlUrlList.clear();
- GlobelHtmlUrlList.addAll(htmlUrlList);
- }
- }
-
-
- callbackHolder.OnUpdated(null);
- }
-
-
- private static String ImageTagToLink(String baseUrl, Element imageTag)
- {
- String link = imageTag.attributes().get("src");
-
- if (link.endsWith(".png") || link.endsWith(".jpg") || link.endsWith(".jpeg") || link.endsWith(".bmp")
- || link.endsWith(".PNG") || link.endsWith(".JPG") || link.endsWith(".JPEG")
- || link.endsWith(".BMP"))
- {
- if (link.startsWith("//"))
- {
- link = "http:" + link;
- }
- if (!link.startsWith("http://"))
- {
- link = baseUrl + link;
- }
-
- return link;
-
- } else
- {
- return "";
- }
- }
-
- public static void RecursiveRemoveScript(Element e)
- {
- for (Iterator iterator = e.children().iterator(); iterator.hasNext();)
- {
-
- Element c = iterator.next();
-
- RecursiveRemoveScript(c);
-
- if ("script".equals(c.tagName()))
- {
- iterator.remove();
- }
- }
- }
-
-
- public ArrayList getGlobalHtmlList()
- {
-
- ArrayList result = new ArrayList();
-
-
- synchronized(GlobelHtmlUrlList)
- {
- result.addAll(GlobelHtmlUrlList);
- }
-
- return result;
-
- }
-
- public static ArrayList getListFromPropertyTree(SimplePropertyTree ptree)
- {
- ArrayList htmlUrlList = new ArrayList();
-
- SimplePropertyTree listNode = ptree.GetNode("list");
-
- if (listNode != null)
- {
- for (int i = 0; i < listNode.SubNodes.size(); i++)
- {
-
- String url = listNode.SubNodes.get(i).Get("url");
- String baseUrl = listNode.SubNodes.get(i).Get("baseUrl");
- String localUrl = listNode.SubNodes.get(i).Get("localUrl");
-
- TextFileRecord.SeparatorType separator;
-
- if (listNode.SubNodes.get(i).Get("separator").equals("ST_DIV_ID"))
- {
- separator = TextFileRecord.SeparatorType.ST_DIV_ID;
- } else if (listNode.SubNodes.get(i).Get("separator").equals("ST_DIV_CLASS"))
- {
- separator = TextFileRecord.SeparatorType.ST_DIV_CLASS;
- } else
- {
- separator = TextFileRecord.SeparatorType.ST_ARTICLE;
- }
-
- String separatorValue = listNode.SubNodes.get(i).Get("separatorValue");
- String title = listNode.SubNodes.get(i).Get("title");
- String topicImg = listNode.SubNodes.get(i).Get("topicImg");
-
-
- htmlUrlList.add(new TextFileRecord(url, baseUrl, localUrl, separator, separatorValue, title, topicImg));
-
- ImageManager.getInstance().AddImageToLibrary(topicImg);
- }
- }
-
- return htmlUrlList;
- }
-
-}
diff --git a/android/src/fishrungames/bashgid/core/JournalManager.java b/android/src/fishrungames/bashgid/core/JournalManager.java
index 01129a3..4c381c8 100644
--- a/android/src/fishrungames/bashgid/core/JournalManager.java
+++ b/android/src/fishrungames/bashgid/core/JournalManager.java
@@ -1,14 +1,9 @@
package fishrungames.bashgid.core;
import java.util.ArrayList;
-import java.util.Comparator;
-import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
-import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
-import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
-import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
-import fishrungames.bashgid.core.NewsManager.NewsRecord;
+
public class JournalManager
@@ -49,13 +44,12 @@ public class JournalManager
{
public ArrayList articleArr;
- //public ArrayList previewImageArr;
+
public JournalSemiFullData(JournalRecordData copyFrom)
{
super(copyFrom);
articleArr = new ArrayList();
- //previewImageArr = new ArrayList();
}
}
@@ -75,7 +69,7 @@ public class JournalManager
public static JournalSemiFullData CreateEmptyJournal()
{
- JournalSemiFullData result = new JournalSemiFullData(new JournalRecordData("", "", "", 0, 0, 0));
+ JournalSemiFullData result = new JournalSemiFullData(new JournalRecordData("", "", "", 1, 0, 0));
return result;
}
diff --git a/android/src/fishrungames/bashgid/core/LocationHolder.java b/android/src/fishrungames/bashgid/core/LocationHolder.java
index 9da81c4..04d8419 100644
--- a/android/src/fishrungames/bashgid/core/LocationHolder.java
+++ b/android/src/fishrungames/bashgid/core/LocationHolder.java
@@ -1,8 +1,8 @@
package fishrungames.bashgid.core;
-import android.content.Context;
+
import android.location.Location;
-import android.location.LocationManager;
+
public class LocationHolder
{
@@ -10,32 +10,8 @@ public class LocationHolder
public static double CONST_UFA_LATITUDE = 54.726274;
public static double CONST_UFA_LONGITUDE = 55.947622;
+
public static int CONST_UFA_ZOOM = 10;
- public static void RefreshLocation(Context context)
- {
- LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
-
- boolean isGPSEnabled = locationManager
- .isProviderEnabled(LocationManager.GPS_PROVIDER);
-
- // getting network status
- boolean isNetworkEnabled = locationManager
- .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
-
- if (isGPSEnabled)
- {
- location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
- }
- else if (isNetworkEnabled)
- {
- location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
- }
- else
- {
- location = null;
- }
- }
-
}
diff --git a/android/src/fishrungames/bashgid/core/NewsDownloadTask.java b/android/src/fishrungames/bashgid/core/NewsDownloadTask.java
index 3776047..c11fe3d 100644
--- a/android/src/fishrungames/bashgid/core/NewsDownloadTask.java
+++ b/android/src/fishrungames/bashgid/core/NewsDownloadTask.java
@@ -19,7 +19,7 @@ public class NewsDownloadTask extends AsyncTask
for (int i = 0; i < NewsManager.urlArr.length; i++)
{
- NewsManager.LoadNewsAndImagesFromRss2_new(NewsManager.urlArr[i]);
+ NewsManager.LoadNewsAndImagesFromRss(NewsManager.urlArr[i]);
}
return (long) 0;
diff --git a/android/src/fishrungames/bashgid/core/NewsManager.java b/android/src/fishrungames/bashgid/core/NewsManager.java
index 73d55c5..1d781c6 100644
--- a/android/src/fishrungames/bashgid/core/NewsManager.java
+++ b/android/src/fishrungames/bashgid/core/NewsManager.java
@@ -4,16 +4,12 @@ import fishrungames.networkutils.ImageManager;
import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
+
import java.util.Locale;
-import java.util.concurrent.Semaphore;
+
import fishrungames.networkutils.DownloadFunctions;
-import android.util.Log;
-
-
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.R;
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
@@ -35,159 +31,6 @@ public class NewsManager {
"https://news.yandex.ru/Ufa/index.rss",
};
- private static NewsManager instance = null;
-
- private static volatile boolean SynchronizationInProcess = false; //Not strict, so don't need mutex
-
- //private volatile Semaphore newsRecordMutex = new Semaphore(1, true);
- private ArrayList newsRecord = new ArrayList();
-
-
- private volatile Semaphore newsSearchResultMutex = new Semaphore(1, true);
- private ArrayList newsSearchResult = new ArrayList();
- String LastSearchQuery = "";
-
-
- public static boolean CanCallSynchronization()
- {
- return !SynchronizationInProcess;
- }
-
-
-
- public static NewsManager getInstance()
- {
- if (instance == null)
- {
- instance = new NewsManager();
- }
-
- return instance;
- }
-
-
- public static class NewsRecord
- {
- public String title;
- public String description;
- public String imageId;
- public Date pubDate;
-
- public NewsRecord(String title, String description, String imageId, Date pubDate)
- {
- this.title = title;
- this.description = description;
- this.imageId = imageId;
- this.pubDate = pubDate;
- }
-
- NewsRecord(RssReader.Rss2Item rss2Item)
- {
- this.title = rss2Item.title;
- this.description = rss2Item.description;
-
- if ((rss2Item.rss2Enclosure != null) && (DownloadFunctions.MimeTypeIsImage(rss2Item.rss2Enclosure.mimeType)))
- {
- this.imageId = rss2Item.rss2Enclosure.url;
- }
- else
- {
- this.imageId = "R.drawable.transparent";
- }
-
- this.pubDate = rss2Item.pubDate;
- }
- }
-
-
- public NewsManager()
- {
- synchronized(newsRecord)
- {
- newsRecord = MainActivity.getInstance().newsDataSource.getNews();
- }
- }
-
- public void replaceNews(ArrayList freshNews)
- {
- synchronized(newsRecord)
- {
- newsRecord.clear();
- newsRecord.addAll(freshNews);
- MainActivity.getInstance().newsDataSource.replaceNews(newsRecord);
- }
- }
-
-
- public ArrayList getNews()
- {
- ArrayList result = new ArrayList();
-
-
- synchronized(newsRecord)
- {
- result.addAll(newsRecord);
- }
-
- return result;
- }
-
- public ArrayList getSearchResultNews()
- {
- ArrayList result = new ArrayList();
-
- try
- {
- newsSearchResultMutex.acquire();
- try
- {
- result.addAll(newsSearchResult);
-
- } finally
- {
- newsSearchResultMutex.release();
- }
- } catch (InterruptedException ie)
- {
- Log.e("Error in getSearchResultNews", "Error in getSearchResultNews");
- }
-
- return result;
- }
-
-
- public String getLastSearchQuery()
- {
- //Should always be called from main thread
-
- return LastSearchQuery;
- }
-
- public void searchNews(String searchText)
- {
- ArrayList result = new ArrayList();
-
- result = MainActivity.getInstance().newsDataSource.searchNewsByString(searchText);
-
- try
- {
- newsSearchResultMutex.acquire();
- try
- {
-
- LastSearchQuery = searchText;
- newsSearchResult = result;
-
- } finally
- {
- newsSearchResultMutex.release();
- }
- } catch (InterruptedException ie)
- {
- Log.e("Error in getSearchResultNews", "Error in getSearchResultNews");
- }
- }
-
public static ArrayList ExtractEnclosureImageUrl(ArrayList rss2ItemArr)
{
@@ -273,66 +116,7 @@ public class NewsManager {
}
}
- static void LoadNewsAndImagesFromRss2(String url, ArrayList newsRecordArr, ArrayList imageUrlArr)
- {
- //Xperimental -- need to optimize this code. slow block BEGINS
- String xmlCode = DownloadFunctions.getXmlFromUrl(url);
-
- if (xmlCode == null)
- {
- return;
- }
-
- //Remove BOM character if present
- if (xmlCode.startsWith("\uFEFF"))
- {
- xmlCode = xmlCode.substring(1);
- }
-
-
-
- RssReader rssReader = new RssReader();
-
- rssReader.ReadRss(xmlCode);
-
-
- //Xperimental -- need to optimize this code. slow block ENDS
-
- imageUrlArr.addAll(ExtractEnclosureImageUrl(rssReader.rss2ItemArr));
-
-
- ArrayList relativeImageUrlList = ExtractDescriptionImageUrl(rssReader.rss2ItemArr);
-
- ArrayList absoluteImageUrlList = ConvertRelativeToAbsoluteImageUrlList(relativeImageUrlList, url);
-
- imageUrlArr.addAll(absoluteImageUrlList);
-
- //Xperimental -- this function is very slow, need to speed up
- ReplaceRemoteUrlToLocalUrl(rssReader.rss2ItemArr, relativeImageUrlList, absoluteImageUrlList);
-
- for (RssReader.Rss2Item rss2Item : rssReader.rss2ItemArr)
- {
- boolean exists = false;
-
- for (NewsRecord newsRecord : newsRecordArr)
- {
- if (newsRecord.title.equals(rss2Item.title))
- {
- exists = true;
- break;
- }
- }
-
- if (!exists)
- {
- newsRecordArr.add(new NewsRecord(rss2Item));
- }
- }
-
- }
-
-
- static void LoadNewsAndImagesFromRss2_new(String url)
+ static void LoadNewsAndImagesFromRss(String url)
{
//Xperimental -- need to optimize this code. slow block BEGINS
String xmlCode = DownloadFunctions.getXmlFromUrl(url);
@@ -403,49 +187,8 @@ public class NewsManager {
descriptionUp, //Ru Up
descriptionUp //Zh Up
));
- //newsRecordArr.add(newsArticle);
}
- /*imageUrlArr.addAll(ExtractEnclosureImageUrl(rssReader.rss2ItemArr));
-
- ArrayList relativeImageUrlList = ExtractDescriptionImageUrl(rssReader.rss2ItemArr);
-
- ArrayList absoluteImageUrlList = ConvertRelativeToAbsoluteImageUrlList(relativeImageUrlList, url);
-
- imageUrlArr.addAll(absoluteImageUrlList);
-
- //Xperimental -- this function is very slow, need to speed up
- ReplaceRemoteUrlToLocalUrl(rssReader.rss2ItemArr, relativeImageUrlList, absoluteImageUrlList);
-
- for (RssReader.Rss2Item rss2Item : rssReader.rss2ItemArr)
- {
- boolean exists = false;
-
- for (NewsRecord newsRecord : newsRecordArr)
- {
- if (newsRecord.title.equals(rss2Item.title))
- {
- exists = true;
- break;
- }
- }
-
- if (!exists)
- {
- newsRecordArr.add(new NewsRecord(rss2Item));
- }
- }
-
- */
-
}
-
- public static class NewsSortComparator implements Comparator {
- public int compare(NewsRecord newsRecord1, NewsRecord newsRecord2) {
- return newsRecord2.pubDate.compareTo(newsRecord1.pubDate);
- }
- }
-
-
}
diff --git a/android/src/fishrungames/bashgid/core/NewsSearchRunnable.java b/android/src/fishrungames/bashgid/core/NewsSearchRunnable.java
deleted file mode 100644
index ff98320..0000000
--- a/android/src/fishrungames/bashgid/core/NewsSearchRunnable.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package fishrungames.bashgid.core;
-
-import fishrungames.networkutils.UpdateCallbackHolder;
-import fishrungames.networkutils.interfaces.NetworkActionInterface;
-
-
-import android.os.Bundle;
-
-public class NewsSearchRunnable implements NetworkActionInterface
-{
-
- @Override
- public void InThreadAction(Bundle query, UpdateCallbackHolder callbackHolder)
- {
- NewsManager.getInstance().searchNews(query.getString("query"));
- callbackHolder.OnUpdated(null);
- }
-
-}
diff --git a/android/src/fishrungames/bashgid/core/VideoManager.java b/android/src/fishrungames/bashgid/core/VideoManager.java
index ae0ee1b..881586c 100644
--- a/android/src/fishrungames/bashgid/core/VideoManager.java
+++ b/android/src/fishrungames/bashgid/core/VideoManager.java
@@ -62,5 +62,4 @@ public class VideoManager
}
-
}
diff --git a/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java b/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java
index 5378636..388f873 100644
--- a/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java
+++ b/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java
@@ -32,9 +32,6 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
public static final String TABLE_TRANSLATION = "table_translation";
- // Oldstyle
- public static final String TABLE_NEWS = "table_news";
-
public static final String COLUMN_ID = "id";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_TITLE = "title";
@@ -45,7 +42,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
public static final String COLUMN_GEOLON = "geoLon";
public static final String COLUMN_ADDRESS = "address";
public static final String COLUMN_PHONE = "phone";
- public static final String COLUMN_PUBDATE = "pubDate";
+
public static final String COLUMN_TYPE = "type";
public static final String COLUMN_CONTENT = "content";
@@ -81,10 +78,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
// Database creation sql statement
-
- private static final String TABLE_NEWS_CREATE = "create table " + TABLE_NEWS + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_TITLE
- + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_IMAGE_URL + " text not null" + ", " + COLUMN_PUBDATE
- + " text not null" + ");";
+
private static final String TABLE_PHOTO_CREATE = "create table " + TABLE_PHOTO + "(" + COLUMN_ID + " integer primary key autoincrement"
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_IMAGE_URL + " text not null" + ", " + COLUMN_IMAGE_HASH + " text not null" + ", " + COLUMN_GEOLAT
@@ -142,7 +136,6 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
@Override
public void onCreate(SQLiteDatabase database)
{
- database.execSQL(TABLE_NEWS_CREATE);
database.execSQL(TABLE_PHOTO_CREATE);
database.execSQL(TABLE_ALBUM_CREATE);
database.execSQL(TABLE_PHOTO_ALBUM_RELATION_CREATE);
@@ -165,7 +158,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
//Log.w(BashgidSqliteHelper.class.getName(), "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
- db.execSQL("DROP TABLE IF EXISTS " + TABLE_NEWS);
+
db.execSQL("DROP TABLE IF EXISTS " + TABLE_PHOTO);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ALBUM);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_PHOTO_ALBUM_RELATION);
diff --git a/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java b/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java
index e0d5d1e..3630bb8 100644
--- a/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java
@@ -13,7 +13,6 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
public class ChannelDataSource
{
@@ -47,7 +46,7 @@ public class ChannelDataSource
database.insert(BashgidSqliteHelper.TABLE_CHANNEL, null, values);
} else
{
- database.update(BashgidSqliteHelper.TABLE_CHANNEL, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
+ database.update(BashgidSqliteHelper.TABLE_CHANNEL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"", null);
}
} finally
@@ -147,7 +146,7 @@ public class ChannelDataSource
{
result.videoRecordArr.add(MainActivity.getInstance().videoDataSource.InnerGetVideoByVideoUrl(videoUrl, database));
}
-
+
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database);
@@ -159,7 +158,7 @@ public class ChannelDataSource
private boolean innerIsChannelAlreadyExist(String name, SQLiteDatabase database)
{
boolean result = false;
-
+
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
+ "=?", new String[] { name }, null, null, null, null);
@@ -169,7 +168,7 @@ public class ChannelDataSource
{
result = true;
}
-
+
cursor.close();
cursor = null;
}
@@ -181,7 +180,7 @@ public class ChannelDataSource
private boolean innerVideoChannelRelationAlreadyExist(String videoUrl, String name, SQLiteDatabase database)
{
boolean result = false;
-
+
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO_CHANNEL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL,
BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?" + " AND " + BashgidSqliteHelper.COLUMN_NAME + "=?",
new String[] { videoUrl, name }, null, null, null, null);
@@ -192,7 +191,7 @@ public class ChannelDataSource
{
result = true;
}
-
+
cursor.close();
cursor = null;
}
@@ -228,21 +227,22 @@ public class ChannelDataSource
public ChannelRecordData InnerGetChannelByName(String name, SQLiteDatabase database)
{
-
+
ChannelRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
- BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name },
+ null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
-
+
result = new ChannelRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3));
-
+
}
-
+
cursor.close();
cursor = null;
}
diff --git a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
index 0d01df1..f26d654 100644
--- a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java
@@ -5,9 +5,6 @@ import java.util.Collections;
import fishrungames.bashgid.MainActivity;
-import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
-import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
-import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
import fishrungames.bashgid.core.ArticleManager;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
import fishrungames.bashgid.core.JournalManager;
@@ -19,7 +16,6 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
public class JournalDataSource
{
@@ -56,7 +52,7 @@ public class JournalDataSource
} else
{
// Replace
- database.update(BashgidSqliteHelper.TABLE_JOURNAL, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
+ database.update(BashgidSqliteHelper.TABLE_JOURNAL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"", null);
}
} finally
@@ -106,11 +102,10 @@ public class JournalDataSource
if (!InnerArticleJournalRelationAlreadyExist(articleName, journalName, database))
{
- //Log.e("a", "aaa1");
+
database.insert(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, null, values);
- //Log.e("a", "aaa2");
+
}
- //Log.e("a", "aaa3");
} finally
{
@@ -119,56 +114,11 @@ public class JournalDataSource
}
}
-/*
- public ArrayList GetRecentArticlesExceptHidden(String journalName, int count)
- {
- ArrayList result = new ArrayList();
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
- try
- {
-
- JournalRecordData recordData = innerGetJournalByName(journalName, database);
-
- if (recordData != null)
- {
-
- ArrayList articleNameArr = innerGetArticleArrInJournal(journalName, database);
-
- for (String articleName : articleNameArr)
- {
- if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(articleName, database))
- {
- result.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(articleName, database));
- }
- }
-
- Collections.sort(result, new ArticleDataSource.DateSortComparator());
-
- if (result.size() > count)
- {
- result.subList(count, result.size() - count - 1).clear();
- }
- }
-
- } finally
- {
- dbHelper.close();
- }
-
- }
-
- return result;
- }*/
-
public JournalSemiFullData GetJournalSemiFullData(String name)
{
return GetJournalSemiFullData(name, null, 0);
}
-
+
public JournalSemiFullData GetJournalSemiFullData(String name, int count)
{
return GetJournalSemiFullData(name, null, count);
@@ -207,60 +157,52 @@ public class JournalDataSource
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
- BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_HIDDEN + "=0", null, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN,
+ BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_HIDDEN + "=0", null, null, null,
+ null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
-
+
do
{
- //String name = cursor.getString(0);
- //if (!name.equals("news") && !name.equals("map"))
- //{
+ JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1),
+ cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
- JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
+ ArrayList articleArr;
- ArrayList articleArr;
-
- if (count > 0)
+ if (count > 0)
+ {
+ articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
+ } else
+ {
+ articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
+ }
+ for (String article : articleArr)
+ {
+ if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
{
- articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
- }
- else
- {
- articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
- }
- for (String article : articleArr)
- {
- if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
- {
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
- }
}
-
- journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
- journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
+ }
- result.add(journal);
-
- //}
+ journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
+ journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
+ result.add(journal);
} while (cursor.moveToNext());
-
-
}
-
+
cursor.close();
cursor = null;
}
- }
- finally
+ } finally
{
dbHelper.close();
}
@@ -268,13 +210,11 @@ public class JournalDataSource
return result;
}
-
-
+
public ArrayList GetJournalListMain(int count)
{
- //Xperimental - need to create a real superjournal
-
-
+ // Xperimental - need to create a real superjournal
+
ArrayList result = new ArrayList();
SQLiteDatabase database = dbHelper.getWritableDatabase();
@@ -284,8 +224,9 @@ public class JournalDataSource
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
- BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION,
- BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN}, BashgidSqliteHelper.COLUMN_MAIN + "=1", null, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN,
+ BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_MAIN + "=1", null, null, null,
+ null, null);
if (cursor != null)
{
@@ -296,58 +237,48 @@ public class JournalDataSource
{
- //String name = cursor.getString(0);
- //if (name.equals("Universities") || name.equals("hotels")) //Xperimental
- //{
+ JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1),
+ cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
- JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
+ ArrayList articleArr;
-
- ArrayList articleArr;
-
- if (count > 0)
- {
- articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
- }
- else
- {
- articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
- }
+ if (count > 0)
+ {
+ articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
+ } else
+ {
+ articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
+ }
- for (String article : articleArr)
+ for (String article : articleArr)
+ {
+ if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
{
- if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
- {
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
- }
}
-
- journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
- journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
+ }
- result.add(journal);
-
- //}
+ journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
+ journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
+ result.add(journal);
} while (cursor.moveToNext());
}
-
+
cursor.close();
cursor = null;
}
- }
- finally
+ } finally
{
dbHelper.close();
}
}
-
return result;
}
-
+
public ArrayList GetGeoJournalList()
{
ArrayList result = new ArrayList();
@@ -359,8 +290,9 @@ public class JournalDataSource
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
- BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION,
- BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN}, BashgidSqliteHelper.COLUMN_GEOCATEGORY + "=1", null, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN,
+ BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_GEOCATEGORY + "=1", null, null,
+ null, null, null);
if (cursor != null)
{
@@ -370,29 +302,30 @@ public class JournalDataSource
do
{
- JournalRecordData journal = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5));
-
+ JournalRecordData journal = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3),
+ cursor.getInt(4), cursor.getInt(5));
+
journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
-
- //journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
+
+ // journal.description =
+ // MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description,
+ // database);
result.add(journal);
} while (cursor.moveToNext());
}
-
+
cursor.close();
cursor = null;
}
- }
- finally
+ } finally
{
dbHelper.close();
}
}
-
return result;
}
@@ -411,18 +344,16 @@ public class JournalDataSource
ArrayList articleArr = innerGetArticleArrInJournal(name, database);
ArrayList intermediateArticleArr = new ArrayList();
-
+
for (String article : articleArr)
{
- //if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
- //{
+
intermediateArticleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
-
- //
+
}
-
+
Collections.sort(intermediateArticleArr, new ArticleManager.ArticleShortDataTimeSortComparator());
-
+
boolean articleCanGo = false;
if (startAfterArticleName == null || startAfterArticleName.length() == 0)
@@ -431,7 +362,7 @@ public class JournalDataSource
}
int i = 0;
-
+
for (ArticleShortData article : intermediateArticleArr)
{
if (!articleCanGo)
@@ -440,18 +371,17 @@ public class JournalDataSource
{
articleCanGo = true;
}
- }
- else
+ } else
{
if (count == 0 || i < count)
{
result.articleArr.add(article);
i++;
}
-
+
}
}
-
+
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database);
@@ -460,7 +390,6 @@ public class JournalDataSource
return result;
}
-
private boolean innerIsJournalAlreadyExist(String name, SQLiteDatabase database)
{
boolean result = false;
@@ -488,8 +417,8 @@ public class JournalDataSource
boolean result = false;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME,
- BashgidSqliteHelper.COLUMN_JOURNAL_NAME }, BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?",
- new String[] { articleName, journalName }, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_JOURNAL_NAME }, BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_JOURNAL_NAME
+ + "=?", new String[] { articleName, journalName }, null, null, null, null);
if (cursor != null)
{
@@ -566,7 +495,8 @@ public class JournalDataSource
JournalRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
- BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
+ BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY,
+ BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
@@ -574,7 +504,8 @@ public class JournalDataSource
{
cursor.moveToFirst();
- result = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5));
+ result = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4),
+ cursor.getInt(5));
}
cursor.close();
cursor = null;
diff --git a/android/src/fishrungames/bashgid/core/db/NewsDataSource.java b/android/src/fishrungames/bashgid/core/db/NewsDataSource.java
deleted file mode 100644
index 8f5b14a..0000000
--- a/android/src/fishrungames/bashgid/core/db/NewsDataSource.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package fishrungames.bashgid.core.db;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Locale;
-import java.util.concurrent.Semaphore;
-
-import fishrungames.bashgid.core.NewsManager;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.SQLException;
-import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
-
-public class NewsDataSource
-{
-
- // Xperimental -- move somewhere
- public static final SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
-
- // private SQLiteDatabase database = null;
-
- private BashgidSqliteHelper dbHelper = null;
-
- private String[] allColumns = { BashgidSqliteHelper.COLUMN_ID, BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION,
- BashgidSqliteHelper.COLUMN_IMAGE_URL, BashgidSqliteHelper.COLUMN_PUBDATE };
-
- public NewsDataSource(Context context, BashgidSqliteHelper dbHelper)
- {
-
- this.dbHelper = dbHelper;
-
- }
-
- private void createNewsRecord(SQLiteDatabase database, NewsManager.NewsRecord newsRecord)
- {
-
- ContentValues values = new ContentValues();
-
- values.put(BashgidSqliteHelper.COLUMN_TITLE, newsRecord.title);
- values.put(BashgidSqliteHelper.COLUMN_DESCRIPTION, newsRecord.description);
- values.put(BashgidSqliteHelper.COLUMN_IMAGE_URL, newsRecord.imageId);
- values.put(BashgidSqliteHelper.COLUMN_PUBDATE, iso8601Format.format(newsRecord.pubDate));
-
- database.insert(BashgidSqliteHelper.TABLE_NEWS, null, values);
-
- }
-
- public void replaceNews(ArrayList newsRecordArr)
- {
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
- try
- {
- database.delete(BashgidSqliteHelper.TABLE_NEWS, null, null);
-
- for (NewsManager.NewsRecord newsRecord : newsRecordArr)
- {
- createNewsRecord(database, newsRecord);
- }
-
- dbHelper.close();
- }
- finally
- {
- dbHelper.close();
- }
- }
-
- }
-
- public ArrayList getNews()
- {
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- ArrayList newsRecordArr = new ArrayList();
-
- if (database != null)
- {
- try
- {
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_NEWS, allColumns, null, null, null, null, null);
-
- cursor.moveToFirst();
-
- while (!cursor.isAfterLast())
- {
- NewsManager.NewsRecord newsRecord = cursorToNewsRecord(cursor);
- newsRecordArr.add(newsRecord);
- cursor.moveToNext();
- }
-
- cursor.close();
-
- }
- finally
- {
- dbHelper.close();
- }
- }
-
- return newsRecordArr;
- }
-
- public ArrayList searchNewsByString(String searchText)
- {
-
-
- ArrayList newsRecordArr = new ArrayList();
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
-
- try
- {
- Cursor cursor = database.query(true, BashgidSqliteHelper.TABLE_NEWS, allColumns, BashgidSqliteHelper.COLUMN_TITLE + " LIKE '%" + searchText + "%'",
- null, null, null, null, null);
-
- cursor.moveToFirst();
-
- while (!cursor.isAfterLast())
- {
- NewsManager.NewsRecord newsRecord = cursorToNewsRecord(cursor);
- newsRecordArr.add(newsRecord);
- cursor.moveToNext();
- }
-
- cursor.close();
- }
- finally
- {
- dbHelper.close();
- }
-
-
- }
-
- return newsRecordArr;
- }
-
- private NewsManager.NewsRecord cursorToNewsRecord(Cursor cursor)
- {
-
- NewsManager.NewsRecord newsRecord = null;
- try
- {
- newsRecord = new NewsManager.NewsRecord(cursor.getString(1), cursor.getString(2), cursor.getString(3), iso8601Format.parse(cursor.getString(4)));
- } catch (ParseException e)
- {
- e.printStackTrace();
- }
-
- return newsRecord;
- }
-}
diff --git a/android/src/fishrungames/bashgid/core/db/NewsDbRecord.java b/android/src/fishrungames/bashgid/core/db/NewsDbRecord.java
deleted file mode 100644
index f5719e6..0000000
--- a/android/src/fishrungames/bashgid/core/db/NewsDbRecord.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package fishrungames.bashgid.core.db;
-
-import java.util.Date;
-
-public class NewsDbRecord
-{
- public long id;
- public String title;
- public String description;
- public String imageId;
- public Date pubDate;
-}
diff --git a/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java b/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java
index c9ce5da..0f016dc 100644
--- a/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java
@@ -8,7 +8,6 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
public class PhotoDataSource
{
@@ -21,7 +20,7 @@ public class PhotoDataSource
this.dbHelper = dbHelper;
}
-
+
public void AddOrReplacePhoto(PhotoRecordData recordData)
{
SQLiteDatabase database = dbHelper.getWritableDatabase();
@@ -46,10 +45,10 @@ public class PhotoDataSource
database.insert(BashgidSqliteHelper.TABLE_PHOTO, null, values);
} else
{
- database.update(BashgidSqliteHelper.TABLE_PHOTO, values, BashgidSqliteHelper.COLUMN_IMAGE_URL + " = " +"\"" + recordData.imageUrl +"\"", null);
+ database.update(BashgidSqliteHelper.TABLE_PHOTO, values, BashgidSqliteHelper.COLUMN_IMAGE_URL + " = " + "\"" + recordData.imageUrl + "\"",
+ null);
}
- //Log.e("a", "aaa4");
} finally
{
dbHelper.close();
@@ -81,7 +80,7 @@ public class PhotoDataSource
public PhotoRecordData InnerGetPhotoByImageUrl(String imageUrl, SQLiteDatabase database)
{
-
+
PhotoRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_TITLE,
@@ -93,15 +92,14 @@ public class PhotoDataSource
{
if (cursor.moveToFirst())
{
-
- result = new PhotoRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3),
- cursor.getDouble(4), cursor.getDouble(5));
-
+ result = new PhotoRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getDouble(4),
+ cursor.getDouble(5));
+
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database);
}
-
+
cursor.close();
cursor = null;
}
@@ -113,7 +111,7 @@ public class PhotoDataSource
private boolean isPhotoAlreadyExist(String imageUrl, SQLiteDatabase database)
{
boolean result = false;
-
+
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?", new String[] { imageUrl }, null, null, null, null);
@@ -123,7 +121,7 @@ public class PhotoDataSource
{
result = true;
}
-
+
cursor.close();
cursor = null;
}
diff --git a/android/src/fishrungames/bashgid/core/db/TranslationDataSource.java b/android/src/fishrungames/bashgid/core/db/TranslationDataSource.java
index 3bc0f32..ae49060 100644
--- a/android/src/fishrungames/bashgid/core/db/TranslationDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/TranslationDataSource.java
@@ -3,7 +3,6 @@ package fishrungames.bashgid.core.db;
import java.util.ArrayList;
import java.util.Locale;
-
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
import android.content.ContentValues;
@@ -12,7 +11,6 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-
public class TranslationDataSource
{
@@ -42,14 +40,14 @@ public class TranslationDataSource
values.put(BashgidSqliteHelper.COLUMN_TEXT_EN_UP, recordData.textEnUp);
values.put(BashgidSqliteHelper.COLUMN_TEXT_RU_UP, recordData.textRuUp);
values.put(BashgidSqliteHelper.COLUMN_TEXT_ZH_UP, recordData.textZhUp);
-
-
+
if (!innerIsTranslationAlreadyExist(recordData.name, database))
{
database.insert(BashgidSqliteHelper.TABLE_TRANSLATION, null, values);
} else
{
- database.update(BashgidSqliteHelper.TABLE_TRANSLATION, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
+ database.update(BashgidSqliteHelper.TABLE_TRANSLATION, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"",
+ null);
}
} finally
@@ -59,34 +57,32 @@ public class TranslationDataSource
}
}
-
+
public String TryTranslateText(String name, SQLiteDatabase database)
{
if (innerIsTranslationAlreadyExist(name, database))
{
TranslationRecordData record = innerGetTranslationByName(name, database);
-
+
if (Locale.getDefault().equals(new Locale("ru")))
{
return record.textRu;
- }
- else if (Locale.getDefault() == Locale.CHINA)
+ } else if (Locale.getDefault() == Locale.CHINA)
{
return record.textZh;
}
-
+
return record.textEn;
- }
- else
+ } else
{
return name;
}
}
-
+
public ArrayList SearchRussian(String partString)
{
ArrayList result = new ArrayList();
-
+
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
@@ -104,11 +100,11 @@ public class TranslationDataSource
return result;
}
-
+
public ArrayList SearchEnglish(String partString)
{
ArrayList result = new ArrayList();
-
+
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
@@ -126,11 +122,11 @@ public class TranslationDataSource
return result;
}
-
+
public ArrayList SearchChinese(String partString)
{
ArrayList result = new ArrayList();
-
+
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
@@ -148,60 +144,7 @@ public class TranslationDataSource
return result;
}
-/*
- public boolean IsTranslationAlreadyExist(String name)
- {
- boolean result = false;
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
-
- try
- {
- result = innerIsAlbumAlreadyExist(name, database);
-
- } finally
- {
- dbHelper.close();
- }
- }
-
- return result;
-
- }*/
-/*
- public void AddPhotoToAlbum(String imageUrl, String albumName)
- {
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
-
- try
- {
- ContentValues values = new ContentValues();
-
- values.put(BashgidSqliteHelper.COLUMN_IMAGE_URL, imageUrl);
- values.put(BashgidSqliteHelper.COLUMN_NAME, albumName);
-
- if (!innerPhotoAlbumRelationAlreadyExist(imageUrl, albumName, database))
- {
- Log.e("a", "aaa1");
- database.insert(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, null, values);
- Log.e("a", "aaa2");
- }
- Log.e("a", "aaa3");
-
- } finally
- {
- dbHelper.close();
- }
- }
- }
-*/
-
public TranslationRecordData GetTranslationRecordData(String name)
{
TranslationRecordData result = null;
@@ -215,30 +158,6 @@ public class TranslationDataSource
result = innerGetTranslationByName(name, database);
-
- } finally
- {
- dbHelper.close();
- }
- }
-
- return result;
- }
-
- /*
- public AlbumFullData GetAlbumFullData(String name)
- {
- AlbumFullData result = null;
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
- try
- {
-
- result = InnerGetAlbumFullData(name, database);
-
} finally
{
dbHelper.close();
@@ -248,122 +167,10 @@ public class TranslationDataSource
return result;
}
- public AlbumFullData InnerGetAlbumFullData(String name, SQLiteDatabase database)
- {
-
- AlbumFullData result = null;
-
- AlbumRecordData recordData = innerGetAlbumByName(name, database);
-
- if (recordData != null)
- {
-
- result = new AlbumFullData(recordData);
-
- ArrayList imageUrlArr = innerGetImageUrlArrInAlbum(name, database);
-
- for (String imageUrl : imageUrlArr)
- {
- result.photoRecordArr.add(MainActivity.getInstance().photoDataSource.InnerGetPhotoByImageUrl(imageUrl, database));
- }
-
- }
-
- return result;
- }
-
- public AlbumShortData GetAlbumShortData(String name)
- {
- AlbumShortData result = null;
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
- try
- {
-
- AlbumRecordData recordData = innerGetAlbumByName(name, database);
-
- if (recordData != null)
- {
-
- result = new AlbumShortData(recordData);
-
- ArrayList imageUrlArr = innerGetImageUrlArrInAlbum(name, database);
-
- result.photoCount = imageUrlArr.size();
-
- if (imageUrlArr.size() > 0)
- {
- result.firstImageUrl = imageUrlArr.get(0);
- }
- }
-
- } finally
- {
- dbHelper.close();
- }
- }
-
- return result;
- }
-
- public ArrayList GetAllAlbumShortData()
- {
-
- ArrayList result = new ArrayList();
-
- SQLiteDatabase database = dbHelper.getWritableDatabase();
-
- if (database != null)
- {
- try
- {
-
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME,
- BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION }, null, null, null, null, null, null);
-
- if (cursor != null)
- {
- if (cursor.moveToFirst())
- {
- do
- {
-
- AlbumShortData shortData = new AlbumShortData(new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
-
- ArrayList imageUrlArr = innerGetImageUrlArrInAlbum(shortData.name, database);
-
- shortData.photoCount = imageUrlArr.size();
-
- if (imageUrlArr.size() > 0)
- {
- shortData.firstImageUrl = imageUrlArr.get(0);
- }
-
- result.add(shortData);
- } while (cursor.moveToNext());
-
- }
-
- cursor.close();
- }
-
- } finally
- {
- dbHelper.close();
- }
-
- }
-
- return result;
- }
-*/
private boolean innerIsTranslationAlreadyExist(String name, SQLiteDatabase database)
{
boolean result = false;
-
+
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
+ "=?", new String[] { name }, null, null, null, null);
@@ -373,88 +180,34 @@ public class TranslationDataSource
{
result = true;
}
-
+
cursor.close();
cursor = null;
-
-
- }
- return result;
-
- }
-/*
- private boolean innerPhotoAlbumRelationAlreadyExist(String imageUrl, String name, SQLiteDatabase database)
- {
- boolean result = false;
-
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL,
- BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?" + " AND " + BashgidSqliteHelper.COLUMN_NAME + "=?",
- new String[] { imageUrl, name }, null, null, null, null);
-
- if (cursor != null)
- {
- if (cursor.getCount() > 0)
- {
- result = true;
- }
-
- cursor.close();
}
return result;
}
- private ArrayList innerGetImageUrlArrInAlbum(String name, SQLiteDatabase database)
+ public TranslationRecordData innerGetTranslationByName(String name, SQLiteDatabase database)
{
- ArrayList result = new ArrayList();
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
+ TranslationRecordData result = null;
+
+ Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME,
+ BashgidSqliteHelper.COLUMN_TEXT_EN, BashgidSqliteHelper.COLUMN_TEXT_RU, BashgidSqliteHelper.COLUMN_TEXT_ZH,
+ BashgidSqliteHelper.COLUMN_TEXT_EN_UP, BashgidSqliteHelper.COLUMN_TEXT_RU_UP, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP },
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
- do
- {
- result.add(cursor.getString(0));
- } while (cursor.moveToNext());
-
+ result = new TranslationRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4),
+ cursor.getString(5), cursor.getString(6));
}
-
- cursor.close();
- }
- return result;
-
- }
-
-*/
- public TranslationRecordData innerGetTranslationByName(String name, SQLiteDatabase database)
- {
-
- TranslationRecordData result = null;
-
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME,
- BashgidSqliteHelper.COLUMN_TEXT_EN, BashgidSqliteHelper.COLUMN_TEXT_RU, BashgidSqliteHelper.COLUMN_TEXT_ZH,
- BashgidSqliteHelper.COLUMN_TEXT_EN_UP, BashgidSqliteHelper.COLUMN_TEXT_RU_UP, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP}, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
-
- if (cursor != null)
- {
- if (cursor.moveToFirst())
- {
- result = new TranslationRecordData(
- cursor.getString(0),
- cursor.getString(1),
- cursor.getString(2),
- cursor.getString(3),
- cursor.getString(4),
- cursor.getString(5),
- cursor.getString(6));
- }
-
cursor.close();
cursor = null;
}
@@ -462,13 +215,14 @@ public class TranslationDataSource
return result;
}
-
+
public ArrayList innerGetTranslationNameByPartString_Russian(String partString, SQLiteDatabase database)
{
-
+
ArrayList result = new ArrayList();
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_RU_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
+ Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
+ BashgidSqliteHelper.COLUMN_TEXT_RU_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
@@ -479,7 +233,7 @@ public class TranslationDataSource
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
-
+
cursor.close();
cursor = null;
}
@@ -487,13 +241,14 @@ public class TranslationDataSource
return result;
}
-
+
public ArrayList innerGetTranslationNameByPartString_English(String partString, SQLiteDatabase database)
{
-
+
ArrayList result = new ArrayList();
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_EN_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
+ Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
+ BashgidSqliteHelper.COLUMN_TEXT_EN_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
@@ -504,7 +259,7 @@ public class TranslationDataSource
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
-
+
cursor.close();
cursor = null;
}
@@ -512,13 +267,14 @@ public class TranslationDataSource
return result;
}
-
+
public ArrayList innerGetTranslationNameByPartString_Chinese(String partString, SQLiteDatabase database)
{
-
+
ArrayList result = new ArrayList();
-
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
+
+ Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
+ BashgidSqliteHelper.COLUMN_TEXT_ZH_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
@@ -529,7 +285,7 @@ public class TranslationDataSource
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
-
+
cursor.close();
cursor = null;
}
@@ -537,8 +293,5 @@ public class TranslationDataSource
return result;
}
-
-
-
}
diff --git a/android/src/fishrungames/bashgid/core/db/VideoDataSource.java b/android/src/fishrungames/bashgid/core/db/VideoDataSource.java
index 8e93220..7d325c0 100644
--- a/android/src/fishrungames/bashgid/core/db/VideoDataSource.java
+++ b/android/src/fishrungames/bashgid/core/db/VideoDataSource.java
@@ -1,6 +1,5 @@
package fishrungames.bashgid.core.db;
-
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
@@ -9,7 +8,6 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
public class VideoDataSource
{
@@ -45,7 +43,8 @@ public class VideoDataSource
database.insert(BashgidSqliteHelper.TABLE_VIDEO, null, values);
} else
{
- database.update(BashgidSqliteHelper.TABLE_VIDEO, values, BashgidSqliteHelper.COLUMN_VIDEO_URL + " = " +"\"" + recordData.videoUrl +"\"", null);
+ database.update(BashgidSqliteHelper.TABLE_VIDEO, values, BashgidSqliteHelper.COLUMN_VIDEO_URL + " = " + "\"" + recordData.videoUrl + "\"",
+ null);
}
} finally
@@ -55,19 +54,19 @@ public class VideoDataSource
}
}
-
+
public VideoRecordData GetVideoByVideoUrl(String videoUrl)
{
VideoRecordData result = null;
-
+
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
- result = InnerGetVideoByVideoUrl(videoUrl, database);
-
+ result = InnerGetVideoByVideoUrl(videoUrl, database);
+
} finally
{
dbHelper.close();
@@ -76,47 +75,42 @@ public class VideoDataSource
return result;
}
-
+
public VideoRecordData InnerGetVideoByVideoUrl(String videoUrl, SQLiteDatabase database)
{
VideoRecordData result = null;
-
- Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO,
- new String[] { BashgidSqliteHelper.COLUMN_TYPE, BashgidSqliteHelper.COLUMN_VIDEO_URL, BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_URL, BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_HASH },
- BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { videoUrl }, null, null, null, null);
- if (cursor != null)
- {
- if (cursor.moveToFirst())
- {
-
-
- result = new VideoRecordData(
- cursor.getInt(0),
- cursor.getString(1),
- cursor.getString(2),
- cursor.getString(3),
- cursor.getString(4),
- cursor.getString(5)
- );
-
- result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
- result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database);
- }
-
- cursor.close();
- cursor = null;
- }
-
- return result;
+ Cursor cursor = database
+ .query(BashgidSqliteHelper.TABLE_VIDEO, new String[] { BashgidSqliteHelper.COLUMN_TYPE, BashgidSqliteHelper.COLUMN_VIDEO_URL,
+ BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_URL,
+ BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_HASH }, BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { videoUrl }, null, null,
+ null, null);
+
+ if (cursor != null)
+ {
+ if (cursor.moveToFirst())
+ {
+
+ result = new VideoRecordData(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4),
+ cursor.getString(5));
+
+ result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
+ result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database);
+ }
+
+ cursor.close();
+ cursor = null;
+ }
+
+ return result;
}
private boolean isVideoAlreadyExist(String videoUrl, SQLiteDatabase database)
{
boolean result = false;
-
+
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL },
BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { videoUrl }, null, null, null, null);
@@ -126,13 +120,12 @@ public class VideoDataSource
{
result = true;
}
-
+
cursor.close();
cursor = null;
}
-
+
return result;
-
}