Independente da missão de nossa saga, seja esta de alegria ou desgraça, o Brasil tem que ser defendido!
        Java
        19
        06

        Android - ProgressDialog Customizado

         
         
        
        
        Classe Customizada:
        
        
        
        
        import android.app.ProgressDialog;
        import android.content.Context;
        import android.graphics.drawable.AnimationDrawable;
        import android.os.Bundle;
        import android.widget.ImageView;
        
        import com.meuprojeto.R;
        
        public class MyCustomProgressDialog extends ProgressDialog {
          private AnimationDrawable animation;
        
          public static ProgressDialog ctor(Context context) {
            MyCustomProgressDialog dialog = new MyCustomProgressDialog(context);
            dialog.setIndeterminate(true);
            dialog.setCancelable(false);
            return dialog;
          }
        
          public MyCustomProgressDialog(Context context) {
            super(context);
          }
        
          public MyCustomProgressDialog(Context context, int theme) {
            super(context, theme);
          }
        
          @Override
          protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.view_custom_progress_dialog);
        
            ImageView la = (ImageView) findViewById(R.id.animation);
            la.setBackgroundResource(R.drawable.custom_progress_dialog_animation);
            animation = (AnimationDrawable) la.getBackground();
          }
        
          @Override
          public void show() {
            super.show();
            animation.start();
          }
        
          @Override
          public void dismiss() {
            super.dismiss();
            animation.stop();
          }
        }
        
        
        
        
        
        
        
        XML da Classe Customizada:
        
        
        
        
        ‹LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
          android:background="@null"
        ›
          ‹ImageView
            android:id="@+id/animation"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="centerCrop"
            android:adjustViewBounds="true" /›
        ‹/LinearLayout›
        
        
        
        
        
        Implementação da Classe Customizada:
        
        
        
        
        ‹?xml version="1.0" encoding="utf-8"?›
        ‹animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"›
          ‹item android:drawable="@drawable/load1_animation00000" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00001" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00002" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00003" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00004" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00005" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00006" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00007" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00008" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00009" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00010" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00011" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00012" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00013" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00014" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00015" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00016" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00017" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00018" android:duration="150" /›
          ‹item android:drawable="@drawable/load1_animation00019" android:duration="150" /›
        ‹/animation-list›
        
        
        
        
        
        Java
        28
        05

        Android - ImgView com GIF

         
         
        
        
        No arquivo build.gradle de seu APP compile a dependência Android Gif Drawable:
         
         
        dependencies {
            compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
        
        }
         
         
         
        Depois, no arquivo de layout basta usar a seguinte sintaxe:
         
         
        ‹pl.droidsonroids.gif.giftextview android:background="@drawable/aload_loading" android:layout_gravity="center" android:id="@+id/imageLoading" android:layout_margintop="100dp" android:layout_centerinparent="true" android:layout_height="wrap_content" android:layout_width="wrap_content">    
        Java
        30
        11

        Java - schedule a meia noite

        // fecha o caixa a meia noite //////////////////////
        import java.util.Calendar;
        import java.util.Timer;
        import java.util.TimerTask;


                Timer timer = new Timer();
                            Calendar date = Calendar.getInstance();
                            date.set(Calendar.HOUR, 0);
                            date.set(Calendar.MINUTE, 0);
                            date.set(Calendar.SECOND, 1);
                            date.set(Calendar.MILLISECOND, 0);


                            timer.schedule(
                              new TimerTask() {
                                @Override
                                public void run() {
                                    new fechaMeiaNoite();
                                }
                              },
                              date.getTime(),
                              1000 60 60 24 7
                            );
        ///////////////////////////////////////////////////
        Java
        30
        11

        Java - Ordenação de HashMap

        Exemplo simples de como ordenar um HashMap para que no momento do loop a ordem dos indices sejam respeitados...
         
         
         
        HashMap<Integer, String[]> registros = new HashMap<Integer, String[]>();


        Map<Integer,String[]> mp = new TreeMap<Integer,String[]>(registros);
        Iterator it = mp.entrySet().iterator();
        while (it.hasNext()) {
              Map.Entry pairs = (Map.Entry)it.next();
              String[] valores = (String[])pairs.getValue();

        }
        Java
        20
        11

        Java - JButton sem bordas

        JButton botao = new JButton("Botao");
        botao.setHorizontalTextPosition(SwingConstants.CENTER);
        botao.setForeground(Color.WHITE);
        botao.setFont(new Font("Arial", Font.BOLD, 40));
        botao.setMargin(new Insets(0, 0, 0, 0));
        botao.setBorder(null);
        botao.setOpaque(false);
        botao.setContentAreaFilled(false);
        botao.setBorderPainted(false);
        Java
        09
        11

        PHP CURL em JAVA

        Segue um exemplo de como um programador PHP pode fazer uma chamada externa em Java nos mesmos moldes do CURL:
         
         
         
         
         
        import java.io.BufferedReader;
        import java.io.DataOutputStream;
        import java.io.InputStreamReader;
        import java.net.URL;

        import javax.net.ssl.HttpsURLConnection;



        public class curl {


            private final String USER_AGENT = "Mozilla/5.0";



                public String sendPost(String url,String parametro) throws Exception {

                URL obj = new URL(url);
                HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

                //add reuqest header
                con.setRequestMethod("POST");
                con.setRequestProperty("User-Agent", USER_AGENT);
                con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

                // Send post request
                con.setDoOutput(true);
                DataOutputStream wr = new DataOutputStream(con.getOutputStream());
                wr.writeBytes(parametro);
                wr.flush();
                wr.close();

                int responseCode = con.getResponseCode();
                System.out.println("nSending 'POST' request to URL : " + url);
                System.out.println("Post parameters : " + parametro);
                System.out.println("Response Code : " + responseCode);

                BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
                String inputLine;
                StringBuffer response = new StringBuffer();

                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();

                //print result
                        return response.toString();


            }

        }
        Tipo de Posts
        Parceiros
        Feed

        Entre com o seu e-mail:

        Sobre

        Rafael Nonato Ribeiro Ferreira, graduado em Análise e Desenvolvimento de Sistemas pela Uninove, programador nas linguagens PHP, JavaScript, JQuery e Java, desenvolvedor web HTML e CSS desenvolve e modela em SGBDs Mysql, PostGreSQL e Oracle, atualmente trabalha como Analista e Desenvolvedor de Sistemas, é um brasileiro, cristão, patriota filiado ao PSOL e com convicções politicas próprias conforme será mostrado em seu futuro site www.constituicaoproposta.com.br, nas horas de folga gosta de tocar seu violão e compor letras de múisca, Torço para o São Paulo e para a Portela.

        © Copyright 2012 NRF Informática Soluções. All Rights Reserved.