target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testEnrichBooks() throws Exception { BookImportContext bookImportContext = new BookImportContext(new File("src/test/resources/epubs/W. H. Davenport Adams - Some heroes of Travel.epub")); Book book = new BookProducer().produce(bookImportContext); assertThat(book.getFirstAuthor(), is(new Author("Davenport", "Adams W. H."))); }
public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new LanguageScorer().determineBestScore(context).getValue())); book.setIsbn10(new Isbn10Scorer().determineBestScore(context).getValue()); book.setIsbn13(new Isbn13Scorer().determineBestScore(context).getValue()); book.setSummary(new SummaryScorer().determineBestScore(context).getValue()); book.setPublisher(new PublisherScorer().determineBestScore(context).getValue()); book.setPublicationDate(new PublicationDateScorer().determineBestScore(context).getValue()); book.setTags(new TagsScorer().determineBestScore(context).getValue()); Binary epub = getBinaryFromFile(context); book.setEpub(epub); book.setFileSizeInKb(epub.getContents().length / 1024); book.setCover(new CoverScorer().determineBestScore(context).getValue()); book.setContents(getContent(context.getEpubBook().getContents()) ); log.info("Produced book {}", book); return book; }
BookProducer { public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new LanguageScorer().determineBestScore(context).getValue())); book.setIsbn10(new Isbn10Scorer().determineBestScore(context).getValue()); book.setIsbn13(new Isbn13Scorer().determineBestScore(context).getValue()); book.setSummary(new SummaryScorer().determineBestScore(context).getValue()); book.setPublisher(new PublisherScorer().determineBestScore(context).getValue()); book.setPublicationDate(new PublicationDateScorer().determineBestScore(context).getValue()); book.setTags(new TagsScorer().determineBestScore(context).getValue()); Binary epub = getBinaryFromFile(context); book.setEpub(epub); book.setFileSizeInKb(epub.getContents().length / 1024); book.setCover(new CoverScorer().determineBestScore(context).getValue()); book.setContents(getContent(context.getEpubBook().getContents()) ); log.info("Produced book {}", book); return book; } }
BookProducer { public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new LanguageScorer().determineBestScore(context).getValue())); book.setIsbn10(new Isbn10Scorer().determineBestScore(context).getValue()); book.setIsbn13(new Isbn13Scorer().determineBestScore(context).getValue()); book.setSummary(new SummaryScorer().determineBestScore(context).getValue()); book.setPublisher(new PublisherScorer().determineBestScore(context).getValue()); book.setPublicationDate(new PublicationDateScorer().determineBestScore(context).getValue()); book.setTags(new TagsScorer().determineBestScore(context).getValue()); Binary epub = getBinaryFromFile(context); book.setEpub(epub); book.setFileSizeInKb(epub.getContents().length / 1024); book.setCover(new CoverScorer().determineBestScore(context).getValue()); book.setContents(getContent(context.getEpubBook().getContents()) ); log.info("Produced book {}", book); return book; } }
BookProducer { public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new LanguageScorer().determineBestScore(context).getValue())); book.setIsbn10(new Isbn10Scorer().determineBestScore(context).getValue()); book.setIsbn13(new Isbn13Scorer().determineBestScore(context).getValue()); book.setSummary(new SummaryScorer().determineBestScore(context).getValue()); book.setPublisher(new PublisherScorer().determineBestScore(context).getValue()); book.setPublicationDate(new PublicationDateScorer().determineBestScore(context).getValue()); book.setTags(new TagsScorer().determineBestScore(context).getValue()); Binary epub = getBinaryFromFile(context); book.setEpub(epub); book.setFileSizeInKb(epub.getContents().length / 1024); book.setCover(new CoverScorer().determineBestScore(context).getValue()); book.setContents(getContent(context.getEpubBook().getContents()) ); log.info("Produced book {}", book); return book; } Book produce(BookImportContext context); }
BookProducer { public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new LanguageScorer().determineBestScore(context).getValue())); book.setIsbn10(new Isbn10Scorer().determineBestScore(context).getValue()); book.setIsbn13(new Isbn13Scorer().determineBestScore(context).getValue()); book.setSummary(new SummaryScorer().determineBestScore(context).getValue()); book.setPublisher(new PublisherScorer().determineBestScore(context).getValue()); book.setPublicationDate(new PublicationDateScorer().determineBestScore(context).getValue()); book.setTags(new TagsScorer().determineBestScore(context).getValue()); Binary epub = getBinaryFromFile(context); book.setEpub(epub); book.setFileSizeInKb(epub.getContents().length / 1024); book.setCover(new CoverScorer().determineBestScore(context).getValue()); book.setContents(getContent(context.getEpubBook().getContents()) ); log.info("Produced book {}", book); return book; } Book produce(BookImportContext context); }
@Test public void getCode() throws Exception { }
public int getCode() { return code; }
Response { public int getCode() { return code; } }
Response { public int getCode() { return code; } }
Response { public int getCode() { return code; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public int getCode() { return code; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void onPreExecute() throws Exception { }
@Override protected void onPreExecute() { super.onPreExecute(); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPreExecute() { super.onPreExecute(); } }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPreExecute() { super.onPreExecute(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPreExecute() { super.onPreExecute(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPreExecute() { super.onPreExecute(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
@Test public void doInBackground() throws Exception { }
@Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, bitmap); } return bitmap; } catch (Exception e) { e.printStackTrace(); error = true; } return null; }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, bitmap); } return bitmap; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, bitmap); } return bitmap; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, bitmap); } return bitmap; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, bitmap); } return bitmap; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
@Test public void onPostExecute() throws Exception { }
@Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
@Test public void onCancelled() throws Exception { }
@Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }
@Test public void onPreExecute() throws Exception { }
@Override protected void onPreExecute() { super.onPreExecute(); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPreExecute() { super.onPreExecute(); } }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
@Test public void doInBackground() throws Exception { }
@Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
@Test public void onPostExecute() throws Exception { }
@Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
@Test public void onCancelled() throws Exception { }
@Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }
@Test public void getKey() throws Exception { }
public String getKey() { return key; }
RequestParams { public String getKey() { return key; } }
RequestParams { public String getKey() { return key; } }
RequestParams { public String getKey() { return key; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
RequestParams { public String getKey() { return key; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
@Test public void setKey() throws Exception { }
public RequestParams setKey(String key) { this.key = key; return this; }
RequestParams { public RequestParams setKey(String key) { this.key = key; return this; } }
RequestParams { public RequestParams setKey(String key) { this.key = key; return this; } }
RequestParams { public RequestParams setKey(String key) { this.key = key; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
RequestParams { public RequestParams setKey(String key) { this.key = key; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
@Test public void setCode() throws Exception { }
public Response setCode(int code) { this.code = code; return this; }
Response { public Response setCode(int code) { this.code = code; return this; } }
Response { public Response setCode(int code) { this.code = code; return this; } }
Response { public Response setCode(int code) { this.code = code; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public Response setCode(int code) { this.code = code; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void getValue() throws Exception { }
public String getValue() { return value; }
RequestParams { public String getValue() { return value; } }
RequestParams { public String getValue() { return value; } }
RequestParams { public String getValue() { return value; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
RequestParams { public String getValue() { return value; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
@Test public void setValue() throws Exception { }
public RequestParams setValue(String value) { this.value = value; return this; }
RequestParams { public RequestParams setValue(String value) { this.value = value; return this; } }
RequestParams { public RequestParams setValue(String value) { this.value = value; return this; } }
RequestParams { public RequestParams setValue(String value) { this.value = value; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
RequestParams { public RequestParams setValue(String value) { this.value = value; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }
@Test public void getKey() throws Exception { }
public String getKey() { return key; }
HeaderParams { public String getKey() { return key; } }
HeaderParams { public String getKey() { return key; } }
HeaderParams { public String getKey() { return key; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
HeaderParams { public String getKey() { return key; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
@Test public void setKey() throws Exception { }
public HeaderParams setKey(String key) { this.key = key; return this; }
HeaderParams { public HeaderParams setKey(String key) { this.key = key; return this; } }
HeaderParams { public HeaderParams setKey(String key) { this.key = key; return this; } }
HeaderParams { public HeaderParams setKey(String key) { this.key = key; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
HeaderParams { public HeaderParams setKey(String key) { this.key = key; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
@Test public void getValue() throws Exception { }
public String getValue() { return value; }
HeaderParams { public String getValue() { return value; } }
HeaderParams { public String getValue() { return value; } }
HeaderParams { public String getValue() { return value; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
HeaderParams { public String getValue() { return value; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
@Test public void setValue() throws Exception { }
public HeaderParams setValue(String value) { this.value = value; return this; }
HeaderParams { public HeaderParams setValue(String value) { this.value = value; return this; } }
HeaderParams { public HeaderParams setValue(String value) { this.value = value; return this; } }
HeaderParams { public HeaderParams setValue(String value) { this.value = value; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
HeaderParams { public HeaderParams setValue(String value) { this.value = value; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }
@Test public void sizeOf() throws Exception { }
@Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString().getBytes().length; } else { bytesCount = ((JSONArray) data).toString().getBytes().length; } return bytesCount / 1024; }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString().getBytes().length; } else { bytesCount = ((JSONArray) data).toString().getBytes().length; } return bytesCount / 1024; } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString().getBytes().length; } else { bytesCount = ((JSONArray) data).toString().getBytes().length; } return bytesCount / 1024; } CacheManager(int cacheSize); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString().getBytes().length; } else { bytesCount = ((JSONArray) data).toString().getBytes().length; } return bytesCount / 1024; } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString().getBytes().length; } else { bytesCount = ((JSONArray) data).toString().getBytes().length; } return bytesCount / 1024; } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
@Test public void addDataToCache() throws Exception { }
@Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } } CacheManager(int cacheSize); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
@Test public void removeDataFromCache() throws Exception { }
@Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } } CacheManager(int cacheSize); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
@Test public void getDataFromCache() throws Exception { }
@Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); } CacheManager(int cacheSize); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
@Test public void getData() throws Exception { }
public InputStream getData() { return inputStream; }
Response { public InputStream getData() { return inputStream; } }
Response { public InputStream getData() { return inputStream; } }
Response { public InputStream getData() { return inputStream; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public InputStream getData() { return inputStream; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void evictUnused() throws Exception { }
@Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } } }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } } CacheManager(int cacheSize); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override void removeDataFromCache(String key); @Override T getDataFromCache(String key); @Override void evictUnused(); }
@Test public void setCallback() throws Exception { }
public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonArrayTask(method, url, params, headers, mListener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; }
JsonArray extends Type<JSONArray> { public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonArrayTask(method, url, params, headers, mListener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } }
JsonArray extends Type<JSONArray> { public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonArrayTask(method, url, params, headers, mListener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonArray extends Type<JSONArray> { public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonArrayTask(method, url, params, headers, mListener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
JsonArray extends Type<JSONArray> { public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonArrayTask(method, url, params, headers, mListener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
@Test public void cancel() throws Exception { }
public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; }
JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } }
JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
@Test public void setCacheManager() throws Exception { }
public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; }
JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } }
JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); }
@Test public void setCallback() throws Exception { }
public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; }
BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } }
BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
@Test public void cancel() throws Exception { }
public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; }
BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } }
BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
@Test public void setCacheManager() throws Exception { }
public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; }
BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } }
BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); }
@Test public void setCacheManager() throws Exception { }
public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager);
Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); }
Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); }
Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
@Test public void setCallback() throws Exception { }
public abstract Type setCallback(HttpListener<T> callback);
Type { public abstract Type setCallback(HttpListener<T> callback); }
Type { public abstract Type setCallback(HttpListener<T> callback); }
Type { public abstract Type setCallback(HttpListener<T> callback); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
Type { public abstract Type setCallback(HttpListener<T> callback); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
@Test public void cancel() throws Exception { }
public abstract boolean cancel();
Type { public abstract boolean cancel(); }
Type { public abstract boolean cancel(); }
Type { public abstract boolean cancel(); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
Type { public abstract boolean cancel(); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }
@Test public void setData() throws Exception { }
public Response setData(InputStream data) { this.inputStream = data; return this; }
Response { public Response setData(InputStream data) { this.inputStream = data; return this; } }
Response { public Response setData(InputStream data) { this.inputStream = data; return this; } }
Response { public Response setData(InputStream data) { this.inputStream = data; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public Response setData(InputStream data) { this.inputStream = data; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void setCallback() throws Exception { }
public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; }
JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; } }
JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
@Test public void cancel() throws Exception { }
public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; }
JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } }
JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
@Test public void setCacheManager() throws Exception { }
public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; }
JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } }
JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); }
JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); }
@Test public void getDataAsString() throws Exception { }
public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); }
Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); } }
Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); } }
Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void getAsBitmap() throws Exception { }
public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; }
Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } }
Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } }
Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }
@Test public void onPreExecute() throws Exception { }
@Override protected void onPreExecute() { super.onPreExecute(); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
@Test public void doInBackground() throws Exception { }
@Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
@Test public void onPostExecute() throws Exception { }
@Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
@Test public void onCancelled() throws Exception { }
@Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }
@Test public void testSuperfluousData() { byte[] data = new byte[2]; try { SnappyDecompressor.decompress(data); Assert.fail("Exception was expected"); } catch(FormatViolationException e) { Assert.assertEquals(1, e.getOffset()); } }
public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); }
SnappyDecompressor { public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); } }
SnappyDecompressor { public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); } private SnappyDecompressor(); }
SnappyDecompressor { public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); } private SnappyDecompressor(); static Buffer decompress(byte[] in); static Buffer decompress(byte[] in, Buffer out); static Buffer decompress(byte[] in, int offset, int length); static Buffer decompress(Buffer in); static Buffer decompress(Buffer in, Buffer out); static Buffer decompress(byte[] in, int offset, int length, Buffer out); }
SnappyDecompressor { public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); } private SnappyDecompressor(); static Buffer decompress(byte[] in); static Buffer decompress(byte[] in, Buffer out); static Buffer decompress(byte[] in, int offset, int length); static Buffer decompress(Buffer in); static Buffer decompress(Buffer in, Buffer out); static Buffer decompress(byte[] in, int offset, int length, Buffer out); }
@Test public void onDragEnd() throws Exception { WXComponent c = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); mFakeDragHelper.onDragEnd(c,1,2); verify(mockedEventTrigger).triggerEvent(eq("dragend"),anyMap()); }
@Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); }
DefaultDragHelper implements DragHelper { @Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); } }
DefaultDragHelper implements DragHelper { @Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); }
DefaultDragHelper implements DragHelper { @Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); }
DefaultDragHelper implements DragHelper { @Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); }
@Test public void onDragging() throws Exception { assertEquals(mFakeDataSource.get(0),c1); assertEquals(mFakeDataSource.get(1),c2); mFakeDragHelper.onDragging(0,1); assertEquals(mFakeDataSource.get(0),c2); assertEquals(mFakeDataSource.get(1),c1); }
@Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } }
DefaultDragHelper implements DragHelper { @Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } } }
DefaultDragHelper implements DragHelper { @Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); }
DefaultDragHelper implements DragHelper { @Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); }
DefaultDragHelper implements DragHelper { @Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); }
@Test public void testOnRefresh() throws Exception { component.onRefresh(); }
@Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } } }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; }
@Test public void testOnPullingDown() throws Exception { component.onPullingDown(10,100,100); }
@Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } } }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; }
@Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.DISPLAY,WXRefresh.HIDE); }
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); } }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); }
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; }
@Test public void testSetProperties() throws Exception { component.setProperty(WXSliderNeighbor.NEIGHBOR_ALPHA,0.4f); component.setProperty(WXSliderNeighbor.NEIGHBOR_SCALE,0.9f); }
@Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); }
WXSliderNeighbor extends WXSlider { @Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); } }
WXSliderNeighbor extends WXSlider { @Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); }
WXSliderNeighbor extends WXSlider { @Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); }
WXSliderNeighbor extends WXSlider { @Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); static final String NEIGHBOR_SCALE; static final String NEIGHBOR_ALPHA; static final String NEIGHBOR_SPACE; static final String CURRENT_ITEM_SCALE; }
@Test public void testZoomTransformer() throws Exception { component = create(); TestComponent page = ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class); TestComponent pageChild = ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class); page.addChild(pageChild); component.addChild(page); ComponentTest.create(component); WXSliderNeighbor.ZoomTransformer transformer = component.createTransformer(); transformer.transformPage(page.getHostView(),0.2f); }
ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; }
WXSliderNeighbor extends WXSlider { ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; } }
WXSliderNeighbor extends WXSlider { ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); }
WXSliderNeighbor extends WXSlider { ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); }
WXSliderNeighbor extends WXSlider { ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); static final String NEIGHBOR_SCALE; static final String NEIGHBOR_ALPHA; static final String NEIGHBOR_SPACE; static final String CURRENT_ITEM_SCALE; }
@Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.SRC,"http: }
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); } }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); static final String ITEM_ID; }
@Test public void testSetVisibility() throws Exception { component.setProperty(Constants.Name.VISIBILITY,Constants.Value.HIDDEN); component.setProperty(Constants.Name.SRC,"http: component.setProperty(Constants.Name.VISIBILITY,Constants.Value.VISIBLE); }
@Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; } }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); }
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); static final String ITEM_ID; }
@Test public void testOnLoading() throws Exception { component.onLoading(); }
@Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } } }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; }
@Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.DISPLAY,WXLoading.HIDE); }
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); } }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); }
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; }
@Test public void testAddChild() throws Exception{ WXDiv div = WXDivTest.create(component); component.addChild(div); ComponentTest.create(div); }
@Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); }
WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewListener,Scrollable { @Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); } }
WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewListener,Scrollable { @Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); } @Deprecated WXScroller(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXScroller(WXSDKInstance instance, WXDomObject node, WXVContainer parent); }
WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewListener,Scrollable { @Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); } @Deprecated WXScroller(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXScroller(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override ViewGroup getRealView(); @Override void createViewImpl(); ViewGroup getInnerView(); @Override void addEvent(String type); @Override void addChild(WXComponent child, int index); @Override void remove(WXComponent child,boolean destory); @Override void destroy(); @Override int getScrollY(); @Override int getScrollX(); @Override int getOrientation(); Map<String, Map<String, WXComponent>> getStickMap(); @WXComponentProp(name = Constants.Name.SHOW_SCROLLBAR) void setShowScrollbar(boolean show); @WXComponentProp(name = Constants.Name.SCROLLABLE) void setScrollable(boolean scrollable); @WXComponentProp(name = Constants.Name.OFFSET_ACCURACY) void setOffsetAccuracy(int accuracy); @Override boolean isScrollable(); @Override void bindStickStyle(WXComponent component); @Override void unbindStickStyle(WXComponent component); @Override void bindAppearEvent(WXComponent component); @Override void bindDisappearEvent(WXComponent component); @Override void unbindAppearEvent(WXComponent component); @Override void unbindDisappearEvent(WXComponent component); @Override void scrollTo(WXComponent component, Map<String, Object> options); void scrollBy(final int x, final int y); void scrollBy(final int x, final int y, final boolean smooth); @Override void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy); @Override void onScrollToBottom(WXScrollView scrollView, int x, int y); @Override void onScrollStopped(WXScrollView scrollView, int x, int y); @Override void onScroll(WXScrollView scrollView, int x, int y); @JSMethod void resetLoadmore(); }
WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewListener,Scrollable { @Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); } @Deprecated WXScroller(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXScroller(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override ViewGroup getRealView(); @Override void createViewImpl(); ViewGroup getInnerView(); @Override void addEvent(String type); @Override void addChild(WXComponent child, int index); @Override void remove(WXComponent child,boolean destory); @Override void destroy(); @Override int getScrollY(); @Override int getScrollX(); @Override int getOrientation(); Map<String, Map<String, WXComponent>> getStickMap(); @WXComponentProp(name = Constants.Name.SHOW_SCROLLBAR) void setShowScrollbar(boolean show); @WXComponentProp(name = Constants.Name.SCROLLABLE) void setScrollable(boolean scrollable); @WXComponentProp(name = Constants.Name.OFFSET_ACCURACY) void setOffsetAccuracy(int accuracy); @Override boolean isScrollable(); @Override void bindStickStyle(WXComponent component); @Override void unbindStickStyle(WXComponent component); @Override void bindAppearEvent(WXComponent component); @Override void bindDisappearEvent(WXComponent component); @Override void unbindAppearEvent(WXComponent component); @Override void unbindDisappearEvent(WXComponent component); @Override void scrollTo(WXComponent component, Map<String, Object> options); void scrollBy(final int x, final int y); void scrollBy(final int x, final int y, final boolean smooth); @Override void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy); @Override void onScrollToBottom(WXScrollView scrollView, int x, int y); @Override void onScrollStopped(WXScrollView scrollView, int x, int y); @Override void onScroll(WXScrollView scrollView, int x, int y); @JSMethod void resetLoadmore(); static final String DIRECTION; }
@Test public void testTransition() throws Exception { module.transition("","",""); module.transition("test","test",""); }
@JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } }
WXAnimationModule extends WXModule { @JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } } }
WXAnimationModule extends WXModule { @JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } } }
WXAnimationModule extends WXModule { @JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } } @JSMethod void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack); }
WXAnimationModule extends WXModule { @JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } } @JSMethod void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack); }
@Test public void testDispatchTouchEvent() throws Exception { for(int action:EVENTS) { MotionEvent event = MotionEvent.obtain(100, 100, action, 10, 10, 0); view.dispatchTouchEvent(event); event.recycle(); } }
@Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); } }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
@Test public void testOnTouchEvent() throws Exception { for(int action:EVENTS) { MotionEvent event = MotionEvent.obtain(100, 100, action, 10, 10, 0); view.onTouchEvent(event); event.recycle(); } }
@Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
@Test public void testOnScrollChanged() throws Exception { view.onScrollChanged(0,10,0,20); }
@Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); } }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
WXScrollView extends ScrollView implements Callback, IWXScroller, WXGestureObservable,NestedScrollingChild { @Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX, float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); }
@Test public void testOnTouch() throws Exception { MotionEvent event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_DOWN,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_MOVE,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_UP,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_POINTER_UP,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_CANCEL,0,0,0); mGesture.onTouch(component.getHostView(),event); }
@Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } }
WXGesture extends GestureDetector.SimpleOnGestureListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } } }
WXGesture extends GestureDetector.SimpleOnGestureListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } } WXGesture(WXComponent wxComponent, Context context); }
WXGesture extends GestureDetector.SimpleOnGestureListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } } WXGesture(WXComponent wxComponent, Context context); void setPreventMoveEvent(boolean preventMoveEvent); boolean isTouchEventConsumedByAdvancedGesture(); @Override boolean onTouch(View v, MotionEvent event); @Override void onLongPress(MotionEvent e); @Override boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY); @Override boolean onDown(MotionEvent e); }
WXGesture extends GestureDetector.SimpleOnGestureListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } } WXGesture(WXComponent wxComponent, Context context); void setPreventMoveEvent(boolean preventMoveEvent); boolean isTouchEventConsumedByAdvancedGesture(); @Override boolean onTouch(View v, MotionEvent event); @Override void onLongPress(MotionEvent e); @Override boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY); @Override boolean onDown(MotionEvent e); static final String START; static final String MOVE; static final String END; static final String UNKNOWN; static final String LEFT; static final String RIGHT; static final String UP; static final String DOWN; }
@Test public void testGetOpacity() throws Exception { BorderDrawable opaque = new BorderDrawable(); opaque.setColor(Color.GREEN); assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE)); BorderDrawable transparent = new BorderDrawable(); transparent.setColor(WXResourceUtils.getColor("#00ff0000")); assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT)); BorderDrawable half = new BorderDrawable(); half.setColor(WXResourceUtils.getColor("#aaff0000")); assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT)); BorderDrawable changeAlpha = new BorderDrawable(); changeAlpha.setColor(Color.RED); changeAlpha.setAlpha(15); assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT)); }
@Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); }
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } }
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); }
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); }
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; }
@Test public void testIsRounded(){ BorderDrawable none = new BorderDrawable(); assertThat(none.isRounded(), is(false)); BorderDrawable full = new BorderDrawable(); full.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 12); assertThat(full.isRounded(), is(true)); BorderDrawable noneAndPart = new BorderDrawable(); noneAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 5); noneAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 12); assertThat(noneAndPart.isRounded(), is(true)); BorderDrawable fullAndPart = new BorderDrawable(); fullAndPart.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); fullAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); fullAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 19); assertThat(fullAndPart.isRounded(), is(true)); BorderDrawable partAndFull = new BorderDrawable(); partAndFull.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); partAndFull.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); assertThat(partAndFull.isRounded(), is(true)); BorderDrawable zeroAll = new BorderDrawable(); zeroAll.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); assertThat(zeroAll.isRounded(), is(false)); BorderDrawable zeroPart = new BorderDrawable(); zeroPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 0); assertThat(zeroPart.isRounded(), is(false)); }
public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); }
BorderDrawable extends Drawable { public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); } }
BorderDrawable extends Drawable { public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); } BorderDrawable(); }
BorderDrawable extends Drawable { public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); }
BorderDrawable extends Drawable { public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; }
@Test public void testClearTimeout() throws Exception { module.setTimeout(VALID_FUNC_ID, DELAY); module.clearTimeout(VALID_FUNC_ID); mLooper.idle(DELAY, TimeUnit.MILLISECONDS); Mockito.verify(module, never()).handleMessage(any(Message.class)); }
@JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); } }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); } WXTimerModule(); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); }
@Test public void testClearInterval() throws Exception { module.setInterval(VALID_FUNC_ID, DELAY); module.clearInterval(VALID_FUNC_ID); mLooper.idle(DELAY, TimeUnit.MILLISECONDS); Mockito.verify(module, never()).handleMessage(any(Message.class)); }
@JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); } }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); } WXTimerModule(); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); }
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); }
@Test public void setViewport() throws Exception { JSONObject jsonObject = new JSONObject(); jsonObject.put(WXMetaModule.WIDTH,640); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 640); jsonObject.put(WXMetaModule.WIDTH,320.5); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); jsonObject.put(WXMetaModule.WIDTH,"-200"); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); jsonObject.put(WXMetaModule.WIDTH,"error"); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); mMeta.setViewport("ads"); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); }
@JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } }
WXMetaModule extends WXModule { @JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } } }
WXMetaModule extends WXModule { @JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } } }
WXMetaModule extends WXModule { @JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } } @JSMethod(uiThread = false) void setViewport(String param); }
WXMetaModule extends WXModule { @JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } } @JSMethod(uiThread = false) void setViewport(String param); static final String WIDTH; static final String DEVICE_WIDTH; }
@Test public void testGetValue() throws Exception { assertEquals(null,WXAttr.getValue(attr)); attr.put(VALUE,"test"); assertEquals("test",WXAttr.getValue(attr)); }
public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testLoadFileContent() throws Exception { File folder = new File("build/intermediates/bundles/debug/assets/"); if(!folder.exists()){ folder = new File("build/intermediates/bundles/debug/assets/"); folder.mkdirs(); } File file = new File(folder,"test"); System.out.println(file.getAbsolutePath()); if(!file.exists()){ file.createNewFile(); } WXFileUtils.loadAsset("test", RuntimeEnvironment.application); }
public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; }
WXFileUtils { public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; } }
WXFileUtils { public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; } }
WXFileUtils { public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); }
WXFileUtils { public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); }
@Test public void testSaveFile() throws Exception { WXFileUtils.saveFile("build/test","test".getBytes(),RuntimeEnvironment.application); }
public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; }
WXFileUtils { public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } }
WXFileUtils { public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } }
WXFileUtils { public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); }
WXFileUtils { public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); }
@Test public void testGetImageQuality() throws Exception { assertEquals(WXImageQuality.AUTO,attr.getImageQuality()); attr.put(IMAGE_QUALITY,HIGH); assertEquals(WXImageQuality.HIGH,attr.getImageQuality()); }
public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; }
WXAttr implements Map<String, Object>,Cloneable { public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; } }
WXAttr implements Map<String, Object>,Cloneable { public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testParse() throws Exception { List<Integer> s = new SingleFunctionParser<>("blur(5px)", new SingleFunctionParser.FlatMapper<Integer>() { @Override public Integer map(String raw) { return WXUtils.getInteger(raw,0); } }).parse("blur"); System.out.println(s); }
public LinkedHashMap<K, V> parse() { lexer.moveOn(); return definition(); }
FunctionParser { public LinkedHashMap<K, V> parse() { lexer.moveOn(); return definition(); } }
FunctionParser { public LinkedHashMap<K, V> parse() { lexer.moveOn(); return definition(); } FunctionParser(@NonNull String source, @NonNull Mapper<K, V> mapper); }
FunctionParser { public LinkedHashMap<K, V> parse() { lexer.moveOn(); return definition(); } FunctionParser(@NonNull String source, @NonNull Mapper<K, V> mapper); LinkedHashMap<K, V> parse(); }
FunctionParser { public LinkedHashMap<K, V> parse() { lexer.moveOn(); return definition(); } FunctionParser(@NonNull String source, @NonNull Mapper<K, V> mapper); LinkedHashMap<K, V> parse(); static final char SPACE; }
@Test public void testGetFloat() throws Exception { float test_float = WXUtils.getFloat("12324.9px"); assertEquals(12324.9, test_float, 0.01); assertEquals(WXUtils.fastGetFloat("1.2345",2), 1.23f); }
public static float getFloat(Object value) { return getFloat(value, Float.NaN); }
WXUtils { public static float getFloat(Object value) { return getFloat(value, Float.NaN); } }
WXUtils { public static float getFloat(Object value) { return getFloat(value, Float.NaN); } }
WXUtils { public static float getFloat(Object value) { return getFloat(value, Float.NaN); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { public static float getFloat(Object value) { return getFloat(value, Float.NaN); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetImageSharpen() throws Exception { assertEquals(WXImageSharpen.UNSHARPEN,attr.getImageSharpen()); }
public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; }
WXAttr implements Map<String, Object>,Cloneable { public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; } }
WXAttr implements Map<String, Object>,Cloneable { public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetInt() throws Exception { int test_int = WXUtils.getInt("23px"); assertEquals(23, test_int); }
public static int getInt(Object value) { return getInteger(value, 0); }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetLong() throws Exception { long test_long = WXUtils.getLong("8098px"); assertEquals(8098, test_long); }
@Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; }
WXUtils { @Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { @Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetDouble() throws Exception { double test_Double = WXUtils.getDouble("8098.8989px"); assertEquals(8098.8, test_Double, 0.1); }
@Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetFloatWX() throws Exception { Float test_float = WXUtils.getFloatByViewport("100wx", TEST_VIEW_PORT); Float want = 100 * TEST_DENSITY * TEST_VIEW_PORT / TEST_SCREEN_WIDTH; assertEquals(test_float, want , 0.01); test_float = WXUtils.getFloatByViewport("100px", TEST_VIEW_PORT); want = 100F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport("100.2", TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport(100.2F, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport(100.2D, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport("NaN", TEST_VIEW_PORT); want = Float.NaN; assertEquals(test_float, want); }
public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; }
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; } }
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; } }
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetIntWX() throws Exception { Integer test_int = WXUtils.getInt("100wx"); Integer want = (int)(100 * TEST_DENSITY * 750 / TEST_SCREEN_WIDTH); assertEquals(test_int, want); test_int = WXUtils.getInt("100px"); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt("100"); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt(100); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt(100.1); want = 0; assertEquals(test_int, want); }
public static int getInt(Object value) { return getInteger(value, 0); }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetDoubleWX() throws Exception { Double test_double = WXUtils.getDouble("100.32wx"); Double want = (100.32D * TEST_DENSITY * 750 / TEST_SCREEN_WIDTH); assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble("100px"); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble("100"); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble(100); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble(100.1); want = 100.1D; assertEquals(test_double, want, 0.01); }
@Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); }
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; }
@Test public void testGetImageSrc() throws Exception { assertEquals(null,attr.getImageSrc()); attr.put(SRC,"test"); assertEquals("test",attr.getImageSrc()); }
public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testRewrite() throws Exception { final String host = "http: final String base = host + "/test/123/"; final String bundleWithSlash = base + "?arg=value"; final String bundle = base + "bundle.js?arg=value"; instance.renderByUrl("", bundle, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE); testRelative(host, base, bundle); instance.renderByUrl("", bundleWithSlash, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE); testRelative(host, base, bundleWithSlash); }
@NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; }
DefaultUriAdapter implements URIAdapter { @NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; } }
DefaultUriAdapter implements URIAdapter { @NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; } }
DefaultUriAdapter implements URIAdapter { @NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; } @NonNull @Override Uri rewrite(WXSDKInstance instance, String type, Uri uri); }
DefaultUriAdapter implements URIAdapter { @NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; } @NonNull @Override Uri rewrite(WXSDKInstance instance, String type, Uri uri); }
@Test public void testShowIndicators() throws Exception { assertEquals(true,attr.showIndicators()); }
public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; }
WXAttr implements Map<String, Object>,Cloneable { public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; } }
WXAttr implements Map<String, Object>,Cloneable { public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testAutoPlay() throws Exception { assertEquals(false,attr.autoPlay()); }
public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; }
WXAttr implements Map<String, Object>,Cloneable { public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; } }
WXAttr implements Map<String, Object>,Cloneable { public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetScope() throws Exception { assertEquals(null,attr.getScope()); }
public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetLoadMoreRetry() throws Exception { assertEquals(null,attr.getLoadMoreRetry()); }
public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetLoadMoreOffset() throws Exception { assertEquals(null,attr.getLoadMoreOffset()); }
public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetIsRecycleImage() throws Exception { assertEquals(true,attr.getIsRecycleImage()); }
public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; }
WXAttr implements Map<String, Object>,Cloneable { public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; } }
WXAttr implements Map<String, Object>,Cloneable { public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetScrollDirection() throws Exception { assertEquals("vertical",attr.getScrollDirection()); }
public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); }
WXAttr implements Map<String, Object>,Cloneable { public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); } }
WXAttr implements Map<String, Object>,Cloneable { public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testGetElevation() { int elevation = 100, viewPortW = 750; attr.put(Constants.Name.ELEVATION, elevation); assertThat(attr.getElevation(viewPortW), is(WXViewUtils.getRealSubPxByWidth(elevation, viewPortW))); attr.put(Constants.Name.ELEVATION, ""); assertThat(attr.getElevation(viewPortW), is(0f)); attr.put(Constants.Name.ELEVATION, "give me a NAN"); assertThat(attr.getElevation(viewPortW), is(Float.NaN)); }
public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; }
WXAttr implements Map<String, Object>,Cloneable { public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; } }
WXAttr implements Map<String, Object>,Cloneable { public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); }
WXAttr implements Map<String, Object>,Cloneable { public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
WXAttr implements Map<String, Object>,Cloneable { public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); }
@Test public void testCallDomMethod() throws Exception { module.callDomMethod(null); JSONObject obj = new JSONObject(); for (String m : METHODS) { obj.put(WXBridgeManager.METHOD,m); module.callDomMethod(obj); } obj = new JSONObject(); for (Object[] args:ARGS_CASES ) { JSONArray ary = new JSONArray(); if(args == null){ ary = null; }else { for (Object arg : args ) { ary.add(arg); } } obj.put(WXBridgeManager.ARGS,ary); for (String m : METHODS) { obj.put(WXBridgeManager.METHOD,m); module.callDomMethod(obj); } } }
public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); }
WXDomModule extends WXModule { public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); } }
WXDomModule extends WXModule { public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); } WXDomModule(WXSDKInstance instance); }
WXDomModule extends WXModule { public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); } WXDomModule(WXSDKInstance instance); void callDomMethod(JSONObject task); Object callDomMethod(String method, JSONArray args); void invokeMethod(String ref, String method, JSONArray args); void postAction(RenderAction action); void postAction(DOMAction action, boolean createContext); }
WXDomModule extends WXModule { public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); } WXDomModule(WXSDKInstance instance); void callDomMethod(JSONObject task); Object callDomMethod(String method, JSONArray args); void invokeMethod(String ref, String method, JSONArray args); void postAction(RenderAction action); void postAction(DOMAction action, boolean createContext); static final String CREATE_BODY; static final String UPDATE_ATTRS; static final String UPDATE_STYLE; static final String REMOVE_ELEMENT; static final String ADD_ELEMENT; static final String MOVE_ELEMENT; static final String ADD_EVENT; static final String REMOVE_EVENT; static final String CREATE_FINISH; static final String REFRESH_FINISH; static final String UPDATE_FINISH; static final String SCROLL_TO_ELEMENT; static final String ADD_RULE; static final String GET_COMPONENT_RECT; static final String WXDOM; static final String INVOKE_METHOD; static final String[] METHODS; }
@Test public void testParseFromJson() throws Exception { dom.parseFromJson(JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}")); assertEquals(dom.getRef(),"100"); assertEquals(dom.getType(),"div"); dom.applyStyleToNode(); }
public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated public WXDomObject parent; }
@Test public void testAdd() throws Exception { JSONObject obj = new JSONObject(); obj.put("ref","100"); obj.put("type","div"); dom.parseFromJson(obj); JSONObject child = new JSONObject(); child.put("ref","101"); child.put("type","test"); WXDomObject childDom = new WXDomObject(); childDom.parseFromJson(child); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.removeChildAt(0); assertEquals(dom.getChildCount(),0); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.remove(childDom); }
public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated public WXDomObject parent; }
@Test public void testClone() throws Exception { JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}"); JSONObject obj = new JSONObject(); obj.put("ref","101"); obj.put("type","test"); JSONArray event = new JSONArray(); event.add("click"); obj.put("event",event); dom.parseFromJson(obj); WXDomObject clone = dom.clone(); assertEquals(clone.getRef(),"101"); assertEquals(clone.getType(),"test"); }
@Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { @Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { @Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { @Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { @Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated public WXDomObject parent; }
@Test public void testRemoveDomStatement() throws Exception { dm.removeDomStatement(instance.getInstanceId()); }
public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } }
WXDomManager { public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } } }
WXDomManager { public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } } WXDomManager(WXRenderManager renderManager); }
WXDomManager { public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } } WXDomManager(WXRenderManager renderManager); void sendEmptyMessageDelayed(int what, long delayMillis); void sendMessage(Message msg); void sendMessageDelayed(Message msg, long delay); void removeDomStatement(String instanceId); void post(Runnable task); void destroy(); void executeAction(String instanceId, DOMAction action, boolean createContext); void postAction(String instanceId,DOMAction action, boolean createContext); void postActionDelay(String instanceId,DOMAction action, boolean createContext, long delay); void postRenderTask(@NonNull String instanceId); }
WXDomManager { public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } } WXDomManager(WXRenderManager renderManager); void sendEmptyMessageDelayed(int what, long delayMillis); void sendMessage(Message msg); void sendMessageDelayed(Message msg, long delay); void removeDomStatement(String instanceId); void post(Runnable task); void destroy(); void executeAction(String instanceId, DOMAction action, boolean createContext); void postAction(String instanceId,DOMAction action, boolean createContext); void postActionDelay(String instanceId,DOMAction action, boolean createContext, long delay); void postRenderTask(@NonNull String instanceId); }
@Test public void testGetInstance() throws Exception { WXBridgeManager instance = WXBridgeManager.getInstance(); assertNotNull(instance); }
public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; }
WXBridgeManager implements Callback,BactchExecutor { public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; } }
WXBridgeManager implements Callback,BactchExecutor { public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; } private WXBridgeManager(); }
WXBridgeManager implements Callback,BactchExecutor { public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); }
WXBridgeManager implements Callback,BactchExecutor { public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; }
@Test public void testRestart() throws Exception { getInstance().restart(); }
public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); }
WXBridgeManager implements Callback,BactchExecutor { public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); } }
WXBridgeManager implements Callback,BactchExecutor { public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); } private WXBridgeManager(); }
WXBridgeManager implements Callback,BactchExecutor { public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); }
WXBridgeManager implements Callback,BactchExecutor { public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; }
@Test public void testSetStackTopInstance() throws Exception { getInstance().setStackTopInstance(""); }
public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); } }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); } private WXBridgeManager(); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; }
@Test public void testCallNative() throws Exception { getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\"testModule\",\"method\":\"test\"}]", null); getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\""+WXDomModule.WXDOM+"\",\"method\":\"test\"}]", null); }
public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
WXBridgeManager implements Callback,BactchExecutor { public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; } }
WXBridgeManager implements Callback,BactchExecutor { public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; } private WXBridgeManager(); }
WXBridgeManager implements Callback,BactchExecutor { public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); }
WXBridgeManager implements Callback,BactchExecutor { public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; }
@Test public void testInitScriptsFramework() throws Exception { getInstance().initScriptsFramework(""); }
public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); } }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); } private WXBridgeManager(); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); }
WXBridgeManager implements Callback,BactchExecutor { public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref, final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback, final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback, final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function, WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function, String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; }