2024年1月1日发(作者:)
public class ProgressRequestBody extends RequestBody { private File mFile; private String mPath; private String mMediaType; private BaseView mListener; private int mEachBufferSize = 1024; public ProgressRequestBody(final File file, String mediaType, BaseView baseView) { mFile = file; mMediaType = mediaType; mListener = baseView; } public ProgressRequestBody(final File file, String mediaType, int eachBufferSize, BaseView baseView) { mFile = file; mMediaType = mediaType; mEachBufferSize = eachBufferSize; mListener = baseView; } @Override public MediaType contentType() { // i want to upload only images return (mMediaType); } @Override public void writeTo(BufferedSink sink) throws IOException { long fileLength = (); byte[] buffer = new byte[mEachBufferSize]; FileInputStream in = new FileInputStream(mFile); long uploaded = 0; try { int read; Handler handler = new Handler(nLooper()); while ((read = (buffer)) != -1) { // update progress on UI thread (new ProgressUpdater(uploaded, fileLength)); uploaded += read; (buffer, 0, read); } } finally { (); } } private class ProgressUpdater implements Runnable { private long mUploaded; private long mTotal; public ProgressUpdater(long uploaded, long total) { mUploaded = uploaded; mTotal = total; } @Override public void run() { ress((int) (100 * mUploaded / mTotal)); } }}5、 定义MainPresenter,并继承BasePresenter
public class DoubleDefault0Adapter implements JsonSerializer
public class OkHttpCookies implements Serializable { private transient final Cookie cookies; private transient Cookie clientCookies; public OkHttpCookies(Cookie cookies) { s = cookies; } public Cookie getCookies() { Cookie bestCookies = cookies; if (clientCookies != null) { bestCookies = clientCookies; } return bestCookies; } private void writeObject(ObjectOutputStream out) throws IOException { bject(()); bject(()); ong(sAt()); bject(()); bject(()); oolean(()); oolean(ly()); oolean(ly()); oolean(tent()); } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String name = (String) ject(); String value = (String) ject(); long expiresAt = ng(); String domain = (String) ject(); String path = (String) ject(); boolean secure = olean(); boolean httpOnly = olean(); boolean hostOnly = olean(); boolean persistent = olean(); r builder = new r(); builder = (name); builder = (value); builder = sAt(expiresAt); builder = hostOnly ? lyDomain(domain) : (domain); builder = (path); builder = secure ? () : builder; builder = httpOnly ? ly() : builder; clientCookies =(); }}(3)创建PersistentCookieStore类public class PersistentCookieStore { private static final String LOG_TAG = "PersistentCookieStore"; private static final String COOKIE_PREFS = "Cookies_Prefs"; private final Map
String encodedCookie = ing(name, null); if (encodedCookie != null) { Cookie decodedCookie = decodeCookie(encodedCookie); if (decodedCookie != null) { if (!nsKey(())) { ((), new ConcurrentHashMap


发布评论