Fixing bugs
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="fishrungames.bashgid"
|
package="fishrungames.bashgid"
|
||||||
android:versionCode="1"
|
android:versionCode="2"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.01" >
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:glEsVersion="0x00020000"
|
android:glEsVersion="0x00020000"
|
||||||
@ -16,10 +16,6 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<!-- The following two permissions are not required to use
|
|
||||||
Google Maps Android API v2, but are recommended. -->
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
@ -34,8 +30,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation"
|
android:configChanges="orientation" >
|
||||||
android:screenOrientation="portrait" >
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
@ -45,11 +40,6 @@
|
|||||||
<meta-data android:name="com.google.android.gms.version"
|
<meta-data android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version" />
|
android:value="@integer/google_play_services_version" />
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="com.google.android.maps.v2.API_KEY"
|
|
||||||
android:value="AIzaSyAN67lwiJpFHprBo7VOio4jAdSzIIOY4s8"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 85 KiB |
BIN
android/res/drawable-hdpi/ic_action_refresh.png
Normal file
After Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 1.0 KiB |
BIN
android/res/drawable-mdpi/ic_action_refresh.png
Normal file
After Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
android/res/drawable-xhdpi/drawer_agenda.png
Normal file
After Width: | Height: | Size: 565 B |
BIN
android/res/drawable-xhdpi/drawer_bookmark.png
Normal file
After Width: | Height: | Size: 608 B |
BIN
android/res/drawable-xhdpi/drawer_books.png
Normal file
After Width: | Height: | Size: 466 B |
BIN
android/res/drawable-xhdpi/drawer_gear.png
Normal file
After Width: | Height: | Size: 1022 B |
BIN
android/res/drawable-xhdpi/drawer_id.png
Normal file
After Width: | Height: | Size: 718 B |
BIN
android/res/drawable-xhdpi/drawer_industry.png
Normal file
After Width: | Height: | Size: 727 B |
BIN
android/res/drawable-xhdpi/drawer_news.png
Normal file
After Width: | Height: | Size: 553 B |
BIN
android/res/drawable-xhdpi/drawer_phone.png
Normal file
After Width: | Height: | Size: 1006 B |
BIN
android/res/drawable-xhdpi/drawer_photography.png
Normal file
After Width: | Height: | Size: 625 B |
BIN
android/res/drawable-xhdpi/drawer_pushpin.png
Normal file
After Width: | Height: | Size: 1006 B |
BIN
android/res/drawable-xhdpi/drawer_tv.png
Normal file
After Width: | Height: | Size: 617 B |
BIN
android/res/drawable-xhdpi/ic_action_refresh.png
Normal file
After Width: | Height: | Size: 901 B |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 5.5 KiB |
BIN
android/res/drawable-xxhdpi/ic_action_refresh.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 25 KiB |
@ -13,7 +13,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:background="@color/bkg2"
|
android:background="@color/button_default"
|
||||||
android:drawableLeft="@drawable/ic_action_web_site"
|
android:drawableLeft="@drawable/ic_action_web_site"
|
||||||
android:text="@string/go_to_website"
|
android:text="@string/go_to_website"
|
||||||
android:textSize="@dimen/xlarge_text_size" />
|
android:textSize="@dimen/xlarge_text_size" />
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:background="@color/bkg2"
|
android:background="@color/button_default"
|
||||||
android:drawableLeft="@drawable/ic_action_call"
|
android:drawableLeft="@drawable/ic_action_call"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:textSize="@dimen/xlarge_text_size" />
|
android:textSize="@dimen/xlarge_text_size" />
|
||||||
|
@ -7,13 +7,15 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:showDividers="middle" >
|
android:showDividers="middle" >
|
||||||
|
|
||||||
<fishrungames.bashgid.DynamicImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:cropToPadding="false"
|
android:cropToPadding="false"
|
||||||
|
android:minHeight="10dp"
|
||||||
|
android:minWidth="10dp"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -11,15 +11,17 @@
|
|||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:indeterminate="true" />
|
android:indeterminate="true" />
|
||||||
|
|
||||||
<GridView
|
<fishrungames.bashgid.StaticGridView
|
||||||
android:id="@+id/gridView"
|
android:id="@+id/gridView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
android:horizontalSpacing="@dimen/grid_view_horizontal_spacing"
|
android:horizontalSpacing="@dimen/grid_view_horizontal_spacing"
|
||||||
android:numColumns="@integer/grid_columns"
|
android:numColumns="@integer/grid_columns"
|
||||||
android:verticalSpacing="@dimen/grid_view_vertical_spacing" >
|
android:verticalSpacing="@dimen/grid_view_vertical_spacing"
|
||||||
|
android:isScrollContainer="false"
|
||||||
|
android:stretchMode="columnWidth" />
|
||||||
|
|
||||||
|
|
||||||
</GridView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,4 +20,13 @@
|
|||||||
|
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="@dimen/progress_bar_size"
|
||||||
|
android:layout_height="@dimen/progress_bar_size"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -3,19 +3,18 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="0dp"
|
android:layout_margin="0dp"
|
||||||
android:background="@color/bkg1"
|
android:background="@color/black"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context="fishrungames.bashgid.MainPageFragment" >
|
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||||
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/listView"
|
android:id="@+id/listView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/large_margin"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginLeft="@dimen/large_margin"
|
android:layout_marginLeft="@dimen/large_margin"
|
||||||
android:layout_marginRight="@dimen/large_margin"
|
android:layout_marginRight="@dimen/large_margin"
|
||||||
android:divider="@color/bkg2"
|
android:divider="@color/black"
|
||||||
android:dividerHeight="@dimen/small_divider_height" >
|
android:dividerHeight="@dimen/small_divider_height" >
|
||||||
|
|
||||||
</ListView>
|
</ListView>
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
style="?android:attr/borderlessButtonStyle"
|
style="?android:attr/borderlessButtonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/button_default"
|
||||||
android:text="@string/call_support"
|
android:text="@string/call_support"
|
||||||
android:textSize="@dimen/small_text_size"
|
android:textSize="@dimen/small_text_size"
|
||||||
android:layout_marginBottom="@dimen/medium_margin"
|
android:layout_marginBottom="@dimen/medium_margin"
|
||||||
@ -149,6 +150,7 @@
|
|||||||
style="?android:attr/borderlessButtonStyle"
|
style="?android:attr/borderlessButtonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/button_default"
|
||||||
android:text="@string/visit_kitap"
|
android:text="@string/visit_kitap"
|
||||||
android:textSize="@dimen/small_text_size"
|
android:textSize="@dimen/small_text_size"
|
||||||
android:layout_marginBottom="@dimen/medium_margin" />
|
android:layout_marginBottom="@dimen/medium_margin" />
|
||||||
@ -158,6 +160,7 @@
|
|||||||
style="?android:attr/borderlessButtonStyle"
|
style="?android:attr/borderlessButtonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/button_default"
|
||||||
android:text="@string/visit_developer"
|
android:text="@string/visit_developer"
|
||||||
android:textSize="@dimen/small_text_size"
|
android:textSize="@dimen/small_text_size"
|
||||||
android:layout_marginBottom="@dimen/medium_margin" />
|
android:layout_marginBottom="@dimen/medium_margin" />
|
||||||
@ -167,6 +170,7 @@
|
|||||||
style="?android:attr/borderlessButtonStyle"
|
style="?android:attr/borderlessButtonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/button_default"
|
||||||
android:text="@string/visit_translator"
|
android:text="@string/visit_translator"
|
||||||
android:textSize="@dimen/small_text_size"
|
android:textSize="@dimen/small_text_size"
|
||||||
android:layout_marginBottom="@dimen/medium_margin" />
|
android:layout_marginBottom="@dimen/medium_margin" />
|
||||||
|
@ -32,7 +32,9 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/descriptionTextView"
|
android:id="@+id/descriptionTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/medium_margin" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -36,7 +36,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:text="@string/lang_english"
|
android:text="@string/lang_english"
|
||||||
android:textSize="@dimen/language_text_size" />
|
android:textColor="@color/text_white"
|
||||||
|
android:textSize="@dimen/language_text_size"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/image_flag_usa"
|
android:id="@+id/image_flag_usa"
|
||||||
@ -65,7 +67,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:text="@string/lang_russian"
|
android:text="@string/lang_russian"
|
||||||
android:textSize="@dimen/language_text_size" />
|
android:textColor="@color/text_white"
|
||||||
|
android:textSize="@dimen/language_text_size"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/image_flag_russia"
|
android:id="@+id/image_flag_russia"
|
||||||
@ -94,7 +98,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:text="@string/lang_chinese"
|
android:text="@string/lang_chinese"
|
||||||
android:textSize="@dimen/language_text_size" />
|
android:textColor="@color/text_white"
|
||||||
|
android:textSize="@dimen/language_text_size"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/image_flag_china"
|
android:id="@+id/image_flag_china"
|
||||||
|
@ -2,27 +2,27 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/LinearLayout1"
|
android:id="@+id/LinearLayout1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/video_page_height"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@color/bkg1"
|
android:background="@color/bkg1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:showDividers="middle" >
|
android:showDividers="middle" >
|
||||||
|
|
||||||
<fishrungames.bashgid.DynamicImageView
|
<fishrungames.bashgid.SquareImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="center_vertical"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:cropToPadding="false"
|
android:cropToPadding="false"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/nameTextView"
|
android:id="@+id/nameTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="clip_vertical"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:text="dsdsd"
|
android:text="dsdsd"
|
||||||
android:textSize="@dimen/large_text_size"
|
android:textSize="@dimen/large_text_size"
|
@ -14,5 +14,60 @@
|
|||||||
|
|
||||||
<include layout="@layout/main_page_news"/>
|
<include layout="@layout/main_page_news"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/View01"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/large_divider_height"
|
||||||
|
android:background="@color/bkg2" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/bkg1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:paddingRight="20dp" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shortCatalogTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_margin="@dimen/medium_margin"
|
||||||
|
android:text="@string/featured"
|
||||||
|
android:textSize="@dimen/large_text_size"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/refreshCatalogButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:background="@drawable/transparent"
|
||||||
|
android:src="@drawable/ic_action_refresh" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/databaseDownloadProgressBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="false"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="0" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -6,23 +6,40 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context="fishrungames.bashgid.MainPageFragment" >
|
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/selectLanguageTextView"
|
android:id="@+id/selectLanguageTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:text="@string/news_header"
|
android:text="@string/news_header"
|
||||||
android:textSize="@dimen/large_text_size"
|
android:textSize="@dimen/large_text_size"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/refreshNewsButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:background="@drawable/transparent"
|
||||||
|
android:src="@drawable/ic_action_refresh" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/newsDownloadProgressBar"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="@dimen/progress_bar_size"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/progress_bar_size"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:indeterminate="false"
|
||||||
android:indeterminate="true" />
|
android:max="100"
|
||||||
|
android:progress="0" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -36,6 +53,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/medium_margin"
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
|
android:layout_marginRight="@dimen/medium_margin"
|
||||||
android:background="@drawable/transparent_button"
|
android:background="@drawable/transparent_button"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
@ -56,6 +74,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/medium_margin"
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
|
android:layout_marginRight="@dimen/medium_margin"
|
||||||
android:background="@drawable/transparent_button"
|
android:background="@drawable/transparent_button"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
@ -76,6 +95,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/medium_margin"
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
|
android:layout_marginRight="@dimen/medium_margin"
|
||||||
android:background="@drawable/transparent_button"
|
android:background="@drawable/transparent_button"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
@ -90,7 +110,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:background="@drawable/transparent"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
|
android:background="@color/button_default"
|
||||||
|
android:padding="@dimen/medium_margin"
|
||||||
android:text="@string/other_news" />
|
android:text="@string/other_news" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
android:id="@+id/searchEditText"
|
android:id="@+id/searchEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
android:hint="@string/enter_search_query" >
|
android:hint="@string/enter_search_query" >
|
||||||
|
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
@ -41,6 +43,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:drawableLeft="@drawable/ic_action_search"
|
android:drawableLeft="@drawable/ic_action_search"
|
||||||
|
android:layout_margin="@dimen/medium_margin"
|
||||||
|
android:background="@color/button_default"
|
||||||
|
android:padding="@dimen/medium_margin"
|
||||||
android:text="@string/search_title"
|
android:text="@string/search_title"
|
||||||
android:textSize="@dimen/large_text_size" />
|
android:textSize="@dimen/large_text_size" />
|
||||||
|
|
||||||
|
@ -8,22 +8,38 @@
|
|||||||
android:paddingRight="20dp"
|
android:paddingRight="20dp"
|
||||||
tools:context="fishrungames.bashgid.MainPageFragment" >
|
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dateTextView"
|
android:id="@+id/dateTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
android:layout_margin="@dimen/medium_margin"
|
android:layout_margin="@dimen/medium_margin"
|
||||||
android:text="@string/news_header"
|
android:text="@string/news_header"
|
||||||
android:textSize="@dimen/large_text_size"
|
android:textSize="@dimen/large_text_size"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/refreshNewsButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:background="@drawable/transparent"
|
||||||
|
android:src="@drawable/ic_action_refresh" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/newsDownloadProgressBar"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="@dimen/progress_bar_size"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/progress_bar_size"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:indeterminate="false"
|
||||||
android:indeterminate="true" />
|
android:max="100"
|
||||||
|
android:progress="0" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,16 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/LinearLayout"
|
android:id="@+id/LinearLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/light_grey_1"
|
android:layout_gravity="center_horizontal"
|
||||||
android:orientation="horizontal"
|
android:background="@color/black"
|
||||||
|
android:orientation="vertical"
|
||||||
android:showDividers="middle" >
|
android:showDividers="middle" >
|
||||||
|
|
||||||
<fishrungames.bashgid.DynamicImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:cropToPadding="false"
|
android:cropToPadding="false"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/LinearLayout1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@color/light_grey_1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:showDividers="middle" >
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/imageButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/related_image"
|
|
||||||
android:scaleType="fitCenter" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dateTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="TextView" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -3,6 +3,7 @@
|
|||||||
android:id="@+id/LinearLayout1"
|
android:id="@+id/LinearLayout1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
@ -32,6 +33,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/large_margin"
|
android:layout_margin="@dimen/large_margin"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
|
android:textColor="@color/text_white"
|
||||||
android:textSize="@dimen/xlarge_text_size"
|
android:textSize="@dimen/xlarge_text_size"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
@ -42,6 +44,7 @@
|
|||||||
android:layout_marginLeft="@dimen/large_margin"
|
android:layout_marginLeft="@dimen/large_margin"
|
||||||
android:layout_marginRight="@dimen/large_margin"
|
android:layout_marginRight="@dimen/large_margin"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
|
android:textColor="@color/text_white"
|
||||||
android:textSize="@dimen/medium_text_size" />
|
android:textSize="@dimen/medium_text_size" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -7,20 +7,30 @@
|
|||||||
tools:context="fishrungames.bashgid.SearchFragment" >
|
tools:context="fishrungames.bashgid.SearchFragment" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/addressTextView"
|
android:id="@+id/titleTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="@dimen/medium_text_size"
|
android:textSize="@dimen/xlarge_text_size"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/smallHintTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/search_small_hint"
|
||||||
|
android:textSize="@dimen/xsmall_text_size" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/editText"
|
android:id="@+id/editText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/enter_search_query"
|
android:hint="@string/enter_search_query"
|
||||||
android:inputType="text" >
|
android:inputType="text"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="@dimen/medium_text_size" >
|
||||||
|
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
</EditText>
|
</EditText>
|
||||||
@ -28,6 +38,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/hintTextView"
|
android:id="@+id/hintTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/xsmall_text_size" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -4,7 +4,7 @@
|
|||||||
<item android:id="@+id/action_search"
|
<item android:id="@+id/action_search"
|
||||||
android:title="@string/search_title"
|
android:title="@string/search_title"
|
||||||
android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
|
android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
|
||||||
app:showAsAction="always|withText"
|
app:showAsAction="always"
|
||||||
android:actionViewClass="android.widget.SearchView" />
|
android:actionViewClass="android.widget.SearchView" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -49,11 +49,6 @@
|
|||||||
|
|
||||||
<string name="go_to_website">Перейти на сайт</string>
|
<string name="go_to_website">Перейти на сайт</string>
|
||||||
|
|
||||||
<string name="buy">Купить...</string>
|
|
||||||
<string name="read">Читать</string>
|
|
||||||
<string name="price">Стоимость: </string>
|
|
||||||
<string name="rub">Руб.</string>
|
|
||||||
|
|
||||||
<string name="journal_open_map">Показать на карте</string>
|
<string name="journal_open_map">Показать на карте</string>
|
||||||
<string name="map_is_loading">Карта загружается...</string>
|
<string name="map_is_loading">Карта загружается...</string>
|
||||||
<string name="map_is_loaded">Карта загружена</string>
|
<string name="map_is_loaded">Карта загружена</string>
|
||||||
@ -74,7 +69,7 @@
|
|||||||
<string name="search_is_performing">Идет поиск, пожалуйста, подождите...</string>
|
<string name="search_is_performing">Идет поиск, пожалуйста, подождите...</string>
|
||||||
<string name="search_at_least_3_symbols">Чтобы начать поиск, введите как минимум 3 символа</string>
|
<string name="search_at_least_3_symbols">Чтобы начать поиск, введите как минимум 3 символа</string>
|
||||||
|
|
||||||
<string name="credits">Башгид (c) 2015\n\nВсе права принадлежат ГУП «Китап»\nТелефон: +73472238838\nhttp://kitap-ufa.ru/\n\nРазработчик - Владислав Хорев\nТелефон: +79260492730\nEmail: mephi1984@gmail.com\n\nПеревод на китайский язык сделан Лилией Лисицей\nТелефон: +8615756011926\nEmail:lilialoo926@mail.ru</string>
|
<string name="credits">Башгид (c) 2015\n\nВсе права принадлежат ГУП «Китап»\nТелефон: +73472238838\nhttp://kitap-ufa.ru/\n\nРазработчик - Владислав Хорев\nТелефон: +79260492730\nEmail: mephi1984@gmail.com\nhttp://fishrungames.ru/\n\nПеревод на китайский язык сделан Лилией Лисицей\nТелефон: +8615756011926\nEmail: littlefoxlilia@mail.ru\nhttp://littlefoxlilia.ru/</string>
|
||||||
|
|
||||||
<string name="call_support">У вас возникли трудности при работе с приложением? Нажмите сюда, чтобы позвонить в техподдержку.</string>
|
<string name="call_support">У вас возникли трудности при работе с приложением? Нажмите сюда, чтобы позвонить в техподдержку.</string>
|
||||||
|
|
||||||
@ -91,5 +86,12 @@
|
|||||||
<string name="category_is_loaded">Категория загружена</string>
|
<string name="category_is_loaded">Категория загружена</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="search_small_hint">Чтобы искать во всех категориях, нажмите кнопку Поиск справа вверху</string>
|
||||||
|
|
||||||
|
<string name="littlefoxlilia_link" formatted="false">http://littlefoxlilia.ru/ru/%D0%BE-%D1%81%D0%B5%D0%B1%D0%B5/</string>
|
||||||
|
|
||||||
|
<string name="featured">Символы РБ</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">俄罗斯联邦巴什基尔自治共和国指南</string>
|
|
||||||
|
<string name="app_name">巴什科尔托斯坦指南</string>
|
||||||
<string name="navigation_drawer_open">打开导航窗口</string>
|
<string name="navigation_drawer_open">打开导航窗口</string>
|
||||||
<string name="navigation_drawer_close">关闭导航窗口</string>
|
<string name="navigation_drawer_close">关闭导航窗口</string>
|
||||||
<string name="action_settings">设置</string>
|
<string name="action_settings">设置</string>
|
||||||
@ -10,13 +11,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<string name="search_title">搜索标题</string>
|
<string name="search_title">搜索标题</string>
|
||||||
<string name="enter_search_query">输入问题</string>
|
<string name="enter_search_query">输入关键词</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="news_record_not_available">无法查看新闻记录</string>
|
<string name="news_record_not_available">无法查看记录</string>
|
||||||
<string name="other_news">其他新闻…</string>
|
<string name="other_news">其他…</string>
|
||||||
|
|
||||||
<string name="see_all">查看所有新闻</string>
|
<string name="see_all">更多</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="news_header">头条新闻</string>
|
<string name="news_header">头条新闻</string>
|
||||||
@ -29,10 +30,10 @@
|
|||||||
|
|
||||||
<string name="RB_Coat">标识</string>
|
<string name="RB_Coat">标识</string>
|
||||||
|
|
||||||
<string name="drawer_header">俄罗斯联邦巴什基尔自治共和国指南</string>
|
<string name="drawer_header">巴什科尔托斯坦指南</string>
|
||||||
<string name="drawer_guide">指南</string>
|
<string name="drawer_guide">指南</string>
|
||||||
<string name="drawer_news">新闻</string>
|
<string name="drawer_news">新闻</string>
|
||||||
<string name="drawer_catalogue">目录</string>
|
<string name="drawer_catalogue">所有文章</string>
|
||||||
<string name="drawer_map">地图</string>
|
<string name="drawer_map">地图</string>
|
||||||
<string name="drawer_video">视频</string>
|
<string name="drawer_video">视频</string>
|
||||||
<string name="drawer_photo_gallery">图片库</string>
|
<string name="drawer_photo_gallery">图片库</string>
|
||||||
@ -40,12 +41,7 @@
|
|||||||
<string name="drawer_for_investor">投资者信息</string>
|
<string name="drawer_for_investor">投资者信息</string>
|
||||||
<string name="drawer_settings">设置</string>
|
<string name="drawer_settings">设置</string>
|
||||||
|
|
||||||
<string name="go_to_website">去现场</string>
|
<string name="go_to_website">跳转至详细信息页面</string>
|
||||||
|
|
||||||
<string name="buy">Buy</string>
|
|
||||||
<string name="read">Read</string>
|
|
||||||
<string name="price">Price: </string>
|
|
||||||
<string name="rub">RUB</string>
|
|
||||||
|
|
||||||
|
|
||||||
<string name="journal_open_map">在地图上显示</string>
|
<string name="journal_open_map">在地图上显示</string>
|
||||||
@ -57,7 +53,7 @@
|
|||||||
<string name="dialog_cancel">取消</string>
|
<string name="dialog_cancel">取消</string>
|
||||||
|
|
||||||
<string name="search_everywhere">全面搜索</string>
|
<string name="search_everywhere">全面搜索</string>
|
||||||
<string name="search_in">在%%搜索: </string>
|
<string name="search_in">在%%搜索: %%</string>
|
||||||
|
|
||||||
<string name="address_form">地址:</string>
|
<string name="address_form">地址:</string>
|
||||||
<string name="copied_text">复制文本</string>
|
<string name="copied_text">复制文本</string>
|
||||||
@ -65,23 +61,28 @@
|
|||||||
|
|
||||||
<string name="search_result_count">搜索结果: %% 文章被找到</string>
|
<string name="search_result_count">搜索结果: %% 文章被找到</string>
|
||||||
<string name="search_is_performing">正在搜索,请稍等…</string>
|
<string name="search_is_performing">正在搜索,请稍等…</string>
|
||||||
<string name="search_at_least_3_symbols">输入关键字符,开始搜索</string>
|
<string name="search_at_least_3_symbols">请输入关键字并开始搜索</string>
|
||||||
|
|
||||||
<string name="credits">Bashguide (c) 2015\n\nApplication owner: ГУП «Китап»\nPhone: +73472238838\nhttp://kitap-ufa.ru/\n\nApplication is made by Vladislav Khorev\nPhone: +79260492730\nEmail: mephi1984@gmail.com\n\nTranslation to Chinese made by Little Fox Lilia\nPhone: +8615756011926\nEmail:lilialoo926@mail.ru</string>
|
<string name="credits">巴什科尔托斯坦指南 (c) 2015\n\n软件所有权:版权归俄罗斯国企“基塔普”公司所有 (ГУП «Китап»)\n电话: +73472238838\nhttp://kitap-ufa.ru/\n\n软件开发者:弗拉季斯拉夫·郝列夫\n电话: +79260492730\n邮箱: mephi1984@gmail.com\nhttp://fishrungames.ru/\n\n软件翻译:小狐狸莉莉娅\n电话: +8615756011926\n邮箱:littlefoxlilia@mail.ru\nhttp://littlefoxlilia.ru/</string>
|
||||||
|
|
||||||
<string name="call_support">Having problems with application? Click here to call support.</string>
|
<string name="call_support">程序出现问题?请点击这里寻求技术支持</string>
|
||||||
|
|
||||||
<string name="visit_kitap">Visit ГУП «Китап» website</string>
|
<string name="visit_kitap">查看“基塔普”公司网站</string>
|
||||||
|
|
||||||
<string name="visit_developer">Visit developer\'s website</string>
|
<string name="visit_developer">查看开发人员的个人网站</string>
|
||||||
|
|
||||||
<string name="visit_translator">Visit translator\'s website</string>
|
<string name="visit_translator">查看翻译人员的个人网站</string>
|
||||||
|
|
||||||
<string name="hold_address">Tap and hold address to copy it to clipboard.</string>
|
<string name="hold_address">请轻按地址直至复制到剪贴板</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="category_is_loading">Category is loading...</string>
|
<string name="category_is_loading">正在加载目录...</string>
|
||||||
|
|
||||||
<string name="category_is_loaded">Category is loaded</string>
|
<string name="category_is_loaded">目录加载完毕</string>
|
||||||
|
<string name="search_small_hint">如果您想要搜索所有的目录,请点击右上角的搜索按钮</string>
|
||||||
|
|
||||||
|
<string name="littlefoxlilia_link" formatted="false">http://littlefoxlilia.ru/zh/%E5%85%B3%E4%BA%8E%E6%88%91/</string>
|
||||||
|
|
||||||
|
<string name="featured">巴什科尔托斯坦特色</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
<color name="bkg2">#d0d0d0</color>
|
<color name="bkg2">#d0d0d0</color>
|
||||||
|
|
||||||
|
<color name="button_default">#e0e0e0</color>
|
||||||
|
|
||||||
|
|
||||||
<color name="drawer_color">#202020</color>
|
<color name="drawer_color">#202020</color>
|
||||||
|
@ -50,11 +50,6 @@
|
|||||||
|
|
||||||
<string name="go_to_website">Go to website</string>
|
<string name="go_to_website">Go to website</string>
|
||||||
|
|
||||||
<string name="buy">Buy</string>
|
|
||||||
<string name="read">Read</string>
|
|
||||||
<string name="price">Price: </string>
|
|
||||||
<string name="rub">RUB</string>
|
|
||||||
|
|
||||||
<string name="journal_open_map">Show on map</string>
|
<string name="journal_open_map">Show on map</string>
|
||||||
<string name="map_is_loading">Map is loading...</string>
|
<string name="map_is_loading">Map is loading...</string>
|
||||||
<string name="map_is_loaded">Map is loaded</string>
|
<string name="map_is_loaded">Map is loaded</string>
|
||||||
@ -75,7 +70,7 @@
|
|||||||
<string name="search_is_performing">Search is performing, please wait...</string>
|
<string name="search_is_performing">Search is performing, please wait...</string>
|
||||||
<string name="search_at_least_3_symbols">To start search, enter at least 3 symbols</string>
|
<string name="search_at_least_3_symbols">To start search, enter at least 3 symbols</string>
|
||||||
|
|
||||||
<string name="credits">Bashguide (c) 2015\n\nApplication owner: ГУП «Китап»\nPhone: +73472238838\nhttp://kitap-ufa.ru/\n\nApplication is made by Vladislav Khorev\nPhone: +79260492730\nEmail: mephi1984@gmail.com\n\nTranslation to Chinese made by Little Fox Lilia\nPhone: +8615756011926\nEmail:lilialoo926@mail.ru</string>
|
<string name="credits">Bashguide (c) 2015\n\nApplication owner: ГУП «Китап»\nPhone: +73472238838\nhttp://kitap-ufa.ru/\n\nApplication is made by Vladislav Khorev\nPhone: +79260492730\nEmail: mephi1984@gmail.com\nhttp://fishrungames.ru/\n\nTranslation to Chinese made by Little Fox Lilia\nPhone: +8615756011926\nEmail: littlefoxlilia@mail.ru\nhttp://littlefoxlilia.ru/</string>
|
||||||
|
|
||||||
<string name="call_support">Having problems with application? Click here to call support.</string>
|
<string name="call_support">Having problems with application? Click here to call support.</string>
|
||||||
|
|
||||||
@ -91,6 +86,11 @@
|
|||||||
|
|
||||||
<string name="category_is_loaded">Category is loaded</string>
|
<string name="category_is_loaded">Category is loaded</string>
|
||||||
|
|
||||||
|
<string name="search_small_hint">If you want to search in all categories, click search button at top right</string>
|
||||||
|
|
||||||
|
<string name="littlefoxlilia_link" formatted="false">http://littlefoxlilia.ru/en/about/</string>
|
||||||
|
|
||||||
|
<string name="featured">Featured RB</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -32,13 +32,14 @@ public class AlbumListFragment extends Fragment
|
|||||||
|
|
||||||
GridView gridView;
|
GridView gridView;
|
||||||
|
|
||||||
ArrayList<AlbumShortData> albumArr;
|
ArrayList<AlbumShortData> albumArr = new ArrayList<AlbumShortData>();
|
||||||
|
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
DatabaseGetAlbumListTask databaseGetAlbumListTask = null;
|
||||||
|
|
||||||
public AlbumListFragment()
|
public AlbumListFragment()
|
||||||
{
|
{
|
||||||
RestoreAlbumList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlbumListFragment(ArrayList<AlbumShortData> albumArr)
|
public AlbumListFragment(ArrayList<AlbumShortData> albumArr)
|
||||||
@ -50,7 +51,7 @@ public class AlbumListFragment extends Fragment
|
|||||||
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);
|
View rootView = inflater.inflate(R.layout.fragment_grid_page, container, false);
|
||||||
|
|
||||||
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
||||||
|
|
||||||
@ -73,22 +74,64 @@ public class AlbumListFragment extends Fragment
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (albumArr.size() == 0)
|
||||||
|
{
|
||||||
|
RestoreAlbumList();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDatabaseDonwloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
databaseDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (databaseGetAlbumListTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreAlbumList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetJournalList(r.journalList);
|
||||||
|
}
|
||||||
|
|
||||||
public void RestoreAlbumList()
|
public void RestoreAlbumList()
|
||||||
{
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
albumArr = new ArrayList<AlbumShortData>();
|
albumArr = new ArrayList<AlbumShortData>();
|
||||||
|
|
||||||
DatabaseGetAlbumListTask task = new DatabaseGetAlbumListTask();
|
databaseGetAlbumListTask = new DatabaseGetAlbumListTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetAlbumListTask.mHandler = MainActivity.getInstance().databaseHandler;
|
||||||
|
|
||||||
|
//databaseGetAlbumListTask.execute();
|
||||||
|
databaseGetAlbumListTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
task.execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAlbumList(ArrayList<AlbumShortData> albumArr)
|
public void SetAlbumList(ArrayList<AlbumShortData> albumArr)
|
||||||
{
|
{
|
||||||
|
databaseGetAlbumListTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.albumArr = albumArr;
|
this.albumArr = albumArr;
|
||||||
@ -96,6 +139,23 @@ public class AlbumListFragment extends Fragment
|
|||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetAlbumListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetAlbumListTask.cancel(false);
|
||||||
|
databaseGetAlbumListTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class DatabaseGetAlbumListTask extends AsyncTask<String, Integer, Long>
|
public static class DatabaseGetAlbumListTask extends AsyncTask<String, Integer, Long>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -113,15 +173,15 @@ public class AlbumListFragment extends Fragment
|
|||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_LIST_STATE_UPDATE, albumArr);
|
//Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_LIST_STATE_UPDATE, albumArr);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
//completeMessage.sendToTarget();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Long result)
|
protected void onPostExecute(Long result)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_LIST_STATE_FINISHED, albumArr);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_LIST_STATE_FINISHED, albumArr);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
}
|
}
|
||||||
@ -160,7 +220,7 @@ public class AlbumListFragment extends Fragment
|
|||||||
if (convertView == null)
|
if (convertView == null)
|
||||||
{ // if it's not recycled, initialize some attributes
|
{ // if it's not recycled, initialize some attributes
|
||||||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.video_page_list_element, null);
|
view = inflater.inflate(R.layout.grid_page_list_element, null);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -170,10 +230,19 @@ public class AlbumListFragment extends Fragment
|
|||||||
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||||
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, albumArr.get(position).firstImageUrl);
|
if (albumArr.get(position) != null)
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, albumArr.get(position).firstImageUrl);
|
||||||
nameTextView.setText(albumArr.get(position).title);
|
nameTextView.setText(albumArr.get(position).title);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, "R.drawable.no_picture");
|
||||||
|
nameTextView.setText("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -121,28 +122,29 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
String articleName;
|
String articleName = "";
|
||||||
ArticleFullData article;
|
|
||||||
|
ArticleFullData article = null;
|
||||||
|
|
||||||
|
DatabaseGetArticleTask databaseGetArticleTask = null;
|
||||||
|
|
||||||
|
|
||||||
ArrayList<ArticleLayoutElement> articleLayout = new ArrayList<ArticleLayoutElement>();
|
ArrayList<ArticleLayoutElement> articleLayout = new ArrayList<ArticleLayoutElement>();
|
||||||
|
|
||||||
public ArticleFragment()
|
public ArticleFragment()
|
||||||
{
|
{
|
||||||
articleName = "";
|
|
||||||
article = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticleFragment(String articleName)
|
public ArticleFragment(String articleName)
|
||||||
{
|
{
|
||||||
this.articleName = articleName;
|
this.articleName = articleName;
|
||||||
RestoreArticle();
|
RestoreArticle();
|
||||||
ReloadLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticleFragment(ArticleFullData article)
|
public ArticleFragment(ArticleFullData article)
|
||||||
{
|
{
|
||||||
this.articleName = article.name;
|
this.articleName = article.name;
|
||||||
this.article = article;
|
this.article = article;
|
||||||
ReloadLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,11 +156,13 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
public void RestoreArticle()
|
public void RestoreArticle()
|
||||||
{
|
{
|
||||||
DatabaseGetArticleTask task = new DatabaseGetArticleTask();
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetArticleTask = new DatabaseGetArticleTask();
|
||||||
|
|
||||||
task.execute(articleName);
|
databaseGetArticleTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
|
databaseGetArticleTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, articleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadLayout()
|
public void ReloadLayout()
|
||||||
@ -214,6 +218,8 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
public void SetArticle(ArticleFullData article)
|
public void SetArticle(ArticleFullData article)
|
||||||
{
|
{
|
||||||
|
databaseGetArticleTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.article = article;
|
this.article = article;
|
||||||
@ -223,17 +229,19 @@ public class ArticleFragment extends Fragment
|
|||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetArticleTask != null)
|
||||||
|
{
|
||||||
|
databaseGetArticleTask.cancel(false);
|
||||||
|
databaseGetArticleTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
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);
|
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);
|
||||||
@ -246,9 +254,39 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
articleName = savedInstanceState.getString("articleName");
|
||||||
|
RestoreArticle();
|
||||||
|
}
|
||||||
|
else if (articleName.length() > 0 && article == null)
|
||||||
|
{
|
||||||
|
RestoreArticle();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReloadLayout();
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter
|
public class ListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -314,8 +352,7 @@ public class ArticleFragment extends Fragment
|
|||||||
{
|
{
|
||||||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.article_button_element, null);
|
view = inflater.inflate(R.layout.article_button_element, null);
|
||||||
} else
|
} else // if (getItemViewType(position) == 6)
|
||||||
// if (getItemViewType(position) == 6)
|
|
||||||
{
|
{
|
||||||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.article_phone_element, null);
|
view = inflater.inflate(R.layout.article_phone_element, null);
|
||||||
@ -333,10 +370,10 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
if (article.type == ArticleManager.ARTICLE_TYPE_NEWS)
|
if (article.type == ArticleManager.ARTICLE_TYPE_NEWS)
|
||||||
{
|
{
|
||||||
textView.setTextSize(getResources().getDimension(R.dimen.xlarge_text_size));
|
textView.setTextSize(getResources().getDimension(R.dimen.large_text_size));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
textView.setTextSize(getResources().getDimension(R.dimen.xxlarge_text_size));
|
textView.setTextSize(getResources().getDimension(R.dimen.xlarge_text_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
textView.setTypeface(null, Typeface.BOLD);
|
textView.setTypeface(null, Typeface.BOLD);
|
||||||
@ -359,7 +396,23 @@ public class ArticleFragment extends Fragment
|
|||||||
|
|
||||||
PhotoRecordData photo = MainActivity.getInstance().photoDataSource.GetPhotoByImageUrl(articleLayout.get(position).value);
|
PhotoRecordData photo = MainActivity.getInstance().photoDataSource.GetPhotoByImageUrl(articleLayout.get(position).value);
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, photo.imageUrl);
|
//ImageManager.getInstance().ApplyImageToImageView(imageView, photo.imageUrl);
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, photo.imageUrl);
|
||||||
|
|
||||||
|
imageView.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().SetLastArticleName(articleName);
|
||||||
|
|
||||||
|
String albumName = article.albumArr.get(0).name;
|
||||||
|
|
||||||
|
MainActivity.getInstance().OpenPhotoScreen(albumName, 0, MainActivity.TAG_BACK_TO_ARTICLEFRAGMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
textView.setText(photo.title);
|
textView.setText(photo.title);
|
||||||
} else if (getItemViewType(position) == 3)
|
} else if (getItemViewType(position) == 3)
|
||||||
@ -382,6 +435,7 @@ public class ArticleFragment extends Fragment
|
|||||||
addressTextView.setOnLongClickListener(new OnLongClickListener()
|
addressTextView.setOnLongClickListener(new OnLongClickListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v)
|
public boolean onLongClick(View v)
|
||||||
{
|
{
|
||||||
@ -407,7 +461,7 @@ public class ArticleFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
// editText.setKeyListener(null);
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -494,7 +548,7 @@ public class ArticleFragment extends Fragment
|
|||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (getItemViewType(position) == 6)
|
} else //if (getItemViewType(position) == 6)
|
||||||
{
|
{
|
||||||
Button button = (Button) view.findViewById(R.id.button);
|
Button button = (Button) view.findViewById(R.id.button);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -29,13 +30,12 @@ public class CatalogFragment extends Fragment
|
|||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
ArrayList<JournalSemiFullData> journalList;
|
ArrayList<JournalSemiFullData> journalList = new ArrayList<JournalSemiFullData>();
|
||||||
|
|
||||||
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
||||||
|
|
||||||
public CatalogFragment()
|
public CatalogFragment()
|
||||||
{
|
{
|
||||||
RestoreJournalList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CatalogFragment(ArrayList<JournalSemiFullData> journalList)
|
public CatalogFragment(ArrayList<JournalSemiFullData> journalList)
|
||||||
@ -59,6 +59,11 @@ public class CatalogFragment extends Fragment
|
|||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
|
if (journalList.size() == 0)
|
||||||
|
{
|
||||||
|
RestoreJournalList();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,24 +71,44 @@ public class CatalogFragment extends Fragment
|
|||||||
public void onDestroyView()
|
public void onDestroyView()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (databaseGetJournalListTask != null)
|
CancelTaskIfRunning();
|
||||||
{
|
|
||||||
databaseGetJournalListTask.cancel(false);
|
|
||||||
databaseGetJournalListTask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnDatabaseDonwloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
databaseDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (databaseGetJournalListTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreJournalList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetJournalList(r.journalList);
|
||||||
|
}
|
||||||
|
|
||||||
public void RestoreJournalList()
|
public void RestoreJournalList()
|
||||||
{
|
{
|
||||||
journalList = new ArrayList<JournalSemiFullData>();
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
//journalList = new ArrayList<JournalSemiFullData>();
|
||||||
|
|
||||||
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
||||||
|
|
||||||
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetJournalListTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
databaseGetJournalListTask.execute();
|
databaseGetJournalListTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
||||||
@ -97,6 +122,23 @@ public class CatalogFragment extends Fragment
|
|||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetJournalListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalListTask.cancel(false);
|
||||||
|
databaseGetJournalListTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter
|
public class ListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@ -3,6 +3,7 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -27,8 +28,8 @@ import fishrungames.networkutils.ImageManager;
|
|||||||
public class JournalFragment extends Fragment
|
public class JournalFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
JournalSemiFullData journal;
|
JournalSemiFullData journal = null;
|
||||||
String journalName;
|
String journalName = "";
|
||||||
|
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@ -38,8 +39,6 @@ public class JournalFragment extends Fragment
|
|||||||
|
|
||||||
public JournalFragment()
|
public JournalFragment()
|
||||||
{
|
{
|
||||||
journal = null;
|
|
||||||
journalName = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JournalFragment(String journalName)
|
public JournalFragment(String journalName)
|
||||||
@ -61,15 +60,10 @@ public class JournalFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@SuppressLint("InflateParams") @Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
View rootView = inflater.inflate(R.layout.fragment_journal_page, container, false);
|
||||||
journalName = savedInstanceState.getString("journalName");
|
|
||||||
RestoreJournal();
|
|
||||||
}
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_photo_album_page, container, false);
|
|
||||||
|
|
||||||
progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
|
progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
|
||||||
|
|
||||||
@ -78,10 +72,8 @@ public class JournalFragment extends Fragment
|
|||||||
|
|
||||||
ListView listView = (ListView) rootView.findViewById(R.id.listView);
|
ListView listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
|
|
||||||
|
|
||||||
View header = inflater.inflate(R.layout.journal_page_header, null);
|
View header = inflater.inflate(R.layout.journal_page_header, null);
|
||||||
|
|
||||||
|
|
||||||
headerTextView = (TextView)header.findViewById(R.id.headerTextView);
|
headerTextView = (TextView)header.findViewById(R.id.headerTextView);
|
||||||
|
|
||||||
listView.addHeaderView(header);
|
listView.addHeaderView(header);
|
||||||
@ -114,6 +106,15 @@ public class JournalFragment extends Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
journalName = savedInstanceState.getString("journalName");
|
||||||
|
RestoreJournal();
|
||||||
|
}
|
||||||
|
else if (journalName.length() > 0 && journal == null)
|
||||||
|
{
|
||||||
|
RestoreJournal();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +122,7 @@ public class JournalFragment extends Fragment
|
|||||||
public void onDestroyView ()
|
public void onDestroyView ()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (databaseGetJournalTask != null)
|
CancelTaskIfRunning();
|
||||||
{
|
|
||||||
databaseGetJournalTask.cancel(false);
|
|
||||||
databaseGetJournalTask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
@ -133,23 +130,17 @@ public class JournalFragment extends Fragment
|
|||||||
|
|
||||||
void RestoreJournal()
|
void RestoreJournal()
|
||||||
{
|
{
|
||||||
if (databaseGetJournalTask != null)
|
CancelTaskIfRunning();
|
||||||
{
|
|
||||||
databaseGetJournalTask.cancel(false);
|
|
||||||
databaseGetJournalTask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
journal = JournalManager.CreateEmptyJournal();
|
journal = JournalManager.CreateEmptyJournalSemiFull();
|
||||||
|
|
||||||
databaseGetJournalTask = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
bundle.putString("journalName", journalName);
|
bundle.putString("journalName", journalName);
|
||||||
|
|
||||||
databaseGetJournalTask.execute(bundle);
|
databaseGetJournalTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
@ -175,6 +166,23 @@ public class JournalFragment extends Fragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter {
|
public class ListAdapter extends BaseAdapter {
|
||||||
@ -223,7 +231,9 @@ public class JournalFragment extends Fragment
|
|||||||
|
|
||||||
if (journal.articleArr.get(position).previewImageUrl != null)
|
if (journal.articleArr.get(position).previewImageUrl != null)
|
||||||
{
|
{
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, journal.articleArr.get(position).previewImageUrl);
|
//ImageManager.getInstance().ApplyImageToImageView(imageView, journal.articleArr.get(position).previewImageUrl);
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, journal.articleArr.get(position).previewImageUrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -35,8 +36,11 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
|
||||||
@ -48,6 +52,7 @@ import android.view.View;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
|
|
||||||
public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks
|
public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks
|
||||||
{
|
{
|
||||||
@ -56,7 +61,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
public static final String TAG_BACK_TO_CATALOGFRAGMENT = "TAG_BACK_TO_CATALOGFRAGMENT";
|
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_ALBUMLISTFRAGMENT = "TAG_BACK_TO_ALBUMLISTFRAGMENT";
|
||||||
|
|
||||||
|
|
||||||
public static final String TAG_BACK_TO_JOURNALFRAGMENT = "TAG_BACK_TO_JOURNALFRAGMENT";
|
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_ARTICLEFRAGMENT = "TAG_BACK_TO_ARTICLEFRAGMENT";
|
||||||
public static final String TAG_BACK_TO_ALBUMFRAGMENT = "TAG_BACK_TO_ALBUMFRAGMENT";
|
public static final String TAG_BACK_TO_ALBUMFRAGMENT = "TAG_BACK_TO_ALBUMFRAGMENT";
|
||||||
@ -69,9 +73,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String PREFS_MAIN = "PREFS_MAIN";
|
public static final String PREFS_MAIN = "PREFS_MAIN";
|
||||||
|
|
||||||
public static final int NEWS_DOWNLOADER_STATE_UPDATE = 10;
|
public static final int NEWS_DOWNLOADER_STATE_UPDATE = 10;
|
||||||
@ -108,7 +109,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED = 31;
|
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED = 31;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainPageFragment mainPageFragment = null;
|
MainPageFragment mainPageFragment = null;
|
||||||
NewsListFragment newsListFragment = null;
|
NewsListFragment newsListFragment = null;
|
||||||
|
|
||||||
@ -144,9 +144,26 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
public TranslationDataSource translationDataSource = null;
|
public TranslationDataSource translationDataSource = null;
|
||||||
|
|
||||||
|
|
||||||
|
private NewsDownloadTask newsDownloadTask = null;
|
||||||
|
private DatabaseDownloadTask databaseDownloadTask = null;
|
||||||
|
private ImageDownloadTask imageDownloadTask = null;
|
||||||
|
|
||||||
|
//private Object imgUrlSynchronizer = new Object();
|
||||||
|
private ArrayList<String> queuedImgUrlArr = new ArrayList<String>();
|
||||||
|
private ArrayList<String> queuedImgHashArr = new ArrayList<String>();
|
||||||
|
|
||||||
public static final SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
|
public static final SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
//public Handler mHandler;
|
||||||
|
|
||||||
|
//public Handler databaseHandler;
|
||||||
|
|
||||||
|
public Handler mainHandler;
|
||||||
|
|
||||||
|
//public HandlerThread downloadHandlerThread;
|
||||||
|
//public HandlerThread databaseHandlerThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
@ -154,6 +171,9 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
ImageManager.getInstance().PredefinedImageId.put("R.drawable.no_picture", R.drawable.no_picture);
|
ImageManager.getInstance().PredefinedImageId.put("R.drawable.no_picture", R.drawable.no_picture);
|
||||||
|
ImageManager.getInstance().PredefinedImageIdBitmap.put("R.drawable.no_picture", ((BitmapDrawable)getResources().getDrawable(R.drawable.no_picture)).getBitmap());
|
||||||
|
|
||||||
|
ImageManager.PreferredEmptyPicture = "R.drawable.no_picture";
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
@ -182,26 +202,65 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
translationDataSource = new TranslationDataSource(this, dbHelper);
|
translationDataSource = new TranslationDataSource(this, dbHelper);
|
||||||
|
|
||||||
mHandler = new Handler(Looper.getMainLooper())
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
downloadHandlerThread = new HandlerThread("downloadHandlerThread");
|
||||||
|
downloadHandlerThread.start();
|
||||||
|
|
||||||
|
|
||||||
|
mHandler = new Handler(downloadHandlerThread.getLooper())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message inputMessage)
|
public void handleMessage(Message inputMessage)
|
||||||
{
|
{
|
||||||
|
Message msg;
|
||||||
|
|
||||||
switch (inputMessage.what)
|
switch (inputMessage.what)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_UPDATE:
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_UPDATE:
|
||||||
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_FINISHED:
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_FINISHED:
|
||||||
UpdateOnImageDownloaded();
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
break;
|
msg.sendToTarget();
|
||||||
|
|
||||||
|
UpdateDatabaseRelatedThingsAndSendMessage();
|
||||||
|
|
||||||
case NEWS_DOWNLOADER_STATE_UPDATE:
|
case NEWS_DOWNLOADER_STATE_UPDATE:
|
||||||
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
msg.sendToTarget();
|
||||||
|
break;
|
||||||
case NEWS_DOWNLOADER_STATE_FINISHED:
|
case NEWS_DOWNLOADER_STATE_FINISHED:
|
||||||
UpdateOnNewsDownloaded();
|
|
||||||
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
msg.sendToTarget();
|
||||||
|
JournalSemiFullData journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData("news", null, 3);
|
||||||
|
Message completeMessage = mainHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_STATE_FINISHED, journal);
|
||||||
|
completeMessage.sendToTarget();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DATABASE_DOWNLOADER_STATE_UPDATE:
|
case DATABASE_DOWNLOADER_STATE_UPDATE:
|
||||||
case DATABASE_DOWNLOADER_STATE_FINISHED:
|
|
||||||
UpdateOnDatabaseDownloaded();
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
msg.sendToTarget();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DATABASE_DOWNLOADER_STATE_FINISHED:
|
||||||
|
|
||||||
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
msg.sendToTarget();
|
||||||
|
|
||||||
|
//UpdateDatabaseRelatedThingsAndSendMessage();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_UPDATE:
|
||||||
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_FINISHED:
|
||||||
|
msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
msg.sendToTarget();
|
||||||
|
break;
|
||||||
|
|
||||||
case DATABASE_GET_ALBUM_STATE_UPDATE:
|
case DATABASE_GET_ALBUM_STATE_UPDATE:
|
||||||
case DATABASE_GET_ALBUM_STATE_FINISHED:
|
case DATABASE_GET_ALBUM_STATE_FINISHED:
|
||||||
UpdateOnAlbumLoaded((AlbumFullData) inputMessage.obj);
|
UpdateOnAlbumLoaded((AlbumFullData) inputMessage.obj);
|
||||||
@ -253,7 +312,140 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DownloadDatabase();
|
|
||||||
|
databaseHandlerThread = new HandlerThread("databaseHandlerThread");
|
||||||
|
databaseHandlerThread.start();
|
||||||
|
|
||||||
|
databaseHandler = new Handler(databaseHandlerThread.getLooper())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message inputMessage)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (inputMessage.what)
|
||||||
|
{
|
||||||
|
|
||||||
|
case DATABASE_GET_ALBUM_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ALBUM_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_ALBUM_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ALBUM_LIST_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_ARTICLE_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ARTICLE_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_JOURNAL_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_JOURNAL_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_JOURNAL_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_JOURNAL_LIST_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_CHANNEL_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_CHANNEL_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_VIDEO_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_VIDEO_STATE_FINISHED:
|
||||||
|
case DATABASE_SEARCH_ARTICLE_STATE_UPDATE:
|
||||||
|
case DATABASE_SEARCH_ARTICLE_STATE_FINISHED:
|
||||||
|
case DATABASE_GET_GEO_JOURNAL_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED:
|
||||||
|
|
||||||
|
Message msg = mainHandler.obtainMessage(inputMessage.what, inputMessage.obj);
|
||||||
|
|
||||||
|
msg.sendToTarget();
|
||||||
|
|
||||||
|
//DownloadRestImageArr();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
super.handleMessage(inputMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};*/
|
||||||
|
|
||||||
|
|
||||||
|
mainHandler = new Handler(Looper.getMainLooper())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message inputMessage)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (inputMessage.what)
|
||||||
|
{
|
||||||
|
|
||||||
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_UPDATE:
|
||||||
|
UpdateOnImageDownloaded();
|
||||||
|
break;
|
||||||
|
case ImageDownloadTask.IMAGE_DOWNLOADER_STATE_FINISHED:
|
||||||
|
UpdateOnImageDownloaded();
|
||||||
|
imageDownloadTask = null;
|
||||||
|
DownloadRestImageArr();
|
||||||
|
break;
|
||||||
|
case NEWS_DOWNLOADER_STATE_UPDATE:
|
||||||
|
UpdateOnNewsDownloaded((Integer)inputMessage.obj);
|
||||||
|
break;
|
||||||
|
case NEWS_DOWNLOADER_STATE_FINISHED:
|
||||||
|
UpdateOnNewsDownloaded((Integer)inputMessage.obj);
|
||||||
|
newsDownloadTask = null;
|
||||||
|
break;
|
||||||
|
case DATABASE_DOWNLOADER_STATE_UPDATE:
|
||||||
|
UpdateOnDatabaseDownloaded((Integer)inputMessage.obj);
|
||||||
|
break;
|
||||||
|
case DATABASE_DOWNLOADER_STATE_FINISHED:
|
||||||
|
UpdateOnDatabaseDownloaded((Integer)inputMessage.obj);
|
||||||
|
databaseDownloadTask = null;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATABASE_GET_JOURNAL_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_JOURNAL_STATE_FINISHED:
|
||||||
|
final JournalSemiFullData journal = (JournalSemiFullData) inputMessage.obj;
|
||||||
|
UpdateOnJournalLoaded(journal);
|
||||||
|
break;
|
||||||
|
case DATABASE_GET_JOURNAL_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_JOURNAL_LIST_STATE_FINISHED:
|
||||||
|
UpdateOnJournalListLoaded((ArrayList<JournalSemiFullData>) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATABASE_GET_ALBUM_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ALBUM_STATE_FINISHED:
|
||||||
|
UpdateOnAlbumLoaded((AlbumFullData) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
case DATABASE_GET_ALBUM_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ALBUM_LIST_STATE_FINISHED:
|
||||||
|
|
||||||
|
ArrayList<AlbumShortData> albumShortList = (ArrayList<AlbumShortData>) inputMessage.obj;
|
||||||
|
UpdateOnAlbumListLoaded(albumShortList);
|
||||||
|
break;
|
||||||
|
case DATABASE_GET_ARTICLE_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_ARTICLE_STATE_FINISHED:
|
||||||
|
UpdateOnArticleLoaded((ArticleFullData) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATABASE_GET_CHANNEL_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_CHANNEL_STATE_FINISHED:
|
||||||
|
UpdateOnChannelLoaded((ChannelFullData) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATABASE_GET_VIDEO_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_VIDEO_STATE_FINISHED:
|
||||||
|
UpdateOnVideoLoaded((VideoRecordData) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case DATABASE_SEARCH_ARTICLE_STATE_UPDATE:
|
||||||
|
case DATABASE_SEARCH_ARTICLE_STATE_FINISHED:
|
||||||
|
UpdateOnArticleSearchPerformed((ArrayList<ArticleShortData>) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATABASE_GET_GEO_JOURNAL_LIST_STATE_UPDATE:
|
||||||
|
case DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED:
|
||||||
|
UpdateOnGeoJournalListLoaded((ArrayList<JournalRecordData>) inputMessage.obj);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super.handleMessage(inputMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//DownloadDatabase();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +454,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public void DownloadImageArr(String[] imageUrlArr)
|
public void DownloadImageArr(String[] imageUrlArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -275,41 +467,105 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
task.mHandler = mHandler;
|
task.mHandler = mHandler;
|
||||||
|
|
||||||
task.execute(innerQuery);
|
task.execute(innerQuery);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void DownloadImageArr(String[] imageUrlArr, String[] imageHashArr)
|
public void DownloadImageArr(String[] imageUrlArr, String[] imageHashArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
synchronized(queuedImgUrlArr)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = 0; i < imageUrlArr.length; i++)
|
||||||
|
{
|
||||||
|
queuedImgUrlArr.add(imageUrlArr[i]);
|
||||||
|
|
||||||
|
if (imageHashArr[i] == null)
|
||||||
|
{
|
||||||
|
queuedImgHashArr.add("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queuedImgHashArr.add(imageHashArr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageDownloadTask == null)
|
||||||
|
{
|
||||||
|
DownloadRestImageArr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DownloadRestImageArr()
|
||||||
|
{
|
||||||
|
synchronized(queuedImgUrlArr)
|
||||||
|
{
|
||||||
|
if (queuedImgUrlArr.size() > 0)
|
||||||
|
{
|
||||||
|
imageDownloadTask = new ImageDownloadTask();
|
||||||
|
|
||||||
|
imageDownloadTask.mHandler = mainHandler;
|
||||||
|
|
||||||
Bundle innerQuery = new Bundle();
|
Bundle innerQuery = new Bundle();
|
||||||
|
|
||||||
|
String[] imageUrlArr = queuedImgUrlArr.toArray(new String[queuedImgUrlArr.size()]);
|
||||||
|
String[] imageHashArr = queuedImgHashArr.toArray(new String[queuedImgHashArr.size()]);
|
||||||
|
|
||||||
innerQuery.putStringArray("imageUrlArr", imageUrlArr);
|
innerQuery.putStringArray("imageUrlArr", imageUrlArr);
|
||||||
innerQuery.putStringArray("imageHashArr", imageHashArr);
|
innerQuery.putStringArray("imageHashArr", imageHashArr);
|
||||||
|
|
||||||
ImageDownloadTask task = new ImageDownloadTask();
|
queuedImgUrlArr.clear();
|
||||||
|
queuedImgHashArr.clear();
|
||||||
|
|
||||||
task.mHandler = mHandler;
|
imageDownloadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, innerQuery);
|
||||||
|
|
||||||
task.execute(innerQuery);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void DownloadImage(String imageUrl)
|
public void DownloadImage(String imageUrl)
|
||||||
{
|
{
|
||||||
this.DownloadImageArr(new String[] { imageUrl });
|
this.DownloadImageArr(new String[] { imageUrl });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public void DownloadImage(String imageUrl, String imageHash)
|
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 CancelDownloadDatabaseTask()
|
||||||
|
{
|
||||||
|
if (databaseDownloadTask != null)
|
||||||
|
{
|
||||||
|
databaseDownloadTask.cancel(false);
|
||||||
|
databaseDownloadTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateOnDatabaseDownloaded(0);
|
||||||
|
}
|
||||||
|
|
||||||
public void DownloadDatabase()
|
public void DownloadDatabase()
|
||||||
{
|
{
|
||||||
DatabaseDownloadTask task = new DatabaseDownloadTask();
|
/*
|
||||||
|
if (databaseDownloadTask != null)
|
||||||
|
{
|
||||||
|
databaseDownloadTask.cancel(false);
|
||||||
|
databaseDownloadTask = null;
|
||||||
|
}*/
|
||||||
|
if (databaseDownloadTask != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
task.mHandler = mHandler;
|
databaseDownloadTask = new DatabaseDownloadTask();
|
||||||
|
|
||||||
task.execute();
|
databaseDownloadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAllFragmentLinks()
|
public void ClearAllFragmentLinks()
|
||||||
@ -335,6 +591,26 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateDatabaseRelatedThingsAndSendMessage()
|
||||||
|
{
|
||||||
|
if (mainPageFragment != null)
|
||||||
|
{
|
||||||
|
ArrayList<JournalSemiFullData> journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3);
|
||||||
|
|
||||||
|
Message completeMessage = mainHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
||||||
|
completeMessage.sendToTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalogFragment != null)
|
||||||
|
{
|
||||||
|
ArrayList<JournalSemiFullData> journalList = MainActivity.getInstance().journalDataSource.GetAllJournalListExceptHidden(3);
|
||||||
|
|
||||||
|
Message completeMessage = mainHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
||||||
|
completeMessage.sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void StartDownloadImagesTask(ArrayList<String> imageUrlArr, ArrayList<String> imageHashArr)
|
public void StartDownloadImagesTask(ArrayList<String> imageUrlArr, ArrayList<String> imageHashArr)
|
||||||
{
|
{
|
||||||
ImageDownloadTask task = new ImageDownloadTask();
|
ImageDownloadTask task = new ImageDownloadTask();
|
||||||
@ -346,15 +622,36 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
query.putStringArray("imageUrlArr", (String[]) imageUrlArr.toArray());
|
query.putStringArray("imageUrlArr", (String[]) imageUrlArr.toArray());
|
||||||
|
|
||||||
task.execute(query);
|
task.execute(query);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
public void CancelDownloadNewsTask()
|
||||||
|
{
|
||||||
|
if (newsDownloadTask != null)
|
||||||
|
{
|
||||||
|
newsDownloadTask.cancel(false);
|
||||||
|
newsDownloadTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateOnNewsDownloaded(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartDownloadNewsTask()
|
public void StartDownloadNewsTask()
|
||||||
{
|
{
|
||||||
NewsDownloadTask task = new NewsDownloadTask();
|
/*
|
||||||
|
if (newsDownloadTask != null)
|
||||||
|
{
|
||||||
|
newsDownloadTask.cancel(false);
|
||||||
|
newsDownloadTask = null;
|
||||||
|
}*/
|
||||||
|
if (newsDownloadTask != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
task.mHandler = mHandler;
|
newsDownloadTask = new NewsDownloadTask();
|
||||||
|
|
||||||
task.execute();
|
newsDownloadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOnImageDownloaded()
|
public void UpdateOnImageDownloaded()
|
||||||
@ -364,27 +661,96 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
mainPageFragment.RefreshAdapter();
|
mainPageFragment.RefreshAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsListFragment != null)
|
if (albumListFragment != null)
|
||||||
{
|
{
|
||||||
newsListFragment.RefreshAdapter();
|
albumListFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (photoAlbumFragment != null)
|
||||||
|
{
|
||||||
|
photoAlbumFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFragment != null)
|
||||||
|
{
|
||||||
|
photoFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (articleFragment != null)
|
||||||
|
{
|
||||||
|
articleFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (journalFragment != null)
|
||||||
|
{
|
||||||
|
journalFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalogFragment != null)
|
||||||
|
{
|
||||||
|
catalogFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchFragment != null)
|
||||||
|
{
|
||||||
|
searchFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoListFragment != null)
|
||||||
|
{
|
||||||
|
videoListFragment.RefreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoRecordFragment != null)
|
||||||
|
{
|
||||||
|
videoRecordFragment.RefreshView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOnNewsDownloaded()
|
public void UpdateOnNewsDownloaded(Integer percent)
|
||||||
{
|
{
|
||||||
|
SetNewsDownloadProgress(percent);
|
||||||
|
|
||||||
if (mainPageFragment != null)
|
if (mainPageFragment != null)
|
||||||
{
|
{
|
||||||
mainPageFragment.RefreshJournal();
|
mainPageFragment.OnNewsDownloadProgress(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsListFragment != null)
|
if (newsListFragment != null)
|
||||||
{
|
{
|
||||||
newsListFragment.RefreshJournal();
|
newsListFragment.OnNewsDownloadProgress(percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOnDatabaseDownloaded()
|
public void UpdateOnDatabaseDownloaded(Integer percent)
|
||||||
{
|
{
|
||||||
|
SetDatabaseDownloadProgress(percent);
|
||||||
|
|
||||||
|
if (mainPageFragment != null)
|
||||||
|
{
|
||||||
|
mainPageFragment.OnDatabaseDonwloadProgress(percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catalogFragment != null)
|
||||||
|
{
|
||||||
|
catalogFragment.OnDatabaseDonwloadProgress(percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (albumListFragment != null)
|
||||||
|
{
|
||||||
|
albumListFragment.OnDatabaseDonwloadProgress(percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoAlbumFragment != null)
|
||||||
|
{
|
||||||
|
photoAlbumFragment.OnDatabaseDonwloadProgress(percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoListFragment != null)
|
||||||
|
{
|
||||||
|
videoListFragment.OnDatabaseDonwloadProgress(percent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,6 +868,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
{
|
{
|
||||||
if (searchFragment != null)
|
if (searchFragment != null)
|
||||||
{
|
{
|
||||||
|
OpenSearchScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,13 +1143,14 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
mNavigationDrawerFragment.EnableDrawer();
|
mNavigationDrawerFragment.EnableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void UpdateMainScreenIfPossible(Bundle result)
|
public void UpdateMainScreenIfPossible(Bundle result)
|
||||||
{
|
{
|
||||||
if (mainPageFragment != null)
|
if (mainPageFragment != null)
|
||||||
{
|
{
|
||||||
mainPageFragment.RefreshJournal();
|
mainPageFragment.RefreshJournal();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachFragment(Fragment fragment)
|
public void onAttachFragment(Fragment fragment)
|
||||||
@ -903,6 +1271,13 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_ALBUMLISTFRAGMENT) != null)
|
||||||
|
{
|
||||||
|
OpenPhotoAlbumListScreen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_CHANNELFRAGMENT) != null)
|
if (getSupportFragmentManager().findFragmentByTag(TAG_BACK_TO_CHANNELFRAGMENT) != null)
|
||||||
{
|
{
|
||||||
OpenVideoListScreen(GetLastChannelName());
|
OpenVideoListScreen(GetLastChannelName());
|
||||||
@ -1035,6 +1410,43 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
return settings.getString("lastMapFilterName", "");
|
return settings.getString("lastMapFilterName", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetNewsDownloadProgress(int newsDownloadProgress)
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putInt("newsDownloadProgress", newsDownloadProgress);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetNewsDownloadProgress()
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
return settings.getInt("newsDownloadProgress", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDatabaseDownloadProgress(int databaseDownloadProgress)
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putInt("databaseDownloadProgress", databaseDownloadProgress);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetDatabaseDownloadProgress()
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
return settings.getInt("databaseDownloadProgress", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String DateFormattedForLocale(Date date)
|
||||||
|
{
|
||||||
|
return DateUtils.formatDateTime(this, date.getTime(), DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
|
@ -2,20 +2,25 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
import fishrungames.bashgid.core.JournalManager;
|
||||||
|
import fishrungames.bashgid.core.NewsDownloadTask;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.View.OnKeyListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -34,10 +39,11 @@ public class MainPageFragment extends Fragment
|
|||||||
ListView listView;
|
ListView listView;
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
View header;
|
View header;
|
||||||
ProgressBar progressBar;
|
ProgressBar newsDownloadProgressBar;
|
||||||
|
ProgressBar databaseDownloadProgressBar;
|
||||||
EditText searchEditText;
|
EditText searchEditText;
|
||||||
|
|
||||||
JournalSemiFullData newsJournal;
|
JournalSemiFullData newsJournal = JournalManager.CreateEmptyJournalSemiFull();
|
||||||
|
|
||||||
DatabaseGetJournalTask databaseGetJournalTask = null;
|
DatabaseGetJournalTask databaseGetJournalTask = null;
|
||||||
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
||||||
@ -51,10 +57,6 @@ public class MainPageFragment extends Fragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
||||||
journalList.clear();
|
|
||||||
|
|
||||||
RestoreJournalList();
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_main_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_main_page, container, false);
|
||||||
|
|
||||||
listView = (ListView) rootView.findViewById(R.id.listView);
|
listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
@ -63,16 +65,21 @@ public class MainPageFragment extends Fragment
|
|||||||
|
|
||||||
header = inflater.inflate(R.layout.main_page_header, null);
|
header = inflater.inflate(R.layout.main_page_header, null);
|
||||||
|
|
||||||
RestoreJournal();
|
|
||||||
MainActivity.getInstance().StartDownloadNewsTask();
|
|
||||||
|
|
||||||
listView.addHeaderView(header);
|
listView.addHeaderView(header);
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
progressBar = (ProgressBar) header.findViewById(R.id.progressBar);
|
newsDownloadProgressBar = (ProgressBar) header.findViewById(R.id.newsDownloadProgressBar);
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
newsDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
newsDownloadProgressBar.setProgress(MainActivity.getInstance().GetNewsDownloadProgress());
|
||||||
|
|
||||||
|
databaseDownloadProgressBar = (ProgressBar) header.findViewById(R.id.databaseDownloadProgressBar);
|
||||||
|
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
databaseDownloadProgressBar.setProgress(MainActivity.getInstance().GetDatabaseDownloadProgress());
|
||||||
|
|
||||||
Button moreNewsButton = (Button) header.findViewById(R.id.moreNewsButton);
|
Button moreNewsButton = (Button) header.findViewById(R.id.moreNewsButton);
|
||||||
|
|
||||||
@ -101,11 +108,66 @@ public class MainPageFragment extends Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
searchEditText.setOnKeyListener(new OnKeyListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
|
{
|
||||||
|
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
|
||||||
|
(keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||||
|
String query = searchEditText.getText().toString();
|
||||||
|
MainActivity.getInstance().OpenSearchScreen(query);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageButton refreshCatalogButton = (ImageButton) header.findViewById(R.id.refreshCatalogButton);
|
||||||
|
|
||||||
|
refreshCatalogButton.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().CancelDownloadDatabaseTask();
|
||||||
|
MainActivity.getInstance().DownloadDatabase();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageButton refreshNewsButton = (ImageButton) header.findViewById(R.id.refreshNewsButton);
|
||||||
|
|
||||||
|
refreshNewsButton.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().CancelDownloadNewsTask();
|
||||||
|
MainActivity.getInstance().StartDownloadNewsTask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
RestoreJournalListFromDatabase();
|
||||||
|
RestoreNewsFromDatabase();
|
||||||
|
MainActivity.getInstance().StartDownloadNewsTask();
|
||||||
|
MainActivity.getInstance().DownloadDatabase();
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView()
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelRestoreNewsTaskIfRunning();
|
||||||
|
CancelRestoreJournalListTasksIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelRestoreNewsTaskIfRunning()
|
||||||
{
|
{
|
||||||
if (databaseGetJournalTask != null)
|
if (databaseGetJournalTask != null)
|
||||||
{
|
{
|
||||||
@ -113,32 +175,24 @@ public class MainPageFragment extends Fragment
|
|||||||
databaseGetJournalTask = null;
|
databaseGetJournalTask = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelRestoreJournalListTasksIfRunning()
|
||||||
|
{
|
||||||
if (databaseGetJournalListTask != null)
|
if (databaseGetJournalListTask != null)
|
||||||
{
|
{
|
||||||
databaseGetJournalListTask.cancel(false);
|
databaseGetJournalListTask.cancel(false);
|
||||||
databaseGetJournalListTask = null;
|
databaseGetJournalListTask = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onDestroyView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreJournal()
|
public void RestoreNewsFromDatabase()
|
||||||
{
|
{
|
||||||
newsJournal = JournalManager.CreateEmptyJournal();
|
CancelRestoreNewsTaskIfRunning();
|
||||||
|
|
||||||
RefreshJournal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefreshJournal()
|
|
||||||
{
|
|
||||||
if (databaseGetJournalTask != null)
|
|
||||||
{
|
|
||||||
databaseGetJournalTask.cancel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseGetJournalTask = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetJournalTask.mHandler = MainActivity.getInstance().databaseHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -146,17 +200,73 @@ public class MainPageFragment extends Fragment
|
|||||||
|
|
||||||
bundle.putInt("count", 3);
|
bundle.putInt("count", 3);
|
||||||
|
|
||||||
databaseGetJournalTask.execute(bundle);
|
databaseGetJournalTask .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnNewsDownloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
|
||||||
|
newsDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
newsDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newsDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (databaseGetJournalTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreNewsFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
//RestoreNewsFromDatabase();
|
||||||
|
|
||||||
|
//SetJournal(r.journal);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDatabaseDonwloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (databaseGetJournalListTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreJournalListFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetJournalList(r.journalList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RestoreJournalListFromDatabase()
|
||||||
|
{
|
||||||
|
|
||||||
|
CancelRestoreJournalListTasksIfRunning();
|
||||||
|
|
||||||
|
|
||||||
|
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
||||||
|
|
||||||
|
//databaseGetJournalListTask.mHandler = MainActivity.getInstance().databaseHandler;
|
||||||
|
|
||||||
|
databaseGetJournalListTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "featured");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
{
|
{
|
||||||
databaseGetJournalTask = null;
|
CancelRestoreNewsTaskIfRunning();
|
||||||
|
|
||||||
// Xperimental
|
|
||||||
if (journal != null)
|
|
||||||
{
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
newsJournal = journal;
|
newsJournal = journal;
|
||||||
|
|
||||||
@ -207,40 +317,23 @@ public class MainPageFragment extends Fragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshAdapter()
|
|
||||||
{
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RestoreJournalList()
|
|
||||||
{
|
|
||||||
journalList = new ArrayList<JournalSemiFullData>();
|
|
||||||
|
|
||||||
if (databaseGetJournalListTask != null)
|
|
||||||
{
|
|
||||||
databaseGetJournalListTask.cancel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
|
||||||
|
|
||||||
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
|
|
||||||
|
|
||||||
databaseGetJournalListTask.execute("featured");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
||||||
{
|
{
|
||||||
databaseGetJournalListTask = null;
|
databaseGetJournalListTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
this.journalList = journalList;
|
this.journalList = journalList;
|
||||||
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter
|
public class ListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@ -65,13 +65,17 @@ public class MainPageHListViewAdapters
|
|||||||
|
|
||||||
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, albumFullData.photoRecordArr.get(position).imageUrl);
|
//ImageManager.getInstance().ApplyImageToImageView(imageView, albumFullData.photoRecordArr.get(position).imageUrl);
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, albumFullData.photoRecordArr.get(position).imageUrl);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class JournalElementAdapter extends BaseAdapter
|
public static class JournalElementAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -125,11 +129,12 @@ public class MainPageHListViewAdapters
|
|||||||
|
|
||||||
textView.setText(journal.articleArr.get(position).title);
|
textView.setText(journal.articleArr.get(position).title);
|
||||||
|
|
||||||
subTextView.setText(journal.articleArr.get(position).dateTime.toString());
|
subTextView.setText(MainActivity.getInstance().DateFormattedForLocale(journal.articleArr.get(position).dateTime));
|
||||||
|
|
||||||
String imageUrl = journal.articleArr.get(position).previewImageUrl;
|
String imageUrl = journal.articleArr.get(position).previewImageUrl;
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageButton, imageUrl);
|
//ImageManager.getInstance().ApplyImageToImageView(imageButton, imageUrl);
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageButton, imageUrl);
|
||||||
|
|
||||||
imageButton.setOnClickListener(new OnClickListener()
|
imageButton.setOnClickListener(new OnClickListener()
|
||||||
{
|
{
|
||||||
|
@ -9,20 +9,24 @@ import fishrungames.bashgid.core.ArticleManager;
|
|||||||
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
import fishrungames.bashgid.core.JournalManager;
|
||||||
|
import fishrungames.bashgid.core.NewsDownloadTask;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -35,9 +39,9 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
|
|
||||||
JournalSemiFullData journal;
|
JournalSemiFullData journal = JournalManager.CreateEmptyJournalSemiFull();
|
||||||
|
|
||||||
ProgressBar progressBar;
|
ProgressBar newsDownloadProgressBar;
|
||||||
|
|
||||||
TextView footerTextView;
|
TextView footerTextView;
|
||||||
|
|
||||||
@ -48,8 +52,6 @@ public class NewsListFragment extends Fragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
||||||
RestoreJournal();
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_news_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_news_page, container, false);
|
||||||
|
|
||||||
listView = (ListView) rootView.findViewById(R.id.listView);
|
listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
@ -58,9 +60,11 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
listView.addHeaderView(header);
|
listView.addHeaderView(header);
|
||||||
|
|
||||||
progressBar = (ProgressBar) header.findViewById(R.id.progressBar);
|
newsDownloadProgressBar = (ProgressBar) header.findViewById(R.id.newsDownloadProgressBar);
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
newsDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
newsDownloadProgressBar.setProgress(MainActivity.getInstance().GetNewsDownloadProgress());
|
||||||
|
|
||||||
View footer = inflater.inflate(R.layout.news_page_list_footer, null);
|
View footer = inflater.inflate(R.layout.news_page_list_footer, null);
|
||||||
|
|
||||||
@ -68,6 +72,8 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
footerTextView = (TextView) footer.findViewById(R.id.footerTextView);
|
footerTextView = (TextView) footer.findViewById(R.id.footerTextView);
|
||||||
|
|
||||||
|
footerTextView.setVisibility(View.GONE);
|
||||||
|
|
||||||
listAdapter = new ListAdapter(getActivity());
|
listAdapter = new ListAdapter(getActivity());
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
@ -93,18 +99,29 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ImageButton refreshNewsButton = (ImageButton) header.findViewById(R.id.refreshNewsButton);
|
||||||
|
|
||||||
|
refreshNewsButton.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().CancelDownloadNewsTask();
|
||||||
|
MainActivity.getInstance().StartDownloadNewsTask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
RestoreNewsFromDatabase();
|
||||||
|
MainActivity.getInstance().StartDownloadNewsTask();
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView()
|
public void onDestroyView()
|
||||||
{
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
if (databaseGetJournalTask != null)
|
|
||||||
{
|
|
||||||
databaseGetJournalTask.cancel(false);
|
|
||||||
databaseGetJournalTask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
@ -114,18 +131,34 @@ public class NewsListFragment extends Fragment
|
|||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreJournal()
|
public void OnNewsDownloadProgress(Integer percent)
|
||||||
{
|
{
|
||||||
journal = JournalManager.CreateEmptyJournal();
|
|
||||||
|
|
||||||
RefreshJournal();
|
newsDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
newsDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newsDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshJournal()
|
if (databaseGetJournalTask == null || percent == 100)
|
||||||
{
|
{
|
||||||
|
RestoreNewsFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RestoreNewsFromDatabase()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
databaseGetJournalTask = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetJournalTask.mHandler = MainActivity.getInstance().databaseHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -133,19 +166,16 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
bundle.putInt("count", 20);
|
bundle.putInt("count", 20);
|
||||||
|
|
||||||
databaseGetJournalTask.execute(bundle);
|
databaseGetJournalTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMoreNews()
|
void LoadMoreNews()
|
||||||
{
|
{
|
||||||
if (databaseGetJournalTask != null)
|
CancelTaskIfRunning();
|
||||||
{
|
|
||||||
databaseGetJournalTask.cancel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseGetJournalTask = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetJournalTask.mHandler = MainActivity.getInstance().databaseHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -155,12 +185,13 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
bundle.putInt("count", 10);
|
bundle.putInt("count", 10);
|
||||||
|
|
||||||
databaseGetJournalTask.execute(bundle);
|
databaseGetJournalTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
{
|
{
|
||||||
progressBar.setVisibility(View.GONE);
|
databaseGetJournalTask = null;
|
||||||
|
|
||||||
|
|
||||||
this.journal.articleArr.addAll(journal.articleArr);
|
this.journal.articleArr.addAll(journal.articleArr);
|
||||||
|
|
||||||
@ -171,12 +202,23 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
Collections.sort(this.journal.articleArr, new ArticleManager.ArticleShortDataTimeSortComparator());
|
Collections.sort(this.journal.articleArr, new ArticleManager.ArticleShortDataTimeSortComparator());
|
||||||
|
|
||||||
|
footerTextView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
footerTextView.setText(R.string.news_load_more);
|
footerTextView.setText(R.string.news_load_more);
|
||||||
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter
|
public class ListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@ -2,6 +2,7 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -9,6 +10,7 @@ import android.content.Intent;
|
|||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
@ -102,7 +104,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
DetailsOverlayItem item = new DetailsOverlayItem(title, imageUrl, geoPoint, address, phone);
|
DetailsOverlayItem item = new DetailsOverlayItem(title, imageUrl, geoPoint, address, phone);
|
||||||
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
||||||
item.setMarkerHotspot(HotspotPlace.CENTER);
|
item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
|
||||||
|
|
||||||
mOverlayItems.add(item);
|
mOverlayItems.add(item);
|
||||||
mArticles.add(articleName);
|
mArticles.add(articleName);
|
||||||
@ -122,6 +124,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("InflateParams")
|
||||||
@Override
|
@Override
|
||||||
protected boolean onTap(final int index)
|
protected boolean onTap(final int index)
|
||||||
{
|
{
|
||||||
@ -154,6 +157,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
textView.setOnLongClickListener(new OnLongClickListener()
|
textView.setOnLongClickListener(new OnLongClickListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v)
|
public boolean onLongClick(View v)
|
||||||
{
|
{
|
||||||
@ -270,7 +274,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
OverlayItem item = new OverlayItem("", "", geoPoint);
|
OverlayItem item = new OverlayItem("", "", geoPoint);
|
||||||
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
||||||
item.setMarkerHotspot(HotspotPlace.CENTER);
|
item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
|
||||||
|
|
||||||
mOverlayItems.add(item);
|
mOverlayItems.add(item);
|
||||||
|
|
||||||
@ -292,43 +296,34 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
CustomItemizedOverlay itemizedOverlay;
|
CustomItemizedOverlay itemizedOverlay;
|
||||||
|
|
||||||
String filter;
|
String filter = "";
|
||||||
|
|
||||||
ArrayList<JournalRecordData> availableGeoJournals;
|
ArrayList<JournalRecordData> availableGeoJournals = new ArrayList<JournalRecordData>();
|
||||||
ArrayList<String> availableGeoJournalNames;
|
ArrayList<String> availableGeoJournalNames = new ArrayList<String>();
|
||||||
|
|
||||||
ArrayAdapter<String> spinnerAdapter;
|
ArrayAdapter<String> spinnerAdapter;
|
||||||
|
|
||||||
JournalSemiFullData journal;
|
JournalSemiFullData journal = null;
|
||||||
ArticleFullData article;
|
ArticleFullData article = null;
|
||||||
|
|
||||||
int filterType;
|
int filterType = 0;
|
||||||
|
|
||||||
Spinner spinner;
|
Spinner spinner;
|
||||||
MapView mapView;
|
MapView mapView;
|
||||||
TextView titleTextView;
|
TextView titleTextView;
|
||||||
|
|
||||||
|
DatabaseGetArticleTask databaseGetArticleTask = null;
|
||||||
|
DatabaseGetJournalTask databaseGetJournalTask = null;
|
||||||
|
DatabaseGetGeoJournalListTask databaseGetGeoJournalListTask = null;
|
||||||
|
|
||||||
public OsmMapHolderFragment()
|
public OsmMapHolderFragment()
|
||||||
{
|
{
|
||||||
journal = null;
|
|
||||||
article = null;
|
|
||||||
filter = "";
|
|
||||||
filterType = 0;
|
|
||||||
availableGeoJournals = new ArrayList<JournalRecordData>();
|
|
||||||
availableGeoJournalNames = new ArrayList<String>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmMapHolderFragment(int filterType, String filter)
|
public OsmMapHolderFragment(int filterType, String filter)
|
||||||
{
|
{
|
||||||
this.journal = null;
|
|
||||||
this.article = null;
|
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.filterType = filterType;
|
this.filterType = filterType;
|
||||||
|
|
||||||
availableGeoJournals = new ArrayList<JournalRecordData>();
|
|
||||||
availableGeoJournalNames = new ArrayList<String>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmMapHolderFragment(ArticleFullData article)
|
public OsmMapHolderFragment(ArticleFullData article)
|
||||||
@ -338,10 +333,6 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
this.article = article;
|
this.article = article;
|
||||||
this.journal = null;
|
this.journal = null;
|
||||||
|
|
||||||
availableGeoJournals = new ArrayList<JournalRecordData>();
|
|
||||||
availableGeoJournalNames = new ArrayList<String>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -356,12 +347,6 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (savedInstanceState != null)
|
|
||||||
{
|
|
||||||
filter = savedInstanceState.getString("filter");
|
|
||||||
filterType = savedInstanceState.getInt("filterType");
|
|
||||||
}
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false);
|
||||||
|
|
||||||
titleTextView = (TextView) rootView.findViewById(R.id.titleTextView);
|
titleTextView = (TextView) rootView.findViewById(R.id.titleTextView);
|
||||||
@ -381,8 +366,6 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
mapController.setZoom(10);
|
mapController.setZoom(10);
|
||||||
mapController.animateTo(center);
|
mapController.animateTo(center);
|
||||||
|
|
||||||
RefreshView();
|
|
||||||
|
|
||||||
spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, availableGeoJournalNames);
|
spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, availableGeoJournalNames);
|
||||||
|
|
||||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
@ -406,7 +389,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
filterType = 0;
|
filterType = 0;
|
||||||
filter = availableGeoJournals.get(position).name;
|
filter = availableGeoJournals.get(position).name;
|
||||||
titleTextView.setText(R.string.map_is_loading);
|
titleTextView.setText(R.string.map_is_loading);
|
||||||
RestoreJournalOrArticle();
|
RestoreJournal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,13 +402,28 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
|
RefreshView();
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
filter = savedInstanceState.getString("filter");
|
||||||
|
filterType = savedInstanceState.getInt("filterType");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterType == 0 && journal == null)
|
||||||
{
|
{
|
||||||
titleTextView.setText(R.string.map_is_loading);
|
titleTextView.setText(R.string.map_is_loading);
|
||||||
|
|
||||||
RestoreJournalOrArticle();
|
RestoreJournal();
|
||||||
|
|
||||||
} else
|
} else if (filterType == 1 && article == null)
|
||||||
|
{
|
||||||
|
titleTextView.setText(R.string.map_is_loading);
|
||||||
|
|
||||||
|
RestoreArticle();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
titleTextView.setText(R.string.map_is_loaded);
|
titleTextView.setText(R.string.map_is_loaded);
|
||||||
RestoreGeoJournals();
|
RestoreGeoJournals();
|
||||||
@ -434,29 +432,29 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreJournalOrArticle()
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
{
|
{
|
||||||
if (filterType == 0)
|
CancelRestoreArticleTaskIfRunning();
|
||||||
{
|
CancelRestoreJournalTaskIfRunning();
|
||||||
RestoreJournal();
|
CancelRestoreGeoJournalListTasksIfRunning();
|
||||||
} else
|
|
||||||
{
|
super.onDestroyView();
|
||||||
RestoreArticle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreJournal()
|
void RestoreJournal()
|
||||||
{
|
{
|
||||||
|
CancelRestoreJournalTaskIfRunning();
|
||||||
|
|
||||||
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
//databaseGetJournalTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
bundle.putString("journalName", filter);
|
bundle.putString("journalName", filter);
|
||||||
|
|
||||||
task.execute(bundle);
|
databaseGetJournalTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
|
|
||||||
availableGeoJournals.clear();
|
availableGeoJournals.clear();
|
||||||
availableGeoJournalNames.clear();
|
availableGeoJournalNames.clear();
|
||||||
@ -466,12 +464,13 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
void RestoreArticle()
|
void RestoreArticle()
|
||||||
{
|
{
|
||||||
|
CancelRestoreArticleTaskIfRunning();
|
||||||
|
|
||||||
DatabaseGetArticleTask task = new DatabaseGetArticleTask();
|
databaseGetArticleTask = new DatabaseGetArticleTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetArticleTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.execute(filter);
|
databaseGetArticleTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter);
|
||||||
|
|
||||||
availableGeoJournals.clear();
|
availableGeoJournals.clear();
|
||||||
availableGeoJournalNames.clear();
|
availableGeoJournalNames.clear();
|
||||||
@ -481,17 +480,49 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
void RestoreGeoJournals()
|
void RestoreGeoJournals()
|
||||||
{
|
{
|
||||||
|
CancelRestoreGeoJournalListTasksIfRunning();
|
||||||
|
|
||||||
DatabaseGetGeoJournalListTask task = new DatabaseGetGeoJournalListTask();
|
databaseGetGeoJournalListTask = new DatabaseGetGeoJournalListTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetGeoJournalListTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.execute();
|
databaseGetGeoJournalListTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelRestoreArticleTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetArticleTask != null)
|
||||||
|
{
|
||||||
|
databaseGetArticleTask.cancel(false);
|
||||||
|
databaseGetArticleTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelRestoreJournalTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelRestoreGeoJournalListTasksIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetGeoJournalListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetGeoJournalListTask.cancel(false);
|
||||||
|
databaseGetGeoJournalListTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
{
|
{
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
|
||||||
filterType = 0;
|
filterType = 0;
|
||||||
|
|
||||||
titleTextView.setText(R.string.map_is_loaded);
|
titleTextView.setText(R.string.map_is_loaded);
|
||||||
@ -506,6 +537,8 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
public void SetArticle(ArticleFullData article)
|
public void SetArticle(ArticleFullData article)
|
||||||
{
|
{
|
||||||
|
databaseGetArticleTask = null;
|
||||||
|
|
||||||
filterType = 1;
|
filterType = 1;
|
||||||
|
|
||||||
titleTextView.setText(R.string.map_is_loaded);
|
titleTextView.setText(R.string.map_is_loaded);
|
||||||
@ -521,6 +554,8 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
public void SetGeoJournals(ArrayList<JournalRecordData> availableGeoJournals)
|
public void SetGeoJournals(ArrayList<JournalRecordData> availableGeoJournals)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
databaseGetGeoJournalListTask = null;
|
||||||
|
|
||||||
this.availableGeoJournals = availableGeoJournals;
|
this.availableGeoJournals = availableGeoJournals;
|
||||||
availableGeoJournalNames.clear();
|
availableGeoJournalNames.clear();
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -25,17 +26,17 @@ import fishrungames.networkutils.ImageManager;
|
|||||||
public class PhotoAlbumFragment extends Fragment
|
public class PhotoAlbumFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
AlbumFullData album;
|
AlbumFullData album = AlbumManager.CreateEmptyAlbum();
|
||||||
String albumName;
|
String albumName = "";
|
||||||
|
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
|
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
DatabaseGetAlbumTask databaseGetAlbumTask = null;
|
||||||
|
|
||||||
public PhotoAlbumFragment()
|
public PhotoAlbumFragment()
|
||||||
{
|
{
|
||||||
album = null;
|
|
||||||
albumName = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhotoAlbumFragment(AlbumFullData album)
|
public PhotoAlbumFragment(AlbumFullData album)
|
||||||
@ -60,10 +61,6 @@ public class PhotoAlbumFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
albumName = savedInstanceState.getString("albumName");
|
|
||||||
RestoreAlbum();
|
|
||||||
}
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_photo_album_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_photo_album_page, container, false);
|
||||||
|
|
||||||
@ -89,22 +86,63 @@ public class PhotoAlbumFragment extends Fragment
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
albumName = savedInstanceState.getString("albumName");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (albumName.length() > 0 && album.photoRecordArr.size() == 0)
|
||||||
|
{
|
||||||
|
RestoreAlbum();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDatabaseDonwloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
databaseDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (databaseGetAlbumTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreAlbum();
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetJournalList(r.journalList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RestoreAlbum()
|
void RestoreAlbum()
|
||||||
{
|
{
|
||||||
album = AlbumManager.CreateEmptyAlbum();
|
databaseGetAlbumTask = new DatabaseGetAlbumTask();
|
||||||
|
|
||||||
DatabaseGetAlbumTask task = new DatabaseGetAlbumTask();
|
databaseGetAlbumTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetAlbumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, albumName);
|
||||||
|
|
||||||
task.execute(albumName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAlbum(AlbumFullData album)
|
public void SetAlbum(AlbumFullData album)
|
||||||
{
|
{
|
||||||
|
databaseGetAlbumTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.album = album;
|
this.album = album;
|
||||||
@ -113,6 +151,23 @@ public class PhotoAlbumFragment extends Fragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetAlbumTask != null)
|
||||||
|
{
|
||||||
|
databaseGetAlbumTask.cancel(false);
|
||||||
|
databaseGetAlbumTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter {
|
public class ListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@ -149,7 +204,15 @@ public class PhotoAlbumFragment extends Fragment
|
|||||||
|
|
||||||
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, album.photoRecordArr.get(position).imageUrl);
|
|
||||||
|
if (album.photoRecordArr.get(position) != null)
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, album.photoRecordArr.get(position).imageUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, "R.drawable.no_picture");
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fishrungames.bashgid;
|
package fishrungames.bashgid;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -18,20 +17,19 @@ import fishrungames.bashgid.core.DatabaseGetAlbumTask;
|
|||||||
public class PhotoFragment extends Fragment
|
public class PhotoFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
AlbumFullData album;
|
AlbumFullData album = AlbumManager.CreateEmptyAlbum();
|
||||||
String albumName;
|
String albumName = "";
|
||||||
int currentPhoto;
|
int currentPhoto = -1;
|
||||||
|
|
||||||
PhotoFragmentAdapter listAdapter;
|
PhotoFragmentAdapter listAdapter;
|
||||||
ViewPager pager;
|
ViewPager pager;
|
||||||
|
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
DatabaseGetAlbumTask databaseGetAlbumTask = null;
|
||||||
|
|
||||||
public PhotoFragment()
|
public PhotoFragment()
|
||||||
{
|
{
|
||||||
album = null;
|
|
||||||
albumName = "";
|
|
||||||
currentPhoto = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhotoFragment(AlbumFullData album, int currentPhoto)
|
public PhotoFragment(AlbumFullData album, int currentPhoto)
|
||||||
@ -43,39 +41,30 @@ public class PhotoFragment extends Fragment
|
|||||||
|
|
||||||
public PhotoFragment(String albumName, int currentPhoto)
|
public PhotoFragment(String albumName, int currentPhoto)
|
||||||
{
|
{
|
||||||
this.album = null;
|
|
||||||
this.albumName = albumName;
|
this.albumName = albumName;
|
||||||
this.currentPhoto = currentPhoto;
|
this.currentPhoto = currentPhoto;
|
||||||
RestoreAlbum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(final Bundle outState) {
|
public void onSaveInstanceState(final Bundle outState)
|
||||||
|
{
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putString("albumName", albumName);
|
outState.putString("albumName", albumName);
|
||||||
outState.putInt("currentPhoto", currentPhoto);
|
outState.putInt("currentPhoto", currentPhoto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
|
{
|
||||||
if (savedInstanceState != null) {
|
|
||||||
albumName = savedInstanceState.getString("albumName");
|
|
||||||
currentPhoto = savedInstanceState.getInt("currentPhoto");
|
|
||||||
RestoreAlbum();
|
|
||||||
}
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_photo_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_photo_page, container, false);
|
||||||
|
|
||||||
progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
||||||
|
|
||||||
if (album == null)
|
if (album == null)
|
||||||
{
|
{
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -88,22 +77,42 @@ public class PhotoFragment extends Fragment
|
|||||||
|
|
||||||
pager.setCurrentItem(currentPhoto);
|
pager.setCurrentItem(currentPhoto);
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
albumName = savedInstanceState.getString("albumName");
|
||||||
|
currentPhoto = savedInstanceState.getInt("currentPhoto");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (album.photoRecordArr.size() == 0 && albumName.length() > 0)
|
||||||
|
{
|
||||||
|
RestoreAlbum();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
void RestoreAlbum()
|
void RestoreAlbum()
|
||||||
{
|
{
|
||||||
album = AlbumManager.CreateEmptyAlbum();
|
databaseGetAlbumTask = new DatabaseGetAlbumTask();
|
||||||
|
|
||||||
DatabaseGetAlbumTask task = new DatabaseGetAlbumTask();
|
databaseGetAlbumTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetAlbumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, albumName);
|
||||||
|
|
||||||
task.execute(albumName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAlbum(AlbumFullData album)
|
public void SetAlbum(AlbumFullData album)
|
||||||
{
|
{
|
||||||
|
databaseGetAlbumTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.album = album;
|
this.album = album;
|
||||||
@ -112,10 +121,29 @@ public class PhotoFragment extends Fragment
|
|||||||
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
if (currentPhoto < 0)
|
||||||
|
{
|
||||||
|
currentPhoto = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pager.setCurrentItem(currentPhoto);
|
pager.setCurrentItem(currentPhoto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetAlbumTask != null)
|
||||||
|
{
|
||||||
|
databaseGetAlbumTask.cancel(false);
|
||||||
|
databaseGetAlbumTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -59,7 +59,16 @@ public class PhotoFragmentAdapter extends PagerAdapter {
|
|||||||
|
|
||||||
ImageView image = (ImageView) viewLayout.findViewById(R.id.image);
|
ImageView image = (ImageView) viewLayout.findViewById(R.id.image);
|
||||||
|
|
||||||
|
//ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl);
|
||||||
|
|
||||||
|
if (album.photoRecordArr.get(position) != null)
|
||||||
|
{
|
||||||
ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl);
|
ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplyImageToImageView(image, "R.drawable.no_picture");
|
||||||
|
}
|
||||||
|
|
||||||
((ViewPager) container).addView(viewLayout);
|
((ViewPager) container).addView(viewLayout);
|
||||||
|
|
||||||
|
@ -11,14 +11,17 @@ import fishrungames.networkutils.ImageManager;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnKeyListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
@ -42,24 +45,18 @@ public class SearchFragment extends Fragment
|
|||||||
|
|
||||||
ArrayList<ArticleShortData> searchResultArr = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> searchResultArr = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
String journalName;
|
String journalName = "";
|
||||||
String journalTitle;
|
String journalTitle = "";
|
||||||
String query;
|
String query = "";
|
||||||
|
|
||||||
DatabaseSearchArticleTask databaseSearchArticleTask = null;
|
DatabaseSearchArticleTask databaseSearchArticleTask = null;
|
||||||
|
|
||||||
public SearchFragment()
|
public SearchFragment()
|
||||||
{
|
{
|
||||||
this.journalName = "";
|
|
||||||
this.journalTitle = "";
|
|
||||||
this.query = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchFragment(String query)
|
public SearchFragment(String query)
|
||||||
{
|
{
|
||||||
this.journalName = "";
|
|
||||||
this.journalTitle = "";
|
|
||||||
this.journalTitle = "";
|
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,32 +88,30 @@ public class SearchFragment extends Fragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
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);
|
View rootView = inflater.inflate(R.layout.fragment_search_page, container, false);
|
||||||
|
|
||||||
listView = (ListView) rootView.findViewById(R.id.listView);
|
listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
|
|
||||||
View header = inflater.inflate(R.layout.search_page_list_header, null);
|
View header = inflater.inflate(R.layout.search_page_list_header, null);
|
||||||
|
|
||||||
TextView addressTextView = (TextView) header.findViewById(R.id.addressTextView);
|
TextView titleTextView = (TextView) header.findViewById(R.id.titleTextView);
|
||||||
|
|
||||||
|
TextView smallHintTextView = (TextView) header.findViewById(R.id.smallHintTextView);
|
||||||
|
|
||||||
if (journalTitle == null || journalTitle.length() == 0)
|
if (journalTitle == null || journalTitle.length() == 0)
|
||||||
{
|
{
|
||||||
addressTextView.setText(R.string.search_everywhere);
|
titleTextView.setText(R.string.search_everywhere);
|
||||||
|
|
||||||
|
smallHintTextView.setVisibility(View.GONE);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
String search_in = this.getResources().getString(R.string.search_in);
|
String search_in = this.getResources().getString(R.string.search_in);
|
||||||
|
|
||||||
search_in = search_in.replace("%%", journalTitle);
|
search_in = search_in.replace("%%", journalTitle);
|
||||||
|
|
||||||
addressTextView.setText(search_in);
|
titleTextView.setText(search_in);
|
||||||
|
|
||||||
|
smallHintTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
hintTextView = (TextView) header.findViewById(R.id.hintTextView);
|
hintTextView = (TextView) header.findViewById(R.id.hintTextView);
|
||||||
@ -125,6 +120,9 @@ public class SearchFragment extends Fragment
|
|||||||
|
|
||||||
searchEditText.setText(query);
|
searchEditText.setText(query);
|
||||||
|
|
||||||
|
int textLength = searchEditText.getText().length();
|
||||||
|
searchEditText.setSelection(textLength, textLength);
|
||||||
|
|
||||||
searchEditText.addTextChangedListener(new TextWatcher()
|
searchEditText.addTextChangedListener(new TextWatcher()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -146,6 +144,19 @@ public class SearchFragment extends Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
searchEditText.setOnKeyListener(new OnKeyListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
|
{
|
||||||
|
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
|
||||||
|
(keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
listView.addHeaderView(header);
|
listView.addHeaderView(header);
|
||||||
|
|
||||||
listAdapter = new ListAdapter(getActivity());
|
listAdapter = new ListAdapter(getActivity());
|
||||||
@ -167,13 +178,59 @@ public class SearchFragment extends Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
journalName = savedInstanceState.getString("journalName");
|
||||||
|
journalTitle = savedInstanceState.getString("journalTitle");
|
||||||
|
query = savedInstanceState.getString("query");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CallUpdateNews();
|
CallUpdateNews();
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CallUpdateNews()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (query.length() >= 3 || (Locale.getDefault() == Locale.CHINA && query.length() >= 1))
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
databaseSearchArticleTask = new DatabaseSearchArticleTask();
|
||||||
|
|
||||||
|
databaseSearchArticleTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
|
bundle.putString("journalName", journalName);
|
||||||
|
bundle.putString("query", query);
|
||||||
|
|
||||||
|
databaseSearchArticleTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, bundle);
|
||||||
|
|
||||||
|
hintTextView.setText(R.string.search_is_performing);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
searchResultArr.clear();
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
hintTextView.setText(R.string.search_at_least_3_symbols);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSearchResult(ArrayList<ArticleShortData> articleArr)
|
public void SetSearchResult(ArrayList<ArticleShortData> articleArr)
|
||||||
{
|
{
|
||||||
|
databaseSearchArticleTask = null;
|
||||||
|
|
||||||
searchResultArr = articleArr;
|
searchResultArr = articleArr;
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
@ -184,6 +241,24 @@ public class SearchFragment extends Fragment
|
|||||||
hintTextView.setText(searchResultCount);
|
hintTextView.setText(searchResultCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseSearchArticleTask != null)
|
||||||
|
{
|
||||||
|
databaseSearchArticleTask.cancel(false);
|
||||||
|
databaseSearchArticleTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter
|
public class ListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -246,35 +321,6 @@ public class SearchFragment extends Fragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
searchResultArr.clear();
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
hintTextView.setText(R.string.search_at_least_3_symbols);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,9 @@ public class SettingsFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
|
String link = getResources().getString(R.string.littlefoxlilia_link);
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
i.setData(Uri.parse("http://littlefoxlilia.ru/"));
|
i.setData(Uri.parse(link));
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
37
android/src/fishrungames/bashgid/SquareImageView.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package fishrungames.bashgid;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
public class SquareImageView extends ImageView {
|
||||||
|
|
||||||
|
public SquareImageView(final Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SquareImageView(final Context context, final AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SquareImageView(final Context context, final AttributeSet attrs,
|
||||||
|
final int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int width, int height) {
|
||||||
|
super.onMeasure(width, height);
|
||||||
|
int measuredWidth = getMeasuredWidth();
|
||||||
|
//int measuredHeight = getMeasuredHeight();
|
||||||
|
|
||||||
|
setMeasuredDimension(measuredWidth, measuredWidth);
|
||||||
|
|
||||||
|
/*if (measuredWidth > measuredHeight) {
|
||||||
|
setMeasuredDimension(measuredHeight, measuredHeight);
|
||||||
|
} else {
|
||||||
|
setMeasuredDimension(measuredWidth, measuredWidth);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
android/src/fishrungames/bashgid/StaticGridView.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package fishrungames.bashgid;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.GridView;
|
||||||
|
|
||||||
|
public class StaticGridView extends GridView {
|
||||||
|
|
||||||
|
public StaticGridView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StaticGridView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StaticGridView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
|
||||||
|
//super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST));
|
||||||
|
//getLayoutParams().height = getMeasuredHeight();
|
||||||
|
|
||||||
|
|
||||||
|
/*int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
|
||||||
|
MeasureSpec.AT_MOST);
|
||||||
|
super.onMeasure(widthMeasureSpec, expandSpec);*/
|
||||||
|
|
||||||
|
|
||||||
|
//super.onMeasure(widthMeasureSpec, MeasureSpec.UNSPECIFIED);
|
||||||
|
|
||||||
|
|
||||||
|
int heightSpec;
|
||||||
|
|
||||||
|
if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) {
|
||||||
|
|
||||||
|
heightSpec = MeasureSpec.makeMeasureSpec(
|
||||||
|
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Any other height should be respected as is.
|
||||||
|
heightSpec = heightMeasureSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onMeasure(widthMeasureSpec, heightSpec);
|
||||||
|
}
|
||||||
|
}
|
@ -35,13 +35,13 @@ public class VideoListFragment extends Fragment
|
|||||||
GridView gridView;
|
GridView gridView;
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
String channelName;
|
String channelName = "";
|
||||||
ChannelFullData channelFullData;
|
ChannelFullData channelFullData = ChannelManager.CreateEmptyChannel();
|
||||||
|
|
||||||
|
DatabaseGetChannelTask databaseGetChannelTask = null;
|
||||||
|
|
||||||
public VideoListFragment()
|
public VideoListFragment()
|
||||||
{
|
{
|
||||||
channelName = "";
|
|
||||||
channelFullData = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoListFragment(String channelName)
|
public VideoListFragment(String channelName)
|
||||||
@ -65,13 +65,7 @@ public class VideoListFragment extends Fragment
|
|||||||
@Override
|
@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_grid_page, container, false);
|
||||||
if (savedInstanceState != null) {
|
|
||||||
channelName = savedInstanceState.getString("channelName");
|
|
||||||
RestoreChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -98,28 +92,87 @@ public class VideoListFragment extends Fragment
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
channelName = savedInstanceState.getString("channelName");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channelName.length() > 0 && channelFullData.videoRecordArr.size() == 0)
|
||||||
|
{
|
||||||
|
RestoreChannel();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDatabaseDonwloadProgress(Integer percent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
databaseDownloadProgressBar.setProgress(percent);
|
||||||
|
|
||||||
|
if (percent >= 100)
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
databaseDownloadProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (databaseGetChannelTask == null || percent == 100)
|
||||||
|
{
|
||||||
|
RestoreChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetJournalList(r.journalList);
|
||||||
|
}
|
||||||
|
|
||||||
void RestoreChannel()
|
void RestoreChannel()
|
||||||
{
|
{
|
||||||
channelFullData = ChannelManager.CreateEmptyChannel();
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
DatabaseGetChannelTask task = new DatabaseGetChannelTask();
|
databaseGetChannelTask = new DatabaseGetChannelTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetChannelTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.execute(channelName);
|
databaseGetChannelTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetChannel(ChannelFullData channelFullData)
|
void SetChannel(ChannelFullData channelFullData)
|
||||||
{
|
{
|
||||||
|
databaseGetChannelTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.channelFullData = channelFullData;
|
this.channelFullData = channelFullData;
|
||||||
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetChannelTask != null)
|
||||||
|
{
|
||||||
|
databaseGetChannelTask.cancel(false);
|
||||||
|
databaseGetChannelTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
if (listAdapter != null)
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class DatabaseGetChannelTask extends AsyncTask<String, Integer, Long>
|
public class DatabaseGetChannelTask extends AsyncTask<String, Integer, Long>
|
||||||
@ -182,7 +235,7 @@ public class VideoListFragment extends Fragment
|
|||||||
View view;
|
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);
|
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.video_page_list_element, null);
|
view = inflater.inflate(R.layout.grid_page_list_element, null);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -192,9 +245,22 @@ public class VideoListFragment extends Fragment
|
|||||||
ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
|
ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
|
||||||
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
||||||
|
|
||||||
ImageManager.getInstance().ApplyImageToImageView(imageView, channelFullData.videoRecordArr.get(position).previewImageUrl);
|
//ImageManager.getInstance().ApplyImageToImageView(imageView, channelFullData.videoRecordArr.get(position).previewImageUrl);
|
||||||
|
|
||||||
|
|
||||||
|
if (channelFullData.videoRecordArr.get(position) != null)
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, channelFullData.videoRecordArr.get(position).previewImageUrl);
|
||||||
|
|
||||||
nameTextView.setText(channelFullData.videoRecordArr.get(position).title);
|
nameTextView.setText(channelFullData.videoRecordArr.get(position).title);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImageManager.getInstance().ApplySmallImageToImageView(imageView, "R.drawable.no_picture");
|
||||||
|
nameTextView.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -24,26 +24,24 @@ import android.widget.TextView;
|
|||||||
public class VideoRecordFragment extends Fragment
|
public class VideoRecordFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
String videoUrl;
|
String videoUrl = "";
|
||||||
|
|
||||||
VideoRecordData recordData;
|
VideoRecordData recordData = VideoManager.CreateEmptyVideo();
|
||||||
|
|
||||||
TextView nameTextView;
|
TextView nameTextView;
|
||||||
TextView descriptionTextView;
|
TextView descriptionTextView;
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
DatabaseGetVideoTask databaseGetVideoTask = null;
|
||||||
|
|
||||||
public VideoRecordFragment()
|
public VideoRecordFragment()
|
||||||
{
|
{
|
||||||
this.videoUrl = "";
|
|
||||||
this.recordData = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoRecordFragment(String videoUrl)
|
public VideoRecordFragment(String videoUrl)
|
||||||
{
|
{
|
||||||
this.recordData = null;
|
|
||||||
this.videoUrl = videoUrl;
|
this.videoUrl = videoUrl;
|
||||||
RestoreVideo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoRecordFragment(VideoRecordData recordData)
|
public VideoRecordFragment(VideoRecordData recordData)
|
||||||
@ -63,12 +61,6 @@ public class VideoRecordFragment extends Fragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (savedInstanceState != null)
|
|
||||||
{
|
|
||||||
videoUrl = savedInstanceState.getString("videoUrl");
|
|
||||||
RestoreVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_video_record_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_video_record_page, container, false);
|
||||||
|
|
||||||
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
||||||
@ -88,29 +80,57 @@ public class VideoRecordFragment extends Fragment
|
|||||||
|
|
||||||
RefreshView();
|
RefreshView();
|
||||||
|
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
videoUrl = savedInstanceState.getString("videoUrl");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoUrl.length() > 0 && recordData.videoUrl.length() == 0)
|
||||||
|
{
|
||||||
|
RestoreVideo();
|
||||||
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView()
|
||||||
|
{
|
||||||
|
CancelTaskIfRunning();
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
void RestoreVideo()
|
void RestoreVideo()
|
||||||
{
|
{
|
||||||
// recordData =
|
CancelTaskIfRunning();
|
||||||
// MainActivity.getInstance().videoDataSource.GetVideoByVideoUrl(videoUrl);
|
|
||||||
recordData = VideoManager.CreateEmptyVideo();
|
|
||||||
|
|
||||||
DatabaseGetVideoTask task = new DatabaseGetVideoTask();
|
databaseGetVideoTask = new DatabaseGetVideoTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetVideoTask.mHandler = MainActivity.getInstance().mainHandler;
|
||||||
|
|
||||||
task.execute(videoUrl);
|
databaseGetVideoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, videoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVideo(VideoRecordData recordData)
|
void SetVideo(VideoRecordData recordData)
|
||||||
{
|
{
|
||||||
|
databaseGetVideoTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
this.recordData = recordData;
|
this.recordData = recordData;
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CancelTaskIfRunning()
|
||||||
|
{
|
||||||
|
if (databaseGetVideoTask != null)
|
||||||
|
{
|
||||||
|
databaseGetVideoTask.cancel(false);
|
||||||
|
databaseGetVideoTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RefreshView()
|
void RefreshView()
|
||||||
{
|
{
|
||||||
nameTextView.setText(recordData.title);
|
nameTextView.setText(recordData.title);
|
||||||
|
@ -21,6 +21,22 @@ public class WelcomeFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
ImageView flagView1 = (ImageView) rootView.findViewById(R.id.image_flag_china);
|
||||||
|
ImageView flagView2 = (ImageView) rootView.findViewById(R.id.image_flag_russia);
|
||||||
|
ImageView flagView3 = (ImageView) rootView.findViewById(R.id.image_flag_usa);
|
||||||
|
|
||||||
|
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.language_flag_in);
|
||||||
|
flagView1.startAnimation(animation);
|
||||||
|
flagView2.startAnimation(animation);
|
||||||
|
flagView3.startAnimation(animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Override
|
||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -33,5 +49,5 @@ public class WelcomeFragment extends Fragment {
|
|||||||
flagView1.startAnimation(animation);
|
flagView1.startAnimation(animation);
|
||||||
flagView2.startAnimation(animation);
|
flagView2.startAnimation(animation);
|
||||||
flagView3.startAnimation(animation);
|
flagView3.startAnimation(animation);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ public class AlbumManager
|
|||||||
public String description;
|
public String description;
|
||||||
public int hidden;
|
public int hidden;
|
||||||
|
|
||||||
|
|
||||||
public AlbumRecordData(String name, String title, String description, int hidden)
|
public AlbumRecordData(String name, String title, String description, int hidden)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -91,6 +91,13 @@ public class ArticleManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArticleRecordData CreateEmptyArticle()
|
||||||
|
{
|
||||||
|
ArticleRecordData result = new ArticleRecordData("", 0, "", "", 0.0, 0.0, "", "", "", "", new Date(), 1);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static class ArticleShortDataSortComparator implements Comparator<ArticleShortData> {
|
public static class ArticleShortDataSortComparator implements Comparator<ArticleShortData> {
|
||||||
public int compare(ArticleShortData record1, ArticleShortData record2) {
|
public int compare(ArticleShortData record1, ArticleShortData record2) {
|
||||||
return record2.name.compareTo(record1.name);
|
return record2.name.compareTo(record1.name);
|
||||||
|
@ -12,7 +12,6 @@ public class ChannelManager
|
|||||||
public String description;
|
public String description;
|
||||||
public int hidden;
|
public int hidden;
|
||||||
|
|
||||||
|
|
||||||
public ChannelRecordData(String name, String title, String description, int hidden)
|
public ChannelRecordData(String name, String title, String description, int hidden)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -21,9 +21,8 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.database.DatabaseUtils;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
@ -34,36 +33,122 @@ import fishrungames.bashgid.core.JournalManager.JournalRecordData;
|
|||||||
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
||||||
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
||||||
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
||||||
|
import fishrungames.networkutils.SimpleAsyncTask;
|
||||||
|
|
||||||
public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
public class DatabaseDownloadTask extends SimpleAsyncTask
|
||||||
{
|
{
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
|
||||||
protected Long doInBackground(Bundle... queryArr)
|
protected Long doInBackground(Bundle... queryArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PublishProgress(0.1f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseJsonTranslation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=translation/json"));
|
||||||
|
PublishProgress(0.2f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonPhoto(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photo/json"));
|
ParseJsonPhoto(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photo/json"));
|
||||||
|
PublishProgress(0.25f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonAlbum(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=album/json"));
|
ParseJsonAlbum(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=album/json"));
|
||||||
|
PublishProgress(0.3f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonPhotoAlbumRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photoAlbumRelation/json"));
|
ParseJsonPhotoAlbumRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photoAlbumRelation/json"));
|
||||||
|
PublishProgress(0.35f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonVideo(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=video/json"));
|
ParseJsonVideo(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=video/json"));
|
||||||
|
PublishProgress(0.4f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonChannel(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channel/json"));
|
ParseJsonChannel(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channel/json"));
|
||||||
|
PublishProgress(0.5f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonVideoChannelRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=videoChannelRelation/json"));
|
ParseJsonVideoChannelRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=videoChannelRelation/json"));
|
||||||
|
PublishProgress(0.6f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonArticle(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=article/json"));
|
ParseJsonArticle(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=article/json"));
|
||||||
ParseJsonJournal(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=journal/json"));
|
PublishProgress(0.65f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=albumArticleRelation/json"));
|
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=albumArticleRelation/json"));
|
||||||
|
PublishProgress(0.85f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonChannelArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channelArticleRelation/json"));
|
ParseJsonChannelArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channelArticleRelation/json"));
|
||||||
|
PublishProgress(0.9f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseJsonJournal(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=journal/json"));
|
||||||
|
PublishProgress(0.75f);
|
||||||
|
|
||||||
|
if (isCancelled())
|
||||||
|
{
|
||||||
|
return (long)0;
|
||||||
|
}
|
||||||
|
|
||||||
ParseJsonArticleJournalRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=articleJournalRelation/json"));
|
ParseJsonArticleJournalRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=articleJournalRelation/json"));
|
||||||
ParseJsonTranslation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=translation/json"));
|
PublishProgress(0.95f);
|
||||||
|
|
||||||
return (long) 0;
|
return (long) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_DOWNLOADER_STATE_UPDATE, this);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.DATABASE_DOWNLOADER_STATE_UPDATE, progress[0]);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
|
|
||||||
@ -71,11 +156,16 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
protected void onPostExecute(Long result)
|
protected void onPostExecute(Long result)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_DOWNLOADER_STATE_FINISHED, this);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.DATABASE_DOWNLOADER_STATE_FINISHED, 100);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReloadDatabaseContent()
|
||||||
|
{
|
||||||
|
//journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3);
|
||||||
|
}
|
||||||
|
|
||||||
private String getJsonFromUrl(String url_select)
|
private String getJsonFromUrl(String url_select)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -152,10 +242,10 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String description = jObject.getString("description");
|
String description = DatabaseDownloadTask.sqlEscapeString(jObject.getString("description"));
|
||||||
String imageUrl = jObject.getString("imageUrl");
|
String imageUrl = DatabaseDownloadTask.sqlEscapeString(jObject.getString("imageUrl"));
|
||||||
String imageHash = jObject.getString("imageHash");
|
String imageHash = DatabaseDownloadTask.sqlEscapeString(jObject.getString("imageHash"));
|
||||||
double geoLat = jObject.getDouble("geoLat");
|
double geoLat = jObject.getDouble("geoLat");
|
||||||
double geoLon = jObject.getDouble("geoLon");
|
double geoLon = jObject.getDouble("geoLon");
|
||||||
|
|
||||||
@ -182,9 +272,9 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String description = jObject.getString("description");
|
String description = DatabaseDownloadTask.sqlEscapeString(jObject.getString("description"));
|
||||||
int hidden = jObject.getInt("hidden");
|
int hidden = jObject.getInt("hidden");
|
||||||
|
|
||||||
MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(name, title, description, hidden));
|
MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(name, title, description, hidden));
|
||||||
@ -208,8 +298,8 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String imageUrl = jObject.getString("imageUrl");
|
String imageUrl = DatabaseDownloadTask.sqlEscapeString(jObject.getString("imageUrl"));
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
|
|
||||||
MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, name);
|
MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, name);
|
||||||
|
|
||||||
@ -233,12 +323,12 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
int type = jObject.getInt("type");
|
int type = jObject.getInt("type");
|
||||||
String videoUrl = jObject.getString("videoUrl");
|
String videoUrl = DatabaseDownloadTask.sqlEscapeString(jObject.getString("videoUrl"));
|
||||||
|
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String description = jObject.getString("description");
|
String description = DatabaseDownloadTask.sqlEscapeString(jObject.getString("description"));
|
||||||
String previewImageUrl = jObject.getString("previewImageUrl");
|
String previewImageUrl = DatabaseDownloadTask.sqlEscapeString(jObject.getString("previewImageUrl"));
|
||||||
String previewImageHash = jObject.getString("previewImageHash");
|
String previewImageHash = DatabaseDownloadTask.sqlEscapeString(jObject.getString("previewImageHash"));
|
||||||
|
|
||||||
MainActivity.getInstance().videoDataSource.AddOrReplaceVideo(new VideoRecordData(type, videoUrl, title, description, previewImageUrl,
|
MainActivity.getInstance().videoDataSource.AddOrReplaceVideo(new VideoRecordData(type, videoUrl, title, description, previewImageUrl,
|
||||||
previewImageHash));
|
previewImageHash));
|
||||||
@ -264,9 +354,9 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String description = jObject.getString("description");
|
String description = DatabaseDownloadTask.sqlEscapeString(jObject.getString("description"));
|
||||||
int hidden = jObject.getInt("hidden");
|
int hidden = jObject.getInt("hidden");
|
||||||
|
|
||||||
MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(name, title, description, hidden));
|
MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(name, title, description, hidden));
|
||||||
@ -290,8 +380,8 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String videoUrl = jObject.getString("videoUrl");
|
String videoUrl = DatabaseDownloadTask.sqlEscapeString(jObject.getString("videoUrl"));
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
|
|
||||||
MainActivity.getInstance().channelDataSource.AddVideoToChannel(videoUrl, name);
|
MainActivity.getInstance().channelDataSource.AddVideoToChannel(videoUrl, name);
|
||||||
|
|
||||||
@ -316,16 +406,16 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
{
|
{
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
int type = jObject.getInt("type");
|
int type = jObject.getInt("type");
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String content = jObject.getString("content");
|
String content = DatabaseDownloadTask.sqlEscapeString(jObject.getString("content"));
|
||||||
double geoLat = jObject.getDouble("geoLat");
|
double geoLat = jObject.getDouble("geoLat");
|
||||||
double geoLon = jObject.getDouble("geoLon");
|
double geoLon = jObject.getDouble("geoLon");
|
||||||
String address = jObject.getString("address");
|
String address = DatabaseDownloadTask.sqlEscapeString(jObject.getString("address"));
|
||||||
String phone = jObject.getString("phone");
|
String phone = DatabaseDownloadTask.sqlEscapeString(jObject.getString("phone"));
|
||||||
String externalLink = jObject.getString("externalLink");
|
String externalLink = DatabaseDownloadTask.sqlEscapeString(jObject.getString("externalLink"));
|
||||||
String externalLinkText = jObject.getString("externalLinkText");
|
String externalLinkText = DatabaseDownloadTask.sqlEscapeString(jObject.getString("externalLinkText"));
|
||||||
Date dateTime = ArticleManager.iso8601Format.parse(jObject.getString("dateTime"));
|
Date dateTime = ArticleManager.iso8601Format.parse(jObject.getString("dateTime"));
|
||||||
int hidden = jObject.getInt("hidden");
|
int hidden = jObject.getInt("hidden");
|
||||||
|
|
||||||
@ -357,9 +447,9 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
String title = jObject.getString("title");
|
String title = DatabaseDownloadTask.sqlEscapeString(jObject.getString("title"));
|
||||||
String description = jObject.getString("description");
|
String description = DatabaseDownloadTask.sqlEscapeString(jObject.getString("description"));
|
||||||
int hidden = jObject.getInt("hidden");
|
int hidden = jObject.getInt("hidden");
|
||||||
int geoCategory = jObject.getInt("geoCategory");
|
int geoCategory = jObject.getInt("geoCategory");
|
||||||
int main = jObject.getInt("main");
|
int main = jObject.getInt("main");
|
||||||
@ -385,8 +475,8 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String albumName = jObject.getString("albumName");
|
String albumName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("albumName"));
|
||||||
String articleName = jObject.getString("articleName");
|
String articleName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("articleName"));
|
||||||
|
|
||||||
MainActivity.getInstance().articleDataSource.AddAlbumToArticle(albumName, articleName);
|
MainActivity.getInstance().articleDataSource.AddAlbumToArticle(albumName, articleName);
|
||||||
|
|
||||||
@ -409,8 +499,8 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String channelName = jObject.getString("channelName");
|
String channelName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("channelName"));
|
||||||
String articleName = jObject.getString("articleName");
|
String articleName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("articleName"));
|
||||||
|
|
||||||
MainActivity.getInstance().articleDataSource.AddChannelToArticle(channelName, articleName);
|
MainActivity.getInstance().articleDataSource.AddChannelToArticle(channelName, articleName);
|
||||||
|
|
||||||
@ -433,8 +523,8 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String articleName = jObject.getString("articleName");
|
String articleName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("articleName"));
|
||||||
String journalName = jObject.getString("journalName");
|
String journalName = DatabaseDownloadTask.sqlEscapeString(jObject.getString("journalName"));
|
||||||
|
|
||||||
MainActivity.getInstance().journalDataSource.AddArticleToJournal(articleName, journalName);
|
MainActivity.getInstance().journalDataSource.AddArticleToJournal(articleName, journalName);
|
||||||
|
|
||||||
@ -457,13 +547,13 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JSONObject jObject = jArray.getJSONObject(i);
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
String name = jObject.getString("name");
|
String name = DatabaseDownloadTask.sqlEscapeString(jObject.getString("name"));
|
||||||
String textEn = jObject.getString("textEn");
|
String textEn = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textEn"));
|
||||||
String textRu = jObject.getString("textRu");
|
String textRu = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textRu"));
|
||||||
String textZh = jObject.getString("textZh");
|
String textZh = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textZh"));
|
||||||
String textEnUp = jObject.getString("textEnUp");
|
String textEnUp = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textEnUp"));
|
||||||
String textRuUp = jObject.getString("textRuUp");
|
String textRuUp = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textRuUp"));
|
||||||
String textZhUp = jObject.getString("textZhUp");
|
String textZhUp = DatabaseDownloadTask.sqlEscapeString(jObject.getString("textZhUp"));
|
||||||
|
|
||||||
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh, textEnUp,
|
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh, textEnUp,
|
||||||
textRuUp, textZhUp));
|
textRuUp, textZhUp));
|
||||||
@ -476,4 +566,27 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String sqlEscapeString_withquotes(String s)
|
||||||
|
{
|
||||||
|
String result = DatabaseUtils.sqlEscapeString(s);
|
||||||
|
|
||||||
|
result = result.substring(1, result.length()-1);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sqlEscapeString(String s)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
String result = s;
|
||||||
|
|
||||||
|
result = DatabaseUtils.sqlEscapeString(result);
|
||||||
|
|
||||||
|
result = result.substring(1, result.length()-1);
|
||||||
|
|
||||||
|
return result;*/
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -24,9 +24,9 @@ public class DatabaseGetAlbumTask extends AsyncTask<String, Integer, Long>
|
|||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_STATE_UPDATE, album);
|
//Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ALBUM_STATE_UPDATE, album);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
//completeMessage.sendToTarget();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,20 +11,18 @@ import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
|||||||
public class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
|
public class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
|
||||||
{
|
{
|
||||||
|
|
||||||
ArrayList<JournalSemiFullData> journalList;
|
ArrayList<JournalSemiFullData> journalList;
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
|
||||||
protected Long doInBackground(String... queryArr)
|
protected Long doInBackground(String... queryArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (queryArr.length > 0)
|
if (queryArr.length > 0)
|
||||||
{
|
{
|
||||||
journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3); //Xperimental -- need to pass exactly how many articles
|
journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(7); //Xperimental -- need to pass exactly how many articles
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalListExceptHidden(3); //Xperimental -- need to pass exactly how many articles
|
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalListExceptHidden(7); //Xperimental -- need to pass exactly how many articles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,15 +31,16 @@ ArrayList<JournalSemiFullData> journalList;
|
|||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_UPDATE, journalList);
|
//Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_UPDATE, journalList);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
//completeMessage.sendToTarget();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Long result)
|
protected void onPostExecute(Long result)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
|
||||||
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ public class DatabaseGetJournalTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
JournalSemiFullData journal = null;
|
JournalSemiFullData journal = null;
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
|
||||||
protected Long doInBackground(Bundle... queryArr)
|
protected Long doInBackground(Bundle... queryArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,15 +28,15 @@ public class DatabaseGetJournalTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_STATE_UPDATE, journal);
|
//Message completeMessage = MainActivity.getInstance().obtainMessage(MainActivity.DATABASE_GET_JOURNAL_STATE_UPDATE, journal);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
//completeMessage.sendToTarget();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Long result)
|
protected void onPostExecute(Long result)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_STATE_FINISHED, journal);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_STATE_FINISHED, journal);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
}
|
}
|
||||||
|
@ -67,12 +67,23 @@ public class JournalManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static JournalSemiFullData CreateEmptyJournal()
|
|
||||||
|
public static JournalRecordData CreateEmptyJournal()
|
||||||
{
|
{
|
||||||
JournalSemiFullData result = new JournalSemiFullData(new JournalRecordData("", "", "", 1, 0, 0));
|
JournalRecordData result = new JournalRecordData("", "", "", 1, 0, 0);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JournalSemiFullData CreateEmptyJournalSemiFull()
|
||||||
|
{
|
||||||
|
JournalSemiFullData result = new JournalSemiFullData(CreateEmptyJournal());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
package fishrungames.bashgid.core;
|
package fishrungames.bashgid.core;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
|
import fishrungames.networkutils.SimpleAsyncTask;
|
||||||
|
|
||||||
public class NewsDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
public class NewsDownloadTask extends SimpleAsyncTask
|
||||||
{
|
{
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
|
||||||
protected Long doInBackground(Bundle... queryArr)
|
protected Long doInBackground(Bundle... queryArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < NewsManager.urlArr.length; i++)
|
for (int i = 0; i < NewsManager.urlArr.length; i++)
|
||||||
{
|
{
|
||||||
NewsManager.LoadNewsAndImagesFromRss(NewsManager.urlArr[i]);
|
NewsManager.LoadNewsFromRss(NewsManager.urlArr[i], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (long) 0;
|
return (long) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
protected void onProgressUpdate(Integer... progress)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.NEWS_DOWNLOADER_STATE_UPDATE, this);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.NEWS_DOWNLOADER_STATE_UPDATE, progress[0]);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
|
|
||||||
@ -35,9 +34,10 @@ public class NewsDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
protected void onPostExecute(Long result)
|
protected void onPostExecute(Long result)
|
||||||
{
|
{
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.NEWS_DOWNLOADER_STATE_FINISHED, this);
|
Message completeMessage = MainActivity.getInstance().mainHandler.obtainMessage(MainActivity.NEWS_DOWNLOADER_STATE_FINISHED, 100);
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
completeMessage.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,35 +2,32 @@ package fishrungames.bashgid.core;
|
|||||||
|
|
||||||
import fishrungames.networkutils.ImageManager;
|
import fishrungames.networkutils.ImageManager;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
import fishrungames.networkutils.DownloadFunctions;
|
import fishrungames.networkutils.DownloadFunctions;
|
||||||
|
import fishrungames.networkutils.SimpleAsyncTask;
|
||||||
|
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
import fishrungames.bashgid.R;
|
import fishrungames.bashgid.R;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
||||||
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
||||||
|
|
||||||
|
public class NewsManager
|
||||||
public class NewsManager {
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public static final String [] urlArr = {
|
* public static final String [] urlArr = {
|
||||||
"https://www.bashkortostan.ru/presscenter/news/rss/",
|
* "https://www.bashkortostan.ru/presscenter/news/rss/",
|
||||||
"http://www.bashedu.ru/rss.xml",
|
* "http://www.bashedu.ru/rss.xml", "http://www.bashinform.ru/rss/all.xml",
|
||||||
"http://www.bashinform.ru/rss/all.xml",
|
* "http://www.minkult-rb.ru/news/rss/", "http://02.mvd.ru/news/rss/" };
|
||||||
"http://www.minkult-rb.ru/news/rss/",
|
*/
|
||||||
"http://02.mvd.ru/news/rss/"
|
|
||||||
}; */
|
|
||||||
|
|
||||||
public static final String [] urlArr = {
|
|
||||||
"https://news.yandex.ru/Ufa/index.rss",
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public static final String[] urlArr = { "https://news.yandex.ru/Ufa/index.rss", };
|
||||||
|
|
||||||
public static ArrayList<String> ExtractEnclosureImageUrl(ArrayList<RssReader.Rss2Item> rss2ItemArr)
|
public static ArrayList<String> ExtractEnclosureImageUrl(ArrayList<RssReader.Rss2Item> rss2ItemArr)
|
||||||
{
|
{
|
||||||
@ -38,7 +35,7 @@ public class NewsManager {
|
|||||||
|
|
||||||
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
||||||
{
|
{
|
||||||
//Enclosure
|
// Enclosure
|
||||||
if (rss2Item.rss2Enclosure != null)
|
if (rss2Item.rss2Enclosure != null)
|
||||||
{
|
{
|
||||||
if (DownloadFunctions.MimeTypeIsImage(rss2Item.rss2Enclosure.mimeType))
|
if (DownloadFunctions.MimeTypeIsImage(rss2Item.rss2Enclosure.mimeType))
|
||||||
@ -57,7 +54,7 @@ public class NewsManager {
|
|||||||
|
|
||||||
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
||||||
{
|
{
|
||||||
//And images inside text
|
// And images inside text
|
||||||
int i = rss2Item.description.indexOf("<img");
|
int i = rss2Item.description.indexOf("<img");
|
||||||
|
|
||||||
while (i != -1)
|
while (i != -1)
|
||||||
@ -101,8 +98,8 @@ public class NewsManager {
|
|||||||
return absoluteImageUrlList;
|
return absoluteImageUrlList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ReplaceRemoteUrlToLocalUrl(ArrayList<RssReader.Rss2Item> rss2ItemArr, ArrayList<String> relativeImageUrlList,
|
||||||
static void ReplaceRemoteUrlToLocalUrl(ArrayList<RssReader.Rss2Item> rss2ItemArr, ArrayList<String> relativeImageUrlList, ArrayList<String> absoluteImageUrlList)
|
ArrayList<String> absoluteImageUrlList)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
for (RssReader.Rss2Item rss2Item : rss2ItemArr)
|
||||||
@ -111,83 +108,91 @@ public class NewsManager {
|
|||||||
{
|
{
|
||||||
String fileName = ImageManager.GetImageLocalUrl(absoluteImageUrlList.get(i));
|
String fileName = ImageManager.GetImageLocalUrl(absoluteImageUrlList.get(i));
|
||||||
|
|
||||||
rss2Item.description = rss2Item.description.replace("\"" +relativeImageUrlList.get(i) + "\"" , "\"" +fileName + "\"");
|
rss2Item.description = rss2Item.description.replace("\"" + relativeImageUrlList.get(i) + "\"", "\"" + fileName + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadNewsAndImagesFromRss(String url)
|
static void LoadNewsFromRss(String url, SimpleAsyncTask task)
|
||||||
{
|
{
|
||||||
//Xperimental -- need to optimize this code. slow block BEGINS
|
// Xperimental -- need to optimize this code. slow block BEGINS
|
||||||
String xmlCode = DownloadFunctions.getXmlFromUrl(url);
|
String xmlCode = DownloadFunctions.getXmlFromUrl(url, task);
|
||||||
|
|
||||||
if (xmlCode == null)
|
if (xmlCode == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove BOM character if present
|
// Remove BOM character if present
|
||||||
if (xmlCode.startsWith("\uFEFF"))
|
if (xmlCode.startsWith("\uFEFF"))
|
||||||
{
|
{
|
||||||
xmlCode = xmlCode.substring(1);
|
xmlCode = xmlCode.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (task != null)
|
||||||
|
{
|
||||||
|
if (task.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
task.PublishMoreProgress();
|
||||||
|
}
|
||||||
|
|
||||||
RssReader rssReader = new RssReader();
|
RssReader rssReader = new RssReader();
|
||||||
|
|
||||||
rssReader.ReadRss(xmlCode);
|
rssReader.ReadRss(xmlCode);
|
||||||
|
|
||||||
|
// Xperimental -- need to optimize this code. slow block ENDS
|
||||||
|
|
||||||
|
//for (RssReader.Rss2Item rss2Item : rssReader.rss2ItemArr)
|
||||||
//Xperimental -- need to optimize this code. slow block ENDS
|
for (int i = 0; i < rssReader.rss2ItemArr.size(); i++)
|
||||||
|
|
||||||
|
|
||||||
for (RssReader.Rss2Item rss2Item : rssReader.rss2ItemArr)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
RssReader.Rss2Item rss2Item = rssReader.rss2ItemArr.get(i);
|
||||||
|
|
||||||
String title = rss2Item.title.replace("'", "''").replace("\"", "\"\"");
|
String title = rss2Item.title.replace("'", "''").replace("\"", "\"\"");
|
||||||
String description = rss2Item.description.replace("'", "''").replace("\"", "\"\"");
|
String description = rss2Item.description.replace("'", "''").replace("\"", "\"\"");
|
||||||
|
|
||||||
String titleUp = title.toUpperCase(new Locale("ru"));
|
String titleUp = title.toUpperCase(new Locale("ru"));
|
||||||
String descriptionUp = description.toUpperCase(new Locale("ru"));
|
String descriptionUp = description.toUpperCase(new Locale("ru"));
|
||||||
|
|
||||||
|
ArticleRecordData newsArticle = new ArticleRecordData(title, ArticleManager.ARTICLE_TYPE_NEWS, title, description, 0, 0, "", "", rss2Item.link,
|
||||||
ArticleRecordData newsArticle = new ArticleRecordData(
|
MainActivity.getInstance().getResources().getString(R.string.dialog_open), rss2Item.pubDate, 0);
|
||||||
title,
|
|
||||||
ArticleManager.ARTICLE_TYPE_NEWS,
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
rss2Item.link,
|
|
||||||
MainActivity.getInstance().getResources().getString(R.string.dialog_open),
|
|
||||||
rss2Item.pubDate,
|
|
||||||
0);
|
|
||||||
|
|
||||||
AlbumManager.AddNewArticleToJournal(newsArticle, "news");
|
AlbumManager.AddNewArticleToJournal(newsArticle, "news");
|
||||||
|
|
||||||
//To perform search
|
// To perform search
|
||||||
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(
|
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(title, title, // En
|
||||||
title,
|
title, // Ru
|
||||||
title, //En
|
title, // Zh
|
||||||
title, //Ru
|
titleUp, // En Up
|
||||||
title, //Zh
|
titleUp, // Ru Up
|
||||||
titleUp, //En Up
|
titleUp // Zh Up
|
||||||
titleUp, //Ru Up
|
|
||||||
titleUp //Zh Up
|
|
||||||
));
|
));
|
||||||
|
|
||||||
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(
|
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(description, description, // En
|
||||||
description,
|
description, // Ru
|
||||||
description, //En
|
description, // Zh
|
||||||
description, //Ru
|
descriptionUp, // En Up
|
||||||
description, //Zh
|
descriptionUp, // Ru Up
|
||||||
descriptionUp, //En Up
|
descriptionUp // Zh Up
|
||||||
descriptionUp, //Ru Up
|
|
||||||
descriptionUp //Zh Up
|
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
if (task != null)
|
||||||
|
{
|
||||||
|
if (task.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
task.PublishProgress(i / (float) rssReader.rss2ItemArr.size());
|
||||||
|
task.ReloadDatabaseContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,12 @@ public class TranslationManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static TranslationRecordData CreateEmptyTranslation()
|
||||||
|
{
|
||||||
|
TranslationRecordData result = new TranslationRecordData("", "", "", "", "", "", "");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package fishrungames.bashgid.core;
|
package fishrungames.bashgid.core;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
|
|
||||||
|
|
||||||
public class VideoManager
|
public class VideoManager
|
||||||
{
|
{
|
||||||
public static final int VIDEO_TYPE_YOUTUBE = 1;
|
public static final int VIDEO_TYPE_YOUTUBE = 1;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
import fishrungames.bashgid.core.AlbumManager;
|
import fishrungames.bashgid.core.AlbumManager;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
|
||||||
@ -13,7 +14,6 @@ import android.content.Context;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class AlbumDataSource
|
public class AlbumDataSource
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ public class AlbumDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_ALBUM, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_ALBUM, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_ALBUM, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
|
database.update(BashgidSqliteHelper.TABLE_ALBUM, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.name) +"'", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
@ -62,7 +62,7 @@ public class AlbumDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -109,9 +109,9 @@ public class AlbumDataSource
|
|||||||
|
|
||||||
public AlbumFullData GetAlbumFullData(String name)
|
public AlbumFullData GetAlbumFullData(String name)
|
||||||
{
|
{
|
||||||
AlbumFullData result = null;
|
AlbumFullData result = AlbumManager.CreateEmptyAlbum();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ public class AlbumDataSource
|
|||||||
public AlbumFullData InnerGetAlbumFullData(String name, SQLiteDatabase database)
|
public AlbumFullData InnerGetAlbumFullData(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
AlbumFullData result = null;
|
AlbumFullData result = AlbumManager.CreateEmptyAlbum();
|
||||||
|
|
||||||
AlbumRecordData recordData = innerGetAlbumByName(name, database);
|
AlbumRecordData recordData = innerGetAlbumByName(name, database);
|
||||||
|
|
||||||
@ -158,9 +158,9 @@ public class AlbumDataSource
|
|||||||
|
|
||||||
public AlbumShortData GetAlbumShortData(String name)
|
public AlbumShortData GetAlbumShortData(String name)
|
||||||
{
|
{
|
||||||
AlbumShortData result = null;
|
AlbumShortData result = new AlbumShortData(new AlbumRecordData("", "", "", 1));
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -202,7 +202,7 @@ public class AlbumDataSource
|
|||||||
|
|
||||||
ArrayList<AlbumShortData> result = new ArrayList<AlbumShortData>();
|
ArrayList<AlbumShortData> result = new ArrayList<AlbumShortData>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -228,6 +228,13 @@ public class AlbumDataSource
|
|||||||
{
|
{
|
||||||
shortData.firstImageUrl = imageUrlArr.get(0);
|
shortData.firstImageUrl = imageUrlArr.get(0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shortData.firstImageUrl = "R.drawable.no_picture";
|
||||||
|
}
|
||||||
|
|
||||||
|
shortData.title = MainActivity.getInstance().translationDataSource.TryTranslateText(shortData.title, database);
|
||||||
|
shortData.description = MainActivity.getInstance().translationDataSource.TryTranslateText(shortData.description, database);
|
||||||
|
|
||||||
result.add(shortData);
|
result.add(shortData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
@ -253,7 +260,7 @@ public class AlbumDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
+ "=?", new String[] { name }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -278,7 +285,7 @@ public class AlbumDataSource
|
|||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL,
|
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 + "=?",
|
BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?" + " AND " + BashgidSqliteHelper.COLUMN_NAME + "=?",
|
||||||
new String[] { imageUrl, name }, null, null, null, null);
|
new String[] { DatabaseDownloadTask.sqlEscapeString(imageUrl), DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -300,7 +307,7 @@ public class AlbumDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -323,10 +330,10 @@ public class AlbumDataSource
|
|||||||
public AlbumRecordData innerGetAlbumByName(String name, SQLiteDatabase database)
|
public AlbumRecordData innerGetAlbumByName(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
AlbumRecordData result = null;
|
AlbumRecordData result = new AlbumRecordData("", "", "", 1);
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, 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[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
package fishrungames.bashgid.core.db;
|
package fishrungames.bashgid.core.db;
|
||||||
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
||||||
import fishrungames.bashgid.core.ArticleManager;
|
import fishrungames.bashgid.core.ArticleManager;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
||||||
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
|
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
|
||||||
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ArticleDataSource
|
public class ArticleDataSource
|
||||||
@ -28,15 +27,14 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
private BashgidSqliteHelper dbHelper = null;
|
private BashgidSqliteHelper dbHelper = null;
|
||||||
|
|
||||||
|
public static class DateSortComparator implements Comparator<ArticleManager.ArticleRecordData>
|
||||||
|
{
|
||||||
public static class DateSortComparator implements Comparator<ArticleManager.ArticleRecordData> {
|
public int compare(ArticleManager.ArticleRecordData record1, ArticleManager.ArticleRecordData record2)
|
||||||
public int compare(ArticleManager.ArticleRecordData record1, ArticleManager.ArticleRecordData record2) {
|
{
|
||||||
return record2.dateTime.compareTo(record1.dateTime);
|
return record2.dateTime.compareTo(record1.dateTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArticleDataSource(Context context, BashgidSqliteHelper dbHelper)
|
public ArticleDataSource(Context context, BashgidSqliteHelper dbHelper)
|
||||||
{
|
{
|
||||||
this.dbHelper = dbHelper;
|
this.dbHelper = dbHelper;
|
||||||
@ -48,7 +46,6 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
@ -71,7 +68,7 @@ public class ArticleDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_ARTICLE, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_ARTICLE, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_ARTICLE, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
|
database.update(BashgidSqliteHelper.TABLE_ARTICLE, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.name) + "'", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
@ -86,7 +83,7 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -95,7 +92,6 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
result = innerIsArticleAlreadyExist(name, database);
|
result = innerIsArticleAlreadyExist(name, database);
|
||||||
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
@ -122,11 +118,10 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
if (!innerAlbumArticleRelationAlreadyExist(albumName, articleName, database))
|
if (!innerAlbumArticleRelationAlreadyExist(albumName, articleName, database))
|
||||||
{
|
{
|
||||||
//Log.e("a", "aaa1");
|
|
||||||
database.insert(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, null, values);
|
||||||
//Log.e("a", "aaa2");
|
|
||||||
}
|
}
|
||||||
//Log.e("a", "aaa3");
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
@ -151,11 +146,8 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
if (!innerChannelArticleRelationAlreadyExist(channelName, articleName, database))
|
if (!innerChannelArticleRelationAlreadyExist(channelName, articleName, database))
|
||||||
{
|
{
|
||||||
//Log.e("a", "aaa1");
|
|
||||||
database.insert(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, null, values);
|
||||||
//Log.e("a", "aaa2");
|
|
||||||
}
|
}
|
||||||
//Log.e("a", "aaa3");
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
@ -168,16 +160,14 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArticleFullData result = null;
|
ArticleFullData result = null;
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
result = InnerGetArticleFullData(name, database);
|
result = InnerGetArticleFullData(name, database);
|
||||||
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
@ -189,8 +179,7 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
public ArticleFullData InnerGetArticleFullData(String name, SQLiteDatabase database)
|
public ArticleFullData InnerGetArticleFullData(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
ArticleFullData result = null;
|
ArticleFullData result = new ArticleFullData(ArticleManager.CreateEmptyArticle());
|
||||||
|
|
||||||
|
|
||||||
ArticleRecordData recordData = innerGetArticleByName(name, database);
|
ArticleRecordData recordData = innerGetArticleByName(name, database);
|
||||||
|
|
||||||
@ -219,20 +208,22 @@ public class ArticleDataSource
|
|||||||
result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database);
|
result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database);
|
||||||
result.externalLinkText = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLinkText, database);
|
result.externalLinkText = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLinkText, database);
|
||||||
|
|
||||||
|
if (result.type == ArticleManager.ARTICLE_TYPE_NEWS)
|
||||||
|
{
|
||||||
|
result.title = Html.fromHtml(result.title).toString();
|
||||||
|
result.content = Html.fromHtml(result.content).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArticleShortData GetArticleShortData(String name)
|
public ArticleShortData GetArticleShortData(String name)
|
||||||
{
|
{
|
||||||
ArticleShortData result = null;
|
ArticleShortData result = new ArticleShortData(ArticleManager.CreateEmptyArticle());
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -241,7 +232,6 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
result = InnerGetArticleShortData(name, database);
|
result = InnerGetArticleShortData(name, database);
|
||||||
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
@ -255,7 +245,7 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -281,7 +271,7 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -310,7 +300,7 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -318,7 +308,6 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
result = InnerSearchArticleByQuery(query, database);
|
result = InnerSearchArticleByQuery(query, database);
|
||||||
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
@ -332,7 +321,7 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -349,7 +338,6 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
@ -363,7 +351,6 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
|
||||||
|
|
||||||
|
|
||||||
ArrayList<ArticleRecordData> recordDataArr = innerGetArticlesByQuery(query, database);
|
ArrayList<ArticleRecordData> recordDataArr = innerGetArticlesByQuery(query, database);
|
||||||
|
|
||||||
for (int i = 0; i < recordDataArr.size(); i++)
|
for (int i = 0; i < recordDataArr.size(); i++)
|
||||||
@ -375,17 +362,15 @@ public class ArticleDataSource
|
|||||||
result.add(article);
|
result.add(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean InnerArticleIsHidden(String name, SQLiteDatabase database)
|
public boolean InnerArticleIsHidden(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=? AND " +BashgidSqliteHelper.COLUMN_HIDDEN + "=1", new String[] { name }, null, null, null, null);
|
+ "=? AND " + BashgidSqliteHelper.COLUMN_HIDDEN + "=1", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -401,12 +386,9 @@ public class ArticleDataSource
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ArticleShortData InnerGetArticleShortData(String name, SQLiteDatabase database)
|
public ArticleShortData InnerGetArticleShortData(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
ArticleShortData result = null;
|
ArticleShortData result = new ArticleShortData(ArticleManager.CreateEmptyArticle());
|
||||||
|
|
||||||
|
|
||||||
ArticleRecordData recordData = innerGetArticleByName(name, database);
|
ArticleRecordData recordData = innerGetArticleByName(name, database);
|
||||||
|
|
||||||
@ -420,10 +402,14 @@ public class ArticleDataSource
|
|||||||
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
|
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
|
||||||
result.content = MainActivity.getInstance().translationDataSource.TryTranslateText(result.content, database);
|
result.content = MainActivity.getInstance().translationDataSource.TryTranslateText(result.content, database);
|
||||||
result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database);
|
result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database);
|
||||||
|
result.externalLinkText = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLinkText, database);
|
||||||
|
|
||||||
|
if (result.type == ArticleManager.ARTICLE_TYPE_NEWS)
|
||||||
|
{
|
||||||
|
result.title = Html.fromHtml(result.title).toString();
|
||||||
|
result.content = Html.fromHtml(result.content).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -467,8 +453,8 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -485,14 +471,13 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean innerAlbumArticleRelationAlreadyExist(String albumName, String articleName, SQLiteDatabase database)
|
private boolean innerAlbumArticleRelationAlreadyExist(String albumName, String articleName, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ALBUM_NAME, BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ALBUM_NAME,
|
||||||
BashgidSqliteHelper.COLUMN_ALBUM_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { albumName, articleName }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_ARTICLE_NAME }, BashgidSqliteHelper.COLUMN_ALBUM_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_ARTICLE_NAME
|
||||||
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(albumName), DatabaseDownloadTask.sqlEscapeString(articleName) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -512,8 +497,9 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_CHANNEL_NAME, BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_CHANNEL_NAME,
|
||||||
BashgidSqliteHelper.COLUMN_CHANNEL_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { channelName, articleName }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_ARTICLE_NAME }, BashgidSqliteHelper.COLUMN_CHANNEL_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_ARTICLE_NAME
|
||||||
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(channelName), DatabaseDownloadTask.sqlEscapeString(articleName) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -533,23 +519,13 @@ public class ArticleDataSource
|
|||||||
private ArticleRecordData innerGetArticleByName(String name, SQLiteDatabase database)
|
private ArticleRecordData innerGetArticleByName(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
ArticleRecordData result = null;
|
ArticleRecordData result = ArticleManager.CreateEmptyArticle();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TYPE,
|
||||||
BashgidSqliteHelper.COLUMN_NAME,
|
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_CONTENT, BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON,
|
||||||
BashgidSqliteHelper.COLUMN_TYPE,
|
BashgidSqliteHelper.COLUMN_ADDRESS, BashgidSqliteHelper.COLUMN_PHONE, BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,
|
||||||
BashgidSqliteHelper.COLUMN_TITLE,
|
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK_TEXT, BashgidSqliteHelper.COLUMN_DATE_TIME, BashgidSqliteHelper.COLUMN_HIDDEN },
|
||||||
BashgidSqliteHelper.COLUMN_CONTENT,
|
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
BashgidSqliteHelper.COLUMN_GEOLAT,
|
|
||||||
BashgidSqliteHelper.COLUMN_GEOLON,
|
|
||||||
BashgidSqliteHelper.COLUMN_ADDRESS,
|
|
||||||
BashgidSqliteHelper.COLUMN_PHONE,
|
|
||||||
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,
|
|
||||||
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK_TEXT,
|
|
||||||
BashgidSqliteHelper.COLUMN_DATE_TIME,
|
|
||||||
BashgidSqliteHelper.COLUMN_HIDDEN
|
|
||||||
},
|
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -561,26 +537,13 @@ public class ArticleDataSource
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
|
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
|
||||||
}
|
} catch (ParseException e)
|
||||||
catch(ParseException e)
|
|
||||||
{
|
{
|
||||||
Log.e("aaa", "aaa!!!!!");
|
Log.e("aaa", "aaa!!!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new ArticleRecordData(
|
result = new ArticleRecordData(cursor.getString(0), cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getDouble(4),
|
||||||
cursor.getString(0),
|
cursor.getDouble(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), d, cursor.getInt(11));
|
||||||
cursor.getInt(1),
|
|
||||||
cursor.getString(2),
|
|
||||||
cursor.getString(3),
|
|
||||||
cursor.getDouble(4),
|
|
||||||
cursor.getDouble(5),
|
|
||||||
cursor.getString(6),
|
|
||||||
cursor.getString(7),
|
|
||||||
cursor.getString(8),
|
|
||||||
cursor.getString(9),
|
|
||||||
d,
|
|
||||||
cursor.getInt(11)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
@ -596,21 +559,11 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
ArrayList<ArticleRecordData> result = new ArrayList<ArticleRecordData>();
|
ArrayList<ArticleRecordData> result = new ArrayList<ArticleRecordData>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TYPE,
|
||||||
BashgidSqliteHelper.COLUMN_NAME,
|
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_CONTENT, BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON,
|
||||||
BashgidSqliteHelper.COLUMN_TYPE,
|
BashgidSqliteHelper.COLUMN_ADDRESS, BashgidSqliteHelper.COLUMN_PHONE, BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,
|
||||||
BashgidSqliteHelper.COLUMN_TITLE,
|
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK_TEXT, BashgidSqliteHelper.COLUMN_DATE_TIME, BashgidSqliteHelper.COLUMN_HIDDEN },
|
||||||
BashgidSqliteHelper.COLUMN_CONTENT,
|
BashgidSqliteHelper.COLUMN_TITLE + " LIKE ?", new String[] { "%" + DatabaseDownloadTask.sqlEscapeString(query) + "%" }, null, null, null, null);
|
||||||
BashgidSqliteHelper.COLUMN_GEOLAT,
|
|
||||||
BashgidSqliteHelper.COLUMN_GEOLON,
|
|
||||||
BashgidSqliteHelper.COLUMN_ADDRESS,
|
|
||||||
BashgidSqliteHelper.COLUMN_PHONE,
|
|
||||||
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,
|
|
||||||
BashgidSqliteHelper.COLUMN_EXTERNAL_LINK_TEXT,
|
|
||||||
BashgidSqliteHelper.COLUMN_DATE_TIME,
|
|
||||||
BashgidSqliteHelper.COLUMN_HIDDEN
|
|
||||||
},
|
|
||||||
BashgidSqliteHelper.COLUMN_TITLE + " LIKE ?", new String[] { "%" + query + "%" }, null, null, null, null);
|
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -625,29 +578,15 @@ public class ArticleDataSource
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
|
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
|
||||||
}
|
} catch (ParseException e)
|
||||||
catch(ParseException e)
|
|
||||||
{
|
{
|
||||||
Log.e("aaa", "aaa!!!!!");
|
Log.e("aaa", "aaa!!!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(new ArticleRecordData(
|
result.add(new ArticleRecordData(cursor.getString(0), cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getDouble(4),
|
||||||
cursor.getString(0),
|
cursor.getDouble(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), d, cursor.getInt(11)));
|
||||||
cursor.getInt(1),
|
|
||||||
cursor.getString(2),
|
|
||||||
cursor.getString(3),
|
|
||||||
cursor.getDouble(4),
|
|
||||||
cursor.getDouble(5),
|
|
||||||
cursor.getString(6),
|
|
||||||
cursor.getString(7),
|
|
||||||
cursor.getString(8),
|
|
||||||
cursor.getString(9),
|
|
||||||
d,
|
|
||||||
cursor.getInt(11)
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
} while (cursor.moveToNext());
|
||||||
while (cursor.moveToNext());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
@ -658,16 +597,13 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<String> InnerSearchArticleByTitleOrText(String query, SQLiteDatabase database)
|
private ArrayList<String> InnerSearchArticleByTitleOrText(String query, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_TITLE
|
||||||
BashgidSqliteHelper.COLUMN_NAME
|
+ " = ? OR " + BashgidSqliteHelper.COLUMN_CONTENT + " = ?", new String[] { DatabaseDownloadTask.sqlEscapeString(query), DatabaseDownloadTask.sqlEscapeString(query) }, null, null, null, null);
|
||||||
},
|
|
||||||
BashgidSqliteHelper.COLUMN_TITLE + " = ? OR " + BashgidSqliteHelper.COLUMN_CONTENT + " = ?", new String[] { query, query }, null, null, null, null);
|
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -679,8 +615,7 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
result.add(cursor.getString(0));
|
result.add(cursor.getString(0));
|
||||||
|
|
||||||
}
|
} while (cursor.moveToNext());
|
||||||
while (cursor.moveToNext());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
@ -696,7 +631,7 @@ public class ArticleDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ALBUM_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ALBUM_NAME },
|
||||||
BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -705,8 +640,7 @@ public class ArticleDataSource
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
result.add(cursor.getString(0));
|
result.add(cursor.getString(0));
|
||||||
}
|
} while (cursor.moveToNext());
|
||||||
while (cursor.moveToNext());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,7 +657,7 @@ public class ArticleDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_CHANNEL_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL_ARTICLE_RELATION, new String[] { BashgidSqliteHelper.COLUMN_CHANNEL_NAME },
|
||||||
BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -732,8 +666,7 @@ public class ArticleDataSource
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
result.add(cursor.getString(0));
|
result.add(cursor.getString(0));
|
||||||
}
|
} while (cursor.moveToNext());
|
||||||
while (cursor.moveToNext());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,6 +678,4 @@ public class ArticleDataSource
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
|
|||||||
@Override
|
@Override
|
||||||
public SQLiteDatabase getWritableDatabase()
|
public SQLiteDatabase getWritableDatabase()
|
||||||
{
|
{
|
||||||
|
|
||||||
SQLiteDatabase result = null;
|
SQLiteDatabase result = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -200,6 +201,36 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
//return super.getWritableDatabase();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SQLiteDatabase getReadableDatabase()
|
||||||
|
{
|
||||||
|
|
||||||
|
SQLiteDatabase result = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mutex.acquire();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = super.getReadableDatabase();
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
mutex.release();
|
||||||
|
}
|
||||||
|
} catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
Log.e("Error in getWritableDatabase()", "Error in getWritableDatabase()");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
//return super.getReadableDatabase();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.ChannelManager;
|
import fishrungames.bashgid.core.ChannelManager;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
|
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
|
||||||
import fishrungames.bashgid.core.ChannelManager.ChannelRecordData;
|
import fishrungames.bashgid.core.ChannelManager.ChannelRecordData;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class ChannelDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_CHANNEL, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_CHANNEL, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_CHANNEL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"", null);
|
database.update(BashgidSqliteHelper.TABLE_CHANNEL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.name) + "'", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
@ -61,7 +62,7 @@ public class ChannelDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -108,9 +109,9 @@ public class ChannelDataSource
|
|||||||
|
|
||||||
public ChannelFullData GetChannelFullData(String name)
|
public ChannelFullData GetChannelFullData(String name)
|
||||||
{
|
{
|
||||||
ChannelFullData result = null;
|
ChannelFullData result = ChannelManager.CreateEmptyChannel();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -131,7 +132,7 @@ public class ChannelDataSource
|
|||||||
public ChannelFullData InnerGetChannelFullData(String name, SQLiteDatabase database)
|
public ChannelFullData InnerGetChannelFullData(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
ChannelFullData result = null;
|
ChannelFullData result = ChannelManager.CreateEmptyChannel();
|
||||||
|
|
||||||
ChannelRecordData recordData = InnerGetChannelByName(name, database);
|
ChannelRecordData recordData = InnerGetChannelByName(name, database);
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ public class ChannelDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
+ "=?", new String[] { name }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -183,7 +184,7 @@ public class ChannelDataSource
|
|||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO_CHANNEL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL,
|
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 + "=?",
|
BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?" + " AND " + BashgidSqliteHelper.COLUMN_NAME + "=?",
|
||||||
new String[] { videoUrl, name }, null, null, null, null);
|
new String[] { DatabaseDownloadTask.sqlEscapeString(videoUrl), DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -205,7 +206,7 @@ public class ChannelDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO_CHANNEL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO_CHANNEL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL },
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -228,10 +229,10 @@ public class ChannelDataSource
|
|||||||
public ChannelRecordData InnerGetChannelByName(String name, SQLiteDatabase database)
|
public ChannelRecordData InnerGetChannelByName(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
ChannelRecordData result = null;
|
ChannelRecordData result = new ChannelRecordData("", "", "", 1);
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
|
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 },
|
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) },
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Collections;
|
|||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.ArticleManager;
|
import fishrungames.bashgid.core.ArticleManager;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
import fishrungames.bashgid.core.JournalManager;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
|
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
|
||||||
@ -52,7 +53,7 @@ public class JournalDataSource
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Replace
|
// Replace
|
||||||
database.update(BashgidSqliteHelper.TABLE_JOURNAL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"", null);
|
database.update(BashgidSqliteHelper.TABLE_JOURNAL, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.name) + "'", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
@ -67,7 +68,7 @@ public class JournalDataSource
|
|||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -126,9 +127,9 @@ public class JournalDataSource
|
|||||||
|
|
||||||
public JournalSemiFullData GetJournalSemiFullData(String name, String startAfterArticleName, int count)
|
public JournalSemiFullData GetJournalSemiFullData(String name, String startAfterArticleName, int count)
|
||||||
{
|
{
|
||||||
JournalSemiFullData result = null;
|
JournalSemiFullData result = JournalManager.CreateEmptyJournalSemiFull();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -149,7 +150,7 @@ public class JournalDataSource
|
|||||||
public ArrayList<JournalSemiFullData> GetAllJournalListExceptHidden(int count)
|
public ArrayList<JournalSemiFullData> GetAllJournalListExceptHidden(int count)
|
||||||
{
|
{
|
||||||
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -216,7 +217,7 @@ public class JournalDataSource
|
|||||||
// Xperimental - need to create a real superjournal
|
// Xperimental - need to create a real superjournal
|
||||||
|
|
||||||
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -282,7 +283,7 @@ public class JournalDataSource
|
|||||||
public ArrayList<JournalRecordData> GetGeoJournalList()
|
public ArrayList<JournalRecordData> GetGeoJournalList()
|
||||||
{
|
{
|
||||||
ArrayList<JournalRecordData> result = new ArrayList<JournalRecordData>();
|
ArrayList<JournalRecordData> result = new ArrayList<JournalRecordData>();
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -332,7 +333,7 @@ public class JournalDataSource
|
|||||||
public JournalSemiFullData InnerGetJournalSemiFullData(String name, SQLiteDatabase database, String startAfterArticleName, int count)
|
public JournalSemiFullData InnerGetJournalSemiFullData(String name, SQLiteDatabase database, String startAfterArticleName, int count)
|
||||||
{
|
{
|
||||||
|
|
||||||
JournalSemiFullData result = null;
|
JournalSemiFullData result = JournalManager.CreateEmptyJournalSemiFull();
|
||||||
|
|
||||||
JournalRecordData recordData = innerGetJournalByName(name, database);
|
JournalRecordData recordData = innerGetJournalByName(name, database);
|
||||||
|
|
||||||
@ -395,7 +396,7 @@ public class JournalDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
+ "=?", new String[] { name }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -418,7 +419,7 @@ public class JournalDataSource
|
|||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME,
|
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
|
BashgidSqliteHelper.COLUMN_JOURNAL_NAME }, BashgidSqliteHelper.COLUMN_ARTICLE_NAME + "=?" + " AND " + BashgidSqliteHelper.COLUMN_JOURNAL_NAME
|
||||||
+ "=?", new String[] { articleName, journalName }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(articleName), DatabaseDownloadTask.sqlEscapeString(journalName) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -440,7 +441,7 @@ public class JournalDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
||||||
BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -466,7 +467,7 @@ public class JournalDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
||||||
BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -492,11 +493,11 @@ public class JournalDataSource
|
|||||||
public JournalRecordData innerGetJournalByName(String name, SQLiteDatabase database)
|
public JournalRecordData innerGetJournalByName(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
JournalRecordData result = null;
|
JournalRecordData result = JournalManager.CreateEmptyJournal();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
|
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_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY,
|
||||||
BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fishrungames.bashgid.core.db;
|
package fishrungames.bashgid.core.db;
|
||||||
|
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@ -45,7 +46,7 @@ public class PhotoDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_PHOTO, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_PHOTO, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_PHOTO, values, BashgidSqliteHelper.COLUMN_IMAGE_URL + " = " + "\"" + recordData.imageUrl + "\"",
|
database.update(BashgidSqliteHelper.TABLE_PHOTO, values, BashgidSqliteHelper.COLUMN_IMAGE_URL + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.imageUrl) + "'",
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +60,9 @@ public class PhotoDataSource
|
|||||||
|
|
||||||
public PhotoRecordData GetPhotoByImageUrl(String imageUrl)
|
public PhotoRecordData GetPhotoByImageUrl(String imageUrl)
|
||||||
{
|
{
|
||||||
PhotoRecordData result = null;
|
PhotoRecordData result = new PhotoRecordData("", "", "", "", 0, 0);
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -81,11 +82,11 @@ public class PhotoDataSource
|
|||||||
public PhotoRecordData InnerGetPhotoByImageUrl(String imageUrl, SQLiteDatabase database)
|
public PhotoRecordData InnerGetPhotoByImageUrl(String imageUrl, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
PhotoRecordData result = null;
|
PhotoRecordData result = new PhotoRecordData("", "", "", "", 0, 0);
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_TITLE,
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_TITLE,
|
||||||
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_IMAGE_URL, BashgidSqliteHelper.COLUMN_IMAGE_HASH,
|
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_IMAGE_URL, BashgidSqliteHelper.COLUMN_IMAGE_HASH,
|
||||||
BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON }, BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?", new String[] { imageUrl },
|
BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON }, BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(imageUrl) },
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
@ -113,7 +114,7 @@ public class PhotoDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
|
||||||
BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?", new String[] { imageUrl }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(imageUrl) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,8 @@ package fishrungames.bashgid.core.db;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
|
import fishrungames.bashgid.core.TranslationManager;
|
||||||
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@ -46,7 +48,7 @@ public class TranslationDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_TRANSLATION, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_TRANSLATION, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_TRANSLATION, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "\"" + recordData.name + "\"",
|
database.update(BashgidSqliteHelper.TABLE_TRANSLATION, values, BashgidSqliteHelper.COLUMN_NAME + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.name) + "'",
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +85,7 @@ public class TranslationDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -105,7 +107,7 @@ public class TranslationDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -127,7 +129,7 @@ public class TranslationDataSource
|
|||||||
{
|
{
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -147,9 +149,9 @@ public class TranslationDataSource
|
|||||||
|
|
||||||
public TranslationRecordData GetTranslationRecordData(String name)
|
public TranslationRecordData GetTranslationRecordData(String name)
|
||||||
{
|
{
|
||||||
TranslationRecordData result = null;
|
TranslationRecordData result = TranslationManager.CreateEmptyTranslation();
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -172,7 +174,7 @@ public class TranslationDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
+ "=?", new String[] { name }, null, null, null, null);
|
+ "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -193,12 +195,12 @@ public class TranslationDataSource
|
|||||||
public TranslationRecordData innerGetTranslationByName(String name, SQLiteDatabase database)
|
public TranslationRecordData innerGetTranslationByName(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
TranslationRecordData result = null;
|
TranslationRecordData result = TranslationManager.CreateEmptyTranslation();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME,
|
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, 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_TEXT_EN_UP, BashgidSqliteHelper.COLUMN_TEXT_RU_UP, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP },
|
||||||
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(name) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -222,7 +224,7 @@ public class TranslationDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
|
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);
|
BashgidSqliteHelper.COLUMN_TEXT_RU_UP + " LIKE ?", new String[] { "%" + DatabaseDownloadTask.sqlEscapeString(partString) + "%" }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -248,7 +250,7 @@ public class TranslationDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
|
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);
|
BashgidSqliteHelper.COLUMN_TEXT_EN_UP + " LIKE ?", new String[] { "%" + DatabaseDownloadTask.sqlEscapeString(partString) + "%" }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
@ -274,7 +276,7 @@ public class TranslationDataSource
|
|||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME },
|
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);
|
BashgidSqliteHelper.COLUMN_TEXT_ZH_UP + " LIKE ?", new String[] { "%" + DatabaseDownloadTask.sqlEscapeString(partString) + "%" }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fishrungames.bashgid.core.db;
|
package fishrungames.bashgid.core.db;
|
||||||
|
|
||||||
import fishrungames.bashgid.MainActivity;
|
import fishrungames.bashgid.MainActivity;
|
||||||
|
import fishrungames.bashgid.core.DatabaseDownloadTask;
|
||||||
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@ -43,7 +44,7 @@ public class VideoDataSource
|
|||||||
database.insert(BashgidSqliteHelper.TABLE_VIDEO, null, values);
|
database.insert(BashgidSqliteHelper.TABLE_VIDEO, null, values);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
database.update(BashgidSqliteHelper.TABLE_VIDEO, values, BashgidSqliteHelper.COLUMN_VIDEO_URL + " = " + "\"" + recordData.videoUrl + "\"",
|
database.update(BashgidSqliteHelper.TABLE_VIDEO, values, BashgidSqliteHelper.COLUMN_VIDEO_URL + " = " + "'" + DatabaseDownloadTask.sqlEscapeString_withquotes(recordData.videoUrl) + "'",
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +58,9 @@ public class VideoDataSource
|
|||||||
|
|
||||||
public VideoRecordData GetVideoByVideoUrl(String videoUrl)
|
public VideoRecordData GetVideoByVideoUrl(String videoUrl)
|
||||||
{
|
{
|
||||||
VideoRecordData result = null;
|
VideoRecordData result = new VideoRecordData(0, "", "", "", "", "");
|
||||||
|
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getReadableDatabase();
|
||||||
|
|
||||||
if (database != null)
|
if (database != null)
|
||||||
{
|
{
|
||||||
@ -79,12 +80,12 @@ public class VideoDataSource
|
|||||||
public VideoRecordData InnerGetVideoByVideoUrl(String videoUrl, SQLiteDatabase database)
|
public VideoRecordData InnerGetVideoByVideoUrl(String videoUrl, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
|
|
||||||
VideoRecordData result = null;
|
VideoRecordData result = new VideoRecordData(0, "", "", "", "", "");
|
||||||
|
|
||||||
Cursor cursor = database
|
Cursor cursor = database
|
||||||
.query(BashgidSqliteHelper.TABLE_VIDEO, new String[] { BashgidSqliteHelper.COLUMN_TYPE, BashgidSqliteHelper.COLUMN_VIDEO_URL,
|
.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_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_URL,
|
||||||
BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_HASH }, BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { videoUrl }, null, null,
|
BashgidSqliteHelper.COLUMN_PREVIEW_IMAGE_HASH }, BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(videoUrl) }, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
@ -112,7 +113,7 @@ public class VideoDataSource
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL },
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_VIDEO, new String[] { BashgidSqliteHelper.COLUMN_VIDEO_URL },
|
||||||
BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { videoUrl }, null, null, null, null);
|
BashgidSqliteHelper.COLUMN_VIDEO_URL + "=?", new String[] { DatabaseDownloadTask.sqlEscapeString(videoUrl) }, null, null, null, null);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
{
|
{
|
||||||
|