added translations
This commit is contained in:
parent
b648779ba3
commit
4e80964196
@ -8,11 +8,14 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:showDividers="middle" >
|
android:showDividers="middle" >
|
||||||
|
|
||||||
<ImageView
|
<fishrungames.bashgid.DynamicImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:cropToPadding="false"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dateTextView"
|
android:id="@+id/dateTextView"
|
||||||
|
@ -7,13 +7,6 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context="fishrungames.bashgid.MainPageFragment" >
|
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBar"
|
|
||||||
style="?android:attr/progressBarStyleLarge"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:indeterminate="true" />
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/listView"
|
android:id="@+id/listView"
|
||||||
@ -27,4 +20,13 @@
|
|||||||
|
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
22
android/res/layout/journal_page_header.xml
Normal file
22
android/res/layout/journal_page_header.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/bkg1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:paddingRight="20dp"
|
||||||
|
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dateTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:text="@string/journal_open_map"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<string name="news_header">Новости</string>
|
<string name="news_header">Новости</string>
|
||||||
|
<string name="news_load_more">Загрузить больше</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="news_content_description">Картинка к новости</string>
|
<string name="news_content_description">Картинка к новости</string>
|
||||||
|
|
||||||
@ -52,4 +54,14 @@
|
|||||||
<string name="price">Стоимость: </string>
|
<string name="price">Стоимость: </string>
|
||||||
<string name="rub">Руб.</string>
|
<string name="rub">Руб.</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>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<string name="news_header">头条新闻</string>
|
<string name="news_header">头条新闻</string>
|
||||||
|
<string name="news_load_more">Load more</string>
|
||||||
|
|
||||||
<string name="news_content_description">新闻内容描述</string>
|
<string name="news_content_description">新闻内容描述</string>
|
||||||
|
|
||||||
@ -41,5 +42,18 @@
|
|||||||
|
|
||||||
<string name="go_to_website">去现场</string>
|
<string name="go_to_website">去现场</string>
|
||||||
|
|
||||||
|
<string name="buy">Buy</string>
|
||||||
|
<string name="read">Read</string>
|
||||||
|
<string name="price">Price: </string>
|
||||||
|
<string name="rub">RUB</string>
|
||||||
|
|
||||||
|
<string name="journal_open_map">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>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -55,5 +55,14 @@
|
|||||||
<string name="price">Price: </string>
|
<string name="price">Price: </string>
|
||||||
<string name="rub">RUB</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>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -6,6 +6,7 @@ import it.sephiroth.android.library.widget.HListView;
|
|||||||
import fishrungames.bashgid.AlbumListFragment.DatabaseGetAlbumListTask;
|
import fishrungames.bashgid.AlbumListFragment.DatabaseGetAlbumListTask;
|
||||||
import fishrungames.bashgid.MainPageFragment.ListAdapter;
|
import fishrungames.bashgid.MainPageFragment.ListAdapter;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumShortData;
|
||||||
|
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -33,6 +34,8 @@ public class CatalogFragment extends Fragment
|
|||||||
|
|
||||||
ArrayList<JournalSemiFullData> journalList;
|
ArrayList<JournalSemiFullData> journalList;
|
||||||
|
|
||||||
|
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
||||||
|
|
||||||
public CatalogFragment()
|
public CatalogFragment()
|
||||||
{
|
{
|
||||||
RestoreJournalList();
|
RestoreJournalList();
|
||||||
@ -62,19 +65,34 @@ public class CatalogFragment extends Fragment
|
|||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (databaseGetJournalListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalListTask.cancel(false);
|
||||||
|
databaseGetJournalListTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
public void RestoreJournalList()
|
public void RestoreJournalList()
|
||||||
{
|
{
|
||||||
journalList = new ArrayList<JournalSemiFullData>();
|
journalList = new ArrayList<JournalSemiFullData>();
|
||||||
|
|
||||||
DatabaseGetJournalListTask task = new DatabaseGetJournalListTask();
|
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
task.execute();
|
databaseGetJournalListTask.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
||||||
{
|
{
|
||||||
|
databaseGetJournalListTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
this.journalList = journalList;
|
this.journalList = journalList;
|
||||||
@ -82,36 +100,6 @@ public class CatalogFragment extends Fragment
|
|||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<JournalSemiFullData> journalList;
|
|
||||||
|
|
||||||
public Handler mHandler;
|
|
||||||
|
|
||||||
protected Long doInBackground(String... queryArr)
|
|
||||||
{
|
|
||||||
|
|
||||||
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalList();
|
|
||||||
|
|
||||||
return (long) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onProgressUpdate(Integer... progress)
|
|
||||||
{
|
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_UPDATE, journalList);
|
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onPostExecute(Long result)
|
|
||||||
{
|
|
||||||
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
|
||||||
|
|
||||||
completeMessage.sendToTarget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter {
|
public class ListAdapter extends BaseAdapter {
|
||||||
|
@ -3,10 +3,7 @@ package fishrungames.bashgid;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -21,9 +18,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.AlbumManager;
|
|
||||||
import fishrungames.bashgid.core.DatabaseGetAlbumTask;
|
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
import fishrungames.bashgid.core.JournalManager;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
@ -38,6 +33,8 @@ public class JournalFragment extends Fragment
|
|||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
DatabaseGetJournalTask databaseGetJournalTask = null;
|
||||||
|
|
||||||
public JournalFragment()
|
public JournalFragment()
|
||||||
{
|
{
|
||||||
journal = null;
|
journal = null;
|
||||||
@ -78,9 +75,14 @@ public class JournalFragment extends Fragment
|
|||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
||||||
|
ListView listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
|
|
||||||
|
View header = inflater.inflate(R.layout.journal_page_header, null);
|
||||||
|
|
||||||
|
listView.addHeaderView(header);
|
||||||
|
|
||||||
listAdapter = new ListAdapter(getActivity());
|
listAdapter = new ListAdapter(getActivity());
|
||||||
|
|
||||||
ListView listView = (ListView) rootView.findViewById(R.id.listView);
|
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
@ -89,39 +91,66 @@ public class JournalFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
if (journalName.equals("news"))
|
if (position == 0)
|
||||||
{
|
{
|
||||||
MainActivity.getInstance().OpenNewsRecordScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
MainActivity.getInstance().OpenMapScreen(journalName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
if (journalName.equals("news"))
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().OpenNewsRecordScreen(journal.articleArr.get(position-1).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position-1).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RestoreJournal()
|
void RestoreJournal()
|
||||||
{
|
{
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
journal = JournalManager.CreateEmptyJournal();
|
journal = JournalManager.CreateEmptyJournal();
|
||||||
|
|
||||||
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
bundle.putString("journalName", journalName);
|
bundle.putString("journalName", journalName);
|
||||||
|
|
||||||
task.execute(bundle);
|
databaseGetJournalTask.execute(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
{
|
{
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +76,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
|
public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
|
||||||
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
|
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
|
||||||
public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
|
public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
|
||||||
@ -263,7 +262,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
albumDataSource.CreateNewAlbum(new AlbumRecordData("TEST", "Vk Photos", "Wow"));
|
albumDataSource.CreateNewAlbum(new AlbumRecordData("TEST", "Vk Photos", "Wow"));
|
||||||
|
|
||||||
@ -343,7 +342,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
translationDataSource.CreateNewTranslation(new TranslationRecordData("Wow 2 photos", "Wow 2 photos", "Вау 2 фото", "哇2张照片"));
|
translationDataSource.CreateNewTranslation(new TranslationRecordData("Wow 2 photos", "Wow 2 photos", "Вау 2 фото", "哇2张照片"));
|
||||||
translationDataSource.CreateNewTranslation(new TranslationRecordData("Rickroll", "Rickroll", "Рикролл", "笑话"));
|
translationDataSource.CreateNewTranslation(new TranslationRecordData("Rickroll", "Rickroll", "Рикролл", "笑话"));
|
||||||
|
*/
|
||||||
DownloadDatabase();
|
DownloadDatabase();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -450,12 +449,12 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
{
|
{
|
||||||
if (mainPageFragment != null)
|
if (mainPageFragment != null)
|
||||||
{
|
{
|
||||||
mainPageFragment.RefreshJournal();
|
mainPageFragment.RefreshAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsListFragment != null)
|
if (newsListFragment != null)
|
||||||
{
|
{
|
||||||
newsListFragment.RefreshJournal();
|
newsListFragment.RefreshAdapter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,9 +569,16 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
{
|
{
|
||||||
catalogFragment.SetJournalList(journalList);
|
catalogFragment.SetJournalList(journalList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mainPageFragment != null)
|
||||||
|
{
|
||||||
|
mainPageFragment.SetJournalList(journalList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateOnArticleSearchPerformed(ArrayList<ArticleShortData> articleArr)
|
public void UpdateOnArticleSearchPerformed(ArrayList<ArticleShortData> articleArr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -4,14 +4,12 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import fishrungames.networkutils.ImageManager;
|
import fishrungames.networkutils.ImageManager;
|
||||||
|
|
||||||
|
import fishrungames.bashgid.core.DatabaseGetJournalListTask;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
import fishrungames.bashgid.core.JournalManager;
|
||||||
import fishrungames.bashgid.core.NewsManager;
|
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
import fishrungames.bashgid.core.NewsManager.NewsRecord;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -33,10 +31,7 @@ import it.sephiroth.android.library.widget.HListView;
|
|||||||
public class MainPageFragment extends Fragment {
|
public class MainPageFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
String [] teaserHeaderArray = { "Разное"};
|
ArrayList<JournalSemiFullData> journalList = new ArrayList<JournalSemiFullData>();
|
||||||
|
|
||||||
int[] varietyContentIdArray = { 1, 2, 3, 4 };
|
|
||||||
|
|
||||||
|
|
||||||
ListView listView;
|
ListView listView;
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
@ -45,16 +40,27 @@ public class MainPageFragment extends Fragment {
|
|||||||
|
|
||||||
JournalSemiFullData newsJournal;
|
JournalSemiFullData newsJournal;
|
||||||
|
|
||||||
|
DatabaseGetJournalTask databaseGetJournalTask = null;
|
||||||
|
DatabaseGetJournalListTask databaseGetJournalListTask = null;
|
||||||
|
|
||||||
|
public MainPageFragment()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
journalList.clear();
|
||||||
|
|
||||||
|
RestoreJournalList();
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_main_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_main_page, container, false);
|
||||||
|
|
||||||
listView = (ListView) rootView.findViewById(R.id.listView);
|
listView = (ListView) rootView.findViewById(R.id.listView);
|
||||||
|
|
||||||
listAdapter = new ListAdapter(getActivity());
|
listAdapter = new ListAdapter(getActivity());
|
||||||
|
|
||||||
|
|
||||||
header = inflater.inflate(R.layout.main_page_header, null);
|
header = inflater.inflate(R.layout.main_page_header, null);
|
||||||
|
|
||||||
RestoreJournal();
|
RestoreJournal();
|
||||||
@ -97,6 +103,24 @@ public class MainPageFragment extends Fragment {
|
|||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView ()
|
||||||
|
{
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (databaseGetJournalListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalListTask.cancel(false);
|
||||||
|
databaseGetJournalListTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RestoreJournal()
|
void RestoreJournal()
|
||||||
{
|
{
|
||||||
@ -107,9 +131,14 @@ public class MainPageFragment extends Fragment {
|
|||||||
|
|
||||||
void RefreshJournal()
|
void RefreshJournal()
|
||||||
{
|
{
|
||||||
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
}
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
|
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -117,11 +146,13 @@ public class MainPageFragment extends Fragment {
|
|||||||
|
|
||||||
bundle.putInt("count", 3);
|
bundle.putInt("count", 3);
|
||||||
|
|
||||||
task.execute(bundle);
|
databaseGetJournalTask.execute(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
{
|
{
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
|
||||||
//Xperimental
|
//Xperimental
|
||||||
if (journal != null)
|
if (journal != null)
|
||||||
{
|
{
|
||||||
@ -191,6 +222,38 @@ public class MainPageFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RestoreJournalList()
|
||||||
|
{
|
||||||
|
journalList = new ArrayList<JournalSemiFullData>();
|
||||||
|
|
||||||
|
if (databaseGetJournalListTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalListTask.cancel(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
databaseGetJournalListTask = new DatabaseGetJournalListTask();
|
||||||
|
|
||||||
|
databaseGetJournalListTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
|
databaseGetJournalListTask.execute("featured");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetJournalList(ArrayList<JournalSemiFullData> journalList)
|
||||||
|
{
|
||||||
|
databaseGetJournalListTask = null;
|
||||||
|
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
this.journalList = journalList;
|
||||||
|
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ListAdapter extends BaseAdapter {
|
public class ListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -200,7 +263,7 @@ public class MainPageFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return teaserHeaderArray.length;
|
return journalList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
@ -213,7 +276,7 @@ public class MainPageFragment extends Fragment {
|
|||||||
|
|
||||||
// create a new ImageView for each item referenced by the Adapter
|
// create a new ImageView for each item referenced by the Adapter
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
|
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
@ -227,24 +290,40 @@ public class MainPageFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextView textView = (TextView) view.findViewById(R.id.dateTextView);
|
TextView textView = (TextView) view.findViewById(R.id.dateTextView);
|
||||||
|
TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
|
||||||
|
|
||||||
Button button = (Button) view.findViewById(R.id.button);
|
Button button = (Button) view.findViewById(R.id.button);
|
||||||
|
|
||||||
HListView hListView = (HListView) view.findViewById(R.id.hListView);
|
HListView hListView = (HListView) view.findViewById(R.id.hListView);
|
||||||
|
|
||||||
hListView.setAdapter(new MainPageHListViewAdapters.SimpleElementAdapter(getActivity()));
|
hListView.setAdapter(new MainPageHListViewAdapters.JournalElementAdapter(getActivity(), journalList.get(position)));
|
||||||
|
|
||||||
|
textView.setText(journalList.get(position).title);
|
||||||
|
|
||||||
|
descriptionTextView.setText(journalList.get(position).description);
|
||||||
|
|
||||||
textView.setText(teaserHeaderArray[position]);
|
|
||||||
|
|
||||||
button.setText(R.string.see_all);
|
button.setText(R.string.see_all);
|
||||||
|
|
||||||
|
button.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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class NewsButtonOnClickListener implements OnClickListener
|
public class NewsButtonOnClickListener implements OnClickListener
|
||||||
{
|
{
|
||||||
|
|
||||||
String articleName;
|
String articleName;
|
||||||
@ -257,6 +336,7 @@ public class MainPageFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
MainActivity.getInstance().OpenNewsRecordScreen(articleName, MainActivity.TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
MainActivity.getInstance().OpenNewsRecordScreen(articleName, MainActivity.TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
TextView footerTextView;
|
TextView footerTextView;
|
||||||
|
|
||||||
|
DatabaseGetJournalTask databaseGetJournalTask = null;
|
||||||
|
|
||||||
@SuppressLint("InflateParams") @Override
|
@SuppressLint("InflateParams") @Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
@ -83,7 +85,7 @@ public class NewsListFragment extends Fragment
|
|||||||
//Add position + 1, because first element of list is always title
|
//Add position + 1, because first element of list is always title
|
||||||
if (position == journal.articleArr.size() + 1)
|
if (position == journal.articleArr.size() + 1)
|
||||||
{
|
{
|
||||||
footerTextView.setText("Loading...");
|
footerTextView.setText(R.string.news_are_loading);
|
||||||
LoadMoreNews();
|
LoadMoreNews();
|
||||||
}
|
}
|
||||||
else if (position > 0)
|
else if (position > 0)
|
||||||
@ -99,6 +101,24 @@ public class NewsListFragment extends Fragment
|
|||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
databaseGetJournalTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshAdapter()
|
||||||
|
{
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void RestoreJournal()
|
void RestoreJournal()
|
||||||
{
|
{
|
||||||
journal = JournalManager.CreateEmptyJournal();
|
journal = JournalManager.CreateEmptyJournal();
|
||||||
@ -108,9 +128,9 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
void RefreshJournal()
|
void RefreshJournal()
|
||||||
{
|
{
|
||||||
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -118,14 +138,19 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
bundle.putInt("count", 20);
|
bundle.putInt("count", 20);
|
||||||
|
|
||||||
task.execute(bundle);
|
databaseGetJournalTask.execute(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMoreNews()
|
void LoadMoreNews()
|
||||||
{
|
{
|
||||||
DatabaseGetJournalTask task = new DatabaseGetJournalTask();
|
if (databaseGetJournalTask != null)
|
||||||
|
{
|
||||||
|
databaseGetJournalTask.cancel(false);
|
||||||
|
}
|
||||||
|
|
||||||
task.mHandler = MainActivity.getInstance().mHandler;
|
databaseGetJournalTask = new DatabaseGetJournalTask();
|
||||||
|
|
||||||
|
databaseGetJournalTask.mHandler = MainActivity.getInstance().mHandler;
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
@ -135,7 +160,7 @@ public class NewsListFragment extends Fragment
|
|||||||
|
|
||||||
bundle.putInt("count", 10);
|
bundle.putInt("count", 10);
|
||||||
|
|
||||||
task.execute(bundle);
|
databaseGetJournalTask.execute(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetJournal(JournalSemiFullData journal)
|
public void SetJournal(JournalSemiFullData journal)
|
||||||
@ -155,9 +180,7 @@ public class NewsListFragment extends Fragment
|
|||||||
//this.journal.previewImageArr.addAll(journal.previewImageArr);
|
//this.journal.previewImageArr.addAll(journal.previewImageArr);
|
||||||
|
|
||||||
|
|
||||||
|
footerTextView.setText(R.string.news_load_more);
|
||||||
|
|
||||||
footerTextView.setText("Load more");
|
|
||||||
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
@ -34,12 +34,10 @@ import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
|||||||
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
||||||
import fishrungames.bashgid.core.DatabaseGetArticleTask;
|
import fishrungames.bashgid.core.DatabaseGetArticleTask;
|
||||||
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
import fishrungames.bashgid.core.DatabaseGetJournalTask;
|
||||||
import fishrungames.bashgid.core.JournalManager;
|
|
||||||
import fishrungames.bashgid.core.LocationHolder;
|
import fishrungames.bashgid.core.LocationHolder;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
import fishrungames.networkutils.ImageManager;
|
import fishrungames.networkutils.ImageManager;
|
||||||
|
|
||||||
|
|
||||||
public class OsmMapHolderFragment extends Fragment
|
public class OsmMapHolderFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -102,14 +100,16 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
dialog.setView(image);
|
dialog.setView(image);
|
||||||
|
|
||||||
|
|
||||||
dialog.setPositiveButton("Open", new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
|
dialog.setPositiveButton(R.string.dialog_open, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
MainActivity.getInstance().SetLastMapFilterName(journalName);
|
MainActivity.getInstance().SetLastMapFilterName(journalName);
|
||||||
MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT);
|
MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), MainActivity.TAG_FROM_MAPFRAGMENT_TO_ARTICLEFRAGMENT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
dialog.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
}
|
}
|
||||||
@ -234,11 +234,11 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
|
|
||||||
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
|
if ((filterType == 0 && journal == null) || (filterType == 1 && article == null))
|
||||||
{
|
{
|
||||||
textView.setText("Loading map...");
|
textView.setText(R.string.map_is_loading);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
textView.setText("Map is loaded");
|
textView.setText(R.string.map_is_loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
mapView = (MapView) rootView.findViewById(R.id.mapview);
|
mapView = (MapView) rootView.findViewById(R.id.mapview);
|
||||||
@ -308,7 +308,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
{
|
{
|
||||||
filterType = 0;
|
filterType = 0;
|
||||||
|
|
||||||
textView.setText("Map is loaded");
|
textView.setText(R.string.map_is_loaded);
|
||||||
|
|
||||||
this.journal = journal;
|
this.journal = journal;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
{
|
{
|
||||||
filterType = 1;
|
filterType = 1;
|
||||||
|
|
||||||
textView.setText("Map is loaded");
|
textView.setText(R.string.map_is_loaded);
|
||||||
|
|
||||||
this.article = article;
|
this.article = article;
|
||||||
|
|
||||||
|
@ -70,8 +70,10 @@ public class PhotoFragmentAdapter extends PagerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
public void destroyItem(View collection, int position, Object o) {
|
||||||
((ViewPager) container).removeView((LinearLayout) object);
|
View view = (View)o;
|
||||||
|
((ViewPager) collection).removeView(view);
|
||||||
|
view = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -32,6 +32,7 @@ import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
|||||||
import fishrungames.bashgid.core.ChannelManager.ChannelRecordData;
|
import fishrungames.bashgid.core.ChannelManager.ChannelRecordData;
|
||||||
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
|
import fishrungames.bashgid.core.JournalManager.JournalRecordData;
|
||||||
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
||||||
|
import fishrungames.bashgid.core.TranslationManager.TranslationRecordData;
|
||||||
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
||||||
|
|
||||||
public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
||||||
@ -41,6 +42,7 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
|
|
||||||
protected Long doInBackground(Bundle... queryArr)
|
protected Long doInBackground(Bundle... queryArr)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
|
||||||
ParseJsonPhoto(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=photo/json"));
|
ParseJsonPhoto(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=photo/json"));
|
||||||
ParseJsonAlbum(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=album/json"));
|
ParseJsonAlbum(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=album/json"));
|
||||||
@ -55,6 +57,23 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=albumArticleRelation/json"));
|
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=albumArticleRelation/json"));
|
||||||
ParseJsonChannelArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=channelArticleRelation/json"));
|
ParseJsonChannelArticleRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=channelArticleRelation/json"));
|
||||||
ParseJsonArticleJournalRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=articleJournalRelation/json"));
|
ParseJsonArticleJournalRelation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=articleJournalRelation/json"));
|
||||||
|
ParseJsonTranslation(getJsonFromUrl("http://192.168.0.72/bashgid/index.php?r=translation/json"));
|
||||||
|
*/
|
||||||
|
|
||||||
|
ParseJsonPhoto(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photo/json"));
|
||||||
|
ParseJsonAlbum(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=album/json"));
|
||||||
|
ParseJsonPhotoAlbumRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=photoAlbumRelation/json"));
|
||||||
|
|
||||||
|
ParseJsonVideo(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=video/json"));
|
||||||
|
ParseJsonChannel(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channel/json"));
|
||||||
|
ParseJsonVideoChannelRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=videoChannelRelation/json"));
|
||||||
|
|
||||||
|
ParseJsonArticle(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=article/json"));
|
||||||
|
ParseJsonJournal(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=journal/json"));
|
||||||
|
ParseJsonAlbumArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=albumArticleRelation/json"));
|
||||||
|
ParseJsonChannelArticleRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=channelArticleRelation/json"));
|
||||||
|
ParseJsonArticleJournalRelation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=articleJournalRelation/json"));
|
||||||
|
ParseJsonTranslation(getJsonFromUrl("http://bashgid.hallyu.ru/index.php?r=translation/json"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -441,4 +460,27 @@ public class DatabaseDownloadTask extends AsyncTask<Bundle, Integer, Long>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ParseJsonTranslation(String jsonCode)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
JSONArray jArray = new JSONArray(jsonCode);
|
||||||
|
|
||||||
|
for(int i=0; i < jArray.length(); i++) {
|
||||||
|
|
||||||
|
JSONObject jObject = jArray.getJSONObject(i);
|
||||||
|
|
||||||
|
String name = jObject.getString("name");
|
||||||
|
String textEn = jObject.getString("textEn");
|
||||||
|
String textRu = jObject.getString("textRu");
|
||||||
|
String textZh = jObject.getString("textZh");
|
||||||
|
|
||||||
|
MainActivity.getInstance().translationDataSource.CreateNewTranslation(new TranslationRecordData(name, textEn, textRu, textZh));
|
||||||
|
|
||||||
|
} // End Loop
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.e("JSONException", "Error: " + e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
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.JournalSemiFullData;
|
||||||
|
|
||||||
|
public class DatabaseGetJournalListTask extends AsyncTask<String, Integer, Long>
|
||||||
|
{
|
||||||
|
|
||||||
|
ArrayList<JournalSemiFullData> journalList;
|
||||||
|
|
||||||
|
public Handler mHandler;
|
||||||
|
|
||||||
|
protected Long doInBackground(String... queryArr)
|
||||||
|
{
|
||||||
|
|
||||||
|
String superJournal = "";
|
||||||
|
|
||||||
|
if (queryArr.length > 0)
|
||||||
|
{
|
||||||
|
superJournal = queryArr[0];
|
||||||
|
journalList = MainActivity.getInstance().journalDataSource.GetJournalList(superJournal, 3); //Xperimental -- need to pass exactly how many articles
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
journalList = MainActivity.getInstance().journalDataSource.GetAllJournalList(3); //Xperimental -- need to pass exactly how many articles
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (long) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onProgressUpdate(Integer... progress)
|
||||||
|
{
|
||||||
|
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_UPDATE, journalList);
|
||||||
|
|
||||||
|
completeMessage.sendToTarget();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Long result)
|
||||||
|
{
|
||||||
|
Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_JOURNAL_LIST_STATE_FINISHED, journalList);
|
||||||
|
|
||||||
|
completeMessage.sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package fishrungames.bashgid.core;
|
||||||
|
|
||||||
|
|
||||||
|
public class TranslationManager
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class TranslationRecordData
|
||||||
|
{
|
||||||
|
public String name;
|
||||||
|
public String textEn;
|
||||||
|
public String textRu;
|
||||||
|
public String textZh;
|
||||||
|
|
||||||
|
|
||||||
|
public TranslationRecordData(String name, String textEn, String textRu, String textZh)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.textEn = textEn;
|
||||||
|
this.textRu = textRu;
|
||||||
|
this.textZh = textZh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TranslationRecordData(TranslationRecordData copyFrom)
|
||||||
|
{
|
||||||
|
this.name = copyFrom.name;
|
||||||
|
this.textEn = copyFrom.textEn;
|
||||||
|
this.textRu = copyFrom.textRu;
|
||||||
|
this.textZh = copyFrom.textZh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -207,7 +207,6 @@ public class AlbumDataSource
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME,
|
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 }, null, null, null, null, null, null);
|
||||||
|
|
||||||
@ -235,6 +234,7 @@ public class AlbumDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally
|
} finally
|
||||||
@ -262,6 +262,7 @@ public class AlbumDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -286,6 +287,7 @@ public class AlbumDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -311,6 +313,7 @@ public class AlbumDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -333,6 +336,7 @@ public class AlbumDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -392,6 +392,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -413,8 +414,8 @@ public class ArticleDataSource
|
|||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -436,6 +437,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -480,6 +482,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -530,6 +533,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -556,6 +560,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -582,6 +587,7 @@ public class ArticleDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -170,6 +170,7 @@ public class ChannelDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -192,6 +193,7 @@ public class ChannelDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -216,6 +218,7 @@ public class ChannelDataSource
|
|||||||
|
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -239,6 +242,7 @@ public class ChannelDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -190,7 +190,7 @@ public class JournalDataSource
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<JournalSemiFullData> GetAllJournalList()
|
public ArrayList<JournalSemiFullData> GetAllJournalList(int count)
|
||||||
{
|
{
|
||||||
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
||||||
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
@ -218,8 +218,16 @@ public class JournalDataSource
|
|||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
ArrayList<String> articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
|
ArrayList<String> articleArr;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
|
||||||
|
}
|
||||||
for (String article : articleArr)
|
for (String article : articleArr)
|
||||||
{
|
{
|
||||||
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
|
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
|
||||||
@ -239,6 +247,84 @@ public class JournalDataSource
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<JournalSemiFullData> GetJournalList(String superJournalName, int count)
|
||||||
|
{
|
||||||
|
//Xperimental - need to create a real superjournal
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<JournalSemiFullData> result = new ArrayList<JournalSemiFullData>();
|
||||||
|
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 }, null, null, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<String> articleArr;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
articleArr = innerGetArticleArrInJournal(cursor.getString(0), database, count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
articleArr = innerGetArticleArrInJournal(cursor.getString(0), database);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String article : articleArr)
|
||||||
|
{
|
||||||
|
journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database);
|
||||||
|
journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database);
|
||||||
|
|
||||||
|
result.add(journal);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -329,6 +415,7 @@ public class JournalDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -351,13 +438,13 @@ public class JournalDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<String> innerGetArticleArrInJournal(String name, SQLiteDatabase database)
|
private ArrayList<String> innerGetArticleArrInJournal(String name, SQLiteDatabase database)
|
||||||
{
|
{
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
@ -377,6 +464,35 @@ public class JournalDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<String> innerGetArticleArrInJournal(String name, SQLiteDatabase database, int count)
|
||||||
|
{
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ARTICLE_JOURNAL_RELATION, new String[] { BashgidSqliteHelper.COLUMN_ARTICLE_NAME },
|
||||||
|
BashgidSqliteHelper.COLUMN_JOURNAL_NAME + "=?", new String[] { name }, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result.add(cursor.getString(0));
|
||||||
|
i++;
|
||||||
|
} while (cursor.moveToNext() && i < count);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -400,6 +516,7 @@ public class JournalDataSource
|
|||||||
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.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -103,6 +103,7 @@ public class PhotoDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -124,6 +125,7 @@ public class PhotoDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -0,0 +1,395 @@
|
|||||||
|
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;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class TranslationDataSource
|
||||||
|
{
|
||||||
|
|
||||||
|
private BashgidSqliteHelper dbHelper = null;
|
||||||
|
|
||||||
|
public TranslationDataSource(Context context, BashgidSqliteHelper dbHelper)
|
||||||
|
{
|
||||||
|
this.dbHelper = dbHelper;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateNewTranslation(TranslationRecordData recordData)
|
||||||
|
{
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_NAME, recordData.name);
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_TEXT_EN, recordData.textEn);
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_TEXT_RU, recordData.textRu);
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_TEXT_ZH, recordData.textZh);
|
||||||
|
|
||||||
|
if (!innerIsTranslationAlreadyExist(recordData.name, database))
|
||||||
|
{
|
||||||
|
database.insert(BashgidSqliteHelper.TABLE_TRANSLATION, null, values);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
database.update(BashgidSqliteHelper.TABLE_TRANSLATION, values, BashgidSqliteHelper.COLUMN_NAME + " = " +"\"" + recordData.name +"\"", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String TryTranslateText(String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
if (innerIsTranslationAlreadyExist(name, database))
|
||||||
|
{
|
||||||
|
TranslationRecordData record = innerGetTranslationByName(name, database);
|
||||||
|
|
||||||
|
if (Locale.getDefault().equals(new Locale("ru")))
|
||||||
|
{
|
||||||
|
return record.textRu;
|
||||||
|
}
|
||||||
|
else if (Locale.getDefault() == Locale.CHINA)
|
||||||
|
{
|
||||||
|
return record.textZh;
|
||||||
|
}
|
||||||
|
|
||||||
|
return record.textEn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public boolean IsTranslationAlreadyExist(String name)
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = innerIsAlbumAlreadyExist(name, database);
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}*/
|
||||||
|
/*
|
||||||
|
public void AddPhotoToAlbum(String imageUrl, String albumName)
|
||||||
|
{
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_IMAGE_URL, imageUrl);
|
||||||
|
values.put(BashgidSqliteHelper.COLUMN_NAME, albumName);
|
||||||
|
|
||||||
|
if (!innerPhotoAlbumRelationAlreadyExist(imageUrl, albumName, database))
|
||||||
|
{
|
||||||
|
Log.e("a", "aaa1");
|
||||||
|
database.insert(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, null, values);
|
||||||
|
Log.e("a", "aaa2");
|
||||||
|
}
|
||||||
|
Log.e("a", "aaa3");
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public TranslationRecordData GetTranslationRecordData(String name)
|
||||||
|
{
|
||||||
|
TranslationRecordData result = null;
|
||||||
|
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
result = innerGetTranslationByName(name, database);
|
||||||
|
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public AlbumFullData GetAlbumFullData(String name)
|
||||||
|
{
|
||||||
|
AlbumFullData result = null;
|
||||||
|
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
result = InnerGetAlbumFullData(name, database);
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlbumFullData InnerGetAlbumFullData(String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
|
||||||
|
AlbumFullData result = null;
|
||||||
|
|
||||||
|
AlbumRecordData recordData = innerGetAlbumByName(name, database);
|
||||||
|
|
||||||
|
if (recordData != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
result = new AlbumFullData(recordData);
|
||||||
|
|
||||||
|
ArrayList<String> imageUrlArr = innerGetImageUrlArrInAlbum(name, database);
|
||||||
|
|
||||||
|
for (String imageUrl : imageUrlArr)
|
||||||
|
{
|
||||||
|
result.photoRecordArr.add(MainActivity.getInstance().photoDataSource.InnerGetPhotoByImageUrl(imageUrl, database));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlbumShortData GetAlbumShortData(String name)
|
||||||
|
{
|
||||||
|
AlbumShortData result = null;
|
||||||
|
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
AlbumRecordData recordData = innerGetAlbumByName(name, database);
|
||||||
|
|
||||||
|
if (recordData != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
result = new AlbumShortData(recordData);
|
||||||
|
|
||||||
|
ArrayList<String> imageUrlArr = innerGetImageUrlArrInAlbum(name, database);
|
||||||
|
|
||||||
|
result.photoCount = imageUrlArr.size();
|
||||||
|
|
||||||
|
if (imageUrlArr.size() > 0)
|
||||||
|
{
|
||||||
|
result.firstImageUrl = imageUrlArr.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<AlbumShortData> GetAllAlbumShortData()
|
||||||
|
{
|
||||||
|
|
||||||
|
ArrayList<AlbumShortData> result = new ArrayList<AlbumShortData>();
|
||||||
|
|
||||||
|
SQLiteDatabase database = dbHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_ALBUM, new String[] { BashgidSqliteHelper.COLUMN_NAME,
|
||||||
|
BashgidSqliteHelper.COLUMN_TITLE, BashgidSqliteHelper.COLUMN_DESCRIPTION }, null, null, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
AlbumShortData shortData = new AlbumShortData(new AlbumRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
|
||||||
|
|
||||||
|
ArrayList<String> imageUrlArr = innerGetImageUrlArrInAlbum(shortData.name, database);
|
||||||
|
|
||||||
|
shortData.photoCount = imageUrlArr.size();
|
||||||
|
|
||||||
|
if (imageUrlArr.size() > 0)
|
||||||
|
{
|
||||||
|
shortData.firstImageUrl = imageUrlArr.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(shortData);
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
dbHelper.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
private boolean innerIsTranslationAlreadyExist(String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_NAME
|
||||||
|
+ "=?", new String[] { name }, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.getCount() > 0)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
private boolean innerPhotoAlbumRelationAlreadyExist(String imageUrl, String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL,
|
||||||
|
BashgidSqliteHelper.COLUMN_NAME }, BashgidSqliteHelper.COLUMN_IMAGE_URL + "=?" + " AND " + BashgidSqliteHelper.COLUMN_NAME + "=?",
|
||||||
|
new String[] { imageUrl, name }, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.getCount() > 0)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<String> innerGetImageUrlArrInAlbum(String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_PHOTO_ALBUM_RELATION, new String[] { BashgidSqliteHelper.COLUMN_IMAGE_URL },
|
||||||
|
BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result.add(cursor.getString(0));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
public TranslationRecordData innerGetTranslationByName(String name, SQLiteDatabase database)
|
||||||
|
{
|
||||||
|
|
||||||
|
TranslationRecordData result = null;
|
||||||
|
|
||||||
|
Cursor cursor = database.query(BashgidSqliteHelper.TABLE_TRANSLATION, new String[] { BashgidSqliteHelper.COLUMN_NAME, BashgidSqliteHelper.COLUMN_TEXT_EN,
|
||||||
|
BashgidSqliteHelper.COLUMN_TEXT_RU, BashgidSqliteHelper.COLUMN_TEXT_ZH }, BashgidSqliteHelper.COLUMN_NAME + "=?", new String[] { name }, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null)
|
||||||
|
{
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
result = new TranslationRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -106,6 +106,7 @@ public class VideoDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -127,6 +128,7 @@ public class VideoDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user