Wow almost ready

This commit is contained in:
Vladislav Khorev 2015-07-02 08:36:51 +00:00
parent 4e80964196
commit 760ddd06ee
57 changed files with 1409 additions and 308 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -10,8 +10,13 @@
<Button
android:id="@+id/button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Перейти на сайт..." />
android:layout_margin="8dp"
android:background="@color/bkg2"
android:drawableLeft="@drawable/ic_action_web_site"
android:text="@string/go_to_website"
android:textSize="30sp" />
</LinearLayout>

View File

@ -8,6 +8,25 @@
android:orientation="vertical"
android:showDividers="middle" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/address_form"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/addressTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@color/bkg2"
android:textSize="24sp" />
<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<Button
android:id="@+id/button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@color/bkg2"
android:drawableLeft="@drawable/ic_action_call"
android:gravity="left|center_vertical"
android:textSize="30sp" />
</LinearLayout>

View File

@ -11,7 +11,7 @@
tools:context="fishrungames.bashgid.MapHolderFragment" >
<TextView
android:id="@+id/textView"
android:id="@+id/addressTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@ -20,6 +20,11 @@
android:text="TextView"
android:textSize="24dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<org.osmdroid.views.MapView
android:id="@+id/mapview"

View File

@ -13,7 +13,7 @@
<ImageView
android:id="@+id/logo_view"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_height="250dp"
android:layout_marginTop="22dp"
android:contentDescription="@string/RB_Coat"
android:scaleType="fitCenter"
@ -22,7 +22,9 @@
<LinearLayout
android:id="@+id/flag_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom" >
<ImageButton
android:id="@+id/image_flag_usa"

View File

@ -16,23 +16,33 @@
<TextView
android:id="@+id/dateTextView"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingLeft="16dp"
android:textSize="16sp"
android:textSize="32sp"
android:textStyle="bold" />
<Button
android:id="@+id/button"
android:layout_width="152dp"
android:layout_height="24dp"
android:layout_margin="8dp"
android:background="@drawable/see_more_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/transparent"
android:gravity="right|center_vertical"
android:paddingRight="28dp"
android:textSize="16sp" />
android:textSize="20sp" />
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/transparent"
android:src="@drawable/see_more_small" />
</LinearLayout>
@ -40,7 +50,9 @@
android:id="@+id/descriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
android:layout_margin="14dp"
android:text=""
android:textSize="18sp" />
<it.sephiroth.android.library.widget.HListView
android:id="@+id/hListView"

View File

@ -121,9 +121,11 @@
<Button
android:id="@+id/moreNewsButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/transparent"
android:text="@string/other_news" />
</LinearLayout>

View File

@ -26,7 +26,7 @@
android:textSize="20sp" />
<EditText
android:id="@+id/editText"
android:id="@+id/searchEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
@ -37,9 +37,11 @@
<Button
android:id="@+id/searchButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/ic_action_search"
android:text="@string/search_title" />
</LinearLayout>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/light_grey_1"
android:orientation="vertical"
android:showDividers="middle" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp" />
<TextView
android:id="@+id/addressTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@color/bkg2"
android:text="TextView"
android:textSize="18sp" />
<Button
android:id="@+id/button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@color/bkg2"
android:drawableLeft="@drawable/ic_action_call"
android:gravity="left|center_vertical"
android:text="Button"
android:textSize="30sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -9,7 +9,7 @@
tools:context="fishrungames.bashgid.SearchFragment" >
<TextView
android:id="@+id/textView"
android:id="@+id/addressTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@ -27,5 +27,10 @@
<requestFocus />
</EditText>
<TextView
android:id="@+id/hintTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

View File

@ -24,7 +24,7 @@
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:text="TextView"
android:textSize="16sp"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
@ -32,6 +32,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="TextView" />
android:text="TextView"
android:textSize="18sp" />
</LinearLayout>

View File

@ -4,7 +4,7 @@
<item android:id="@+id/action_search"
android:title="@string/search_title"
android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
app:showAsAction="always"
android:showAsAction="always|withText"
android:actionViewClass="android.widget.SearchView" />
</menu>

View File

@ -63,5 +63,16 @@
<string name="dialog_open">Открыть</string>
<string name="dialog_cancel">Отмена</string>
<string name="search_everywhere">Искать везде</string>
<string name="search_in">Искать в: %%</string>
<string name="address_form">Адрес:</string>
<string name="copied_text">Скопированный текст</string>
<string name="text_is_copied">Адрес скопирован в буфер обмена.</string>
<string name="search_result_count">Найдено результатов поиска: %%</string>
<string name="search_is_performing">Идет поиск, пожалуйста, подождите...</string>
<string name="search_at_least_3_symbols">Чтобы начать поиск, введите как минимум 3 символа</string>
</resources>

View File

@ -20,7 +20,7 @@
<string name="news_header">头条新闻</string>
<string name="news_load_more">Load more</string>
<string name="news_load_more">加载更多</string>
<string name="news_content_description">新闻内容描述</string>
@ -47,13 +47,25 @@
<string name="price">Price: </string>
<string name="rub">RUB</string>
<string name="journal_open_map">Show on map</string>
<string name="map_is_loading">Map is loading...</string>
<string name="map_is_loaded">Map is loaded</string>
<string name="news_are_loading">News are loading...</string>
<string name="dialog_open">Open</string>
<string name="dialog_cancel">Cancel</string>
<string name="journal_open_map">在地图上显示</string>
<string name="map_is_loading">地图正在加载...</string>
<string name="map_is_loaded">地图加载完毕</string>
<string name="news_are_loading">新闻正在加载</string>
<string name="dialog_open">打开</string>
<string name="dialog_cancel">取消</string>
<string name="search_everywhere">全面搜索</string>
<string name="search_in">在%%搜索: </string>
<string name="address_form">地址:</string>
<string name="copied_text">复制文本</string>
<string name="text_is_copied">地址已被复制到剪贴板</string>
<string name="search_result_count">搜索结果: %% 文章被找到</string>
<string name="search_is_performing">正在搜索,请稍等…</string>
<string name="search_at_least_3_symbols">输入关键字符,开始搜索</string>
</resources>

View File

@ -63,6 +63,18 @@
<string name="dialog_open">Open</string>
<string name="dialog_cancel">Cancel</string>
<string name="search_everywhere">Search everywhere</string>
<string name="search_in">Search in: %%</string>
<string name="address_form">Address:</string>
<string name="copied_text">Copied text</string>
<string name="text_is_copied">Address is copied to clipboard.</string>
<string name="search_result_count">Search result: %% articles found</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>
</resources>

View File

@ -110,7 +110,7 @@ public class AlbumListFragment extends Fragment
protected Long doInBackground(String... queryArr)
{
albumArr = MainActivity.getInstance().albumDataSource.GetAllAlbumShortData();
albumArr = MainActivity.getInstance().albumDataSource.GetAllAlbumShortDataExceptHidden();
return (long) 0;
}

View File

@ -38,15 +38,18 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@ -55,7 +58,7 @@ public class ArticleFragment extends Fragment
public static class ArticleLayoutElement
{
public int type; //0 title; 1 text; 2 photo; 3 geotag; 4 photo_album; 5 button
public int type; //0 title; 1 text; 2 photo; 3 geotag; 4 photo_album; 5 button 6 phone
public String value;
@ -194,6 +197,12 @@ public class ArticleFragment extends Fragment
articleLayout.add(new ArticleLayoutElement(1, article.content));
if (article.phone.length() > 0)
{
articleLayout.add(new ArticleLayoutElement(6, article.phone));
}
if (article.geoLat != 0 && article.geoLon != 0)
{
articleLayout.add(new ArticleLayoutElement(article.geoLat, article.geoLon));
@ -271,7 +280,7 @@ public class ArticleFragment extends Fragment
@Override
public int getViewTypeCount()
{
return 6;
return 7;
}
@Override
@ -309,15 +318,20 @@ public class ArticleFragment extends Fragment
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.article_album_element, null);
}
else //if (getItemViewType(position) == 5)
else if (getItemViewType(position) == 5)
{
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.article_button_element, null);
}
else //if (getItemViewType(position) == 6)
{
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.article_phone_element, null);
}
} else {
view = convertView;
}
if (getItemViewType(position) == 0)
{
@ -325,7 +339,7 @@ public class ArticleFragment extends Fragment
textView.setText(articleLayout.get(position).value);
textView.setTextSize(24);
textView.setTextSize(64);
textView.setTypeface(null, Typeface.BOLD);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
@ -336,7 +350,7 @@ public class ArticleFragment extends Fragment
textView.setText(articleLayout.get(position).value);
textView.setTextSize(12);
textView.setTextSize(24);
textView.setTypeface(null, Typeface.NORMAL);
textView.setGravity(Gravity.LEFT);
@ -357,7 +371,49 @@ public class ArticleFragment extends Fragment
double geoLat = articleLayout.get(position).geoLat;
double geoLon = articleLayout.get(position).geoLon;
TextView addressTextView = (TextView) view.findViewById(R.id.addressTextView);
if (article.address.length() > 0)
{
addressTextView.setText(article.address);
addressTextView.setVisibility(View.VISIBLE);
final String copied_text = getResources().getString(R.string.copied_text);
addressTextView.setOnLongClickListener(new OnLongClickListener(){
@Override
public boolean onLongClick(View v)
{
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) MainActivity.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(article.address);
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) MainActivity.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText(copied_text, article.address);
clipboard.setPrimaryClip(clip);
}
CharSequence text = getResources().getString(R.string.text_is_copied);
Toast toast = Toast.makeText(MainActivity.getInstance(), text, Toast.LENGTH_SHORT);
toast.show();
return true;
}
});
//editText.setKeyListener(null);
}
else
{
addressTextView.setVisibility(View.GONE);
}
MapView mapView = (MapView) view.findViewById(R.id.mapview);
mapView.setMaxZoomLevel(20);
mapView.setMinZoomLevel(4);
@ -422,6 +478,15 @@ public class ArticleFragment extends Fragment
else if (getItemViewType(position) == 5)
{
Button button = (Button) view.findViewById(R.id.button);
if (article.externalLinkText.length() > 0)
{
button.setText(article.externalLinkText);
}
else
{
button.setText(R.string.go_to_website);
}
button.setOnClickListener(new OnClickListener()
{
@ -434,6 +499,27 @@ public class ArticleFragment extends Fragment
}
});
}
else if (getItemViewType(position) == 6)
{
Button button = (Button) view.findViewById(R.id.button);
final String phone = article.phone;
button.setText(phone);
button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String uri = "tel:" + phone;
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(uri));
MainActivity.getInstance().startActivity(intent);
}
});
}

View File

@ -3,9 +3,6 @@ package fishrungames.bashgid;
import java.util.ArrayList;
import it.sephiroth.android.library.widget.HListView;
import fishrungames.bashgid.AlbumListFragment.DatabaseGetAlbumListTask;
import fishrungames.bashgid.MainPageFragment.ListAdapter;
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import android.annotation.SuppressLint;
@ -21,6 +18,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -142,6 +140,7 @@ public class CatalogFragment extends Fragment
TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
Button button = (Button) view.findViewById(R.id.button);
ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
HListView hListView = (HListView) view.findViewById(R.id.hListView);
@ -164,6 +163,15 @@ public class CatalogFragment extends Fragment
});
imageButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_FROM_CATALOGFRAGMENT_TO_JOURNALFRAGMENT);
}
});
return view;
}

View File

@ -20,6 +20,7 @@ import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;
import fishrungames.bashgid.core.DatabaseDownloadTask;
import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import fishrungames.bashgid.core.NewsDownloadTask;
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
@ -43,6 +44,7 @@ import fishrungames.networkutils.ImageManager;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
@ -54,6 +56,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.support.v4.widget.DrawerLayout;
@ -114,6 +117,10 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
public static final int DATABASE_SEARCH_ARTICLE_STATE_UPDATE = 28;
public static final int DATABASE_SEARCH_ARTICLE_STATE_FINISHED = 29;
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_UPDATE = 30;
public static final int DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED = 31;
@ -253,7 +260,10 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
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);
@ -421,6 +431,9 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
searchFragment = null;
catalogFragment = null;
InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
}
public void StartDownloadImagesTask(ArrayList<String> imageUrlArr, ArrayList<String> imageHashArr)
@ -578,6 +591,17 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
}
public void UpdateOnGeoJournalListLoaded(ArrayList<JournalRecordData> journalList)
{
if (mapHolderFragment != null)
{
mapHolderFragment.SetGeoJournals(journalList);
}
}
public void UpdateOnArticleSearchPerformed(ArrayList<ArticleShortData> articleArr)
{
@ -736,6 +760,17 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
mNavigationDrawerFragment.EnableDrawer();
}
public void OpenSearchScreen(String query)
{
ClearAllFragmentLinks();
searchFragment = new SearchFragment(query);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, searchFragment, TAG_TO_MAINFRAGMENT).commit();
mNavigationDrawerFragment.EnableDrawer();
}
public void OpenSearchScreen(String journalName, String journalTitle)
{
ClearAllFragmentLinks();
@ -1038,7 +1073,8 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
}
else if (position == 7)
{
OpenBooksScreen();
//OpenBooksScreen();
OpenJournalScreen("books", MainActivity.TAG_TO_MAINFRAGMENT);
}
else if (position == 8)
{

View File

@ -22,6 +22,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
@ -37,6 +38,7 @@ public class MainPageFragment extends Fragment {
ListAdapter listAdapter;
View header;
ProgressBar progressBar;
EditText searchEditText;
JournalSemiFullData newsJournal;
@ -87,6 +89,8 @@ public class MainPageFragment extends Fragment {
}
);
searchEditText = (EditText) header.findViewById(R.id.searchEditText);
Button searchButton = (Button) header.findViewById(R.id.searchButton);
searchButton.setOnClickListener(new OnClickListener()
@ -95,7 +99,8 @@ public class MainPageFragment extends Fragment {
@Override
public void onClick(View v)
{
MainActivity.getInstance().OpenSearchScreen();
String query = searchEditText.getText().toString();
MainActivity.getInstance().OpenSearchScreen(query);
}
}
);
@ -294,6 +299,9 @@ public class MainPageFragment extends Fragment {
Button button = (Button) view.findViewById(R.id.button);
ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton);
HListView hListView = (HListView) view.findViewById(R.id.hListView);
hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
@ -317,6 +325,21 @@ public class MainPageFragment extends Fragment {
MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_TO_MAINFRAGMENT);
}
});
imageButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
}
MainActivity.getInstance().OpenJournalScreen(journalList.get(position).name, MainActivity.TAG_TO_MAINFRAGMENT);
}
});
return view;
}
@ -336,7 +359,11 @@ public class MainPageFragment extends Fragment {
@Override
public void onClick(View v)
{
databaseGetJournalTask.cancel(false);
if (databaseGetJournalTask != null)
{
databaseGetJournalTask.cancel(false);
databaseGetJournalTask = null;
}
MainActivity.getInstance().OpenNewsRecordScreen(articleName, MainActivity.TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT);
}

View File

@ -1,25 +1,34 @@
package fishrungames.bashgid;
import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IGeoPoint;
import org.osmdroid.api.IMapController;
import org.osmdroid.api.IMapView;
import org.osmdroid.util.GeoPoint;
@ -33,7 +42,9 @@ import org.osmdroid.views.overlay.OverlayItem.HotspotPlace;
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
import fishrungames.bashgid.core.DatabaseGetArticleTask;
import fishrungames.bashgid.core.DatabaseGetGeoJournalListTask;
import fishrungames.bashgid.core.DatabaseGetJournalTask;
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
import fishrungames.bashgid.core.LocationHolder;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
import fishrungames.networkutils.ImageManager;
@ -41,31 +52,55 @@ import fishrungames.networkutils.ImageManager;
public class OsmMapHolderFragment extends Fragment
{
public static class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem>{
public static class DetailsOverlayItem extends OverlayItem
{
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
public String address;
public String phone;
public DetailsOverlayItem(String aTitle, String aSnippet, IGeoPoint aGeoPoint, String address, String phone)
{
super(aTitle, aSnippet, aGeoPoint);
this.address = address;
this.phone = phone;
}
}
public static class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem>
{
private ArrayList<DetailsOverlayItem> mOverlayItems = new ArrayList<DetailsOverlayItem>();
private ArrayList<String> mArticles = new ArrayList<String>();
String journalName;
Context context;
public CustomItemizedOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy, String journalName) {
public CustomItemizedOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy, String journalName, Context context)
{
super(pDefaultMarker, pResourceProxy);
this.journalName = journalName;
this.context = context;
}
@Override
protected OverlayItem createItem(int pos) {
protected OverlayItem createItem(int pos)
{
return mOverlayItems.get(pos);
}
@Override
public int size() {
if(mOverlayItems!=null) return mOverlayItems.size();
else return 0;
public int size()
{
if (mOverlayItems != null)
return mOverlayItems.size();
else
return 0;
}
public void addOverlayItem(GeoPoint geoPoint, String articleName, String title, String imageUrl){
public void addOverlayItem(GeoPoint geoPoint, String articleName, String title, String imageUrl, String address, String phone)
{
OverlayItem item = new OverlayItem(title, imageUrl, geoPoint);
DetailsOverlayItem item = new DetailsOverlayItem(title, imageUrl, geoPoint, address, phone);
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
item.setMarkerHotspot(HotspotPlace.CENTER);
@ -75,7 +110,8 @@ public class OsmMapHolderFragment extends Fragment
populateNow();
}
public void populateNow(){
public void populateNow()
{
populate();
}
@ -87,64 +123,141 @@ public class OsmMapHolderFragment extends Fragment
}
@Override
protected boolean onTap(final int index) {
OverlayItem item = mOverlayItems.get(index);
protected boolean onTap(final int index)
{
DetailsOverlayItem item = mOverlayItems.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.getInstance());
dialog.setTitle(item.getTitle());
//dialog.setMessage(item.getSnippet());
// dialog.setMessage(item.getSnippet());
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogInnerView = inflater.inflate(R.layout.osm_dialog, null, false);
ImageView image = (ImageView) dialogInnerView.findViewById(R.id.imageView);
TextView textView = (TextView) dialogInnerView.findViewById(R.id.addressTextView);
Button button = (Button) dialogInnerView.findViewById(R.id.button);
ImageView image = new ImageView(MainActivity.getInstance());
ImageManager.getInstance().ApplyImageToImageView(image, item.getSnippet());
//image.setImageResource(R.drawable.YOUR_IMAGE_ID);
dialog.setView(image);
if (item.address.length() > 0)
{
final String address = item.address;
textView.setText(address);
textView.setVisibility(View.VISIBLE);
dialog.setPositiveButton(R.string.dialog_open, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String copied_text = MainActivity.getInstance().getResources().getString(R.string.copied_text);
textView.setOnLongClickListener(new OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
{
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) MainActivity.getInstance().getSystemService(
Context.CLIPBOARD_SERVICE);
clipboard.setText(address);
} else
{
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) MainActivity.getInstance().getSystemService(
Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText(copied_text, address);
clipboard.setPrimaryClip(clip);
}
CharSequence text = MainActivity.getInstance().getResources().getString(R.string.text_is_copied);
Toast toast = Toast.makeText(MainActivity.getInstance(), text, Toast.LENGTH_SHORT);
toast.show();
return true;
}
});
} else
{
textView.setVisibility(View.GONE);
}
if (item.phone.length() > 0)
{
final String phone = item.phone;
button.setText(phone);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String uri = "tel:" + phone;
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(uri));
MainActivity.getInstance().startActivity(intent);
}
});
} else
{
button.setVisibility(View.GONE);
}
dialog.setView(dialogInnerView);
dialog.setPositiveButton(R.string.dialog_open, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
MainActivity.getInstance().SetLastMapFilterName(journalName);
MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT);
}
});
dialog.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
dialog.show();
return true;
}
}
public static class NoInteractionOverlay extends ItemizedOverlay<OverlayItem>{
public static class NoInteractionOverlay extends ItemizedOverlay<OverlayItem>
{
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
public NoInteractionOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy) {
public NoInteractionOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy)
{
super(pDefaultMarker, pResourceProxy);
}
@Override
protected OverlayItem createItem(int pos) {
protected OverlayItem createItem(int pos)
{
return mOverlayItems.get(pos);
}
@Override
public int size() {
if(mOverlayItems!=null) return mOverlayItems.size();
else return 0;
public int size()
{
if (mOverlayItems != null)
return mOverlayItems.size();
else
return 0;
}
public void addOverlayItem(GeoPoint geoPoint){
public void addOverlayItem(GeoPoint geoPoint)
{
OverlayItem item = new OverlayItem("", "", geoPoint);
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
@ -155,7 +268,8 @@ public class OsmMapHolderFragment extends Fragment
populateNow();
}
public void populateNow(){
public void populateNow()
{
populate();
}
@ -171,11 +285,17 @@ public class OsmMapHolderFragment extends Fragment
String filter;
ArrayList<JournalRecordData> availableGeoJournals;
ArrayList<String> availableGeoJournalNames;
ArrayAdapter<String> spinnerAdapter;
JournalSemiFullData journal;
ArticleFullData article;
int filterType;
Spinner spinner;
public OsmMapHolderFragment()
{
@ -183,8 +303,10 @@ public class OsmMapHolderFragment extends Fragment
article = null;
filter = "";
filterType = 0;
}
availableGeoJournals = new ArrayList<JournalRecordData>();
availableGeoJournalNames = new ArrayList<String>();
}
public OsmMapHolderFragment(int filterType, String filter)
{
@ -192,54 +314,51 @@ public class OsmMapHolderFragment extends Fragment
this.article = null;
this.filter = filter;
this.filterType = filterType;
RestoreJournalOrArticle();
availableGeoJournals = new ArrayList<JournalRecordData>();
availableGeoJournalNames = new ArrayList<String>();
}
public OsmMapHolderFragment(ArticleFullData article)
{
this.filter = article.name;
this.filterType = 1;
this.article = article;
this.journal = null;
availableGeoJournals = new ArrayList<JournalRecordData>();
availableGeoJournalNames = new ArrayList<String>();
}
@Override
public void onSaveInstanceState(final Bundle outState) {
public void onSaveInstanceState(final Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putString("filter", filter);
outState.putInt("filterType", filterType);
}
MapView mapView;
TextView textView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if (savedInstanceState != null) {
if (savedInstanceState != null)
{
filter = savedInstanceState.getString("filter");
filterType = savedInstanceState.getInt("filterType");
RestoreJournalOrArticle();
}
View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false);
textView = (TextView) rootView.findViewById(R.id.textView);
textView = (TextView) rootView.findViewById(R.id.addressTextView);
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
{
textView.setText(R.string.map_is_loading);
}
else
{
textView.setText(R.string.map_is_loaded);
}
mapView = (MapView) rootView.findViewById(R.id.mapview);
@ -249,37 +368,82 @@ public class OsmMapHolderFragment extends Fragment
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
IMapController mapController = mapView.getController();
IMapController mapController = mapView.getController();
GeoPoint center = new GeoPoint(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
mapController.setZoom(10);
mapController.animateTo(center);
RefreshView();
spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, availableGeoJournalNames);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner = (Spinner) rootView.findViewById(R.id.spinner);
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
if (position < availableGeoJournals.size())
{
if (!(filterType == 0 && filter.equals(availableGeoJournals.get(position).name)))
{
filterType = 0;
filter = availableGeoJournals.get(position).name;
textView.setText(R.string.map_is_loading);
RestoreJournalOrArticle();
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
{
textView.setText(R.string.map_is_loading);
RestoreJournalOrArticle();
} else
{
textView.setText(R.string.map_is_loaded);
RestoreGeoJournals();
}
return rootView;
}
void RestoreJournalOrArticle()
{
if (filterType == 0)
{
RestoreJournal();
}
else
} else
{
RestoreArticle();
}
}
void RestoreJournal()
{
//journal = JournalManager.CreateEmptyJournal();
// journal = JournalManager.CreateEmptyJournal();
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
@ -291,8 +455,12 @@ public class OsmMapHolderFragment extends Fragment
task.execute(bundle);
availableGeoJournals.clear();
availableGeoJournalNames.clear();
spinnerAdapter.notifyDataSetChanged();
}
void RestoreArticle()
{
@ -302,71 +470,123 @@ public class OsmMapHolderFragment extends Fragment
task.execute(filter);
availableGeoJournals.clear();
availableGeoJournalNames.clear();
spinnerAdapter.notifyDataSetChanged();
}
void RestoreGeoJournals()
{
DatabaseGetGeoJournalListTask task = new DatabaseGetGeoJournalListTask();
task.mHandler = MainActivity.getInstance().mHandler;
task.execute();
}
public void SetJournal(JournalSemiFullData journal)
{
filterType = 0;
textView.setText(R.string.map_is_loaded);
this.journal = journal;
RefreshView();
RestoreGeoJournals();
}
public void SetArticle(ArticleFullData article)
{
filterType = 1;
textView.setText(R.string.map_is_loaded);
this.article = article;
RefreshView();
RestoreGeoJournals();
}
public void SetGeoJournals(ArrayList<JournalRecordData> availableGeoJournals)
{
this.availableGeoJournals = availableGeoJournals;
availableGeoJournalNames.clear();
int selection = -1;
for (JournalRecordData journal : availableGeoJournals)
{
if (filterType == 0 && filter.equals(journal.name))
{
selection = availableGeoJournalNames.size();
}
availableGeoJournalNames.add(journal.title);
}
if (filterType == 1)
{
selection = availableGeoJournalNames.size();
availableGeoJournalNames.add(article.title);
}
spinnerAdapter.notifyDataSetChanged();
if (selection != -1)
{
spinner.setSelection(selection);
}
}
public void RefreshView()
{
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
itemizedOverlay = new CustomItemizedOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy, filter);
if (filterType == 0)
{
if (journal != null)
{
for (int i = 0; i < journal.articleArr.size(); i++)
{
ArticleRecordData article = journal.articleArr.get(i);
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
if (article.geoLat != 0 || article.geoLon != 0)
itemizedOverlay = new CustomItemizedOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy, filter, getActivity());
if (filterType == 0)
{
if (journal != null)
{
for (int i = 0; i < journal.articleArr.size(); i++)
{
GeoPoint markerPoint = new GeoPoint(article.geoLat, article.geoLon);
ArticleRecordData article = journal.articleArr.get(i);
itemizedOverlay.addOverlayItem(markerPoint, article.name, article.title, journal.articleArr.get(i).previewImageUrl);
if (article.geoLat != 0 || article.geoLon != 0)
{
GeoPoint markerPoint = new GeoPoint(article.geoLat, article.geoLon);
itemizedOverlay.addOverlayItem(markerPoint, article.name, article.title, journal.articleArr.get(i).previewImageUrl, article.address,
article.phone);
}
}
}
}
}
else
} else
{
if (article != null)
{
if (article != null)
{
if (article.geoLat != 0 || article.geoLon != 0)
{
GeoPoint markerPoint = new GeoPoint(article.geoLat, article.geoLon);
String imageUrl = "R.drawable.no_picture";
if (article.albumArr.size() > 0)
{
if (article.albumArr.get(0).photoRecordArr.size() > 0)
@ -374,20 +594,19 @@ public class OsmMapHolderFragment extends Fragment
imageUrl = article.albumArr.get(0).photoRecordArr.get(0).imageUrl;
}
}
itemizedOverlay.addOverlayItem(markerPoint, article.name, article.title, imageUrl);
itemizedOverlay.addOverlayItem(markerPoint, article.name, article.title, imageUrl, article.address, article.phone);
}
}
}
mapView.getOverlays().clear();
mapView.getOverlays().add(itemizedOverlay);
mapView.invalidate();
}
mapView.getOverlays().clear();
mapView.getOverlays().add(itemizedOverlay);
mapView.invalidate();
}
}

View File

@ -2,6 +2,7 @@ package fishrungames.bashgid;
import java.util.ArrayList;
import java.util.Locale;
import fishrungames.bashgid.core.ArticleManager;
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
@ -39,12 +40,15 @@ public class SearchFragment extends Fragment
ListAdapter listAdapter;
TextView hintTextView;
EditText searchEditText;
ArrayList<ArticleShortData> searchResultArr = new ArrayList<ArticleShortData>();
String journalName;
String journalTitle;
String query;
DatabaseSearchArticleTask databaseSearchArticleTask = null;
@ -52,12 +56,22 @@ public class SearchFragment extends Fragment
{
this.journalName = "";
this.journalTitle = "";
this.query = "";
}
public SearchFragment(String query)
{
this.journalName = "";
this.journalTitle = "";
this.journalTitle = "";
this.query = query;
}
public SearchFragment(String journalName, String journalTitle)
{
this.journalName = journalName;
this.journalTitle = journalTitle;
this.query = "";
}
@Override
@ -65,6 +79,7 @@ public class SearchFragment extends Fragment
super.onSaveInstanceState(outState);
outState.putString("journalName", journalName);
outState.putString("journalTitle", journalTitle);
outState.putString("query", query);
}
@SuppressLint("InflateParams") @Override
@ -73,6 +88,7 @@ public class SearchFragment extends Fragment
if (savedInstanceState != null) {
journalName = savedInstanceState.getString("journalName");
journalTitle = savedInstanceState.getString("journalTitle");
query = savedInstanceState.getString("query");
}
@ -82,26 +98,36 @@ public class SearchFragment extends Fragment
View header = inflater.inflate(R.layout.search_page_list_header, null);
TextView textView = (TextView) header.findViewById(R.id.textView);
TextView addressTextView = (TextView) header.findViewById(R.id.addressTextView);
if (journalTitle == null || journalTitle.length() == 0)
{
textView.setText("Search everywhere");
addressTextView.setText(R.string.search_everywhere);
}
else
{
textView.setText("Search in: " + journalTitle);
String search_in = this.getResources().getString(R.string.search_in);
search_in = search_in.replace("%%", journalTitle);
addressTextView.setText(search_in);
}
hintTextView = (TextView) header.findViewById(R.id.hintTextView);
searchEditText = (EditText) header.findViewById(R.id.editText);
searchEditText.setText(query);
searchEditText.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
String text = searchEditText.getText().toString();
query = searchEditText.getText().toString();
CallUpdateNews(text);
CallUpdateNews();
}
@ -115,6 +141,7 @@ public class SearchFragment extends Fragment
listView.setAdapter(listAdapter);
CallUpdateNews();
return rootView;
}
@ -124,6 +151,12 @@ public class SearchFragment extends Fragment
{
searchResultArr = articleArr;
listAdapter.notifyDataSetChanged();
String searchResultCount = getResources().getString(R.string.search_result_count);
searchResultCount = searchResultCount.replace("%%", Integer.toString(articleArr.size()));
hintTextView.setText(searchResultCount);
}
@ -165,13 +198,13 @@ public class SearchFragment extends Fragment
Button button = (Button) view.findViewById(R.id.button);
TextView textView = (TextView) view.findViewById(R.id.dateTextView);
TextView dateTextView = (TextView) view.findViewById(R.id.dateTextView);
ImageManager.getInstance().ApplyImageToImageView(imageButton, searchResultArr.get(position).previewImageUrl);
button.setText(searchResultArr.get(position).title);
textView.setText(NewsDataSource.iso8601Format.format(searchResultArr.get(position).dateTime));
dateTextView.setText(NewsDataSource.iso8601Format.format(searchResultArr.get(position).dateTime));
@ -185,9 +218,11 @@ public class SearchFragment extends Fragment
}
public void CallUpdateNews(String text)
public void CallUpdateNews()
{
if (text.length() >= 3)
if (query.length() >= 3 || Locale.getDefault() == Locale.CHINA)
{
if (databaseSearchArticleTask != null)
{
@ -198,17 +233,21 @@ public class SearchFragment extends Fragment
databaseSearchArticleTask.mHandler = MainActivity.getInstance().mHandler;
Bundle bundle = new Bundle();
bundle.putString("journalName", journalName);
bundle.putString("query", text);
databaseSearchArticleTask.execute(bundle);
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);
}
}

View File

@ -1,6 +1,5 @@
package fishrungames.bashgid;
import fishrungames.bashgid.core.AlbumManager;
import fishrungames.bashgid.core.DatabaseGetAlbumTask;
import fishrungames.bashgid.core.VideoManager;
@ -23,107 +22,107 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
public class VideoRecordFragment extends Fragment
{
String videoUrl;
VideoRecordData recordData;
TextView nameTextView;
TextView descriptionTextView;
ImageView imageView;
ProgressBar progressBar;
public VideoRecordFragment()
{
this.videoUrl = "";
this.recordData = null;
}
public VideoRecordFragment(String videoUrl)
{
this.recordData = null;
this.videoUrl = videoUrl;
RestoreVideo();
}
public VideoRecordFragment(VideoRecordData recordData)
{
this.videoUrl = recordData.videoUrl;
this.recordData = recordData;
}
@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("videoUrl", videoUrl);
}
public void onSaveInstanceState(final Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putString("videoUrl", videoUrl);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (savedInstanceState != null) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if (savedInstanceState != null)
{
videoUrl = savedInstanceState.getString("videoUrl");
RestoreVideo();
}
View rootView = inflater.inflate(R.layout.fragment_video_record_page, container, false);
progressBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
if (recordData == null)
{
progressBar.setVisibility(View.VISIBLE);
}
View rootView = inflater.inflate(R.layout.fragment_video_record_page, container, false);
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
if (recordData == null)
{
progressBar.setVisibility(View.VISIBLE);
} else
{
progressBar.setVisibility(View.GONE);
}
}
else
{
progressBar.setVisibility(View.GONE);
}
nameTextView = (TextView) rootView.findViewById(R.id.nameTextView);
descriptionTextView = (TextView) rootView.findViewById(R.id.descriptionTextView);
imageView = (ImageView) rootView.findViewById(R.id.imageView);
RefreshView();
return rootView;
}
void RestoreVideo()
{
//recordData = MainActivity.getInstance().videoDataSource.GetVideoByVideoUrl(videoUrl);
// recordData =
// MainActivity.getInstance().videoDataSource.GetVideoByVideoUrl(videoUrl);
recordData = VideoManager.CreateEmptyVideo();
DatabaseGetVideoTask task = new DatabaseGetVideoTask();
task.mHandler = MainActivity.getInstance().mHandler;
task.execute(videoUrl);
}
void SetVideo(VideoRecordData recordData)
{
progressBar.setVisibility(View.GONE);
this.recordData = recordData;
RefreshView();
}
void RefreshView()
{
nameTextView.setText(recordData.title);
descriptionTextView.setText(recordData.description);
ImageManager.getInstance().ApplyImageToImageView(imageView, recordData.previewImageUrl);
imageView.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
@ -132,24 +131,23 @@ else
MainActivity.getInstance().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoUrl)));
}
}
});
}
public static class DatabaseGetVideoTask extends AsyncTask<String, Integer, Long>
{
VideoRecordData recordData = null;
public Handler mHandler;
protected Long doInBackground(String... queryArr)
{
String videoUrl = queryArr[0];
recordData = MainActivity.getInstance().videoDataSource.GetVideoByVideoUrl(videoUrl);
return (long) 0;
}
@ -168,6 +166,5 @@ else
completeMessage.sendToTarget();
}
}
}

View File

@ -19,13 +19,15 @@ public class AlbumManager
public String name;
public String title;
public String description;
public int hidden;
public AlbumRecordData(String name, String title, String description)
public AlbumRecordData(String name, String title, String description, int hidden)
{
this.name = name;
this.title = title;
this.description = description;
this.hidden = hidden;
}
public AlbumRecordData(AlbumRecordData copyFrom)
@ -33,6 +35,7 @@ public class AlbumManager
this.name = copyFrom.name;
this.title = copyFrom.title;
this.description = copyFrom.description;
this.hidden = copyFrom.hidden;
}
}
@ -65,16 +68,16 @@ public class AlbumManager
{
public int id;
public AlbumRecord(int id, String name, String title, String description)
public AlbumRecord(int id, String name, String title, String description, int hidden)
{
super(name, title, description);
super(name, title, description, hidden);
this.id = id;
}
}
public static AlbumFullData CreateEmptyAlbum()
{
AlbumFullData result = new AlbumFullData(new AlbumRecordData("", "", ""));
AlbumFullData result = new AlbumFullData(new AlbumRecordData("", "", "", 0));
return result;
}
@ -91,7 +94,7 @@ public class AlbumManager
{
if (!MainActivity.getInstance().albumDataSource.IsAlbumAlreadyExist(albumName))
{
MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(albumName, albumName, ""));
MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(albumName, albumName, "", 0));
}
MainActivity.getInstance().albumDataSource.AddPhotoToAlbum(imageUrl, albumName);
@ -118,7 +121,7 @@ public class AlbumManager
{
if (!MainActivity.getInstance().channelDataSource.IsChannelAlreadyExist(channelName))
{
MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(channelName, channelName, ""));
MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(channelName, channelName, "", 0));
}
MainActivity.getInstance().channelDataSource.AddVideoToChannel(videoUrl, channelName);
@ -143,7 +146,7 @@ public class AlbumManager
{
if (!MainActivity.getInstance().journalDataSource.IsJournalAlreadyExist(journalName))
{
MainActivity.getInstance().journalDataSource.CreateNewJournal(new JournalRecordData(journalName, journalName, ""));
MainActivity.getInstance().journalDataSource.CreateNewJournal(new JournalRecordData(journalName, journalName, "", 0, 0, 0));
}
MainActivity.getInstance().journalDataSource.AddArticleToJournal(articleName, journalName);

View File

@ -27,10 +27,14 @@ public class ArticleManager
public String content;
public double geoLat;
public double geoLon;
public String address;
public String phone;
public String externalLink;
public String externalLinkText;
public Date dateTime;
public int hidden;
public ArticleRecordData(String name, int type, String title, String content, double geoLat, double geoLon, String externalLink, Date dateTime)
public ArticleRecordData(String name, int type, String title, String content, double geoLat, double geoLon, String address, String phone, String externalLink, String externalLinkText, Date dateTime, int hidden)
{
this.name = name;
this.type = type;
@ -38,8 +42,12 @@ public class ArticleManager
this.content = content;
this.geoLat = geoLat;
this.geoLon = geoLon;
this.address = address;
this.phone = phone;
this.externalLink = externalLink;
this.externalLinkText = externalLinkText;
this.dateTime = dateTime;
this.hidden = hidden;
}
public ArticleRecordData(ArticleRecordData copyFrom)
@ -50,8 +58,12 @@ public class ArticleManager
this.content = copyFrom.content;
this.geoLat = copyFrom.geoLat;
this.geoLon = copyFrom.geoLon;
this.address = copyFrom.address;
this.phone = copyFrom.phone;
this.externalLink = copyFrom.externalLink;
this.externalLinkText = copyFrom.externalLinkText;
this.dateTime = copyFrom.dateTime;
this.hidden = copyFrom.hidden;
}
}

View File

@ -17,13 +17,15 @@ public class ChannelManager
public String name;
public String title;
public String description;
public int hidden;
public ChannelRecordData(String name, String title, String description)
public ChannelRecordData(String name, String title, String description, int hidden)
{
this.name = name;
this.title = title;
this.description = description;
this.hidden = hidden;
}
public ChannelRecordData(ChannelRecordData copyFrom)
@ -31,6 +33,7 @@ public class ChannelManager
this.name = copyFrom.name;
this.title = copyFrom.title;
this.description = copyFrom.description;
this.hidden = copyFrom.hidden;
}
}
@ -50,16 +53,16 @@ public class ChannelManager
{
public int id;
public ChannelRecord(int id, String name, String title, String description)
public ChannelRecord(int id, String name, String title, String description, int hidden)
{
super(name, title, description);
super(name, title, description, hidden);
this.id = id;
}
}
public static ChannelFullData CreateEmptyChannel()
{
ChannelFullData result = new ChannelFullData(new ChannelRecordData("", "", ""));
ChannelFullData result = new ChannelFullData(new ChannelRecordData("", "", "", 0));
return result;
}

View File

@ -200,11 +200,13 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
String name = jObject.getString("name");
String title = jObject.getString("title");
String description = jObject.getString("description");
int hidden = jObject.getInt("hidden");
MainActivity.getInstance().albumDataSource.CreateNewAlbum(new AlbumRecordData(
name,
title,
description));
description,
hidden));
} // End Loop
@ -285,11 +287,13 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
String name = jObject.getString("name");
String title = jObject.getString("title");
String description = jObject.getString("description");
int hidden = jObject.getInt("hidden");
MainActivity.getInstance().channelDataSource.CreateNewChannel(new ChannelRecordData(
name,
title,
description));
description,
hidden));
} // End Loop
@ -339,9 +343,13 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
String content = jObject.getString("content");
double geoLat = jObject.getDouble("geoLat");
double geoLon = jObject.getDouble("geoLon");
String address = jObject.getString("address");
String phone = jObject.getString("phone");
String externalLink = jObject.getString("externalLink");
String externalLinkText = jObject.getString("externalLinkText");
Date dateTime = ArticleManager.iso8601Format.parse(jObject.getString("dateTime"));
int hidden = jObject.getInt("hidden");
MainActivity.getInstance().articleDataSource.CreateNewArticle(new ArticleRecordData(
name,
type,
@ -349,9 +357,12 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
content,
geoLat,
geoLon,
address,
phone,
externalLink,
dateTime
));
externalLinkText,
dateTime,
hidden));
} catch (ParseException e)
@ -379,11 +390,17 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
String name = jObject.getString("name");
String title = jObject.getString("title");
String description = jObject.getString("description");
int hidden = jObject.getInt("hidden");
int geoCategory = jObject.getInt("geoCategory");
int main = jObject.getInt("main");
MainActivity.getInstance().journalDataSource.CreateNewJournal(new JournalRecordData(
name,
title,
description));
description,
hidden,
geoCategory,
main));
} // End Loop
@ -473,8 +490,11 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
String textEn = jObject.getString("textEn");
String textRu = jObject.getString("textRu");
String textZh = jObject.getString("textZh");
String textEnUp = jObject.getString("textEnUp");
String textRuUp = jObject.getString("textRuUp");
String textZhUp = jObject.getString("textZhUp");
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh));
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh, textEnUp, textRuUp, textZhUp));
} // End Loop

View File

@ -0,0 +1,46 @@
package fishrungames.bashgid.core;
import java.util.ArrayList;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
public class DatabaseGetGeoJournalListTask extends AsyncTask<String, Integer, Long>
{
ArrayList<JournalRecordData> geoJournalList;
public Handler mHandler;
protected Long doInBackground(String... queryArr)
{
geoJournalList = MainActivity.getInstance().journalDataSource.GetGeoJournalList();
return (long) 0;
}
protected void onProgressUpdate(Integer... progress)
{
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_GEO_JOURNAL_LIST_STATE_UPDATE, geoJournalList);
completeMessage.sendToTarget();
}
protected void onPostExecute(Long result)
{
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_GEO_JOURNAL_LIST_STATE_FINISHED, geoJournalList);
completeMessage.sendToTarget();
}
}

View File

@ -11,23 +11,22 @@ import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
public class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
{
ArrayList<JournalSemiFullData> journalList;
ArrayList<JournalSemiFullData> journalList;
public Handler mHandler;
protected Long doInBackground(String... queryArr)
{
String superJournal = "";
//String superJournal = "";
if (queryArr.length > 0)
{
superJournal = queryArr[0];
journalList = MainActivity.getInstance().journalDataSource.GetJournalList(superJournal, 3); //Xperimental -- need to pass exactly how many articles
journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3); //Xperimental -- need to pass exactly how many articles
}
else
{
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalList(3); //Xperimental -- need to pass exactly how many articles
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalListExceptHidden(3); //Xperimental -- need to pass exactly how many articles
}
@ -48,4 +47,5 @@ public class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
completeMessage.sendToTarget();
}
}

View File

@ -2,6 +2,10 @@ package fishrungames.bashgid.core;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import android.os.AsyncTask;
import android.os.Bundle;
@ -18,6 +22,8 @@ public class DatabaseSearchArticleTask extends AsyncTask<Bundle, Integer, Long>
public Handler mHandler;
ArrayList<ArticleShortData> articleArr = new ArrayList<ArticleShortData>();
ArrayList<String> translationNamesArr = new ArrayList<String>();
protected Long doInBackground(Bundle... queryArr)
{
@ -25,19 +31,54 @@ public class DatabaseSearchArticleTask extends AsyncTask<Bundle, Integer, Long>
String journalName = queryArr[0].getString("journalName");
if (journalName != null && journalName.length() > 0)
query = query.toUpperCase(Locale.getDefault());
if (Locale.getDefault().equals(new Locale("ru")))
{
articleArr = MainActivity.getInstance().articleDataSource.SearchArticleByQueryAndJournal(query, journalName);
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchRussian(query);
}
else if (Locale.getDefault() == Locale.CHINA)
{
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchChinese(query);
}
else
{
articleArr = MainActivity.getInstance().articleDataSource.SearchArticleByQuery(query);
translationNamesArr = MainActivity.getInstance().translationDataSource.SearchEnglish(query);
}
//articleArr.addAll(journal.articleArr);
if (journalName != null && journalName.length() > 0)
{
for (String translationName : translationNamesArr)
{
articleArr.addAll(MainActivity.getInstance().articleDataSource.SearchArticleByTitleOrTextInJournal(translationName, journalName));
}
}
else
{
for (String translationName : translationNamesArr)
{
articleArr.addAll(MainActivity.getInstance().articleDataSource.SearchArticleByTitleOrText(translationName));
}
}
//Remove duplicates
Set<ArticleShortData> articleSet = new TreeSet<ArticleShortData>(new Comparator<ArticleShortData>() {
@Override
public int compare(ArticleShortData lhs, ArticleShortData rhs)
{
return lhs.name.compareTo(rhs.name);
}
});
articleSet.addAll(articleArr);
articleArr.clear();
articleArr.addAll(articleSet);
return (long) 0;
}

View File

@ -19,13 +19,19 @@ public class JournalManager
public String name;
public String title;
public String description;
public int hidden;
public int geoCategory;
public int main;
public JournalRecordData(String name, String title, String description)
public JournalRecordData(String name, String title, String description, int hidden, int geoCategory, int main)
{
this.name = name;
this.title = title;
this.description = description;
this.hidden = hidden;
this.geoCategory = geoCategory;
this.main = main;
}
public JournalRecordData(JournalRecordData copyFrom)
@ -33,6 +39,9 @@ public class JournalManager
this.name = copyFrom.name;
this.title = copyFrom.title;
this.description = copyFrom.description;
this.hidden = copyFrom.hidden;
this.geoCategory = copyFrom.geoCategory;
this.main = copyFrom.main;
}
}
@ -56,9 +65,9 @@ public class JournalManager
{
public int id;
public JournalRecord(int id, String name, String title, String description)
public JournalRecord(int id, String name, String title, String description, int hidden, int geoCategory, int main)
{
super(name, title, description);
super(name, title, description, hidden, geoCategory, main);
this.id = id;
}
}
@ -66,7 +75,7 @@ public class JournalManager
public static JournalSemiFullData CreateEmptyJournal()
{
JournalSemiFullData result = new JournalSemiFullData(new JournalRecordData("", "", ""));
JournalSemiFullData result = new JournalSemiFullData(new JournalRecordData("", "", "", 0, 0, 0));
return result;
}

View File

@ -14,6 +14,7 @@ import android.util.Log;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.R;
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
@ -360,9 +361,12 @@ public class NewsManager {
rss2Item.description.replace("'", "''").replace("\"", "\"\""),
0,
0,
"",
"",
rss2Item.link,
rss2Item.pubDate
);
MainActivity.getInstance().getResources().getString(R.string.dialog_open),
rss2Item.pubDate,
0);
AlbumManager.AddNewArticleToJournal(newsArticle, "news");
//newsRecordArr.add(newsArticle);

View File

@ -15,14 +15,13 @@ import android.util.Log;
public class RssReader {
public static class Rss2Item
{
String title;
String link;
String description;
public static class Rss2Enclosure
{
String url;

View File

@ -10,14 +10,21 @@ public class TranslationManager
public String textEn;
public String textRu;
public String textZh;
public String textEnUp;
public String textRuUp;
public String textZhUp;
public TranslationRecordData(String name, String textEn, String textRu, String textZh)
public TranslationRecordData(String name, String textEn, String textRu, String textZh, String textEnUp, String textRuUp, String textZhUp)
{
this.name = name;
this.textEn = textEn;
this.textRu = textRu;
this.textZh = textZh;
this.textEnUp = textEnUp;
this.textRuUp = textRuUp;
this.textZhUp = textZhUp;
}
public TranslationRecordData(TranslationRecordData copyFrom)
@ -26,6 +33,9 @@ public class TranslationManager
this.textEn = copyFrom.textEn;
this.textRu = copyFrom.textRu;
this.textZh = copyFrom.textZh;
this.textEnUp = copyFrom.textEnUp;
this.textRuUp = copyFrom.textRuUp;
this.textZhUp = copyFrom.textZhUp;
}
}

View File

@ -40,6 +40,7 @@ public class AlbumDataSource
values.put(BashgidSqliteHelper.COLUMN_NAME, recordData.name);
values.put(BashgidSqliteHelper.COLUMN_TITLE, recordData.title);
values.put(BashgidSqliteHelper.COLUMN_DESCRIPTION, recordData.description);
values.put(BashgidSqliteHelper.COLUMN_HIDDEN, recordData.hidden);
if (!innerIsAlbumAlreadyExist(recordData.name, database))
{
@ -196,7 +197,7 @@ public class AlbumDataSource
return result;
}
public ArrayList<AlbumShortData> GetAllAlbumShortData()
public ArrayList<AlbumShortData> GetAllAlbumShortDataExceptHidden()
{
ArrayList<AlbumShortData> result = new ArrayList<AlbumShortData>();
@ -208,7 +209,7 @@ public class AlbumDataSource
try
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION }, null, null, null, null, null, null);
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_HIDDEN + "=0", null, null, null, null, null);
if (cursor != null)
{
@ -217,7 +218,7 @@ public class AlbumDataSource
do
{
AlbumShortData shortData = new AlbumShortData(new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
AlbumShortData shortData = new AlbumShortData(new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3)));
ArrayList<String> imageUrlArr = innerGetImageUrlArrInAlbum(shortData.name, database);
@ -326,13 +327,13 @@ public class AlbumDataSource
AlbumRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
BashgidSqliteHelper.COLUMN_DESCRIPTION }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
result = new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2));
result = new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3));
}
cursor.close();

View File

@ -59,8 +59,12 @@ public class ArticleDataSource
values.put(BashgidSqliteHelper.COLUMN_CONTENT, recordData.content);
values.put(BashgidSqliteHelper.COLUMN_GEOLAT, recordData.geoLat);
values.put(BashgidSqliteHelper.COLUMN_GEOLON, recordData.geoLon);
values.put(BashgidSqliteHelper.COLUMN_ADDRESS, recordData.address);
values.put(BashgidSqliteHelper.COLUMN_PHONE, recordData.phone);
values.put(BashgidSqliteHelper.COLUMN_EXTERNAL_LINK, recordData.externalLink);
values.put(BashgidSqliteHelper.COLUMN_EXTERNAL_LINK_TEXT, recordData.externalLinkText);
values.put(BashgidSqliteHelper.COLUMN_DATE_TIME, ArticleManager.iso8601Format.format(recordData.dateTime));
values.put(BashgidSqliteHelper.COLUMN_HIDDEN, recordData.hidden);
if (!innerIsArticleAlreadyExist(recordData.name, database))
{
@ -211,8 +215,12 @@ public class ArticleDataSource
result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database);
result.content = MainActivity.getInstance().translationDataSource.TryTranslateText(result.content, database);
result.address = MainActivity.getInstance().translationDataSource.TryTranslateText(result.address, database);
result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database);
result.externalLinkText = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLinkText, database);
}
@ -242,6 +250,61 @@ public class ArticleDataSource
return result;
}
public ArrayList<ArticleShortData> SearchArticleByTitleOrText(String query)
{
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
ArrayList<String> articleNameArr = InnerSearchArticleByTitleOrText(query, database);
for (String articleName : articleNameArr)
{
result.add(InnerGetArticleShortData(articleName, database));
}
} finally
{
dbHelper.close();
}
}
return result;
}
public ArrayList<ArticleShortData> SearchArticleByTitleOrTextInJournal(String query, String journalName)
{
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
ArrayList<String> articleNameArr = InnerSearchArticleByTitleOrText(query, database);
for (String articleName : articleNameArr)
{
if (MainActivity.getInstance().journalDataSource.InnerArticleJournalRelationAlreadyExist(articleName, journalName, database))
{
result.add(InnerGetArticleShortData(articleName, database));
}
}
} finally
{
dbHelper.close();
}
}
return result;
}
public ArrayList<ArticleShortData> SearchArticleByQuery(String query)
{
@ -317,6 +380,29 @@ public class ArticleDataSource
}
public boolean InnerArticleIsHidden(String name, SQLiteDatabase database)
{
boolean result = false;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] { BashgidSqliteHelper.COLUMN_NAME },
BashgidSqliteHelper.COLUMN_NAME + "=? AND " +BashgidSqliteHelper.COLUMN_HIDDEN + "=1", new String[] { name }, null, null, null, null);
if (cursor != null)
{
if (cursor.getCount() > 0)
{
result = true;
}
cursor.close();
cursor = null;
}
return result;
}
public ArticleShortData InnerGetArticleShortData(String name, SQLiteDatabase database)
{
ArticleShortData result = null;
@ -450,7 +536,19 @@ public class ArticleDataSource
ArticleRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TYPE, BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_CONTENT, BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON, BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,BashgidSqliteHelper.COLUMN_DATE_TIME },
BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TYPE,
BashgidSqliteHelper.COLUMN_TITLE,
BashgidSqliteHelper.COLUMN_CONTENT,
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)
@ -462,7 +560,7 @@ public class ArticleDataSource
try
{
d = ArticleManager.iso8601Format.parse(cursor.getString(7));
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
}
catch(ParseException e)
{
@ -477,7 +575,11 @@ public class ArticleDataSource
cursor.getDouble(4),
cursor.getDouble(5),
cursor.getString(6),
d
cursor.getString(7),
cursor.getString(8),
cursor.getString(9),
d,
cursor.getInt(11)
);
}
@ -495,7 +597,19 @@ public class ArticleDataSource
ArrayList<ArticleRecordData> result = new ArrayList<ArticleRecordData>();
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TYPE, BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_CONTENT, BashgidSqliteHelper.COLUMN_GEOLAT, BashgidSqliteHelper.COLUMN_GEOLON, BashgidSqliteHelper.COLUMN_EXTERNAL_LINK,BashgidSqliteHelper.COLUMN_DATE_TIME },
BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TYPE,
BashgidSqliteHelper.COLUMN_TITLE,
BashgidSqliteHelper.COLUMN_CONTENT,
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)
@ -510,7 +624,7 @@ public class ArticleDataSource
try
{
d = ArticleManager.iso8601Format.parse(cursor.getString(7));
d = ArticleManager.iso8601Format.parse(cursor.getString(10));
}
catch(ParseException e)
{
@ -525,7 +639,11 @@ public class ArticleDataSource
cursor.getDouble(4),
cursor.getDouble(5),
cursor.getString(6),
d
cursor.getString(7),
cursor.getString(8),
cursor.getString(9),
d,
cursor.getInt(11)
));
}
@ -540,6 +658,39 @@ public class ArticleDataSource
}
private ArrayList<String> InnerSearchArticleByTitleOrText(String query, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE, new String[] {
BashgidSqliteHelper.COLUMN_NAME
},
BashgidSqliteHelper.COLUMN_TITLE + " = ? OR " + BashgidSqliteHelper.COLUMN_CONTENT + " = ?", new String[] { query, query }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
do
{
result.add(cursor.getString(0));
}
while (cursor.moveToNext());
}
cursor.close();
cursor = null;
}
return result;
}
public ArrayList<String> innerGetAlbumNameArrInArticle(String name, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();

View File

@ -43,11 +43,14 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
public static final String COLUMN_IMAGE_HASH = "imageHash";
public static final String COLUMN_GEOLAT = "geoLat";
public static final String COLUMN_GEOLON = "geoLon";
public static final String COLUMN_ADDRESS = "address";
public static final String COLUMN_PHONE = "phone";
public static final String COLUMN_PUBDATE = "pubDate";
public static final String COLUMN_TYPE = "type";
public static final String COLUMN_CONTENT = "content";
public static final String COLUMN_EXTERNAL_LINK = "externalLink";
public static final String COLUMN_EXTERNAL_LINK_TEXT = "externalLinkText";
public static final String COLUMN_ALBUM_NAME = "albumName";
public static final String COLUMN_CHANNEL_NAME = "channelName";
@ -58,12 +61,21 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
public static final String COLUMN_PREVIEW_IMAGE_URL = "previewImageUrl";
public static final String COLUMN_PREVIEW_IMAGE_HASH = "previewImageHash";
public static final String COLUMN_HIDDEN = "hidden";
public static final String COLUMN_GEOCATEGORY = "geoCategory";
public static final String COLUMN_MAIN = "main";
public static final String COLUMN_DATE_TIME = "dateTime";
public static final String COLUMN_TEXT_EN = "textEn";
public static final String COLUMN_TEXT_RU = "textRu";
public static final String COLUMN_TEXT_ZH = "textZh";
public static final String COLUMN_TEXT_EN_UP = "textEnUp";
public static final String COLUMN_TEXT_RU_UP = "textRuUp";
public static final String COLUMN_TEXT_ZH_UP = "textZhUp";
private static final String DATABASE_NAME = "bashgid.db";
private static final int DATABASE_VERSION = 1;
@ -79,7 +91,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
+ " real not null" + ", " + COLUMN_GEOLON + " real not null" + ");";
private static final String TABLE_ALBUM_CREATE = "create table " + TABLE_ALBUM + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_NAME + " text not null"
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ");";
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_HIDDEN + " integer not null" + ");";
private static final String TABLE_PHOTO_ALBUM_RELATION_CREATE = "create table " + TABLE_PHOTO_ALBUM_RELATION + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_IMAGE_URL + " text not null"
+ ", " + COLUMN_NAME + " text not null" + ");";
@ -87,7 +99,11 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
private static final String TABLE_ARTICLE_CREATE = "create table " + TABLE_ARTICLE + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_NAME + " text not null"
+ ", " + COLUMN_TYPE + " integer not null" + ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_CONTENT + " text not null" + ", " + COLUMN_GEOLAT
+ " real not null" + ", " + COLUMN_GEOLON + " real not null" + ", " + COLUMN_EXTERNAL_LINK + " text not null" + ", " + COLUMN_DATE_TIME + " text not null" +");";
+ " real not null" + ", " + COLUMN_GEOLON + " real not null" + ", "
+ COLUMN_ADDRESS + " text not null" + ", "
+ COLUMN_PHONE + " text not null" + ", "
+ COLUMN_EXTERNAL_LINK + " text not null" + ", "
+ COLUMN_EXTERNAL_LINK_TEXT + " text not null" + ", "+ COLUMN_DATE_TIME + " text not null" + ", " + COLUMN_HIDDEN + " integer not null" +");";
private static final String TABLE_ALBUM_ARTICLE_RELATION_CREATE = "create table " + TABLE_ALBUM_ARTICLE_RELATION + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_ALBUM_NAME + " text not null"
+ ", " + COLUMN_ARTICLE_NAME + " text not null" + ");";
@ -101,19 +117,20 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper
+ ", " + COLUMN_PREVIEW_IMAGE_HASH + " text not null"+ ");";
private static final String TABLE_CHANNEL_CREATE = "create table " + TABLE_CHANNEL + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_NAME + " text not null"
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ");";
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_HIDDEN + " integer not null" + ");";
private static final String TABLE_VIDEO_CHANNEL_RELATION_CREATE = "create table " + TABLE_VIDEO_CHANNEL_RELATION + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_VIDEO_URL + " text not null"
+ ", " + COLUMN_NAME + " text not null" + ");";
private static final String TABLE_JOURNAL_CREATE = "create table " + TABLE_JOURNAL + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_NAME + " text not null"
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ");";
+ ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_HIDDEN + " integer not null" + ", " + COLUMN_GEOCATEGORY + " integer not null" + ", " + COLUMN_MAIN + " integer not null" + ");";
private static final String TABLE_ARTICLE_JOURNAL_RELATION_CREATE = "create table " + TABLE_ARTICLE_JOURNAL_RELATION + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_ARTICLE_NAME + " text not null"
+ ", " + COLUMN_JOURNAL_NAME + " text not null" + ");";
private static final String TABLE_TRANSLATION_CREATE = "create table " + TABLE_TRANSLATION + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_NAME + " text not null"
+ ", " + COLUMN_TEXT_EN + " text not null"+ ", " + COLUMN_TEXT_RU + " text not null" + ", " + COLUMN_TEXT_ZH + " text not null" + ");";
+ ", " + COLUMN_TEXT_EN + " text not null"+ ", " + COLUMN_TEXT_RU + " text not null" + ", " + COLUMN_TEXT_ZH + " text not null"
+ ", " + COLUMN_TEXT_EN_UP + " text not null"+ ", " + COLUMN_TEXT_RU_UP + " text not null" + ", " + COLUMN_TEXT_ZH_UP + " text not null" + ");";
public final Semaphore mutex = new Semaphore(1, true);

View File

@ -40,6 +40,7 @@ public class ChannelDataSource
values.put(BashgidSqliteHelper.COLUMN_NAME, recordData.name);
values.put(BashgidSqliteHelper.COLUMN_TITLE, recordData.title);
values.put(BashgidSqliteHelper.COLUMN_DESCRIPTION, recordData.description);
values.put(BashgidSqliteHelper.COLUMN_HIDDEN, recordData.hidden);
if (!innerIsChannelAlreadyExist(recordData.name, database))
{
@ -231,14 +232,15 @@ public class ChannelDataSource
ChannelRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_CHANNEL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
BashgidSqliteHelper.COLUMN_DESCRIPTION }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
result = new ChannelRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2));
result = new ChannelRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3));
}
cursor.close();

View File

@ -46,6 +46,9 @@ public class JournalDataSource
values.put(BashgidSqliteHelper.COLUMN_NAME, recordData.name);
values.put(BashgidSqliteHelper.COLUMN_TITLE, recordData.title);
values.put(BashgidSqliteHelper.COLUMN_DESCRIPTION, recordData.description);
values.put(BashgidSqliteHelper.COLUMN_HIDDEN, recordData.hidden);
values.put(BashgidSqliteHelper.COLUMN_GEOCATEGORY, recordData.geoCategory);
values.put(BashgidSqliteHelper.COLUMN_MAIN, recordData.main);
if (!innerIsJournalAlreadyExist(recordData.name, database))
{
@ -116,8 +119,8 @@ public class JournalDataSource
}
}
public ArrayList<ArticleShortData> GetRecentArticles(String journalName, int count)
/*
public ArrayList<ArticleShortData> GetRecentArticlesExceptHidden(String journalName, int count)
{
ArrayList<ArticleShortData> result = new ArrayList<ArticleShortData>();
@ -137,8 +140,11 @@ public class JournalDataSource
for (String articleName : articleNameArr)
{
if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(articleName, database))
{
result.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(articleName, database));
}
}
Collections.sort(result, new ArticleDataSource.DateSortComparator());
@ -156,7 +162,7 @@ public class JournalDataSource
}
return result;
}
}*/
public JournalSemiFullData GetJournalSemiFullData(String name)
{
@ -190,7 +196,7 @@ public class JournalDataSource
return result;
}
public ArrayList<JournalSemiFullData> GetAllJournalList(int count)
public ArrayList<JournalSemiFullData> GetAllJournalListExceptHidden(int count)
{
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
@ -201,7 +207,7 @@ public class JournalDataSource
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION }, null, null, null, null, null, null);
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_HIDDEN + "=0", null, null, null, null, null);
if (cursor != null)
{
@ -212,11 +218,11 @@ public class JournalDataSource
{
String name = cursor.getString(0);
if (!name.equals("news") && !name.equals("map"))
{
//String name = cursor.getString(0);
//if (!name.equals("news") && !name.equals("map"))
//{
JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
ArrayList<String> articleArr;
@ -230,8 +236,10 @@ public class JournalDataSource
}
for (String article : articleArr)
{
if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
{
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
}
}
journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
@ -239,7 +247,7 @@ public class JournalDataSource
result.add(journal);
}
//}
} while (cursor.moveToNext());
@ -262,7 +270,7 @@ public class JournalDataSource
}
public ArrayList<JournalSemiFullData> GetJournalList(String superJournalName, int count)
public ArrayList<JournalSemiFullData> GetJournalListMain(int count)
{
//Xperimental - need to create a real superjournal
@ -276,7 +284,8 @@ public class JournalDataSource
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION }, null, null, null, null, null, null);
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION,
BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN}, BashgidSqliteHelper.COLUMN_MAIN + "=1", null, null, null, null, null);
if (cursor != null)
{
@ -287,11 +296,11 @@ public class JournalDataSource
{
String name = cursor.getString(0);
if (name.equals("Universities") || name.equals("hotels")) //Xperimental
{
//String name = cursor.getString(0);
//if (name.equals("Universities") || name.equals("hotels")) //Xperimental
//{
JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
JournalSemiFullData journal = new JournalSemiFullData(new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5)));
ArrayList<String> articleArr;
@ -307,8 +316,10 @@ public class JournalDataSource
for (String article : articleArr)
{
if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
{
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
}
}
journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
@ -316,7 +327,7 @@ public class JournalDataSource
result.add(journal);
}
//}
} while (cursor.moveToNext());
@ -334,6 +345,54 @@ public class JournalDataSource
}
return result;
}
public ArrayList<JournalRecordData> GetGeoJournalList()
{
ArrayList<JournalRecordData> result = new ArrayList<JournalRecordData>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION,
BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN}, BashgidSqliteHelper.COLUMN_GEOCATEGORY + "=1", null, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
do
{
JournalRecordData journal = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5));
journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
//journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
result.add(journal);
} while (cursor.moveToNext());
}
cursor.close();
cursor = null;
}
}
finally
{
dbHelper.close();
}
}
return result;
}
@ -355,9 +414,11 @@ public class JournalDataSource
for (String article : articleArr)
{
//if (!MainActivity.getInstance().articleDataSource.InnerArticleIsHidden(article, database))
//{
intermediateArticleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
//
}
Collections.sort(intermediateArticleArr, new ArticleManager.ArticleShortDataTimeSortComparator());
@ -505,7 +566,7 @@ public class JournalDataSource
JournalRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_JOURNAL, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TITLE,
BashgidSqliteHelper.COLUMN_DESCRIPTION }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
BashgidSqliteHelper.COLUMN_DESCRIPTION, BashgidSqliteHelper.COLUMN_HIDDEN, BashgidSqliteHelper.COLUMN_GEOCATEGORY, BashgidSqliteHelper.COLUMN_MAIN }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
@ -513,7 +574,7 @@ public class JournalDataSource
{
cursor.moveToFirst();
result = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2));
result = new JournalRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5));
}
cursor.close();
cursor = null;

View File

@ -49,7 +49,7 @@ public class PhotoDataSource
database.update(BashgidSqliteHelper.TABLE_PHOTO, values, BashgidSqliteHelper.COLUMN_IMAGE_URL + " = " +"\"" + recordData.imageUrl +"\"", null);
}
Log.e("a", "aaa4");
//Log.e("a", "aaa4");
} finally
{
dbHelper.close();

View File

@ -3,11 +3,7 @@ package fishrungames.bashgid.core.db;
import java.util.ArrayList;
import java.util.Locale;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.AlbumManager;
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.AlbumManager.AlbumRecordData;
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
import android.content.ContentValues;
@ -15,7 +11,7 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public class TranslationDataSource
{
@ -43,6 +39,10 @@ public class TranslationDataSource
values.put(BashgidSqliteHelper.COLUMN_TEXT_EN, recordData.textEn);
values.put(BashgidSqliteHelper.COLUMN_TEXT_RU, recordData.textRu);
values.put(BashgidSqliteHelper.COLUMN_TEXT_ZH, recordData.textZh);
values.put(BashgidSqliteHelper.COLUMN_TEXT_EN_UP, recordData.textEnUp);
values.put(BashgidSqliteHelper.COLUMN_TEXT_RU_UP, recordData.textRuUp);
values.put(BashgidSqliteHelper.COLUMN_TEXT_ZH_UP, recordData.textZhUp);
if (!innerIsTranslationAlreadyExist(recordData.name, database))
{
@ -82,6 +82,72 @@ public class TranslationDataSource
return name;
}
}
public ArrayList<String> SearchRussian(String partString)
{
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
result = innerGetTranslationNameByPartString_Russian(partString, database);
} finally
{
dbHelper.close();
}
}
return result;
}
public ArrayList<String> SearchEnglish(String partString)
{
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
result = innerGetTranslationNameByPartString_English(partString, database);
} finally
{
dbHelper.close();
}
}
return result;
}
public ArrayList<String> SearchChinese(String partString)
{
ArrayList<String> result = new ArrayList<String>();
SQLiteDatabase database = dbHelper.getWritableDatabase();
if (database != null)
{
try
{
result = innerGetTranslationNameByPartString_Chinese(partString, database);
} finally
{
dbHelper.close();
}
}
return result;
}
/*
public boolean IsTranslationAlreadyExist(String name)
{
@ -371,14 +437,97 @@ public class TranslationDataSource
TranslationRecordData result = null;
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TEXT_EN,
BashgidSqliteHelper.COLUMN_TEXT_RU, BashgidSqliteHelper.COLUMN_TEXT_ZH }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME,
BashgidSqliteHelper.COLUMN_TEXT_EN, BashgidSqliteHelper.COLUMN_TEXT_RU, BashgidSqliteHelper.COLUMN_TEXT_ZH,
BashgidSqliteHelper.COLUMN_TEXT_EN_UP, BashgidSqliteHelper.COLUMN_TEXT_RU_UP, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP}, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
result = new TranslationRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3));
result = new TranslationRecordData(
cursor.getString(0),
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5),
cursor.getString(6));
}
cursor.close();
cursor = null;
}
return result;
}
public ArrayList<String> innerGetTranslationNameByPartString_Russian(String partString, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_RU_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
do
{
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
cursor.close();
cursor = null;
}
return result;
}
public ArrayList<String> innerGetTranslationNameByPartString_English(String partString, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_EN_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
do
{
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
cursor.close();
cursor = null;
}
return result;
}
public ArrayList<String> innerGetTranslationNameByPartString_Chinese(String partString, SQLiteDatabase database)
{
ArrayList<String> result = new ArrayList<String>();
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME}, BashgidSqliteHelper.COLUMN_TEXT_ZH_UP + " LIKE ?", new String[] { "%" + partString + "%" }, null, null, null, null);
if (cursor != null)
{
if (cursor.moveToFirst())
{
do
{
result.add(cursor.getString(0));
} while (cursor.moveToNext());
}
cursor.close();