Search in sources :

Example 1 with BaseApplication

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

the class CountryAdapter method bindView.

// wird nicht benutzt, ersetzt durch getView()
@Override
public void bindView(View view, Context context, Cursor cursor) {
    BaseApplication baseApplication = BaseApplication.getInstance();
    String prefCountry = baseApplication.getCountryShortCode();
    //If you want to have zebra lines color effect uncomment below code
    if (cursor.getPosition() % 2 == 1) {
        view.setBackgroundResource(R.drawable.item_list_backgroundcolor);
    } else {
        view.setBackgroundResource(R.drawable.item_list_backgroundcolor2);
    }
    CountryAdapter.ViewHolder holder = (CountryAdapter.ViewHolder) view.getTag();
    holder.txtCountryShortCode.setText(cursor.getString(cursor.getColumnIndex(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYSHORTCODE)));
    holder.txtCountryName.setText(cursor.getString(cursor.getColumnIndex(Constants.DB_JSON_CONSTANTS.KEY_COUNTRYNAME)));
    Log.i(TAG, cursor.getString(1) + " " + prefCountry);
    if (cursor.getString(1).equals(prefCountry)) {
        holder.checkCountry.setChecked(true);
    } else if (selectedPosition == cursor.getPosition()) {
        holder.checkCountry.setChecked(true);
        baseApplication.setCountryShortCode(cursor.getString(1));
    } else {
        holder.checkCountry.setChecked(false);
    }
    holder.checkCountry.setOnClickListener(onStateChangedListener(holder.checkCountry, cursor.getPosition()));
}
Also used : BaseApplication(de.bahnhoefe.deutschlands.bahnhofsfotos.BaseApplication)

Aggregations

BaseApplication (de.bahnhoefe.deutschlands.bahnhofsfotos.BaseApplication)1