Example usage for android.widget AdapterView getId

List of usage examples for android.widget AdapterView getId

Introduction

In this page you can find the example usage for android.widget AdapterView getId.

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    switch (adapterView.getId()) {
    case R.id.sp_centers:
        centerId = centerNameIdHashMap.get(centerNames.get(i));
        if (centerId != -1) {
            inflateGroupSpinner(centerId);
        } else {//w w w . ja v a 2 s. c  om
            Toaster.show(rootView, getString(R.string.error_select_center));
        }
        break;

    case R.id.sp_staff:
        staffId = staffNameIdHashMap.get(staffNames.get(i));
        if (staffId != -1) {
            inflateCenterSpinner(officeId, staffId);
            inflateGroupSpinner(officeId, staffId);
        } else {
            Toaster.show(rootView, getString(R.string.error_select_staff));
        }
        break;

    case R.id.sp_branch_offices:
        officeId = officeNameIdHashMap.get(officeNames.get(i));
        if (officeId != -1) {
            inflateStaffSpinner(officeId);
            inflateCenterSpinner(officeId, -1);
            inflateGroupSpinner(officeId, -1);
        } else {
            Toaster.show(rootView, getString(R.string.error_select_office));
        }
        break;

    case R.id.sp_groups:
        groupId = groupNameIdHashMap.get(groupNames.get(i));
        break;

    }
}

From source file:com.jefftharris.passwdsafe.sync.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.i(TAG, "onCreate");

    OnItemSelectedListener freqSelListener = new OnItemSelectedListener() {
        @Override/*ww  w.j  a v a  2 s.  c o  m*/
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (parent.getId()) {
            case R.id.gdrive_interval: {
                onGdriveFreqChanged(position);
                break;
            }
            case R.id.dropbox_interval: {
                onDropboxFreqChanged(position);
                break;
            }
            case R.id.box_interval: {
                onBoxFreqChanged(position);
                break;
            }
            case R.id.onedrive_interval: {
                onOnedriveFreqChanged(position);
                break;
            }
            }
        }

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

    for (int id : new int[] { R.id.box_interval, R.id.dropbox_interval, R.id.gdrive_interval,
            R.id.onedrive_interval }) {
        Spinner freqSpin = (Spinner) findViewById(id);
        assert freqSpin != null;
        freqSpin.setOnItemSelectedListener(freqSelListener);
    }

    itsPermissionMgr = new DynamicPermissionMgr(Manifest.permission.GET_ACCOUNTS, this, PERMISSIONS_RC,
            APP_SETTINGS_RC, "com.jefftharris.passwdsafe.sync", R.id.reload, R.id.app_settings);
    View noPermGroup = findViewById(R.id.no_permission_group);
    GuiUtils.setVisible(noPermGroup, !itsPermissionMgr.checkPerms());

    // Check the state of Google Play services
    GoogleApiAvailability googleApi = GoogleApiAvailability.getInstance();
    int rc = googleApi.isGooglePlayServicesAvailable(this);
    if (rc != ConnectionResult.SUCCESS) {
        googleApi.showErrorDialogFragment(this, rc, GDRIVE_PLAY_SERVICES_ERROR_RC);
    }

    updateGdriveAccount(null);
    updateDropboxAccount(null);
    updateBoxAccount(null);
    updateOnedriveAccount(null);
    updateOwncloudAccount(null);
    LoaderManager lm = getSupportLoaderManager();
    lm.initLoader(LOADER_PROVIDERS, null, this);
}

From source file:org.deviceconnect.android.manager.setting.ReqResDebugActivity.java

@Override
public void onItemSelected(final AdapterView<?> parent, final View v, final int position, final long pos) {
    int id = parent.getId();
    Spinner spinner = (Spinner) parent;//w w  w.ja va  2s .co  m
    if (id == R.id.reqProfile) {
        String profileName = spinner.getSelectedItem().toString();
        if (!profileName.equals("")) {
            int resInterfacesId = getResources().getIdentifier(profileName + "_interface_list", "array",
                    getPackageName());
            ArrayAdapter<CharSequence> adapterInterfaces = ArrayAdapter.createFromResource(this,
                    resInterfacesId, android.R.layout.simple_spinner_item);
            adapterInterfaces.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            mInter.setAdapter(adapterInterfaces);
            int resAttributeId = getResources().getIdentifier(profileName + "_attrib_list", "array",
                    getPackageName());
            ArrayAdapter<CharSequence> adapterAttribute = ArrayAdapter.createFromResource(this, resAttributeId,
                    android.R.layout.simple_spinner_item);
            adapterInterfaces.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            mAttrib.setAdapter(adapterAttribute);
        }
    }
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsFragment.java

@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
    if (arg0.getId() == R.id.resultListResultNonExpandable) {
        if ((model.getNearResp() != null) && (model.getNearResp().getTheaterList() != null)) {
            int theaterListSize = model.getNearResp().getTheaterList().size();
            if (theaterListSize == position) {
                model.setStart(model.getStart() + 10);
                try {
                    interaction.getTracker().trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_RESULT // Category
                            , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                            , CineShowtimeCst.ANALYTICS_LABEL_RESULTS_MORE_RESULTS // Label
                            , 0 // Value
                    );// w  ww .j  a va 2 s .c  om
                    launchNearService();
                } catch (UnsupportedEncodingException e) {
                    // TODO
                }
            } else {
                if (nonExpendable) {
                    if (resultListNonExpandable
                            .getChildAt(adapterNonExpendable.getSelectedPosition()) != null) {
                        resultListNonExpandable.getChildAt(adapterNonExpendable.getSelectedPosition())
                                .setBackgroundDrawable(null);
                    }
                    adapterNonExpendable.setSelectedPosition(position);
                    view.setBackgroundColor(R.color.select_color);
                }
                model.getGroupExpanded().clear();
                model.getGroupExpanded().add(position);
                if (!movieView) {
                    interaction.onTheaterClick(model.getNearResp().getTheaterList().get(position));
                } else if (nonExpendable) {
                    interaction.onMovieClick(adapterNonExpendable.getMovieList().get(position));
                }
            }
        }
    }

}

From source file:joshuatee.wx.ModelInterfaceActivity.java

public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    if (spinner1_ran && spinner2_ran && spinner_sector_ran) {
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {/*from   w  w w .  ja  v  a 2s.  co  m*/

        switch (parent.getId()) {

        case R.id.spinner1:

            if (!spinner1_ran) {
                spinner1_ran = true;
            }
            break;
        case R.id.spinner2:
            if (!spinner2_ran) {
                spinner2_ran = true;
            }
            break;
        case R.id.spinner_sector:
            if (!spinner_sector_ran) {
                spinner_sector_ran = true;
            }
            break;
        }
    }

}

From source file:com.tcl.lzhang1.mymusic.ui.MusicListAcitivity.java

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub
    Bundle bundle = null;//  w  w w  .java 2s  .co m
    switch (arg0.getId()) {
    case R.id.music_list: {
        if (null == mSongs || mSongs.isEmpty()) {
            return;
        }
        bundle = new Bundle();
        bundle.putSerializable("songs", new SongsWrap(mSongs));
        if (curStartMode == START_MODE_LOCAL)
            bundle.putInt("index", arg2 - 1);
        else {
            bundle.putInt("index", arg2);
            sendPlayListChanedBroadCast();
        }

        bundle.putInt("time", 0);
        // Log.d(TAG, "msongs:" + mSongs.toString());
        UIHelper.showMusicPlayActivity(this, bundle);
        bundle = null;
    }
        break;
    case R.id.music_list_singer:
        if (mSingers == null || mSingers.isEmpty()) {
            return;
        }
        bundle = new Bundle();
        bundle.putInt("startmode", START_MODE_SINGER);
        SingerModel model = mSingers.get(arg2);
        if (null == model) {
            return;
        }
        bundle.putString("singername", model.getSinger_name());
        UIHelper.showMusicListActivity(this, bundle);
        break;

    case R.id.music_list_alubm:

        if (mAblums == null || mAblums.isEmpty()) {
            return;
        }
        bundle = new Bundle();
        bundle.putInt("startmode", START_MODE_ALBUM);
        AlbumModel model1 = mAblums.get(arg2);
        if (null == model1) {
            return;
        }
        bundle.putString("albumname", model1.getAlbum_name());
        UIHelper.showMusicListActivity(this, bundle);
        break;
    default:
        break;
    }
}

From source file:edu.princeton.jrpalmer.asmlibrary.Settings.java

@Override
protected void onResume() {

    if (Util.trafficCop(this))
        finish();/*from w  w  w .jav a 2  s  .  c  o  m*/
    IntentFilter uploadFilter;
    uploadFilter = new IntentFilter(
            getResources().getString(R.string.internal_message_id) + Util.MESSAGE_FIX_UPLOADED);
    uploadReceiver = new UploadReceiver();
    registerReceiver(uploadReceiver, uploadFilter);

    IntentFilter fixFilter;
    fixFilter = new IntentFilter(
            getResources().getString(R.string.internal_message_id) + Util.MESSAGE_FIX_RECORDED);
    fixReceiver = new FixReceiver();
    registerReceiver(fixReceiver, fixFilter);

    shareMyData = PropertyHolder.getShareData();

    toggleParticipationViews(shareMyData);

    int nUploads = PropertyHolder.getNUploads();

    final long participationTime = PropertyHolder.ptCheck();
    participationTimeText.setBase(SystemClock.elapsedRealtime() - participationTime);

    // service button
    boolean isServiceOn = PropertyHolder.isServiceOn();

    mServiceButton.setChecked(isServiceOn);
    mServiceButton.setOnClickListener(new ToggleButton.OnClickListener() {
        public void onClick(View view) {
            if (view.getId() != R.id.service_button)
                return;
            Context context = view.getContext();
            boolean on = ((ToggleButton) view).isChecked();
            String schedule = on ? Util.MESSAGE_SCHEDULE : Util.MESSAGE_UNSCHEDULE;
            // Log.e(TAG, schedule + on);

            // now schedule or unschedule
            Intent intent = new Intent(getString(R.string.internal_message_id) + schedule);
            context.sendBroadcast(intent);
            showSpinner(on, storeMyData);

            if (on && shareMyData) {
                final long ptNow = PropertyHolder.ptStart();
                participationTimeText.setBase(SystemClock.elapsedRealtime() - ptNow);
                participationTimeText.start();

                ContentResolver ucr = getContentResolver();

                ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("ONF",
                        "on," + Util.iso8601(System.currentTimeMillis()) + "," + ptNow));
            } else {

                final long ptNow = PropertyHolder.ptStop();
                participationTimeText.setBase(SystemClock.elapsedRealtime() - ptNow);
                participationTimeText.stop();
                // stop uploader
                Intent stopUploaderIntent = new Intent(Settings.this, FileUploader.class);
                // Stop service if it is currently running
                stopService(stopUploaderIntent);

                if (shareMyData) {

                    ContentResolver ucr = getContentResolver();

                    ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("ONF",
                            "off," + Util.iso8601(System.currentTimeMillis()) + "," + ptNow));

                }

            }
            // If user turns CountdownDisplay on but GPS is not on, remind
            // user to turn
            // GPS on
            if (on) {
                final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

                if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                    if (!manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
                        buildAlertMessageNoGpsNoNet();
                    } else
                        buildAlertMessageNoGps();
                }
            }

            return;
        }
    });

    // interval spinner
    int intspinner_item = android.R.layout.simple_spinner_item;
    int dropdown_item = android.R.layout.simple_spinner_dropdown_item;
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.interval_array,
            intspinner_item);
    adapter.setDropDownViewResource(dropdown_item);
    mIntervalSpinner.setAdapter(adapter);
    mIntervalSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
            int parentId = parent.getId();
            if (parentId != R.id.spinner_interval)
                return;
            if (pos > mInterval.length)
                return;
            if (!PropertyHolder.isServiceOn()) {
                PropertyHolder.setAlarmInterval(mInterval[pos]);
                return;
            }
            PropertyHolder.setAlarmInterval(mInterval[pos]);
            mServiceButton.setChecked(true);

            Intent intent = new Intent(getString(R.string.internal_message_id) + Util.MESSAGE_SCHEDULE);
            Context context = getApplicationContext();
            context.sendBroadcast(intent);
            showSpinner(true, storeMyData);

            if (shareMyData) {
                ContentResolver ucr = getContentResolver();

                ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("INT",
                        Util.iso8601(System.currentTimeMillis()) + "," + mInterval[pos]));
            }
        }

        public void onNothingSelected(AdapterView<?> parent) {
            // do nothing
        }
    });
    int pos = ai2pos(PropertyHolder.getAlarmInterval());
    mIntervalSpinner.setSelection(pos);
    showSpinner(isServiceOn, storeMyData);

    // mydata buttons

    // storage spinner

    storageDays = PropertyHolder.getStorageDays();

    mStorageSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
            int parentId = parent.getId();
            if (parentId != R.id.spinner_mydata)
                return;
            if (pos > MAX_STORAGE - MIN_STORAGE)
                return;
            PropertyHolder.setStorageDays(pos + MIN_STORAGE);
            PropertyHolder.setStoreMyData((pos + MIN_STORAGE) > 0);
        }

        public void onNothingSelected(AdapterView<?> parent) {
            // do nothing
        }
    });
    int storagepos = storageDays - MIN_STORAGE;
    mStorageSpinner.setSelection(storagepos);

    // NEW STUFF
    mToggleSatRadioGroup = (RadioGroup) findViewById(R.id.toggleSatRadioGroup);
    mToggleIconsRadioGroup = (RadioGroup) findViewById(R.id.toggleIconsRadioGroup);
    mToggleAccRadioGroup = (RadioGroup) findViewById(R.id.toggleAccRadioGroup);
    mLimitStartDateRadioGroup = (RadioGroup) findViewById(R.id.limitStartDateRadioGroup);
    mLimitEndDateRadioGroup = (RadioGroup) findViewById(R.id.limitEndDateRadioGroup);

    Intent i = getIntent();
    if (i.getBooleanExtra(MapMyData.DATES_BUTTON_MESSAGE, false)) {

        RelativeLayout dateSettingsArea = (RelativeLayout) findViewById(R.id.dateSettingsArea);
        dateSettingsArea.setFocusable(true);
        dateSettingsArea.setFocusableInTouchMode(true);
        dateSettingsArea.requestFocus();
    }

    if (shareMyData && isServiceOn) {
        participationTimeText.setBase(SystemClock.elapsedRealtime() - PropertyHolder.ptStart());
        participationTimeText.start();
    }

    nUploadsText.setText(String.valueOf(nUploads));

    if (nUploads >= Util.UPLOADS_TO_PRO && !PropertyHolder.getProVersion()
            && participationTime >= Util.TIME_TO_PRO) {
        Util.createProNotification(context);
        PropertyHolder.setProVersion(true);
        PropertyHolder.setNeedsDebriefingSurvey(true);
    }

    boolean proV = PropertyHolder.getProVersion();

    // 19 December 2013: end of research changes
    mShareDataRadioGroup.check(R.id.sharedataNo);

    mShareDataRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.sharedataYes) {
                buildSharingOverAnnouncement();
            }
            mShareDataRadioGroup.check(R.id.sharedataNo);
        }
    });

    /*
     * if (proV) {
     * 
     * if (shareMyData) { mShareDataRadioGroup.check(R.id.sharedataYes); if
     * (PropertyHolder.isRegistered() == false ||
     * PropertyHolder.hasConsented() == false) { send2Intro(context); } }
     * else { mShareDataRadioGroup.check(R.id.sharedataNo); }
     * 
     * mShareDataRadioGroup .setOnCheckedChangeListener(new
     * OnCheckedChangeListener() {
     * 
     * @Override public void onCheckedChanged(RadioGroup group, int
     * checkedId) { shareMyData = (checkedId == R.id.sharedataYes);
     * PropertyHolder.setShareData(shareMyData);
     * toggleParticipationViews(shareMyData); final boolean on =
     * PropertyHolder.isServiceOn(); if (shareMyData) { if
     * (PropertyHolder.isRegistered() == false ||
     * PropertyHolder.hasConsented() == false) { send2Intro(context);
     * 
     * } if (on) {
     * 
     * final long ptNow = PropertyHolder.ptStart();
     * participationTimeText.setBase(SystemClock .elapsedRealtime() -
     * ptNow);
     * 
     * participationTimeText.start();
     * 
     * ContentResolver ucr = getContentResolver();
     * 
     * ucr.insert( Util.getUploadQueueUri(context),
     * UploadContentValues.createUpload( "ONF", "on," + Util.iso8601(System
     * .currentTimeMillis()) + "," + ptNow));
     * 
     * } } else {
     * 
     * final long ptNow = PropertyHolder.ptStop();
     * participationTimeText.setBase(SystemClock .elapsedRealtime() -
     * ptNow); participationTimeText.stop(); // stop uploader Intent i = new
     * Intent(Settings.this, FileUploader.class); // Stop service if it is
     * currently running stopService(i);
     * 
     * if (on) { ContentResolver ucr = getContentResolver();
     * 
     * ucr.insert( Util.getUploadQueueUri(context),
     * UploadContentValues.createUpload( "ONF", "off," + Util.iso8601(System
     * .currentTimeMillis()) + "," + ptNow));
     * 
     * }
     * 
     * }
     * 
     * } }); } else { mShareDataRadioGroup.check(R.id.sharedataYes);
     * mShareDataRadioGroup .setOnCheckedChangeListener(new
     * OnCheckedChangeListener() {
     * 
     * @Override public void onCheckedChanged(RadioGroup group, int
     * checkedId) { if (checkedId == R.id.sharedataNo) {
     * mShareDataRadioGroup.check(R.id.sharedataYes);
     * showCurrentlySharingDialog(); } } });
     * 
     * }
     */
    new CheckPendingUploadsSizeTask().execute(context);
    new CheckUserDbSizeTask().execute(context);

    deletePendingUploadsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ContentResolver cr = getContentResolver();
            final int nDeleted = cr.delete(Util.getUploadQueueUri(context), "1", null);

            // Log.i("Settings", "number of rows deleted=" + nDeleted);
            Util.toast(context, String.valueOf(nDeleted) + " "
                    + getResources().getString(R.string.locations_deleted) + ".");

            updateStorageSizes();

        }

    });

    deleteUserDbButton = (ImageButton) findViewById(R.id.deleteMyDbButton);

    deleteUserDbButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ContentResolver cr = getContentResolver();
            final int nDeleted = cr.delete(Util.getFixesUri(context), "1", null);

            Util.toast(context, String.valueOf(nDeleted) + " "
                    + getResources().getString(R.string.locations_deleted) + ".");
            updateStorageSizes();

        }

    });

    uploadButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (Util.isOnline(context)) {
                Intent i = new Intent(Settings.this, FileUploader.class);
                startService(i);

                new UploadMessageTask().execute(context);
            } else {
                Util.toast(context, getResources().getString(R.string.offline_warning));
            }

        }

    });

    mToggleSatRadioGroup.check(PropertyHolder.getMapSat() ? R.id.toggleSatYes : R.id.toggleSatNo);

    mToggleSatRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            PropertyHolder.setMapSat(checkedId == R.id.toggleSatYes);
        }
    });

    mToggleIconsRadioGroup.check(PropertyHolder.getMapIcons() ? R.id.toggleIconsYes : R.id.toggleIconsNo);

    mToggleIconsRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            PropertyHolder.setMapIcons(checkedId == R.id.toggleIconsYes);
        }
    });

    mToggleAccRadioGroup.check(PropertyHolder.getMapAcc() ? R.id.toggleAccYes : R.id.toggleAccNo);

    mToggleAccRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            PropertyHolder.setMapAcc(checkedId == R.id.toggleAccYes);
        }
    });

    mStartDateButton = (Button) findViewById(R.id.startDateButton);
    mEndDateButton = (Button) findViewById(R.id.endDateButton);

    boolean limitStartDate = PropertyHolder.getLimitStartDate();
    boolean limitEndDate = PropertyHolder.getLimitEndDate();

    if (!limitStartDate)
        mStartDateButton.setVisibility(View.GONE);
    else {
        mStartDateButton.setVisibility(View.VISIBLE);

    }
    if (!limitEndDate)
        mEndDateButton.setVisibility(View.GONE);
    else {
        mEndDateButton.setVisibility(View.VISIBLE);
    }

    mLimitStartDateRadioGroup.check(limitStartDate ? R.id.limitStartDateYes : R.id.limitStartDateNo);

    mLimitStartDateRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            PropertyHolder.setLimitStartDate(checkedId == R.id.limitStartDateYes);

            if (checkedId != R.id.limitStartDateYes)
                mStartDateButton.setVisibility(View.GONE);
            else {
                mStartDateButton.setVisibility(View.VISIBLE);
            }
        }
    });

    mLimitEndDateRadioGroup.check(limitEndDate ? R.id.limitEndDateYes : R.id.limitEndDateNo);

    mLimitEndDateRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            PropertyHolder.setLimitEndDate(checkedId == R.id.limitEndDateYes);

            if (checkedId != R.id.limitEndDateYes)
                mEndDateButton.setVisibility(View.GONE);
            else {
                mEndDateButton.setVisibility(View.VISIBLE);
            }
        }
    });

    mStartDateButton.setText(Util.userDateNoTime(PropertyHolder.getMapStartDate()));
    mStartDateButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            DialogFragment newFragment = new StartDatePickerFragment();
            newFragment.show(getSupportFragmentManager(), "datePicker");

        }

    });

    mEndDateButton.setText(Util.userDateNoTime(PropertyHolder.getMapEndDate()));
    mEndDateButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            DialogFragment newFragment = new EndDatePickerFragment();
            newFragment.show(getSupportFragmentManager(), "datePicker");

        }

    });

    if (PropertyHolder.getNeedsDebriefingSurvey()) {
        buildProAnnouncement();
        PropertyHolder.setNeedsDebriefingSurvey(false);
    }

    super.onResume();

}

From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if (parent.getId() != R.id.OperationType) {
        setDirty(true);//from w  w  w. j  a  v  a2  s  .c  om
    }
    switch (parent.getId()) {
    case R.id.Recurrence:
        int visibility = View.GONE;
        if (id > 0) {
            if (ContextCompat.checkSelfPermission(ExpenseEdit.this,
                    Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED) {
                if (PrefKey.NEW_PLAN_ENABLED.getBoolean(true)) {
                    visibility = View.VISIBLE;
                } else {
                    mReccurenceSpinner.setSelection(0);
                    CommonCommands.showContribDialog(this, ContribFeature.PLANS_UNLIMITED, null);
                }
            } else {
                ActivityCompat.requestPermissions(ExpenseEdit.this,
                        new String[] { Manifest.permission.WRITE_CALENDAR },
                        ProtectionDelegate.PERMISSIONS_REQUEST_WRITE_CALENDAR);
            }
        }
        if (mTransaction instanceof Template) {
            mPlanButton.setVisibility(visibility);
            mPlanToggleButton.setVisibility(visibility);
        }
        break;
    case R.id.Method:
        if (id > 0) {
            //ignore first row "no method" merged in
            mMethodsCursor.moveToPosition(position - 1);
            if (!(mTransaction instanceof Template))
                mReferenceNumberText.setVisibility(
                        mMethodsCursor.getInt(mMethodsCursor.getColumnIndexOrThrow(KEY_IS_NUMBERED)) > 0
                                ? View.VISIBLE
                                : View.INVISIBLE);
        } else {
            mTransaction.methodId = null;
            mReferenceNumberText.setVisibility(View.GONE);
        }
        break;
    case R.id.Account:
        final Account account = mAccounts[position];
        if (mTransaction instanceof SplitTransaction && findSplitPartList().getSplitCount() > 0) {
            //call background task for moving parts to new account
            startTaskExecution(TaskExecutionFragment.TASK_MOVE_UNCOMMITED_SPLIT_PARTS,
                    new Long[] { mTransaction.getId() }, account.getId(),
                    R.string.progress_dialog_updating_split_parts);
        } else {
            updateAccount(account);
        }
        break;
    case R.id.OperationType:
        int newType = ((Integer) mOperationTypeSpinner.getItemAtPosition(position));
        if (newType != mOperationType && isValidType(newType)) {
            if (newType == MyExpenses.TYPE_TRANSFER && !checkTransferEnabled(getCurrentAccount())) {
                //reset to previous
                resetOperationType();
            } else if (newType == MyExpenses.TYPE_SPLIT) {
                resetOperationType();
                contribFeatureRequested(ContribFeature.SPLIT_TRANSACTION, null);
            } else {
                restartWithType(newType);
            }
        }
        break;
    case R.id.TransferAccount:
        mTransaction.transfer_account = mTransferAccountSpinner.getSelectedItemId();
        configureTransferInput();
        break;
    }
}