Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

In this page you can find the example usage for android.widget LinearLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {/*from w w w  .j  a v  a  2  s.c om*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    setContentView(R.layout.activity_authentication);
    RelativeLayout relativeLayout = (RelativeLayout) this.findViewById(R.id.relavtiveLayoutAuthentication);

    if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) {
        relativeLayout.setVisibility(RelativeLayout.GONE);
    }
    deviceInfo = new DeviceInfo(context);
    etDomain = (EditText) findViewById(R.id.etDomain);
    etUsername = (EditText) findViewById(R.id.etUsername);
    etPassword = (EditText) findViewById(R.id.etPassword);
    etDomain.setFocusable(true);
    etDomain.requestFocus();
    btnSignIn = (Button) findViewById(R.id.btnSignIn);
    btnSignIn.setOnClickListener(onClickAuthenticate);
    btnSignIn.setEnabled(false);

    // change button color background till user enters a valid input
    btnSignIn.setBackgroundResource(R.drawable.btn_grey);
    btnSignIn.setTextColor(ContextCompat.getColor(this, R.color.black));
    TextView textViewSignIn = (TextView) findViewById(R.id.textViewSignIn);
    LinearLayout loginLayout = (LinearLayout) findViewById(R.id.loginLayout);

    if (Preference.hasPreferenceKey(context, Constants.TOKEN_EXPIRED)) {
        etDomain.setEnabled(false);
        etDomain.setTextColor(ContextCompat.getColor(this, R.color.black));
        etUsername.setEnabled(false);
        etUsername.setTextColor(ContextCompat.getColor(this, R.color.black));
        btnSignIn.setText(R.string.btn_sign_in);
        etPassword.setFocusable(true);
        etPassword.requestFocus();
        String tenantedUserName = Preference.getString(context, Constants.USERNAME);
        int tenantSeparator = tenantedUserName.lastIndexOf('@');
        etUsername.setText(tenantedUserName.substring(0, tenantSeparator));
        etDomain.setText(tenantedUserName.substring(tenantSeparator + 1, tenantedUserName.length()));
        isReLogin = true;
        textViewSignIn.setText(R.string.msg_need_to_sign_in);
    } else if (Constants.CLOUD_MANAGER != null) {
        isCloudLogin = true;
        etDomain.setVisibility(View.GONE);
        textViewSignIn.setText(R.string.txt_sign_in_cloud);
    }

    if (Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_ACTIVE) && !isReLogin) {
        Intent intent = new Intent(AuthenticationActivity.this, AlreadyRegisteredActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish();
        return;
    }

    TextView textViewSignUp = (TextView) findViewById(R.id.textViewSignUp);
    if (!isReLogin && Constants.SIGN_UP_URL != null) {
        Linkify.TransformFilter transformFilter = new Linkify.TransformFilter() {
            @Override
            public String transformUrl(Matcher match, String url) {
                return Constants.SIGN_UP_URL;
            }
        };
        Pattern pattern = Pattern.compile(getResources().getString(R.string.txt_sign_up_linkify));
        Linkify.addLinks(textViewSignUp, pattern, null, null, transformFilter);
    } else {
        textViewSignUp.setVisibility(View.GONE);
    }

    if (Constants.HIDE_LOGIN_UI) {
        loginLayout.setVisibility(View.GONE);
    }

    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            startLockTask();
        }
    }

    TextView textViewWipeData = (TextView) this.findViewById(R.id.textViewWipeData);
    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP) && Constants.DISPLAY_WIPE_DEVICE_BUTTON) {
        textViewWipeData.setVisibility(View.VISIBLE);
        textViewWipeData.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(AuthenticationActivity.this).setTitle(getString(R.string.app_name))
                        .setMessage(R.string.wipe_confirmation)
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getApplicationContext()
                                        .getSystemService(Context.DEVICE_POLICY_SERVICE);
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                                    devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE
                                            | DevicePolicyManager.WIPE_RESET_PROTECTION_DATA);
                                } else {
                                    devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE);
                                }
                            }
                        }).setNegativeButton(android.R.string.no, null).show();
            }
        });
    }

    ImageView logo = (ImageView) findViewById(R.id.imageViewLogo);
    if (Constants.COSU_SECRET_EXIT) {
        logo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                kioskExit++;
                if (kioskExit == 6) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        stopLockTask();
                    }
                    finish();
                }
            }
        });
    }

    etUsername.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            enableSubmitIfReady();
        }

        @Override
        public void afterTextChanged(Editable s) {
            enableSubmitIfReady();
        }
    });

    etPassword.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            enableSubmitIfReady();
        }

        @Override
        public void afterTextChanged(Editable s) {
            enableSubmitIfReady();
        }
    });

    if (org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE
            .equals(org.wso2.iot.agent.proxy.utils.Constants.Authenticator.MUTUAL_SSL_AUTHENTICATOR)) {

        AuthenticatorFactory authenticatorFactory = new AuthenticatorFactory();
        ClientAuthenticator authenticator = authenticatorFactory.getClient(
                org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE,
                AuthenticationActivity.this, Constants.AUTHENTICATION_REQUEST_CODE);
        authenticator.doAuthenticate();
    }

    //This is an override to ownership type.
    if (Constants.DEFAULT_OWNERSHIP != null) {
        deviceType = Constants.DEFAULT_OWNERSHIP;
        Preference.putString(context, Constants.DEVICE_TYPE, deviceType);
    } else {
        deviceType = Constants.OWNERSHIP_BYOD;
    }

    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) {
        Intent intent = getIntent();
        if (intent.hasExtra("android.app.extra.token")) {
            adminAccessToken = intent.getStringExtra("android.app.extra.token");
            proceedToAuthentication();
        }
    }

    // This is added so that in case due to an agent customisation, if the authentication
    // activity is called the AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED is set, the activity
    // must be finished.
    if (Constants.AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED) {
        finish();
    }
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private void showConfirmDialog(String fp, String method) {

    util.addDebugLogMsg(1, "I", "showConfirmDialog entered");
    final NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override/*from www . j av  a  2 s  .  c  om*/
        public void positiveResponse(Context c, Object[] o) {
            try {
                mSvcClient.aidlConfirmResponse((Integer) o[0]);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            try {
                mSvcClient.aidlConfirmResponse((Integer) o[0]);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    });

    final LinearLayout ll_confirm = (LinearLayout) findViewById(R.id.profile_confirm);
    ll_confirm.setVisibility(LinearLayout.VISIBLE);
    ll_confirm.setBackgroundColor(Color.BLACK);
    ll_confirm.bringToFront();
    TextView dlg_title = (TextView) findViewById(R.id.copy_delete_confirm_title);
    TextView dlg_msg = (TextView) findViewById(R.id.copy_delete_confirm_msg);
    dlg_title.setText(mContext.getString(R.string.msgs_common_dialog_warning));
    dlg_title.setTextColor(Color.YELLOW);
    String msg_text = "";
    if (method.equals(SMBSYNC_CONFIRM_FOR_COPY)) {
        msg_text = String.format(getString(R.string.msgs_mirror_confirm_copy_confirm), fp);
    } else {
        msg_text = String.format(getString(R.string.msgs_mirror_confirm_delete_confirm), fp);
    }
    dlg_msg.setText(msg_text);

    showNotificationMsg(msg_text);

    if (method.equals(SMBSYNC_CONFIRM_FOR_COPY))
        dlg_msg.setText(String.format(getString(R.string.msgs_mirror_confirm_copy_confirm), fp));
    else
        dlg_msg.setText(String.format(getString(R.string.msgs_mirror_confirm_delete_confirm), fp));

    Button btnYes = (Button) findViewById(R.id.copy_delete_confirm_yes);
    Button btnYesAll = (Button) findViewById(R.id.copy_delete_confirm_yesall);
    final Button btnNo = (Button) findViewById(R.id.copy_delete_confirm_no);
    Button btnNoAll = (Button) findViewById(R.id.copy_delete_confirm_noall);
    Button btnTaskCancel = (Button) findViewById(R.id.copy_delete_confirm_task_cancel);

    // Yes?
    btnYes.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ll_confirm.setVisibility(LinearLayout.GONE);
            ntfy.notifyToListener(true, new Object[] { SMBSYNC_CONFIRM_RESP_YES });
        }
    });
    // YesAll?
    btnYesAll.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ll_confirm.setVisibility(LinearLayout.GONE);
            ntfy.notifyToListener(true, new Object[] { SMBSYNC_CONFIRM_RESP_YESALL });
        }
    });
    // No?
    btnNo.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ll_confirm.setVisibility(LinearLayout.GONE);
            ntfy.notifyToListener(false, new Object[] { SMBSYNC_CONFIRM_RESP_NO });
        }
    });
    // NoAll?
    btnNoAll.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ll_confirm.setVisibility(LinearLayout.GONE);
            ntfy.notifyToListener(false, new Object[] { SMBSYNC_CONFIRM_RESP_NOALL });
        }
    });
    // Task cancel?
    btnTaskCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ll_confirm.setVisibility(LinearLayout.GONE);
            try {
                mSvcClient.aidlCancelThread();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            ntfy.notifyToListener(false, new Object[] { SMBSYNC_CONFIRM_RESP_NOALL });
        }
    });
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private void autoTerminateDlg(final String result_code, final String result_msg) {
    final ThreadCtrl threadCtl = new ThreadCtrl();
    threadCtl.setEnabled();//enableAsyncTask();

    final LinearLayout ll_bar = (LinearLayout) findViewById(R.id.profile_progress_bar);
    ll_bar.setVisibility(LinearLayout.VISIBLE);
    ll_bar.setBackgroundColor(Color.BLACK);
    ll_bar.bringToFront();/*from w w w .ja v a  2s.co  m*/

    final TextView title = (TextView) findViewById(R.id.profile_progress_bar_msg);
    title.setText("");
    final Button btnCancel = (Button) findViewById(R.id.profile_progress_bar_btn_cancel);
    btnCancel.setText(getString(R.string.msgs_progress_bar_dlg_aterm_cancel));
    final Button btnImmed = (Button) findViewById(R.id.profile_progress_bar_btn_immediate);
    btnImmed.setText(getString(R.string.msgs_progress_bar_dlg_aterm_immediate));

    // CANCEL?
    btnCancel.setEnabled(true);
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mGp.settingAutoTerm = false;
            btnCancel.setText(getString(R.string.msgs_progress_dlg_canceling));
            btnCancel.setEnabled(false);
            threadCtl.setDisabled();//disableAsyncTask();
            util.addLogMsg("W", getString(R.string.msgs_aterm_canceling));
            showNotificationMsg(getString(R.string.msgs_aterm_canceling));
        }
    });

    final NotifyEvent at_ne = new NotifyEvent(mContext);
    at_ne.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            util.addLogMsg("I", getString(R.string.msgs_aterm_expired));
            if (mGp.settingAutoTerm || (isExtraSpecAutoStart && extraValueAutoStart)) {
                svcStopForeground(true);
                //Wait until stopForeground() completion 
                Handler hndl = new Handler();
                hndl.post(new Runnable() {
                    @Override
                    public void run() {
                        util.addDebugLogMsg(1, "I", "Auto termination was invoked.");
                        if (!mGp.settingBgTermNotifyMsg.equals(SMBSYNC_BG_TERM_NOTIFY_MSG_NO)) {
                            //                        Log.v("","result code="+result_code+", result_msg="+result_msg);
                            if (mGp.settingBgTermNotifyMsg.equals(SMBSYNC_BG_TERM_NOTIFY_MSG_ALWAYS))
                                NotificationUtil.showNoticeMsg(mContext, mGp, result_msg);
                            else {
                                if (!result_code.equals("OK")) {
                                    NotificationUtil.showNoticeMsg(mContext, mGp, result_msg);
                                } else {
                                    NotificationUtil.clearNotification(mGp);
                                }
                            }
                        } else {
                            NotificationUtil.clearNotification(mGp);
                        }
                        //                     saveTaskData();
                        util.flushLogFile();
                        terminateApplication();
                    }
                });
            }
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            util.addLogMsg("W", getString(R.string.msgs_aterm_cancelled));
            showNotificationMsg(getString(R.string.msgs_aterm_cancelled));
            util.rotateLogFile();
            mGp.mirrorThreadActive = false;
        }
    });

    // Immediate?
    btnImmed.setEnabled(true);
    btnImmed.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mRequestAutoTimerExpired = true;
            threadCtl.setDisabled();//disableAsyncTask();
        }
    });

    //      Log.v("","e="+extraDataSpecifiedAutoTerm);
    util.addLogMsg("I", getString(R.string.msgs_aterm_started));
    if (extraValueAutoTerm) {
        util.addLogMsg("I", getString(R.string.msgs_aterm_back_ground_term));
        at_ne.notifyToListener(true, null);
    } else if (!util.isActivityForeground()) {
        util.addLogMsg("I", getString(R.string.msgs_aterm_back_ground_term));
        at_ne.notifyToListener(true, null);
    } else {
        mRequestAutoTimerExpired = false;
        autoTimer(threadCtl, at_ne, getString(R.string.msgs_aterm_terminate_after));
    }
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private void startMirrorTask(ArrayList<MirrorIoParmList> alp) {
    final LinearLayout ll_spin = (LinearLayout) findViewById(R.id.profile_progress_spin);
    final Button btnCancel = (Button) findViewById(R.id.profile_progress_spin_btn_cancel);
    ll_spin.setVisibility(LinearLayout.VISIBLE);
    ll_spin.setBackgroundColor(Color.BLACK);
    ll_spin.bringToFront();//  ww  w . ja v a2 s .  co m

    btnCancel.setText(getString(R.string.msgs_progress_spin_dlg_sync_cancel));
    btnCancel.setEnabled(true);
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                mSvcClient.aidlCancelThread();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            btnCancel.setText(getString(R.string.msgs_progress_dlg_canceling));
            btnCancel.setEnabled(false);
            mGp.settingAutoTerm = false;
        }
    });

    mGp.msgListView.setFastScrollEnabled(false);

    mGp.mirrorIoParms = alp;

    setUiDisabled();
    mGp.mirrorThreadActive = true;
    try {
        mSvcClient.aidlStartThread();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    setScreenOn();
    acqWifiLock();

}

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

public void dialogBusqueda() {

    AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this);
    dialogBusqueda.setTitle("Busqueda");
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflater.inflate(R.layout.dialog_busqueda, null);
    dialogBusqueda.setView(v);/*from  w ww.  j a v a  2 s . com*/

    Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda);
    final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar);
    final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            R.layout.support_simple_spinner_dropdown_item, searchArray);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            SpiBusqueda = position;

            if (position != 3) {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.GONE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.VISIBLE);
            } else {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.VISIBLE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show();
        }
    });

    final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar);
    final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle);
    final EditText eNumber = (EditText) v.findViewById(R.id.txtNum);

    dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            if (SpiBusqueda == 3) {
                txtBusqueda = new String();
                if (!eStreet.getText().toString().isEmpty())
                    txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 "
                            : eNumber.getText().toString().trim() + " ";
                txtBusqueda = txtBusqueda + eStreet.getText().toString();
            } else {
                txtBusqueda = eSearch.getText().toString();
            }

            if (txtBusqueda.trim().isEmpty()) {
                Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show();
            } else {
                // Escala de calle para busquedas por default
                // TODO Asignar a res values o strings
                iBusqScale = 4000;
                switch (SpiBusqueda) {
                case 0:
                    callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"),
                            LyCLIENTES.getUrl().concat("/0"));
                    if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0)
                        iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 1:
                    callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1"));
                    if (LySED.getLayers() != null && LySED.getLayers().length > 1)
                        iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale();
                    break;
                case 2:
                    callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0"));
                    if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0)
                        iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 3:
                    iBusqScale = 5000;
                    String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() };
                    String[] sFields = { "nombre_calle", "numero" };
                    callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0"));
                    break;
                }
            }
        }
    });

    dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    dialogBusqueda.show();
}

From source file:com.hybris.mobile.app.commerce.view.CartViewUtils.java

/**
 * Populate the cart summary//w ww .ja va 2 s .  c  om
 *
 * @param cart
 */
public static void createCartSummary(View view, Cart cart, boolean enableItems) {

    // Cart summary
    LinearLayout mCartSummaryItemsLayout;
    TextView mCartSummaryItems;
    TextView mCartSummarySubtotal;
    TextView mCartSummarySavings;
    TextView mCartSummaryTax;
    TextView mCartSummaryShipping;
    TextView mCartSummaryTotal;
    TextView mCartSummaryPromotion;
    TableRow mCartSummarySavingsRow;
    TableRow mCartSummaryTaxRow;
    TextView mCartSummaryNoTax;
    TableRow mCartSummaryShippingRow;
    TextView mCartSummaryEmpty;
    LinearLayout mCartSummaryDetailsLayout;

    // cart summary
    mCartSummaryItemsLayout = (LinearLayout) view.findViewById(R.id.cart_summary_items_layout);
    mCartSummaryItems = (TextView) view.findViewById(R.id.cart_summary_items);
    mCartSummarySubtotal = (TextView) view.findViewById(R.id.cart_summary_subtotal);
    mCartSummarySavings = (TextView) view.findViewById(R.id.cart_summary_savings);
    mCartSummaryTax = (TextView) view.findViewById(R.id.cart_summary_tax);
    mCartSummaryShipping = (TextView) view.findViewById(R.id.cart_summary_shipping);
    mCartSummaryTotal = (TextView) view.findViewById(R.id.cart_summary_total);
    mCartSummaryPromotion = (TextView) view.findViewById(R.id.cart_summary_promotion);
    mCartSummarySavingsRow = (TableRow) view.findViewById(R.id.cart_summary_savings_row);
    mCartSummaryTaxRow = (TableRow) view.findViewById(R.id.cart_summary_tax_row);
    mCartSummaryNoTax = (TextView) view.findViewById(R.id.cart_summary_no_taxes);
    mCartSummaryShippingRow = (TableRow) view.findViewById(R.id.cart_summary_shipping_row);
    mCartSummaryEmpty = (TextView) view.findViewById(R.id.cart_summary_empty);
    mCartSummaryDetailsLayout = (LinearLayout) view.findViewById(R.id.cart_summary_details_layout);

    if (cart != null) {
        if (cart.getEntries() != null && !cart.getEntries().isEmpty()) {
            // Display total price
            if (cart.getTotalPrice() != null) {
                mCartSummaryTotal.setText(cart.getTotalPrice().getFormattedValue());
            }

            // Display subtotal price
            if (cart.getSubTotal() != null) {
                mCartSummarySubtotal.setText(cart.getSubTotal().getFormattedValue());
            }

            // Display tax price
            if (cart.getTotalTax() != null && cart.getTotalTax().getValue().intValue() > 0) {
                mCartSummaryTax.setText(cart.getTotalTax().getFormattedValue());
                mCartSummaryTaxRow.setVisibility(View.VISIBLE);
                mCartSummaryNoTax.setVisibility(View.GONE);
            } else {
                mCartSummaryTaxRow.setVisibility(View.GONE);
                mCartSummaryNoTax.setVisibility(View.VISIBLE);
            }

            // Display delivery method cost
            if (cart.getDeliveryCost() != null) {
                mCartSummaryShipping.setText(cart.getDeliveryCost().getFormattedValue());
                mCartSummaryShippingRow.setVisibility(View.VISIBLE);
            } else {
                mCartSummaryShippingRow.setVisibility(View.GONE);
            }

            if (cart.getAppliedOrderPromotions() != null && !cart.getAppliedOrderPromotions().isEmpty()) {
                if (StringUtils.isNotBlank(cart.getOrderDiscounts().getFormattedValue())) {
                    mCartSummarySavingsRow.setVisibility(View.VISIBLE);
                    mCartSummarySavings.setText(cart.getOrderDiscounts().getFormattedValue());
                }
            }

            if (cart.getTotalDiscounts() != null && cart.getTotalDiscounts().getValue().doubleValue() > 0) {
                if (cart.getAppliedOrderPromotions() != null && !cart.getAppliedOrderPromotions().isEmpty()) {
                    mCartSummaryPromotion.setVisibility(View.VISIBLE);
                    // Nb order Promotion
                    StringBuffer promotion = new StringBuffer();
                    for (PromotionResult orderPromotion : cart.getAppliedOrderPromotions()) {
                        promotion.append(orderPromotion.getDescription()).append("\n");
                    }
                    mCartSummaryPromotion.setText(promotion);
                } else {
                    mCartSummaryPromotion.setVisibility(View.GONE);
                }
            } else {
                mCartSummaryPromotion.setVisibility(View.GONE);
                mCartSummarySavingsRow.setVisibility(View.GONE);
            }

            // Nb items
            mCartSummaryItemsLayout.setVisibility(enableItems ? View.VISIBLE : View.GONE);
            mCartSummaryItems.setText(CommerceApplication.getContext().getString(R.string.cart_summary_items,
                    cart.getTotalUnitCount()));

            //Cart is used
            mCartSummaryEmpty.setVisibility(View.GONE);
            mCartSummaryDetailsLayout.setVisibility(View.VISIBLE);
        } else {
            //Cart Empty show messages & Cart Empty remove all summary views
            mCartSummaryEmpty.setVisibility(View.VISIBLE);
            mCartSummaryDetailsLayout.setVisibility(View.GONE);
            mCartSummaryPromotion.setVisibility(View.GONE);

        }
    }
}

From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register_driver);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  w w w.  ja v a 2s .c  o  m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    context = this;
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    appBarLayout.setExpanded(false, true);
    mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver);
    mainScrollView.setSmoothScrollingEnabled(true);
    selectorsLayouts = new ArrayList<>();

    editDriver = new Driver();
    preferredPlace = new PrologixPlace();
    if (currentDriver == null) {
        getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver));
        if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) {
            editDriver = tempDriver;
            if (editDriver == null)
                editDriver = new Driver();
        }
        vehiclesList = new ArrayList<>();
    } else {
        getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver));
        editDriver = currentDriver.clone();
        if (editDriver.getPreferredAddress() != null) {
            preferredPlace.setAddress(
                    driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class));
            preferredPlace.setLocation(
                    driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class));
        }
    }

    storagePermission = new PermissionManager(this);
    if (!storagePermission.checkReadStoragePermission())
        storagePermission.getReadStoragePermission();
    registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver);

    vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator);
    if (editDriver.getVehicles() == null)
        editDriver.setVehicles(new ArrayList<Vehicle>());
    vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false);
    if (!editDriver.getVehicles().isEmpty())
        setIndicator(context, vehicleIndicator, true);
    if (!editDriver.getVehicles().contains(createVehicle)) {
        editDriver.getVehicles().add(new Vehicle());
        //TODO remove this.. just for testing only
        /*String vehicleId = "SA-3184VLB";
        DriverTask driverTask = new DriverTask(vehicleFetcher, "en");
        driverTask.getVehicle.execute(vehicleId);*/
    }
    vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view);
    vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    vehicleListView.setHasFixedSize(true);
    vehicleListView.setAdapter(vehicleRecyclerAdapter);
    vehicleListView.setNestedScrollingEnabled(false);

    licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator);
    licenseValueNumber = (TextView) findViewById(R.id.license_info_number);
    licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry);
    licenseImage = (ImageView) findViewById(R.id.license_image);
    licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded);
    licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout);
    if (editDriver.getLicenseNumber() != null) {
        setIndicator(context, licenseIndicator, true);
        licenseValueNumber.setText(editDriver.getLicenseNumber());
        licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry()));
        if (editDriver.getLicenseImage() != null)
            licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(),
                    DataHolder.getInstance().getImageLoader());
    }
    if (photo1 != null)
        licenseImage.setImageBitmap(photo1);
    licenseInfoLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent scanIdIntent = new Intent(context, CameraVisionActivity.class);
            scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE);
            startActivity(scanIdIntent);
        }
    });

    residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator);
    residenceValueNumber = (TextView) findViewById(R.id.residence_info_number);
    residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry);
    residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name);
    residenceImage = (ImageView) findViewById(R.id.residence_image);
    residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded);
    residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout);
    if (editDriver.getResidenceNumber() != null) {
        setIndicator(context, residenceIndicator, true);
        residenceValueNumber.setText(editDriver.getResidenceNumber());
        residenceValueLegalName.setText(editDriver.getLegalName());
        if (editDriver.getResidenceImage() != null)
            residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(),
                    DataHolder.getInstance().getImageLoader());
    }
    if (photo2 != null)
        residenceImage.setImageBitmap(photo2);
    residenceInfoLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent scanIdIntent = new Intent(context, CameraVisionActivity.class);
            scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID);
            startActivity(scanIdIntent);
        }
    });

    nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator);
    nationalityValue = (TextView) findViewById(R.id.nationality_value);
    nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout);
    nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout);
    final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector);
    selectorsLayouts.add(nationalitySelector);
    nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content);
    countryTask = new CountryTask(countryListHandler, "en");
    countryTask.getCountryList.execute("en");
    if (editDriver.getNationality() != null) {
        setIndicator(context, nationalityIndicator, true);
        nationalityValue.setText(editDriver.getNationality().getCountryName());
    }
    nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto);
    nationalityLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboard(context);
            if (nationalitySelector.getVisibility() == View.GONE) {
                closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector);
                mainScrollView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mainScrollView.smoothScrollTo(0, nationalityLayout.getTop());
                        nationalityAuto.showDropDown();
                    }
                }, 1000);
            }
            if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) {
                nationalityProgressLayout.setVisibility(View.VISIBLE);
                nationalitySelectorContent.setVisibility(View.GONE);
            }
            LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button);
            okayButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (editDriver.getNationality() != null) {
                        setIndicator(context, nationalityIndicator, true);
                        nationalityValue.setText(editDriver.getNationality().getCountryName());
                        addressLayout.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                addressLayout.performClick();
                            }
                        }, 1000);
                    } else {
                        setIndicator(context, nationalityIndicator, false);
                        nationalitySelector.setVisibility(View.GONE);
                    }
                }
            });
            LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button);
            cancelButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    nationalitySelector.setVisibility(View.GONE);
                }
            });
        }
    });

    addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator);
    addressValue = (TextView) findViewById(R.id.preferred_address_value);
    addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout);
    if (editDriver.getPreferredAddress() != null) {
        setIndicator(context, addressIndicator, true);
        preferredPlace.setAddress(transform(editDriver.getPreferredAddress()));
        preferredPlace.setLocation(transform(editDriver.getPreferredLocation()));
        addressValue.setText(preferredPlace.getAddress().getFullAddress());
    }
    addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser);
    selectorsLayouts.add(addressChooser);
    addressLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboard(context);
            try {
                if (addressChooser.getVisibility() == View.GONE) {
                    closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser);
                    getSupportFragmentManager().beginTransaction()
                            .replace(R.id.preferred_address_chooser,
                                    PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler))
                            .commit();
                    mainScrollView.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mainScrollView.smoothScrollTo(0, addressLayout.getTop());
                        }
                    }, 1500);
                } else {
                    addressChooser.setVisibility(View.GONE);
                    getSupportFragmentManager().popBackStack();
                }
            } catch (Resources.NotFoundException | OutOfMemoryError ignored) {
            }
        }
    });

    final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator);
    final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value);
    if (editDriver.getPhoneNumber() != null) {
        setIndicator(context, phoneIndicator, true);
        phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), ""));
    }
    final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector);
    selectorsLayouts.add(phoneSelector);
    phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout);
    phoneLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboard(context);
            if (phoneSelector.getVisibility() == View.GONE) {
                closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector);
                mainScrollView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mainScrollView.smoothScrollTo(0, phoneLayout.getTop());
                    }
                }, 1000);
            }
            final EditText input = (EditText) findViewById(R.id.phone_number);
            if (editDriver.getPhoneNumber() != null)
                input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), ""));
            TextView phoneCode = (TextView) findViewById(R.id.country_code);
            phoneCode.setText(currentCountry.getPhoneCode());
            NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag);
            countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader());
            LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button);
            okayButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!input.getText().toString().isEmpty()) {
                        String phoneNumberEdit = currentCountry.getPhoneCode()
                                + input.getText().toString().replaceAll(" ", "");
                        editDriver.setPhoneNumber(phoneNumberEdit);
                        phoneValue.setText(phoneNumberEdit);
                        setIndicator(context, phoneIndicator, true);
                        mainScrollView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                mainScrollView.smoothScrollTo(0, dobLayout.getTop());
                            }
                        }, 1000);
                    } else {
                        phoneValue.setText(getString(R.string.driver_phone_hint));
                        setIndicator(context, phoneIndicator, false);
                    }
                    phoneSelector.setVisibility(View.GONE);
                }
            });
            LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button);
            cancelButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    phoneSelector.setVisibility(View.GONE);
                }
            });
        }
    });

    dobValue = (TextView) findViewById(R.id.driver_dob_value);
    if (editDriver.getDob() != null)
        dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob()));
    dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout);
    dobLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Calendar calendar = Calendar.getInstance();
            if (editDriver.getDob() != null) {
                dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob()));
                calendar.setTimeInMillis(editDriver.getDob());
            }
            DatePickerDialog datePickerDialog = DatePickerDialog
                    .newInstance(new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePickerDialog view, int year, int monthOfYear,
                                int dayOfMonth) {
                            calendar.set(Calendar.YEAR, year);
                            calendar.set(Calendar.MONTH, monthOfYear);
                            calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                            editDriver.setDob(calendar.getTimeInMillis());
                            dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob()));
                        }
                    }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                            calendar.get(Calendar.DAY_OF_MONTH));
            datePickerDialog.show(getFragmentManager(), "Datepickerdialog");
        }
    });

    final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value);
    if (editDriver.getGender() != null)
        genderValue.setText(
                editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option));
    final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector);
    selectorsLayouts.add(genderSelector);
    final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout);
    genderLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboard(context);
            if (genderSelector.getVisibility() == View.GONE) {
                closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector);
                mainScrollView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mainScrollView.smoothScrollTo(0, genderLayout.getTop());
                    }
                }, 1000);
            } else
                genderSelector.setVisibility(View.GONE);
            final int checkedPos = editDriver.getGender() == null ? -1
                    : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female);
            final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group);
            if (checkedPos != -1)
                insuranceRadioGroup.check(checkedPos);
            LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button);
            okayButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    switch (insuranceRadioGroup.getCheckedRadioButtonId()) {
                    case R.id.driver_gender_male:
                        editDriver.setGender(true);
                        genderValue.setText(getString(R.string.male_option));
                        break;
                    case R.id.driver_gender_female:
                        editDriver.setGender(false);
                        genderValue.setText(getString(R.string.female_option));
                        break;
                    default:
                        break;
                    }
                    mainScrollView.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mainScrollView.smoothScrollTo(0, 0);
                        }
                    }, 500);
                    appBarLayout.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            appBarLayout.setExpanded(true, true);
                        }
                    }, 1500);
                }
            });
            LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button);
            cancelButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    genderSelector.setVisibility(View.GONE);
                }
            });
        }
    });

    //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie

    uploadCount = new AtomicInteger(0);
    saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id);
    saveDriverAction.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean error = false;
            hideKeyboard(context);
            if (editDriver.getVehicles().size() == 1) {
                setIndicator(context, vehicleIndicator, false);
                error = true;
            }
            if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null
                    || editDriver.getLicenseNumber() == null) {
                setIndicator(context, licenseIndicator, false);
                error = true;
            }
            if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) {
                setIndicator(context, residenceIndicator, false);
                error = true;
            }
            if (editDriver.getNationality() == null) {
                setIndicator(context, nationalityIndicator, false);
                error = true;
            }
            if (editDriver.getPreferredAddress() == null) {
                setIndicator(context, addressIndicator, false);
                error = true;
            }
            if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) {
                setIndicator(context, phoneIndicator, false);
                error = true;
            }
            if (user == null && !registerEmailHeaderFragment.setCustomerValues())
                error = true;
            if (error)
                Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG)
                        .show();
            else if (user != null) {
                signUpAnalytics(user.getProviderId());
                editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1);
                uploadImage("driver_license_snapshot",
                        "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_"
                                + editDriver.getLicenseNumber() + ".jpg",
                        ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE);
                uploadImage("driver_residence_snapshot",
                        "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_"
                                + editDriver.getResidenceNumber() + ".jpg",
                        ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID);
                crossFade(context, findViewById(R.id.driver_progress_layout),
                        findViewById(R.id.driver_main_layout), null);
                //TODO verify registration details for duplicate, correctness, etc
            }
        }
    });

    imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status);
    imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() {
        @Override
        public View makeView() {
            TextView switcherTextView = new TextView(getApplicationContext());
            switcherTextView.setTextSize(16);
            switcherTextView.setTypeface(null, Typeface.BOLD);
            switcherTextView.setText(getString(R.string.uploading_images));
            switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent));
            return switcherTextView;
        }
    });
    Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);
    Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    imageUploadStatus.setOutAnimation(animationOut);
    imageUploadStatus.setInAnimation(animationIn);
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * THIS FUNCTION CONTAINS ALL THE ACTION THAT HAS TO BE PERFORMED WHEN
 * SEARCH IS IN PROGRESS/*from   w w  w.  ja  v  a 2  s . c o  m*/
 */
public void search() {
    searchList = new ArrayList<File>();
    try {
        LinearLayout a = (LinearLayout) findViewById(R.id.applyBtn);
        a.setVisibility(View.GONE);
        //Search Flipper is loaded
        mVFlipper.setAnimation(nextAnim());
        mVFlipper.showNext();
        mVFlipper.showNext();
        SEARCH_FLAG = true;
        // PREVIOUS COMMANDS ARE OVERWRITTEN
        COPY_COMMAND = CUT_COMMAND = RENAME_COMMAND = CREATE_FILE = false;
        editBox.setTextColor(Color.WHITE);
        editBox.setText(null);
        editBox.setHint("Enter Name To Filter Out");
        editBox.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
                searchList.clear();
                // TODO Auto-generated method stub
            }

            @Override
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
                searchList.clear();
                // TODO Auto-generated method stub
            }

            @Override
            public void afterTextChanged(Editable text) {
                // TODO Auto-generated method stub
                searchList.clear();
                File f = new File(PATH);
                if (CURRENT_ITEM == 2)
                    f = new File(RFileManager.getCurrentDirectory());
                else if (CURRENT_ITEM == 1)
                    f = new File(SFileManager.getCurrentDirectory());
                final File[] list = f.listFiles();
                final String search = text.toString();
                final String[] fList = f.list();
                new AsyncTask<String[], Void, Void>() {
                    @Override
                    protected void onPostExecute(Void result) {
                        if (SEARCH_FLAG) {
                            if (CURRENT_ITEM == 2) {
                                root.setAdapter(
                                        new RootAdapter(getBaseContext(), R.layout.row_list_1, searchList));
                            } else if (CURRENT_ITEM == 1) {
                                simple.setAdapter(
                                        new SimpleAdapter(getBaseContext(), R.layout.row_list_1, searchList));
                            } else
                                LIST_VIEW_3D.setAdapter(new MediaElementAdapter(getBaseContext(),
                                        R.layout.row_list_1, searchList));
                        }
                    }

                    protected void onPreExecute() {
                        if (SEARCH_FLAG) {
                            if (CURRENT_ITEM == 2)
                                root.setAdapter(null);
                            else if (CURRENT_ITEM == 1)
                                simple.setAdapter(null);
                            else
                                LIST_VIEW_3D.setAdapter(null);
                        }
                        super.onPreExecute();
                    }

                    @Override
                    protected Void doInBackground(String[]... arg0) {
                        if (SEARCH_FLAG) {
                            // SEARCH IS PERFORMED FOR CURRENT ITEM 0
                            if (CURRENT_ITEM == 0) {
                                int len = mediaFileList.size();
                                for (int i = 0; i < len; ++i) {
                                    File file = mediaFileList.get(i);
                                    if (file.canRead())
                                        if (file.getName().toLowerCase().contains(search))
                                            searchList.add(file);
                                }
                            }
                            // SEARCH IS PERFORMED FOR CURRENT ITEM = 1,2
                            else
                                for (int i = 0; i < fList.length; ++i) {
                                    if (CURRENT_ITEM == 2) {
                                        if (list[i].canRead()) {
                                            if ((fList[i].toLowerCase()).contains(search.toLowerCase()))
                                                searchList.add(list[i]);
                                        }
                                    } else if (CURRENT_ITEM == 1) {
                                        if ((fList[i].toLowerCase()).contains(search.toLowerCase()))
                                            searchList.add(list[i]);
                                    }
                                }
                        }
                        return null;
                    }
                }.execute();
            }
        });
    } catch (IllegalStateException e) {

    } catch (RuntimeException e) {

    } catch (Exception e) {

    }
}

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

public void dialogBusqueda() {

    AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this);
    dialogBusqueda.setTitle("Busqueda");
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflater.inflate(R.layout.dialog_busqueda, null);
    dialogBusqueda.setView(v);/*from   www . j a va  2 s . c  o  m*/

    Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda);
    final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar);
    final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            R.layout.support_simple_spinner_dropdown_item, searchArray);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            SpiBusqueda = position;

            if (position != 4) {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.GONE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.VISIBLE);
            } else {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.VISIBLE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show();
        }
    });

    final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar);
    final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle);
    final EditText eNumber = (EditText) v.findViewById(R.id.txtNum);

    dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            if (SpiBusqueda == 4) {
                txtBusqueda = new String();
                if (!eStreet.getText().toString().isEmpty())
                    txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 "
                            : eNumber.getText().toString().trim() + " ";
                txtBusqueda = txtBusqueda + eStreet.getText().toString();
            } else {
                if (SpiBusqueda > 1)
                    txtBusqueda = eSearch.getText().toString();
                else
                    txtBusqueda = Util.extraerNum(eSearch.getText().toString());
            }

            if (txtBusqueda.trim().isEmpty()) {
                Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show();
            } else {
                // Escala de calle para busquedas por default

                iBusqScale = 4000;
                switch (SpiBusqueda) {
                case 0:
                    callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"),
                            LyCLIENTES.getUrl().concat("/0"));
                    if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0)
                        iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 1:
                    callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1"));
                    if (LySED.getLayers() != null && LySED.getLayers().length > 1)
                        iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale();
                    break;
                case 2:
                    callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0"));
                    if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0)
                        iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 3:
                    callQuery(txtBusqueda, "serie_medidor", LyMEDIDORES.getUrl().concat("/1"));
                    if (LyMEDIDORES.getLayers() != null && LyMEDIDORES.getLayers().length > 1)
                        iBusqScale = LyMEDIDORES.getLayers()[1].getLayerServiceInfo().getMinScale();
                    break;
                case 4:
                    iBusqScale = 5000;
                    String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() };
                    String[] sFields = { "nombre_calle", "numero" };
                    callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0"));
                    break;
                case 5:
                    callQuery(txtBusqueda, new String[] { "id_equipo", "nombre" },
                            LyEQUIPOSLINEA.getUrl().concat("/0"));
                    if (LyEQUIPOSLINEA.getLayers() != null && LyEQUIPOSLINEA.getLayers().length > 0)
                        iBusqScale = LyEQUIPOSLINEA.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                }
            }
        }
    });

    dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    dialogBusqueda.show();
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * THIS FUNCTION SHOWS THE BOX GINIG THE OPTIONS TO ADD NEW FOLDER AND CLOUD STUFFS
 * @param v//w w w .ja  va 2  s  .c  o m
 */
private void NEW_OPTIONS(View v) {
    // TODO Auto-generated method stub
    final QuickAction action = new QuickAction(getBaseContext(), 1);
    ActionItem hiddenItem = new ActionItem(-10000, "Dropbox",
            getResources().getDrawable(R.drawable.ic_launcher_drop_box));
    action.addActionItem(hiddenItem);
    hiddenItem = new ActionItem(-9000, "Google Drive",
            getResources().getDrawable(R.drawable.ic_launcher_google_drive));
    action.addActionItem(hiddenItem);

    hiddenItem = new ActionItem(-7000, "SkyDrive",
            getResources().getDrawable(R.drawable.ic_launcher_sky_drive));
    action.addActionItem(hiddenItem);

    hiddenItem = new ActionItem(-5000, "SugarSync",
            getResources().getDrawable(R.drawable.ic_launcher_sugar_sync));
    action.addActionItem(hiddenItem);

    hiddenItem = new ActionItem(500, "Create Hidden Folder",
            getResources().getDrawable(R.drawable.ic_launcher_add_new));
    action.addActionItem(hiddenItem);
    ActionItem folderItem = new ActionItem(600, "Create A Folder",
            getResources().getDrawable(R.drawable.ic_launcher_add_new));
    action.addActionItem(folderItem);
    ActionItem fileItem = new ActionItem(700, "Create An Empty File",
            getResources().getDrawable(R.drawable.ic_launcher_new_file));
    action.addActionItem(fileItem);
    action.show(v);
    action.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
        @Override
        public void onItemClick(QuickAction source, int pos, int actionId) {
            // TODO Auto-generated method stub
            if (actionId >= 500) {
                CREATE_FLAG_PATH = null;
                if (CURRENT_ITEM == 1)
                    CREATE_FLAG_PATH = SFileManager.getCurrentDirectory();
                else if (CURRENT_ITEM == 2)
                    CREATE_FLAG_PATH = RFileManager.getCurrentDirectory();
                CREATE_FILE = true;
                editBox.setText(null);
                switch (actionId) {
                case 500:

                    editBox.setHint("Enter Folder Name");
                    CREATE_FLAG = 1;
                    LinearLayout l = (LinearLayout) findViewById(R.id.applyBtn);
                    l.setVisibility(View.VISIBLE);
                    editBox.setTextColor(Color.WHITE);
                    // if file is to created then edittext for extension of
                    // file is also displayed
                    //then mViewFlipper is rotated to editText for getting text 
                    mVFlipper.setAnimation(nextAnim());
                    mVFlipper.showNext();
                    mVFlipper.showNext();
                    break;
                case 600:

                    editBox.setHint("Enter Folder Name");
                    CREATE_FLAG = 2;
                    LinearLayout l2 = (LinearLayout) findViewById(R.id.applyBtn);
                    l2.setVisibility(View.VISIBLE);
                    editBox.setTextColor(Color.WHITE);
                    // if file is to created then edittext for extension of
                    // file is also displayed
                    //then mViewFlipper is rotated to editText for getting text 
                    mVFlipper.setAnimation(nextAnim());
                    mVFlipper.showNext();
                    mVFlipper.showNext();
                    break;
                case 700:
                    editBox.setHint("Enter File Name");
                    CREATE_FLAG = 3;
                    LinearLayout l3 = (LinearLayout) findViewById(R.id.applyBtn);
                    l3.setVisibility(View.VISIBLE);
                    editBox.setTextColor(Color.WHITE);
                    // if file is to created then edittext for extension of
                    // file is also displayed
                    //then mViewFlipper is rotated to editText for getting text 
                    mVFlipper.setAnimation(nextAnim());
                    mVFlipper.showNext();
                    mVFlipper.showNext();
                }

            } else {
                /**
                 * CLOUD STORAGE OPTIONS
                 */
                switch (actionId) {
                case -10000:
                    /*
                    * DROPBOX INFO STUFF
                    * 
                    */
                    Toast.makeText(mContext, "Fix This", Toast.LENGTH_SHORT).show();
                    break;

                case -80001:
                    //BOX

                default:
                    new ErrorDialogs(mContext, size.x * 4 / 5, "cloud");
                }
            }
        }

    });
}