// Path: disk-restapi-sdk/src/main/java/com/yandex/disk/rest/exceptions/http/HttpCodeException.java
// public class HttpCodeException extends ServerIOException {
// 
//     protected final int code;
//     protected final ApiError response;
// 
//     public HttpCodeException(int code, ApiError response) {
//         super();
//         this.code = code;
//         this.response = response;
//     }
// 
//     public HttpCodeException(int code) {
//         this(code, null);
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public ApiError getResponse() {
//         return response;
//     }
// 
//     @Override
//     public String toString() {
//         return "HttpCodeException{" +
//                 "code=" + code +
//                 ", response=" + response +
//                 '}';
//     }
// }
// 
// Path: disk-restapi-sdk/src/main/java/com/yandex/disk/rest/exceptions/http/UnauthorizedException.java
// public class UnauthorizedException extends HttpCodeException {
//     public UnauthorizedException(int code, ApiError response) {
//         super(code, response);
//     }
// }


import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.yandex.disk.rest.exceptions.http.HttpCodeException;
import com.yandex.disk.rest.exceptions.http.UnauthorizedException;
import java.io.File;
import java.util.List;
        if (data.isEmpty()) {
            Exception ex = ((ListExampleLoader) loader).getException();
            if (ex != null) {
                handleException(ex);
            } else {
                setDefaultEmptyText();
            }
        } else {
            adapter.setData(data);
        }
    }

    private void handleException(Exception ex) {
        if (ex instanceof HttpCodeException) {
            setEmptyText(((HttpCodeException)ex).getResponse().getDescription());
            if (ex instanceof UnauthorizedException) {
                final ExampleActivity activity = ((ExampleActivity) getActivity());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        activity.startLogin();
                    }
                });
            }
        } else {
            setEmptyText(ex.getMessage());
        }
    }

    @Override
// Path: disk-restapi-sdk/src/main/java/com/yandex/disk/rest/exceptions/http/HttpCodeException.java
// public class HttpCodeException extends ServerIOException {
// 
//     protected final int code;
//     protected final ApiError response;
// 
//     public HttpCodeException(int code, ApiError response) {
//         super();
//         this.code = code;
//         this.response = response;
//     }
// 
//     public HttpCodeException(int code) {
//         this(code, null);
//     }
// 
//     public int getCode() {
//         return code;
//     }
// 
//     public ApiError getResponse() {
//         return response;
//     }
// 
//     @Override
//     public String toString() {
//         return "HttpCodeException{" +
//                 "code=" + code +
//                 ", response=" + response +
//                 '}';
//     }
// }
// 
// Path: disk-restapi-sdk/src/main/java/com/yandex/disk/rest/exceptions/http/UnauthorizedException.java
// public class UnauthorizedException extends HttpCodeException {
//     public UnauthorizedException(int code, ApiError response) {
//         super(code, response);
//     }
// }


// Path: app/src/main/java/com/yandex/disk/rest/example/ListExampleFragment.java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.yandex.disk.rest.exceptions.http.HttpCodeException;
import com.yandex.disk.rest.exceptions.http.UnauthorizedException;
import java.io.File;
import java.util.List;

        if (data.isEmpty()) {
            Exception ex = ((ListExampleLoader) loader).getException();
            if (ex != null) {
                handleException(ex);
            } else {
                setDefaultEmptyText();
            }
        } else {
            adapter.setData(data);
        }
    }

    private void handleException(Exception ex) {
        if (ex instanceof HttpCodeException) {
            setEmptyText(((HttpCodeException)ex).getResponse().getDescription());
            if (ex instanceof UnauthorizedException) {
                final ExampleActivity activity = ((ExampleActivity) getActivity());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        activity.startLogin();
                    }
                });
            }
        } else {
            setEmptyText(ex.getMessage());
        }
    }

    @Override
    public void onLoaderReset(Loader<List<ListItem>> loader) {