Example usage for android.widget ScrollView findViewById

List of usage examples for android.widget ScrollView findViewById

Introduction

In this page you can find the example usage for android.widget ScrollView findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.flan.stock.fragment.FragmentStockFenShi.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ScrollView view = (ScrollView) inflater.inflate(R.layout.fragment_stock_fenshi, null);

    //?/TabView??
    stockWdmxTabView = (StockWdMxTabView) view.findViewById(R.id.tab_wdmx);
    stockWdmxTabView.setOnClickListener(stockWdmxTabView);
    //?TabView??//from  w w w  .  ja  v  a  2s . co m
    stockTextTabView = (StockTextDataTabView) view.findViewById(R.id.tab_stocktext);
    stockTextTabView.setOnClickListener(stockTextTabView);
    stockTextTabView.setParentScrollView(view);

    //?
    stockFSView = (StockFSView) view.findViewById(R.id.stock_sf);

    return view;
}

From source file:com.fastbootmobile.encore.app.fragments.LyricsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ScrollView root = (ScrollView) inflater.inflate(R.layout.fragment_lyrics, container, false);
    mTvLyrics = (TextView) root.findViewById(R.id.tvLyrics);
    mPbLoading = (ProgressBar) root.findViewById(R.id.pbLoading);

    updateLyrics();/* w  w w.  j  ava 2  s  . co  m*/

    return root;
}

From source file:fr.bmartel.android.iotf.app.ConnectActivity.java

protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    setContentView(R.layout.activity_connect);

    final Intent intent = getIntent();

    String defaultOrgId = "";
    String defaultApiKey = "";
    String defaultApiToken = "";

    if (BuildConfig.BLUEMIX_IOT_ORG != null)
        defaultOrgId = BuildConfig.BLUEMIX_IOT_ORG;
    if (BuildConfig.BLUEMIX_API_KEY != null)
        defaultApiKey = BuildConfig.BLUEMIX_API_KEY;
    if (BuildConfig.BLUEMIX_API_TOKEN != null)
        defaultApiToken = BuildConfig.BLUEMIX_API_TOKEN;

    String organizationId = sharedpreferences.getString(StorageConst.STORAGE_ORGANIZATION_ID, defaultOrgId);
    String apiKey = sharedpreferences.getString(StorageConst.STORAGE_API_KEY, defaultApiKey);
    String apiToken = sharedpreferences.getString(StorageConst.STORAGE_API_TOKEN, defaultApiToken);
    boolean ssl = sharedpreferences.getBoolean(StorageConst.STORAGE_USE_SSL, true);

    boolean fromJsonFile = false;

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {

        String jsonContent = loadFile(intent);

        try {//w w w. j a v  a  2s .  c  o m
            JSONObject json = new JSONObject(jsonContent);

            if (json.has(StorageConst.STORAGE_API_KEY) && json.has(StorageConst.STORAGE_API_TOKEN)
                    && json.has(StorageConst.STORAGE_ORGANIZATION_ID)
                    && json.has(StorageConst.STORAGE_USE_SSL)) {

                organizationId = json.getString(StorageConst.STORAGE_ORGANIZATION_ID);
                apiKey = json.getString(StorageConst.STORAGE_API_KEY);
                apiToken = json.getString(StorageConst.STORAGE_API_TOKEN);
                ssl = json.getBoolean(StorageConst.STORAGE_USE_SSL);

                SharedPreferences.Editor editor = sharedpreferences.edit();
                editor.putString(StorageConst.STORAGE_ORGANIZATION_ID, organizationId);
                editor.putString(StorageConst.STORAGE_API_KEY, apiKey);
                editor.putString(StorageConst.STORAGE_API_TOKEN, apiToken);
                editor.putBoolean(StorageConst.STORAGE_USE_SSL, ssl);
                editor.commit();

                fromJsonFile = true;

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

    ScrollView scrollView = (ScrollView) findViewById(R.id.scrollview);

    mOrganizationEditText = (EditText) scrollView.findViewById(R.id.organization);
    mApikeyEditText = (EditText) scrollView.findViewById(R.id.api_key);
    mApitokenEditText = (EditText) scrollView.findViewById(R.id.api_token);
    mOrganizationEditText.setText(organizationId);
    mApikeyEditText.setText(apiKey);
    mApitokenEditText.setText(apiToken);
    mSslCheckbox = (CheckBox) scrollView.findViewById(R.id.ssl);
    mSslCheckbox.setChecked(ssl);
    mReconnectCheckbox = (CheckBox) scrollView.findViewById(R.id.reconnect);
    mReconnectCheckbox.setChecked(true);

    if (fromJsonFile) {
        connect();
    }

    initNv();
}

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

@Override
@SuppressWarnings("unchecked")
public void onPriceClicked(String pair, double price) {
    try {//  w  ww . ja  va2  s.c  om
        ScrollView scrollView = (ScrollView) getView();
        if (scrollView != null) {
            scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom());
            String[] currencies = pair.split("/");
            EditText tradePrice = (EditText) scrollView.findViewById(R.id.TradePrice);
            tradePrice.setText(String.valueOf(price));
            Spinner tradeCurrency = (Spinner) scrollView.findViewById(R.id.TradeCurrency);
            Spinner tradePriceCurrency = (Spinner) scrollView.findViewById(R.id.TradePriceCurrency);
            tradeCurrency.setSelection(
                    ((ArrayAdapter<String>) tradeCurrency.getAdapter()).getPosition(currencies[0]));
            tradePriceCurrency.setSelection(
                    ((ArrayAdapter<String>) tradePriceCurrency.getAdapter()).getPosition(currencies[1]));
        }
    } catch (ClassCastException | NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

/**
 * Refreshes funds table with fetched data
 *
 * @param response JSONObject with funds data
 *//*from   w  ww .  j  ava 2 s  . c  o m*/
private void refreshFunds(JSONObject response) {
    try {
        if (response == null) {
            Toast.makeText(getActivity(), getResources().getString(R.string.GeneralErrorText),
                    Toast.LENGTH_LONG).show();
            return;
        }
        String notificationText;
        if (response.getInt("success") == 1) {

            View.OnClickListener fillAmount = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ScrollView scrollView = (ScrollView) getView();
                    if (scrollView != null) {
                        EditText tradeAmount = (EditText) scrollView.findViewById(R.id.TradeAmount);
                        tradeAmount.setText(((TextView) v).getText());
                        scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom());
                    }
                }
            };

            notificationText = getResources().getString(R.string.FundsInfoUpdatedtext);
            TableLayout fundsContainer = (TableLayout) getView().findViewById(R.id.FundsContainer);
            fundsContainer.removeAllViews();
            JSONObject funds = response.getJSONObject("return").getJSONObject("funds");
            JSONArray fundsNames = response.getJSONObject("return").getJSONObject("funds").names();
            List<String> arrayList = new ArrayList<>();

            for (int i = 0; i < fundsNames.length(); i++) {
                arrayList.add(fundsNames.getString(i));
            }
            Collections.sort(arrayList);
            TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0,
                    ViewGroup.LayoutParams.MATCH_PARENT, 1);

            for (String anArrayList : arrayList) {

                TableRow row = new TableRow(getActivity());
                TextView currency = new TextView(getActivity());
                TextView amount = new TextView(getActivity());
                currency.setText(anArrayList.toUpperCase(Locale.US));
                amount.setText(funds.getString(anArrayList));
                currency.setLayoutParams(layoutParams);
                currency.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
                currency.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
                currency.setGravity(Gravity.CENTER);
                amount.setLayoutParams(layoutParams);
                amount.setGravity(Gravity.CENTER);
                amount.setOnClickListener(fillAmount);
                row.addView(currency);
                row.addView(amount);
                fundsContainer.addView(row);
            }

        } else {
            notificationText = response.getString("error");
        }

        mCallback.makeNotification(ConstantHolder.ACCOUNT_INFO_NOTIF_ID, notificationText);

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

From source file:org.ambient.control.config.EditConfigFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // integrate object into existing configuration after child fragment has data left for us via onIntegrate. We do the
    // integration here after the arguments and bundles have been restored. We cannot merge the values in onCreate() because
    // it will only be called from android when the fragment instance has been removed before. e.g. screen rotation.
    if (this.valueToIntegrate != null) {
        this.integrateConfiguration(this.valueToIntegrate);
    }/*from w  w  w  .  j a v  a  2 s.c  om*/

    try {

        ScrollView result = (ScrollView) inflater.inflate(R.layout.fragment_edit_config, container, false);

        LinearLayout content = (LinearLayout) result.findViewById(R.id.linearLayoutEditConfigContent);

        // init the maps for grouped and sorted fields
        Map<Integer, Map<Integer, Field>> sortedMap = new TreeMap<Integer, Map<Integer, Field>>();
        // and a simple list for those fields which have no sort description
        List<Field> unsortedList = new ArrayList<Field>();

        // create groups if class description is present and defines some
        ClassDescription description = beanToEdit.getClass().getAnnotation(ClassDescription.class);
        if (description != null) {
            for (Group currentGroup : description.groups()) {
                Map<Integer, Field> category = new TreeMap<Integer, Field>();
                sortedMap.put(currentGroup.position(), category);
            }
        } else {
            // create a default group
            sortedMap.put(0, new TreeMap<Integer, Field>());
        }

        // sort fields that are annotated in groups
        for (final Field field : beanToEdit.getClass().getFields()) {
            // only use field with typedef annotation. the rest of the
            // fields will be ignored
            if (field.isAnnotationPresent(TypeDef.class)) {
                if (field.isAnnotationPresent(Presentation.class)) {
                    // put into groups
                    Presentation presentation = field.getAnnotation(Presentation.class);
                    sortedMap.get(presentation.groupPosition()).put(presentation.position(), field);
                } else {
                    // or to unsorted group if no information for sorting is
                    // present
                    unsortedList.add(field);
                }
            }
        }

        // if no sorted values haven been drawn we create a default group on
        // screen and put all unsorted values in there. if some have been
        // drawn we put them into a "misc" group. we could do a check at the
        // beginning if several groups have been filled and so on. but we
        // render them first and get the information as result of that.
        boolean sortedValuesDrawn = false;

        for (Integer currentCategoryId : sortedMap.keySet()) {
            if (sortedMap.get(currentCategoryId).isEmpty()) {
                continue;
            }

            LinearLayout categoryView = (LinearLayout) inflater.inflate(R.layout.layout_editconfig_group_header,
                    null);
            TextView title = (TextView) categoryView.findViewById(R.id.textViewGroupHeader);
            TextView descriptionTextView = (TextView) categoryView.findViewById(R.id.textViewGroupDescription);
            content.addView(categoryView);

            if (currentCategoryId == 0) {
                // draw allgemein for category 0. if an group with id 0 is
                // described the values will be overwritten in next step
                title.setText("ALLGEMEIN");
                descriptionTextView.setVisibility(View.GONE);
            }

            // draw the category header and a description if present
            if (description != null) {
                for (Group currentGroup : description.groups()) {
                    if (currentGroup.position() == currentCategoryId) {
                        title.setText(currentGroup.name());
                        if (currentGroup.description().isEmpty() == false) {
                            descriptionTextView.setText(currentGroup.description());
                            descriptionTextView.setVisibility(View.VISIBLE);
                        } else {
                            descriptionTextView.setVisibility(View.GONE);
                        }
                        break;
                    }
                }
            }

            // draw all handlers for the fields in this category
            Map<Integer, Field> values = sortedMap.get(currentCategoryId);
            for (Field field : values.values()) {
                addFieldToView(inflater, beanToEdit, content, field);

                // we are shure that the default or a special category have
                // been used. if there are unsorted values put them into an
                // additional group later
                sortedValuesDrawn = true;
            }
        }

        // draw a header for unsorted fields if class description provided
        // categories for the other fields
        if (sortedValuesDrawn && unsortedList.isEmpty() == false) {
            LinearLayout categoryFurther = (LinearLayout) inflater
                    .inflate(R.layout.layout_editconfig_group_header, null);
            TextView title = (TextView) categoryFurther.findViewById(R.id.textViewGroupHeader);
            title.setText("WEITERE");
            TextView descriptionTextView = (TextView) categoryFurther
                    .findViewById(R.id.textViewGroupDescription);
            descriptionTextView.setVisibility(View.GONE);
            content.addView(categoryFurther);
        }

        // draw the handlers
        for (Field currentField : unsortedList) {
            addFieldToView(inflater, beanToEdit, content, currentField);
        }

        // default text if no fields are annotated
        if (sortedValuesDrawn == false && unsortedList.isEmpty()) {
            TextView tv = new TextView(content.getContext());
            tv.setText("Dieses Objekt wird nicht konfiguriert");
            content.addView(tv);
        }

        return result;

    } catch (Exception e) {
        Log.e(LOG, "could not create View for bean: " + beanToEdit.getClass().getName(), e);
        return null;
    }
}

From source file:com.RSMSA.policeApp.Adapters.ViewPagerAccidentsDetailsAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    android.widget.ScrollView itemView = (ScrollView) inflater.inflate(R.layout.accident_details, container,
            false);/* w w w  .  java2s  .c o m*/

    final AccidentVehicle accidentVehicle = new AccidentVehicle();
    Button addPasenger = (Button) itemView.findViewById(R.id.add_witness);
    Button next = (Button) itemView.findViewById(R.id.next);
    final LinearLayout linearLayout = (LinearLayout) itemView.findViewById(R.id.passengers_layout);

    if (position == tabnames.size() - 1) {
        next.setVisibility(View.VISIBLE);
    } else {
        next.setVisibility(View.GONE);
    }
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AccidentReportFormActivity.showWitneses();
        }
    });

    final EditText fatalEdit = (EditText) itemView.findViewById(R.id.fatal_edit);
    fatalEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setFatal"));

    final EditText simpleEdit = (EditText) itemView.findViewById(R.id.simple_edit);
    simpleEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setSimple"));

    EditText injuryEdit = (EditText) itemView.findViewById(R.id.injury_edit);
    injuryEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setSevere_injured"));

    EditText notInjuredEdit = (EditText) itemView.findViewById(R.id.not_injured_edit);
    notInjuredEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setOnly_damage"));

    EditText driverLicenceEdit = (EditText) itemView.findViewById(R.id.license_one);
    driverLicenceEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setLicence_no") {
        public void afterFocus(final String text, final EditText editText) {
            new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {
                    DHIS2Modal dhis2Modal = new DHIS2Modal("Driver", null, MainOffence.username,
                            MainOffence.password);
                    JSONObject where = new JSONObject();
                    try {
                        where.put("value", text);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    JSONObject driverObject = null;
                    try {
                        JSONArray driver = dhis2Modal.getEvent(where);
                        Log.d(TAG, "returned driver json = " + driver.toString());
                        driverObject = driver.getJSONObject(0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    try {
                        if (driverObject.getString("Driver License Number").equals(text)) {
                            accidentVehicle.setProgram_driver(driverObject.getString("id"));
                            return true;
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        Log.e(TAG, "returned json object is null");
                    }
                    return false;
                }

                @Override
                protected void onPostExecute(Boolean aVoid) {
                    super.onPostExecute(aVoid);
                    if (!aVoid) {
                        editText.setTextColor(context.getResources().getColor(R.color.red));
                    } else {
                        editText.setTextColor(context.getResources().getColor(R.color.green_500));
                    }
                }
            }.execute();

        }
    });

    final EditText alcoholEdit = (EditText) itemView.findViewById(R.id.alcohol_edit);
    alcoholEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setAlcohol_percentage"));

    CheckBox drug = (CheckBox) itemView.findViewById(R.id.drug_edit);
    drug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            accidentVehicle.setDrug(isChecked);
        }
    });

    CheckBox phone = (CheckBox) itemView.findViewById(R.id.phone_edit);
    phone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            accidentVehicle.setPhone_use(isChecked);
        }
    });

    EditText plateNumber = (EditText) itemView.findViewById(R.id.registration_number_one);
    plateNumber.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setPlate_number") {
        public void afterFocus(final String text, final EditText editText) {
            new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {
                    DHIS2Modal dhis2Modal = new DHIS2Modal("Vehicle", null, MainOffence.username,
                            MainOffence.password);
                    JSONObject where = new JSONObject();
                    try {
                        where.put("value", text);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    JSONObject vehicleObject = null;
                    try {
                        JSONArray vehiclesArray = dhis2Modal.getEvent(where);
                        Log.d(TAG, "returned vehicle json = " + vehiclesArray.toString());
                        vehicleObject = vehiclesArray.getJSONObject(0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }

                    try {
                        if (vehicleObject.getString("Vehicle Plate Number").equals(text)) {
                            accidentVehicle.setProgram_vehicle(vehicleObject.getString("id"));
                            return true;
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        Log.e(TAG, "returned json object is null");
                    }
                    return false;
                }

                @Override
                protected void onPostExecute(Boolean aVoid) {
                    super.onPostExecute(aVoid);
                    if (!aVoid) {
                        editText.setTextColor(context.getResources().getColor(R.color.red));
                    } else {
                        editText.setTextColor(context.getResources().getColor(R.color.light_gray));
                    }
                }
            }.execute();

        }
    });

    EditText repairCost = (EditText) itemView.findViewById(R.id.repair_amount_one);
    repairCost.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setEstimated_repair"));

    EditText vehicleEdit = (EditText) itemView.findViewById(R.id.vehicle_title_edit);
    vehicleEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setVehicle"));

    EditText vehicleTotalEdit = (EditText) itemView.findViewById(R.id.vehicle_total_edit);
    vehicleTotalEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setVehicle_total"));

    EditText infastructureEdit = (EditText) itemView.findViewById(R.id.infrastructure_edit);
    infastructureEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setInfastructure"));

    EditText costEdit = (EditText) itemView.findViewById(R.id.rescue_cost_edit);
    costEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setCost"));

    final List<PassengerVehicle> passengers = new ArrayList<PassengerVehicle>();

    addPasenger.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final PassengerVehicle passengerVehicle = new PassengerVehicle();
            LinearLayout passenger = (LinearLayout) inflater.inflate(R.layout.passenger, null);

            linearLayout.addView(passenger);

            EditText nameEdit = (EditText) passenger.findViewById(R.id.name_edit);
            nameEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setName"));

            final EditText dateOfBirth = (EditText) passenger.findViewById(R.id.dob_one);
            dateOfBirth.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setDate_of_birth"));

            EditText physicalAddressEdit = (EditText) passenger.findViewById(R.id.physical_address_one);
            physicalAddressEdit
                    .setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setPhysical_address"));

            EditText addressBoxEdit = (EditText) passenger.findViewById(R.id.address_box_one);
            addressBoxEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setAddress"));

            EditText nationalIDEdit = (EditText) passenger.findViewById(R.id.national_id_one);
            nationalIDEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setNational_id"));

            EditText phoneNoEdit = (EditText) passenger.findViewById(R.id.phone_no_one);
            phoneNoEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setPhone_no"));

            EditText alcoholPercentageEdit = (EditText) passenger.findViewById(R.id.alcohol_percentage);
            alcoholPercentageEdit
                    .setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setAlcohol_percent"));

            CheckBox seatbeltCheckbox = (CheckBox) passenger.findViewById(R.id.seat_belt_check);
            seatbeltCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    passengerVehicle.setHelmet(isChecked);
                }
            });

            Button date_picker = (Button) passenger.findViewById(R.id.date_picker);
            date_picker.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    DatePickerDialog newDatePickerDialogueFragment;
                    newDatePickerDialogueFragment = new DatePickerDialog();
                    newDatePickerDialogueFragment.show(AccidentReportFormActivity.fragmentManager,
                            "DatePickerDialogue");
                    newDatePickerDialogueFragment
                            .setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
                                @Override
                                public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear,
                                        int dayOfMonth) {
                                    dateOfBirth.setText(dayOfMonth + " / " + (monthOfYear + 1) + " / " + year);
                                }
                            });
                }
            });

            final RadioButton male = (RadioButton) passenger.findViewById(R.id.male);
            male.setTypeface(MainOffence.Roboto_Regular);

            final RadioButton female = (RadioButton) passenger.findViewById(R.id.female);
            female.setTypeface(MainOffence.Roboto_Regular);

            passengerVehicle.setGender("Male");
            male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked)
                        passengerVehicle.setGender("Male");
                }
            });

            female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked)
                        passengerVehicle.setGender("Female");
                }
            });

            passengers.add(linearLayout.getChildCount() - 1, passengerVehicle);

        }
    });

    accident[position] = accidentVehicle;
    passanger.add(position, passengers);

    ((ViewPager) container).addView(itemView);
    return itemView;
}

From source file:com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);//  w  w  w  .java  2s.  c  o m
    ScrollView ll = (ScrollView) inflater.inflate(R.layout.sound_control, container, false);
    fa = (ActionBarActivity) super.getActivity();
    fa.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    fa.getSupportActionBar().setHomeButtonEnabled(true);
    bootPrefs = fa.getSharedPreferences("BOOT_PREFS", 0);
    final Boolean isLinked = fa.getSharedPreferences("SOUND_CONTROL", 0).getBoolean("LINKED", true);

    assert ll != null;
    final SeekBar headphoneLeft = (SeekBar) ll.findViewById(R.id.headphone_seekbar_left);
    final SeekBar headphoneRight = (SeekBar) ll.findViewById(R.id.headphone_seekbar_right);
    final SeekBar headphonePALeft = (SeekBar) ll.findViewById(R.id.headphone_pa_seekbar_left);
    final SeekBar headphonePARight = (SeekBar) ll.findViewById(R.id.headphone_pa_seekbar_right);
    final SeekBar speakerLeft = (SeekBar) ll.findViewById(R.id.speaker_seekbar_left);
    final SeekBar speakerRight = (SeekBar) ll.findViewById(R.id.speaker_seekbar_right);
    final SeekBar micGain = (SeekBar) ll.findViewById(R.id.mic_seekbar);
    final SeekBar camMicGain = (SeekBar) ll.findViewById(R.id.cam_mic_seekbar);

    final TextView headUnitLeft = (TextView) ll.findViewById(R.id.headphone_unit_left);
    final TextView headUnitRight = (TextView) ll.findViewById(R.id.headphone_unit_right);
    final TextView headPAUnitLeft = (TextView) ll.findViewById(R.id.headphone_pa_unit_left);
    final TextView headPAUnitRight = (TextView) ll.findViewById(R.id.headphone_pa_unit_right);
    final TextView speakerUnitLeft = (TextView) ll.findViewById(R.id.speaker_unit_left);
    final TextView speakerUnitRight = (TextView) ll.findViewById(R.id.speaker_unit_right);
    final TextView micUnit = (TextView) ll.findViewById(R.id.mic_unit);
    final TextView camMicUnit = (TextView) ll.findViewById(R.id.cam_mic_unit);

    // Headphone L/R Gain
    if (Helpers.doesFileExist(FAUX_SC_HEADPHONE)) {
        headphoneLeft.setMax(40);
        headphoneRight.setMax(40);
        String[] headphoneGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE).split(" ");
        int headphoneGainLeft = Integer.valueOf(headphoneGains[0]);
        if (headphoneGainLeft > 100)
            headphoneGainLeft -= 256;

        int headphoneGainRight = Integer.valueOf(headphoneGains[1]);
        if (headphoneGainRight > 100)
            headphoneGainRight -= 256;

        headphoneLeft.setProgress(headphoneGainLeft + 30);
        headphoneRight.setProgress(headphoneGainRight + 30);
        headUnitLeft.setText(headphoneGainLeft + "");
        headUnitRight.setText(headphoneGainRight + "");

        headphoneLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                headUnitLeft.setText(i - 30 + "");
                if (isLinked) {
                    headUnitRight.setText(i - 30 + "");
                    headphoneRight.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(seekBar.getProgress());
                int toApplyRight = getSCInt(headphoneRight.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_HEADPHONE + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("HEADPHONE",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

        headphoneRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                headUnitRight.setText(i - 30 + "");
                if (isLinked) {
                    headUnitLeft.setText(i - 30 + "");
                    headphoneLeft.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(headphoneLeft.getProgress());
                int toApplyRight = getSCInt(seekBar.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_HEADPHONE + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("HEADPHONE",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

    } else {
        headphoneLeft.setMax(40);
        headphoneRight.setMax(40);
        headphoneLeft.setProgress(20);
        headphoneRight.setProgress(20);
        headphoneLeft.setEnabled(false);
        headphoneRight.setEnabled(false);
        headUnitLeft.setText("Unsupported");
        headUnitRight.setText("Unsupported");
    }

    // Headphone analog L/R gain
    if (Helpers.doesFileExist(FAUX_SC_HEADPHONE_POWERAMP)) {
        headphonePALeft.setMax(12);
        headphonePARight.setMax(12);
        String[] headphonePAGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE_POWERAMP).split(" ");
        int headphonePAGainLeft = Integer.valueOf(headphonePAGains[0]);
        int headphonePAGainRight = Integer.valueOf(headphonePAGains[1]);
        headphonePALeft.setProgress(headphonePAGainLeft);
        headphonePARight.setProgress(headphonePAGainRight);
        headPAUnitLeft.setText(headphonePAGainLeft - 26 + "");
        headPAUnitRight.setText(headphonePAGainRight - 26 + "");

        headphonePALeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                headPAUnitLeft.setText(i - 6 + "");
                if (isLinked) {
                    headphonePARight.setProgress(i);
                    headPAUnitRight.setText(i - 6 + "");
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSysfsValue(seekBar.getProgress());
                int toApplyRight = getSysfsValue(headphonePARight.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_HEADPHONE_POWERAMP + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("HEADPHONE_PA",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

        headphonePARight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                headPAUnitRight.setText(i - 6 + "");
                if (isLinked) {
                    headphonePALeft.setProgress(i);
                    headPAUnitLeft.setText(i - 6 + "");
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSysfsValue(headphonePALeft.getProgress());
                int toApplyRight = getSysfsValue(seekBar.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_HEADPHONE_POWERAMP + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("HEADPHONE_PA",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

    } else {
        headphonePALeft.setMax(40);
        headphonePARight.setMax(40);
        headphonePALeft.setProgress(20);
        headphonePARight.setProgress(20);
        headphonePALeft.setEnabled(false);
        headphonePARight.setEnabled(false);
        headPAUnitLeft.setText("Unsupported");
        headPAUnitRight.setText("Unsupported");
    }

    // Speaker L/R Gain
    if (Helpers.doesFileExist(FAUX_SC_SPEAKER)) {
        speakerLeft.setMax(40);
        speakerRight.setMax(40);
        String[] speakerGains = CPUHelper.readOneLineNotRoot(FAUX_SC_SPEAKER).split(" ");
        int speakerGainLeft = Integer.valueOf(speakerGains[0]);
        if (speakerGainLeft > 100)
            speakerGainLeft -= 256;

        int speakerGainRight = Integer.valueOf(speakerGains[1]);
        if (speakerGainRight > 100)
            speakerGainRight -= 256;

        speakerLeft.setProgress(speakerGainLeft + 30);
        speakerRight.setProgress(speakerGainRight + 30);
        speakerUnitLeft.setText(speakerGainLeft + "");
        speakerUnitRight.setText(speakerGainRight + "");

        speakerLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                speakerUnitLeft.setText(i - 30 + "");
                if (isLinked) {
                    speakerUnitRight.setText(i - 30 + "");
                    speakerRight.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(seekBar.getProgress());
                int toApplyRight = getSCInt(speakerRight.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_SPEAKER + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("SPEAKER",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

        speakerRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                speakerUnitRight.setText(i - 30 + "");
                if (isLinked) {
                    speakerUnitLeft.setText(i - 30 + "");
                    speakerLeft.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(speakerLeft.getProgress());
                int toApplyRight = getSCInt(seekBar.getProgress());
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n"
                        + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > "
                        + FAUX_SC_SPEAKER + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("SPEAKER",
                                toApplyLeft + " " + toApplyRight + " "
                                        + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight))
                        .commit();
            }
        });

    } else {
        speakerLeft.setMax(40);
        speakerRight.setMax(40);
        speakerLeft.setProgress(20);
        speakerRight.setProgress(20);
        speakerLeft.setEnabled(false);
        speakerRight.setEnabled(false);
        speakerUnitLeft.setText("Unsupported");
        speakerUnitRight.setText("Unsupported");
    }

    // Microphone Gain
    if (Helpers.doesFileExist(FAUX_SC_MIC)) {
        int micValue = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_MIC));
        if (micValue > 100)
            micValue -= 256;

        micGain.setMax(40);
        micGain.setProgress(micValue + 30);
        micUnit.setText(micValue + "");
        micGain.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                micUnit.setText(i - 30 + "");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int scProgress = seekBar.getProgress() - 30;
                if (scProgress < 0)
                    scProgress += 256;

                Helpers.CMDProcessorWrapper
                        .runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + scProgress
                                + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0) + " > "
                                + FAUX_SC_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("SC_MIC",
                                scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0))
                        .commit();
            }
        });

    } else {
        micGain.setMax(40);
        micGain.setProgress(20);
        micUnit.setText("Unsupported");
        micGain.setEnabled(false);
    }

    // Camera Microphone Gain
    if (Helpers.doesFileExist(FAUX_SC_CAM_MIC)) {
        int camMicValue = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_CAM_MIC));
        if (camMicValue > 100)
            camMicValue -= 256;

        camMicGain.setMax(40);
        camMicGain.setProgress(camMicValue + 30);
        camMicUnit.setText(camMicValue + "");
        camMicGain.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                camMicUnit.setText(i - 30 + "");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int scProgress = seekBar.getProgress() - 30;
                if (scProgress < 0)
                    scProgress += 256;

                Helpers.CMDProcessorWrapper
                        .runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + scProgress
                                + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0) + " > "
                                + FAUX_SC_CAM_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED);
                bootPrefs.edit()
                        .putString("SC_MIC",
                                scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0))
                        .commit();
            }
        });

    } else {
        camMicGain.setMax(40);
        camMicGain.setProgress(20);
        camMicUnit.setText("Unsupported");
        camMicGain.setEnabled(false);
    }

    return ll;
}

From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java

/**
 * Shows a dialog asking the user to confirm suspension of ScreenSpeak.
 *//*  www.  ja va2s.c o  m*/
private void confirmSuspendScreenSpeak() {
    // Ensure only one dialog is showing.
    if (mSuspendDialog != null) {
        if (mSuspendDialog.isShowing()) {
            return;
        } else {
            mSuspendDialog.dismiss();
            mSuspendDialog = null;
        }
    }

    final LayoutInflater inflater = LayoutInflater.from(this);
    @SuppressLint("InflateParams")
    final ScrollView root = (ScrollView) inflater.inflate(R.layout.suspend_screenspeak_dialog, null);
    final CheckBox confirmCheckBox = (CheckBox) root.findViewById(R.id.show_warning_checkbox);
    final TextView message = (TextView) root.findViewById(R.id.message_resume);

    final DialogInterface.OnClickListener okayClick = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                if (!confirmCheckBox.isChecked()) {
                    SharedPreferencesUtils.putBooleanPref(mPrefs, getResources(),
                            R.string.pref_show_suspension_confirmation_dialog, false);
                }

                suspendScreenSpeak();
            }
        }
    };

    final OnDismissListener onDismissListener = new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mSuspendDialog = null;
        }
    };

    if (mAutomaticResume.equals(getString(R.string.resume_screen_keyguard))) {
        message.setText(getString(R.string.message_resume_keyguard));
    } else if (mAutomaticResume.equals(getString(R.string.resume_screen_manual))) {
        message.setText(getString(R.string.message_resume_manual));
    } else { // screen on is the default value
        message.setText(getString(R.string.message_resume_screen_on));
    }

    mSuspendDialog = new AlertDialog.Builder(this).setTitle(R.string.dialog_title_suspend_screenspeak)
            .setView(root).setNegativeButton(android.R.string.cancel, null)
            .setPositiveButton(android.R.string.ok, okayClick).create();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        mSuspendDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY);
    } else {
        mSuspendDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
    }

    mSuspendDialog.setOnDismissListener(onDismissListener);
    mSuspendDialog.show();
}

From source file:com.google.android.marvin.mytalkback.TalkBackService.java

/**
 * Shows a dialog asking the user to confirm suspension of TalkBack.
 *//*from   www  .  j  a v a2  s. co m*/
private void confirmSuspendTalkBack() {
    // Ensure only one dialog is showing.
    if (mSuspendDialog != null) {
        if (mSuspendDialog.isShowing()) {
            return;
        } else {
            mSuspendDialog.dismiss();
            mSuspendDialog = null;
        }
    }

    final LayoutInflater inflater = LayoutInflater.from(this);
    final ScrollView root = (ScrollView) inflater.inflate(R.layout.suspend_talkback_dialog, null);
    final CheckBox confirmCheckBox = (CheckBox) root.findViewById(R.id.show_warning_checkbox);
    final TextView message = (TextView) root.findViewById(R.id.message_resume);

    final DialogInterface.OnClickListener okayClick = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                if (!confirmCheckBox.isChecked()) {
                    SharedPreferencesUtils.putBooleanPref(mPrefs, getResources(),
                            R.string.pref_show_suspension_confirmation_dialog, false);
                }

                suspendTalkBack();
                break;
            }
        }
    };

    final OnDismissListener onDismissListener = new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mSuspendDialog = null;
        }
    };

    switch (mAutomaticResume) {
    case KEYGUARD:
        message.setText(getString(R.string.message_resume_keyguard));
        break;
    case SCREEN_ON:
        message.setText(getString(R.string.message_resume_screen_on));
        break;
    case MANUAL:
        message.setText(getString(R.string.message_resume_manual));
        break;
    }

    mSuspendDialog = new AlertDialog.Builder(this).setTitle(R.string.dialog_title_suspend_talkback)
            .setView(root).setNegativeButton(android.R.string.cancel, null)
            .setPositiveButton(android.R.string.ok, okayClick).create();

    // Ensure we can show the dialog from this service.
    mSuspendDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
    mSuspendDialog.setOnDismissListener(onDismissListener);
    mSuspendDialog.show();
}