Example usage for android.widget TextView setBackgroundColor

List of usage examples for android.widget TextView setBackgroundColor

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:truckerboys.otto.utils.tabs.SlidingTabLayout.java

private void populateTabStrip() {

    Log.w("PAGER", "POPULATE TABS!");
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*  www.j  av a  2 s  .  co  m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setBackgroundColor(Color.TRANSPARENT);
        tabTitles.add(tabTitleView);
        tabTitleColor = tabTitleView.getCurrentTextColor();
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.pukulab.puku0x.gscalendar.CalendarActivity.java

@Override
public void onDayClick(final long dayInMillis) {
    // Reset the previously selected TextView to his previous Typeface
    if (mSelectedTextView != null) {
        mSelectedTextView.setTypeface(mSelectedTypeface);
        mSelectedTextView.setBackgroundColor(getResources().getColor(android.R.color.background_light));
    }//from  www.  j  a v  a2s . c  o  m

    final TextView day = mCalendarView.getTextViewForDate(dayInMillis);
    if (day != null) {
        // Remember the selected TextView and it's font
        mSelectedTypeface = day.getTypeface();
        mSelectedTextView = day;

        // Show the selected TextView as bold
        day.setTypeface(Typeface.DEFAULT_BOLD);
        day.setBackgroundColor(getResources().getColor(R.color.theme_color_transparent));
    }

    // ?
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(dayInMillis);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    mDisplayedDate = calendar.getTime();

    // 
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //actionBar.setDisplayHomeAsUpEnabled(true);
        //actionBar.setTitle(mDisplayedUser.name);
        actionBar.setSubtitle(DateFormat.format(getString(R.string.date_year_month_day), mDisplayedDate));
    }

    // ?
    mDailyScheduleList.clear();

    for (ScheduleData d : mScheduleDataList) {
        if (d.date.equals(mDisplayedDate)) {
            // 
            //TextView tv_date = (TextView) findViewById(R.id.tv_schedule_date);
            //tv_date.setText(DateFormat.format(getString(R.string.date_month_day_week), d.date));
            // ????
            if (!d.scheduleList.isEmpty()) {
                mDailyScheduleList.addAll(d.scheduleList);
            }
        }
    }
    mDailyScheduleaListAdapter.notifyDataSetChanged();
}

From source file:com.pacoapp.paco.ui.MyExperimentsActivity.java

private TextView setListHeader() {
    TextView listHeader = (TextView) findViewById(R.id.ExperimentListTitle);
    String header = getString(R.string.your_current_experiments);
    listHeader.setText(header);/*from  w  ww.ja  v a 2s  .c o m*/
    listHeader.setTextSize(25);
    listHeader.setBackgroundColor(0xffdddddd);
    return listHeader;
}

From source file:com.unkonw.testapp.libs.view.indicator.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);//ww  w.  j a v a  2  s . c o m
        } else {
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == 0) {
                tab.setTextSize(14);
                selectedBackground(tab);
                tab.setTextColor(getResources().getColor(indexColor));
            }

            else {
                tab.setBackgroundColor(backGroundColor);
                tab.setTextColor(tabTextColor);
                tab.setTextSize(tabTextSize);
            }

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.hardcopy.retroband.MainActivity.java

public void procesarXYZ(int[] accel) {
    if (accel == null || accel.length < 3)
        return;/* w  w  w  .j a v a2s . c  o  m*/
    // Viene un arreglo de [x1,y1,z1,x2,y2,z2,x3,y3,z3,...,x_n,y_n,z_n]
    TextView textIndicatorView = (TextView) findViewById(R.id.text_indicador);
    textIndicatorView.setText("Listo");
    textIndicatorView.setBackgroundColor(Color.parseColor("#6495ED")); //Azul

    for (int i = 0; i < accel.length; i += 3) {
        int x = accel[i];
        int y = accel[i + 1];
        int z = accel[i + 2];
        int[] vector = { x, y, z };
        procesarSum(vector);
        appendRecordVector(vector);
        procesarMuestra();//se puede ejecutar en cualquier lado
    }

    if (grabarArchivo == true) {
        guardarDatos(accel);
    } else {
        // actualiza el nombre con la fecha
        Date date = new Date();
        DateFormat hourdateFormat = new SimpleDateFormat("dd_MM_yyyy__HH_mm_ss");
        System.out.println("Hora y fecha: " + hourdateFormat.format(date));
        nombreArchivo = "no_fallout_" + hourdateFormat.format(date) + ".txt";
    }
}

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

@SuppressLint("InlinedApi")
@Override//  ww  w . j  a  v  a 2  s.  co  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.one_account);
    setupToolbar();

    mLabelText = (EditText) findViewById(R.id.Label);
    mDescriptionText = (EditText) findViewById(R.id.Description);

    Bundle extras = getIntent().getExtras();
    long rowId = extras != null ? extras.getLong(DatabaseConstants.KEY_ROWID) : 0;
    requireAccount();
    if (mAccount == null) {
        Toast.makeText(this, "Error instantiating account " + rowId, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    if (rowId != 0) {
        mNewInstance = false;
        setTitle(R.string.menu_edit_account);
        mLabelText.setText(mAccount.label);
        mDescriptionText.setText(mAccount.description);
    } else {
        setTitle(R.string.menu_create_account);
        mAccount = new Account();
        String currency = extras != null ? extras.getString(DatabaseConstants.KEY_CURRENCY) : null;
        if (currency != null)
            try {
                mAccount.setCurrency(currency);
            } catch (IllegalArgumentException e) {
                //if not supported ignore
            }
    }
    configTypeButton();
    mAmountText.setFractionDigits(Money.getFractionDigits(mAccount.currency));

    mCurrencySpinner = new SpinnerHelper(findViewById(R.id.Currency));
    currencyAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1,
            CurrencyEnum.sortedValues());
    currencyAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    mCurrencySpinner.setAdapter(currencyAdapter);

    mAccountTypeSpinner = new SpinnerHelper(findViewById(R.id.AccountType));
    ArrayAdapter<AccountType> typAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            android.R.id.text1, AccountType.values());
    typAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    mAccountTypeSpinner.setAdapter(typAdapter);

    mColorSpinner = new SpinnerHelper(findViewById(R.id.Color));
    mColors = new ArrayList<>();
    Resources r = getResources();
    mColors.add(r.getColor(R.color.material_red));
    mColors.add(r.getColor(R.color.material_pink));
    mColors.add(r.getColor(R.color.material_purple));
    mColors.add(r.getColor(R.color.material_deep_purple));
    mColors.add(r.getColor(R.color.material_indigo));
    mColors.add(r.getColor(R.color.material_blue));
    mColors.add(r.getColor(R.color.material_light_blue));
    mColors.add(r.getColor(R.color.material_cyan));
    mColors.add(r.getColor(R.color.material_teal));
    mColors.add(r.getColor(R.color.material_green));
    mColors.add(r.getColor(R.color.material_light_green));
    mColors.add(r.getColor(R.color.material_lime));
    mColors.add(r.getColor(R.color.material_yellow));
    mColors.add(r.getColor(R.color.material_amber));
    mColors.add(r.getColor(R.color.material_orange));
    mColors.add(r.getColor(R.color.material_deep_orange));
    mColors.add(r.getColor(R.color.material_brown));
    mColors.add(r.getColor(R.color.material_grey));
    mColors.add(r.getColor(R.color.material_blue_grey));

    if (mColors.indexOf(mAccount.color) == -1)
        mColors.add(mAccount.color);

    mColAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item, mColors) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView tv = (TextView) super.getView(position, convertView, parent);
            if (mColors.get(position) != 0)
                setColor(tv, mColors.get(position));
            else
                setColor(tv, mAccount.color);
            return tv;
        }

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            TextView tv = (TextView) super.getDropDownView(position, convertView, parent);
            if (mColors.get(position) != 0)
                setColor(tv, mColors.get(position));
            return tv;
        }

        public void setColor(TextView tv, int color) {
            tv.setBackgroundColor(color);
            tv.setText("");
            tv.setContentDescription(getString(R.string.color));
        }
    };
    mColAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mColorSpinner.setAdapter(mColAdapter);
    linkInputsWithLabels();
    populateFields();
}

From source file:com.google.android.apps.santatracker.launch.TvStartupActivity.java

private void addDebugMenuListRaw(ArrayObjectAdapter objectAdapter) {

    mMarkers.setPadding(mMarkers.getPaddingLeft(), mMarkers.getPaddingTop() + 150, mMarkers.getPaddingRight(),
            mMarkers.getPaddingBottom());

    Presenter debugMenuPresenter = new Presenter() {
        @Override/*www .  ja  va 2 s . c o m*/
        public ViewHolder onCreateViewHolder(ViewGroup parent) {
            TextView tv = new TextView(parent.getContext());
            ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(200, 150);
            tv.setLayoutParams(params);
            tv.setGravity(Gravity.CENTER);
            tv.setBackgroundColor(getResources().getColor(R.color.SantaBlueDark));
            tv.setFocusableInTouchMode(false);
            tv.setFocusable(true);
            tv.setClickable(true);
            return new ViewHolder(tv);
        }

        @Override
        public void onBindViewHolder(ViewHolder viewHolder, Object item) {
            ((TextView) viewHolder.view).setText((String) item);
            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final String text = ((TextView) v).getText().toString();
                    if (text.contains("Enable Tracker")) {
                        enableTrackerMode(true);
                    } else if (text.contains("Enable CountDown")) {
                        startCountdown(SantaPreferences.getCurrentTime());
                    } else {
                        mIsDebug = false;
                        initialiseViews();
                        resetLauncherStates();
                    }
                }
            });
        }

        @Override
        public void onUnbindViewHolder(ViewHolder viewHolder) {

        }
    };

    ObjectAdapter debugMenuAdapter = new ObjectAdapter(debugMenuPresenter) {

        private final String[] mMenuString = { "Enable Tracker", "Enable CountDown", "Hide DebugMenu" };

        @Override
        public int size() {
            return mMenuString.length;
        }

        @Override
        public Object get(int position) {
            return mMenuString[position];
        }
    };

    ListRow debugMenuListRow = new ListRow(debugMenuAdapter);
    objectAdapter.add(debugMenuListRow);
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) {

    ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>();

    HashMap<String, APInfoMapItem> apMap = wifi.getAps();
    Set<String> keys = apMap.keySet();
    Iterator<String> iter = keys.iterator();
    while (iter.hasNext()) {
        String bssid = iter.next();
        APInfoMapItem ap = apMap.get(bssid);
        items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets));
    }/*from w  w  w  . j av  a2  s.c o  m*/

    Collections.sort(items);

    table.setColumnCollapsed(0, false);
    table.setColumnCollapsed(1, true);
    table.setColumnShrinkable(0, true);

    for (int i = 0; i < mAddedRows.size(); i++) {
        table.removeView(mAddedRows.get(i));
    }
    mAddedRows.clear();

    int totalCount = wifi.getScanCount();

    Context context = getContext();

    for (WifiViewListItem item : items) {
        TableRow row = new TableRow(context);

        TextView ssidView = new TextView(context);
        ssidView.setText(item.ssid);
        //ssidView.setText("very very very veryvery very very very very very");
        ssidView.setPadding(2, 2, 2, 2);
        ssidView.setTextColor(0xffffffff);

        TextView bssidView = new TextView(context);
        bssidView.setText(item.bssid);
        bssidView.setPadding(2, 2, 2, 2);
        bssidView.setTextColor(0xffffffff);

        TextView cntView = new TextView(context);
        cntView.setText("" + (item.count * 100) / totalCount);
        cntView.setPadding(2, 2, 2, 2);
        cntView.setGravity(Gravity.CENTER);
        cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        TextView rssView = new TextView(context);
        rssView.setText("" + item.rss);
        rssView.setPadding(2, 2, 6, 2);
        rssView.setGravity(Gravity.CENTER);
        rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        row.addView(ssidView, new TableRow.LayoutParams(0));
        row.addView(bssidView, new TableRow.LayoutParams(1));
        row.addView(cntView, new TableRow.LayoutParams(2));
        row.addView(rssView, new TableRow.LayoutParams(3));

        //Log.d(TAG, item.ssid);
        for (int i = 0; i < item.rssBuckets.length; i++) {
            TextView box = new TextView(context);
            box.setText("  ");
            box.setGravity(Gravity.RIGHT);
            box.setPadding(2, 2, 2, 2);
            box.setHeight(15);
            box.setGravity(Gravity.CENTER_VERTICAL);

            float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount());
            //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]);
            int colorValInt = ((int) colorVal) - 1;
            if (colorValInt < 0)
                colorValInt = 0;

            box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan));
            box.setTextColor(0xffffffff);

            row.addView(box, new TableRow.LayoutParams(4 + i));
        }

        row.setGravity(Gravity.CENTER);

        table.addView(row, new TableLayout.LayoutParams());
        table.setColumnStretchable(3, true);
        mAddedRows.add(row);
    }

}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Populate the koopman fragment item details item when the loader has finished
 * @param loader the cursor loader//from w w w .  j  a  va  2  s  . co  m
 * @param data data object containing one or more koopman rows with joined sollicitatie data
 */
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        boolean validSollicitatie = false;

        // get the markt id from the sharedprefs
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0);

        // make the koopman details visible
        mKoopmanDetail.setVisibility(View.VISIBLE);

        // check koopman status
        String koopmanStatus = data.getString(data.getColumnIndex("koopman_status"));
        mMeldingVerwijderd = koopmanStatus.equals(getString(R.string.koopman_status_verwijderd));

        // koopman photo
        Glide.with(getContext())
                .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL)))
                .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage);

        // koopman naam
        String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " "
                + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM));
        mKoopmanVoorlettersAchternaamText.setText(naam);

        // koopman erkenningsnummer
        mErkenningsnummer = data
                .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER));
        mErkenningsnummerText.setText(mErkenningsnummer);

        // koopman sollicitaties
        View view = getView();
        if (view != null) {
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder);
            placeholderLayout.removeAllViews();

            // get vaste producten for selected markt, and add multiple markt sollicitatie views to the koopman items
            while (!data.isAfterLast()) {

                // get vaste producten for selected markt
                if (marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    String[] productParams = getResources().getStringArray(R.array.array_product_param);
                    for (String product : productParams) {
                        mProducten.put(product, data.getInt(data.getColumnIndex(product)));
                    }
                }

                // inflate sollicitatie layout and populate its view items
                View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie,
                        null);

                // highlight the sollicitatie for the current markt
                if (data.getCount() > 1 && marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
                }

                // markt afkorting
                String marktAfkorting = data
                        .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING));
                TextView marktAfkortingText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_markt_afkorting);
                marktAfkortingText.setText(marktAfkorting);

                // koopman sollicitatienummer
                String sollicitatienummer = data.getString(
                        data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER));
                TextView sollicitatienummerText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_sollicitatie_nummer);
                sollicitatienummerText.setText(sollicitatienummer);

                // koopman sollicitatie status
                String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status"));
                TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status);
                sollicitatieStatusText.setText(sollicitatieStatus);
                if (sollicitatieStatus != null && !sollicitatieStatus.equals("?")
                        && !sollicitatieStatus.equals("")) {
                    sollicitatieStatusText
                            .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
                    sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(),
                            Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus)));

                    // check if koopman has at least one valid sollicitatie on selected markt
                    if (marktId == data
                            .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                        validSollicitatie = true;
                    }
                }

                // add view and move cursor to next
                placeholderLayout.addView(childLayout, data.getPosition());
                data.moveToNext();
            }
        }

        // check valid sollicitatie
        mMeldingNoValidSollicitatie = !validSollicitatie;

        // get the date of today for the dag param
        SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_dag));
        String dag = sdf.format(new Date());

        // check multiple dagvergunningen
        Cursor dagvergunningen = getContext().getContentResolver().query(
                MakkelijkeMarktProvider.mUriDagvergunningJoined, null,
                "dagvergunning_doorgehaald != '1' AND " + MakkelijkeMarktProvider.mTableDagvergunning + "."
                        + MakkelijkeMarktProvider.Dagvergunning.COL_MARKT_ID + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_DAG + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE + " = ? ",
                new String[] { String.valueOf(marktId), dag, mErkenningsnummer, }, null);
        mMeldingMultipleDagvergunningen = (dagvergunningen != null && dagvergunningen.moveToFirst())
                && (dagvergunningen.getCount() > 1 || mDagvergunningId == -1);
        if (dagvergunningen != null) {
            dagvergunningen.close();
        }

        // callback to dagvergunning activity to updaten the meldingen view
        ((Callback) getActivity()).onMeldingenUpdated();
    }
}

From source file:es.upv.riromu.arbre.main.MainActivity.java

@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState.containsKey("cropping")) {
        state[CROP_IMAGE] = savedInstanceState.getBoolean("cropping");
    }//from  ww  w  .  ja v  a 2 s .c  o m
    if (savedInstanceState.containsKey("treated")) {
        state[TREAT_IMAGE] = savedInstanceState.getBoolean("treated");
    }

    if (savedInstanceState.containsKey("image_uri")) {
        image_uri = Uri.parse(savedInstanceState.getString("image_uri"));
    }

    if (savedInstanceState.getBoolean("image")) {
        String fileName = "temp_image.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            image = Util.decodeScaledBitmapFromFile(file.getPath(), MAX_SIZE, MAX_SIZE);
            //  image = BitmapFactory.decodeStream(imageStream);

        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        }
    }

    if (state[CROP_IMAGE]) {
        String fileName = "temp_cropped.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            croppedimage = BitmapFactory.decodeStream(imageStream);
            imageStream.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }
    }
    if (state[TREAT_IMAGE]) {
        String fileName = "temp_treated.jpg";
        String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath()
                + "/" + fileName;
        File file = new File(fileURL);
        try {
            InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file));
            ImageView imv = (ImageView) findViewById(R.id.image_intro);
            imv.setImageBitmap(BitmapFactory.decodeStream(imageStream));
            imageStream.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }
    }
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    colours = savedInstanceState.getIntArray("colours");
    if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE])
        imv.setImageBitmap(croppedimage);
    else {

        imv.setImageBitmap(image);
    }
    TextView imc = (TextView) findViewById(R.id.textView);
    imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B]));
}