Advertisement
Guest User

Untitled

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