Example usage for android.view View INVISIBLE

List of usage examples for android.view View INVISIBLE

Introduction

In this page you can find the example usage for android.view View INVISIBLE.

Prototype

int INVISIBLE

To view the source code for android.view View INVISIBLE.

Click Source Link

Document

This view is invisible, but it still takes up space for layout purposes.

Usage

From source file:com.alexskyy.gplusauthtest.MainActivity.java

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
    case R.id.request_auth_code_checkbox:
        mRequestServerAuthCode = isChecked;
        buildGoogleApiClient();/*  w ww  .  j av  a 2 s.  c  o m*/
        if (isChecked) {
            findViewById(R.id.layout_has_token).setVisibility(View.VISIBLE);
        } else {
            findViewById(R.id.layout_has_token).setVisibility(View.INVISIBLE);
        }
        break;
    case R.id.has_token_checkbox:
        mServerHasToken = isChecked;
        break;
    }
}

From source file:reportsas.com.formulapp.Formulario.java

public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) {
    int id;/*from w ww.  ja  v  a2s  .  c o m*/
    int tipo_pregunta = preg.getTipoPregunta();
    LinearLayout pregunta;
    TextView textView;
    TextView textAyuda;
    switch (tipo_pregunta) {
    case 1:
        id = R.layout.pregunta_texto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloPregunta);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    case 2:
        id = R.layout.pregunta_multitexto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo);
        textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 3:
        id = R.layout.pregunta_seleccion;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica);
        ArrayList<OpcionForm> opciones = preg.getOpciones();
        final ArrayList<RadioButton> rb = new ArrayList<RadioButton>();

        for (int i = 0; i < opciones.size(); i++) {
            OpcionForm opcion = opciones.get(i);
            rb.add(new RadioButton(this));
            rg.addView(rb.get(i));
            rb.get(i).setText(opcion.getEtInicial());

        }
        final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int radioButtonID = group.getCheckedRadioButtonId();
                RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID);
                respt.setText(radioButton.getText());
            }
        });

        break;
    case 4:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones2 = preg.getOpciones();
        final EditText ediOtros = new EditText(this);
        ArrayList<CheckBox> cb = new ArrayList<CheckBox>();

        for (int i = 0; i < opciones2.size(); i++) {
            OpcionForm opcion = opciones2.get(i);
            cb.add(new CheckBox(this));
            pregunta.addView(cb.get(i));
            cb.get(i).setText(opcion.getEtInicial());
            if (opcion.getEditble().equals("S")) {

                ediOtros.setEnabled(false);
                ediOtros.setId(R.id.edtTexto);
                pregunta.addView(ediOtros);
                cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) {
                            ediOtros.setEnabled(true);
                        } else {
                            ediOtros.setText("");
                            ediOtros.setEnabled(false);
                        }
                    }
                });
            }

        }
        TextView spacio = new TextView(this);
        spacio.setText("        ");
        spacio.setVisibility(View.INVISIBLE);
        pregunta.addView(spacio);
        break;
    case 5:
        id = R.layout.pregunta_escala;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloEscala);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());

        TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial);
        TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal);
        OpcionForm opci = preg.getOpciones().get(0);
        etInicial.setText(opci.getEtInicial());
        etFinal.setText(opci.getEtFinal());
        final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala);
        RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala);
        rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion()));
        rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                respEscala.setText("" + Math.round(rating));
            }
        });

        break;
    case 6:
        id = R.layout.pregunta_lista;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloLista);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones3 = preg.getOpciones();
        //Creamos la lista
        LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>();
        //La poblamos con los ejemplos
        for (int i = 0; i < opciones3.size(); i++) {
            opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial()));
        }

        //Creamos el adaptador*/
        Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado);
        ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this,
                android.R.layout.simple_spinner_item, opcn);
        //Aadimos el layout para el men y se lo damos al spinner
        spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        listad.setAdapter(spinner_adapter);

        break;
    case 7:
        id = R.layout.pregunta_tabla;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloTabla);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones);
        ArrayList<OpcionForm> opciones4 = preg.getOpciones();
        ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>();
        for (int i = 0; i < opciones4.size(); i++) {
            TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null);
            RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow);

            final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>();
            ArrayList<Valor> valoresT = opciones4.get(i).getValores();
            for (int k = 0; k < valoresT.size(); k++) {
                RadioButton rb_nuevo = new RadioButton(this);
                rb_nuevo.setText(valoresT.get(k).getDescripcion());
                tg_valores.addView(rb_nuevo);
                valoOpc.add(rb_nuevo);
            }

            ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial());
            tba.addView(row);
        }
        TextView espacio = new TextView(this);
        espacio.setText("        ");
        pregunta.addView(espacio);
        break;
    case 8:
        id = R.layout.pregunta_fecha;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloFecha);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 9:
        id = R.layout.pregunta_hora;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloHora);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    default:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    }

    return pregunta;
}

From source file:com.android.development.Connectivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.connectivity);

    mWm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mPm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
    mNetd = INetworkManagementService.Stub.asInterface(b);

    findViewById(R.id.enableWifi).setOnClickListener(mClickListener);
    findViewById(R.id.disableWifi).setOnClickListener(mClickListener);

    findViewById(R.id.startDelayedCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopDelayedCycle).setOnClickListener(mClickListener);
    mDCOnDurationEdit = (EditText) findViewById(R.id.dc_wifi_on_duration);
    mDCOnDurationEdit.setText(Long.toString(mDCOnDuration));
    mDCOffDurationEdit = (EditText) findViewById(R.id.dc_wifi_off_duration);
    mDCOffDurationEdit.setText(Long.toString(mDCOffDuration));
    mDCCycleCountView = (TextView) findViewById(R.id.dc_wifi_cycles_done);
    mDCCycleCountView.setText(Integer.toString(mDCCycleCount));

    findViewById(R.id.startScreenCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopScreenCycle).setOnClickListener(mClickListener);
    mSCOnDurationEdit = (EditText) findViewById(R.id.sc_wifi_on_duration);
    mSCOnDurationEdit.setText(Long.toString(mSCOnDuration));
    mSCOffDurationEdit = (EditText) findViewById(R.id.sc_wifi_off_duration);
    mSCOffDurationEdit.setText(Long.toString(mSCOffDuration));
    mSCCycleCountView = (TextView) findViewById(R.id.sc_wifi_cycles_done);
    mSCCycleCountView.setText(Integer.toString(mSCCycleCount));

    mScanButton = (Button) findViewById(R.id.startScan);
    mScanButton.setOnClickListener(mClickListener);
    mScanCyclesEdit = (EditText) findViewById(R.id.sc_scan_cycles);
    mScanCyclesEdit.setText(Long.toString(mScanCycles));
    mScanDisconnect = (CheckBox) findViewById(R.id.scanDisconnect);
    mScanDisconnect.setChecked(true);//from  ww  w .java2 s.  c o m
    mScanResults = (TextView) findViewById(R.id.sc_scan_results);
    mScanResults.setVisibility(View.INVISIBLE);

    mScanRecv = new WifiScanReceiver();
    mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

    findViewById(R.id.startTdls).setOnClickListener(mClickListener);
    findViewById(R.id.stopTdls).setOnClickListener(mClickListener);

    findViewById(R.id.start_mms).setOnClickListener(mClickListener);
    findViewById(R.id.stop_mms).setOnClickListener(mClickListener);
    findViewById(R.id.start_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.stop_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.crash).setOnClickListener(mClickListener);

    findViewById(R.id.add_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.remove_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.bound_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.bound_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_socket).setOnClickListener(mClickListener);

    registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
}

From source file:sjizl.com.ChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (CommonUtilities.isInternetAvailable(getApplicationContext())) //returns true if internet available
    {/* w  ww  .j  a v a 2s .  c  o m*/

        SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE);
        pid = sp.getString("pid", null);
        naam = sp.getString("naam", null);
        username = sp.getString("username", null);
        password = sp.getString("password", null);
        foto = sp.getString("foto", null);
        foto_num = sp.getString("foto_num", null);
        Bundle bundle = getIntent().getExtras();
        pid_user = bundle.getString("pid_user");
        user = bundle.getString("user");
        user_foto_num = bundle.getString("user_foto_num");
        user_foto = bundle.getString("user_foto");

        // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show();

        if (user.equalsIgnoreCase(naam.toString())) {
            Toast.makeText(getApplicationContext(), "You can't message yourself!", Toast.LENGTH_SHORT).show();
            finish();
        }

        AbsListViewBaseActivity.imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext()));

        //registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION));
        setContentView(R.layout.activity_chat);

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d1 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d2 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        smilbtn = (ImageView) findViewById(R.id.smilbtn);
        listView = (ListView) findViewById(android.R.id.list);
        underlayout = (LinearLayout) findViewById(R.id.underlayout);
        smiles_layout = (LinearLayout) findViewById(R.id.smiles);
        textView1_bgtext = (TextView) findViewById(R.id.textView1_bgtext);
        textView1_bgtext.setText(user);
        imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard);
        imageView1_logo = (ImageView) findViewById(R.id.imageView1_logo);
        imageView_bericht = (ImageView) findViewById(R.id.imageView_bericht);
        textView2_under_title = (TextView) findViewById(R.id.textView2_under_title);
        right_lin = (LinearLayout) findViewById(R.id.right_lin);
        left_lin1 = (LinearLayout) findViewById(R.id.left_lin1);
        left_lin3 = (LinearLayout) findViewById(R.id.left_lin3);
        left_lin4 = (LinearLayout) findViewById(R.id.left_lin4);
        middle_lin = (LinearLayout) findViewById(R.id.middle_lin);
        smile_lin = (LinearLayout) findViewById(R.id.smile_lin);
        ber_lin = (LinearLayout) findViewById(R.id.ber_lin);
        progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole);
        progressBar_hole.setVisibility(View.INVISIBLE);
        imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto,
                imageView2_dashboard, options);
        new UpdateChat().execute();
        mNewMessage = (EditText) findViewById(R.id.newmsg);

        ber_lin = (LinearLayout) findViewById(R.id.ber_lin);
        photosend = (ImageView) findViewById(R.id.photosend);

        /*
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    
                    
                    
            imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() {
               @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        super.onLoadingComplete(imageUri, view, loadedImage);
                
        Bitmap LoadedImage2 = loadedImage;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
           if(loadedImage!=null){
        LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext());
           }
        }
                
        if (Build.VERSION.SDK_INT >= 16) {
                
           listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2));
                
          } else {
                
             listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2));
          }
                
        }
        }
            );
        }
        */
        final ImageView left_button;
        left_button = (ImageView) findViewById(R.id.imageView1_back);
        CommonUtilities u = new CommonUtilities();
        u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1,
                left_button);

        listView.setOnScrollListener(new OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                mScrollState = scrollState;
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
            }

        });
        listView.setLongClickable(true);
        registerForContextMenu(listView);

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        viewPager_smiles = new ViewPager(this);
        viewPager_smiles.setId(0x1000);
        LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams555.width = LayoutParams.MATCH_PARENT;
        layoutParams555.height = (metrics.heightPixels / 2);
        viewPager_smiles.setLayoutParams(layoutParams555);
        TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mNewMessage);
        viewPager_smiles.setAdapter(mAdapter);
        LayoutInflater inflater = null;
        viewPager_smiles.setVisibility(View.VISIBLE);
        smiles_layout.addView(viewPager_smiles);
        smiles_layout.setVisibility(View.GONE);

        left_lin4.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });
        middle_lin.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });

        smile_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                opensmiles();
            }
        });

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent dashboard = new Intent(getApplicationContext(), ProfileActivityMain.class);
                dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                dashboard.putExtra("user", ArrChatLines.get(position).getNaam());
                dashboard.putExtra("user_foto", foto);
                dashboard.putExtra("user_foto_num", foto_num);
                startActivity(dashboard);
            }
        });

        mNewMessage.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {

                    v.setFocusable(true);
                    v.setFocusableInTouchMode(true);

                    smiles_layout.setVisibility(View.GONE);
                    smilbtn.setImageResource(R.drawable.emoji_btn_normal);
                    return false;
                }
                return false;
            }
        });

        TextWatcher textWatcher = new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                //after text changed
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                if (ArrChatLines.get(0).getblocked_profile().equals("1")) {

                } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) {

                } else {
                    CommonUtilities.startandsendwebsock(
                            "" + pid_user + " " + naam + " " + pid + " is typing to you ...");
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() {
                  @Override
                     public void onCompleted(Exception ex, WebSocket webSocket) {
                         if (ex != null) {
                   ex.printStackTrace();
                   return;
                         }
                         webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ...");
                                 
                         webSocket.close();
                     }
                 });
                 */
            }
        };

        photosend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (ArrChatLines.get(0).getblocked_profile().equals("1")) {

                } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) {

                } else {
                    openGallery(SELECT_FILE1);
                }
            }
        });

        mNewMessage.addTextChangedListener(textWatcher);

        ber_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText();
                Spanned cs = (Spanned) mNewMessage.getText();
                String a = Html.toHtml(spanStr);
                String text = mNewMessage.getText().toString();
                mNewMessage.setText("");
                mNewMessage.requestFocus();
                mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto;
                if (text.length() < 1) {
                } else {
                    addItem(foto, foto_num, "0", naam, text.toString(),
                            "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a);
                }
            }
        });

        hideSoftKeyboard();

    } else {

        Intent dashboard = new Intent(getApplicationContext(), NoInternetActivity.class);
        dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dashboard);

        finish();
    }
    mNewMessage.clearFocus();
    listView.requestFocus();

    final String wsuri = "ws://sjizl.com:9300";

    WebSocketConnection mConnection8 = new WebSocketConnection();

    if (mConnection8.isConnected()) {
        mConnection8.reconnect();

    } else {
        try {
            mConnection8.connect(wsuri, new WebSocketConnectionHandler() {

                @Override
                public void onOpen() {
                    Log.d("TAG", "Status: Connected to " + wsuri);

                }

                @Override
                public void onTextMessage(String payload) {

                    if (payload.contains("message send")) {
                        String[] parts = payload.split(" ");
                        String zender = parts[0];
                        String send_from = parts[1];
                        String send_name = parts[2];
                        String send_foto = parts[3];
                        String send_foto_num = parts[4];
                        String send_xxx = parts[5];

                        //      Toast.makeText(getApplication(), "" +   "\n zender: "+zender+"" +   "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" +
                        //         "\n send_from: "+send_from, 
                        //                  Toast.LENGTH_LONG).show();
                        if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) {

                            if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) {

                                //Toast.makeText(getApplication(), "uu",    Toast.LENGTH_LONG).show();

                                new UpdateChat().execute();

                            }
                        }

                    } else if (payload.contains("is typing to you")) {

                        String[] parts = payload.split(" ");
                        String part1 = parts[0]; // 004
                        is_typing_name = parts[1]; // 034556
                        if (is_typing_name.equalsIgnoreCase(user)) {

                            if (ArrChatLines.size() > 0) {
                                oldvalue = ArrChatLines.get(0).getLaatstOnline();

                            } else {
                                oldvalue = textView2_under_title.getText().toString();
                            }

                            Timer t = new Timer(false);
                            t.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText("typing ...");
                                        }
                                    });
                                }
                            }, 2);

                            Timer t2 = new Timer(false);
                            t2.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText(oldvalue);
                                        }
                                    });
                                }
                            }, 2000);
                        }

                    }
                    Log.d("TAG", "Got echo: " + payload);
                }

                @Override
                public void onClose(int code, String reason) {
                    Log.d("TAG", "Connection lost.");
                }
            });
        } catch (WebSocketException e) {
            Log.d("TAG", e.toString());
        }
    }

}

From source file:com.nononsenseapps.filepicker.sample.ftp.FtpPickerFragment.java

@Override
public void onLoaderReset(Loader<SortedList<FtpFile>> loader) {
    progressBar.setVisibility(View.INVISIBLE);
    recyclerView.setVisibility(View.VISIBLE);
    super.onLoaderReset(loader);
}

From source file:mp.paschalis.LoginFragment.java

/**
 * Clears login message and Progress dialog
 *//*from  w  w  w  .j av a 2 s  .  c  o  m*/
private void clearLoginStaff() {
    ProgressBar progressBarLoginButton = (ProgressBar) getSherlockActivity()
            .findViewById(R.id.progressBarLoginButton);

    TextView editTextLoginMsg = (TextView) getSherlockActivity().findViewById(R.id.textViewLoginMessage);

    progressBarLoginButton.setVisibility(View.INVISIBLE);
    editTextLoginMsg.setText("");
}

From source file:com.ccxt.whl.activity.SettingsFragmentCopy.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    /***************?**************/
    rl_user_pic = (RelativeLayout) getView().findViewById(R.id.rl_user_pic);
    rl_user_nicheng = (RelativeLayout) getView().findViewById(R.id.rl_user_nicheng);
    rl_user_xingbie = (RelativeLayout) getView().findViewById(R.id.rl_user_xingbie);
    rl_user_nianling = (RelativeLayout) getView().findViewById(R.id.rl_user_nianling);
    rl_user_chengshi = (RelativeLayout) getView().findViewById(R.id.rl_user_chengshi);
    rl_user_zainadongtai = (RelativeLayout) getView().findViewById(R.id.rl_user_zainadongtai);
    //?//from  ww  w  .  j a v  a  2  s .co  m
    iv_user_photo = (ImageView) getView().findViewById(R.id.iv_user_photo);
    tv_user_nicheng = (TextView) getView().findViewById(R.id.tv_user_nicheng);
    tv_user_xingbie = (TextView) getView().findViewById(R.id.tv_user_xingbie);
    tv_user_nianling = (TextView) getView().findViewById(R.id.tv_user_nianling);
    tv_user_chengshi = (TextView) getView().findViewById(R.id.tv_user_chengshi);
    tv_user_zainadongtai = (TextView) getView().findViewById(R.id.tv_user_zainadongtai);
    //??
    UserPic = PreferenceUtils.getInstance(getActivity()).getSettingUserPic();
    UserNickName = PreferenceUtils.getInstance(getActivity()).getSettingUserNickName();
    UserSex = PreferenceUtils.getInstance(getActivity()).getSettingUserSex();
    UserAge = PreferenceUtils.getInstance(getActivity()).getSettingUserAge();
    UserArea = PreferenceUtils.getInstance(getActivity()).getSettingUserArea();
    UserZaina = PreferenceUtils.getInstance(getActivity()).getSettingUserZaina();
    //?
    //iv_user_photo
    ImageLoader.getInstance().displayImage(UserPic, iv_user_photo, ImageOptions.getOptions());
    tv_user_nicheng.setText(UserNickName);
    tv_user_xingbie.setText(UserSex);
    tv_user_nianling.setText(UserAge);
    tv_user_chengshi.setText(UserArea);
    tv_user_zainadongtai.setText(UserZaina);
    /***************?**************/

    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);

    iv_switch_open_notification = (ImageView) getView().findViewById(R.id.iv_switch_open_notification);
    iv_switch_close_notification = (ImageView) getView().findViewById(R.id.iv_switch_close_notification);
    iv_switch_open_sound = (ImageView) getView().findViewById(R.id.iv_switch_open_sound);
    iv_switch_close_sound = (ImageView) getView().findViewById(R.id.iv_switch_close_sound);
    iv_switch_open_vibrate = (ImageView) getView().findViewById(R.id.iv_switch_open_vibrate);
    iv_switch_close_vibrate = (ImageView) getView().findViewById(R.id.iv_switch_close_vibrate);
    iv_switch_open_speaker = (ImageView) getView().findViewById(R.id.iv_switch_open_speaker);
    iv_switch_close_speaker = (ImageView) getView().findViewById(R.id.iv_switch_close_speaker);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMChatManager.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMChatManager.getInstance().getCurrentUser() + ")");
    }

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);

    /*********************/
    rl_user_pic.setOnClickListener(this);
    rl_user_nicheng.setOnClickListener(this);
    rl_user_xingbie.setOnClickListener(this);
    rl_user_nianling.setOnClickListener(this);
    rl_user_chengshi.setOnClickListener(this);
    rl_user_zainadongtai.setOnClickListener(this);
    /*********************/

    blacklistContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);

    chatOptions = EMChatManager.getInstance().getChatOptions();
    if (chatOptions.getNotificationEnable()) {
        iv_switch_open_notification.setVisibility(View.VISIBLE);
        iv_switch_close_notification.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_notification.setVisibility(View.INVISIBLE);
        iv_switch_close_notification.setVisibility(View.VISIBLE);
    }
    if (chatOptions.getNoticedBySound()) {
        iv_switch_open_sound.setVisibility(View.VISIBLE);
        iv_switch_close_sound.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_sound.setVisibility(View.INVISIBLE);
        iv_switch_close_sound.setVisibility(View.VISIBLE);
    }
    if (chatOptions.getNoticedByVibrate()) {
        iv_switch_open_vibrate.setVisibility(View.VISIBLE);
        iv_switch_close_vibrate.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_vibrate.setVisibility(View.INVISIBLE);
        iv_switch_close_vibrate.setVisibility(View.VISIBLE);
    }

    if (chatOptions.getUseSpeaker()) {
        iv_switch_open_speaker.setVisibility(View.VISIBLE);
        iv_switch_close_speaker.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_speaker.setVisibility(View.INVISIBLE);
        iv_switch_close_speaker.setVisibility(View.VISIBLE);
    }

    /*************************http?***********************/
    responseHandler = new BaseJsonHttpResponseHandler() {

        @Override
        public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
            // TODO Auto-generated method stub
            Log.d("log", rawJsonResponse);
            if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                Toast.makeText(getActivity(), "?,?", 0).show();
                return;
            }

            Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);
            if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) {
                Toast.makeText(getActivity(), "?", 0).show();
                Log.d("log", "message==" + lm.get("message").toString());
                if (!CommonUtils.isNullOrEmpty(lm.get("result").toString())) {
                    Map<String, Object> lmres = JsonToMapList.getMap(lm.get("result").toString());
                    String nickname = lmres.get("nickname").toString();
                    String age = lmres.get("age").toString();
                    String sex = lmres.get("sex").toString();
                    String headurl = lmres.get("headurl").toString();
                    if (!CommonUtils.isNullOrEmpty(nickname)) {
                        tv_user_nicheng.setText(nickname);
                    } else if (!CommonUtils.isNullOrEmpty(age)) {
                        tv_user_nianling.setText(age);
                    } else if (!CommonUtils.isNullOrEmpty(sex)) {
                        tv_user_xingbie.setText(sex);
                    } else if (!CommonUtils.isNullOrEmpty(headurl)) {
                        //tv_user_xingbie.setText(sex);
                        //?
                    }

                }
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                Object errorResponse) {
            // TODO Auto-generated method stub
            Toast.makeText(getActivity(), ",?", 0).show();
            return;
        }

        @Override
        protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
            // TODO Auto-generated method stub
            return null;
        }

    };
}

From source file:com.wikitude.phonegap.WikitudePlugin.java

@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callContext) {

    /* hide architect-view -> destroy and remove from activity */
    if (WikitudePlugin.ACTION_CLOSE.equals(action)) {
        if (this.architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override/*from  w  w  w . j  a  v  a2  s . c o  m*/
                public void run() {
                    removeArchitectView();
                }
            });
            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* return success only if view is opened (no matter if visible or not) */
    if (WikitudePlugin.ACTION_STATE_ISOPEN.equals(action)) {
        if (this.architectView != null) {
            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* return success only if view is opened (no matter if visible or not) */
    if (WikitudePlugin.ACTION_IS_DEVICE_SUPPORTED.equals(action)) {
        if (ArchitectView.isDeviceSupported(this.cordova.getActivity()) && hasNeonSupport()) {
            callContext.success(action + ": this device is ARchitect-ready");
        } else {
            callContext.error(action + action + ":Sorry, this device is NOT ARchitect-ready");
        }
        return true;
    }

    if (WikitudePlugin.ACTION_CAPTURE_SCREEN.equals(action)) {
        if (architectView != null) {

            int captureMode = ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW;

            try {
                captureMode = (args.getBoolean(0))
                        ? ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW
                        : ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM;
            } catch (Exception e) {
                // unexpected error;
            }

            architectView.captureScreen(captureMode, new CaptureScreenCallback() {

                @Override
                public void onScreenCaptured(Bitmap screenCapture) {
                    try {
                        // final File imageDirectory = cordova.getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
                        final File imageDirectory = Environment.getExternalStorageDirectory();
                        if (imageDirectory == null) {
                            callContext.error("External storage not available");
                        }

                        final File screenCaptureFile = new File(imageDirectory,
                                System.currentTimeMillis() + ".jpg");

                        if (screenCaptureFile.exists()) {
                            screenCaptureFile.delete();
                        }
                        final FileOutputStream out = new FileOutputStream(screenCaptureFile);
                        screenCapture.compress(Bitmap.CompressFormat.JPEG, 90, out);
                        out.flush();
                        out.close();

                        cordova.getActivity().runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                final String absoluteCaptureImagePath = screenCaptureFile.getAbsolutePath();
                                callContext.success(absoluteCaptureImagePath);

                                //                         in case you want to sent the pic to other applications, uncomment these lines (for future use)
                                //                        final Intent share = new Intent(Intent.ACTION_SEND);
                                //                        share.setType("image/jpg");
                                //                        share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenCaptureFile));
                                //                        final String chooserTitle = "Share Snaphot";
                                //                        cordova.getActivity().startActivity(Intent.createChooser(share, chooserTitle));
                            }
                        });
                    } catch (Exception e) {
                        callContext.error(e.getMessage());
                    }

                }
            });
            return true;
        }
    }

    /* life-cycle's RESUME */
    if (WikitudePlugin.ACTION_ON_RESUME.equals(action)) {

        if (this.architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    WikitudePlugin.this.architectView.onResume();
                    callContext.success(action + ": architectView is present");
                    locationProvider.onResume();
                }
            });

            // callContext.success( action + ": architectView is present" );
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* life-cycle's PAUSE */
    if (WikitudePlugin.ACTION_ON_PAUSE.equals(action)) {
        if (architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    WikitudePlugin.this.architectView.onPause();
                    locationProvider.onPause();
                }
            });

            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* set visibility to "visible", return error if view is null */
    if (WikitudePlugin.ACTION_SHOW.equals(action)) {

        this.cordova.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (architectView != null) {
                    architectView.setVisibility(View.VISIBLE);
                    callContext.success(action + ": architectView is present");
                } else {
                    callContext.error(action + ": architectView is not present");
                }
            }
        });

        return true;
    }

    /* set visibility to "invisible", return error if view is null */
    if (WikitudePlugin.ACTION_HIDE.equals(action)) {

        this.cordova.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (architectView != null) {
                    architectView.setVisibility(View.INVISIBLE);
                    callContext.success(action + ": architectView is present");
                } else {
                    callContext.error(action + ": architectView is not present");
                }
            }
        });

        return true;
    }

    /* define call-back for url-invocations */
    if (WikitudePlugin.ACTION_ON_URLINVOKE.equals(action)) {
        this.urlInvokeCallback = callContext;
        final PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT,
                action + ": registered callback");
        result.setKeepCallback(true);
        callContext.sendPluginResult(result);
        return true;
    }

    /* location update */
    if (WikitudePlugin.ACTION_SET_LOCATION.equals(action)) {
        if (this.architectView != null) {
            try {
                final double lat = args.getDouble(0);
                final double lon = args.getDouble(1);
                float alt = Float.MIN_VALUE;
                try {
                    alt = (float) args.getDouble(2);
                } catch (Exception e) {
                    // invalid altitude -> ignore it
                }
                final float altitude = alt;
                Double acc = null;
                try {
                    acc = args.getDouble(3);
                } catch (Exception e) {
                    // invalid accuracy -> ignore it
                }
                final Double accuracy = acc;
                if (this.cordova != null && this.cordova.getActivity() != null) {
                    cordova.getActivity().runOnUiThread(
                            //                  this.cordova.getThreadPool().execute( 
                            new Runnable() {

                                @Override
                                public void run() {
                                    if (accuracy != null) {
                                        WikitudePlugin.this.architectView.setLocation(lat, lon, altitude,
                                                accuracy.floatValue());
                                    } else {
                                        WikitudePlugin.this.architectView.setLocation(lat, lon, altitude);
                                    }
                                }
                            });
                }

            } catch (Exception e) {
                callContext.error(
                        action + ": exception thrown, " + e != null ? e.getMessage() : "(exception is NULL)");
                return true;
            }
            callContext.success(action + ": updated location");
            return true;
        } else {
            /* return error if there is no architect-view active*/
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    if (WikitudePlugin.ACTION_CALL_JAVASCRIPT.equals(action)) {

        String logMsg = null;
        try {
            final String callJS = args.getString(0);
            logMsg = callJS;

            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    if (architectView != null) {
                        WikitudePlugin.this.architectView.callJavascript(callJS);
                    } else {
                        callContext.error(action + ": architectView is not present");
                    }
                }
            });

        } catch (JSONException je) {
            callContext.error(
                    action + ": exception thrown, " + je != null ? je.getMessage() : "(exception is NULL)");
            return true;
        }
        callContext.success(action + ": called js, '" + logMsg + "'");

        return true;
    }

    /* initial set-up, show ArchitectView full-screen in current screen/activity */
    if (WikitudePlugin.ACTION_OPEN.equals(action)) {
        this.openCallback = callContext;
        PluginResult result = null;
        try {
            final String apiKey = args.getString(0);
            final String filePath = args.getString(1);

            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    try {
                        WikitudePlugin.this.addArchitectView(apiKey, filePath);

                        /* call success method once architectView was added successfully */
                        if (openCallback != null) {
                            PluginResult result = new PluginResult(PluginResult.Status.OK);
                            result.setKeepCallback(false);
                            openCallback.sendPluginResult(result);
                        }
                    } catch (Exception e) {
                        /* in case "addArchitectView" threw an exception -> notify callback method asynchronously */
                        openCallback.error(e != null ? e.getMessage() : "Exception is 'null'");
                    }
                }
            });

        } catch (Exception e) {
            result = new PluginResult(PluginResult.Status.ERROR,
                    action + ": exception thown, " + e != null ? e.getMessage() : "(exception is NULL)");
            result.setKeepCallback(false);
            callContext.sendPluginResult(result);
            return true;
        }

        /* adding architect-view is done in separate thread, ensure to setKeepCallback so one can call success-method properly later on */
        result = new PluginResult(PluginResult.Status.NO_RESULT,
                action + ": no result required, just registered callback-method");
        result.setKeepCallback(true);
        callContext.sendPluginResult(result);
        return true;
    }

    /* fall-back return value */
    callContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "no such action: " + action));
    return false;
}

From source file:com.moonpi.tapunlock.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get lobster_two asset and create typeface
    // Set action bar title to lobster_two typeface
    lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf");

    int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle);

    if (actionBarTitleView != null) {
        actionBarTitleView.setTypeface(lobsterTwo);
        actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f);
        actionBarTitleView.setTextColor(getResources().getColor(R.color.blue));
    }//from  w  ww.j a va2  s. c  o m

    setContentView(R.layout.activity_main);

    // Hide keyboard on app launch
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Get NFC service and adapter
    NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
    nfcAdapter = nfcManager.getDefaultAdapter();

    // Create PendingIntent for enableForegroundDispatch for NFC tag discovery
    pIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    readFromJSON();
    writeToJSON();
    readFromJSON();

    // If Android 4.2 or bigger
    if (Build.VERSION.SDK_INT > 16) {
        // Check if TapUnlock folder exists, if not, create directory
        File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock");
        boolean folderSuccess = true;

        if (!folder.exists()) {
            folderSuccess = folder.mkdir();
        }

        try {
            // If blur var bigger than 0
            if (settings.getInt("blur") > 0) {
                // If folder exists or successfully created
                if (folderSuccess) {
                    // If blurred wallpaper file doesn't exist
                    if (!ImageUtils.doesBlurredWallpaperExist()) {
                        // Get default wallpaper
                        WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
                        final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable();

                        if (wallpaperDrawable != null) {
                            // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable);

                                    Bitmap blurredWallpaper = null;
                                    if (bitmapToBlur != null)
                                        blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur,
                                                blur);

                                    if (blurredWallpaper != null) {
                                        ImageUtils.storeImage(blurredWallpaper);
                                    }
                                }
                            }).start();
                        }
                    }
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    // Initialize layout items
    pinEdit = (EditText) findViewById(R.id.pinEdit);
    pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE);
    Button setPin = (Button) findViewById(R.id.setPin);
    ImageButton newTag = (ImageButton) findViewById(R.id.newTag);
    enabled_disabled = (TextView) findViewById(R.id.enabled_disabled);
    Switch toggle = (Switch) findViewById(R.id.toggle);
    seekBar = (SeekBar) findViewById(R.id.seekBar);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper);
    listView = (ListView) findViewById(R.id.listView);
    backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue);
    noTags = (TextView) findViewById(R.id.noTags);

    // Initialize TagAdapter
    adapter = new TagAdapter(this, tags);

    registerForContextMenu(listView);

    // Set listView adapter to TapAdapter object
    listView.setAdapter(adapter);

    // Set click, check and seekBar listeners
    setPin.setOnClickListener(this);
    newTag.setOnClickListener(this);
    refreshWallpaper.setOnClickListener(this);
    toggle.setOnCheckedChangeListener(this);
    seekBar.setOnSeekBarChangeListener(this);

    // Set seekBar progress to blur var
    try {
        seekBar.setProgress(settings.getInt("blur"));

    } catch (JSONException e) {
        e.printStackTrace();
    }

    // Refresh the listView height
    updateListViewHeight(listView);

    // If no tags, show 'Press + to add Tags' textView
    if (tags.length() == 0)
        noTags.setVisibility(View.VISIBLE);

    else
        noTags.setVisibility(View.INVISIBLE);

    // Scroll up
    scrollView = (ScrollView) findViewById(R.id.scrollView);

    scrollView.post(new Runnable() {
        public void run() {
            scrollView.scrollTo(0, scrollView.getTop());
            scrollView.fullScroll(View.FOCUS_UP);
        }
    });

    // If lockscreen enabled, initialize switch, text and start service
    try {
        if (settings.getBoolean("lockscreen")) {
            onStart = true;
            enabled_disabled.setText(R.string.lockscreen_enabled);
            enabled_disabled.setTextColor(getResources().getColor(R.color.green));

            toggle.setChecked(true);
        }

    } catch (JSONException e1) {
        e1.printStackTrace();
    }
}