public class CardWithCategoryEntity {
@Embedded
public CardEntity cardEntity;
@Ignore
@Relation(parentColumn = "id", entityColumn = "cards_id", entity = CardCategoryEntity.class, projection = {"cards_id, category_id, record_type"})
public List<CategoryEntity> categoryList;
}
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(),
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int hour, int min) {
updateCalendar();
}
},
getHour(),
getMinute(),
true);
timePickerDialog.show();
@Expose
private List<Upd> updates;
public List<Upd> getUpdates()
{
return updates;
}
public class Upd {
@SerializedName("title_ru")
private String title_ru;
}
public class MainActivity extends AppCompatActivity
{
final String TAG = "myLogs";
EditText editVvodText;
Button butSearch;
// класс для retrofit
API api;
final Uri WORD_URI = Uri.parse("content://net.kinomovies.wordprovider.TranslateOnline/words");
final String WORD_RU = "word_ru";
final String WORD_EN = "word_en";
ArrayList<Word> words = new ArrayList<Word>();
WordAdapter wordAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// добавляем progressbar в заголовке
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// показываем progressbar в заголовке
//setProgressBarIndeterminateVisibility(true);
updateAdapter();
// настраиваем список
ListView lvMain = (ListView) findViewById(R.id.listView);
lvMain.setAdapter(wordAdapter);
// подкючаем API
api = new API(MainActivity.this);
butSearch = (Button) findViewById(R.id.butSearch);
butSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (editVvodText.getText().length() > 0) {
if (editVvodText.getText().toString().charAt(0) < 127) {
api.translate(editVvodText.getText().toString(), API.ENGLISH, API.RUSSIAN);
//Toast.makeText(getApplicationContext(), "ENGLISH", Toast.LENGTH_SHORT).show();
} else {
api.translate(editVvodText.getText().toString(), API.RUSSIAN, API.ENGLISH);
//Toast.makeText(getApplicationContext(), "RUSSIAN", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getApplicationContext(), R.string.not_words_search, Toast.LENGTH_SHORT).show();
}
// очищаем edittext
editVvodText.setText("");
updateAdapter();
}
});
editVvodText = (EditText) findViewById(R.id.editVvodText);
editVvodText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
wordAdapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
public void updateAdapter()
{
Log.d(TAG, "updateAdapter!!!");
// получаем данные из удаленной БД
Cursor cursor = getContentResolver().query(WORD_URI, null, null, null, null);
startManagingCursor(cursor);
words.clear();
if(cursor!=null)
{
// выбираем данные
if (cursor.moveToFirst())
{
do {
Log.d(TAG,"ID = " + cursor.getInt(0) + ", word_ru = "
+ cursor.getString(1) + ", word_en = "
+ cursor.getString(2));
words.add(new Word(cursor.getString(1)));
} while (cursor.moveToNext());
}
else
{
Log.d(TAG, "0 rows");
words.clear();
}
cursor.close();
}
wordAdapter = new WordAdapter(this, words);
wordAdapter.notifyDataSetChanged();
}
}
public class API
{
private static final String SOURCE = "http://api.mymemory.translated.net";
public final static String RUSSIAN = "RU";
public final static String ENGLISH = "EN";
private final TranslateService mService;
final String TAG = "myLogs";
Context ctx;
final Uri WORD_URI = Uri.parse("content://net.kinomovies.wordprovider.TranslateOnline/words");
final String WORD_RU = "word_ru";
final String WORD_EN = "word_en";
public interface TranslateService {
@GET("/get")
Call<TranslatedData> getTranslation(@Query("q") String textTranslate,@Query(value = "langpair", encoded = true) String language);
}
public API(Context ctx) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SOURCE)
.addConverterFactory(GsonConverterFactory.create())
.build();
mService = retrofit.create(TranslateService.class);
this.ctx = ctx;
}
public void translate(final String textToTranslate, final String fromLanguage, final String toLanguage) {
mService.getTranslation(textToTranslate, URLEncoder.encode(fromLanguage + "|" + toLanguage))
.enqueue(new Callback<TranslatedData>() {
@Override
public void onResponse(Response<TranslatedData> response, Retrofit retrofit) {
Log.d("myLogs", fromLanguage + "->" + toLanguage + "=" + response.body().responseData.translatedText);
Log.d("myLogs", "match="+Float.valueOf(response.body().responseData.match));
//if(Float.valueOf(response.body().responseData.match)==1)
if(response.body().responseData.match!=textToTranslate)
{
ContentValues cv = new ContentValues();
if(fromLanguage==RUSSIAN)
{
cv.put(WORD_RU, textToTranslate);
cv.put(WORD_EN, response.body().responseData.translatedText);
}
else
{
cv.put(WORD_EN, textToTranslate);
cv.put(WORD_RU, response.body().responseData.translatedText);
}
Uri newUri = ctx.getContentResolver().insert(WORD_URI, cv);
Log.d(TAG, "insert, result Uri : " + newUri.toString());
}
else
{
Toast.makeText(ctx, "НЕ верный запрос!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Throwable t) {
Log.d("myLogs", "Failed!!!");
}
});
}
}
class TranslatedData {
ResponseData responseData;
}
class ResponseData {
String translatedText;
String match;
}
<?php
$response = array();
require 'db_connect.php';
$db = new DB_CONNECT();
$result = mysql_query("SELECT *FROM dle_post ORDER BY id DESC") or die(mysql_error());
if (mysql_num_rows($result) > 0) {
$response["dle_post"] = array();
while ($row = mysql_fetch_array($result)) {
$cinema = array();
$cinema["pid"] = $row["id"];
$cinema["title"] = $row["title"];
$cinema["category"] = $row["category"];
$cinema["short_story"] = $row["short_story"];
/*$cinema["xfields"] = $row["xfields"];*/
$masxfields = array();
$masxfields2 = array();
$masxfields3 = array();
$namescr = "screens";
$masxfields=split("\\|\\|", $row["xfields"], -1);
for ($i = 1; $i < count($masxfields); $i++)
{
$masxfields2=split("\\|", $masxfields[$i], 2);
if ($masxfields2[0] == $namescr)
{
preg_match_all("#src=[\"']([^\"']+)#", $masxfields2[1], $masxfields3);
$cinema[$masxfields2[0]] = $masxfields3[1][0].", ".$masxfields3[1][1].", ".$masxfields3[1][2];
}
else
{
$cinema[$masxfields2[0]] = $masxfields2[1];
}
}
array_push($response["dle_post"], $cinema);
}
$response["success"] = 1;
$datastr=json_encode($response, JSON_UNESCAPED_UNICODE);/*кодируем в utf-8*/
/*$datastr=stripslashes($datastr);*//*убираем экранирование*/
$datastr=strip_tags($datastr, '<img>');/*убираем теги кроме img*/
echo $datastr;
} else {
$response["success"] = 0;
$response["message"] = "No cinema found";
echo json_encode($response);
}
?>
<img src="ссылка" alt="название" title="название"><img src="ссылка" alt="название" title="название"><img src="ссылка" alt="название" title="название">
TestJoinMethod1 t1;
t1=new TestJoinMethod1();
// вызов
t1.baseitem(fn, animX, animY, kart);
t1.start();
try{
t1.join();
}catch(Exception e){System.out.println(e);}
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
public class TestJoinMethod1 extends Thread {
Klondike klondike;
int fn;
int animX, animY;
ImageView kart[] = new ImageView[52];
void baseitem(int fn2, int animX2, int animY2, ImageView[] karts)
{
fn=fn2;
animX=animX2;
animY=animY2;
for (int i = 0; i < karts.length; i++)
{
kart[i]=karts[i];
}
}
public void run(){
System.out.println("running...");
try{
Thread.sleep(1000);
}catch(Exception e){System.out.println(e);}
kart[fn].setVisibility(View.INVISIBLE);
TranslateAnimation anim0 = new TranslateAnimation(kart[fn].getX(), 0, kart[fn].getY(), 0);
anim0.setDuration(1000);
anim0.setFillAfter(true);
kart[fn].bringToFront();
kart[fn].setX(animX);
kart[fn].setY(animY);
kart[fn].startAnimation(anim0);
}
}