List of usage examples for android.util Pair create
public static <A, B> Pair<A, B> create(A a, B b)
From source file:Main.java
/** * Add X-TelefunMtv-Token to Content Header of the Request. *///w w w . j av a 2 s . co m public static Pair getHeaderSession(String sessionToken) { Pair pair = Pair.create("Token", sessionToken); return pair; }
From source file:Main.java
public static Pair<Integer, Integer> randomBalanceAndAccountNumbers() { Random random = new Random(); Integer balance = random.nextInt(80000); Integer account = 10000000 + random.nextInt(90000000); return Pair.create(balance, account); }
From source file:Main.java
public static Pair<Integer, Integer> decodeDimensions(String path) { final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;//w w w.j av a 2 s . c o m BitmapFactory.decodeFile(path, options); return Pair.create(options.outWidth, options.outHeight); }
From source file:Main.java
public static List<Pair<String, String>> getContentTypeAndCacheHeaders(String contentType, boolean disableCache) { List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>(); headers.add(Pair.create("Content-Type", contentType)); if (disableCache) headers.add(Pair.create("Cache-Control", "no-store")); return headers; }
From source file:Main.java
public static ArrayList<Pair<String, String>> convertHeaders(Map<String, List<String>> map) { ArrayList<Pair<String, String>> array = new ArrayList<Pair<String, String>>(); for (Map.Entry<String, List<String>> mapEntry : map.entrySet()) { for (String mapEntryValue : mapEntry.getValue()) { // HttpURLConnection puts a weird null entry in the header map that corresponds to // the HTTP response line (for instance, HTTP/1.1 200 OK). Ignore that weirdness... if (mapEntry.getKey() != null) { array.add(Pair.create(mapEntry.getKey(), mapEntryValue)); }// ww w.j a v a2s.com } } return array; }
From source file:Main.java
static Pair<String, Resources> findSystemApk(String action, PackageManager pm) { final Intent intent = new Intent(action); for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) { if (info.activityInfo != null && (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { final String packageName = info.activityInfo.packageName; try { final Resources res = pm.getResourcesForApplication(packageName); return Pair.create(packageName, res); } catch (NameNotFoundException e) { Log.w(TAG, "Failed to find resources for " + packageName); }/*from w ww . j av a2 s .co m*/ } } return null; }
From source file:Main.java
static List<Pair<String, Resources>> findSystemApks(String action, PackageManager pm) { final Intent intent = new Intent(action); List<Pair<String, Resources>> systemApks = new ArrayList<Pair<String, Resources>>(); for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) { if (info.activityInfo != null && (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { final String packageName = info.activityInfo.packageName; try { final Resources res = pm.getResourcesForApplication(packageName); systemApks.add(Pair.create(packageName, res)); } catch (NameNotFoundException e) { Log.w(TAG, "Failed to find resources for " + packageName); }// w w w . j av a 2 s . c o m } } return systemApks; }
From source file:Main.java
/** * Parses an SPS NAL unit.// ww w. j a v a2s. c o m * * @param spsNalUnit The NAL unit. * @return A pair consisting of AVC profile and level constants, as defined in * {@link android.media.MediaCodecInfo.CodecProfileLevel}. Null if the input data was not an SPS NAL unit. */ public static Pair<Integer, Integer> parseSpsNalUnit(byte[] spsNalUnit) { // SPS NAL unit: // - Start prefix (4 bytes) // - Forbidden zero bit (1 bit) // - NAL ref idx (2 bits) // - NAL unit type (5 bits) // - Profile idc (8 bits) // - Constraint bits (3 bits) // - Reserved bits (5 bits) // - Level idx (8 bits) if (isNalStartCode(spsNalUnit, 0) && spsNalUnit.length == 8 && (spsNalUnit[5] & 0x1F) == SPS_NAL_UNIT_TYPE) { return Pair.create(parseAvcProfile(spsNalUnit), parseAvcLevel(spsNalUnit)); } return null; }
From source file:org.xwalk.core.xwview.test.DownloadListenerTest.java
@SmallTest @Feature({ "onDownloadStart" }) public void testOnDownloadStart() throws Throwable { final String data = "download data"; final String contentDisposition = "attachment;filename=\"download.txt\""; final String mimeType = "text/plain"; final String userAgent = "Chrome/44.0.2403.81 Crosswalk/15.44.376.0 Mobile Safari/537.36"; final String cookieValue = "cookie data"; List<Pair<String, String>> downloadHeaders = new ArrayList<Pair<String, String>>(); downloadHeaders.add(Pair.create("Content-Disposition", contentDisposition)); downloadHeaders.add(Pair.create("Content-Type", mimeType)); downloadHeaders.add(Pair.create("Content-Length", Integer.toString(data.length()))); setUserAgent(userAgent);//w ww . j ava2 s . c o m setDownloadListener(); XWalkCookieManager cookieManager = new XWalkCookieManager(); TestWebServer webServer = TestWebServer.start(); try { final String requestPath = "/download.txt"; final String pageUrl = webServer.setResponse(requestPath, data, downloadHeaders); final int callCount = mDownloadStartHelper.getCallCount(); cookieManager.setCookie(pageUrl, cookieValue); loadUrlAsync(pageUrl); mDownloadStartHelper.waitForCallback(callCount); assertEquals(pageUrl, mDownloadStartHelper.getUrl()); assertEquals(contentDisposition, mDownloadStartHelper.getContentDisposition()); assertEquals(mimeType, mDownloadStartHelper.getMimeType()); assertEquals(data.length(), mDownloadStartHelper.getContentLength()); assertEquals(userAgent, mDownloadStartHelper.getUserAgent()); final HttpRequest lastRequest = webServer.getLastRequest(requestPath); assertEquals(cookieValue, lastRequest.getFirstHeader("Cookie").getValue()); } finally { webServer.shutdown(); } }
From source file:com.pursuer.reader.easyrss.network.ItemDataSyncer.java
public static void clearInstance(final ItemDataSyncer instance) { synchronized (instances) { instances.remove(Pair.create(instance.getUid(), instance.isUnread())); }//from w w w. j a v a 2s . c o m }