1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297 |
- package ru.ktk45.www.feature;
- import android.app.DatePickerDialog;
- import android.graphics.Typeface;
- import android.os.Bundle;
- import android.os.StrictMode;
- import android.support.annotation.Nullable;
- import android.support.design.widget.FloatingActionButton;
- import android.support.design.widget.Snackbar;
- import android.support.v4.content.res.ResourcesCompat;
- import android.text.InputType;
- import android.util.Log;
- import android.util.TypedValue;
- import android.view.Gravity;
- import android.view.View;
- import android.support.design.widget.NavigationView;
- import android.support.v4.view.GravityCompat;
- import android.support.v4.widget.DrawerLayout;
- import android.support.v7.app.ActionBarDrawerToggle;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.ViewGroup;
- import android.webkit.WebSettings;
- import android.webkit.WebView;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.DatePicker;
- import android.widget.EditText;
- import android.widget.FrameLayout;
- import android.widget.LinearLayout;
- import android.widget.Spinner;
- import android.widget.TableRow;
- import android.widget.TextView;
- import android.widget.Toast;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import org.w3c.dom.Text;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.Locale;
- public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
- // Динамический список подразделений
- private ArrayAdapter<String> _BranchCaption;
- private ArrayAdapter<String> _BranchHash;
- private int _BranchSelectID;
- private int _GroupSelectID;
- private int _ScheduleLayoutID;
- // Динамический список групп для расписания (для установки в список Spinner'а)
- private ArrayAdapter<Integer> _Group;
- // Объект с группами подразделений
- private JSONArray _GroupList;
- private final Calendar _Calendar = Calendar.getInstance();
- private final Calendar _CalendarMon = Calendar.getInstance();
- private final Calendar _CalendarSat = Calendar.getInstance();
- private final SimpleDateFormat _DateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.US);
- private final SimpleDateFormat _DateQueryFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
- private EditText _DateSetup;
- // Для сохраниения даты подготовленной для отправки запроса расписания
- private int _DateIs = 0;
- private String[] _DateIsString = new String[2];
- // LinearLayout основного окна
- private LinearLayout _ContentPage;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- StrictMode.setThreadPolicy(policy);
- setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
- .setAction("Action", null).show();
- }
- });
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
- this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
- drawer.addDrawerListener(toggle);
- toggle.syncState();
- NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
- navigationView.setNavigationItemSelectedListener(this);
- _ContentPage = (LinearLayout) findViewById(R.id.content_layout);
- setWeekDateRange();
- loadScheduleFilter();
- createGuestSchedule();
- loadSchedule();
- }
- @Override
- public void onBackPressed() {
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
- } else {
- super.onBackPressed();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- @SuppressWarnings("StatementWithEmptyBody")
- @Override
- public boolean onNavigationItemSelected(MenuItem item) {
- // Handle navigation view item clicks here.
- int id = item.getItemId();
- if (id == R.id.nav_news) {
- loadNews();
- } else if (id == R.id.nav_schedule) {
- setWeekDateRange();
- loadScheduleFilter();
- createGuestSchedule();
- loadSchedule();
- } else if (id == R.id.nav_schedule_call) {
- } else if (id == R.id.nav_manage) {
- } else if (id == R.id.nav_send) {
- }
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- drawer.closeDrawer(GravityCompat.START);
- return true;
- }
- public void loadNews() {
- try {
- Link h = new Link();
- h.SetParameter("Limit", "20");
- h.SetParameter("Page", "0");
- JSONObject obj = h.POST("/news");
- if (obj == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Ошибка получения данных", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (obj.getString("Error").equals("null")) {
- _ContentPage.removeAllViewsInLayout();
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- // layoutParams.gravity = Gravity.FILL_HORIZONTAL;
- layoutParams.bottomMargin = 15;
- layoutParams.leftMargin = 0;
- layoutParams.rightMargin = 0;
- layoutParams.topMargin = 0;
- //
- // layoutParams2.bottomMargin = 0;
- // layoutParams2.leftMargin = 0;
- // layoutParams2.rightMargin = 0;
- // layoutParams2.topMargin = 0;
- JSONArray _news = obj.getJSONArray("News");
- Typeface face = ResourcesCompat.getFont(this, R.font.play_regular);
- for (int i = 0; i < _news.length(); i++) {
- JSONObject _n = _news.getJSONObject(i);
- LinearLayout field = new LinearLayout(this);
- field.setOrientation(LinearLayout.VERTICAL);
- field.setLayoutParams(layoutParams);
- field.setBackgroundColor(getResources().getColor(R.color.colorWhite));
- field.setPadding(10, 10, 10, 10);
- // field.setMinimumHeight(100);
- TextView _date = new TextView(this);
- _date.setText(_n.getString("Published"));
- _date.setTextColor(getResources().getColor(R.color.colorGray));
- _date.setTypeface(face);
- TextView _caption = new TextView(this);
- _caption.setLayoutParams(layoutParams2);
- _caption.setText(_n.getString("Caption") );
- _caption.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
- _caption.setTypeface(face);
- _caption.setTextSize(18);
- newsClick(field, _n.getString("Link"));
- field.addView(_date);
- field.addView(_caption);
- _ContentPage.addView(field);
- }
- }
- } catch (JSONException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- }
- private void newsClick(final LinearLayout fl, final String link) {
- fl.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Link h = new Link();
- try {
- JSONObject obj = h.POST("/mtl/"+link);
- if (obj == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Ошибка получения данных", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- Log.i("INFO", obj.toString());
- JSONObject _news = obj.getJSONObject("mtl");
- _ContentPage.removeAllViewsInLayout();
- WebView webView = new WebView(MainActivity.this);
- webView.loadDataWithBaseURL("http://ktk-45.ru/", getNewsHTML(_news.getString("Caption"), _news.getString("Content")), "text/html", "UTF-8", null);
- _ContentPage.addView(webView);
- } catch (JSONException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- }
- });
- }
- private String getNewsHTML(String caption, String content) {
- return cssStyle1 + caption + cssStyle2 + content + cssStyle3;
- }
- private static final String cssStyle1 = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><style type=\"text/css\">@font-face{font-family:'play';src:url(\"/assets/fonts/google/Play/Play-Regular.ttf\")} body{font-family:'play' !important;} p{text-indent:2.5em;text-align:justify;margin: 10px 0 10px 0;} .the-news-signature{font-style: italic;text-align: right;padding-top: 16px;} h1{text-align:center;font-size:18px;} hr{margin:20px 0;} a{pointer-events: none;} img{width:100%;} .text-center{text-align:center;} .text-right{text-align:right;}</style></head><body><h1>";
- private static final String cssStyle2 = "</h1>";
- private static final String cssStyle3 = "</body></html>";
- //
- // РАСПИСАНИЕ
- //
- public void loadSchedule() {
- }
- // Загрузка данных о подразделениях и группах
- private void loadScheduleFilter() {
- try {
- Link h = new Link();
- JSONObject obj = h.POST("/select/schedule-filter");
- if (obj == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Ошибка получения данных", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (obj.getString("Error").equals("null")) {
- if (_BranchCaption == null) {
- _BranchCaption = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
- }
- _BranchCaption.clear();
- _BranchCaption.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- if (_BranchHash == null) {
- _BranchHash = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
- }
- _BranchHash.clear();
- if (_Group == null) {
- _Group = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item);
- }
- _Group.clear();
- _Group.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- if (obj.isNull("Branch")) {
- Toast toast = Toast.makeText(getApplicationContext(),"Не удалось получить список подразделений!", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- JSONArray _list = obj.getJSONArray("Branch");
-
- for (int i = 0; i < _list.length(); i++) {
- _BranchCaption.add(_list.getJSONObject(i).getString("Caption"));
- _BranchHash.add(_list.getJSONObject(i).getString("Hash"));
- }
- if (obj.isNull("Data")) {
- Toast toast = Toast.makeText(getApplicationContext(),"Не удалось получить список групп!", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- _GroupList = obj.getJSONArray("Data");
- for (int i = 0; i < _GroupList.length(); i++) {
- JSONObject _groupObj = _GroupList.getJSONObject(i);
- if (_groupObj.getString("Branch").equals(_BranchHash.getItem(0))) {
- JSONArray _groups = _groupObj.getJSONArray("Groups");
- for (int j = 0; j < _groups.length(); j++) {
- _Group.add(_groups.getInt(j));
- }
- }
- }
- }
- } catch (JSONException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- }
- // Загрузка списка групп выбранного подразделения
- private void loadGroupList() {
- try {
- Link h = new Link();
- Spinner spinner = (Spinner) findViewById(_BranchSelectID);
- int id = (int)spinner.getSelectedItemId();
- h.SetParameter("Branch", _BranchHash.getItem(id));
- JSONObject obj = h.POST("/select/schedule-call");
- if (obj == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Ошибка получения данных", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (obj.getString("Error").equals("null")) {
- if (_Group == null) {
- _Group = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item);
- }
- _Group.clear();
- _Group.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- Log.i("INFO", obj.toString());
- // if (obj.isNull("Branch")) {
- // Toast toast = Toast.makeText(getApplicationContext(),"Не удалось получить список подразделений!", Toast.LENGTH_LONG);
- // toast.show();
- // return;
- // }
- // JSONArray _list = obj.getJSONArray("Branch");
- // for (int i = 0; i < _list.length(); i++) {
- // _Group.add(_list.getJSONObject(i).getString("Caption"));
- // }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- public void createGuestSchedule() {
- if (_BranchCaption == null) {
- // Сообразить сообщение об ошибке
- Toast toast = Toast.makeText(getApplicationContext(),"Список подразделений не был получен!", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (_Group == null) {
- Toast toast = Toast.makeText(getApplicationContext(),"Список групп не был получен!", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- // Для начала нужно сформировать основную форму с фильтрами
- final Typeface face = ResourcesCompat.getFont(this, R.font.play_bold);
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- layoutParams.bottomMargin = 20;
- layoutParams.leftMargin = 0;
- layoutParams.rightMargin = 0;
- layoutParams.topMargin = 0;
- _ContentPage.removeAllViewsInLayout();
- TextView textViewBranchCaption = new TextView(this);
- textViewBranchCaption.setText(R.string.branch_label);
- textViewBranchCaption.setTypeface(face);
- _ContentPage.addView(textViewBranchCaption);
- Spinner selectBranch = new Spinner(this);
- _BranchSelectID = View.generateViewId();
- selectBranch.setId(_BranchSelectID);
- selectBranch.setAdapter(_BranchCaption);
- selectBranch.setLayoutParams(layoutParams);
- // Событие выбора подразделения
- selectBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- _Group.clear();
- try {
- for (int i = 0; i < _GroupList.length(); i++) {
- JSONObject _groupObj = _GroupList.getJSONObject(i);
- if (_groupObj.getString("Branch").equals(_BranchHash.getItem(position))) {
- JSONArray _groups = _groupObj.getJSONArray("Groups");
- for (int j = 0; j < _groups.length(); j++) {
- _Group.add(_groups.getInt(j));
- }
- }
- }
- Spinner spinner = (Spinner) findViewById(_GroupSelectID);
- spinner.setAdapter(_Group);
- } catch (JSONException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
- _ContentPage.addView(selectBranch);
- TextView textViewGroupCaption = new TextView(this);
- textViewGroupCaption.setText(R.string.group_label);
- textViewGroupCaption.setTypeface(face);
- _ContentPage.addView(textViewGroupCaption);
- Spinner selectGroup = new Spinner(this);
- _GroupSelectID = View.generateViewId();
- selectGroup.setId(_GroupSelectID);
- selectGroup.setLayoutParams(layoutParams);
- selectGroup.setAdapter(_Group);
- selectGroup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- int selectedGroup = 0;
- try {
- selectedGroup = _Group.getItem(position);
- } catch (NullPointerException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- try {
- Spinner spinner = (Spinner) findViewById(_BranchSelectID);
- Date date = new Date();
- Link h = new Link();
- h.SetParameter("Branch", _BranchHash.getItem((int)spinner.getSelectedItemId()));
- h.SetParameter("Group", ""+selectedGroup);
- if (_DateIsString[0] != null) {
- h.SetParameter("FirstDate", _DateIsString[0]);
- } else {
- setWeekDateRange();
- h.SetParameter("FirstDate", _DateIsString[0]);
- }
- if (_DateIsString[1] != null) {
- h.SetParameter("LastDate", _DateIsString[1]);
- } else {
- setWeekDateRange();
- h.SetParameter("LastDate", _DateIsString[1]);
- }
- JSONObject obj = h.POST("/select/schedule-group");
- if (obj == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Ошибка получения данных", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (!obj.getString("Error").equals("null")) {
- Toast toast = Toast.makeText(getApplicationContext(), obj.getString("Error"), Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- if (obj.isNull("Data")) {
- Toast toast = Toast.makeText(getApplicationContext(), "Данные расписания выбранной группы/даты отсутствуют в базе", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- JSONArray _sch = obj.getJSONArray("Data");
- prevDate = "";
- LinearLayout schLayout = (LinearLayout)findViewById(_ScheduleLayoutID);
- if (schLayout == null) {
- Toast toast = Toast.makeText(getApplicationContext(), "Не найден слой для создания расписания", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- schLayout.removeAllViewsInLayout();
- for (int i = 0; i < _sch.length(); i++) {
- JSONObject _currentPair = _sch.getJSONObject(i);
- String _currentDay = _currentPair.getString("Date");
- if (!prevDate.equals(_currentDay)) {
- schLayout.addView(createDateRow(_currentDay));
- prevDate = _currentDay;
- }
- String _subgroup = _currentPair.getString("Subgroup");
- switch (_subgroup) {
- case "left":
- if (i+1 < _sch.length()) {
- JSONObject _next = _sch.getJSONObject(i+1);
- if (_currentPair.getString("Pair").equals(_next.getString("Pair")) &&
- _next.getString("Subgroup").equals("right")) {
- schLayout.addView(createBoth(_currentPair, _next));
- i++;
- } else {
- schLayout.addView(createLeft(_currentPair));
- }
- }
- break;
- case "middle":
- schLayout.addView(createMiddle(_currentPair));
- break;
- case "right":
- schLayout.addView(createRight(_currentPair));
- break;
- default: continue;
- }
- // schLayout.addView(pushSchedulePair(_sch.getJSONObject(i)));
- }
- } catch (JSONException e) {
- Toast toast = Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
- _ContentPage.addView(selectGroup);
- final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
- _Calendar.set(Calendar.YEAR, year);
- _Calendar.set(Calendar.MONTH, month);
- _Calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- if (_DateSetup == null) {
- Toast toast = Toast.makeText(getApplicationContext(),"Нет элемента для установки даты!", Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- _DateSetup.setText(_DateFormat.format(_Calendar.getTime()));
- _DateIsString[_DateIs] = _DateQueryFormat.format(_Calendar.getTime());
- }
- };
- LinearLayout.LayoutParams layoutParamsDate = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- layoutParamsDate.weight = 0.5f;
- LinearLayout _llDate = new LinearLayout(this);
- _llDate.setOrientation(LinearLayout.VERTICAL);
- LinearLayout _llDateCaption = new LinearLayout(this);
- _llDateCaption.setOrientation(LinearLayout.HORIZONTAL);
- LinearLayout _llDateDate = new LinearLayout(this);
- _llDateDate.setOrientation(LinearLayout.HORIZONTAL);
- TextView _tvCaption1 = new TextView(this);
- TextView _tvCaption2 = new TextView(this);
- _tvCaption1.setTypeface(face);
- _tvCaption2.setTypeface(face);
- _tvCaption1.setText("Дата с:");
- _tvCaption2.setText("по:");
- _tvCaption1.setLayoutParams(layoutParamsDate);
- _tvCaption2.setLayoutParams(layoutParamsDate);
- EditText _etDate1 = new EditText(this);
- _etDate1.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE);
- _etDate1.setLayoutParams(layoutParamsDate);
- _etDate1.setTypeface(face);
- _etDate1.setFocusable(false);
- _etDate1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- _DateSetup = (EditText)v;
- _DateIs = 0;
- new DatePickerDialog(MainActivity.this, date,
- _Calendar.get(Calendar.YEAR),
- _Calendar.get(Calendar.MONTH),
- _Calendar.get(Calendar.DAY_OF_MONTH)).show();
- }
- });
- _etDate1.setText(_DateFormat.format(_CalendarMon.getTime()));
- EditText _etDate2 = new EditText(this);
- _etDate2.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE);
- _etDate2.setLayoutParams(layoutParamsDate);
- _etDate2.setTypeface(face);
- _etDate2.setFocusable(false);
- _etDate2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- _DateSetup = (EditText)v;
- _DateIs = 1;
- new DatePickerDialog(MainActivity.this, date,
- _Calendar.get(Calendar.YEAR),
- _Calendar.get(Calendar.MONTH),
- _Calendar.get(Calendar.DAY_OF_MONTH)).show();
- }
- });
- _etDate2.setText(_DateFormat.format(_CalendarSat.getTime()));
- _llDateCaption.addView(_tvCaption1);
- _llDateCaption.addView(_tvCaption2);
- _llDateDate.addView(_etDate1);
- _llDateDate.addView(_etDate2);
- _llDate.addView(_llDateCaption);
- _llDate.addView(_llDateDate);
- _ContentPage.addView(_llDate);
- LinearLayout.LayoutParams layoutParamsSch = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- LinearLayout _llSch = new LinearLayout(this);
- _llSch.setOrientation(LinearLayout.VERTICAL);
- _llSch.setLayoutParams(layoutParamsSch);
- _ScheduleLayoutID = View.generateViewId();
- _llSch.setId(_ScheduleLayoutID);
- _ContentPage.addView(_llSch);
- }
- // Установить в элементы Date1 & Date2 диапозон текущей недели
- private void setWeekDateRange() {
- /*
- * 1 Воскресенье 0
- * 2 Понедельник 1
- * 3 Вторник 2
- * 4 Среда 3
- * 5 Четверг 4
- * 6 Пятница 5
- * 7 Суббота 6
- *
- * */
- int IDayToFirstWeedDay[] = {
- 1,
- 0,
- -1,
- -2,
- -3,
- -4,
- 0,
- };
- int IDayToLastWeedDay[] = {
- 6,
- 5,
- 4,
- 3,
- 2,
- 1,
- 7,
- };
- int _day = _Calendar.get(Calendar.DAY_OF_WEEK) - 1;
- _CalendarMon.setTimeInMillis((new Date()).getTime() + (86400000 * IDayToFirstWeedDay[_day]));
- int _date = _CalendarMon.get(Calendar.DAY_OF_MONTH);
- int _month = _CalendarMon.get(Calendar.MONTH) + 1;
- int _year = _CalendarMon.get(Calendar.YEAR);
- _DateIsString[0] = "" + _year + "-" + _month + "-" + (_date > 9 ? _date : "0" + _date);
- _CalendarSat.setTimeInMillis((new Date()).getTime() + (86400000 * IDayToLastWeedDay[_day]));
- _date = _CalendarSat.get(Calendar.DAY_OF_MONTH);
- _month = _CalendarSat.get(Calendar.MONTH) + 1;
- _year = _CalendarSat.get(Calendar.YEAR);
- _DateIsString[1] = "" + _year + "-" + _month + "-" + (_date > 9 ? _date : "0" + _date);
- }
- private String _DayName[] = {
- "Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота",
- };
- private String _MonthName[] = {
- " января ", " февраля ", " марта ", " апреля ", " июня ", " июля ", " августа ", " сентября ", " октября ", " ноября ", " декабря ",
- };
- private String prevDate = "";
- private LinearLayout createDateRow(String dateStr) {
- LinearLayout _ll_day = new LinearLayout(this);
- _ll_day.setOrientation(LinearLayout.VERTICAL);
- TextView _tv_day = new TextView(this);
- final Typeface faceReg = ResourcesCompat.getFont(this, R.font.play_regular);
- TableRow.LayoutParams _lp_day = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_day.weight = 1;
- _lp_day.topMargin = 20;
- String _currentDay = "";
- String __date[] = dateStr.split("-");
- try {
- _currentDay = __date[2].split("T")[0] + _MonthName[Integer.parseInt(__date[1]) - 1] + __date[0];
- } catch (NumberFormatException e) {
- _currentDay = __date[2].split("T")[0] + "-" + __date[1] + "-" + __date[0];
- }
- _tv_day.setText(_currentDay);
- _tv_day.setTypeface(faceReg);
- _tv_day.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
- _tv_day.setLayoutParams(_lp_day);
- _tv_day.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_day.setBackgroundColor(getResources().getColor(R.color.colorSchHead));
- _tv_day.setTextColor(getResources().getColor(R.color.colorWhite));
- LinearLayout.LayoutParams _llpd = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- _llpd.weight = 1;
- _ll_day.setLayoutParams(_llpd);
- // = = = = = = = = = = = = = = = = =
- _ll_day.addView(_tv_day);
- return _ll_day;
- }
- // Строка расписания Middle
- private LinearLayout createMiddle(JSONObject data) throws JSONException {
- LinearLayout _pair_row = new LinearLayout(this);
- LinearLayout _ll_pair = new LinearLayout(this);
- LinearLayout _ll_desc = new LinearLayout(this);
- LinearLayout _ll_disc = new LinearLayout(this);
- LinearLayout _ll_lect = new LinearLayout(this);
- _pair_row.setOrientation(LinearLayout.VERTICAL);
- _ll_disc.setOrientation(LinearLayout.VERTICAL);
- _ll_lect.setOrientation(LinearLayout.VERTICAL);
- _ll_pair.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc.setOrientation(LinearLayout.HORIZONTAL);
- TextView _tv_day = new TextView(this);
- TextView _tv_pair = new TextView(this);
- TextView _tv_disc = new TextView(this);
- TextView _tv_teacher = new TextView(this);
- TextView _tv_lect = new TextView(this);
- final Typeface faceReg = ResourcesCompat.getFont(this, R.font.play_regular);
- TableRow.LayoutParams _lp_pair = new TableRow.LayoutParams(40, TableRow.LayoutParams.MATCH_PARENT);
- _tv_pair.setText(data.getString("Pair"));
- _tv_pair.setTypeface(faceReg);
- _tv_pair.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_pair.setLayoutParams(_lp_pair);
- _tv_pair.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_pair.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_lect = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_lect.weight = 1;
- _tv_lect.setText(data.getString("Lecture"));
- _tv_lect.setTypeface(faceReg);
- _tv_lect.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_lect.setLayoutParams(_lp_lect);
- // _tv_lect.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_lect.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_lect.setGravity(Gravity.CENTER | Gravity.END);
- TableRow.LayoutParams _lp_disc = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_disc.weight = 1;
- _tv_disc.setText(data.getString("Discipline"));
- _tv_disc.setTypeface(faceReg);
- _tv_disc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_disc.setLayoutParams(_lp_disc);
- _tv_disc.setHeight(52);
- _tv_disc.setShadowLayer(5, 0, 0, R.color.colorBlack);
- _tv_disc.setTextColor(getResources().getColor(R.color.colorBlack));
- TableRow.LayoutParams _lp_teacher = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_teacher.weight = 1;
- _tv_teacher.setText(data.getString("Teacher"));
- _tv_teacher.setTypeface(faceReg, Typeface.ITALIC);
- _tv_teacher.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- _tv_teacher.setLayoutParams(_lp_teacher);
- _tv_teacher.setTextColor(getResources().getColor(R.color.colorTeacher));
- LinearLayout.LayoutParams _llpdi = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdi.weight = 1;
- _ll_disc.setLayoutParams(_llpdi);
- LinearLayout.LayoutParams _llpp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpp.weight = 1;
- _ll_pair.setLayoutParams(_llpp);
- _ll_pair.setBackground(getResources().getDrawable(R.drawable.shcedule_background));
- LinearLayout.LayoutParams _llpds = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpds.weight = 1;
- _llpds.setMargins(4, 4, 4, 4);
- _ll_desc.setLayoutParams(_llpds);
- _ll_desc.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpl = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpl.weight = 5;
- _ll_lect.setLayoutParams(_llpl);
- LinearLayout.LayoutParams _llpd = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- _llpd.weight = 1;
- _pair_row.setLayoutParams(_llpd);
- // = = = = = = = = = = = = = = = = =
- _ll_lect.addView(_tv_lect);
- _ll_disc.addView(_tv_disc);
- _ll_disc.addView(_tv_teacher);
- _ll_desc.addView(_ll_disc);
- _ll_desc.addView(_ll_lect);
- _ll_pair.addView(_tv_pair);
- _ll_pair.addView(_ll_desc);
- _pair_row.addView(_ll_pair);
- return _pair_row;
- }
- // Строка расписания Left
- private LinearLayout createLeft(JSONObject data) throws JSONException {
- LinearLayout _pair_row = new LinearLayout(this);
- LinearLayout _ll_pair = new LinearLayout(this);
- LinearLayout _ll_desc = new LinearLayout(this);
- LinearLayout _ll_desc_null = new LinearLayout(this);
- LinearLayout _ll_disc = new LinearLayout(this);
- LinearLayout _ll_lect = new LinearLayout(this);
- _pair_row.setOrientation(LinearLayout.VERTICAL);
- _ll_disc.setOrientation(LinearLayout.VERTICAL);
- _ll_lect.setOrientation(LinearLayout.VERTICAL);
- _ll_pair.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc_null.setOrientation(LinearLayout.HORIZONTAL);
- TextView _tv_day = new TextView(this);
- TextView _tv_pair = new TextView(this);
- TextView _tv_disc = new TextView(this);
- TextView _tv_teacher = new TextView(this);
- TextView _tv_lect = new TextView(this);
- final Typeface faceReg = ResourcesCompat.getFont(this, R.font.play_regular);
- TableRow.LayoutParams _lp_pair = new TableRow.LayoutParams(40, TableRow.LayoutParams.MATCH_PARENT);
- _tv_pair.setText(data.getString("Pair"));
- _tv_pair.setTypeface(faceReg);
- _tv_pair.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_pair.setLayoutParams(_lp_pair);
- _tv_pair.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_pair.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_lect = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_lect.weight = 1;
- _tv_lect.setText(data.getString("Lecture"));
- _tv_lect.setTypeface(faceReg);
- _tv_lect.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_lect.setLayoutParams(_lp_lect);
- // _tv_lect.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_lect.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_lect.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_disc = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_disc.weight = 1;
- _tv_disc.setText(data.getString("Discipline"));
- _tv_disc.setTypeface(faceReg);
- _tv_disc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_disc.setLayoutParams(_lp_disc);
- _tv_disc.setHeight(52);
- _tv_disc.setShadowLayer(5, 0, 0, R.color.colorBlack);
- _tv_disc.setTextColor(getResources().getColor(R.color.colorBlack));
- TableRow.LayoutParams _lp_teacher = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_teacher.weight = 1;
- _tv_teacher.setText(data.getString("Teacher"));
- _tv_teacher.setTypeface(faceReg, Typeface.ITALIC);
- _tv_teacher.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- _tv_teacher.setLayoutParams(_lp_teacher);
- _tv_teacher.setTextColor(getResources().getColor(R.color.colorTeacher));
- LinearLayout.LayoutParams _llpdi = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdi.weight = 1;
- _ll_disc.setLayoutParams(_llpdi);
- LinearLayout.LayoutParams _llpp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpp.weight = 1;
- _ll_pair.setLayoutParams(_llpp);
- _ll_pair.setBackground(getResources().getDrawable(R.drawable.shcedule_background));
- LinearLayout.LayoutParams _llpds = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpds.weight = 1;
- _llpds.setMargins(4, 4, 2, 4);
- _ll_desc.setLayoutParams(_llpds);
- _ll_desc.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpdsn = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdsn.weight = 1;
- _llpdsn.setMargins(2, 4, 4, 4);
- _ll_desc_null.setLayoutParams(_llpds);
- _ll_desc_null.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc_null.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpl = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpl.weight = 5;
- _ll_lect.setLayoutParams(_llpl);
- LinearLayout.LayoutParams _llpd = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- _llpd.weight = 1;
- _pair_row.setLayoutParams(_llpd);
- // = = = = = = = = = = = = = = = = =
- _ll_lect.addView(_tv_lect);
- _ll_disc.addView(_tv_disc);
- _ll_disc.addView(_tv_teacher);
- _ll_desc.addView(_ll_disc);
- _ll_desc.addView(_ll_lect);
- _ll_pair.addView(_tv_pair);
- _ll_pair.addView(_ll_desc);
- _ll_pair.addView(_ll_desc_null);
- _pair_row.addView(_ll_pair);
- return _pair_row;
- }
- // Строка расписания Right
- private LinearLayout createRight(JSONObject data) throws JSONException {
- LinearLayout _pair_row = new LinearLayout(this);
- LinearLayout _ll_pair = new LinearLayout(this);
- LinearLayout _ll_desc = new LinearLayout(this);
- LinearLayout _ll_desc_null = new LinearLayout(this);
- LinearLayout _ll_disc = new LinearLayout(this);
- LinearLayout _ll_lect = new LinearLayout(this);
- _pair_row.setOrientation(LinearLayout.VERTICAL);
- _ll_disc.setOrientation(LinearLayout.VERTICAL);
- _ll_lect.setOrientation(LinearLayout.VERTICAL);
- _ll_pair.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc_null.setOrientation(LinearLayout.HORIZONTAL);
- TextView _tv_day = new TextView(this);
- TextView _tv_pair = new TextView(this);
- TextView _tv_disc = new TextView(this);
- TextView _tv_teacher = new TextView(this);
- TextView _tv_lect = new TextView(this);
- final Typeface faceReg = ResourcesCompat.getFont(this, R.font.play_regular);
- TableRow.LayoutParams _lp_pair = new TableRow.LayoutParams(40, TableRow.LayoutParams.MATCH_PARENT);
- _tv_pair.setText(data.getString("Pair"));
- _tv_pair.setTypeface(faceReg);
- _tv_pair.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_pair.setLayoutParams(_lp_pair);
- _tv_pair.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_pair.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_lect = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_lect.weight = 1;
- _tv_lect.setText(data.getString("Lecture"));
- _tv_lect.setTypeface(faceReg);
- _tv_lect.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_lect.setLayoutParams(_lp_lect);
- // _tv_lect.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_lect.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_lect.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_disc = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_disc.weight = 1;
- _tv_disc.setText(data.getString("Discipline"));
- _tv_disc.setTypeface(faceReg);
- _tv_disc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_disc.setLayoutParams(_lp_disc);
- _tv_disc.setHeight(52);
- _tv_disc.setShadowLayer(5, 0, 0, R.color.colorBlack);
- _tv_disc.setTextColor(getResources().getColor(R.color.colorBlack));
- TableRow.LayoutParams _lp_teacher = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_teacher.weight = 1;
- _tv_teacher.setText(data.getString("Teacher"));
- _tv_teacher.setTypeface(faceReg, Typeface.ITALIC);
- _tv_teacher.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- _tv_teacher.setLayoutParams(_lp_teacher);
- _tv_teacher.setTextColor(getResources().getColor(R.color.colorTeacher));
- LinearLayout.LayoutParams _llpdi = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdi.weight = 1;
- _ll_disc.setLayoutParams(_llpdi);
- LinearLayout.LayoutParams _llpp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpp.weight = 1;
- _ll_pair.setLayoutParams(_llpp);
- _ll_pair.setBackground(getResources().getDrawable(R.drawable.shcedule_background));
- LinearLayout.LayoutParams _llpds = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpds.weight = 1;
- _llpds.setMargins(4, 4, 2, 4);
- _ll_desc.setLayoutParams(_llpds);
- _ll_desc.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpdsn = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdsn.weight = 1;
- _llpdsn.setMargins(2, 4, 4, 4);
- _ll_desc_null.setLayoutParams(_llpds);
- _ll_desc_null.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc_null.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpl = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpl.weight = 5;
- _ll_lect.setLayoutParams(_llpl);
- LinearLayout.LayoutParams _llpd = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- _llpd.weight = 1;
- _pair_row.setLayoutParams(_llpd);
- // = = = = = = = = = = = = = = = = =
- _ll_lect.addView(_tv_lect);
- _ll_disc.addView(_tv_disc);
- _ll_disc.addView(_tv_teacher);
- _ll_desc.addView(_ll_disc);
- _ll_desc.addView(_ll_lect);
- _ll_pair.addView(_tv_pair);
- _ll_pair.addView(_ll_desc_null);
- _ll_pair.addView(_ll_desc);
- _pair_row.addView(_ll_pair);
- return _pair_row;
- }
- // Строка расписания Both
- private LinearLayout createBoth(JSONObject dataL, JSONObject dataR) throws JSONException {
- LinearLayout _pair_row = new LinearLayout(this);
- LinearLayout _ll_pair = new LinearLayout(this);
- LinearLayout _ll_desc = new LinearLayout(this);
- LinearLayout _ll_desc_r = new LinearLayout(this);
- LinearLayout _ll_disc = new LinearLayout(this);
- LinearLayout _ll_disc_r = new LinearLayout(this);
- LinearLayout _ll_lect = new LinearLayout(this);
- LinearLayout _ll_lect_r = new LinearLayout(this);
- _pair_row.setOrientation(LinearLayout.VERTICAL);
- _ll_disc.setOrientation(LinearLayout.VERTICAL);
- _ll_lect.setOrientation(LinearLayout.VERTICAL);
- _ll_disc_r.setOrientation(LinearLayout.VERTICAL);
- _ll_lect_r.setOrientation(LinearLayout.VERTICAL);
- _ll_pair.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc.setOrientation(LinearLayout.HORIZONTAL);
- _ll_desc_r.setOrientation(LinearLayout.HORIZONTAL);
- TextView _tv_day = new TextView(this);
- TextView _tv_pair = new TextView(this);
- TextView _tv_disc = new TextView(this);
- TextView _tv_teacher = new TextView(this);
- TextView _tv_lect = new TextView(this);
- TextView _tv_disc_r = new TextView(this);
- TextView _tv_teacher_r = new TextView(this);
- TextView _tv_lect_r = new TextView(this);
- final Typeface faceReg = ResourcesCompat.getFont(this, R.font.play_regular);
- TableRow.LayoutParams _lp_pair = new TableRow.LayoutParams(40, TableRow.LayoutParams.MATCH_PARENT);
- _tv_pair.setText(dataL.getString("Pair"));
- _tv_pair.setTypeface(faceReg);
- _tv_pair.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_pair.setLayoutParams(_lp_pair);
- _tv_pair.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_pair.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_lect = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_lect.weight = 1;
- _tv_lect.setText(dataL.getString("Lecture"));
- _tv_lect.setTypeface(faceReg);
- _tv_lect.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_lect.setLayoutParams(_lp_lect);
- // _tv_lect.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_lect.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_lect.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_lect_r = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_lect_r.weight = 1;
- _tv_lect_r.setText(dataL.getString("Lecture"));
- _tv_lect_r.setTypeface(faceReg);
- _tv_lect_r.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_lect_r.setLayoutParams(_lp_lect_r);
- // _tv_lect_r.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- _tv_lect_r.setTextColor(getResources().getColor(R.color.colorBlack));
- _tv_lect_r.setGravity(Gravity.CENTER);
- TableRow.LayoutParams _lp_disc = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_disc.weight = 1;
- _tv_disc.setText(dataL.getString("Discipline"));
- _tv_disc.setTypeface(faceReg);
- _tv_disc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_disc.setLayoutParams(_lp_disc);
- _tv_disc.setHeight(52);
- _tv_disc.setShadowLayer(5, 0, 0, R.color.colorBlack);
- _tv_disc.setTextColor(getResources().getColor(R.color.colorBlack));
- TableRow.LayoutParams _lp_disc_r = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_disc_r.weight = 1;
- _tv_disc_r.setText(dataL.getString("Discipline"));
- _tv_disc_r.setTypeface(faceReg);
- _tv_disc_r.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- _tv_disc_r.setLayoutParams(_lp_disc_r);
- _tv_disc_r.setHeight(52);
- _tv_disc_r.setShadowLayer(5, 0, 0, R.color.colorBlack);
- _tv_disc_r.setTextColor(getResources().getColor(R.color.colorBlack));
- TableRow.LayoutParams _lp_teacher = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_teacher.weight = 1;
- _tv_teacher.setText(dataL.getString("Teacher"));
- _tv_teacher.setTypeface(faceReg, Typeface.ITALIC);
- _tv_teacher.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- _tv_teacher.setLayoutParams(_lp_teacher);
- _tv_teacher.setTextColor(getResources().getColor(R.color.colorTeacher));
- TableRow.LayoutParams _lp_teacher_r = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
- _lp_teacher_r.weight = 1;
- _tv_teacher_r.setText(dataL.getString("Teacher"));
- _tv_teacher_r.setTypeface(faceReg, Typeface.ITALIC);
- _tv_teacher_r.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
- _tv_teacher_r.setLayoutParams(_lp_teacher_r);
- _tv_teacher_r.setTextColor(getResources().getColor(R.color.colorTeacher));
- LinearLayout.LayoutParams _llpdi = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdi.weight = 1;
- _ll_disc.setLayoutParams(_llpdi);
- LinearLayout.LayoutParams _llpdi_r = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdi_r.weight = 1;
- _ll_disc_r.setLayoutParams(_llpdi_r);
- LinearLayout.LayoutParams _llpp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpp.weight = 1;
- _ll_pair.setLayoutParams(_llpp);
- _ll_pair.setBackground(getResources().getDrawable(R.drawable.shcedule_background));
- LinearLayout.LayoutParams _llpds = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpds.weight = 1;
- _llpds.setMargins(4, 4, 2, 4);
- _ll_desc.setLayoutParams(_llpds);
- _ll_desc.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpdsn = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpdsn.weight = 1;
- _llpdsn.setMargins(2, 4, 4, 4);
- _ll_desc_r.setLayoutParams(_llpds);
- _ll_desc_r.setBackground(getResources().getDrawable(R.drawable.schedulet_discipline));
- _ll_desc_r.setPadding(4, 4, 4, 4);
- LinearLayout.LayoutParams _llpl = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpl.weight = 5;
- _ll_lect.setLayoutParams(_llpl);
- LinearLayout.LayoutParams _llpl_r = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- _llpl_r.weight = 5;
- _ll_lect_r.setLayoutParams(_llpl);
- LinearLayout.LayoutParams _llpd = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
- _llpd.weight = 1;
- _pair_row.setLayoutParams(_llpd);
- // = = = = = = = = = = = = = = = = =
- _ll_lect.addView(_tv_lect);
- _ll_disc.addView(_tv_disc);
- _ll_disc.addView(_tv_teacher);
- _ll_desc.addView(_ll_disc);
- _ll_desc.addView(_ll_lect);
- _ll_lect_r.addView(_tv_lect_r);
- _ll_disc_r.addView(_tv_disc_r);
- _ll_disc_r.addView(_tv_teacher_r);
- _ll_desc_r.addView(_ll_disc_r);
- _ll_desc_r.addView(_ll_lect_r);
- _ll_pair.addView(_tv_pair);
- _ll_pair.addView(_ll_desc);
- _ll_pair.addView(_ll_desc_r);
- _pair_row.addView(_ll_pair);
- return _pair_row;
- }
- }
|