@@ -0,0 +1,1950 @@
+%0D%0Apackage com.uwetrottmann.movies.util;%0D%0A%0D%0Aimport com.jakewharton.apibuilder.ApiException;%0D%0Aimport com.jakewharton.trakt.ServiceManager;%0D%0Aimport com.jakewharton.trakt.TraktException;%0D%0Aimport com.jakewharton.trakt.entities.Movie;%0D%0A%0D%0Aimport android.content.Context;%0D%0Aimport android.os.AsyncTask;%0D%0Aimport android.util.Log;%0D%0A%0D%0Aimport java.util.List;%0D%0A%0D%0Apublic class MoviesUpdateTask extends AsyncTask%3CVoid, Void, Integer%3E %7B%0D%0A%0D%0A    private static final String TAG = %22MoviesUpdateTask%22;%0D%0A%0D%0A    private static final int SUCCESS = 1;%0D%0A%0D%0A    private static final Integer INVALID_CREDENTIALS = -1;%0D%0A%0D%0A    private Context mContext;%0D%0A%0D%0A    public MoviesUpdateTask(Context context) %7B%0D%0A        mContext = context;%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    protected Integer doInBackground(Void... params) %7B%0D%0A        try %7B%0D%0A            // if possible get an auth data so we can return additional%0D%0A            // information (seen, checkins, etc.)%0D%0A            ServiceManager serviceManager;%0D%0A            if (Utils.isTraktCredentialsValid(getContext())) %7B%0D%0A                serviceManager = Utils.getServiceManagerWithAuth(getContext(), false);%0D%0A            %7D else %7B%0D%0A                return INVALID_CREDENTIALS;%0D%0A            %7D%0D%0A%0D%0A            // there will always be a username as the fragment using%0D%0A            // this only loads with valid credentials%0D%0A            List%3CMovie%3E movies = serviceManager.userService()%0D%0A                    .watchlistMovies(Utils.getTraktUsername(getContext())).fire();%0D%0A%0D%0A            for (Movie movie : movies) %7B%0D%0A                // TODO%0D%0A            %7D%0D%0A%0D%0A            return SUCCESS;%0D%0A        %7D catch (TraktException e) %7B%0D%0A            Log.w(TAG, e);%0D%0A            return null;%0D%0A        %7D catch (ApiException e) %7B%0D%0A            Log.w(TAG, e);%0D%0A            return null;%0D%0A        %7D catch (Exception e) %7B%0D%0A            Log.w(TAG, e);%0D%0A            return null;%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    private Context getContext() %7B%0D%0A        return mContext;%0D%0A    %7D%0D%0A%0D%0A%7D%0D%0A

Prepare MoviesUpdateTask.