Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ScrollableTabsActivity2 extends AppCompatActivity {
- private Toolbar toolbar;
- private TabLayout tabLayout;
- private ViewPager viewPager;
- private Button logout_user;
- //private SQLiteHandler db;
- private SessionManager session;
- private TextView txtName;
- private TextView txtEmail;
- int s;
- String intentt="";
- File file;
- Uri filePath;
- ListView lv;
- ArrayList<Integer> hm=new ArrayList<>();
- String path=null;
- ArrayList<Planet> planetList=new ArrayList();
- private String myString = "azz";
- ArrayList<Integer> arraylistInteger;
- String value="";
- String numero_tavolo="";
- ArrayList<Integer> hm3=new ArrayList<>();
- ArrayList<Integer> hm_quantitàpizze=new ArrayList<>();
- TextView numero_tavolo_text_view;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_scrollable_tabs2);
- toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- txtName = (TextView) findViewById(R.id.name);
- txtEmail = (TextView) findViewById(R.id.numero_telefonico);
- numero_tavolo_text_view=(TextView)findViewById(R.id.numero_tavolo);
- logout_user=(Button) findViewById(R.id.crisbio);
- logout_user.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- logoutUser();
- }
- });
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- viewPager = (ViewPager) findViewById(R.id.viewpagerr);
- setupViewPager(viewPager);
- tabLayout = (TabLayout) findViewById(R.id.tabss);
- tabLayout.setupWithViewPager(viewPager);
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- value = extras.getString("PATH FILE DA AGGIORNARE");
- numero_tavolo=extras.getString("NUMERO_TAVOLO");
- file = new File(value);
- System.out.println("FILE:" + file);
- FileInputStream is = null;
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = null;
- try {
- dBuilder = dbFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- Document doc = null;
- try {
- doc = dBuilder.parse(is);
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- Element element = doc.getDocumentElement();
- element.normalize();
- int a;
- int b;
- NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
- hm.clear();
- hm_quantitàpizze.clear();
- for (int i = 0; i < nList.getLength(); i++) {
- Node node = nList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element2 = (Element) node;
- //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
- String id = getValue("id", element2);
- a = Integer.parseInt(id);
- String idd = getValue("quantita", element2);
- b = Integer.parseInt(idd);
- System.out.println("XMLLLLLLLLLL:" + b);
- hm.add(a);
- hm_quantitàpizze.add(b);
- System.out.println("AZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:" + hm_quantitàpizze);
- System.out.println("LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:" + hm);
- }
- }
- Bundle bundle = new Bundle();
- bundle.putIntegerArrayList("oki", hm);
- bundle.putIntegerArrayList("okiquantitapizze", hm_quantitàpizze);
- MyListFragment2 myFragment = new MyListFragment2();
- myFragment.setArguments(bundle);
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.cristo, myFragment);
- transaction.commit();
- /* MyListFragment myFragment = MyListFragment.newInstance(hm,hm_quantitàpizze);
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- //transaction.replace(R.id.a, myFragment);
- //transaction.replace(R.id.porcozio, myFragment);
- transaction.replace(android.R.id.content, myFragment);
- transaction.commit();
- */
- }
- numero_tavolo_text_view.setText(numero_tavolo);
- }
- private void logoutUser() {
- Intent intent = new Intent();
- intent.setPackage("com.asus.filemanager");
- intent.setDataAndType(Uri.parse("/storage/emulated/0/ordinazioni"), "text/xml");
- //intent.setType("text/xml");
- intent.setAction(Intent.ACTION_GET_CONTENT);
- startActivityForResult(Intent.createChooser(intent, "LOGOUT"), 1);
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- checkboxPizza(data);
- }
- private void checkboxPizza(Intent data) {
- filePath = data.getData();
- System.out.println("FILEPATH" + filePath);
- path = FilePath.getPath(this, filePath);
- System.out.println("PATH" + path);
- int a=0;
- int b=0;
- String status="";
- boolean statuss = false;
- String intenttt= path;
- System.out.println("INTENT:" + intenttt);
- file = new File(intenttt);
- System.out.println("FILE:" + file);
- FileInputStream is = null;
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = null;
- try {
- dBuilder = dbFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- Document doc = null;
- try {
- doc = dBuilder.parse(is);
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- Element element = doc.getDocumentElement();
- element.normalize();
- NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
- hm.clear();
- hm_quantitàpizze.clear();
- for (int i = 0; i < nList.getLength(); i++) {
- Node node = nList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element2 = (Element) node;
- //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
- String id = getValue("id", element2);
- a = Integer.parseInt(id);
- String idd = getValue("quantita", element2);
- b = Integer.parseInt(idd);
- System.out.println("XMLLLLLLLLLL:" + b);
- hm.add(a);
- hm_quantitàpizze.add(b);
- System.out.println("AZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:" + hm_quantitàpizze);
- System.out.println("LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:" + hm);
- }
- }
- Bundle bundle = new Bundle();
- bundle.putIntegerArrayList("oki", hm);
- bundle.putIntegerArrayList("okiquantitapizze", hm_quantitàpizze);
- System.out.println("PERO:" + bundle);
- MyListFragment2 myFragment = new MyListFragment2();
- myFragment.setArguments(bundle);
- /* FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.acab, myFragment);
- transaction.commit();*/
- }
- private static String getValue(String tag, Element element) {
- NodeList nodeList = element.getElementsByTagName(tag).item(0).getChildNodes();
- Node node = nodeList.item(0);
- return node.getNodeValue();
- }
- /*
- // s = getIntent().getIntExtra("EXTRA_SESSION_ID",0);
- // System.out.println("IDDDDDDD" + s);
- // getMyData();
- */
- /*
- Intent intent = getIntent();
- arraylistInteger = intent.getIntegerArrayListExtra("oki");
- Bundle bundle = new Bundle();
- bundle.putIntegerArrayList("oki", arraylistInteger);
- Fragment fragment = new MyListFragment();
- fragment.setArguments(bundle);
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.container, fragment);
- transaction.commit();
- System.out.println("PASSATO " + bundle);*//*
- }
- */
- /* public int getMyData() {
- return s;
- }*//*
- */
- /* private void logoutUser() {
- Intent intent = new Intent();
- intent.setPackage("com.asus.filemanager");
- intent.setType("text/xml");
- intent.setAction(Intent.ACTION_GET_CONTENT);
- startActivityForResult(Intent.createChooser(intent, "LOGOUT"), 1);
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- *//*
- */
- /* Intent intent = new Intent(ScrollableTabsActivity.this,
- ScrollableTabsActivity.class);
- startActivity(intent);*//*
- */
- /*
- filePath = data.getData();
- System.out.println("FILEPATH" + filePath);
- path = FilePath.getPath(this, filePath);
- System.out.println("PATH" + path);
- int a=0;
- String status="";
- boolean statuss = false;
- String intenttt= path;
- System.out.println("INTENT:"+intenttt);
- file = new File(intenttt);
- System.out.println("FILE:"+file);
- FileInputStream is = null;
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = null;
- try {
- dBuilder = dbFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- Document doc = null;
- try {
- doc = dBuilder.parse(is);
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- Element element = doc.getDocumentElement();
- element.normalize();
- NodeList nList = doc.getElementsByTagName("checkboxes_pizza");
- for (int i = 0; i < nList.getLength(); i++) {
- Node node = nList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element2 = (Element) node;
- //tv1.setText(tv1.getText()+"\nName : " + getValue("name", element2)+"\n");
- String id = getValue("id", element2);
- a = Integer.parseInt(id);
- status = getValue("status", element2);
- statuss= Boolean.parseBoolean(status);
- System.out.println("XML:" + a);
- hm.clear();
- hm.add(a);
- System.out.println("AZZ:" + hm);
- }
- }
- Bundle bundle = new Bundle();
- bundle.putIntegerArrayList("oki", hm);
- Fragment fragment = new MyListFragment();
- fragment.setArguments(bundle);
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.container, fragment);
- transaction.commit();
- System.out.println("PASSATO " + bundle);
- }*//*
- private static String getValue(String tag, Element element) {
- NodeList nodeList = element.getElementsByTagName(tag).item(0).getChildNodes();
- Node node = nodeList.item(0);
- return node.getNodeValue();
- }
- */
- /* @Override
- protected void onPause() {
- super.onPause();
- logoutUser();
- }*/
- private void setupViewPager(ViewPager viewPager) {
- //ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
- ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
- adapter.addFrag(new MyListFragment2(), "PIZZE");
- //adapter.addFrag(new SixFragment(), "SIX");
- //adapter.addFrag(new FiveFragment2(), "TAVOLI");
- adapter.addFrag(new ThreeFragment2(), "BEVANDE");
- adapter.addFrag(new FourFragment2(), "STAMPA");
- /* adapter.addFrag(new TwoFragment(), "TWO");
- adapter.addFrag(new SevenFragment(), "SEVEN");
- adapter.addFrag(new EightFragment(), "EIGHT");
- adapter.addFrag(new NineFragment(), "NINE");
- adapter.addFrag(new TenFragment(), "TEN");*/
- viewPager.setAdapter(adapter);
- viewPager.setOffscreenPageLimit(3);
- }
- class ViewPagerAdapter extends FragmentPagerAdapter {
- private final List<Fragment> mFragmentList = new ArrayList<>();
- private final List<String> mFragmentTitleList = new ArrayList<>();
- public ViewPagerAdapter(FragmentManager manager) {
- super(manager);
- }
- @Override
- public Fragment getItem(int position) {
- return mFragmentList.get(position);
- }
- @Override
- public int getCount() {
- return mFragmentList.size();
- }
- public void addFrag(Fragment fragment, String title) {
- mFragmentList.add(fragment);
- mFragmentTitleList.add(title);
- }
- @Override
- public CharSequence getPageTitle(int position) {
- return mFragmentTitleList.get(position);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement