Example usage for android.view View getClass

List of usage examples for android.view View getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:cl.gisred.android.MicroMedidaActivity.java

private void cerrarFormLimit(boolean bSave, View v) {
    if (bSave) {/*from w w  w  .j a va 2s  .c om*/

        final AtomicReference<String> resp = new AtomicReference<>("");

        if (!validarZoneLimit(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            View vAction = getLayoutValidate(v);
            Map<String, Object> objectMap = new HashMap<>();
            for (View view : vAction.getTouchables()) {

                if (view.getClass().equals(GisEditText.class)) {
                    GisEditText oText = (GisEditText) view;

                    if (oText.getText() != null && !oText.getText().toString().isEmpty()) {
                        if (oText.getId() == R.id.txtPoste) {
                            objectMap.put("id_poste", oText.getIdObjeto());
                            oUbicacion = oText.getPoint();
                        } else if (oText.getId() == R.id.txtTramoBt) {
                            objectMap.put("id_tramo", oText.getText().toString());
                        }
                    }
                }
            }

            objectMap.put("empresa", empresa);
            objectMap.put("modulo", modulo);

            Graphic newFeatureGraphic = new Graphic(oUbicacion, null, objectMap);
            Graphic[] adds = { newFeatureGraphic };
            LyAddZoneLimit.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {
                @Override
                public void onCallback(FeatureEditResult[][] featureEditResults) {
                    if (featureEditResults[0] != null) {
                        if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                            resp.set("Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Util.showConfirmation(MicroMedidaActivity.this, resp.get());
                                }
                            });
                        }
                    }
                }

                @Override
                public void onError(Throwable throwable) {
                    resp.set("Error al ingresar: " + throwable.getLocalizedMessage());
                    Log.w("onError", resp.get());

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(MicroMedidaActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
        }
    }

    bMapTap = false;
    oUbicacion = null;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    if (bVerCapas)
        toogleCapas(fabVerCapas);

    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMicroActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();

    if (LyAddZoneLimit != null)
        LyAddZoneLimit.setVisible(true);
}

From source file:cl.gisred.android.RegEquipoActivity.java

private void cerrarFormCrear(boolean bSave, View v) {
    // TODO Usar Layer Indicada
    bSave = false;//w w  w  .  j a  va 2 s  . c  om
    if (bSave) {

        final AtomicReference<String> resp = new AtomicReference<>("");

        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            View vAction = getLayoutValidate(v);
            Map<String, Object> objectMap = new HashMap<>();
            for (View view : vAction.getTouchables()) {

                if (view.getClass().equals(GisEditText.class)) {
                    GisEditText oText = (GisEditText) view;

                    if (oText.getText() != null && !oText.getText().toString().isEmpty()) {
                        if (oText.getId() == R.id.txtPoste) {
                            objectMap.put("id_poste_camara", oText.getIdObjeto());
                            objectMap.put("tipo_nodo_conex", oText.getTipo());
                        } else if (oText.getId() == R.id.txtTramoBt) {
                            objectMap.put("id_tramo_bt", oText.getText().toString());
                        } else if (oText.getId() == R.id.txtAddress) {
                            objectMap.put("id_direccion", oText.getIdObjeto());
                            objectMap.put("tipo_direccion", oText.getTipo());
                        }
                    }

                } else if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                    EditText oText = (EditText) view;

                    if (oText.getId() == R.id.txtNroMedidor) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("nro_medidor", oVal);
                    }

                } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                    Spinner oSpinner = (Spinner) view;
                    String sValue = oSpinner.getSelectedItem().toString();

                    if (oSpinner.getId() == R.id.spinnerMarcaMed)
                        objectMap.put("marca_medidor", sValue);
                    else if (oSpinner.getId() == R.id.spinnerFaseCon)
                        objectMap.put("fase_conex", sValue);
                    else if (oSpinner.getId() == R.id.spinnerObservacion)
                        objectMap.put("observacion", sValue);
                }
            }

            objectMap.put("empresa", empresa);
            objectMap.put("modulo", modulo);

            if (mLocation != null) {
                Point p = (Point) GeometryEngine.project(mLocation, egs, wm);

                objectMap.put("X", p.getX());
                objectMap.put("Y", p.getY());
            }

            Graphic newFeatureGraphic = new Graphic(oUbicacion, null, objectMap);
            Graphic[] adds = { newFeatureGraphic };
            LyAgrRegEquipo.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {
                @Override
                public void onCallback(FeatureEditResult[][] featureEditResults) {
                    if (featureEditResults[0] != null) {
                        if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                            resp.set("Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Util.showConfirmation(RegEquipoActivity.this, resp.get());
                                }
                            });
                        }
                    }
                }

                @Override
                public void onError(Throwable throwable) {
                    resp.set("Error al ingresar: " + throwable.getLocalizedMessage());
                    Log.w("onError", resp.get());

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(RegEquipoActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
        }
    }

    bMapTap = false;
    oUbicacion = null;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    if (bVerCapas)
        toogleCapas(fabVerCapas);

    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMicroActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();

    if (LyAgrRegEquipo != null)
        LyAgrRegEquipo.setVisible(true);
}

From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java

public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;/*from ww  w.  ja  va 2 s.  c  o m*/
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft >= currLeft) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            final int nextStart = this.orientation == LinearLayout.HORIZONTAL
                    ? getChildRectInPagerCoordinates(mTempRect, nextFocused).left
                    : getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
            final int currentStart = this.orientation == LinearLayout.HORIZONTAL
                    ? getChildRectInPagerCoordinates(mTempRect, currentFocused).left
                    : getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
            if (currentFocused != null && nextStart <= currentStart) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:cl.gisred.android.MicroMedidaActivity.java

private void cerrarFormCrear(boolean bSave, View v) {
    if (bSave) {//from ww w.  j  a  v a2 s.co m

        final AtomicReference<String> resp = new AtomicReference<>("");

        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            View vAction = getLayoutValidate(v);
            Map<String, Object> objectMap = new HashMap<>();
            for (View view : vAction.getTouchables()) {

                if (view.getClass().equals(GisEditText.class)) {
                    GisEditText oText = (GisEditText) view;

                    if (oText.getText() != null && !oText.getText().toString().isEmpty()) {
                        if (oText.getId() == R.id.txtPoste) {
                            objectMap.put("id_poste_camara", oText.getIdObjeto());
                            objectMap.put("tipo_nodo_conex", oText.getTipo());
                        } else if (oText.getId() == R.id.txtTramoBt) {
                            objectMap.put("id_tramo_bt", oText.getText().toString());
                        } else if (oText.getId() == R.id.txtAddress) {
                            objectMap.put("id_direccion", oText.getIdObjeto());
                            objectMap.put("tipo_direccion", oText.getTipo());
                        }
                    }

                } else if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                    EditText oText = (EditText) view;

                    if (oText.getId() == R.id.txtNroMedidor) {
                        String oVal = (oText.getText().toString().isEmpty()) ? "0" : oText.getText().toString();
                        objectMap.put("nro_medidor", oVal);
                    }

                } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                    Spinner oSpinner = (Spinner) view;
                    String sValue = oSpinner.getSelectedItem().toString();

                    if (oSpinner.getId() == R.id.spinnerMarcaMed)
                        objectMap.put("marca_medidor", sValue);
                    else if (oSpinner.getId() == R.id.spinnerFaseCon)
                        objectMap.put("fase_conex", sValue);
                    else if (oSpinner.getId() == R.id.spinnerObservacion)
                        objectMap.put("observacion", sValue);
                }
            }

            objectMap.put("empresa", empresa);
            objectMap.put("modulo", modulo);

            if (mLocation != null) {
                Point p = (Point) GeometryEngine.project(mLocation, egs, wm);

                objectMap.put("X", p.getX());
                objectMap.put("Y", p.getY());
            }

            Graphic newFeatureGraphic = new Graphic(oUbicacion, null, objectMap);
            Graphic[] adds = { newFeatureGraphic };
            LyAddMicroMed.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {
                @Override
                public void onCallback(FeatureEditResult[][] featureEditResults) {
                    if (featureEditResults[0] != null) {
                        if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                            resp.set("Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Util.showConfirmation(MicroMedidaActivity.this, resp.get());
                                }
                            });
                        }
                    }
                }

                @Override
                public void onError(Throwable throwable) {
                    resp.set("Error al ingresar: " + throwable.getLocalizedMessage());
                    Log.w("onError", resp.get());

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(MicroMedidaActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
        }
    }

    bMapTap = false;
    oUbicacion = null;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    if (bVerCapas)
        toogleCapas(fabVerCapas);

    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMicroActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();

    if (LyAddMicroMed != null)
        LyAddMicroMed.setVisible(true);
}

From source file:com.example.sky.test.view.ViewPager.java

/**
 * Handle scrolling in response to a left or right arrow click.
 *
 * @param direction The direction corresponding to the arrow key that was pressed. It should be
 *                  either {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT}.
 * @return Whether the scrolling was handled successfully.
 *///ww w  . j a  v  a 2s  .  c  o m
public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft >= currLeft) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft <= currLeft) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:cn.androidy.materialdesignsample.ryanharterviewpager.ViewPager.java

public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;//from w w w. ja  v  a  2s.co m
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft >= currLeft) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft <= currLeft) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_UP) {
            final int nextUp = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
            final int currUp = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
            if (currentFocused != null && nextUp >= currUp) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_DOWN) {
            final int nextUp = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
            final int currUp = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
            if (currentFocused != null && nextUp <= currUp) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_UP || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_DOWN || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:com.viewpagerindicator.MyDirectionalViewPager.java

public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;/*from w w  w  . j a va2 s. com*/
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft >= currLeft) {
                handled = pagePre();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft <= currLeft) {
                handled = pageNext();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pagePre();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageNext();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:android.improving.utils.views.cardsview.OrientedViewPager.java

public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;//from  ww  w.  ja  v a  2s  . c o m
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_UP) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page left.
            if (mOrientation == Orientation.VERTICAL) {
                final int nextTop = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
                final int currTop = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
                if (currentFocused != null && nextTop >= currTop) {
                    handled = pageBack();
                } else {
                    handled = nextFocused.requestFocus();
                }
            } else {
                final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
                final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
                if (currentFocused != null && nextLeft >= currLeft) {
                    handled = pageBack();
                } else {
                    handled = nextFocused.requestFocus();
                }
            }
        } else if (direction == View.FOCUS_DOWN) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            if (mOrientation == Orientation.VERTICAL) {
                final int nextDown = getChildRectInPagerCoordinates(mTempRect, nextFocused).bottom;
                final int currDown = getChildRectInPagerCoordinates(mTempRect, currentFocused).bottom;
                if (currentFocused != null && nextDown <= currDown) {
                    handled = pageForward();
                } else {
                    handled = nextFocused.requestFocus();
                }
            } else {
                final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
                final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
                if (currentFocused != null && nextLeft <= currLeft) {
                    handled = pageForward();
                } else {
                    handled = nextFocused.requestFocus();
                }
            }
        }
    } else if (direction == FOCUS_UP || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageBack();
    } else if (direction == FOCUS_DOWN || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageForward();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:com.guide.ViewPager.java

public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) {
        currentFocused = null;/* w w w .j a v a 2 s  .  c om*/
    } else if (currentFocused != null) {
        boolean isChild = false;
        for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                .getParent()) {
            if (parent == this) {
                isChild = true;
                break;
            }
        }
        if (!isChild) {
            // This would cause the focus search down below to fail in fun
            // ways.
            final StringBuilder sb = new StringBuilder();
            sb.append(currentFocused.getClass().getSimpleName());
            for (ViewParent parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent
                    .getParent()) {
                sb.append(" => ").append(parent.getClass().getSimpleName());
            }
            Log.e(TAG, "arrowScroll tried to find focus based on non-child " + "current focused view "
                    + sb.toString());
            currentFocused = null;
        }
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            // If there is nothing to the left, or this is causing us to
            // jump to the right, then what we really want to do is page
            // left.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft >= currLeft) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page
            // right.
            final int nextLeft = getChildRectInPagerCoordinates(mTempRect, nextFocused).left;
            final int currLeft = getChildRectInPagerCoordinates(mTempRect, currentFocused).left;
            if (currentFocused != null && nextLeft <= currLeft) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_UP) {
            final int nextUp = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
            final int currUp = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
            if (currentFocused != null && nextUp >= currUp) {
                handled = pageLeft();
            } else {
                handled = nextFocused.requestFocus();
            }
        } else if (direction == View.FOCUS_DOWN) {
            final int nextUp = getChildRectInPagerCoordinates(mTempRect, nextFocused).top;
            final int currUp = getChildRectInPagerCoordinates(mTempRect, currentFocused).top;
            if (currentFocused != null && nextUp <= currUp) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_UP || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_DOWN || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}

From source file:cl.gisred.android.InspActivity.java

private int recorrerForm(View v) {
    int contRequeridos = 0;

    for (View view : v.getTouchables()) {

        if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
            EditText oText = (EditText) view;

            TextInputLayout oTextInput = (TextInputLayout) oText.getParentForAccessibility();
            if (oTextInput.getHint() != null && oTextInput.getHint().toString().contains("*")) {
                if (oText.getText().toString().trim().isEmpty()) {
                    contRequeridos++;/*from   www. j  a  v a2 s. c  om*/
                    oText.setError("Campo obligatorio");
                } else {
                    oText.setError(null);
                    if (oText.getId() == R.id.txtRutInst || oText.getId() == R.id.txtRutTecn) {
                        if (!Util.validateRut(oText.getText().toString())) {
                            contRequeridos++;
                            oText.setError("Rut no vlido");
                        } else
                            oText.setError(null);
                    }
                }
            }
        } else if (view.getClass().getGenericSuperclass().equals(CheckBox.class)) {

        } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
            if (view.getId() == R.id.spinnerMarca || view.getId() == R.id.spinnerTipo
                    || view.getId() == R.id.spinnerFase) {
                Spinner oSpinner = (Spinner) view;
                if (!bFallo && oSpinner.getSelectedItemPosition() == 0)
                    contRequeridos++;
            }
        }
    }

    //28-09 Se elimina firma como requisito
    //contRequeridos += (valImage(v, R.id.imgFirmaTec)) ? 0 : 1;

    //23-09 Se elimina fotos como requisito
    //contRequeridos += (valImage(v, R.id.imgPhoto1)) ? 0 : 1;
    //contRequeridos += (valImage(v, R.id.imgPhoto2)) ? 0 : 1;
    //contRequeridos += (valImage(v, R.id.imgPhoto3)) ? 0 : 1;

    return contRequeridos;
}