Example usage for android.widget Spinner setAdapter

List of usage examples for android.widget Spinner setAdapter

Introduction

In this page you can find the example usage for android.widget Spinner setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

Usage

From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java

/**
 * Sets up the spinner for modes./*from  w w  w .  j  a v  a2 s.c om*/
 */
private void setupModeSpinner() {
    Spinner spinner = (Spinner) this.findViewById(R.id.action_edit_gpsfilter_area_mode);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.action_edit_gpsfilter_area_mode, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    spinner.setSelection(this.area.getMode() == GPSFilterMode.INCLUDE ? 0 : 1);

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateMode(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}

From source file:org.tigase.mobile.muc.JoinMucDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new Dialog(getActivity());
    dialog.setCancelable(true);//from   w ww  .j a va2 s .c  o  m
    dialog.setCanceledOnTouchOutside(true);

    dialog.setContentView(R.layout.join_room_dialog);
    dialog.setTitle(getString(R.string.aboutButton));

    ArrayList<String> accounts = new ArrayList<String>();
    for (Account account : AccountManager.get(getActivity()).getAccountsByType(Constants.ACCOUNT_TYPE)) {
        accounts.add(account.name);
    }

    final Spinner accountSelector = (Spinner) dialog.findViewById(R.id.muc_accountSelector);
    final Button joinButton = (Button) dialog.findViewById(R.id.muc_joinButton);
    final Button cancelButton = (Button) dialog.findViewById(R.id.muc_cancelButton);
    final TextView name = (TextView) dialog.findViewById(R.id.muc_name);
    final TextView roomName = (TextView) dialog.findViewById(R.id.muc_roomName);
    final TextView mucServer = (TextView) dialog.findViewById(R.id.muc_server);
    final TextView nickname = (TextView) dialog.findViewById(R.id.muc_nickname);
    final TextView password = (TextView) dialog.findViewById(R.id.muc_password);
    final CheckBox autojoin = (CheckBox) dialog.findViewById(R.id.muc_autojoin);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            accounts.toArray(new String[] {}));
    accountSelector.setAdapter(adapter);

    Bundle data = getArguments();
    final boolean editMode = data != null && data.containsKey("editMode") && data.getBoolean("editMode");
    final String id = data != null ? data.getString("id") : null;

    if (data != null) {
        accountSelector.setSelection(adapter.getPosition(data.getString("account")));

        name.setText(data.getString("name"));
        roomName.setText(data.getString("room"));
        mucServer.setText(data.getString("server"));
        nickname.setText(data.getString("nick"));
        password.setText(data.getString("password"));
        autojoin.setChecked(data.getBoolean("autojoin"));
    }

    if (!editMode) {
        name.setVisibility(View.GONE);
        autojoin.setVisibility(View.GONE);
    } else {
        joinButton.setText("Save");
    }

    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }
    });
    joinButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (editMode) {

                BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString());
                final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext())
                        .getMultiJaxmpp().get(account);

                Bundle data = new Bundle();

                data.putString("id", id);
                data.putString("account", account.toString());
                data.putString("name", name.getText().toString());
                data.putString("room", roomName.getText().toString());
                data.putString("server", mucServer.getText().toString());
                data.putString("nick", nickname.getText().toString());
                data.putString("password", password.getText().toString());
                data.putBoolean("autojoin", autojoin.isChecked());

                ((BookmarksActivity) getActivity()).saveItem(data);

                dialog.dismiss();
                return;
            }

            BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString());
            final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext())
                    .getMultiJaxmpp().get(account);

            Runnable r = new Runnable() {

                @Override
                public void run() {
                    try {
                        Room room = jaxmpp.getModule(MucModule.class).join(
                                roomName.getEditableText().toString(), mucServer.getEditableText().toString(),
                                nickname.getEditableText().toString(), password.getEditableText().toString());
                        if (task != null)
                            task.execute(room);
                    } catch (Exception e) {
                        Log.w("MUC", "", e);
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            };
            (new Thread(r)).start();
            dialog.dismiss();
        }
    });

    return dialog;
}

From source file:com.example.nativeaudio.NativeAudio.java

/** Called when the activity is first created. */
@Override//  w w  w.ja v a  2s  . com
@TargetApi(17)
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

    Log.d(TAG, "onCreate ----------- ");

    assetManager = getAssets();

    /*
    Ctrl+O ?
    Ctrl+I ?
            
    Ctrl+N /?
    Ctrl+Shift+N 
    Ctrl+Shift+ALt+N ?
            
            
    Ctrl+Space ???
    Ctrl+Shift+Space ?
    Ctrl+Shift+Enter (? ?; )
    Ctrl+P ??
            
    Alt+Enter ?/?/
            
    Ctrl+J ?? ( for foreach Toast system.out.println) logm logr loge
      */

    // initialize native audio system
    createEngine();

    int sampleRate = 0;
    int bufSize = 0;
    /*
     * retrieve fast audio path sample rate and buf size; if we have it, we pass to native
     * side to create a player with fast audio enabled [ fast audio == low latency audio ];
     * IF we do not have a fast audio path, we pass 0 for sampleRate, which will force native
     * side to pick up the 8Khz sample rate.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        String nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
        sampleRate = Integer.parseInt(nativeParam);
        nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
        bufSize = Integer.parseInt(nativeParam); // buffer?

        PackageManager pm = getPackageManager();
        boolean claimsFeature = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);

        // ?5 OUTPUT_SAMPLE_RATE = 48000 OUTPUT_FRAMES_PER_BUFFER = 192 FEATURE_AUDIO_LOW_LATENCY = false
        // MTK MT6735  OUTPUT_SAMPLE_RATE = 44100 OUTPUT_FRAMES_PER_BUFFER = 1024 FEATURE_AUDIO_LOW_LATENCY = false
        Log.d(TAG, "OUTPUT_SAMPLE_RATE = " + sampleRate + " OUTPUT_FRAMES_PER_BUFFER = " + bufSize
                + " FEATURE_AUDIO_LOW_LATENCY = " + claimsFeature);
    }

    //  buffer queue AudioPlayer Demo
    createBufferQueueAudioPlayer(sampleRate, bufSize);

    // initialize URI spinner
    Spinner uriSpinner = (Spinner) findViewById(R.id.uri_spinner);
    ArrayAdapter<CharSequence> uriAdapter = ArrayAdapter.createFromResource(this,
            R.array.local_uri_spinner_array,
            /* R.array.uri_spinner_array, */
            android.R.layout.simple_spinner_item);
    uriAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    uriSpinner.setAdapter(uriAdapter);
    uriSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            URI = parent.getItemAtPosition(pos).toString();
            /* ? ?
              <string-array name="uri_spinner_array">
                <item>http://upload.wikimedia.org/wikipedia/commons/6/6d/Banana.ogg</item>
                <item>http://www.freesound.org/data/previews/18/18765_18799-lq.mp3</item>
              </string-array>
             */
        }

        public void onNothingSelected(AdapterView parent) {
            URI = null;
        }

    });

    // initialize button click handlers

    ((Button) findViewById(R.id.hello)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_HELLO, 2);
        }
    });

    ((Button) findViewById(R.id.android)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_ANDROID, 7);
        }
    });

    ((Button) findViewById(R.id.sawtooth)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_SAWTOOTH, 1);
        }
    });

    ((Button) findViewById(R.id.reverb)).setOnClickListener(new OnClickListener() {
        boolean enabled = false;

        public void onClick(View view) {
            enabled = !enabled;
            if (!enableReverb(enabled)) {
                enabled = !enabled;
            }
        }
    });

    //  AssertManager APK?mp3
    //
    ((Button) findViewById(R.id.embedded_soundtrack)).setOnClickListener(new OnClickListener() {
        boolean created = false;

        public void onClick(View view) {
            if (!created) {
                created = createAssetAudioPlayer(assetManager, "withus.mp3");
            }
            if (created) {
                // URI AudioPlayer Demo ?
                // URI AudioPlayer Demo ? ?play pause
                // Assert/fd AudioPlayer  Demo ?
                isPlayingAsset = !isPlayingAsset;
                setPlayingAssetAudioPlayer(isPlayingAsset);
            }
        }
    });

    ((Button) findViewById(R.id.uri_soundtrack)).setOnClickListener(new OnClickListener() {
        boolean created = false;

        public void onClick(View view) {
            if (!created && URI != null) {
                Log.d(TAG, " uri_soundtrack create URI Audio Player URI " + URI);
                //URI = "file:///mnt/sdcard/xxx.3gp" ;
                //URI = "file:///mnt/sdcard/Banana.ogg" ;
                created = createUriAudioPlayer(URI);
            }
        }
    });

    ((Button) findViewById(R.id.pause_uri)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            Log.d(TAG, " setPlayingUriAudioPlayer  pause URI ");
            setPlayingUriAudioPlayer(false);
        }
    });

    ((Button) findViewById(R.id.play_uri)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            Log.d(TAG, " setPlayingUriAudioPlayer  play URI ");
            setPlayingUriAudioPlayer(true);
        }
    });

    ((Button) findViewById(R.id.loop_uri)).setOnClickListener(new OnClickListener() {
        boolean isLooping = false;

        public void onClick(View view) {
            isLooping = !isLooping;
            setLoopingUriAudioPlayer(isLooping);

        }
    });

    ((Button) findViewById(R.id.mute_left_uri)).setOnClickListener(new OnClickListener() {
        boolean muted = false;

        public void onClick(View view) {
            muted = !muted;
            setChannelMuteUriAudioPlayer(0, muted);
        }
    });

    ((Button) findViewById(R.id.mute_right_uri)).setOnClickListener(new OnClickListener() {
        boolean muted = false;

        public void onClick(View view) {
            muted = !muted;
            setChannelMuteUriAudioPlayer(1, muted);
        }
    });

    ((Button) findViewById(R.id.solo_left_uri)).setOnClickListener(new OnClickListener() {
        boolean soloed = false;

        public void onClick(View view) {
            soloed = !soloed;
            setChannelSoloUriAudioPlayer(0, soloed);
        }
    });

    ((Button) findViewById(R.id.solo_right_uri)).setOnClickListener(new OnClickListener() {
        boolean soloed = false;

        public void onClick(View view) {
            soloed = !soloed;
            setChannelSoloUriAudioPlayer(1, soloed);
        }
    });

    ((Button) findViewById(R.id.mute_uri)).setOnClickListener(new OnClickListener() {
        boolean muted = false;

        public void onClick(View view) {
            muted = !muted;
            setMuteUriAudioPlayer(muted);
        }
    });

    /*
    *  ???? ?  Stereo Panning
    *  https://developer.android.com/ndk/guides/audio/opensl-prog-notes.html#panning
    *
    * */
    ((Button) findViewById(R.id.enable_stereo_position_uri)).setOnClickListener(new OnClickListener() {
        boolean enabled = false;

        public void onClick(View view) {
            enabled = !enabled;
            enableStereoPositionUriAudioPlayer(enabled);
        }
    });

    // ??  ?AudioPlayer ??? ?SetPlayState???
    ((Button) findViewById(R.id.channels_uri)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (numChannelsUri == 0) {
                numChannelsUri = getNumChannelsUriAudioPlayer();
            }
            Toast.makeText(NativeAudio.this, "Channels: " + numChannelsUri, Toast.LENGTH_SHORT).show();
        }
    });

    // ??
    ((SeekBar) findViewById(R.id.volume_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int lastProgress = 100;

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) {
                throw new AssertionError();
            }
            lastProgress = progress;
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            int attenuation = 100 - lastProgress;
            int millibel = attenuation * -50; // 100 * -50  ~  0
            setVolumeUriAudioPlayer(millibel);
        }
    });

    ((SeekBar) findViewById(R.id.pan_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int lastProgress = 100;

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) {
                throw new AssertionError();
            }
            lastProgress = progress;
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            // ?? ?
            // ? ?  ?<50  >50 ?
            int permille = (lastProgress - 50) * 20;
            setStereoPositionUriAudioPlayer(permille);
        }
    });

    ((SeekBar) findViewById(R.id.playback_rate_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int lastProgress = 100;

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) {
                throw new AssertionError();
            }
            lastProgress = progress;
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {

            /*
                    0 ----- 50 ---- 100
                  -1000 --- 0 ---- 1000
             */
            int permille = lastProgress * (1000 - -1000) / 100 + (-1000);
            setPlaybackRateUriAudioPlayer(permille);
        }
    });

    ((Button) findViewById(R.id.record)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            //                int status = ActivityCompat.checkSelfPermission(NativeAudio.this,
            //                        Manifest.permission.RECORD_AUDIO);
            //                if (status != PackageManager.PERMISSION_GRANTED) {
            //                    ActivityCompat.requestPermissions(
            //                            NativeAudio.this,
            //                            new String[]{Manifest.permission.RECORD_AUDIO},
            //                            AUDIO_ECHO_REQUEST);
            //                    return;
            //                }
            recordAudio();
        }
    });

    ((Button) findViewById(R.id.playback)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_PLAYBACK, 3);
        }
    });

}

From source file:com.kubotaku.android.code4kyoto5374.fragments.HomeSelectFragment.java

private void showPlaceSelector(RealmResults<AreaDays> areaDaysResult) {

    final TextView textAlert = (TextView) getView().findViewById(R.id.text_place_alert);
    final Spinner spinner = (Spinner) getView().findViewById(R.id.spinner_select_town);

    if (areaDaysResult.size() <= 1) {
        textAlert.setVisibility(View.GONE);
        spinner.setVisibility(View.GONE);

        if (areaDaysResult.size() == 1) {
            showValidSelectedAreaDays(areaDaysResult.first());
        }/*from  w  w  w . j ava2s  .  c o  m*/

    } else {
        textAlert.setVisibility(View.VISIBLE);
        spinner.setVisibility(View.VISIBLE);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        for (AreaDays areaDays : areaDaysResult) {
            adapter.add(areaDays.areaName);
        }
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(onTownSelectedListener);
    }
}

From source file:blackman.matt.boardlist.BoardListActivity.java

/**
 * Sets up the spinners on the view./*w w w  . j a  v a  2  s . com*/
 */
private void initSpinners() {
    Spinner spinnerSort;
    Spinner spinnerOrder;

    ArrayAdapter<CharSequence> sortAdapter;
    ArrayAdapter<CharSequence> orderAdapter;

    // Set up the spinners
    spinnerSort = (Spinner) findViewById(R.id.spinner_sort_by);
    spinnerOrder = (Spinner) findViewById(R.id.spinner_sort_order);

    sortAdapter = ArrayAdapter.createFromResource(this, R.array.sql_columns_array,
            android.R.layout.simple_spinner_item);

    orderAdapter = ArrayAdapter.createFromResource(this, R.array.sql_sort_order_array,
            android.R.layout.simple_spinner_item);

    sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    orderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinnerSort.setAdapter(sortAdapter);
    spinnerOrder.setAdapter(orderAdapter);

    spinnerOrder.setOnItemSelectedListener(new SpinnerActivity());
    spinnerSort.setOnItemSelectedListener(new SpinnerActivity());
}

From source file:com.andreadec.musicplayer.MainActivity.java

private void equalizerSettings() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.equalizer);
    View view = getLayoutInflater().inflate(R.layout.layout_equalizer, null);
    builder.setView(view);//from   w  ww  . j av a 2 s .  c  o m

    builder.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            updateExtendedMenu();
        }
    });
    builder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            updateExtendedMenu();
        }
    });

    CheckBox checkBoxEqualizerEnabled = (CheckBox) view.findViewById(R.id.checkBoxEqualizerEnabled);
    checkBoxEqualizerEnabled.setChecked(musicService.getEqualizerEnabled());
    checkBoxEqualizerEnabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            musicService.toggleEqualizer();
            updateExtendedMenu();
        }
    });

    String[] availablePresets = musicService.getEqualizerAvailablePresets();
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            availablePresets);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner spinnerEqualizerPreset = (Spinner) view.findViewById(R.id.spinnerEqualizerPreset);
    spinnerEqualizerPreset.setAdapter(adapter);
    spinnerEqualizerPreset.setSelection(musicService.getEqualizerPreset());

    spinnerEqualizerPreset.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            musicService.setEqualizerPreset(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    builder.show();
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.OrgProfile.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    Intent i = this.getIntent();
    Bundle b = i.getExtras();//from  ww w .  j a va2 s. co  m

    __keys = new CipherSuit[3];
    __keys[KEY_IDX_ECDSA_BIG] = newCipherSuit(Cipher.ECDSA, Cipher.SHA384, ECDSA.P_521);
    __keys[KEY_IDX_ECDSA] = newCipherSuit(Cipher.ECDSA, Cipher.SHA1, ECDSA.P_256);
    __keys[KEY_IDX_RSA] = newCipherSuit(Cipher.RSA, Cipher.SHA512, 1024);

    // top panel setting
    organization_position = b.getInt(Orgs.O_ID);
    organization_LID = b.getString(Orgs.O_LID);
    organization_GIDH = b.getString(Orgs.O_GIDH);

    oLID = Util.lval(organization_LID, -1);
    if (oLID <= 0)
        return;
    this.org = D_Organization.getOrgByLID(oLID, true, false);
    if (org == null)
        return;

    try {
        Identity crt_identity = Identity.getCurrentConstituentIdentity();
        if (crt_identity == null) {
            Log.d(TAG, "No identity");
        } else
            constituent_LID = net.ddp2p.common.config.Identity.getDefaultConstituentIDForOrg(oLID);
    } catch (P2PDDSQLException e1) {
        e1.printStackTrace();
    }

    if (constituent_LID > 0) {
        constituent = D_Constituent.getConstByLID(constituent_LID, true, false);
        Log.d(TAG, "Got const: " + constituent);
    }

    setContentView(R.layout.org_profile);

    forename = (EditText) findViewById(R.id.profile_furname);
    surname = (EditText) findViewById(R.id.profile_surname);
    neiborhood = (Button) findViewById(R.id.profile_neiborhood);
    submit = (Button) findViewById(R.id.submit_profile);
    submit_new = (Button) findViewById(R.id.submit_profile_new);
    if (constituent == null)
        submit.setVisibility(Button.GONE);
    else
        submit.setVisibility(Button.VISIBLE);
    keys = (Spinner) findViewById(R.id.profile_keys);
    hasRightToVote = (CheckedTextView) findViewById(R.id.profile_hasRightToVote);
    email = (EditText) findViewById(R.id.profile_email);
    slogan = (EditText) findViewById(R.id.profile_slogan);
    slogan.setActivated(false);
    profilePic = (TextView) findViewById(R.id.profile_picture);
    profilePicImg = (ImageView) findViewById(R.id.profile_picture_img);
    // eligibility = (Spinner) findViewById(R.id.profile_eligibility);

    if (constituent != null) {
        forename.setText(constituent.getForename());
        surname.setText(constituent.getSurname());
        hasRightToVote.setChecked(Util.ival(constituent.getWeight(), 0) > 0);
        email.setText(constituent.getEmail());
        slogan.setText(constituent.getSlogan());
    }

    custom_fields = (LinearLayout) findViewById(R.id.profile_view);
    custom_index = 8;
    // custom_fields = (LinearLayout) findViewById(R.id.profile_custom);
    // custom_index = 0;

    custom_params = org.params.orgParam;

    if (custom_params == null || custom_params.length == 0) {
        custom_params = new D_OrgParam[0];// 3
        /*
         * custom_params[0] = new D_OrgParam(); custom_params[0].label =
         * "School"; custom_params[0].entry_size = 5; custom_params[1] = new
         * D_OrgParam(); custom_params[1].label = "Street"; custom_params[2]
         * = new D_OrgParam(); custom_params[2].label = "Year";
         * custom_params[2].list_of_values = new
         * String[]{"2010","2011","2012"};
         */
    }
    D_FieldValue[] field_values = null;
    if (constituent != null && constituent.address != null)
        field_values = constituent.address;
    for (int crt_field = 0; crt_field < custom_params.length; crt_field++) {
        D_OrgParam field = custom_params[crt_field];
        LinearLayout custom_entry = new LinearLayout(this);
        custom_entry.setOrientation(LinearLayout.HORIZONTAL);
        custom_entry.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        TextView custom_label = new TextView(this);
        custom_label.setText(field.label);
        custom_entry.addView(custom_label);

        if (field.list_of_values != null && field.list_of_values.length > 0) {
            Log.d(TAG, "spinner:" + field);
            Spinner custom_spin = new Spinner(this);
            ArrayAdapter<String> custom_spin_Adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, field.list_of_values);
            custom_spin_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            custom_spin.setAdapter(custom_spin_Adapter);
            custom_entry.addView(custom_spin);
            D_FieldValue fv = locateFV(field_values, field);
            if (fv != null) {
                int position = 0;
                for (int k = 0; k <= field.list_of_values.length; k++) {
                    if (Util.equalStrings_null_or_not(field.list_of_values[k], fv.value)) {
                        position = k;
                        break;
                    }
                }
                custom_spin.setSelection(position);
            }
        } else {
            Log.d(TAG, "edit: " + field);
            EditText edit_text = new EditText(this);
            edit_text.setText(field.default_value);
            edit_text.setInputType(InputType.TYPE_CLASS_TEXT);
            if (field.entry_size > 0)
                edit_text.setMinimumWidth(field.entry_size * 60);
            Log.d(TAG, "edit: size=" + field.entry_size);
            custom_entry.addView(edit_text);
            // Button child = new Button(this);
            // child.setText("Test");
            D_FieldValue fv = locateFV(field_values, field);
            if (fv != null)
                edit_text.setText(fv.value);
        }
        custom_fields.addView(custom_entry, custom_index++);
    }

    ArrayAdapter<String> keysAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m);
    keysAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    keys.setAdapter(keysAdapter);
    keys.setOnItemSelectedListener(new KeysListener());

    if (constituent != null) {
        SK sk = constituent.getSK();
        if (sk != null) {
            Cipher cipher = Cipher.getCipher(sk, null);
            if (cipher instanceof net.ddp2p.ciphersuits.RSA) {
                keys.setSelection(KEY_IDX_RSA, true);
            }
            if (cipher instanceof net.ddp2p.ciphersuits.ECDSA) {
                ECDSA ecdsa = (ECDSA) cipher;
                CipherSuit e = ECDSA.getCipherSuite(ecdsa.getPK());
                if (e.hash_alg == Cipher.SHA1) {
                    keys.setSelection(KEY_IDX_ECDSA, true);
                } else {
                    keys.setSelection(KEY_IDX_ECDSA_BIG, true);
                }
            }
        }
    }

    ArrayAdapter<String> eligibilityAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, m);
    eligibilityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // eligibility.setAdapter(eligibilityAdapter);
    // eligibility.setOnItemSelectedListener(new EligibilityListener());

    hasRightToVote.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            hasRightToVote.setChecked(!hasRightToVote.isChecked());
        }
    });

    setProfilePhoto = (ImageView) findViewById(R.id.org_profile_set_profile_photo);
    /*TODO this part only make the whole stuff slow       
    if (constituent_LID > 0) {
     constituent = D_Constituent.getConstByLID(constituent_LID, true,
       true);
     Log.d(TAG, "Got const: " + constituent);
    }
    */
    /*      boolean gotIcon = false;
          if (constituent != null) {
             if (constituent.getPicture() != null) {
    byte[] icon = constituent.getPicture();
    Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0,
          icon.length - 1);
    setProfilePhoto.setImageBitmap(bmp);
    gotIcon = true;
             }
            
             if (!gotIcon) {
    int imgPath = R.drawable.constitutent_person_icon;
    Bitmap bmp = BitmapFactory.decodeResource(getResources(),
          imgPath);
    setProfilePhoto.setImageBitmap(bmp);
             }
          } else {
             int imgPath = R.drawable.constitutent_person_icon;
             Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath);
             setProfilePhoto.setImageBitmap(bmp);
          }
            
          setProfilePhoto.setOnClickListener(new OnClickListener() {
            
             @Override
             public void onClick(View v) {
    if (Build.VERSION.SDK_INT < 19) {
       Intent intent = new Intent();
       intent.setType("image/*");
       intent.setAction(Intent.ACTION_GET_CONTENT);
       startActivityForResult(intent, SELECT_PROFILE_PHOTO);
    } else {
       Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
       intent.setType("image/*");
       startActivityForResult(intent, SELECT_PPROFILE_PHOTO_KITKAT);
    }
             }
          });*/

    submit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String _forename = forename.getText().toString();
            String _surname = surname.getText().toString();
            int _keys = OrgProfile._selectedKey;
            boolean rightToVote = hasRightToVote.isChecked();
            String _weight = rightToVote ? "1" : "0";
            String _email = email.getText().toString();
            String _slogan = slogan.getText().toString();
            boolean external = false;

            if (constituent == null) {
                D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID,
                        external, _weight, _slogan, OrgProfile.__keys[_keys].cipher,
                        OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null);

                Log.d(TAG, "saved constituent=" + new_const.getNameFull());
                try {
                    // Identity.DEBUG = true;
                    Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID);
                } catch (P2PDDSQLException e) {
                    e.printStackTrace();
                }
                Log.d(TAG, "saved new constituent=" + new_const);
                constituent = new_const;
            } else {
                constituent = D_Constituent.getConstByConst_Keep(constituent);
                constituent.setEmail(_email);
                constituent.setForename(_forename);
                constituent.setSurname(_surname);
                constituent.setWeight(rightToVote);
                constituent.setSlogan(_slogan);
                constituent.setExternal(false);
                constituent.setCreationDate();
                constituent.sign();
                if (constituent.dirty_any())
                    constituent.storeRequest();
                constituent.releaseReference();
                Log.d(TAG, "saved constituent=" + constituent);
                try {
                    // Identity.DEBUG = true;
                    Identity.setCurrentConstituentForOrg(constituent.getLID(), oLID);
                } catch (P2PDDSQLException e) {
                    e.printStackTrace();
                }
                Log.d(TAG, "saved constituent=" + constituent.getLID() + " oLID=" + oLID);
            }
            if (constituent != null) {
                constituent = D_Constituent.getConstByConst_Keep(constituent);
                if (constituent != null) {
                    if (constituent.getSK() != null) {
                        constituent.setPicture(byteIcon);
                        constituent.setCreationDate();
                        constituent.sign();
                        constituent.storeRequest();
                        constituent.releaseReference();
                        Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
                    }
                }
            }

            if (!org.getBroadcasted()) {
                D_Organization _org = D_Organization.getOrgByOrg_Keep(org);
                if (_org != null) {
                    _org.setBroadcasting(true);
                    if (_org.dirty_any())
                        _org.storeRequest();
                    _org.releaseReference();
                    org = _org;
                }
            }
            Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
            Log.d(TAG, "saved constituent Done");
            finish();
        }
    });
    submit_new.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String _forename = forename.getText().toString();
            String _surname = surname.getText().toString();
            int _keys = OrgProfile._selectedKey;
            boolean rightToVote = hasRightToVote.isChecked();
            String _weight = rightToVote ? "1" : "0";
            String _email = email.getText().toString();
            String _slogan = slogan.getText().toString();
            boolean external = false;

            D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID,
                    external, _weight, _slogan, OrgProfile.__keys[_keys].cipher,
                    OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null);

            Log.d(TAG, "saved constituent=" + new_const.getNameFull());
            try {
                // Identity.DEBUG = true;
                Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID);
                Log.d("CONST", "No Set: oLID=" + oLID + " c=" + new_const.getLID());
            } catch (P2PDDSQLException e) {
                e.printStackTrace();
            }
            constituent = new_const;
            constituent_LID = new_const.getLID();
            if (constituent_LID > 0) {
                constituent = D_Constituent.getConstByLID(constituent_LID, true, true);
                Log.d(TAG, "Got const: " + constituent);
            }

            if (constituent != null) {
                if (constituent.getSK() != null) {
                    constituent.setPicture(byteIcon);
                    constituent.setCreationDate();
                    constituent.sign();
                    constituent.storeRequest();
                    constituent.releaseReference();
                    Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
                }
            }

            if (!org.getBroadcasted()) {
                D_Organization _org = D_Organization.getOrgByOrg_Keep(org);
                if (_org != null) {
                    _org.setBroadcasting(true);
                    if (_org.dirty_any())
                        _org.storeRequest();
                    _org.releaseReference();
                    org = _org;
                }
            }
            Log.d(TAG, "saved constituent=" + new_const);
            finish();
        }
    });
}

From source file:general.me.edu.dgtmovil.dgtmovil.formregisestudiante.FormEstudDosFragment.java

public void fijarOpciones(String orden, Spinner pre) {
    Object[] list = null;/*from   w w  w .j  ava2  s .  c  o m*/
    ArrayAdapter<Object> adapterOp;
    Pregunta pregunta = getPregunta(orden);
    list = getOpciones(pregunta.ID_PREGUNTA);
    if (list != null && list.length > 0) {
        adapterOp = new ArrayAdapter<Object>(getActivity(), R.layout.spinner_item, list);

        pre.setAdapter(adapterOp);
    }

}

From source file:com.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;/* www.  j  ava 2  s  .co  m*/
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}