Advertisement
Guest User

WireList

a guest
Jan 23rd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 43.90 KB | None | 0 0
  1. package com.tni.mo;
  2.  
  3. import android.app.AlertDialog;
  4. import android.app.ProgressDialog;
  5. import android.content.Context;
  6. import android.content.DialogInterface;
  7. import android.content.Intent;
  8. import android.database.Cursor;
  9. import android.graphics.Color;
  10. import android.graphics.Point;
  11. import android.graphics.Typeface;
  12. import android.net.ConnectivityManager;
  13. import android.net.NetworkInfo;
  14. import android.os.AsyncTask;
  15. import android.os.Bundle;
  16. import android.provider.Settings;
  17. import android.support.v7.app.ActionBar;
  18. import android.support.v7.widget.DividerItemDecoration;
  19. import android.support.v7.widget.LinearLayoutManager;
  20. import android.support.v7.widget.RecyclerView;
  21. import android.support.v7.widget.Toolbar;
  22. import android.text.SpannableString;
  23. import android.text.Spanned;
  24. import android.text.format.Time;
  25. import android.util.DisplayMetrics;
  26. import android.view.Display;
  27. import android.view.Gravity;
  28. import android.view.View;
  29. import android.view.View.OnClickListener;
  30. import android.view.ViewGroup;
  31. import android.widget.AdapterView;
  32. import android.widget.AdapterView.OnItemSelectedListener;
  33. import android.widget.ArrayAdapter;
  34. import android.widget.Button;
  35. import android.widget.CheckBox;
  36. import android.widget.EditText;
  37. import android.widget.Filter;
  38. import android.widget.Filterable;
  39. import android.widget.ImageView;
  40. import android.widget.LinearLayout;
  41. import android.widget.LinearLayout.LayoutParams;
  42. import android.widget.ListView;
  43. import android.widget.PopupWindow;
  44. import android.widget.ProgressBar;
  45. import android.widget.RelativeLayout;
  46. import android.widget.ScrollView;
  47. import android.widget.SearchView;
  48. import android.widget.Spinner;
  49. import android.widget.TextView;
  50. import android.widget.Toast;
  51.  
  52. import com.google.api.client.http.HttpResponse;
  53. import com.tni.mo.Adapter.WireListAdapter;
  54. import com.tni.mo.R;
  55.  
  56. import org.apache.http.HttpEntity;
  57. import org.apache.http.entity.StringEntity;
  58. import org.apache.http.protocol.HTTP;
  59. import org.apache.http.util.EntityUtils;
  60. import org.json.JSONArray;
  61. import org.json.JSONObject;
  62. import org.ksoap2.serialization.SoapObject;
  63.  
  64. import java.text.SimpleDateFormat;
  65. import java.util.ArrayList;
  66. import java.util.Calendar;
  67. import java.util.LinkedHashMap;
  68. import java.util.List;
  69. import java.util.Timer;
  70.  
  71. import pl.polidea.view.ZoomView;
  72.  
  73. public class WireList extends BaseActivity implements WireListAdapter.WireListAdapterListiner{
  74.     final Context context = this;
  75.  
  76.     WireListAdapter adapterwire;
  77.  
  78.     ZoomView zoom;
  79.  
  80.     LinearLayout _center10, _centerMain1, _masterLayout, _center, _center1,
  81.             _center2, _headerIconLayout, _headerSettingLayout,
  82.             _wordCountLayout, _filterType, _backLayout, _SynkLayout;
  83.  
  84.     ListView listView;
  85.  
  86.  
  87.     RelativeLayout _subMaster, _header, _centerTop, _bottom, heading_header;
  88.     LinearLayout _ListTypeLayout;
  89.  
  90.     RelativeLayout.LayoutParams _headerparams, _centerparams, _bottomParams,
  91.             paramsIcon, paramsSetting, _listtypeRule, _filterTypeRule,
  92.             _wordcountRule, _centerTopRule, _backButtonRule, _synkdateRule;
  93.  
  94.     ScrollView _centerScroller;
  95.  
  96.     TextView _wordCountCation, _headingCap, _statusCap, _dateCap,
  97.             _uploadstatusCap, _storyidCap, Story_uni, _supporttext, _LoginUser,
  98.             _synkDate, _pageCaption; // _keywordsCaption,_sourceCaption,_categoryCaption,_wordCountCation,_supporttext,_imageCaption;
  99.  
  100.     EditText _headingText, _locationText, _storyText, _bylineText,
  101.             _tagnameText, _keywordsText, _sourceText, _wordCountText,
  102.             _imageText;
  103.  
  104.     ImageView _Submit, _Clear, _menuIcon, _settingIcon, upload, imageA,
  105.             imageView1, imageViewNew, _backIcon;
  106.  
  107.     CheckBox _dBreaking, _dHome, _dTicker;
  108.  
  109.     RecyclerView recyclerlist;
  110.  
  111.     Button _attachment;
  112.  
  113.     Timer _tempsave = new Timer();
  114.  
  115.     View ruler, _view;
  116.  
  117.     List<WireListData> dataList;
  118.  
  119.     int _height, _width;
  120.     int _headerHeight, _cenerHeight, _spinnerHeight;
  121.     int _headCapwidth = 0, _headCapHeight = 0, _storyTextHeight = 0,
  122.             _widthHeaderIcon = 0, _wordcountWidth = 0, _imageWidth = 0,
  123.             _imageHeight = 0, _listtypewidth = 0, _keyboardWidth = 0;
  124.     int marginTop = 0;
  125.     int dropdownwidth = 0;
  126.     int imageHeight = 0;
  127.     int textSize = 0, _listContent = 0, _contentSize = 0;
  128.     int carapp = 0, carapp1 = 0;
  129.     int cursorposition = 0;
  130.     int _startPos = 0;
  131.     int keytype = 0;
  132.     int refreshbutton = 0;
  133.  
  134.     int _lheadingWidth = 0, _lstatusWidth = 0, _ldateWidth = 0,
  135.             _luploadWidth = 0;
  136.  
  137.     boolean back_flag = false, specialkeyPressed_flag = false, spchar1 = false,
  138.             spchar2 = false;
  139.  
  140.     char matra, backcar;
  141.  
  142.     // keybord layout
  143.     TextView _keyboardCaption,viewmore;
  144.     Spinner _spinAssetType, _spinFilter;
  145.     int searchwidth;
  146.     int morewidth;
  147.  
  148.     Typeface face;
  149.     Typeface faceCaption;
  150.     Globals g1 = Globals.getInstance();
  151.  
  152.     // login details variables
  153.     String _empcode, _centercode, _deskcode, _username, _password, _groupcode,
  154.             _displayname, _languagecode, _keybordType;
  155.  
  156.     // form inpu values
  157.     String _dbreakingValue = "0";
  158.     String _dhomeValue = "0";
  159.     String _dtickerValue = "0";
  160.  
  161.     // forTempSave
  162.     String _storyCode = "";
  163.  
  164.     String flag = "off";
  165.  
  166.     String assetType = "Story";
  167.     int filterType = 0;
  168.  
  169.     int mu = 0;
  170.  
  171.     // /popup window
  172.     PopupWindow spopUp;
  173.     Point point;
  174.     Boolean flagpopw = true;
  175.     Boolean flag1 = true;
  176.  
  177.     LinearLayout sv;
  178.     LinearLayout llc2;
  179.     ArrayAdapter adapterlist;
  180.  
  181.     // end tempsave
  182.     connection con = connection.getInstance(this);
  183.     JSONParser parsor = new JSONParser();
  184.  
  185.     private ArrayList<String> listId = new ArrayList<String>();
  186.     private ArrayList<String> listHead1 = new ArrayList<String>();
  187.     private ArrayList<String> listStr1 = new ArrayList<String>();
  188.     private ArrayList<String> listDt = new ArrayList<String>();
  189.  
  190.     ArrayList<String> storytime = new ArrayList<String>();
  191.     private ArrayList<String> languageCodes = new ArrayList<String>();
  192.  
  193.     //String options1[] = { "BSS Bangla","BSS English","AFP","Reuters" };
  194.     int count = 0;
  195.     int flagch = 0;
  196.     boolean flagcheck = true;
  197.     boolean deviceType;
  198.  
  199.     public void setLoginData() {
  200.         _empcode = g1.empcode;
  201.         _centercode = g1.centercode;
  202.         _deskcode = g1.deskcode;
  203.         _username = g1.username;
  204.         _password = g1.password;
  205.         _groupcode = g1.groupcode;
  206.         _displayname = g1.displayname;
  207.         _languagecode = g1.languagecode;
  208.         _keybordType = g1.keybordType;
  209.     }
  210.  
  211.     public void setDisplaydim() {
  212.         _headCapwidth = (int) (_width * 0.20);
  213.         _headCapHeight = (int) (_height * 0.06);
  214.         _storyTextHeight = (int) (_height * 0.35);
  215.         textSize = 18;
  216.         _contentSize = 25;
  217.         _listContent = 16;
  218.  
  219.         _imageWidth = (int) (_width * 0.2);
  220.         _imageHeight = (int) (_height * .14);
  221.  
  222.         // list
  223.         _lheadingWidth = (int) (_width * 0.50);
  224.         _lstatusWidth = (int) (_width * 0.20);
  225.         _ldateWidth = (int) (_width * 0.17);
  226.         _luploadWidth = (int) (_width * 0.18);
  227.  
  228.         _listtypewidth = (int) (_width * 0.7);
  229.         _keyboardWidth = (int) (_listtypewidth * 0.5);
  230.  
  231.         if (_height > _width) {
  232.             _headerHeight = (int) (_height * 0.05);
  233.             _cenerHeight = (int) (_height * 0.9);
  234.             _widthHeaderIcon = (int) (_width * 0.25);
  235.             _wordcountWidth = (int) (_width * 0.08);
  236.             refreshbutton = (int) (_width * 0.1);
  237.             g1._popupheight = (int) (_height * (0.6));
  238.             g1._popupWidth = (int) (_width * (0.5));
  239.             g1.popupfontsize = (int) (_height * 0.02);
  240.             _spinnerHeight = (int) (_height * 0.06);
  241.             if (_height <= 800 && _width <= 500) {
  242.                 g1._iconSize = 45;
  243.             } else if (_height <= 1100 && _width <= 600) {
  244.                 g1._iconSize = 30;
  245.             } else if (_height <= 1920 && _width <= 1080) {
  246.                 g1._iconSize = 50;
  247.                 textSize = (int) (_height * 0.02);
  248.                 _contentSize = (int) (_height * 0.025);
  249.             }
  250.         } else {
  251.             _headerHeight = (int) (_width * 0.05);
  252.             _cenerHeight = (int) (_width * 0.9);
  253.             _widthHeaderIcon = (int) (_width * 0.20);
  254.             _wordcountWidth = (int) (_width * 0.02);
  255.             refreshbutton = (int) (_width * 0.08);
  256.             g1._popupheight = (int) (_height * (0.8));
  257.             g1._popupWidth = (int) (_width * (0.3));
  258.             g1.popupfontsize = (int) (_width * 0.02);
  259.             _spinnerHeight = (int) (_width * 0.07);
  260.             if (_width <= 800 && _height <= 500) {
  261.                 g1._iconSize = 45;
  262.             } else if (_width <= 1100 && _height <= 600) {
  263.                 g1._iconSize = 30;
  264.             } else if (_width <= 1920 && _height <= 1080) {
  265.                 g1._iconSize = 50;
  266.                 textSize = (int) (_width * 0.02);
  267.                 _contentSize = (int) (_width * 0.025);
  268.             }
  269.         }
  270.     }
  271.  
  272.     public void displayConfgh() {
  273.         Display _display;
  274.         _display = getWindowManager().getDefaultDisplay();
  275.         _height = _display.getHeight();
  276.         _width = _display.getWidth();
  277.     }
  278.  
  279.     @Override
  280.     protected void onCreate(Bundle savedInstanceState) {
  281.         super.onCreate(savedInstanceState);
  282.         // this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  283.         getLayoutInflater().inflate(R.layout.wire_list, frameLayout);
  284.         listView=(ListView)findViewById(R.id.searchlistview);
  285.  
  286.  
  287.         listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  288.             @Override
  289.             public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
  290.  
  291.                 String item=(String) listView.getItemAtPosition(i);
  292.                 Toast.makeText(context, item, Toast.LENGTH_SHORT).show();
  293.  
  294.            /*  LinearLayout lk = (LinearLayout) view.getParent();
  295.              int position = (Integer) view.getTag();
  296.              String tmpStr10 = String.valueOf(position);
  297.              new Storyres().execute(tmpStr10);*/
  298.             }
  299.         });
  300.  
  301.  
  302.  
  303.         // String[] check={"shivam","ashutosh","himanshu","vishal","shubham","rishabh"};
  304.  
  305.         adapterlist=new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,listHead1);
  306.         listView.setAdapter(adapterlist);
  307.  
  308.         displayConfgh();
  309.         setDisplaydim();
  310.         setLoginData();
  311.  
  312.         deviceType = Globals.isTablet(context);
  313.  
  314.         /*if (isNetworkAvailable())
  315.             new WireStoryLoad().execute();
  316. */
  317.         /*getActionBar().setDisplayShowCustomEnabled(true);
  318.         getActionBar().setDisplayShowHomeEnabled(false);
  319.         getActionBar().setDisplayShowTitleEnabled(false);*/
  320.         DisplayMetrics metrics = new DisplayMetrics();
  321.         getWindowManager().getDefaultDisplay().getMetrics(metrics);
  322.  
  323.         int dens=getResources().getDisplayMetrics().densityDpi;
  324.         {
  325.             if(dens>=DisplayMetrics.DENSITY_MEDIUM && dens<DisplayMetrics.DENSITY_HIGH ) {
  326.                 _contentSize = (int) (_height * 0.022);
  327.                 if (deviceType) {
  328.                     textSize = (int) (_height * 0.014);
  329.                     g1._iconSize = 45;
  330.                     _headCapHeight = (int) (_height * 0.06);
  331.                     _wordcountWidth = (int) (_height * 0.10);
  332.                     marginTop = (int) (_height * 0.014);
  333.                     dropdownwidth = (int) (_width * 0.25);
  334.                     searchwidth = (int) (_width * 0.5);
  335.                     imageHeight = (int) (_height * 0.35);
  336.                 } else {
  337.                     textSize = (int) (_height * 0.028);
  338.                     g1._iconSize = 45;
  339.                     _headCapHeight = (int) (_height * 0.06);
  340.                     _wordcountWidth = (int) (_height * 0.10);
  341.                     marginTop = (int) (_height * 0.014);
  342.                     dropdownwidth = (int) (_width * 0.25);
  343.                     imageHeight = (int) (_height * 0.35);
  344.                 }
  345.             }
  346.             else if(dens>=DisplayMetrics.DENSITY_HIGH && dens<DisplayMetrics.DENSITY_XHIGH ) {
  347.                 _contentSize = (int) (_height * 0.016);
  348.                 if (deviceType) {
  349.                     textSize = (int) (_height * 0.02);
  350.                     g1._iconSize = 50;
  351.                     _headCapHeight = (int) (_height * 0.04);
  352.                     _wordcountWidth = (int) (_height * 0.08);
  353.                     marginTop = (int) (_height * 0.016);
  354.                     dropdownwidth = (int) (_width * 0.25);
  355.                     imageHeight = (int) (_height * 0.35);
  356.                 } else {
  357.                     textSize = (int) (_height * 0.03);
  358.                     _headCapHeight = (int) (_height * 0.06);
  359.                     _wordcountWidth = (int) (_height * 0.10);
  360.                     marginTop = (int) (_height * 0.016);
  361.                     dropdownwidth = (int) (_width * 0.25);
  362.                     imageHeight = (int) (_height * 0.30);
  363.                     g1._iconSize = 50;
  364.                 }
  365.             }
  366.             else if(dens>=DisplayMetrics.DENSITY_XHIGH && dens<DisplayMetrics.DENSITY_XXHIGH ) {
  367.                 _contentSize = (int) (_height * 0.014);
  368.                 if (deviceType) {
  369.                     textSize = (int) (_height * 0.01);
  370.                     g1._iconSize = 70;
  371.                     _headCapHeight = (int) (_height * 0.07);
  372.                     _wordcountWidth = (int) (_height * 0.10);
  373.                     marginTop = (int) (_height * 0.016);
  374.                     dropdownwidth = (int) (_width * 0.25);
  375.                     imageHeight = (int) (_height * 0.40);
  376.                 } else {
  377.                     _headCapHeight = (int) (_height * 0.06);
  378.                     textSize = (int) (_height * 0.02);
  379.                     g1._iconSize = 50;
  380.                     _wordcountWidth = (int) (_height * 0.10);
  381.                     marginTop = (int) (_height * 0.018);
  382.                     dropdownwidth = (int) (_width * 0.30);
  383.                     imageHeight = (int) (_height * 0.35);
  384.                 }
  385.             }
  386.             else if(dens>=DisplayMetrics.DENSITY_XXHIGH && dens<DisplayMetrics.DENSITY_XXXHIGH ) {
  387.                 _contentSize = (int) (_height * 0.010);
  388.                 if (deviceType) {
  389.                     textSize = (int) (_height * 0.02);
  390.                     _headCapHeight = (int) (_height * 0.1);
  391.                     g1._iconSize = 80;
  392.                     _wordcountWidth = (int) (_height * 0.10);
  393.                     marginTop = (int) (_height * 0.018);
  394.                     dropdownwidth = (int) (_width * 0.28);
  395.                     imageHeight = (int) (_height * 0.35);
  396.                 } else {
  397.                     textSize = (int) (_height * 0.02);
  398.                     _headCapHeight = (int) (_height * 0.07);
  399.                     g1._iconSize = 60;
  400.                     _wordcountWidth = (int) (_height * 0.10);
  401.                     marginTop = (int) (_height * 0.018);
  402.                     dropdownwidth = (int) (_width * 0.28);
  403.                     imageHeight = (int) (_height * 0.40);
  404.                 }
  405.             }
  406.             else if(dens>=DisplayMetrics.DENSITY_XXXHIGH ) {
  407.                 _contentSize = (int) (_height * 0.008);
  408.                 if (deviceType) {
  409.                     textSize = (int) (_height * 0.02);
  410.                     _headCapHeight = (int) (_height * 0.02);
  411.                     g1._iconSize = 80;
  412.                     _wordcountWidth = (int) (_height * 0.10);
  413.                     marginTop = (int) (_height * 0.02);
  414.                     dropdownwidth = (int) (_width * 0.3);
  415.                     imageHeight = (int) (_height * 0.4);
  416.                 } else {
  417.                     textSize = (int) (_height * 0.029);
  418.                     _headCapHeight = (int) (_height * 0.029);
  419.                     g1._iconSize = 60;
  420.                     _wordcountWidth = (int) (_height * 0.10);
  421.                     marginTop = (int) (_height * 0.029);
  422.                     dropdownwidth = (int) (_width * 0.3);
  423.                     imageHeight = (int) (_height * 0.35);
  424.                 }
  425.             }
  426.         }
  427.  
  428.         g1.Autow_da = "Author";
  429.         // --------------------------------------------------------
  430.         RelativeLayout ll = new RelativeLayout(context);
  431.         ll.setLayoutParams(new RelativeLayout.LayoutParams(
  432.                 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  433.         ll.setBackgroundColor(Color.parseColor("#1C92DC"));
  434.  
  435.         ImageView moreimg = new ImageView(this);
  436.         moreimg.setId(R.id.moreimg);
  437.         moreimg.setImageResource(R.drawable.menuico);
  438.         RelativeLayout.LayoutParams paramsmenu = new RelativeLayout.LayoutParams(
  439.                 (int) (_height * 0.05), (int) (_height * 0.05));
  440.         paramsmenu.setMargins((int) Math.ceil(5 * (metrics.density)), 0, 0, 0);
  441.         paramsmenu.addRule(RelativeLayout.CENTER_VERTICAL);
  442.         moreimg.setLayoutParams(paramsmenu);
  443.  
  444.         moreimg.setOnClickListener(new OnClickListener() {
  445.             @Override
  446.             public void onClick(View v) {
  447.                 if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
  448.                     mDrawerLayout.closeDrawer(mDrawerList);
  449.                 } else {
  450.                     mDrawerLayout.openDrawer(mDrawerList);
  451.                 }
  452.             }
  453.         });
  454.         ImageView img_logo = new ImageView(this);
  455.         img_logo.setId(R.id.logoid);
  456.         RelativeLayout.LayoutParams menuparam1 = new RelativeLayout.LayoutParams(
  457.                 (int) (_width * 0.4), LayoutParams.MATCH_PARENT);
  458.         menuparam1.setMargins(0, 5, 0, 5);
  459.         menuparam1.addRule(RelativeLayout.CENTER_HORIZONTAL, moreimg.getId());
  460.         img_logo.setLayoutParams(menuparam1);
  461.         img_logo.setImageResource(R.drawable.fourclogo);
  462.         ll.addView(img_logo);
  463.         ll.addView(moreimg);
  464.  
  465.  
  466.         ImageView img_home = new ImageView(this);
  467.         RelativeLayout.LayoutParams menuparam2 = new RelativeLayout.LayoutParams((int) (_height * 0.05), (int) (_height * 0.05));
  468.         menuparam2.setMargins((int) Math.ceil(5 * (metrics.density)), 0, 0, 0);
  469.         menuparam2.addRule(RelativeLayout.CENTER_VERTICAL);
  470.         menuparam2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, img_logo.getId());
  471.         img_home.setLayoutParams(menuparam2);
  472.         img_home.setImageResource(R.drawable.icon_home);
  473.  
  474.         img_home.setOnClickListener(new View.OnClickListener() {
  475.             @Override
  476.             public void onClick(View v) {
  477.                 Intent nextScreen=null;
  478.                 if(g.appname.equalsIgnoreCase("MT Vaani"))
  479.                 {
  480.                     nextScreen = new Intent(getApplicationContext(), DataList.class);
  481.                 }
  482.                 else
  483.                 {
  484.                     nextScreen = new Intent(getApplicationContext(), EditorPage.class);
  485.                 }
  486.                 startActivity(nextScreen);
  487.             }
  488.         });
  489.         ll.addView(img_home);
  490.         getSupportActionBar().setCustomView(ll);
  491.  
  492.         //===========================================================================================
  493.         ActionBar ab = getSupportActionBar();
  494.         //ab.setHomeAsUpIndicator(R.drawable.ic_menu); // set a custom icon for the default home button
  495.         ab.setDisplayShowHomeEnabled(false); // show or hide the default home button
  496.         ab.setDisplayHomeAsUpEnabled(false);
  497.         ab.setDisplayShowCustomEnabled(true); // enable overriding the default toolbar layout
  498.         ab.setDisplayShowTitleEnabled(false); // d
  499.  
  500.         Toolbar parent =(Toolbar) ll.getParent();
  501.         parent.setContentInsetsAbsolute(0,0);
  502.         //===========================================================================================
  503.         // ---------------------------------------------
  504.         face = Typeface.createFromAsset(getAssets(), "font/" + g1.HindiFont);
  505.         faceCaption = Typeface.createFromAsset(getAssets(), "font/"
  506.                 + g1.FontCaption);
  507.         LinearLayout _mymasterLayout = (LinearLayout) findViewById(R.id.mywirelist);
  508.         zoom = new ZoomView(this);
  509.         _mymasterLayout.addView(zoom);
  510.  
  511.         _masterLayout = new LinearLayout(this);
  512.         _masterLayout.setLayoutParams(new LayoutParams(
  513.                 LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
  514.         _masterLayout.setBackgroundColor(Color.WHITE);
  515.         _masterLayout.setOrientation(LinearLayout.VERTICAL);
  516.  
  517.         _subMaster = new RelativeLayout(this);
  518.         _subMaster.setBackgroundColor(Color.WHITE);
  519.         _subMaster.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT));
  520.  
  521.         // header
  522.         // Layout==========================================================================================================
  523.  
  524.         _header = new RelativeLayout(this);
  525.         _header.setBackgroundColor(Color.parseColor("#252525"));
  526.         _header.setId(R.id.header);
  527.         _headerparams = new RelativeLayout.LayoutParams(
  528.                 LayoutParams.FILL_PARENT, _headerHeight);
  529.         _headerparams.addRule(RelativeLayout.ALIGN_PARENT_TOP,
  530.                 RelativeLayout.TRUE);
  531.  
  532.         TextView _caption = new TextView(this);
  533.         RelativeLayout.LayoutParams _captionRule = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, (int) (_height * 0.05));
  534.         _captionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
  535.         _caption.setLayoutParams(_captionRule);
  536.         _caption.setText(" Wire News ");
  537.         _caption.setGravity(Gravity.CENTER_VERTICAL);
  538.         _caption.setPadding(10, 0, 0, 0);
  539.         _caption.setTextColor(Color.WHITE);
  540.         _caption.setTypeface(faceCaption, Typeface.NORMAL);
  541.         _caption.setTextSize(0, textSize);
  542.         _header.addView(_caption);
  543.         _subMaster.addView(_header, _headerparams);
  544.  
  545.         // Bottom
  546.         // Layout=========================================================================================================
  547.  
  548.         _bottom = new RelativeLayout(this);
  549.         _bottom.setBackgroundColor(Color.parseColor(g1._headerColor));
  550.         _bottom.setId(R.id.bottom);
  551.         _bottom.setPadding(0, 10, 0, 0);
  552.         _bottomParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, _headerHeight);
  553.         _bottomParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
  554.  
  555.         _backLayout = new LinearLayout(this);
  556.         _backLayout.setGravity(Gravity.CENTER_HORIZONTAL);
  557.  
  558.         _backButtonRule = new RelativeLayout.LayoutParams(refreshbutton,LayoutParams.WRAP_CONTENT);
  559.         _backButtonRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
  560.  
  561.         /*_backIcon = new ImageView(this);
  562.         _backIcon.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
  563.                 LayoutParams.WRAP_CONTENT));
  564.  
  565.         _backIcon.setImageResource(R.drawable.refresh2);
  566.         _backLayout.addView(_backIcon);
  567.         _bottom.addView(_backLayout, _backButtonRule);
  568.         _backLayout.setOnTouchListener(new OnTouchListener() {
  569.             @Override
  570.             public boolean onTouch(View v, MotionEvent event) {
  571.                 // DeskDetails(g1.empcode);
  572.                 *//*if (isNetworkAvailable())
  573.                     new WireStoryLoad().execute();*//*
  574.                 return false;
  575.             }
  576.         });*/
  577.  
  578.         _SynkLayout = new LinearLayout(this);
  579.         _synkdateRule = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  580.         _synkdateRule.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE);
  581.  
  582.         _synkDate = new TextView(this);
  583.         _synkDate.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  584.         _synkDate.setTypeface(faceCaption, Typeface.BOLD_ITALIC);
  585.         //_synkDate.setText(convert24to12(g1.getSynkTime()));
  586.         _synkDate.setText("");
  587.         _synkDate.setTextSize(0, textSize);
  588.         _synkDate.setTextColor(Color.parseColor(g1._baseColor));
  589.  
  590.         _SynkLayout.addView(_synkDate);
  591.         _bottom.addView(_SynkLayout, _synkdateRule);
  592.         _subMaster.addView(_bottom, _bottomParams);
  593.  
  594.         // CenterLayout
  595.         // Top=========================================================================================================
  596.  
  597.         _centerTop = new RelativeLayout(this);
  598.         _centerTop.setId(R.id.centerTop);
  599.         _centerTop.setBackgroundColor(Color.WHITE);// .parseColor(g1._baseColor));
  600.  
  601.         _centerTopRule = new RelativeLayout.LayoutParams(
  602.                 LayoutParams.MATCH_PARENT, (int) (_height * 0.05));
  603.         _centerTopRule.addRule(RelativeLayout.BELOW, _header.getId());
  604.  
  605.         _centerMain1 = new LinearLayout(this);
  606.         _centerMain1.setLayoutParams(new LayoutParams(
  607.                 LayoutParams.MATCH_PARENT,
  608.                 android.app.ActionBar.LayoutParams.WRAP_CONTENT));
  609.         _centerMain1.setPadding(10, 10, 0, 0);
  610.         _centerMain1.setWeightSum(2);
  611.  
  612.         // 1.=====================================================
  613.  
  614.         _center1 = new LinearLayout(this);
  615.         _center1.setOrientation(LinearLayout.HORIZONTAL);
  616.         _center1.setLayoutParams(new LayoutParams(0,
  617.                 LayoutParams.WRAP_CONTENT, 1.4f));
  618.  
  619.         SearchView searchView=new SearchView(this);
  620.         searchView.setLayoutParams(new LayoutParams(searchwidth,LayoutParams.WRAP_CONTENT));
  621.  
  622.  
  623.         recyclerlist = new RecyclerView(this);
  624.         recyclerlist.setLayoutParams(new LayoutParams(0, LayoutParams.MATCH_PARENT, 10));
  625.         recyclerlist.setPadding(0, 0, 0, 0);
  626.  
  627.         recyclerlist.setHasFixedSize(true);
  628.         recyclerlist.addItemDecoration(new DividerItemDecoration(this,
  629.                 DividerItemDecoration.VERTICAL));
  630.         //recyclerlist.setNestedScrollingEnabled(false);
  631.         recyclerlist.setLayoutManager(new LinearLayoutManager(this));
  632.  
  633.  
  634.         /*dataList= new ArrayList<WireListData>();
  635.  
  636.         dataList.add(
  637.                 new WireListData("Politics","12/09/1994"));
  638.  
  639.         dataList.add(
  640.                 new WireListData("Economy","12/09/1994"));
  641.  
  642.         dataList.add(
  643.                 new WireListData("Sports","Friday,Dec 21,2018, 4:10 (IST)"));
  644.  
  645.         dataList.add(
  646.                 new WireListData("Sports","Friday,Dec 21,2018, 4:20 (IST)"));
  647.  
  648.         dataList.add(
  649.                 new WireListData("Politics","Friday,Dec 21,2018, 4:30 (IST)"));
  650.  
  651.         dataList.add(
  652.                 new WireListData("Economy","Friday,Dec 21,2018, 4:40 (IST)"));*/
  653.  
  654.     //  adapterwire = new WireListAdapter(dataList);
  655.  
  656. //setting adapter to recyclerview
  657.     //  recyclerlist.setAdapter(adapterwire);
  658.  
  659.  
  660.  
  661.         viewmore = new TextView(this);
  662.         viewmore.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 10));
  663.         viewmore.setText("ViewMore");
  664.         viewmore.setPadding(0, 0, 0, 0);
  665.         viewmore.setTypeface(faceCaption, Typeface.BOLD);
  666.         viewmore.setTextSize(0, textSize);
  667.  
  668.  
  669.         searchView = new SearchView(this);
  670.         searchView.setQueryHint("Search Here");
  671.         searchView.setLayoutParams(new LayoutParams((int) (_width * 10), LayoutParams.WRAP_CONTENT, 10));
  672.         searchView.setPadding(0, 0, 0, 0);
  673.  
  674.  
  675.         searchView.setOnCloseListener(new SearchView.OnCloseListener() {
  676.             @Override
  677.             public boolean onClose() {
  678.                 listView.setVisibility(View.GONE);
  679.                 return false;
  680.             }
  681.         });
  682.  
  683.         searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
  684.  
  685.             @Override
  686.             public boolean onQueryTextSubmit(String s) {
  687.                 adapterwire.getFilter().filter(s);
  688.                 return false;
  689.             }
  690.  
  691.             @Override
  692.             public boolean onQueryTextChange(String s) {
  693.                 adapterwire.getFilter().filter(s);
  694.  
  695.                 if (s.isEmpty()){
  696.                     //listView.setVisibility(View.GONE);
  697.                 }else {
  698.                     //listView.setVisibility(View.VISIBLE);
  699.                     //adapterlist.getFilter().filter(s);
  700.  
  701.                     /*List<WireListData> list=null;
  702.  
  703.                     for(WireListData d: dataList){
  704.                         if(d.getHeadline().contains(s)){
  705.                             list.add(d);
  706.                         }
  707.                     }*/
  708.                     //adapterwire.updateList(list);
  709.  
  710.                 }
  711.  
  712.                 return false;
  713.             }
  714.         });
  715.  
  716.  
  717.     /*  void filter(String text){
  718.             List<WireListData> temp;
  719.  
  720.             for(WireListData d: dataList){
  721.                 //or use .equal(text) with you want equal match
  722.                 //use .toLowerCase() for better matches
  723.                 if(d.getEnglish().contains(text)){
  724.                     temp.add(d);
  725.                 }
  726.             }
  727.             //update recyclerview
  728.             disp_adapter.updateList(temp);
  729.         }*/
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.         _spinAssetType = new Spinner(this);
  738.         _spinAssetType.setLayoutParams(new LayoutParams(dropdownwidth, LayoutParams.WRAP_CONTENT));
  739.         _spinAssetType.setBackgroundResource(R.drawable.custom_spinner);
  740.  
  741.         CustomSpinnerEditorAdapter adapter = new CustomSpinnerEditorAdapter(context, g.options1, textSize);
  742.         _spinAssetType.setAdapter(adapter);
  743.         _spinAssetType.setSelection(0);
  744.  
  745.         _spinAssetType.setOnItemSelectedListener(new OnItemSelectedListener() {
  746.             @Override
  747.             public void onItemSelected(AdapterView<?> parameters, View arg1,
  748.                                        int index, long arg3) {
  749.                 if (flagch == 0) {
  750.                     flagcheck = false;
  751.                     flagch = flagch + 1;
  752.                 }
  753.  
  754.                 new WireStoryOnSelected().execute(parameters.getSelectedItem().toString());
  755.             }
  756.  
  757.             @Override
  758.             public void onNothingSelected(AdapterView<?> arg0) {
  759.             }
  760.         });
  761.  
  762.  
  763.  
  764.         _center1.addView(_spinAssetType);
  765.  
  766.         _supporttext = new TextView(this);
  767.         _supporttext.setLayoutParams(new LayoutParams(20, 0));
  768.         _center1.addView(_supporttext);
  769.  
  770.         try {
  771.             if (g1._login1 != 2 && g1.listDesk != null
  772.                     && g1.listDesk.get(1).size() != 0) {
  773.                 /*
  774.                  * _spinFilter=new Spinner(this); _spinFilter.setPadding(5, 0,
  775.                  * 0, 0); _spinFilter.setLayoutParams(new
  776.                  * LinearLayout.LayoutParams
  777.                  * (LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
  778.                  */
  779.  
  780.                 _spinFilter = new Spinner(this);
  781.                 _spinFilter.setLayoutParams(new LayoutParams(
  782.                         dropdownwidth, LayoutParams.WRAP_CONTENT));
  783.                 _spinFilter.setBackgroundResource(R.drawable.custom_spinner);
  784.  
  785.                 String[] options = new String[g1.listDesk.get(1).size() + 1];
  786.                 try {
  787.                     options[0] = "---";
  788.                     for (int i = 0; i < g1.listDesk.get(1).size(); i++)
  789.                     {
  790.                         options[i + 1] = g1.listDesk.get(1).get(i);
  791.                         if (g1.newdeskcode.equalsIgnoreCase("0")) {
  792.                             if (g1.listDesk.get(0).get(i).equals(g1.deskcode)) {
  793.                                 mu = i + 1;
  794.                             }
  795.                         } else {
  796.                             if (g1.listDesk.get(0).get(i).equals(g1.newdeskcode)) {
  797.                                 mu = i + 1;
  798.                             }
  799.                         }
  800.                     }
  801.                 } catch (Exception e) {
  802.                 }
  803.  
  804.                 _center1.addView(searchView);
  805.  
  806.  
  807.                 CustomSpinnerEditorAdapter adapter1= new CustomSpinnerEditorAdapter(context, options, textSize);
  808.                 _spinFilter.setAdapter(adapter1);
  809.                 _spinFilter.setSelection(mu);
  810.                 _center1.addView(_spinFilter);
  811.                 _spinFilter.setOnItemSelectedListener(new OnItemSelectedListener() {
  812.                     @Override
  813.                     public void onItemSelected(AdapterView<?> items,
  814.                                                View arg1, int pos, long arg3) {
  815.                         if (flagcheck == true) {
  816.                             int deskcodem = g1.setDeskCode(items
  817.                                             .getItemAtPosition(pos).toString(),
  818.                                     pos);
  819.                             if (isNetworkAvailable())
  820.                                 new WireStoryLoad().execute();
  821.                         } else {
  822.                             flagcheck = true;
  823.                         }
  824.                     }
  825.  
  826.                     @Override
  827.                     public void onNothingSelected(AdapterView<?> arg0) {
  828.                     }
  829.                 });
  830.             }
  831.         } catch (Exception e) {
  832.         }
  833.  
  834.  
  835.         _center1.addView(searchView);
  836.         _center10 = new LinearLayout(this);
  837.         LayoutParams myparams = new LayoutParams(0,
  838.                 _headerHeight, .6f);
  839.         myparams.setMargins(10, 0, 15, 0);
  840.         _center10.setLayoutParams(myparams);
  841.         _center10.setGravity(Gravity.RIGHT);
  842.  
  843.         _wordCountCation = new TextView(this);
  844.         _wordCountCation.setLayoutParams(new LayoutParams(
  845.                 _headCapwidth, _headCapHeight));
  846.         _wordCountCation.setTypeface(faceCaption, Typeface.BOLD);
  847.         _wordCountCation.setTextSize(0, textSize);
  848.         _center10.addView(_wordCountCation);
  849.  
  850.         _centerMain1.addView(_center1);
  851.         _centerMain1.addView(_center10);
  852.         _centerTop.addView(_centerMain1);
  853.         _subMaster.addView(_centerTop, _centerTopRule);
  854.  
  855.         // Centeral Layout
  856.         // =======================================================================================================
  857.  
  858.         _centerScroller = new ScrollView(this);
  859.         _centerScroller.setBackgroundColor(Color.parseColor(g1._baseColor));
  860.         _centerScroller.setVerticalScrollBarEnabled(true);
  861.         _centerparams = new RelativeLayout.LayoutParams(
  862.                 LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  863.  
  864.         _centerparams.addRule(RelativeLayout.BELOW, _centerTop.getId());
  865.         _centerparams.addRule(RelativeLayout.ABOVE, _bottom.getId());
  866.  
  867.         _center = new LinearLayout(this);
  868.         _center.setLayoutParams(new LayoutParams(
  869.                 LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  870.         _center.setOrientation(LinearLayout.VERTICAL);
  871.         _center.setPadding(5, 5, 5, 5);
  872.  
  873.         _centerScroller.addView(_center);
  874.         _subMaster.addView(_centerScroller, _centerparams);
  875.  
  876.         // addViews==============================================================================================================
  877.         _masterLayout.addView(_subMaster);
  878.         zoom.addView(_masterLayout);
  879.         // setContentView(zoom);
  880.         // new StoryData().execute("8");
  881.     }
  882.  
  883.     @Override
  884.     public void onBackPressed() {
  885.         try {
  886.             if (flagpopw == false) {
  887.                 spopUp.dismiss();
  888.                 flagpopw = true;
  889.             } else {
  890.                 Intent main = new Intent(context, EditorPage.class);
  891.                 finish();
  892.                 startActivity(main);
  893.             }
  894.         } catch (Exception e) {
  895.             e.printStackTrace();
  896.         }
  897.     }
  898.  
  899.     @Override
  900.     public void onSelected(WireListData item) {
  901.  
  902.     }
  903.  
  904.  
  905.     // =========================story======================================
  906.  
  907.     class StoryData extends AsyncTask<String, Void, Void> {
  908.         private Cursor cur1 = null;
  909.         private ProgressDialog dia;
  910.         int count = 0;
  911.  
  912.         private String statusre;
  913.  
  914.         @Override
  915.         protected void onPreExecute() {
  916.             runOnUiThread(new Runnable() {
  917.                 public void run() {
  918.                     try {
  919.                         dia = ProgressDialog.show(context, "Loading...",
  920.                                 "Please wait...");
  921.                     } catch (Exception e) {
  922.                     }
  923.                 }
  924.             });
  925.             super.onPreExecute();
  926.         }
  927.  
  928.         @Override
  929.         protected Void doInBackground(String... params) {
  930.             try
  931.             {
  932.                 count = 0;
  933.                 // cur1 = con.getDeskAssignerList(params[0]);
  934.                 listId = new ArrayList<String>();
  935.                 listHead1 = new ArrayList<>();
  936.                 listStr1 =new ArrayList<String>();
  937.                 listDt = new ArrayList<String>();
  938.  
  939.                 // if (cur1 != null) {
  940.                 // cur1.moveToFirst();
  941.                 // count = cur1.wireList();
  942.                 count=g1.wireList.get(0).size();
  943.                 for (int i = 0; i < g1.wireList.get(0).size(); i++) {
  944.                     // String id=g1.wireList.get(1)
  945.                     String head = g1.wireList.get(0).get(i).toString();
  946.                     listHead1.add(head);
  947.  
  948.                     String dt = g1.wireList.get(1).get(i).toString();
  949.                     listDt.add(dt);
  950.                     String str = g1.wireList.get(2).get(i).toString();
  951.                     listStr1.add(str);
  952.  
  953.                 }
  954.  
  955.                 // }
  956.             } catch (Exception e) {
  957.                 e.printStackTrace();
  958.             } finally {
  959.                 /*
  960.                  * if (cur1 != null) { if (!cur1.isClosed()) cur1.close(); }
  961.                  */
  962.  
  963.                 con.close();
  964.             }
  965.             return null;
  966.         }
  967.  
  968.         @Override
  969.         protected void onPostExecute(Void result) {
  970.             try {
  971.                 layout_list2(listHead1, listDt,listStr1);
  972.                 adapterlist = new ArrayAdapter(context, android.R.layout.simple_list_item_1, listHead1);
  973.                 listView.setAdapter(adapterlist);
  974.             } catch (Exception exf) {
  975.                 finish();
  976.             }
  977.             dia.dismiss();
  978.             super.onPostExecute(result);
  979.         }
  980.     }
  981.  
  982.  
  983.     public void layout_list2(ArrayList<String> head, ArrayList<String> dt,ArrayList<String>Stry) {
  984.         if (head.size() > 0)
  985.             _wordCountCation.setText("Total: " + head.size());
  986.         else
  987.             _wordCountCation.setText("Total: " + head.size());
  988.  
  989.         _center.removeAllViews();
  990.         ruler = new View(this);
  991.         ruler.setBackgroundColor(0xFFcacbc6);
  992.  
  993.         _center2 = new LinearLayout(this);
  994.         _center2.setLayoutParams(new LayoutParams(
  995.                 LayoutParams.FILL_PARENT,
  996.                 LayoutParams.WRAP_CONTENT));
  997.         _center2.setOrientation(LinearLayout.HORIZONTAL);
  998.         _center2.setWeightSum(10);
  999.  
  1000.  
  1001.  
  1002.         _center2.addView(recyclerlist);
  1003.         _center.addView(_center2);
  1004.         _center.addView(ruler, new ViewGroup.LayoutParams(
  1005.                 ViewGroup.LayoutParams.FILL_PARENT, 2));
  1006.  
  1007.  
  1008.         for (int a = 0; a < head.size(); a++) {
  1009.             ruler = new View(this);
  1010.             ruler.setBackgroundColor(0xFFcacbc6);
  1011.             _center1 = new LinearLayout(this);
  1012.             _center1.setOrientation(LinearLayout.HORIZONTAL);
  1013.             _center1.setPadding(0, 5, 0, 5);
  1014.             _center1.setLayoutParams(new LayoutParams(
  1015.                     LayoutParams.FILL_PARENT,
  1016.                     LayoutParams.WRAP_CONTENT));
  1017.             _center1.setWeightSum(10);
  1018.  
  1019.  
  1020.             /*con.reqLanguagepos(Integer
  1021.                     .parseInt(languageCodes.get(a).toString()));
  1022.             face = Typeface.createFromAsset(getAssets(), "font/" + g1.FontName);
  1023.             if (g.appfor.equals("pn"))
  1024.                 face = Typeface.createFromAsset(getAssets(), "font/"
  1025.                         + g1.ResionalFont);
  1026.  
  1027.             _headingCap.setTypeface(face);*/
  1028.  
  1029.  
  1030.             /*    comment by shivam  */
  1031.  
  1032.  
  1033.             //DT
  1034.             /*_headingCap.setOnClickListener(new View.OnClickListener() {
  1035.                 public void onClick(View v) {
  1036.                     LinearLayout lk = (LinearLayout) v.getParent();
  1037.  
  1038.                     TextView t0 = (TextView) lk.getChildAt(3);
  1039.                     TextView t1 = (TextView) lk.getChildAt(4);
  1040.                     TextView t2 = (TextView) lk.getChildAt(5);
  1041.  
  1042.                     String sccode = t1.getText().toString();
  1043.                     String sstatus = t2.getText().toString();
  1044.                     String versi = t0.getText().toString();
  1045.                     try {
  1046.                         g1.assign = t2.getText().toString();
  1047.                     } catch (Exception ex) {
  1048.                         g1.assign = "N";
  1049.                     }
  1050.                     new Storyres().execute(sccode, versi);
  1051.                 }
  1052.             });*/
  1053.             }
  1054.             if (count == 0 && g1.unknownhostexception.equals("Y")) {
  1055.                 Toast.makeText(context, "Message:Proxy is missing.",
  1056.                         Toast.LENGTH_LONG).show();
  1057.                 // createNetErrorDialog();
  1058.             }
  1059.  
  1060.         }
  1061.  
  1062.  
  1063.  
  1064.  
  1065.     protected void createNetErrorDialog() {
  1066.         AlertDialog.Builder builder = new AlertDialog.Builder(this);
  1067.         builder.setMessage(
  1068.                 "You Lost Proxy, So please turn on mobile network or Wi-Fi in Settings to enable proxy.")
  1069.                 .setTitle("Unable to connect")
  1070.                 .setCancelable(false)
  1071.                 .setPositiveButton("Settings",
  1072.                         new DialogInterface.OnClickListener() {
  1073.                             public void onClick(DialogInterface dialog, int id) {
  1074.                                 Intent i = new Intent(
  1075.  
  1076.                                         Settings.ACTION_WIRELESS_SETTINGS);
  1077.                                 startActivity(i);
  1078.                             }
  1079.                         })
  1080.                 .setNegativeButton("Cancel",
  1081.                         new DialogInterface.OnClickListener() {
  1082.                             public void onClick(DialogInterface dialog, int id) {
  1083.                                 // fjklasjf
  1084.                                 // DeskList.this.finish();
  1085.                                 dialog.cancel();
  1086.                             }
  1087.                         });
  1088.         AlertDialog alert = builder.create();
  1089.         alert.show();
  1090.     }
  1091.  
  1092.     class Storyres extends AsyncTask<String, Void, Void> {
  1093.  
  1094.         private Cursor cur;
  1095.         private ProgressDialog dia;
  1096.         private String PosInd="";
  1097.  
  1098.         protected void onPreExecute() {
  1099.             runOnUiThread(new Runnable() {
  1100.                 public void run() {
  1101.                     dia = ProgressDialog.show(context, "Loading...",
  1102.                             "Please wait...");
  1103.                 }
  1104.             });
  1105.             super.onPreExecute();
  1106.         }
  1107.  
  1108.         protected Void doInBackground(String... params) {
  1109.             try {
  1110.                 //con.getReadDeskStory(params[0].toString());
  1111.                 //getReadWireStory(params[0].toString());
  1112.                 PosInd= params[0].toString();
  1113.             } catch (Exception e) {
  1114.                 dia.dismiss();
  1115.                 e.printStackTrace();
  1116.             }
  1117.             return null;
  1118.         }
  1119.  
  1120.         protected void onPostExecute(Void result) {
  1121.             dia.dismiss();
  1122.             Intent nextScreen = new Intent(context, WireViewStory.class);
  1123.             // finish();
  1124.             nextScreen.putExtra("posi", PosInd);
  1125.             startActivity(nextScreen);
  1126.             super.onPostExecute(result);
  1127.         }
  1128.     }
  1129.  
  1130.     private boolean isNetworkAvailable() {
  1131.         NetworkInfo info = ((ConnectivityManager) context
  1132.                 .getSystemService(Context.CONNECTIVITY_SERVICE))
  1133.                 .getActiveNetworkInfo();
  1134.         if (info == null) {
  1135.             return false;
  1136.         } else {
  1137.             return info.isConnected();
  1138.         }
  1139.     }
  1140.  
  1141.     // ====================when desk change by
  1142.     // admin=================================================================================================================
  1143.  
  1144.     class WireStoryLoad extends AsyncTask<String, Void, Void> {
  1145.  
  1146.         private String result;
  1147.         private String res;
  1148.         private String[] resspl;
  1149.         private ProgressDialog dialog;
  1150.  
  1151.         // private SQLiteDatabase db;
  1152.  
  1153.         protected void onPreExecute() {
  1154.             // TODO Auto-generated method stub
  1155.  
  1156.             super.onPreExecute();
  1157.             dialog = ProgressDialog.show(context, "Loading...",
  1158.                     "Please Wait...");
  1159.         }
  1160.  
  1161.         protected Void doInBackground(String... params) {
  1162.             try {
  1163.                 if (isNetworkAvailable())
  1164.                 {
  1165.                     WireDetails("PTI");
  1166.                 }
  1167.  
  1168.             } catch (Exception er) {
  1169.                 // Toast.makeText(context, "DeskStoryLoad"+er.getMessage(),
  1170.                 // Toast.LENGTH_LONG).show();
  1171.                 // er.printStackTrace();
  1172.             }
  1173.             return null;
  1174.         }
  1175.  
  1176.         protected void onPostExecute(Void resut) {
  1177.             try {
  1178.                 new StoryData().execute("1");
  1179.             } catch (Exception e) {
  1180.                 // TODO: handle exception
  1181.             }
  1182.             dialog.dismiss();
  1183.  
  1184.             super.onPostExecute(resut);
  1185.         }
  1186.  
  1187.     }
  1188.  
  1189.     class WireStoryOnSelected extends AsyncTask<String, Void, Void> {
  1190.  
  1191.         private String result;
  1192.         private String res;
  1193.         private String[] resspl;
  1194.         private ProgressDialog dialog;
  1195.  
  1196.         // private SQLiteDatabase db;
  1197.  
  1198.         protected void onPreExecute() {
  1199.             // TODO Auto-generated method stub
  1200.  
  1201.             super.onPreExecute();
  1202.             dialog = ProgressDialog.show(context, "Loading...",
  1203.                     "Please Wait...");
  1204.         }
  1205.  
  1206.         protected Void doInBackground(String... params) {
  1207.             try
  1208.             {
  1209.                 if (isNetworkAvailable())
  1210.                 {
  1211.                     //parseJson("Story");
  1212.                     // if (g1.appfor.equalsIgnoreCase("ht"))
  1213.                     WireDetails(params[0]);
  1214.                 }
  1215.             } catch (Exception er) {
  1216.                 // Toast.makeText(context, "DeskStoryLoad"+er.getMessage(),
  1217.                 // Toast.LENGTH_LONG).show();
  1218.                 // er.printStackTrace();
  1219.             }
  1220.             return null;
  1221.         }
  1222.  
  1223.         protected void onPostExecute(Void resut) {
  1224.             try
  1225.             {
  1226.                 new StoryData().execute("1");
  1227.             }
  1228.             catch (Exception e) {
  1229.                 // TODO: handle exception
  1230.             }
  1231.             dialog.dismiss();
  1232.  
  1233.             super.onPostExecute(resut);
  1234.         }
  1235.  
  1236.     }
  1237.  
  1238.  
  1239.     public void parseJson(String jtype) {
  1240.         Cursor cur = null;
  1241.         try {
  1242.             SimpleDateFormat formatrecived = new SimpleDateFormat(
  1243.                     "yyyy-MM-dd hh:mm:ss");
  1244.             JSONParser jParser = new JSONParser();
  1245.             SoapObject table = null;
  1246.             String perdate;
  1247.             Calendar nnow = Calendar.getInstance();
  1248.             nnow.add(Calendar.DATE, -2);
  1249.  
  1250.             String day = String.valueOf(nnow.get(Calendar.DATE));
  1251.             String month = String.valueOf(nnow.get(Calendar.MONTH) + 1);
  1252.             String year = String.valueOf(nnow.get(Calendar.YEAR));
  1253.             if (month.length() != 2) {
  1254.                 month = "0" + month;
  1255.             }
  1256.             if (day.length() != 2) {
  1257.                 day = "0" + day;
  1258.             }
  1259.             perdate = day + "/" + month + "/" + year + " 00:00:00";
  1260.             table = jParser.soap(jtype, g1.deskcode, g1.groupcode);
  1261.  
  1262.             con.setSynkDateFun();
  1263.             con.setdeskData(table, perdate);
  1264.         } catch (Exception e) {
  1265.             con.setcatData();
  1266.         }
  1267.     }
  1268.  
  1269.     private String convert24to12(String time) {
  1270.         String convertedtime = "";
  1271.         String ampm = "";
  1272.         int ti;
  1273.         try {
  1274.             if (time != "") {
  1275.                 String timearr[] = time.split(":");
  1276.                 if (Integer.parseInt(timearr[0]) >= 12) {
  1277.                     ti = Integer.parseInt(timearr[0]) % 12;
  1278.                     if (ti == 0)
  1279.                         ti = 12;
  1280.                     ampm = "PM";
  1281.                 } else {
  1282.                     ti = Integer.parseInt(timearr[0]);
  1283.                     ampm = "AM";
  1284.                 }
  1285.                 if (timearr[1].length() < 2) {
  1286.                     timearr[1] = "0" + timearr[1];
  1287.                 }
  1288.                 convertedtime = "Last Successfull Sync :" + String.valueOf(ti)
  1289.                         + ":" + timearr[1] + " " + ampm;
  1290.             } else {
  1291.                 Time ime = new Time();
  1292.                 ime.setToNow();
  1293.                 String mint = "00";
  1294.                 if (String.valueOf(ime.minute).length() < 2) {
  1295.                     mint = "0" + ime.minute;
  1296.                 } else {
  1297.                     mint = String.valueOf(ime.minute);
  1298.                 }
  1299.  
  1300.                 if (ime.hour >= 12) {
  1301.                     ti = ime.hour % 12;
  1302.                     if (ti == 0)
  1303.                         ti = 12;
  1304.                     ampm = "PM";
  1305.                 } else {
  1306.                     ti = ime.hour;
  1307.                     ampm = "AM";
  1308.                 }
  1309.  
  1310.                 String tim = ime.hour + ":" + mint;
  1311.                 g1.setSynkTime(tim);
  1312.                 convertedtime = "Last Successfull Sync :" + tim;
  1313.             }
  1314.         } catch (Exception e) {
  1315.             // TODO: handle exception
  1316.         }
  1317.         return convertedtime;
  1318.     }
  1319.  
  1320.  
  1321.     public void DeskDetails(String Empcode) {
  1322.         ArrayList<String> list_desk = new ArrayList<String>();
  1323.         ArrayList<String> list_name = new ArrayList<String>();
  1324.         try {
  1325.             JSONParser jParser = new JSONParser();
  1326.             SoapObject table = null;
  1327.             table = jParser.deskDetails(Empcode);
  1328.             SoapObject tableRowData = null;
  1329.             if (table != null) {
  1330.                 for (int i = 0; i < table.getPropertyCount(); i++) {
  1331.                     tableRowData = (SoapObject) table.getProperty(i);
  1332.                     // DESKCODE,DESCRIPTION
  1333.                     String deskcodeL = tableRowData
  1334.                             .getPropertyAsString("DESKCODE");
  1335.                     String desknameL = tableRowData
  1336.                             .getPropertyAsString("DESCRIPTION");
  1337.                     list_desk.add(deskcodeL);
  1338.                     list_name.add(desknameL);
  1339.                 }
  1340.                 g1.listDesk.add(list_desk);
  1341.                 g1.listDesk.add(list_name);
  1342.             } else {
  1343.                 g1._login1 = 2;
  1344.             }
  1345.         } catch (Exception e) {
  1346.         }
  1347.     }
  1348.  
  1349.     public void WireDetails(String Empcode)
  1350.     {
  1351.         ArrayList<WireListData> listData = new ArrayList<>();
  1352.         ArrayList<String> list_heading = new ArrayList<String>();
  1353.         ArrayList<String> list_dat = new ArrayList<String>();
  1354.         ArrayList<String> list_str=new ArrayList<String>();
  1355.         try
  1356.         {
  1357.             JSONParser jParser = new JSONParser();
  1358.             SoapObject table = null;
  1359.             table = jParser.getWireData(Empcode);
  1360.             SoapObject tableRowData = null;
  1361.             g1.wireList.clear();
  1362.             if (table != null)
  1363.             {
  1364.                 for (int i = 0; i < table.getPropertyCount(); i++) {
  1365.                     tableRowData = (SoapObject) table.getProperty(i);
  1366.                     // DESKCODE,DESCRIPTION
  1367.  
  1368.                     String deskcodeL = tableRowData.getPropertyAsString("Heading");
  1369.                     String desknameL = tableRowData.getPropertyAsString("storydate");
  1370.                     desknameL=desknameL.split("T")[1].toString().substring(0,8);
  1371.                     String storyL = tableRowData.getPropertyAsString("story");
  1372.                     listData.add(new WireListData(deskcodeL, desknameL, storyL));
  1373.                     list_heading.add(deskcodeL);
  1374.                     list_dat.add(desknameL);
  1375.                     list_str.add(storyL);
  1376.                 }
  1377.                 g1.wireList.add(list_heading);
  1378.                 g1.wireList.add(list_dat);
  1379.                 g1.wireList.add(list_str);
  1380.             }
  1381.             else
  1382.             {
  1383.                 g1.wireList.clear();
  1384.                 g1._login1 = 2;
  1385.             }
  1386.         }
  1387.         catch (Exception e)
  1388.         {
  1389.             e.printStackTrace();
  1390.         }
  1391.         finally {
  1392.             adapterwire = new WireListAdapter(listData,WireList.this,WireList.this);
  1393.  
  1394. //setting adapter to recyclerview
  1395.             recyclerlist.setAdapter(adapterwire);
  1396.         }
  1397.     }
  1398.  
  1399.     // spanable
  1400.     public SpannableString setString(String textdata) {
  1401.         SpannableString spn = null;
  1402.         Typeface face1;
  1403.         try {
  1404.             String new_string = textdata.replace("<s><h>", "")
  1405.                     .replace("</h></s>", "").replace("<s><e>", "")
  1406.                     .replace("</e></s>", "");
  1407.             spn = new SpannableString(new_string);
  1408.             String stm[] = textdata.split("<s>");
  1409.             int nextcount = 0;
  1410.             if (!new_string.equals("")) {
  1411.                 for (int mmt = 0; mmt < stm.length; mmt++) {
  1412.                     // mm
  1413.                     String FontName1 = g1.FontName;
  1414.                     String FontName2 = "TimesNewRoman.ttf";
  1415.                     String _fontName = "";
  1416.                     String str1 = stm[mmt];
  1417.  
  1418.                     if (!str1.trim().equals("")) {
  1419.                         if (str1.contains("<h>")) {
  1420.                             str1 = str1.replace("<h>", "").replace("</h></s>",
  1421.                                     "");
  1422.                             face1 = Typeface.createFromAsset(getAssets(),
  1423.                                     "font/" + FontName1);
  1424.                             _fontName = FontName1;
  1425.                         } else if (!str1.contains("<e>")
  1426.                                 && !str1.contains("<h>")) {
  1427.                             str1 = str1.replace("<h>", "")
  1428.                                     .replace("</h></s>", "").replace("<e>", "")
  1429.                                     .replace("</e></s>", "");
  1430.                             face1 = Typeface.createFromAsset(getAssets(),
  1431.                                     "font/" + FontName1);
  1432.                             _fontName = FontName1;
  1433.                         } else {
  1434.                             str1 = str1.replace("<e>", "").replace("</e></s>",
  1435.                                     "");
  1436.                             face1 = Typeface.createFromAsset(getAssets(),
  1437.                                     "font/" + FontName2);
  1438.                             _fontName = FontName2;
  1439.                         }
  1440.                         if (!str1.trim().equals(""))
  1441.                             spn.setSpan(new spantypeface(_fontName, face1),
  1442.                                     nextcount, nextcount + str1.length(),
  1443.                                     Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  1444.                         nextcount = nextcount + str1.length();
  1445.                     }
  1446.                 }
  1447.             }
  1448.         } catch (Exception e) {
  1449.             // TODO: handle exception
  1450.         }
  1451.         return spn;
  1452.     }
  1453.  
  1454. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement