Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.26 KB | None | 0 0
  1. package com.example.kingsrobot.sigilov12;
  2.  
  3. import android.app.AlertDialog;
  4. import android.content.DialogInterface;
  5. import android.content.Intent;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.ArrayAdapter;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.ImageButton;
  13. import android.widget.ListView;
  14. import android.widget.Toast;
  15.  
  16. import com.loopj.android.http.AsyncHttpClient;
  17. import com.loopj.android.http.AsyncHttpResponseHandler;
  18. import com.loopj.android.http.RequestParams;
  19.  
  20. import org.json.JSONArray;
  21.  
  22. import java.util.ArrayList;
  23.  
  24. import cz.msebera.android.httpclient.Header;
  25.  
  26. public class Principal extends AppCompatActivity implements View.OnClickListener {
  27.  
  28.  
  29. // VARIABLE GLOBALES
  30. EditText usuariotxt, contrasenatxt;
  31. Button btnlogin;
  32. ListView listado;
  33. String password;
  34. ArrayList listanit,listanombre,listapass,listacliente,listarmas,listaradio,listaguarda,listadmin;
  35. int posicion;
  36. String namename;
  37. String nombref;
  38. String usuario;
  39. int checkpass;
  40. ImageButton reload;
  41.  
  42. // FIN VARIABLES GLOBALES
  43.  
  44. /////////////////////////////////////////////VERIFICAR INICIO///////////////////////////////////////////////////////////////////////
  45. public boolean verificarinicio() {
  46.  
  47.  
  48.  
  49. if (listanit.contains(usuariotxt.getText().toString())) {
  50.  
  51.  
  52.  
  53. usuario = usuariotxt.getText().toString();
  54. //int retval=arrlist.IndexOf("E");
  55. posicion=listanit.indexOf(usuario);
  56. namename=listanombre.get(posicion).toString();
  57. nombref=namename;
  58.  
  59.  
  60. return true;
  61.  
  62.  
  63.  
  64. }else{return false;
  65.  
  66. }
  67.  
  68.  
  69.  
  70.  
  71. }
  72.  
  73. /////////////////////////////////////////////////VERIFICAR INICIO///////////////////////////////////////////////////////////////
  74. /////////////////////////////////////////////VERIFICAR Contraseña///////////////////////////////////////////////////////////////////////
  75.  
  76. public void verificarcontraseña() {
  77.  
  78. password = listapass.get(posicion).toString();
  79. String check = contrasenatxt.getText().toString();
  80.  
  81. if (check.equals(password)) {
  82.  
  83. checkpass=1940;
  84.  
  85. } else {
  86. checkpass=0;
  87. }
  88.  
  89. }
  90.  
  91.  
  92.  
  93. /////////////////////////////////////////////VERIFICAR contraseña///////////////////////////////////////////////////////////////////////
  94.  
  95.  
  96. //////////////////////////////////////////////////////OBTENER DATOS NIT//////////////////////////////////////////////////////////////////
  97. public void CargaLista(ArrayList<String> datos) {
  98.  
  99.  
  100. // Object[] nitvector = datos.toArray();
  101.  
  102.  
  103. ArrayAdapter<String> adapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,datos);
  104. listado.setAdapter(adapter);
  105. listanit=datos;
  106.  
  107.  
  108.  
  109.  
  110. }
  111.  
  112. //////////////////////////////////////////////////////OBTENER DATOS NIT//////////////////////////////////////////////////////////////////
  113. /////////////////////////////////////////////////OBTENER DATOS NIT/////////////////////////////////////////////////////////
  114.  
  115. public void obtDatos(){
  116.  
  117. AsyncHttpClient client = new AsyncHttpClient();
  118. //String urlusuario="https://graph.facebook.com/19292868552";
  119. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonUser.json";
  120.  
  121. RequestParams parametros = new RequestParams();
  122. //parametros.put("Edad",18);
  123.  
  124. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  125. @Override
  126. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  127. if (statusCode==200){
  128. //llamar funcion....
  129. CargaLista(obtDatosJSON(new String(responseBody)));
  130.  
  131. }
  132. }
  133.  
  134. @Override
  135. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  136.  
  137. }
  138. });
  139.  
  140.  
  141.  
  142. }
  143.  
  144.  
  145.  
  146. //////////////////////////////////////////////////////OBTENER DATOS NIT//////////////////////////////////////////////////////////////////
  147.  
  148.  
  149. //////////////////////////////////////////////////////OBTENER DATOS NIT//////////////////////////////////////////////////////////////////
  150.  
  151. public ArrayList<String> obtDatosJSON(String response){
  152.  
  153. ArrayList<String> listado = new ArrayList<>();
  154.  
  155. try {
  156. JSONArray jsonArray = new JSONArray(response);
  157. String texto;
  158.  
  159. for (int i=0;i<jsonArray.length();i++){
  160. texto=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  161. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  162. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  163.  
  164.  
  165. listado.add(texto);
  166.  
  167.  
  168.  
  169. }
  170.  
  171. }catch (Exception e){
  172. e.printStackTrace();
  173.  
  174. }
  175. return listado;
  176.  
  177. }
  178.  
  179. //////////////////////////////////////////////////////OBTENER DATOS NIT//////////////////////////////////////////////////////////////////
  180.  
  181. //////////////////////////////////////////////////////OBTENER DATOS NOMBRE//////////////////////////////////////////////////////////////////
  182.  
  183. public ArrayList<String> obtDatosJSON1(String response){
  184.  
  185. ArrayList<String> listado1 = new ArrayList<String>();
  186.  
  187. try {
  188. JSONArray jsonArray = new JSONArray(response);
  189. String texto;
  190.  
  191. for (int i=0;i<jsonArray.length();i++){
  192. texto=jsonArray.getJSONObject(i).getString("Nombre_user");//+ " "+
  193. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  194. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  195.  
  196.  
  197. listado1.add(texto);
  198.  
  199.  
  200.  
  201. }
  202.  
  203. }catch (Exception e){
  204. e.printStackTrace();
  205.  
  206. }
  207. return listado1;
  208.  
  209. }
  210.  
  211. //////////////////////////////////////////////////////OBTENER DATOS NOMBRE//////////////////////////////////////////////////////////////////
  212.  
  213.  
  214. /////////////////////////////////////////////////OBTENER DATOS NOMBRE/////////////////////////////////////////////////////////
  215.  
  216. public void obtDatos1(){
  217.  
  218. AsyncHttpClient client = new AsyncHttpClient();
  219. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonUser.json";
  220.  
  221. RequestParams parametros = new RequestParams();
  222. //parametros.put("Edad",18);
  223.  
  224. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  225. @Override
  226. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  227. if (statusCode==200){
  228. //llamar funcion....
  229. CargaLista1(obtDatosJSON1(new String(responseBody)));
  230.  
  231. }
  232. }
  233.  
  234. @Override
  235. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  236.  
  237. }
  238. });
  239.  
  240.  
  241.  
  242. }
  243.  
  244.  
  245.  
  246. //////////////////////////////////////////////////////OBTENER DATOS NOMBRE//////////////////////////////////////////////////////////////////
  247.  
  248.  
  249. //////////////////////////////////////////////////////OBTENER DATOS NOMBRE//////////////////////////////////////////////////////////////////
  250. public void CargaLista1(ArrayList<String> datos1) {
  251.  
  252.  
  253. // Object[] nitvector = datos.toArray();
  254.  
  255.  
  256. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  257. // listado.setAdapter(adapter);
  258. listanombre=datos1;
  259.  
  260.  
  261.  
  262.  
  263. }
  264. //////////////////////////////////////////////////////OBTENER DATOS NOMBRE//////////////////////////////////////////////////////////////////
  265. //////////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA//////////////////////////////////////////////////////////////////
  266.  
  267. public ArrayList<String> obtDatosJSON2(String response){
  268.  
  269. ArrayList<String> listado2 = new ArrayList<String>();
  270.  
  271. try {
  272. JSONArray jsonArray = new JSONArray(response);
  273. String texto;
  274.  
  275. for (int i=0;i<jsonArray.length();i++){
  276. texto=jsonArray.getJSONObject(i).getString("pass_user");//+ " "+
  277. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  278. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  279.  
  280.  
  281. listado2.add(texto);
  282.  
  283.  
  284.  
  285. }
  286.  
  287. }catch (Exception e){
  288. e.printStackTrace();
  289.  
  290. }
  291. return listado2;
  292.  
  293. }
  294.  
  295. //////////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA//////////////////////////////////////////////////////////////////
  296.  
  297.  
  298. /////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA/////////////////////////////////////////////////////////
  299.  
  300. public void obtDatos2(){
  301.  
  302. AsyncHttpClient client = new AsyncHttpClient();
  303. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonUser.json";
  304.  
  305. RequestParams parametros = new RequestParams();
  306. //parametros.put("Edad",18);
  307.  
  308. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  309. @Override
  310. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  311. if (statusCode==200){
  312. //llamar funcion....
  313. CargaLista2(obtDatosJSON2(new String(responseBody)));
  314.  
  315. }
  316. }
  317.  
  318. @Override
  319. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  320.  
  321. }
  322. });
  323.  
  324.  
  325.  
  326. }
  327.  
  328.  
  329.  
  330. //////////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA//////////////////////////////////////////////////////////////////
  331.  
  332.  
  333. //////////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA//////////////////////////////////////////////////////////////////
  334. public void CargaLista2(ArrayList<String> datos2) {
  335.  
  336.  
  337. // Object[] nitvector = datos.toArray();
  338.  
  339.  
  340. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  341. // listado.setAdapter(adapter);
  342. listapass=datos2;
  343.  
  344.  
  345.  
  346.  
  347. }
  348. //////////////////////////////////////////////////////OBTENER DATOS CONTRASEÑA//////////////////////////////////////////////////////////////////
  349. //***************************************
  350. //////////////////////////////////////////////////////OBTENER DATOS CLIENTE//////////////////////////////////////////////////////////////////
  351.  
  352. public ArrayList<String> obtDatosJSON3(String response){
  353.  
  354. ArrayList<String> listado3 = new ArrayList<String>();
  355.  
  356. try {
  357. JSONArray jsonArray = new JSONArray(response);
  358. String texto;
  359.  
  360. for (int i=0;i<jsonArray.length();i++){
  361. texto=jsonArray.getJSONObject(i).getString("nombre");//+ " "+
  362. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  363. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  364.  
  365.  
  366. listado3.add(texto);
  367.  
  368.  
  369.  
  370. }
  371.  
  372. }catch (Exception e){
  373. e.printStackTrace();
  374.  
  375. }
  376. return listado3;
  377.  
  378. }
  379.  
  380. //////////////////////////////////////////////////////OBTENER DATOS CLIENTE//////////////////////////////////////////////////////////////////
  381.  
  382.  
  383. /////////////////////////////////////////////////OBTENER DATOS CLIENTE/////////////////////////////////////////////////////////
  384.  
  385. public void obtDatos3(){
  386.  
  387. AsyncHttpClient client = new AsyncHttpClient();
  388. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonPuesto.json";
  389.  
  390. RequestParams parametros = new RequestParams();
  391. //parametros.put("Edad",18);
  392.  
  393. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  394. @Override
  395. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  396. if (statusCode==200){
  397. //llamar funcion....
  398. CargaLista3(obtDatosJSON3(new String(responseBody)));
  399.  
  400. }
  401. }
  402.  
  403. @Override
  404. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  405.  
  406. }
  407. });
  408.  
  409.  
  410.  
  411. }
  412.  
  413.  
  414.  
  415. //////////////////////////////////////////////////////OBTENER DATOS CLIENTE//////////////////////////////////////////////////////////////////
  416.  
  417.  
  418. //////////////////////////////////////////////////////OBTENER DATOS CLIENTE//////////////////////////////////////////////////////////////////
  419. public void CargaLista3(ArrayList<String> datos3) {
  420.  
  421.  
  422. // Object[] nitvector = datos.toArray();
  423.  
  424.  
  425. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  426. // listado.setAdapter(adapter);
  427. listacliente=datos3;
  428.  
  429.  
  430.  
  431.  
  432. }
  433. //////////////////////////////////////////////////////OBTENER DATOS CLIENTE//////////////////////////////////////////////////////////////////
  434.  
  435. //////////////////////////////////////////////////////OBTENER DATOS CARMAS//////////////////////////////////////////////////////////////////
  436.  
  437. public ArrayList<String> obtDatosJSON4(String response){
  438.  
  439. ArrayList<String> listado4 = new ArrayList<String>();
  440.  
  441. try {
  442. JSONArray jsonArray = new JSONArray(response);
  443. String texto;
  444.  
  445. for (int i=0;i<jsonArray.length();i++){
  446. texto=jsonArray.getJSONObject(i).getString("nombre");//+ " "+
  447. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  448. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  449.  
  450.  
  451. listado4.add(texto);
  452.  
  453.  
  454.  
  455. }
  456.  
  457. }catch (Exception e){
  458. e.printStackTrace();
  459.  
  460. }
  461. return listado4;
  462.  
  463. }
  464.  
  465. //////////////////////////////////////////////////////OBTENER DATOS ARMAS//////////////////////////////////////////////////////////////////
  466.  
  467.  
  468. /////////////////////////////////////////////////OBTENER DATOS ARMAS/////////////////////////////////////////////////////////
  469.  
  470. public void obtDatos4(){
  471.  
  472. AsyncHttpClient client = new AsyncHttpClient();
  473. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonArma.json";
  474.  
  475. RequestParams parametros = new RequestParams();
  476. //parametros.put("Edad",18);
  477.  
  478. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  479. @Override
  480. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  481. if (statusCode==200){
  482. //llamar funcion....
  483. CargaLista4(obtDatosJSON4(new String(responseBody)));
  484.  
  485. }
  486. }
  487.  
  488. @Override
  489. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  490.  
  491. }
  492. });
  493.  
  494.  
  495.  
  496. }
  497.  
  498.  
  499.  
  500. //////////////////////////////////////////////////////OBTENER DATOS ARMAS//////////////////////////////////////////////////////////////////
  501.  
  502.  
  503. //////////////////////////////////////////////////////OBTENER DATOS ARMAS//////////////////////////////////////////////////////////////////
  504. public void CargaLista4(ArrayList<String> datos4) {
  505.  
  506.  
  507. // Object[] nitvector = datos.toArray();
  508.  
  509.  
  510. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  511. // listado.setAdapter(adapter);
  512. listarmas=datos4;
  513.  
  514.  
  515.  
  516.  
  517. }
  518. //////////////////////////////////////////////////////OBTENER DATOS ARMAS//////////////////////////////////////////////////////////////////
  519.  
  520. //////////////////////////////////////////////////////OBTENER DATOS RADIO//////////////////////////////////////////////////////////////////
  521.  
  522. public ArrayList<String> obtDatosJSON5(String response){
  523.  
  524. ArrayList<String> listado5 = new ArrayList<String>();
  525.  
  526. try {
  527. JSONArray jsonArray = new JSONArray(response);
  528. String texto;
  529.  
  530. for (int i=0;i<jsonArray.length();i++){
  531. texto=jsonArray.getJSONObject(i).getString("nombre");//+ " "+
  532. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  533. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  534.  
  535.  
  536. listado5.add(texto);
  537.  
  538.  
  539.  
  540. }
  541.  
  542. }catch (Exception e){
  543. e.printStackTrace();
  544.  
  545. }
  546. return listado5;
  547.  
  548. }
  549.  
  550. //////////////////////////////////////////////////////OBTENER DATOS RADIO/////////////////////////////////////////////////////////////////
  551.  
  552.  
  553. /////////////////////////////////////////////////OBTENER DATOS RADIO////////////////////////////////////////////////////////
  554.  
  555. public void obtDatos5(){
  556.  
  557. AsyncHttpClient client = new AsyncHttpClient();
  558. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonRadio.json";
  559.  
  560. RequestParams parametros = new RequestParams();
  561. //parametros.put("Edad",18);
  562.  
  563. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  564. @Override
  565. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  566. if (statusCode==200){
  567. //llamar funcion....
  568. CargaLista5(obtDatosJSON5(new String(responseBody)));
  569.  
  570. }
  571. }
  572.  
  573. @Override
  574. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  575.  
  576. }
  577. });
  578.  
  579.  
  580.  
  581. }
  582.  
  583.  
  584.  
  585. //////////////////////////////////////////////////////OBTENER DATOS RADIO//////////////////////////////////////////////////////////////////
  586.  
  587.  
  588. //////////////////////////////////////////////////////OBTENER DATOS RADIO//////////////////////////////////////////////////////////////////
  589. public void CargaLista5(ArrayList<String> datos5) {
  590.  
  591.  
  592. // Object[] nitvector = datos.toArray();
  593.  
  594.  
  595. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  596. // listado.setAdapter(adapter);
  597. listaradio=datos5;
  598.  
  599.  
  600.  
  601.  
  602. }
  603. //////////////////////////////////////////////////////OBTENER DATOS RADIO//////////////////////////////////////////////////////////////////
  604.  
  605. //////////////////////////////////////////////////////OBTENER DATOS GUARDA////////////////////////////////////////////////////////////////
  606.  
  607. public ArrayList<String> obtDatosJSON6(String response){
  608.  
  609. ArrayList<String> listado6 = new ArrayList<String>();
  610.  
  611. try {
  612. JSONArray jsonArray = new JSONArray(response);
  613. String texto;
  614.  
  615. for (int i=0;i<jsonArray.length();i++){
  616. texto=jsonArray.getJSONObject(i).getString("nombre");//+ " "+
  617. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  618. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  619.  
  620.  
  621. listado6.add(texto);
  622.  
  623.  
  624.  
  625. }
  626.  
  627. }catch (Exception e){
  628. e.printStackTrace();
  629.  
  630. }
  631. return listado6;
  632.  
  633. }
  634.  
  635. //////////////////////////////////////////////////////OBTENER DATOS GUARDA///////////////////////////////////////////////////////////
  636.  
  637.  
  638. /////////////////////////////////////////////////OBTENER DATOS GUARDA//////////////////////////////////////////////////
  639. public void obtDatos6(){
  640.  
  641. AsyncHttpClient client = new AsyncHttpClient();
  642. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonGuarda.json";
  643.  
  644. RequestParams parametros = new RequestParams();
  645. //parametros.put("Edad",18);
  646.  
  647. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  648. @Override
  649. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  650. if (statusCode==200){
  651. //llamar funcion....
  652. CargaLista6(obtDatosJSON6(new String(responseBody)));
  653.  
  654. }
  655. }
  656.  
  657. @Override
  658. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  659.  
  660. }
  661. });
  662.  
  663.  
  664.  
  665. }
  666.  
  667.  
  668.  
  669. //////////////////////////////////////////////////////OBTENER DATOS GUARDA////////////////////////////////////////////////////////////////
  670.  
  671.  
  672. //////////////////////////////////////////////////////OBTENER DATOS GUARDA//////////////////////////////////////////////////////////////////
  673. public void CargaLista6(ArrayList<String> datos6) {
  674.  
  675.  
  676. // Object[] nitvector = datos.toArray();
  677.  
  678.  
  679. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  680. // listado.setAdapter(adapter);
  681. listaguarda=datos6;
  682.  
  683.  
  684.  
  685.  
  686. }
  687. //////////////////////////////////////////////////////OBTENER DATOS GUARDA//////////////////////////////////////////////////////////////////
  688.  
  689. //////////////////////////////////////////////////////OBTENER DATOS persona contactada////////////////////////////////////////////////////////////////
  690.  
  691. public ArrayList<String> obtDatosJSON7(String response){
  692.  
  693. ArrayList<String> listado7 = new ArrayList<String>();
  694.  
  695. try {
  696. JSONArray jsonArray = new JSONArray(response);
  697. String texto;
  698.  
  699. for (int i=0;i<jsonArray.length();i++){
  700. texto=jsonArray.getJSONObject(i).getString("adminnombre");//+ " "+
  701. //nit=jsonArray.getJSONObject(i).getString("Nit_user");//+ " "+
  702. // clave=jsonArray.getJSONObject(i).getString("pass_user");//+ " ";
  703.  
  704.  
  705. listado7.add(texto);
  706.  
  707.  
  708.  
  709. }
  710.  
  711. }catch (Exception e){
  712. e.printStackTrace();
  713.  
  714. }
  715. return listado7;
  716.  
  717. }
  718.  
  719. //////////////////////////////////////////////////////OBTENER DATOS persona contactada///////////////////////////////////////////////////////////////
  720.  
  721.  
  722. /////////////////////////////////////////////////OBTENER DATOS persona contactada//////////////////////////////////////////////////////
  723.  
  724. public void obtDatos7(){
  725.  
  726. AsyncHttpClient client = new AsyncHttpClient();
  727. String urlusuario="http://192.168.1.52/cotraser/asdfghjklqwertyuiozxcvbnm/jsonPuesto.json";
  728.  
  729. RequestParams parametros = new RequestParams();
  730. //parametros.put("Edad",18);
  731.  
  732. client.post(urlusuario, parametros, new AsyncHttpResponseHandler() {
  733. @Override
  734. public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  735. if (statusCode==200){
  736. //llamar funcion....
  737. CargaLista7(obtDatosJSON7(new String(responseBody)));
  738.  
  739. }
  740. }
  741.  
  742. @Override
  743. public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  744.  
  745. }
  746. });
  747.  
  748.  
  749.  
  750. }
  751.  
  752.  
  753.  
  754. //////////////////////////////////////////////////////OBTENER DATOS persona contactada/////////////////////////////////////////////////////////////////
  755.  
  756.  
  757. //////////////////////////////////////////////////////OBTENER DATOS persona contactada/////////////////////////////////////////////////////////////////
  758. public void CargaLista7(ArrayList<String> datos7) {
  759.  
  760.  
  761. // Object[] nitvector = datos.toArray();
  762.  
  763.  
  764. // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datos);
  765. // listado.setAdapter(adapter);
  766. listadmin=datos7;
  767.  
  768. if (listadmin.size()>0){
  769.  
  770. btnlogin.setVisibility(View.VISIBLE);
  771.  
  772. Toast.makeText(this, "Base De Datos cargada Correctamente",
  773. Toast.LENGTH_SHORT).show();
  774.  
  775. }
  776.  
  777.  
  778.  
  779.  
  780.  
  781. }
  782. //////////////////////////////////////////////////////OBTENER DATOS persona contactada//////////////////////////////////////////////////////////////////
  783.  
  784.  
  785. @Override
  786. protected void onCreate(Bundle savedInstanceState) {
  787. super.onCreate(savedInstanceState);
  788. setContentView(R.layout.activity_principal);
  789.  
  790. reload=(ImageButton)findViewById(R.id.reloadbuton);
  791. reload.setOnClickListener(this);
  792.  
  793. usuariotxt = (EditText) findViewById(R.id.usuariotxt);
  794. contrasenatxt = (EditText) findViewById(R.id.contrasenatxt);
  795. //login boton
  796. btnlogin = (Button) findViewById(R.id.btnlogin);
  797. btnlogin.setOnClickListener(this);
  798. //fin login boton
  799. listado=(ListView) findViewById(R.id.listView);
  800.  
  801. obtDatos();
  802. obtDatos1();
  803. obtDatos2();
  804. obtDatos3();
  805. obtDatos4();
  806. obtDatos5();
  807. obtDatos6();
  808. obtDatos7();
  809.  
  810.  
  811.  
  812.  
  813.  
  814. }
  815.  
  816.  
  817. @Override
  818. public void onClick(View v) {
  819.  
  820. switch (v.getId()) {
  821. case R.id.reloadbuton:
  822.  
  823. Intent intent = getIntent();
  824. finish();
  825. startActivity(intent);
  826.  
  827. break;
  828.  
  829. case R.id.btnlogin:
  830.  
  831. if(usuariotxt.getText().length()==0||contrasenatxt.getText().length()==0){
  832. AlertDialog.Builder error = new AlertDialog.Builder(this);
  833. error.setMessage("Usurario o Contraseña Incorrectos")
  834. .setPositiveButton("Continuar", new DialogInterface.OnClickListener() {
  835. @Override
  836. public void onClick(DialogInterface dialog, int which) {
  837. dialog.dismiss();
  838. }
  839. })
  840. .setTitle("ENSERIO ERRORES?")
  841. .create();
  842. error.show();
  843. //break;
  844.  
  845. }
  846.  
  847. if(usuariotxt.getText().length()!=0 && contrasenatxt.getText().length()!=0){
  848.  
  849.  
  850. verificarinicio();
  851.  
  852. verificarcontraseña();
  853. int a=checkpass;
  854. /////////////////////////////////////////////////////
  855.  
  856. if(checkpass!=1940)
  857. {
  858. AlertDialog.Builder error = new AlertDialog.Builder(this);
  859. error.setMessage("revisa lo que hiciste ¬¬")
  860. .setPositiveButton("Continuar", new DialogInterface.OnClickListener() {
  861. @Override
  862. public void onClick(DialogInterface dialog, int which) {
  863. dialog.dismiss();
  864. }
  865. })
  866. .setTitle("ENSERIO ERRORES?")
  867. .create();
  868. error.show();
  869. break;
  870. }
  871.  
  872.  
  873.  
  874. /////////////////////////////////////////////////
  875.  
  876.  
  877.  
  878. if(verificarinicio()&&(checkpass==1940)){
  879.  
  880.  
  881. Intent i = new Intent(Principal.this, perfil.class);
  882.  
  883. i.putExtra("usuario", usuario);
  884. i.putExtra("nombre", nombref);
  885. i.putExtra("lista1",listanombre);
  886. i.putExtra("lista2",listanit);
  887. i.putExtra("lista3",listapass);
  888. i.putExtra("lista4",listacliente);
  889. i.putExtra("lista5",listarmas);
  890. i.putExtra("lista6",listaradio);
  891. i.putExtra("lista7",listaguarda);
  892. i.putExtra("lista8",listadmin);
  893. startActivity(i);
  894. usuariotxt.setText("");
  895. contrasenatxt.setText("");
  896. //finish();
  897.  
  898. //break;
  899. }
  900. /*
  901. if(checkpass!=1940)
  902. {
  903. AlertDialog.Builder error = new AlertDialog.Builder(this);
  904. error.setMessage("revisa lo que hiciste ¬¬")
  905. .setPositiveButton("Continuar", new DialogInterface.OnClickListener() {
  906. @Override
  907. public void onClick(DialogInterface dialog, int which) {
  908. dialog.dismiss();
  909. }
  910. })
  911. .setTitle("ENSERIO ERRORES?")
  912. .create();
  913. error.show();
  914. //break;
  915. }
  916. */
  917. }
  918.  
  919.  
  920.  
  921.  
  922. //startActivity(new Intent(this, perfil.class));
  923.  
  924. // break;
  925.  
  926.  
  927. }
  928. }
  929.  
  930.  
  931. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement