This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
/// <summary> | |
/// http://zrx.zhaojie.me/20140721/ | |
/// 问题在于firstBuffer.Flush的时候会有新的item加到secondBuffer里面,导致一次Flush的时候firstBuffer的元素有可能比secondBuffer的元素少。 | |
/// 解决方法是先把buffer给缓存出去(先缓存secondBuffer再缓存firstBuffer),然后再Flush。 | |
/// </summary> | |
namespace IBufferTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myRequest.setRetryPolicy(new DefaultRetryPolicy( | |
MY_SOCKET_TIMEOUT_MS, | |
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, | |
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent i = new Intent(Intent.ACTION_SEND); | |
i.setType("message/rfc822"); | |
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"}); | |
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); | |
i.putExtra(Intent.EXTRA_TEXT , "body of email"); | |
try { | |
startActivity(Intent.createChooser(i, "Send mail...")); | |
} catch (android.content.ActivityNotFoundException ex) { | |
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newsList.setOnScrollListener(new AbsListView.OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(AbsListView view, int scrollState) { | |
} | |
@Override | |
public void onScroll( | |
AbsListView view, int firstVisibleItem, | |
int visibleItemCount, int totalItemCount) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getStatusBarHeight(Context context) { | |
int result = 0; | |
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); | |
if (resourceId > 0) { | |
result = context.getResources().getDimensionPixelSize(resourceId); | |
} | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'rubygems' | |
require 'hpricot' | |
require 'fileutils' | |
require 'time' | |
require 'ya2yaml' | |
require 'nokogiri' | |
require 'cgi' | |
require 'chinese_pinyin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<TResult> Map<in TSource, TResult>(IEnumerable<TSource> sources, Func<TSource, TResult> mapper) | |
{ | |
foreach (var source in sources) | |
{ | |
yield return mapper(source); | |
} | |
} |