Android Pair - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Pair class.

This code example shows how to use the following methods:
    assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(666, true));
 
    int anotherNetworkId = 777;
    wifiManager.enableNetwork(anotherNetworkId, false);
    lastEnabled = shadowWifiManager.getLastEnabledNetwork();
    assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(777, false));
  } 
 
  @Test 
  public void shouldReturnSetScanResults() throws Exception { 
    List<ScanResult> scanResults = new ArrayList<ScanResult>();
    shadowWifiManager.setScanResults(scanResults);
    assertThat(wifiManager.getScanResults()).isSameAs(scanResults);
  } 
 
  @Test 
  public void shouldRecordTheLastAddedNetwork() throws Exception { 
    WifiConfiguration wifiConfiguration = new WifiConfiguration();
    wifiConfiguration.networkId = -1;
    int networkId = wifiManager.addNetwork(wifiConfiguration);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    @Test 
    public void shouldEnableNetworks() throws Exception { 
        int networkId = 666;
        wifiManager.enableNetwork(networkId, true);
        Pair<Integer, Boolean> lastEnabled = shadowWifiManager.getLastEnabledNetwork();
        assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(666, true));
 
        int anotherNetworkId = 777;
        wifiManager.enableNetwork(anotherNetworkId, false);
        lastEnabled = shadowWifiManager.getLastEnabledNetwork();
        assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(777, false));
    } 
 
    @Test 
    public void shouldReturnSetScanResults() throws Exception { 
        List<ScanResult> scanResults = new ArrayList<ScanResult>();
        shadowWifiManager.setScanResults(scanResults);
        assertThat(wifiManager.getScanResults()).isSameAs(scanResults);
    } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
					(System.currentTimeMillis() - start));
		} catch (Exception e) {
			L.w(e);
			ex = e;
		} 
		return new Pair<Exception, Result>(ex, res);
	} 
 
	@Override 
	protected final void onPostExecute(Pair<Exception, Result> result) {
		// try-catch to avoid lifecycle-related crashes 
		try { 
			if (progressListener != null) {
				progressListener.dismiss();
			} 
			if (result.first != null) {
				onFailurePostExecute(result.first);
			} else { 
				onSuccessPostExecute(result.second);
			} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	@Override 
	public void onLocationChanged(Location location) {
		@SuppressWarnings("unchecked") 
		Fix lqLocation = new Fix(location, new Pair<String, String>("battery", "" + batteryLevel));
		 
		if (isConnected()) { 
			fixSocket.pushFix(lqLocation);
		} else { 
			// TODO: This is a crude check. Should probably be rolled into UDPClient class directly. 
			Log.w(TAG, "Network unavailable, failed to push location fix!");
		} 
	} 
 
	@Override 
	public void onProviderDisabled(String provider) {
	} 
 
	@Override 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    @Override 
    public Request addHeader(String headerKey, String headerValue) {
      if (headers == null) {
        headers = new ArrayList<Pair<String, String>>();
      } 
      headers.add(new Pair<String, String>(headerKey, headerValue));
      return this;
    } 
     
    @Override 
    public String getHeaderValue(String headerKey) {
      for (Pair<String, String> keyVal : headers) {
        if (keyVal.first.equals(headerKey)) {
          return keyVal.second;
        } 
      } 
      return null; 
    } 
 
    @Override 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        String cookie = loadString(COOKIES);
        if(TextUtils.isEmpty(cookie))
            return null; 
         
        final String[] cookies = cookie.split(";");
        return new Pair<String, String>(cookies[0], cookies[1]);
    } 
     
    private Integer loadInt(String name)
    { 
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(LepraDroidApplication.getInstance());
        return sp.getInt(name, 0);
    } 
     
         
    private void saveInt(String name, Integer value)
    { 
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(LepraDroidApplication.getInstance());
        Editor e = sp.edit();
        e.putInt(name, value);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private boolean freeze;
 
    public void add(String url)
    { 
        if( ( urls.isEmpty() || !urls.get(urls.size() - 1).first.equals(url) ) && !freeze) // обновляем страницу, а не загружаем новую. Запись в историю не нужна.
            urls.add(new Pair<>(url, 0));
 
        freeze = false;
    } 
 
    public void moveBack() 
    { 
        freeze = true;
 
        urls.remove(urls.size() - 1);
    } 
 
    public boolean hasPrevious() 
    { 
        return urls.size() > 1;
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		return _cursor;
	} 
 
	public Pair<Color, Color> setCursor (Color front, Color back)
	{ 
		return _cursor = new Pair(front, back);
	} 
 
	public Pair<Color, Color> setCursor (Pair<Color, Color> value)
	{ 
		return _cursor = value;
	} 
 
	public Color setColor (int index, Color value)
	{ 
		return _colors.put(index, value);
	} 
 
	public Color getColor (int index)
	{ 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            instance.execute((Void) null);
        } 
    } 
 
    public static void addElement(String iconName, ImageView view) {
        queue.add(new Pair<String, ImageView>(iconName, view));
        executeIfNeeded(); 
    } 
 
 
    @Override 
    protected Void doInBackground(Void... params) {
        while (!queue.isEmpty()) {
            Pair<String, ImageView> item = queue.poll();
//            if (!item.second.isShown()) continue; 
            File cacheDir = item.second.getContext().getCacheDir();
            File cachedImage = new File(cacheDir, item.first);
            if (cachedImage.exists()) {
                try { 
                    Bitmap bitmap = BitmapFactory.decodeStream(new FileInputStream(cachedImage));
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    public static Pair<Integer, Integer> getResolution(Activity activity) {
        if (null == sResolution) {
            int width = activity.getWindowManager().getDefaultDisplay().getWidth();
            int height = activity.getWindowManager().getDefaultDisplay().getHeight();
            sResolution = new Pair<Integer, Integer>(width, height);
        } 
        return sResolution;
    } 
 
    public static String getDownloadDir() {
        String status = Environment.getExternalStorageState();
        if (status == null || !status.equals(Environment.MEDIA_MOUNTED)){
            return null; 
        } 
 
        String path = null;
 
        // get the sdcard directory 
        File sdFile = Environment.getExternalStorageDirectory();
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android Pair Questions & Answers:

See Code Examples for Android Pair Methods: