Search in sources :

Example 1 with DbAdapter

use of de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter in project RSAndroidApp by RailwayStations.

the class BaseApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    dbAdapter = new DbAdapter(this);
    dbAdapter.open();
    preferences = getSharedPreferences(PREF_FILE, MODE_PRIVATE);
    // migrate photo owner preference to boolean
    final Object photoOwner = preferences.getAll().get(getString(R.string.PHOTO_OWNER));
    if (photoOwner instanceof String && "YES".equals(photoOwner)) {
        setPhotoOwner(true);
    }
    rsapiClient = new RSAPIClient(getApiUrl(), getEmail(), getPassword());
}
Also used : DbAdapter(de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter) RSAPIClient(de.bahnhoefe.deutschlands.bahnhofsfotos.rsapi.RSAPIClient)

Example 2 with DbAdapter

use of de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter in project RSAndroidApp by RailwayStations.

the class DetailsActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityDetailsBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    baseApplication = (BaseApplication) getApplication();
    rsapiClient = baseApplication.getRsapiClient();
    final DbAdapter dbAdapter = baseApplication.getDbAdapter();
    final Set<String> countryCodes = baseApplication.getCountryCodes();
    countries = dbAdapter.fetchCountriesWithProviderApps(countryCodes);
    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
    binding.details.imageview.setOnClickListener(v -> onPictureClicked());
    binding.details.buttonTakePicture.setOnClickListener(v -> takePicture());
    binding.details.buttonSelectPicture.setOnClickListener(v -> selectPicture());
    binding.details.buttonReportProblem.setOnClickListener(v -> reportProblem());
    binding.details.buttonUpload.setOnClickListener(v -> {
        if (isNotLoggedIn()) {
            Toast.makeText(this, R.string.please_login, Toast.LENGTH_LONG).show();
        } else if (TextUtils.isEmpty(binding.details.etbahnhofname.getText())) {
            Toast.makeText(this, R.string.station_title_needed, Toast.LENGTH_LONG).show();
        } else {
            uploadPhoto();
        }
    });
    binding.details.licenseTag.setMovementMethod(LinkMovementMethod.getInstance());
    // switch off image and license view until we actually have a foto
    binding.details.imageview.setVisibility(View.INVISIBLE);
    binding.details.licenseTag.setVisibility(View.INVISIBLE);
    setPictureButtonsEnabled(false);
    setButtonEnabled(binding.details.buttonReportProblem, false);
    setButtonEnabled(binding.details.buttonUpload, false);
    fullscreen = false;
    readPreferences();
    onNewIntent(getIntent());
}
Also used : DbAdapter(de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter)

Aggregations

DbAdapter (de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter)2 RSAPIClient (de.bahnhoefe.deutschlands.bahnhofsfotos.rsapi.RSAPIClient)1