/*
 * Copyright 2015 Jérémie Boutoille, Jules Cantegril, Hugo Djemaa, Mickael Goubin, David Livet
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package wtf.sur.original.puissante.rapide.automobile.sopracovoit.user;

import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.widget.EditText;
import android.widget.Spinner;

import wtf.sur.original.puissante.rapide.automobile.sopracovoit.BaseActivity;
import wtf.sur.original.puissante.rapide.automobile.sopracovoit.R;

/**
 * Created by MagicMicky on 13/01/2015.
 */
public class UpdatePathActivity extends BaseActivity {

    private EditText city;
    private Spinner sopralist;
    private EditText return_hour;
    private EditText departure_hour;
    private SwitchCompat isDriver;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.city = (EditText) findViewById(R.id.city);
        this.sopralist = (Spinner) findViewById(R.id.sopralist);
        this.departure_hour = (EditText) findViewById(R.id.departure_hour);
        this.return_hour = (EditText) findViewById(R.id.return_hour);
        this.isDriver = (SwitchCompat) findViewById(R.id.driver);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_update_path;
    }
}

@@ -749,24 +749,158 @@
 voit.user;%0A%0A
+import android.app.LoaderManager;%0Aimport android.content.CursorLoader;%0Aimport android.content.Loader;%0Aimport android.database.Cursor;%0A
 import andro
@@ -992,16 +992,59 @@
 itText;%0A
+import android.widget.SimpleCursorAdapter;%0A
 import a
@@ -1211,16 +1211,101 @@
 ovoit.R;
+%0Aimport wtf.sur.original.puissante.rapide.automobile.sopracovoit.data.CovoitContract;
 %0A%0A/**%0A *
@@ -1399,18 +1399,169 @@
 ctivity 
-%7B%0A
+implements LoaderManager.LoaderCallbacks%3CCursor%3E %7B%0A%0A    private static final int WORKPLACE_LOADER = 0;%0A    private SimpleCursorAdapter mWorkplaceAdapter;
 %0A    pri
@@ -1889,24 +1889,25 @@
 .city);%0A
+%0A
         
 this.sop
@@ -1898,21 +1898,16 @@
         
-this.
 sopralis
@@ -1962,323 +1962,1400 @@
     
-this.departure_hour = (EditText) findViewById(R.id.departure_hour);%0A        this.return_hour = (EditText) findViewById(R.id.return_hour);%0A        this.isDriver = (SwitchCompat) findViewById(R.id.driver);%0A    %7D%0A%0A    @Override%0A    protected int getLayoutResource() %7B%0A        return R.layout.activity_update_path;%0A    %7D
+sopralist.setEnabled(false);%0A        mWorkplaceAdapter = new SimpleCursorAdapter(this, R.layout.simple_text_view, null, new String%5B%5D%7BCovoitContract.WorkplaceEntry.COLUMN_NAME%7D, new int%5B%5D%7BR.id.textView%7D, 0);%0A        sopralist.setAdapter(mWorkplaceAdapter);%0A%0A        this.departure_hour = (EditText) findViewById(R.id.departure_hour);%0A        this.return_hour = (EditText) findViewById(R.id.return_hour);%0A        this.isDriver = (SwitchCompat) findViewById(R.id.driver);%0A        getLoaderManager().initLoader(WORKPLACE_LOADER, null, this);%0A    %7D%0A%0A    @Override%0A    public Loader%3CCursor%3E onCreateLoader(int id, Bundle args) %7B%0A        return new CursorLoader(%0A                this,%0A                CovoitContract.WorkplaceEntry.CONTENT_URI,%0A                null,%0A                null,%0A                null,%0A                CovoitContract.WorkplaceEntry.COLUMN_NAME + %22 ASC%22%0A        );%0A    %7D%0A%0A    @Override%0A    public void onLoadFinished(Loader%3CCursor%3E loader, Cursor data) %7B%0A        mWorkplaceAdapter.swapCursor(data);%0A        if (data.getCount() %3E 0) %7B%0A            sopralist.setEnabled(true);%0A        %7D else %7B%0A            sopralist.setEnabled(false);%0A        %7D%0A    %7D%0A%0A%0A    @Override%0A    protected int getLayoutResource() %7B%0A        return R.layout.activity_update_path;%0A    %7D%0A%0A%0A    @Override%0A    public void onLoaderReset(Loader%3CCursor%3E loader) %7B%0A        mWorkplaceAdapter.swapCursor(null);%0A    %7D%0A
 %0A%7D%0A

Add loader workplace