diff --git a/android/src/fishrungames/bashgid/MainActivity.java b/android/src/fishrungames/bashgid/MainActivity.java index 7373ee9..31d26d1 100644 --- a/android/src/fishrungames/bashgid/MainActivity.java +++ b/android/src/fishrungames/bashgid/MainActivity.java @@ -22,6 +22,7 @@ import fishrungames.bashgid.core.DatabaseDownloadTask; import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord; import fishrungames.bashgid.core.JournalManager.JournalSemiFullData; import fishrungames.bashgid.core.NewsDownloadTask; +import fishrungames.bashgid.core.TranslationManager.TranslationRecordData; import fishrungames.bashgid.core.PhotoManager.PhotoRecordData; import fishrungames.bashgid.core.VideoManager; @@ -33,6 +34,7 @@ import fishrungames.bashgid.core.db.ChannelDataSource; import fishrungames.bashgid.core.db.JournalDataSource; import fishrungames.bashgid.core.db.NewsDataSource; import fishrungames.bashgid.core.db.PhotoDataSource; +import fishrungames.bashgid.core.db.TranslationDataSource; import fishrungames.bashgid.core.db.VideoDataSource; import fishrungames.networkutils.ContextHolder; @@ -151,6 +153,8 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF public JournalDataSource journalDataSource = null; + public TranslationDataSource translationDataSource = null; + public Handler mHandler; @Override @@ -187,6 +191,8 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF journalDataSource = new JournalDataSource(this, dbHelper); + translationDataSource = new TranslationDataSource(this, dbHelper); + mHandler = new Handler(Looper.getMainLooper()) { @@ -335,6 +341,9 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF //articleDataSource.AddAlbumToArticle("TEST", "testArticle2"); //articleDataSource.AddChannelToArticle("main", "testArticle2"); + translationDataSource.CreateNewTranslation(new TranslationRecordData("Wow 2 photos", "Wow 2 photos", "Вау 2 фото", "哇2张照片")); + translationDataSource.CreateNewTranslation(new TranslationRecordData("Rickroll", "Rickroll", "Рикролл", "笑话")); + DownloadDatabase(); } diff --git a/android/src/fishrungames/bashgid/MainPageFragment.java b/android/src/fishrungames/bashgid/MainPageFragment.java index e7f711c..b5b99d0 100644 --- a/android/src/fishrungames/bashgid/MainPageFragment.java +++ b/android/src/fishrungames/bashgid/MainPageFragment.java @@ -122,6 +122,9 @@ public class MainPageFragment extends Fragment { public void SetJournal(JournalSemiFullData journal) { + //Xperimental + if (journal != null) + { progressBar.setVisibility(View.GONE); newsJournal = journal; @@ -184,6 +187,8 @@ public class MainPageFragment extends Fragment { listAdapter.notifyDataSetChanged(); + } + } diff --git a/android/src/fishrungames/bashgid/core/db/AlbumDataSource.java b/android/src/fishrungames/bashgid/core/db/AlbumDataSource.java index 908c015..226d5ed 100644 --- a/android/src/fishrungames/bashgid/core/db/AlbumDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/AlbumDataSource.java @@ -96,11 +96,8 @@ public class AlbumDataSource 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 { @@ -149,6 +146,9 @@ public class AlbumDataSource { result.photoRecordArr.add(MainActivity.getInstance().photoDataSource.InnerGetPhotoByImageUrl(imageUrl, database)); } + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); } @@ -181,6 +181,10 @@ public class AlbumDataSource { result.firstImageUrl = imageUrlArr.get(0); } + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); + } } finally diff --git a/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java b/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java index f3bcc07..b79b798 100644 --- a/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/ArticleDataSource.java @@ -208,6 +208,11 @@ public class ArticleDataSource { result.channelArr.add(MainActivity.getInstance().channelDataSource.InnerGetChannelFullData(channelName, database)); } + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.content = MainActivity.getInstance().translationDataSource.TryTranslateText(result.content, database); + result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database); + } @@ -324,9 +329,13 @@ public class ArticleDataSource result = new ArticleShortData(recordData); - result.previewImageUrl = getPreviewImageUrlForArticle(name, database); + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.content = MainActivity.getInstance().translationDataSource.TryTranslateText(result.content, database); + result.externalLink = MainActivity.getInstance().translationDataSource.TryTranslateText(result.externalLink, database); + + } diff --git a/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java b/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java index 51cae3b..89f914f 100644 --- a/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java +++ b/android/src/fishrungames/bashgid/core/db/BashgidSqliteHelper.java @@ -29,6 +29,8 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper public static final String TABLE_JOURNAL = "table_journal"; public static final String TABLE_ARTICLE_JOURNAL_RELATION = "table_article_journal_relation"; + + public static final String TABLE_TRANSLATION = "table_translation"; // Oldstyle public static final String TABLE_NEWS = "table_news"; @@ -58,18 +60,15 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper 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"; private static final String DATABASE_NAME = "bashgid.db"; private static final int DATABASE_VERSION = 1; // Database creation sql statement - /* - private static final String DATABASE_CREATE = "create table " + TABLE_NEWS + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_TITLE - + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_IMAGE_URL + " text not null" + ", " + COLUMN_PUBDATE - + " text not null" + ");";*/ - + private static final String TABLE_NEWS_CREATE = "create table " + TABLE_NEWS + "(" + COLUMN_ID + " integer primary key autoincrement" + ", " + COLUMN_TITLE + " text not null" + ", " + COLUMN_DESCRIPTION + " text not null" + ", " + COLUMN_IMAGE_URL + " text not null" + ", " + COLUMN_PUBDATE @@ -113,6 +112,9 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper 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" + ");"; + public final Semaphore mutex = new Semaphore(1, true); public BashgidSqliteHelper(Context context) @@ -137,6 +139,8 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper database.execSQL(TABLE_JOURNAL_CREATE); database.execSQL(TABLE_ARTICLE_JOURNAL_RELATION_CREATE); + database.execSQL(TABLE_TRANSLATION_CREATE); + } @@ -157,7 +161,7 @@ public class BashgidSqliteHelper extends SQLiteOpenHelper db.execSQL("DROP TABLE IF EXISTS " + TABLE_JOURNAL); db.execSQL("DROP TABLE IF EXISTS " + TABLE_ARTICLE_JOURNAL_RELATION); - + db.execSQL("DROP TABLE IF EXISTS " + TABLE_TRANSLATION); onCreate(db); } diff --git a/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java b/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java index f947506..af050d7 100644 --- a/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/ChannelDataSource.java @@ -96,11 +96,8 @@ public class ChannelDataSource if (!innerVideoChannelRelationAlreadyExist(videoUrl, channelName, database)) { - Log.e("a", "aaa1"); database.insert(BashgidSqliteHelper.TABLE_VIDEO_CHANNEL_RELATION, null, values); - Log.e("a", "aaa2"); } - Log.e("a", "aaa3"); } finally { @@ -149,6 +146,9 @@ public class ChannelDataSource { result.videoRecordArr.add(MainActivity.getInstance().videoDataSource.InnerGetVideoByVideoUrl(videoUrl, database)); } + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); } diff --git a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java index 2567eaa..96964c0 100644 --- a/android/src/fishrungames/bashgid/core/db/JournalDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/JournalDataSource.java @@ -224,25 +224,10 @@ public class JournalDataSource { journal.articleArr.add(MainActivity.getInstance().articleDataSource.InnerGetArticleShortData(article, database)); - /* - String imageUrl = "R.drawable.no_picture"; - - //Find first photo in first album (if exist) - ArrayList albumArr = MainActivity.getInstance().articleDataSource.innerGetAlbumNameArrInArticle(article, database); - if (albumArr.size() > 0) - { - AlbumFullData album = MainActivity.getInstance().albumDataSource.InnerGetAlbumFullData(albumArr.get(0), database); - - if (album.photoRecordArr.size() > 0) - { - imageUrl = album.photoRecordArr.get(0).imageUrl; - } - } - - journal.previewImageArr.add(imageUrl);*/ - } - + + journal.title = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.title, database); + journal.description = MainActivity.getInstance().translationDataSource.TryTranslateText(journal.description, database); result.add(journal); @@ -319,6 +304,10 @@ public class JournalDataSource } } + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); + } return result; diff --git a/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java b/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java index 49d5860..bbb8069 100644 --- a/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/PhotoDataSource.java @@ -1,5 +1,6 @@ package fishrungames.bashgid.core.db; +import fishrungames.bashgid.MainActivity; import fishrungames.bashgid.core.PhotoManager.PhotoRecordData; import android.content.ContentValues; @@ -96,6 +97,9 @@ public class PhotoDataSource result = new PhotoRecordData(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getDouble(4), cursor.getDouble(5)); + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); } cursor.close(); diff --git a/android/src/fishrungames/bashgid/core/db/VideoDataSource.java b/android/src/fishrungames/bashgid/core/db/VideoDataSource.java index 4cbb470..9f6a667 100644 --- a/android/src/fishrungames/bashgid/core/db/VideoDataSource.java +++ b/android/src/fishrungames/bashgid/core/db/VideoDataSource.java @@ -1,6 +1,7 @@ package fishrungames.bashgid.core.db; +import fishrungames.bashgid.MainActivity; import fishrungames.bashgid.core.VideoManager.VideoRecordData; import android.content.ContentValues; @@ -98,7 +99,10 @@ public class VideoDataSource cursor.getString(3), cursor.getString(4), cursor.getString(5) - ); + ); + + result.title = MainActivity.getInstance().translationDataSource.TryTranslateText(result.title, database); + result.description = MainActivity.getInstance().translationDataSource.TryTranslateText(result.description, database); } cursor.close();