Advertisement
markella92

Untitled

Aug 28th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.46 KB | None | 0 0
  1. public class ScrollableTabsActivity2 extends AppCompatActivity {
  2.  
  3. private Toolbar toolbar;
  4. private TabLayout tabLayout;
  5. private ViewPager viewPager;
  6. private Button logout_user;
  7. //private SQLiteHandler db;
  8. private SessionManager session;
  9. private TextView txtName;
  10. private TextView txtEmail;
  11. int s;
  12. String intentt="";
  13. File file;
  14. Uri filePath;
  15. ListView lv;
  16. ArrayList<Integer> hm=new ArrayList<>();
  17. String path=null;
  18. ArrayList<Planet> planetList=new ArrayList();
  19.  
  20. private String myString = "azz";
  21. ArrayList<Integer> arraylistInteger;
  22. String value="";
  23. String numero_tavolo="";
  24. ArrayList<Integer> hm3=new ArrayList<>();
  25. ArrayList<Integer> hm_quantitàpizze=new ArrayList<>();
  26. TextView numero_tavolo_text_view;
  27.  
  28.  
  29. @Override
  30. protected void onCreate(Bundle savedInstanceState) {
  31. super.onCreate(savedInstanceState);
  32. setContentView(R.layout.activity_scrollable_tabs2);
  33.  
  34.  
  35. toolbar = (Toolbar) findViewById(R.id.toolbar);
  36. setSupportActionBar(toolbar);
  37. txtName = (TextView) findViewById(R.id.name);
  38. txtEmail = (TextView) findViewById(R.id.numero_telefonico);
  39. numero_tavolo_text_view=(TextView)findViewById(R.id.numero_tavolo);
  40. logout_user=(Button) findViewById(R.id.crisbio);
  41.  
  42. logout_user.setOnClickListener(new View.OnClickListener() {
  43.  
  44. @Override
  45. public void onClick(View v) {
  46. logoutUser();
  47. }
  48. });
  49.  
  50.  
  51.  
  52. getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  53.  
  54. viewPager = (ViewPager) findViewById(R.id.viewpagerr);
  55. setupViewPager(viewPager);
  56.  
  57. tabLayout = (TabLayout) findViewById(R.id.tabss);
  58. tabLayout.setupWithViewPager(viewPager);
  59.  
  60.  
  61. Bundle extras = getIntent().getExtras();
  62. if (extras != null) {
  63. value = extras.getString("PATH FILE DA AGGIORNARE");
  64. numero_tavolo=extras.getString("NUMERO_TAVOLO");
  65. file = new File(value);
  66. System.out.println("FILE:" + file);
  67.  
  68. FileInputStream is = null;
  69. try {
  70. is = new FileInputStream(file);
  71. } catch (FileNotFoundException e) {
  72. e.printStackTrace();
  73. }
  74.  
  75. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  76. DocumentBuilder dBuilder = null;
  77. try {
  78. dBuilder = dbFactory.newDocumentBuilder();
  79. } catch (ParserConfigurationException e) {
  80. e.printStackTrace();
  81. }
  82. Document doc = null;
  83. try {
  84. doc = dBuilder.parse(is);
  85. } catch (SAXException e) {
  86. e.printStackTrace();
  87. } catch (IOException e) {
  88. e.printStackTrace();
  89. }
  90.  
  91. Element element = doc.getDocumentElement();
  92. element.normalize();
  93.  
  94. int a;
  95. int b;
  96. NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
  97. hm.clear();
  98. hm_quantitàpizze.clear();
  99.  
  100. for (int i = 0; i < nList.getLength(); i++) {
  101. Node node = nList.item(i);
  102.  
  103. if (node.getNodeType() == Node.ELEMENT_NODE) {
  104. Element element2 = (Element) node;
  105. //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
  106.  
  107. String id = getValue("id", element2);
  108. a = Integer.parseInt(id);
  109. String idd = getValue("quantita", element2);
  110. b = Integer.parseInt(idd);
  111.  
  112.  
  113. System.out.println("XMLLLLLLLLLL:" + b);
  114.  
  115. hm.add(a);
  116. hm_quantitàpizze.add(b);
  117.  
  118. System.out.println("AZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:" + hm_quantitàpizze);
  119. System.out.println("LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:" + hm);
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. }
  127.  
  128. }
  129. Bundle bundle = new Bundle();
  130. bundle.putIntegerArrayList("oki", hm);
  131. bundle.putIntegerArrayList("okiquantitapizze", hm_quantitàpizze);
  132.  
  133. MyListFragment2 myFragment = new MyListFragment2();
  134. myFragment.setArguments(bundle);
  135. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  136.  
  137. transaction.replace(R.id.cristo, myFragment);
  138.  
  139. transaction.commit();
  140.  
  141.  
  142. /* MyListFragment myFragment = MyListFragment.newInstance(hm,hm_quantitàpizze);
  143. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  144. //transaction.replace(R.id.a, myFragment);
  145. //transaction.replace(R.id.porcozio, myFragment);
  146. transaction.replace(android.R.id.content, myFragment);
  147.  
  148.  
  149. transaction.commit();
  150. */
  151.  
  152. }
  153.  
  154. numero_tavolo_text_view.setText(numero_tavolo);
  155. }
  156.  
  157. private void logoutUser() {
  158.  
  159.  
  160. Intent intent = new Intent();
  161. intent.setPackage("com.asus.filemanager");
  162. intent.setDataAndType(Uri.parse("/storage/emulated/0/ordinazioni"), "text/xml");
  163. //intent.setType("text/xml");
  164. intent.setAction(Intent.ACTION_GET_CONTENT);
  165. startActivityForResult(Intent.createChooser(intent, "LOGOUT"), 1);
  166. }
  167. @Override
  168. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  169. super.onActivityResult(requestCode, resultCode, data);
  170.  
  171.  
  172.  
  173. checkboxPizza(data);
  174. }
  175.  
  176. private void checkboxPizza(Intent data) {
  177. filePath = data.getData();
  178. System.out.println("FILEPATH" + filePath);
  179.  
  180.  
  181. path = FilePath.getPath(this, filePath);
  182.  
  183.  
  184. System.out.println("PATH" + path);
  185.  
  186. int a=0;
  187. int b=0;
  188.  
  189. String status="";
  190. boolean statuss = false;
  191. String intenttt= path;
  192.  
  193. System.out.println("INTENT:" + intenttt);
  194.  
  195.  
  196.  
  197. file = new File(intenttt);
  198. System.out.println("FILE:" + file);
  199.  
  200. FileInputStream is = null;
  201. try {
  202. is = new FileInputStream(file);
  203. } catch (FileNotFoundException e) {
  204. e.printStackTrace();
  205. }
  206.  
  207. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  208. DocumentBuilder dBuilder = null;
  209. try {
  210. dBuilder = dbFactory.newDocumentBuilder();
  211. } catch (ParserConfigurationException e) {
  212. e.printStackTrace();
  213. }
  214. Document doc = null;
  215. try {
  216. doc = dBuilder.parse(is);
  217. } catch (SAXException e) {
  218. e.printStackTrace();
  219. } catch (IOException e) {
  220. e.printStackTrace();
  221. }
  222.  
  223. Element element = doc.getDocumentElement();
  224. element.normalize();
  225.  
  226. NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
  227. hm.clear();
  228. hm_quantitàpizze.clear();
  229.  
  230. for (int i = 0; i < nList.getLength(); i++) {
  231. Node node = nList.item(i);
  232.  
  233. if (node.getNodeType() == Node.ELEMENT_NODE) {
  234. Element element2 = (Element) node;
  235. //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
  236.  
  237. String id = getValue("id", element2);
  238. a = Integer.parseInt(id);
  239. String idd = getValue("quantita", element2);
  240. b = Integer.parseInt(idd);
  241.  
  242.  
  243. System.out.println("XMLLLLLLLLLL:" + b);
  244.  
  245. hm.add(a);
  246. hm_quantitàpizze.add(b);
  247.  
  248. System.out.println("AZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:" + hm_quantitàpizze);
  249. System.out.println("LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:" + hm);
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256. }
  257.  
  258. }
  259. Bundle bundle = new Bundle();
  260. bundle.putIntegerArrayList("oki", hm);
  261. bundle.putIntegerArrayList("okiquantitapizze", hm_quantitàpizze);
  262.  
  263. System.out.println("PERO:" + bundle);
  264.  
  265. MyListFragment2 myFragment = new MyListFragment2();
  266. myFragment.setArguments(bundle);
  267. /* FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  268. transaction.replace(R.id.acab, myFragment);
  269. transaction.commit();*/
  270.  
  271.  
  272.  
  273.  
  274. }
  275.  
  276.  
  277. private static String getValue(String tag, Element element) {
  278. NodeList nodeList = element.getElementsByTagName(tag).item(0).getChildNodes();
  279. Node node = nodeList.item(0);
  280. return node.getNodeValue();
  281. }
  282. /*
  283.  
  284.  
  285.  
  286. // s = getIntent().getIntExtra("EXTRA_SESSION_ID",0);
  287. // System.out.println("IDDDDDDD" + s);
  288.  
  289. // getMyData();
  290. */
  291. /*
  292. Intent intent = getIntent();
  293.  
  294. arraylistInteger = intent.getIntegerArrayListExtra("oki");
  295. Bundle bundle = new Bundle();
  296. bundle.putIntegerArrayList("oki", arraylistInteger);
  297.  
  298. Fragment fragment = new MyListFragment();
  299. fragment.setArguments(bundle);
  300.  
  301.  
  302. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  303. transaction.replace(R.id.container, fragment);
  304. transaction.commit();
  305. System.out.println("PASSATO " + bundle);*//*
  306.  
  307. }
  308.  
  309.  
  310.  
  311. */
  312. /* public int getMyData() {
  313. return s;
  314.  
  315. }*//*
  316.  
  317.  
  318.  
  319. */
  320. /* private void logoutUser() {
  321.  
  322. Intent intent = new Intent();
  323. intent.setPackage("com.asus.filemanager");
  324. intent.setType("text/xml");
  325. intent.setAction(Intent.ACTION_GET_CONTENT);
  326. startActivityForResult(Intent.createChooser(intent, "LOGOUT"), 1);
  327. }
  328. @Override
  329. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  330. super.onActivityResult(requestCode, resultCode, data);
  331.  
  332. *//*
  333. */
  334. /* Intent intent = new Intent(ScrollableTabsActivity.this,
  335. ScrollableTabsActivity.class);
  336.  
  337. startActivity(intent);*//*
  338. */
  339. /*
  340.  
  341. filePath = data.getData();
  342. System.out.println("FILEPATH" + filePath);
  343.  
  344.  
  345. path = FilePath.getPath(this, filePath);
  346.  
  347. System.out.println("PATH" + path);
  348.  
  349. int a=0;
  350. String status="";
  351. boolean statuss = false;
  352. String intenttt= path;
  353.  
  354. System.out.println("INTENT:"+intenttt);
  355.  
  356.  
  357.  
  358. file = new File(intenttt);
  359. System.out.println("FILE:"+file);
  360.  
  361. FileInputStream is = null;
  362. try {
  363. is = new FileInputStream(file);
  364. } catch (FileNotFoundException e) {
  365. e.printStackTrace();
  366. }
  367.  
  368. DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  369. DocumentBuilder dBuilder = null;
  370. try {
  371. dBuilder = dbFactory.newDocumentBuilder();
  372. } catch (ParserConfigurationException e) {
  373. e.printStackTrace();
  374. }
  375. Document doc = null;
  376. try {
  377. doc = dBuilder.parse(is);
  378. } catch (SAXException e) {
  379. e.printStackTrace();
  380. } catch (IOException e) {
  381. e.printStackTrace();
  382. }
  383.  
  384. Element element = doc.getDocumentElement();
  385. element.normalize();
  386.  
  387. NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
  388.  
  389. for (int i = 0; i < nList.getLength(); i++) {
  390. Node node = nList.item(i);
  391. if (node.getNodeType() == Node.ELEMENT_NODE) {
  392. Element element2 = (Element) node;
  393. //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
  394.  
  395. String id = getValue("id", element2);
  396. a = Integer.parseInt(id);
  397. status = getValue("status", element2);
  398.  
  399. statuss= Boolean.parseBoolean(status);
  400.  
  401. System.out.println("XML:" + a);
  402. hm.clear();
  403.  
  404. hm.add(a);
  405.  
  406. System.out.println("AZZ:" + hm);
  407.  
  408.  
  409.  
  410.  
  411.  
  412. }
  413.  
  414. }
  415.  
  416.  
  417.  
  418. Bundle bundle = new Bundle();
  419. bundle.putIntegerArrayList("oki", hm);
  420.  
  421. Fragment fragment = new MyListFragment();
  422. fragment.setArguments(bundle);
  423.  
  424.  
  425. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  426. transaction.replace(R.id.container, fragment);
  427. transaction.commit();
  428. System.out.println("PASSATO " + bundle);
  429.  
  430.  
  431. }*//*
  432.  
  433.  
  434.  
  435. private static String getValue(String tag, Element element) {
  436. NodeList nodeList = element.getElementsByTagName(tag).item(0).getChildNodes();
  437. Node node = nodeList.item(0);
  438. return node.getNodeValue();
  439. }
  440.  
  441.  
  442.  
  443. */
  444. /* @Override
  445. protected void onPause() {
  446. super.onPause();
  447. logoutUser();
  448. }*/
  449.  
  450.  
  451. private void setupViewPager(ViewPager viewPager) {
  452. //ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
  453. ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
  454.  
  455. adapter.addFrag(new MyListFragment2(), "PIZZE");
  456. //adapter.addFrag(new SixFragment(), "SIX");
  457. //adapter.addFrag(new FiveFragment2(), "TAVOLI");
  458. adapter.addFrag(new ThreeFragment2(), "BEVANDE");
  459. adapter.addFrag(new FourFragment2(), "STAMPA");
  460. /* adapter.addFrag(new TwoFragment(), "TWO");
  461. adapter.addFrag(new SevenFragment(), "SEVEN");
  462. adapter.addFrag(new EightFragment(), "EIGHT");
  463. adapter.addFrag(new NineFragment(), "NINE");
  464. adapter.addFrag(new TenFragment(), "TEN");*/
  465.  
  466.  
  467. viewPager.setAdapter(adapter);
  468. viewPager.setOffscreenPageLimit(3);
  469. }
  470.  
  471.  
  472.  
  473.  
  474. class ViewPagerAdapter extends FragmentPagerAdapter {
  475. private final List<Fragment> mFragmentList = new ArrayList<>();
  476. private final List<String> mFragmentTitleList = new ArrayList<>();
  477.  
  478. public ViewPagerAdapter(FragmentManager manager) {
  479. super(manager);
  480. }
  481.  
  482. @Override
  483. public Fragment getItem(int position) {
  484. return mFragmentList.get(position);
  485. }
  486.  
  487. @Override
  488. public int getCount() {
  489. return mFragmentList.size();
  490. }
  491.  
  492. public void addFrag(Fragment fragment, String title) {
  493. mFragmentList.add(fragment);
  494. mFragmentTitleList.add(title);
  495. }
  496.  
  497. @Override
  498. public CharSequence getPageTitle(int position) {
  499. return mFragmentTitleList.get(position);
  500. }
  501. }
  502.  
  503.  
  504. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement