Files
android_development/samples/browseable/NetworkConnect/src/com.example.android.networkconnect/DownloadCallback.java
Trevor Johns 8a66f8cbc0 Update sample prebults for 2017-02 release (nyc-mr1-dev)
developers/samples/android commit: 6f3586bc08b96d14d8f1315f4839ac59aa39798c

Change-Id: I08c9af2d58f1b3314eba807048dc05175a58e164
2017-02-09 00:45:30 -08:00

61 lines
1.9 KiB
Java

/*
* Copyright (C) 2016 The Android Open Source Project
*
* 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 com.example.android.networkconnect;
import android.net.NetworkInfo;
import android.support.annotation.IntDef;
/**
* Sample interface containing bare minimum methods needed for an asynchronous task
* to update the UI Context.
*/
public interface DownloadCallback {
interface Progress {
int ERROR = -1;
int CONNECT_SUCCESS = 0;
int GET_INPUT_STREAM_SUCCESS = 1;
int PROCESS_INPUT_STREAM_IN_PROGRESS = 2;
int PROCESS_INPUT_STREAM_SUCCESS = 3;
}
/**
* Indicates that the callback handler needs to update its appearance or information based on
* the result of the task. Expected to be called from the main thread.
*/
void updateFromDownload(String result);
/**
* Get the device's active network status in the form of a NetworkInfo object.
*/
NetworkInfo getActiveNetworkInfo();
/**
* Indicate to callback handler any progress update.
* @param progressCode must be one of the constants defined in DownloadCallback.Progress.
* @param percentComplete must be 0-100.
*/
void onProgressUpdate(int progressCode, int percentComplete);
/**
* Indicates that the download operation has finished. This method is called even if the
* download hasn't completed successfully.
*/
void finishDownloading();
}