Guest User

Untitled

a guest
Jun 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.17 KB | None | 0 0
  1. if($consulta){
  2.  
  3. if($reg=mysqli_fetch_array($resultado)){
  4.  
  5. $result["nombre"]=$reg['nombre'];
  6. $result["color"]=$reg['color'];
  7. $result["texto1"]=$reg['texto1'];
  8. $result["texto2"]=$reg['texto2'];
  9. $result["texto3"]=$reg['texto3'];
  10. $result["texto4"]=$reg['texto4'];
  11. $result["precio"]=$reg['precio'];
  12. $result["ancho"]=$reg['ancho'];
  13. $result["largo"]=$reg['largo'];
  14. $result["informacion"]=$reg['informacion'];
  15. $result["imagen"]=base64_encode($reg['foto']);
  16. $json['datos'][]=$reg;
  17. }
  18. mysqli_close($conexion);
  19. echo json_encode($json);
  20. }
  21.  
  22. @Override
  23. public void onResponse(JSONObject response) {
  24. //Toast.makeText(getContext(),"Conexion",Toast.LENGTH_SHORT).show();
  25.  
  26. ListaArticulosPOJO miLista=null;
  27.  
  28. JSONArray jsonArray = response.optJSONArray("datos");
  29.  
  30.  
  31. try{
  32. for (int i=0;i<jsonArray.length();i++){
  33.  
  34. miLista= new ListaArticulosPOJO();
  35. JSONObject jsonObject=null;
  36. jsonObject = jsonArray.getJSONObject(i);
  37.  
  38. miLista.setNombre(jsonObject.optString("nombre"));
  39. miLista.setColor(jsonObject.optString("color"));
  40. miLista.setTexto1(jsonObject.optString("texto1"));
  41. miLista.setTexto2(jsonObject.optString("texto2"));
  42. miLista.setTexto3(jsonObject.optString("texto3"));
  43. miLista.setTexto4(jsonObject.optString("texto4"));
  44. miLista.setPrecio(jsonObject.optDouble("precio"));
  45. miLista.setAncho(jsonObject.optDouble("ancho"));
  46. miLista.setLargo(jsonObject.optDouble("largo"));
  47. miLista.setGrueso(jsonObject.optDouble("grueso"));
  48. miLista.setInformacion(jsonObject.optString("informacion"));
  49. miLista.setDatos(jsonObject.optString("fotoArticulo"));
  50.  
  51.  
  52. list.add(miLista);
  53.  
  54. recuperaActivity=miLista.getNombre().toString();
  55. }
  56.  
  57.  
  58. }
  59. catch (Exception e){
  60. e.printStackTrace();
  61. }
  62.  
  63.  
  64.  
  65.  
  66. RecyclerViewListaArticulosAdapter adapter=new RecyclerViewListaArticulosAdapter(list,getContext());
  67.  
  68. recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  69.  
  70. recyclerView.setAdapter(adapter);
  71.  
  72.  
  73.  
  74.  
  75. }
  76.  
  77. public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
  78.  
  79. holder.id.setText(mDatos.get(position).getNombre());
  80. holder.color.setText(mDatos.get(position).getColor());
  81.  
  82.  
  83.  
  84. holder.cardView.setOnClickListener(new View.OnClickListener() {
  85. @Override
  86. public void onClick(View v) {
  87.  
  88.  
  89. Intent intent=new Intent(mContext,ArticulosActivity.class);
  90. Bundle bundle= new Bundle();
  91.  
  92. intent.putExtra("nombre",mDatos.get(position).getNombre());
  93. intent.putExtra("color",mDatos.get(position).getColor());
  94. intent.putExtra("texto1",mDatos.get(position).getTexto1());
  95. intent.putExtra("texto2",mDatos.get(position).getTexto2());
  96. intent.putExtra("texto3",mDatos.get(position).getTexto3());
  97. intent.putExtra("texto4",mDatos.get(position).getTexto4());
  98. intent.putExtra("precio",mDatos.get(position).getPrecio());
  99. intent.putExtra("ancho",mDatos.get(position).getAncho());
  100. intent.putExtra("largo",mDatos.get(position).getLargo());
  101. intent.putExtra("grueso",mDatos.get(position).getGrueso());
  102. //intent.putExtra("foto",mDatos.get(position).getFotoArticulo());
  103.  
  104. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  105. mContext.startActivity(intent);
  106.  
  107.  
  108. }
  109. });
  110.  
  111. }
  112.  
  113. static String nombre;
  114. static String color;
  115. static String texto1;
  116. static String texto2;
  117. static String texto3;
  118. static String texto4;
  119. static double precio;
  120. static double ancho;
  121. static double largo;
  122. static double grueso;
  123. static String fotoArticulo;
  124. static String informacion;
  125. static ImageView imageView;
  126.  
  127.  
  128.  
  129. @Override
  130. protected void onCreate(Bundle savedInstanceState) {
  131. super.onCreate(savedInstanceState);
  132. setContentView(R.layout.activity_articulos);
  133.  
  134. toolbar = (Toolbar)findViewById(R.id.toolbar_activity_articulos);
  135. setSupportActionBar(toolbar);
  136.  
  137.  
  138. Intent intent=getIntent();
  139. nombre=intent.getExtras().getString("nombre");
  140. color=intent.getExtras().getString("color");
  141. texto4=intent.getExtras().getString("texto4");
  142. ancho=intent.getExtras().getDouble("ancho");
  143. largo=intent.getExtras().getDouble("largo");
  144. grueso=intent.getExtras().getDouble("grueso");
  145. precio=intent.getExtras().getDouble("precio");
  146. informacion=intent.getExtras().getString("informacion");
  147. fotoArticulo=intent.getExtras().getString("foto");
  148.  
  149. //imageView=intent.getExtras().("foto");
  150.  
  151.  
  152.  
  153.  
  154. android.support.v4.app.FragmentManager fmLista1= getSupportFragmentManager();
  155. fmLista1.beginTransaction().replace((R.id.txt_base_articulos_izquierda),new ArticulosListaFragment()).commit();
  156.  
  157. android.support.v4.app.FragmentManager fmLista2= getSupportFragmentManager();
  158. fmLista2.beginTransaction().replace((R.id.txt_base_articulos_derecha),new ArticulosDatosFragment()).commit();
  159. }
  160.  
  161. public ArticulosDatosFragment() {
  162. // Required empty public constructor
  163. }
  164.  
  165.  
  166. @Override
  167. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  168. Bundle savedInstanceState) {
  169. // Inflate the layout for this fragment
  170.  
  171.  
  172. View vista=inflater.inflate(R.layout.fragment_articulos_datos, container, false);
  173. articulosActivity =new ArticulosActivity();
  174.  
  175.  
  176. radioGroup=(RadioGroup)vista.findViewById(R.id.txt_radio_group);
  177. radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  178. @Override
  179. public void onCheckedChanged(RadioGroup group, int checkedId) {
  180. if (checkedId==R.id.txt_radio_eh){
  181. Toast.makeText(getContext(),"EH Pulsado ",Toast.LENGTH_SHORT).show();
  182. }
  183. else if(checkedId==R.id.txt_radio_gh){
  184. Toast.makeText(getContext(),"GH Pulsado ",Toast.LENGTH_SHORT).show();
  185. }
  186. }
  187. });
  188.  
  189. *imageView=(ImageView)vista.findViewById(R.id.txt_imagen_articulo);
  190. //imageView.setImageBitmap(articulosActivity.fotoArticulo);*
  191.  
  192. informacion=(TextView)vista.findViewById(R.id.txt_articulo_informacion);
  193. informacion.setText(articulosActivity.informacion);
  194.  
  195. texto1=(TextView)vista.findViewById(R.id.txt_text1);
  196. texto1.setText(articulosActivity.nombre);
  197.  
  198. texto2=(TextView)vista.findViewById(R.id.txt_text2);
  199. texto2.setText(articulosActivity.color);
  200.  
  201. texto3=(TextView)vista.findViewById(R.id.txt_text3);
  202. texto3.setText(articulosActivity.largo+" x "+articulosActivity.ancho+" x "+articulosActivity.grueso);
  203.  
  204. texto4=(TextView)vista.findViewById(R.id.txt_text4);
  205. texto4.setText(articulosActivity.texto4);
  206.  
  207. m2=(TextView)vista.findViewById(R.id.txt_precio_metro);
  208. m2.setText(articulosActivity.precio+"");
  209.  
  210.  
  211. bedarf=(EditText)vista.findViewById(R.id.txt_cliente_metro);
  212. boton=(Button)vista.findViewById(R.id.txt_boton_kalkulation);
  213. boxPrecio=(TextView)vista.findViewById(R.id.txt_precio_box);
  214. boxTotal=(TextView)vista.findViewById(R.id.txt_metros_total);
  215. menge=(TextView)vista.findViewById(R.id.txt_metros_total);
  216. summe=(TextView)vista.findViewById(R.id.txt_precio_total);
  217.  
  218.  
  219. return vista;
  220. }
Add Comment
Please, Sign In to add comment