Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tni.mo;
- import android.app.AlertDialog;
- import android.app.ProgressDialog;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.database.Cursor;
- import android.graphics.Color;
- import android.graphics.Point;
- import android.graphics.Typeface;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.provider.Settings;
- import android.support.v7.app.ActionBar;
- import android.support.v7.widget.DividerItemDecoration;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.support.v7.widget.Toolbar;
- import android.text.SpannableString;
- import android.text.Spanned;
- import android.text.format.Time;
- import android.util.DisplayMetrics;
- import android.view.Display;
- import android.view.Gravity;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.ViewGroup;
- import android.widget.AdapterView;
- import android.widget.AdapterView.OnItemSelectedListener;
- import android.widget.ArrayAdapter;
- import android.widget.Button;
- import android.widget.CheckBox;
- import android.widget.EditText;
- import android.widget.Filter;
- import android.widget.Filterable;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.LinearLayout.LayoutParams;
- import android.widget.ListView;
- import android.widget.PopupWindow;
- import android.widget.ProgressBar;
- import android.widget.RelativeLayout;
- import android.widget.ScrollView;
- import android.widget.SearchView;
- import android.widget.Spinner;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.google.api.client.http.HttpResponse;
- import com.tni.mo.Adapter.WireListAdapter;
- import com.tni.mo.R;
- import org.apache.http.HttpEntity;
- import org.apache.http.entity.StringEntity;
- import org.apache.http.protocol.HTTP;
- import org.apache.http.util.EntityUtils;
- import org.json.JSONArray;
- import org.json.JSONObject;
- import org.ksoap2.serialization.SoapObject;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Timer;
- import pl.polidea.view.ZoomView;
- public class WireList extends BaseActivity implements WireListAdapter.WireListAdapterListiner{
- final Context context = this;
- WireListAdapter adapterwire;
- ZoomView zoom;
- LinearLayout _center10, _centerMain1, _masterLayout, _center, _center1,
- _center2, _headerIconLayout, _headerSettingLayout,
- _wordCountLayout, _filterType, _backLayout, _SynkLayout;
- ListView listView;
- RelativeLayout _subMaster, _header, _centerTop, _bottom, heading_header;
- LinearLayout _ListTypeLayout;
- RelativeLayout.LayoutParams _headerparams, _centerparams, _bottomParams,
- paramsIcon, paramsSetting, _listtypeRule, _filterTypeRule,
- _wordcountRule, _centerTopRule, _backButtonRule, _synkdateRule;
- ScrollView _centerScroller;
- TextView _wordCountCation, _headingCap, _statusCap, _dateCap,
- _uploadstatusCap, _storyidCap, Story_uni, _supporttext, _LoginUser,
- _synkDate, _pageCaption; // _keywordsCaption,_sourceCaption,_categoryCaption,_wordCountCation,_supporttext,_imageCaption;
- EditText _headingText, _locationText, _storyText, _bylineText,
- _tagnameText, _keywordsText, _sourceText, _wordCountText,
- _imageText;
- ImageView _Submit, _Clear, _menuIcon, _settingIcon, upload, imageA,
- imageView1, imageViewNew, _backIcon;
- CheckBox _dBreaking, _dHome, _dTicker;
- RecyclerView recyclerlist;
- Button _attachment;
- Timer _tempsave = new Timer();
- View ruler, _view;
- List<WireListData> dataList;
- int _height, _width;
- int _headerHeight, _cenerHeight, _spinnerHeight;
- int _headCapwidth = 0, _headCapHeight = 0, _storyTextHeight = 0,
- _widthHeaderIcon = 0, _wordcountWidth = 0, _imageWidth = 0,
- _imageHeight = 0, _listtypewidth = 0, _keyboardWidth = 0;
- int marginTop = 0;
- int dropdownwidth = 0;
- int imageHeight = 0;
- int textSize = 0, _listContent = 0, _contentSize = 0;
- int carapp = 0, carapp1 = 0;
- int cursorposition = 0;
- int _startPos = 0;
- int keytype = 0;
- int refreshbutton = 0;
- int _lheadingWidth = 0, _lstatusWidth = 0, _ldateWidth = 0,
- _luploadWidth = 0;
- boolean back_flag = false, specialkeyPressed_flag = false, spchar1 = false,
- spchar2 = false;
- char matra, backcar;
- // keybord layout
- TextView _keyboardCaption,viewmore;
- Spinner _spinAssetType, _spinFilter;
- int searchwidth;
- int morewidth;
- Typeface face;
- Typeface faceCaption;
- Globals g1 = Globals.getInstance();
- // login details variables
- String _empcode, _centercode, _deskcode, _username, _password, _groupcode,
- _displayname, _languagecode, _keybordType;
- // form inpu values
- String _dbreakingValue = "0";
- String _dhomeValue = "0";
- String _dtickerValue = "0";
- // forTempSave
- String _storyCode = "";
- String flag = "off";
- String assetType = "Story";
- int filterType = 0;
- int mu = 0;
- // /popup window
- PopupWindow spopUp;
- Point point;
- Boolean flagpopw = true;
- Boolean flag1 = true;
- LinearLayout sv;
- LinearLayout llc2;
- ArrayAdapter adapterlist;
- // end tempsave
- connection con = connection.getInstance(this);
- JSONParser parsor = new JSONParser();
- private ArrayList<String> listId = new ArrayList<String>();
- private ArrayList<String> listHead1 = new ArrayList<String>();
- private ArrayList<String> listStr1 = new ArrayList<String>();
- private ArrayList<String> listDt = new ArrayList<String>();
- ArrayList<String> storytime = new ArrayList<String>();
- private ArrayList<String> languageCodes = new ArrayList<String>();
- //String options1[] = { "BSS Bangla","BSS English","AFP","Reuters" };
- int count = 0;
- int flagch = 0;
- boolean flagcheck = true;
- boolean deviceType;
- public void setLoginData() {
- _empcode = g1.empcode;
- _centercode = g1.centercode;
- _deskcode = g1.deskcode;
- _username = g1.username;
- _password = g1.password;
- _groupcode = g1.groupcode;
- _displayname = g1.displayname;
- _languagecode = g1.languagecode;
- _keybordType = g1.keybordType;
- }
- public void setDisplaydim() {
- _headCapwidth = (int) (_width * 0.20);
- _headCapHeight = (int) (_height * 0.06);
- _storyTextHeight = (int) (_height * 0.35);
- textSize = 18;
- _contentSize = 25;
- _listContent = 16;
- _imageWidth = (int) (_width * 0.2);
- _imageHeight = (int) (_height * .14);
- // list
- _lheadingWidth = (int) (_width * 0.50);
- _lstatusWidth = (int) (_width * 0.20);
- _ldateWidth = (int) (_width * 0.17);
- _luploadWidth = (int) (_width * 0.18);
- _listtypewidth = (int) (_width * 0.7);
- _keyboardWidth = (int) (_listtypewidth * 0.5);
- if (_height > _width) {
- _headerHeight = (int) (_height * 0.05);
- _cenerHeight = (int) (_height * 0.9);
- _widthHeaderIcon = (int) (_width * 0.25);
- _wordcountWidth = (int) (_width * 0.08);
- refreshbutton = (int) (_width * 0.1);
- g1._popupheight = (int) (_height * (0.6));
- g1._popupWidth = (int) (_width * (0.5));
- g1.popupfontsize = (int) (_height * 0.02);
- _spinnerHeight = (int) (_height * 0.06);
- if (_height <= 800 && _width <= 500) {
- g1._iconSize = 45;
- } else if (_height <= 1100 && _width <= 600) {
- g1._iconSize = 30;
- } else if (_height <= 1920 && _width <= 1080) {
- g1._iconSize = 50;
- textSize = (int) (_height * 0.02);
- _contentSize = (int) (_height * 0.025);
- }
- } else {
- _headerHeight = (int) (_width * 0.05);
- _cenerHeight = (int) (_width * 0.9);
- _widthHeaderIcon = (int) (_width * 0.20);
- _wordcountWidth = (int) (_width * 0.02);
- refreshbutton = (int) (_width * 0.08);
- g1._popupheight = (int) (_height * (0.8));
- g1._popupWidth = (int) (_width * (0.3));
- g1.popupfontsize = (int) (_width * 0.02);
- _spinnerHeight = (int) (_width * 0.07);
- if (_width <= 800 && _height <= 500) {
- g1._iconSize = 45;
- } else if (_width <= 1100 && _height <= 600) {
- g1._iconSize = 30;
- } else if (_width <= 1920 && _height <= 1080) {
- g1._iconSize = 50;
- textSize = (int) (_width * 0.02);
- _contentSize = (int) (_width * 0.025);
- }
- }
- }
- public void displayConfgh() {
- Display _display;
- _display = getWindowManager().getDefaultDisplay();
- _height = _display.getHeight();
- _width = _display.getWidth();
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- getLayoutInflater().inflate(R.layout.wire_list, frameLayout);
- listView=(ListView)findViewById(R.id.searchlistview);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- String item=(String) listView.getItemAtPosition(i);
- Toast.makeText(context, item, Toast.LENGTH_SHORT).show();
- /* LinearLayout lk = (LinearLayout) view.getParent();
- int position = (Integer) view.getTag();
- String tmpStr10 = String.valueOf(position);
- new Storyres().execute(tmpStr10);*/
- }
- });
- // String[] check={"shivam","ashutosh","himanshu","vishal","shubham","rishabh"};
- adapterlist=new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,listHead1);
- listView.setAdapter(adapterlist);
- displayConfgh();
- setDisplaydim();
- setLoginData();
- deviceType = Globals.isTablet(context);
- /*if (isNetworkAvailable())
- new WireStoryLoad().execute();
- */
- /*getActionBar().setDisplayShowCustomEnabled(true);
- getActionBar().setDisplayShowHomeEnabled(false);
- getActionBar().setDisplayShowTitleEnabled(false);*/
- DisplayMetrics metrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(metrics);
- int dens=getResources().getDisplayMetrics().densityDpi;
- {
- if(dens>=DisplayMetrics.DENSITY_MEDIUM && dens<DisplayMetrics.DENSITY_HIGH ) {
- _contentSize = (int) (_height * 0.022);
- if (deviceType) {
- textSize = (int) (_height * 0.014);
- g1._iconSize = 45;
- _headCapHeight = (int) (_height * 0.06);
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.014);
- dropdownwidth = (int) (_width * 0.25);
- searchwidth = (int) (_width * 0.5);
- imageHeight = (int) (_height * 0.35);
- } else {
- textSize = (int) (_height * 0.028);
- g1._iconSize = 45;
- _headCapHeight = (int) (_height * 0.06);
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.014);
- dropdownwidth = (int) (_width * 0.25);
- imageHeight = (int) (_height * 0.35);
- }
- }
- else if(dens>=DisplayMetrics.DENSITY_HIGH && dens<DisplayMetrics.DENSITY_XHIGH ) {
- _contentSize = (int) (_height * 0.016);
- if (deviceType) {
- textSize = (int) (_height * 0.02);
- g1._iconSize = 50;
- _headCapHeight = (int) (_height * 0.04);
- _wordcountWidth = (int) (_height * 0.08);
- marginTop = (int) (_height * 0.016);
- dropdownwidth = (int) (_width * 0.25);
- imageHeight = (int) (_height * 0.35);
- } else {
- textSize = (int) (_height * 0.03);
- _headCapHeight = (int) (_height * 0.06);
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.016);
- dropdownwidth = (int) (_width * 0.25);
- imageHeight = (int) (_height * 0.30);
- g1._iconSize = 50;
- }
- }
- else if(dens>=DisplayMetrics.DENSITY_XHIGH && dens<DisplayMetrics.DENSITY_XXHIGH ) {
- _contentSize = (int) (_height * 0.014);
- if (deviceType) {
- textSize = (int) (_height * 0.01);
- g1._iconSize = 70;
- _headCapHeight = (int) (_height * 0.07);
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.016);
- dropdownwidth = (int) (_width * 0.25);
- imageHeight = (int) (_height * 0.40);
- } else {
- _headCapHeight = (int) (_height * 0.06);
- textSize = (int) (_height * 0.02);
- g1._iconSize = 50;
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.018);
- dropdownwidth = (int) (_width * 0.30);
- imageHeight = (int) (_height * 0.35);
- }
- }
- else if(dens>=DisplayMetrics.DENSITY_XXHIGH && dens<DisplayMetrics.DENSITY_XXXHIGH ) {
- _contentSize = (int) (_height * 0.010);
- if (deviceType) {
- textSize = (int) (_height * 0.02);
- _headCapHeight = (int) (_height * 0.1);
- g1._iconSize = 80;
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.018);
- dropdownwidth = (int) (_width * 0.28);
- imageHeight = (int) (_height * 0.35);
- } else {
- textSize = (int) (_height * 0.02);
- _headCapHeight = (int) (_height * 0.07);
- g1._iconSize = 60;
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.018);
- dropdownwidth = (int) (_width * 0.28);
- imageHeight = (int) (_height * 0.40);
- }
- }
- else if(dens>=DisplayMetrics.DENSITY_XXXHIGH ) {
- _contentSize = (int) (_height * 0.008);
- if (deviceType) {
- textSize = (int) (_height * 0.02);
- _headCapHeight = (int) (_height * 0.02);
- g1._iconSize = 80;
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.02);
- dropdownwidth = (int) (_width * 0.3);
- imageHeight = (int) (_height * 0.4);
- } else {
- textSize = (int) (_height * 0.029);
- _headCapHeight = (int) (_height * 0.029);
- g1._iconSize = 60;
- _wordcountWidth = (int) (_height * 0.10);
- marginTop = (int) (_height * 0.029);
- dropdownwidth = (int) (_width * 0.3);
- imageHeight = (int) (_height * 0.35);
- }
- }
- }
- g1.Autow_da = "Author";
- // --------------------------------------------------------
- RelativeLayout ll = new RelativeLayout(context);
- ll.setLayoutParams(new RelativeLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- ll.setBackgroundColor(Color.parseColor("#1C92DC"));
- ImageView moreimg = new ImageView(this);
- moreimg.setId(R.id.moreimg);
- moreimg.setImageResource(R.drawable.menuico);
- RelativeLayout.LayoutParams paramsmenu = new RelativeLayout.LayoutParams(
- (int) (_height * 0.05), (int) (_height * 0.05));
- paramsmenu.setMargins((int) Math.ceil(5 * (metrics.density)), 0, 0, 0);
- paramsmenu.addRule(RelativeLayout.CENTER_VERTICAL);
- moreimg.setLayoutParams(paramsmenu);
- moreimg.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
- mDrawerLayout.closeDrawer(mDrawerList);
- } else {
- mDrawerLayout.openDrawer(mDrawerList);
- }
- }
- });
- ImageView img_logo = new ImageView(this);
- img_logo.setId(R.id.logoid);
- RelativeLayout.LayoutParams menuparam1 = new RelativeLayout.LayoutParams(
- (int) (_width * 0.4), LayoutParams.MATCH_PARENT);
- menuparam1.setMargins(0, 5, 0, 5);
- menuparam1.addRule(RelativeLayout.CENTER_HORIZONTAL, moreimg.getId());
- img_logo.setLayoutParams(menuparam1);
- img_logo.setImageResource(R.drawable.fourclogo);
- ll.addView(img_logo);
- ll.addView(moreimg);
- ImageView img_home = new ImageView(this);
- RelativeLayout.LayoutParams menuparam2 = new RelativeLayout.LayoutParams((int) (_height * 0.05), (int) (_height * 0.05));
- menuparam2.setMargins((int) Math.ceil(5 * (metrics.density)), 0, 0, 0);
- menuparam2.addRule(RelativeLayout.CENTER_VERTICAL);
- menuparam2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, img_logo.getId());
- img_home.setLayoutParams(menuparam2);
- img_home.setImageResource(R.drawable.icon_home);
- img_home.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent nextScreen=null;
- if(g.appname.equalsIgnoreCase("MT Vaani"))
- {
- nextScreen = new Intent(getApplicationContext(), DataList.class);
- }
- else
- {
- nextScreen = new Intent(getApplicationContext(), EditorPage.class);
- }
- startActivity(nextScreen);
- }
- });
- ll.addView(img_home);
- getSupportActionBar().setCustomView(ll);
- //===========================================================================================
- ActionBar ab = getSupportActionBar();
- //ab.setHomeAsUpIndicator(R.drawable.ic_menu); // set a custom icon for the default home button
- ab.setDisplayShowHomeEnabled(false); // show or hide the default home button
- ab.setDisplayHomeAsUpEnabled(false);
- ab.setDisplayShowCustomEnabled(true); // enable overriding the default toolbar layout
- ab.setDisplayShowTitleEnabled(false); // d
- Toolbar parent =(Toolbar) ll.getParent();
- parent.setContentInsetsAbsolute(0,0);
- //===========================================================================================
- // ---------------------------------------------
- face = Typeface.createFromAsset(getAssets(), "font/" + g1.HindiFont);
- faceCaption = Typeface.createFromAsset(getAssets(), "font/"
- + g1.FontCaption);
- LinearLayout _mymasterLayout = (LinearLayout) findViewById(R.id.mywirelist);
- zoom = new ZoomView(this);
- _mymasterLayout.addView(zoom);
- _masterLayout = new LinearLayout(this);
- _masterLayout.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
- _masterLayout.setBackgroundColor(Color.WHITE);
- _masterLayout.setOrientation(LinearLayout.VERTICAL);
- _subMaster = new RelativeLayout(this);
- _subMaster.setBackgroundColor(Color.WHITE);
- _subMaster.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT));
- // header
- // Layout==========================================================================================================
- _header = new RelativeLayout(this);
- _header.setBackgroundColor(Color.parseColor("#252525"));
- _header.setId(R.id.header);
- _headerparams = new RelativeLayout.LayoutParams(
- LayoutParams.FILL_PARENT, _headerHeight);
- _headerparams.addRule(RelativeLayout.ALIGN_PARENT_TOP,
- RelativeLayout.TRUE);
- TextView _caption = new TextView(this);
- RelativeLayout.LayoutParams _captionRule = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, (int) (_height * 0.05));
- _captionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- _caption.setLayoutParams(_captionRule);
- _caption.setText(" Wire News ");
- _caption.setGravity(Gravity.CENTER_VERTICAL);
- _caption.setPadding(10, 0, 0, 0);
- _caption.setTextColor(Color.WHITE);
- _caption.setTypeface(faceCaption, Typeface.NORMAL);
- _caption.setTextSize(0, textSize);
- _header.addView(_caption);
- _subMaster.addView(_header, _headerparams);
- // Bottom
- // Layout=========================================================================================================
- _bottom = new RelativeLayout(this);
- _bottom.setBackgroundColor(Color.parseColor(g1._headerColor));
- _bottom.setId(R.id.bottom);
- _bottom.setPadding(0, 10, 0, 0);
- _bottomParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, _headerHeight);
- _bottomParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
- _backLayout = new LinearLayout(this);
- _backLayout.setGravity(Gravity.CENTER_HORIZONTAL);
- _backButtonRule = new RelativeLayout.LayoutParams(refreshbutton,LayoutParams.WRAP_CONTENT);
- _backButtonRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
- /*_backIcon = new ImageView(this);
- _backIcon.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT));
- _backIcon.setImageResource(R.drawable.refresh2);
- _backLayout.addView(_backIcon);
- _bottom.addView(_backLayout, _backButtonRule);
- _backLayout.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- // DeskDetails(g1.empcode);
- *//*if (isNetworkAvailable())
- new WireStoryLoad().execute();*//*
- return false;
- }
- });*/
- _SynkLayout = new LinearLayout(this);
- _synkdateRule = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- _synkdateRule.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE);
- _synkDate = new TextView(this);
- _synkDate.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
- _synkDate.setTypeface(faceCaption, Typeface.BOLD_ITALIC);
- //_synkDate.setText(convert24to12(g1.getSynkTime()));
- _synkDate.setText("");
- _synkDate.setTextSize(0, textSize);
- _synkDate.setTextColor(Color.parseColor(g1._baseColor));
- _SynkLayout.addView(_synkDate);
- _bottom.addView(_SynkLayout, _synkdateRule);
- _subMaster.addView(_bottom, _bottomParams);
- // CenterLayout
- // Top=========================================================================================================
- _centerTop = new RelativeLayout(this);
- _centerTop.setId(R.id.centerTop);
- _centerTop.setBackgroundColor(Color.WHITE);// .parseColor(g1._baseColor));
- _centerTopRule = new RelativeLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, (int) (_height * 0.05));
- _centerTopRule.addRule(RelativeLayout.BELOW, _header.getId());
- _centerMain1 = new LinearLayout(this);
- _centerMain1.setLayoutParams(new LayoutParams(
- LayoutParams.MATCH_PARENT,
- android.app.ActionBar.LayoutParams.WRAP_CONTENT));
- _centerMain1.setPadding(10, 10, 0, 0);
- _centerMain1.setWeightSum(2);
- // 1.=====================================================
- _center1 = new LinearLayout(this);
- _center1.setOrientation(LinearLayout.HORIZONTAL);
- _center1.setLayoutParams(new LayoutParams(0,
- LayoutParams.WRAP_CONTENT, 1.4f));
- SearchView searchView=new SearchView(this);
- searchView.setLayoutParams(new LayoutParams(searchwidth,LayoutParams.WRAP_CONTENT));
- recyclerlist = new RecyclerView(this);
- recyclerlist.setLayoutParams(new LayoutParams(0, LayoutParams.MATCH_PARENT, 10));
- recyclerlist.setPadding(0, 0, 0, 0);
- recyclerlist.setHasFixedSize(true);
- recyclerlist.addItemDecoration(new DividerItemDecoration(this,
- DividerItemDecoration.VERTICAL));
- //recyclerlist.setNestedScrollingEnabled(false);
- recyclerlist.setLayoutManager(new LinearLayoutManager(this));
- /*dataList= new ArrayList<WireListData>();
- dataList.add(
- new WireListData("Politics","12/09/1994"));
- dataList.add(
- new WireListData("Economy","12/09/1994"));
- dataList.add(
- new WireListData("Sports","Friday,Dec 21,2018, 4:10 (IST)"));
- dataList.add(
- new WireListData("Sports","Friday,Dec 21,2018, 4:20 (IST)"));
- dataList.add(
- new WireListData("Politics","Friday,Dec 21,2018, 4:30 (IST)"));
- dataList.add(
- new WireListData("Economy","Friday,Dec 21,2018, 4:40 (IST)"));*/
- // adapterwire = new WireListAdapter(dataList);
- //setting adapter to recyclerview
- // recyclerlist.setAdapter(adapterwire);
- viewmore = new TextView(this);
- viewmore.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 10));
- viewmore.setText("ViewMore");
- viewmore.setPadding(0, 0, 0, 0);
- viewmore.setTypeface(faceCaption, Typeface.BOLD);
- viewmore.setTextSize(0, textSize);
- searchView = new SearchView(this);
- searchView.setQueryHint("Search Here");
- searchView.setLayoutParams(new LayoutParams((int) (_width * 10), LayoutParams.WRAP_CONTENT, 10));
- searchView.setPadding(0, 0, 0, 0);
- searchView.setOnCloseListener(new SearchView.OnCloseListener() {
- @Override
- public boolean onClose() {
- listView.setVisibility(View.GONE);
- return false;
- }
- });
- searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
- @Override
- public boolean onQueryTextSubmit(String s) {
- adapterwire.getFilter().filter(s);
- return false;
- }
- @Override
- public boolean onQueryTextChange(String s) {
- adapterwire.getFilter().filter(s);
- if (s.isEmpty()){
- //listView.setVisibility(View.GONE);
- }else {
- //listView.setVisibility(View.VISIBLE);
- //adapterlist.getFilter().filter(s);
- /*List<WireListData> list=null;
- for(WireListData d: dataList){
- if(d.getHeadline().contains(s)){
- list.add(d);
- }
- }*/
- //adapterwire.updateList(list);
- }
- return false;
- }
- });
- /* void filter(String text){
- List<WireListData> temp;
- for(WireListData d: dataList){
- //or use .equal(text) with you want equal match
- //use .toLowerCase() for better matches
- if(d.getEnglish().contains(text)){
- temp.add(d);
- }
- }
- //update recyclerview
- disp_adapter.updateList(temp);
- }*/
- _spinAssetType = new Spinner(this);
- _spinAssetType.setLayoutParams(new LayoutParams(dropdownwidth, LayoutParams.WRAP_CONTENT));
- _spinAssetType.setBackgroundResource(R.drawable.custom_spinner);
- CustomSpinnerEditorAdapter adapter = new CustomSpinnerEditorAdapter(context, g.options1, textSize);
- _spinAssetType.setAdapter(adapter);
- _spinAssetType.setSelection(0);
- _spinAssetType.setOnItemSelectedListener(new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parameters, View arg1,
- int index, long arg3) {
- if (flagch == 0) {
- flagcheck = false;
- flagch = flagch + 1;
- }
- new WireStoryOnSelected().execute(parameters.getSelectedItem().toString());
- }
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
- }
- });
- _center1.addView(_spinAssetType);
- _supporttext = new TextView(this);
- _supporttext.setLayoutParams(new LayoutParams(20, 0));
- _center1.addView(_supporttext);
- try {
- if (g1._login1 != 2 && g1.listDesk != null
- && g1.listDesk.get(1).size() != 0) {
- /*
- * _spinFilter=new Spinner(this); _spinFilter.setPadding(5, 0,
- * 0, 0); _spinFilter.setLayoutParams(new
- * LinearLayout.LayoutParams
- * (LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
- */
- _spinFilter = new Spinner(this);
- _spinFilter.setLayoutParams(new LayoutParams(
- dropdownwidth, LayoutParams.WRAP_CONTENT));
- _spinFilter.setBackgroundResource(R.drawable.custom_spinner);
- String[] options = new String[g1.listDesk.get(1).size() + 1];
- try {
- options[0] = "---";
- for (int i = 0; i < g1.listDesk.get(1).size(); i++)
- {
- options[i + 1] = g1.listDesk.get(1).get(i);
- if (g1.newdeskcode.equalsIgnoreCase("0")) {
- if (g1.listDesk.get(0).get(i).equals(g1.deskcode)) {
- mu = i + 1;
- }
- } else {
- if (g1.listDesk.get(0).get(i).equals(g1.newdeskcode)) {
- mu = i + 1;
- }
- }
- }
- } catch (Exception e) {
- }
- _center1.addView(searchView);
- CustomSpinnerEditorAdapter adapter1= new CustomSpinnerEditorAdapter(context, options, textSize);
- _spinFilter.setAdapter(adapter1);
- _spinFilter.setSelection(mu);
- _center1.addView(_spinFilter);
- _spinFilter.setOnItemSelectedListener(new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> items,
- View arg1, int pos, long arg3) {
- if (flagcheck == true) {
- int deskcodem = g1.setDeskCode(items
- .getItemAtPosition(pos).toString(),
- pos);
- if (isNetworkAvailable())
- new WireStoryLoad().execute();
- } else {
- flagcheck = true;
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
- }
- });
- }
- } catch (Exception e) {
- }
- _center1.addView(searchView);
- _center10 = new LinearLayout(this);
- LayoutParams myparams = new LayoutParams(0,
- _headerHeight, .6f);
- myparams.setMargins(10, 0, 15, 0);
- _center10.setLayoutParams(myparams);
- _center10.setGravity(Gravity.RIGHT);
- _wordCountCation = new TextView(this);
- _wordCountCation.setLayoutParams(new LayoutParams(
- _headCapwidth, _headCapHeight));
- _wordCountCation.setTypeface(faceCaption, Typeface.BOLD);
- _wordCountCation.setTextSize(0, textSize);
- _center10.addView(_wordCountCation);
- _centerMain1.addView(_center1);
- _centerMain1.addView(_center10);
- _centerTop.addView(_centerMain1);
- _subMaster.addView(_centerTop, _centerTopRule);
- // Centeral Layout
- // =======================================================================================================
- _centerScroller = new ScrollView(this);
- _centerScroller.setBackgroundColor(Color.parseColor(g1._baseColor));
- _centerScroller.setVerticalScrollBarEnabled(true);
- _centerparams = new RelativeLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
- _centerparams.addRule(RelativeLayout.BELOW, _centerTop.getId());
- _centerparams.addRule(RelativeLayout.ABOVE, _bottom.getId());
- _center = new LinearLayout(this);
- _center.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
- _center.setOrientation(LinearLayout.VERTICAL);
- _center.setPadding(5, 5, 5, 5);
- _centerScroller.addView(_center);
- _subMaster.addView(_centerScroller, _centerparams);
- // addViews==============================================================================================================
- _masterLayout.addView(_subMaster);
- zoom.addView(_masterLayout);
- // setContentView(zoom);
- // new StoryData().execute("8");
- }
- @Override
- public void onBackPressed() {
- try {
- if (flagpopw == false) {
- spopUp.dismiss();
- flagpopw = true;
- } else {
- Intent main = new Intent(context, EditorPage.class);
- finish();
- startActivity(main);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Override
- public void onSelected(WireListData item) {
- }
- // =========================story======================================
- class StoryData extends AsyncTask<String, Void, Void> {
- private Cursor cur1 = null;
- private ProgressDialog dia;
- int count = 0;
- private String statusre;
- @Override
- protected void onPreExecute() {
- runOnUiThread(new Runnable() {
- public void run() {
- try {
- dia = ProgressDialog.show(context, "Loading...",
- "Please wait...");
- } catch (Exception e) {
- }
- }
- });
- super.onPreExecute();
- }
- @Override
- protected Void doInBackground(String... params) {
- try
- {
- count = 0;
- // cur1 = con.getDeskAssignerList(params[0]);
- listId = new ArrayList<String>();
- listHead1 = new ArrayList<>();
- listStr1 =new ArrayList<String>();
- listDt = new ArrayList<String>();
- // if (cur1 != null) {
- // cur1.moveToFirst();
- // count = cur1.wireList();
- count=g1.wireList.get(0).size();
- for (int i = 0; i < g1.wireList.get(0).size(); i++) {
- // String id=g1.wireList.get(1)
- String head = g1.wireList.get(0).get(i).toString();
- listHead1.add(head);
- String dt = g1.wireList.get(1).get(i).toString();
- listDt.add(dt);
- String str = g1.wireList.get(2).get(i).toString();
- listStr1.add(str);
- }
- // }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- /*
- * if (cur1 != null) { if (!cur1.isClosed()) cur1.close(); }
- */
- con.close();
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- try {
- layout_list2(listHead1, listDt,listStr1);
- adapterlist = new ArrayAdapter(context, android.R.layout.simple_list_item_1, listHead1);
- listView.setAdapter(adapterlist);
- } catch (Exception exf) {
- finish();
- }
- dia.dismiss();
- super.onPostExecute(result);
- }
- }
- public void layout_list2(ArrayList<String> head, ArrayList<String> dt,ArrayList<String>Stry) {
- if (head.size() > 0)
- _wordCountCation.setText("Total: " + head.size());
- else
- _wordCountCation.setText("Total: " + head.size());
- _center.removeAllViews();
- ruler = new View(this);
- ruler.setBackgroundColor(0xFFcacbc6);
- _center2 = new LinearLayout(this);
- _center2.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- _center2.setOrientation(LinearLayout.HORIZONTAL);
- _center2.setWeightSum(10);
- _center2.addView(recyclerlist);
- _center.addView(_center2);
- _center.addView(ruler, new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.FILL_PARENT, 2));
- for (int a = 0; a < head.size(); a++) {
- ruler = new View(this);
- ruler.setBackgroundColor(0xFFcacbc6);
- _center1 = new LinearLayout(this);
- _center1.setOrientation(LinearLayout.HORIZONTAL);
- _center1.setPadding(0, 5, 0, 5);
- _center1.setLayoutParams(new LayoutParams(
- LayoutParams.FILL_PARENT,
- LayoutParams.WRAP_CONTENT));
- _center1.setWeightSum(10);
- /*con.reqLanguagepos(Integer
- .parseInt(languageCodes.get(a).toString()));
- face = Typeface.createFromAsset(getAssets(), "font/" + g1.FontName);
- if (g.appfor.equals("pn"))
- face = Typeface.createFromAsset(getAssets(), "font/"
- + g1.ResionalFont);
- _headingCap.setTypeface(face);*/
- /* comment by shivam */
- //DT
- /*_headingCap.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- LinearLayout lk = (LinearLayout) v.getParent();
- TextView t0 = (TextView) lk.getChildAt(3);
- TextView t1 = (TextView) lk.getChildAt(4);
- TextView t2 = (TextView) lk.getChildAt(5);
- String sccode = t1.getText().toString();
- String sstatus = t2.getText().toString();
- String versi = t0.getText().toString();
- try {
- g1.assign = t2.getText().toString();
- } catch (Exception ex) {
- g1.assign = "N";
- }
- new Storyres().execute(sccode, versi);
- }
- });*/
- }
- if (count == 0 && g1.unknownhostexception.equals("Y")) {
- Toast.makeText(context, "Message:Proxy is missing.",
- Toast.LENGTH_LONG).show();
- // createNetErrorDialog();
- }
- }
- protected void createNetErrorDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(
- "You Lost Proxy, So please turn on mobile network or Wi-Fi in Settings to enable proxy.")
- .setTitle("Unable to connect")
- .setCancelable(false)
- .setPositiveButton("Settings",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- Intent i = new Intent(
- Settings.ACTION_WIRELESS_SETTINGS);
- startActivity(i);
- }
- })
- .setNegativeButton("Cancel",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- // fjklasjf
- // DeskList.this.finish();
- dialog.cancel();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
- class Storyres extends AsyncTask<String, Void, Void> {
- private Cursor cur;
- private ProgressDialog dia;
- private String PosInd="";
- protected void onPreExecute() {
- runOnUiThread(new Runnable() {
- public void run() {
- dia = ProgressDialog.show(context, "Loading...",
- "Please wait...");
- }
- });
- super.onPreExecute();
- }
- protected Void doInBackground(String... params) {
- try {
- //con.getReadDeskStory(params[0].toString());
- //getReadWireStory(params[0].toString());
- PosInd= params[0].toString();
- } catch (Exception e) {
- dia.dismiss();
- e.printStackTrace();
- }
- return null;
- }
- protected void onPostExecute(Void result) {
- dia.dismiss();
- Intent nextScreen = new Intent(context, WireViewStory.class);
- // finish();
- nextScreen.putExtra("posi", PosInd);
- startActivity(nextScreen);
- super.onPostExecute(result);
- }
- }
- private boolean isNetworkAvailable() {
- NetworkInfo info = ((ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE))
- .getActiveNetworkInfo();
- if (info == null) {
- return false;
- } else {
- return info.isConnected();
- }
- }
- // ====================when desk change by
- // admin=================================================================================================================
- class WireStoryLoad extends AsyncTask<String, Void, Void> {
- private String result;
- private String res;
- private String[] resspl;
- private ProgressDialog dialog;
- // private SQLiteDatabase db;
- protected void onPreExecute() {
- // TODO Auto-generated method stub
- super.onPreExecute();
- dialog = ProgressDialog.show(context, "Loading...",
- "Please Wait...");
- }
- protected Void doInBackground(String... params) {
- try {
- if (isNetworkAvailable())
- {
- WireDetails("PTI");
- }
- } catch (Exception er) {
- // Toast.makeText(context, "DeskStoryLoad"+er.getMessage(),
- // Toast.LENGTH_LONG).show();
- // er.printStackTrace();
- }
- return null;
- }
- protected void onPostExecute(Void resut) {
- try {
- new StoryData().execute("1");
- } catch (Exception e) {
- // TODO: handle exception
- }
- dialog.dismiss();
- super.onPostExecute(resut);
- }
- }
- class WireStoryOnSelected extends AsyncTask<String, Void, Void> {
- private String result;
- private String res;
- private String[] resspl;
- private ProgressDialog dialog;
- // private SQLiteDatabase db;
- protected void onPreExecute() {
- // TODO Auto-generated method stub
- super.onPreExecute();
- dialog = ProgressDialog.show(context, "Loading...",
- "Please Wait...");
- }
- protected Void doInBackground(String... params) {
- try
- {
- if (isNetworkAvailable())
- {
- //parseJson("Story");
- // if (g1.appfor.equalsIgnoreCase("ht"))
- WireDetails(params[0]);
- }
- } catch (Exception er) {
- // Toast.makeText(context, "DeskStoryLoad"+er.getMessage(),
- // Toast.LENGTH_LONG).show();
- // er.printStackTrace();
- }
- return null;
- }
- protected void onPostExecute(Void resut) {
- try
- {
- new StoryData().execute("1");
- }
- catch (Exception e) {
- // TODO: handle exception
- }
- dialog.dismiss();
- super.onPostExecute(resut);
- }
- }
- public void parseJson(String jtype) {
- Cursor cur = null;
- try {
- SimpleDateFormat formatrecived = new SimpleDateFormat(
- "yyyy-MM-dd hh:mm:ss");
- JSONParser jParser = new JSONParser();
- SoapObject table = null;
- String perdate;
- Calendar nnow = Calendar.getInstance();
- nnow.add(Calendar.DATE, -2);
- String day = String.valueOf(nnow.get(Calendar.DATE));
- String month = String.valueOf(nnow.get(Calendar.MONTH) + 1);
- String year = String.valueOf(nnow.get(Calendar.YEAR));
- if (month.length() != 2) {
- month = "0" + month;
- }
- if (day.length() != 2) {
- day = "0" + day;
- }
- perdate = day + "/" + month + "/" + year + " 00:00:00";
- table = jParser.soap(jtype, g1.deskcode, g1.groupcode);
- con.setSynkDateFun();
- con.setdeskData(table, perdate);
- } catch (Exception e) {
- con.setcatData();
- }
- }
- private String convert24to12(String time) {
- String convertedtime = "";
- String ampm = "";
- int ti;
- try {
- if (time != "") {
- String timearr[] = time.split(":");
- if (Integer.parseInt(timearr[0]) >= 12) {
- ti = Integer.parseInt(timearr[0]) % 12;
- if (ti == 0)
- ti = 12;
- ampm = "PM";
- } else {
- ti = Integer.parseInt(timearr[0]);
- ampm = "AM";
- }
- if (timearr[1].length() < 2) {
- timearr[1] = "0" + timearr[1];
- }
- convertedtime = "Last Successfull Sync :" + String.valueOf(ti)
- + ":" + timearr[1] + " " + ampm;
- } else {
- Time ime = new Time();
- ime.setToNow();
- String mint = "00";
- if (String.valueOf(ime.minute).length() < 2) {
- mint = "0" + ime.minute;
- } else {
- mint = String.valueOf(ime.minute);
- }
- if (ime.hour >= 12) {
- ti = ime.hour % 12;
- if (ti == 0)
- ti = 12;
- ampm = "PM";
- } else {
- ti = ime.hour;
- ampm = "AM";
- }
- String tim = ime.hour + ":" + mint;
- g1.setSynkTime(tim);
- convertedtime = "Last Successfull Sync :" + tim;
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- return convertedtime;
- }
- public void DeskDetails(String Empcode) {
- ArrayList<String> list_desk = new ArrayList<String>();
- ArrayList<String> list_name = new ArrayList<String>();
- try {
- JSONParser jParser = new JSONParser();
- SoapObject table = null;
- table = jParser.deskDetails(Empcode);
- SoapObject tableRowData = null;
- if (table != null) {
- for (int i = 0; i < table.getPropertyCount(); i++) {
- tableRowData = (SoapObject) table.getProperty(i);
- // DESKCODE,DESCRIPTION
- String deskcodeL = tableRowData
- .getPropertyAsString("DESKCODE");
- String desknameL = tableRowData
- .getPropertyAsString("DESCRIPTION");
- list_desk.add(deskcodeL);
- list_name.add(desknameL);
- }
- g1.listDesk.add(list_desk);
- g1.listDesk.add(list_name);
- } else {
- g1._login1 = 2;
- }
- } catch (Exception e) {
- }
- }
- public void WireDetails(String Empcode)
- {
- ArrayList<WireListData> listData = new ArrayList<>();
- ArrayList<String> list_heading = new ArrayList<String>();
- ArrayList<String> list_dat = new ArrayList<String>();
- ArrayList<String> list_str=new ArrayList<String>();
- try
- {
- JSONParser jParser = new JSONParser();
- SoapObject table = null;
- table = jParser.getWireData(Empcode);
- SoapObject tableRowData = null;
- g1.wireList.clear();
- if (table != null)
- {
- for (int i = 0; i < table.getPropertyCount(); i++) {
- tableRowData = (SoapObject) table.getProperty(i);
- // DESKCODE,DESCRIPTION
- String deskcodeL = tableRowData.getPropertyAsString("Heading");
- String desknameL = tableRowData.getPropertyAsString("storydate");
- desknameL=desknameL.split("T")[1].toString().substring(0,8);
- String storyL = tableRowData.getPropertyAsString("story");
- listData.add(new WireListData(deskcodeL, desknameL, storyL));
- list_heading.add(deskcodeL);
- list_dat.add(desknameL);
- list_str.add(storyL);
- }
- g1.wireList.add(list_heading);
- g1.wireList.add(list_dat);
- g1.wireList.add(list_str);
- }
- else
- {
- g1.wireList.clear();
- g1._login1 = 2;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally {
- adapterwire = new WireListAdapter(listData,WireList.this,WireList.this);
- //setting adapter to recyclerview
- recyclerlist.setAdapter(adapterwire);
- }
- }
- // spanable
- public SpannableString setString(String textdata) {
- SpannableString spn = null;
- Typeface face1;
- try {
- String new_string = textdata.replace("<s><h>", "")
- .replace("</h></s>", "").replace("<s><e>", "")
- .replace("</e></s>", "");
- spn = new SpannableString(new_string);
- String stm[] = textdata.split("<s>");
- int nextcount = 0;
- if (!new_string.equals("")) {
- for (int mmt = 0; mmt < stm.length; mmt++) {
- // mm
- String FontName1 = g1.FontName;
- String FontName2 = "TimesNewRoman.ttf";
- String _fontName = "";
- String str1 = stm[mmt];
- if (!str1.trim().equals("")) {
- if (str1.contains("<h>")) {
- str1 = str1.replace("<h>", "").replace("</h></s>",
- "");
- face1 = Typeface.createFromAsset(getAssets(),
- "font/" + FontName1);
- _fontName = FontName1;
- } else if (!str1.contains("<e>")
- && !str1.contains("<h>")) {
- str1 = str1.replace("<h>", "")
- .replace("</h></s>", "").replace("<e>", "")
- .replace("</e></s>", "");
- face1 = Typeface.createFromAsset(getAssets(),
- "font/" + FontName1);
- _fontName = FontName1;
- } else {
- str1 = str1.replace("<e>", "").replace("</e></s>",
- "");
- face1 = Typeface.createFromAsset(getAssets(),
- "font/" + FontName2);
- _fontName = FontName2;
- }
- if (!str1.trim().equals(""))
- spn.setSpan(new spantypeface(_fontName, face1),
- nextcount, nextcount + str1.length(),
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- nextcount = nextcount + str1.length();
- }
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- return spn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement