Java 类android.content.ClipData.Item 实例源码
项目:Akoi-Translator
文件:TranslateService.java
@Override
public void onPrimaryClipChanged() {
ClipData data = mClipManager.getPrimaryClip();
if (null != data) {
Item item = data.getItemAt(data.getItemCount() - 1);
CharSequence text = item.getText();
if (shouldTranslate(text)) {
TranslateRequest request = new TranslateRequest();
request.mFromLanguage = "auto";
request.mToLanguage = AppSettings.getInstance().mDestLanguage;
mLastText = text.toString();
request.mQuery = mLastText;
mTranslator.startTranslate(request);
lazyResetLastText();
}
}
}
项目:FMTech
文件:dbs.java
@TargetApi(16)
public static void a(Intent paramIntent, String paramString, List<jpx> paramList, Context paramContext)
{
if (Build.VERSION.SDK_INT < 16) {
return;
}
Iterator localIterator = paramList.iterator();
ClipData localClipData = null;
while (localIterator.hasNext())
{
ClipData.Item localItem = new ClipData.Item(a(((jpx)localIterator.next()).e(), paramString, paramContext));
if (localClipData == null) {
localClipData = new ClipData(a, localItem);
} else {
localClipData.addItem(localItem);
}
}
paramIntent.setClipData(localClipData);
}
项目:buildAPKsSamples
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.titles_frag);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
项目:pullbullet
文件:Utils.java
@SuppressLint("NewApi")
public static String getClip(ClipboardManager cliper) {
try {
ClipData data = cliper.getPrimaryClip();
Item item = data.getItemAt(0);
return String.valueOf(item.getText());
} catch (Exception e) {
}
return null;
}
项目:strava
文件:PostToStrava.java
protected String extractURL() {
String url = null;
ClipData clipboard = getIntent().getClipData();
if ( clipboard.getItemCount() > 0 ) {
Item item = clipboard.getItemAt( 0 );
if ( item != null && item.getText() != null ) {
url = item.getText().toString();
}
}
return url;
}
项目:androidtestdebug
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.frag_title);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
项目:androidtestdebug
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.frag_title);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
项目:androidtestdebug
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.frag_title);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
项目:codeexamples-android
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.titles_frag);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}
项目:codeexamples-android
文件:ContentFragment.java
boolean processDrop(DragEvent event, ImageView imageView) {
// Attempt to parse clip data with expected format: category||entry_id.
// Ignore event if data does not conform to this format.
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
String textData = (String) item.getText();
if (textData != null) {
StringTokenizer tokenizer = new StringTokenizer(textData, "||");
if (tokenizer.countTokens() != 2) {
return false;
}
int category = -1;
int entryId = -1;
try {
category = Integer.parseInt(tokenizer.nextToken());
entryId = Integer.parseInt(tokenizer.nextToken());
} catch (NumberFormatException exception) {
return false;
}
updateContentAndRecycleBitmap(category, entryId);
// Update list fragment with selected entry.
TitlesFragment titlesFrag = (TitlesFragment)
getFragmentManager().findFragmentById(R.id.titles_frag);
titlesFrag.selectPosition(entryId);
return true;
}
}
}
return false;
}