Added translation
This commit is contained in:
parent
5c5238c85f
commit
f7b2d01a13
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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<String> 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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user