Skip to content

Instantly share code, notes, and snippets.

View alvareztech's full-sized avatar
:octocat:
Coding...

Daniel Alvarez alvareztech

:octocat:
Coding...
View GitHub Profile
@alvareztech
alvareztech / .java
Created September 4, 2017 19:16
Android: Check networking
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
Log.d("MIAPP", "Estás online");
Log.d("MIAPP", " Estado actual: " + networkInfo.getState());
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
// Estas conectado a un Wi-Fi
@alvareztech
alvareztech / MainActivity.java
Created September 4, 2017 03:56
Android: SwipeRefreshLayout
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private SwipeRefreshLayout swipeRefreshLayout;
@Override
@alvareztech
alvareztech / Main.java
Created June 13, 2017 20:30
Java: Calendar, Date, Difference
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
@alvareztech
alvareztech / Main.java
Created June 9, 2017 23:56
JavaFX: ChoiceBox demo.
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
@alvareztech
alvareztech / Main.java
Last active June 8, 2017 15:09
JavaFX: TableView, add and delete buttons
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
@alvareztech
alvareztech / Main.java
Created June 5, 2017 21:41
JavaFX: GridPane Demo
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
@alvareztech
alvareztech / MainActivity.java
Last active April 19, 2017 18:47
Mi punto en el mundo. Versión 1. Día 2. Curso de servicios de localización en Android. 2017.1
package tech.alvarez.mipuntoenelmundo;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
@alvareztech
alvareztech / Main.java
Created November 29, 2016 01:27
Aplicación contador de votos y PieChart JavaFX. (necesita imágenes)
// necesita imágenes
package tech.alvarez;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
@alvareztech
alvareztech / Main.java
Created November 29, 2016 01:24
Ejemplo PieChart JavaFX
package tech.alvarez;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.stage.Stage;
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.section == 0 {
self.textFieldTableViewCell = tableView.dequeueReusableCellWithIdentifier("\(self.idFilterTextFieldTableViewCell)", forIndexPath: indexPath) as! FilterTextFieldTableViewCell
self.textFieldTableViewCell.textField.delegate = self
return self.textFieldTableViewCell
} else if indexPath.section == 1 {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCellWithIdentifier("\(self.idImageTableViewCell)", forIndexPath: indexPath) as! ImageTableViewCell
if let variableName = self.object {