}
dictRaf = null;
}
- Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()),
- Toast.LENGTH_LONG).show();
+ if (!isFinishing())
+ Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()),
+ Toast.LENGTH_LONG).show();
startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
finish();
}
* -> language in which the phrase is written to -> to which
* language shall be translated
*/
- if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) {
+ if ("com.hughes.action.ACTION_SEARCH_DICT".equals(intentAction)) {
String query = intent.getStringExtra(SearchManager.QUERY);
String from = intent.getStringExtra("from");
if (from != null)
}
if (dictFilename == null) {
- Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show();
+ if (!isFinishing())
+ Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show();
startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
finish();
return;
typeface = Typeface.createFromAsset(getAssets(), fontName);
} catch (Exception e) {
Log.w(LOG, "Exception trying to use typeface, using default.", e);
- Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()),
- Toast.LENGTH_LONG).show();
+ if (!isFinishing())
+ Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()),
+ Toast.LENGTH_LONG).show();
}
break;
}
final LinearLayout result = new LinearLayout(parent.getContext());
- for (int i = 0; dictionaryInfo.indexInfos != null && i < dictionaryInfo.indexInfos.size(); ++i) {
+ for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
final View button = IsoUtils.INSTANCE.createButton(parent.getContext(),
indexInfo, application.languageButtonPixels);
try {
wordList.getParentFile().mkdirs();
final PrintWriter out = new PrintWriter(new FileWriter(wordList, true));
- out.println(rawText.toString());
+ out.println(rawText);
out.close();
} catch (Exception e) {
Log.e(LOG, "Unable to append to " + wordList.getAbsolutePath(), e);
- Toast.makeText(this,
- getString(R.string.failedAddingToWordList, wordList.getAbsolutePath()),
- Toast.LENGTH_LONG).show();
+ if (!isFinishing())
+ Toast.makeText(this,
+ getString(R.string.failedAddingToWordList, wordList.getAbsolutePath()),
+ Toast.LENGTH_LONG).show();
}
}
Log.d(LOG, "Trying to hide soft keyboard.");
final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
View focus = getCurrentFocus();
- if (focus != null) {
+ if (inputManager != null && focus != null) {
inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}, 20);
}
- private final void jumpToRow(final int row) {
+ private void jumpToRow(final int row) {
Log.d(LOG, "jumpToRow: " + row + ", refocusSearchText=" + false);
// getListView().requestFocusFromTouch();
getListView().setSelectionFromTop(row, 0);
}
public String toString() {
- return String.format("SearchOperation(%s,%s)", searchText, interrupted.toString());
+ return String.format("SearchOperation(%s,%s)", searchText, interrupted);
}
@Override
Log.d(LOG, "interrupted, skipping searchFinished.");
}
} catch (Exception e) {
- Log.e(LOG, "Failure during search (can happen during Activity close.");
+ Log.e(LOG, "Failure during search (can happen during Activity close): " + e.getMessage());
} finally {
synchronized (this) {
done = true;
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
scale = dm.density;
- } catch (NullPointerException e)
+ } catch (NullPointerException ignored)
{}
// Convert the dps to pixels, based on density scale
mPaddingDefault = (int) (PADDING_DEFAULT_DP * scale + 0.5f);
col1.setTextColor(textColorFg);
col2.setTextColor(textColorFg);
- // Set the columns in the table.
- if (r > 0) {
- final TextView bullet = new TextView(tableRow.getContext());
- bullet.setText(" •");
- tableRow.addView(bullet);
- }
- tableRow.addView(col1, layoutParams);
- if (r > 0) {
- final TextView bullet = new TextView(tableRow.getContext());
- bullet.setText(" •");
- tableRow.addView(bullet);
- }
- tableRow.addView(col2, layoutParams);
col1.setWidth(1);
col2.setWidth(1);
col2.setOnLongClickListener(textViewLongClickListenerIndex1);
}
+ // Set the columns in the table.
+ if (r == 0) {
+ tableRow.addView(col1, layoutParams);
+ tableRow.addView(col2, layoutParams);
+ } else {
+ for (int i = 0; i < 2; i++) {
+ final TextView bullet = new TextView(tableRow.getContext());
+ bullet.setText(" • ");
+ LinearLayout wrapped = new LinearLayout(context);
+ wrapped.setOrientation(LinearLayout.HORIZONTAL);
+ LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0);
+ wrapped.addView(bullet, p1);
+ LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
+ wrapped.addView(i == 0 ? col1 : col2, p2);
+ tableRow.addView(wrapped, layoutParams);
+ }
+ }
+
result.addView(tableRow);
}
for (int r = 0; r < rowCount; ++r) {
final TableRow tableRow = (TableRow)result.getChildAt(r);
- final TextView col1 = (TextView)tableRow.getChildAt(r == 0 ? 0 : 1);
- final TextView col2 = (TextView)tableRow.getChildAt(r == 0 ? 1 : 3);
+ View left = tableRow.getChildAt(0);
+ View right = tableRow.getChildAt(1);
+ if (r > 0) {
+ left = ((ViewGroup)left).getChildAt(1);
+ right = ((ViewGroup)right).getChildAt(1);
+ }
+ final TextView col1 = (TextView)left;
+ final TextView col2 = (TextView)right;
// Set what's in the columns.
final Pair pair = entry.pairs.get(r);