<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test</title>
</head>
<body>
<table width="300" border="1" align="center"
cellpadding="0" cellspacing="0">
<!-- time -->
<tr>
<td rowspan="12" bgcolor="#FBF0DB" height="100" width="100">8:00</td>
<td width="100"></td>
<td width="100"></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<!-- time -->
<tr>
<td rowspan="12" bgcolor="#FBF0DB" height="100" width="100">9:00</td>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td bgcolor="#FF6A00" rowspan="5">Иванов Иван Иванович </td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td bgcolor="#FF6A00" colspan="7">Петров Петр Петрович</td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<!-- time -->
<tr>
<td rowspan="12" bgcolor="#FBF0DB" height="100" width="100">10:00</td>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
</table>
</body>
</html>
public void getCinemaFrag()
{
// Создаем адаптер с базовым адресом
Retrofit.Builder builder = new Retrofit.Builder();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SOURCE_MOON)
.addConverterFactory(GsonConverterFactory.create())
.build();
Retrofit retrofit2 = new Retrofit.Builder()
.baseUrl(SOURCE_KP)
.addConverterFactory(GsonConverterFactory.create())
.build();
// Создаём сервисы API
apiMoon = retrofit.create(APIMoon.class);
apiKp= retrofit2.create(APIKp.class);
mProgressBar.setVisibility(View.VISIBLE);
// Получаем данные
cinemas.clear();
Call<KinoModel> call = apiMoon.getCinema(API_TOKEN);
call.enqueue(new Callback<KinoModel>() {
@Override
public void onResponse(Call<KinoModel> call, Response<KinoModel> response)
{
for (int k = 0; k < response.body().getNumUpdates(); k++) {
film_ID = response.body().getUpdates().get(k).getKP();
if (film_ID != 0) {
Call<KinoModelKp> call2 = apiKp.getKp(film_ID);
models[0]=response.body().getUpdates().get(k).getTitleRU();
models[1]=response.body().getUpdates().get(k).getTitleEN();
models[2]=String.valueOf(response.body().getUpdates().get(k).getKP());
models[3]=response.body().getUpdates().get(k).getToken();
models[4]=response.body().getUpdates().get(k).getType();
models[5]=String.valueOf(response.body().getUpdates().get(k).getCAM());
models[6]=response.body().getUpdates().get(k).getIframe();
models[7]=response.body().getUpdates().get(k).getTranslate();
models[8]=response.body().getUpdates().get(k).getTranslateID();
models[9]=response.body().getUpdates().get(k).getAdded();
call2.enqueue(new Callback<KinoModelKp>() {
@Override
public void onResponse(Call<KinoModelKp> call2, Response<KinoModelKp> response2) {
cinemas.add(new Cinema(models[0], models[1],
models[2], models[3], models[4],
models[5], models[6], models[7],
models[8], models[9], "http://kinopoisk.ru/images/" + response2.body().getPoster(), String.valueOf(response2.body().getKPYear()), response2.body().getDescription()));
}
@Override
public void onFailure(Call<KinoModelKp> call2, Throwable t) {
Log.d("myLogs", "Failed!!! KP ");
}
});
}
else
{
cinemas.add(new Cinema(response.body().getUpdates().get(k).getTitleRU(), response.body().getUpdates().get(k).getTitleEN(),
String.valueOf(response.body().getUpdates().get(k).getKP()), response.body().getUpdates().get(k).getToken(), response.body().getUpdates().get(k).getType(),
String.valueOf(response.body().getUpdates().get(k).getCAM()), response.body().getUpdates().get(k).getIframe(), response.body().getUpdates().get(k).getTranslate(),
response.body().getUpdates().get(k).getTranslateID(), response.body().getUpdates().get(k).getAdded(), "", "0", "описание отсутствует..."));
}
if(k==response.body().getNumUpdates()-1)
{
mProgressBar.setVisibility(View.GONE);
cinemaAdapter = new CinemaAdapter(getActivity(), cinemas);
cinemaAdapter.notifyDataSetChanged();
// настраиваем список
lvMain.setAdapter(cinemaAdapter);
}
}
}
@Override
public void onFailure(Call<KinoModel> call, Throwable t) {
Log.d("myLogs", "Failed!!!");
}
});
}
public void getCinemaFrag()
{
// Создаем адаптер с базовым адресом
Retrofit.Builder builder = new Retrofit.Builder();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SOURCE_MOON)
.addConverterFactory(GsonConverterFactory.create())
.build();
Retrofit retrofit2 = new Retrofit.Builder()
.baseUrl(SOURCE_KP)
.addConverterFactory(GsonConverterFactory.create())
.build();
// Создаём сервисы API
apiMoon = retrofit.create(APIMoon.class);
apiKp= retrofit2.create(APIKp.class);
Thread t = new Thread(new Runnable(){
@Override
public void run(){
mProgressBar.setVisibility(View.VISIBLE);
// Получаем данные
cinemas.clear();
Call<KinoModel> call = apiMoon.getCinema(API_TOKEN);
try {
kinoModel = call.execute().body();
} catch (IOException e) {
e.printStackTrace();
}
if (call.isExecuted()) {
for (int k = 0; k < kinoModel.getNumUpdates(); k++) {
film_ID = kinoModel.getUpdates().get(k).getKP();
if (film_ID != 0) {
Call<KinoModelKp> call2 = apiKp.getKp(film_ID);
try {
kinoModelKp = call2.execute().body();
} catch (IOException e) {
e.printStackTrace();
}
cinemas.add(new Cinema(kinoModel.getUpdates().get(k).getTitleRU(), kinoModel.getUpdates().get(k).getTitleEN(),
kinoModel.getUpdates().get(k).getKP(), kinoModel.getUpdates().get(k).getToken(), kinoModel.getUpdates().get(k).getType(),
kinoModel.getUpdates().get(k).getCAM(), kinoModel.getUpdates().get(k).getIframe(), kinoModel.getUpdates().get(k).getTranslate(),
kinoModel.getUpdates().get(k).getTranslateID(), kinoModel.getUpdates().get(k).getAdded(), "http://st.kp.yandex.net/images/" + kinoModelKp.getPoster(), kinoModelKp.getKPYear(), kinoModelKp.getDescription()));
}
else
{
cinemas.add(new Cinema(kinoModel.getUpdates().get(k).getTitleRU(), kinoModel.getUpdates().get(k).getTitleEN(),
kinoModel.getUpdates().get(k).getKP(), kinoModel.getUpdates().get(k).getToken(), kinoModel.getUpdates().get(k).getType(),
kinoModel.getUpdates().get(k).getCAM(), kinoModel.getUpdates().get(k).getIframe(), kinoModel.getUpdates().get(k).getTranslate(),
kinoModel.getUpdates().get(k).getTranslateID(), kinoModel.getUpdates().get(k).getAdded(), "", 0, "описание отсутствует..."));
}
}
}
}
});
t.start();
try {
t.join();
mProgressBar.setVisibility(View.GONE);
cinemaAdapter = new CinemaAdapter(getActivity(), cinemas);
cinemaAdapter.notifyDataSetChanged();
// настраиваем список
lvMain.setAdapter(cinemaAdapter);
} catch (InterruptedException e) {
e.printStackTrace();
}
}