List of usage examples for android.os Handler obtainMessage
public final Message obtainMessage(int what, int arg1, int arg2, Object obj)
From source file:org.hedgewars.hedgeroid.netplay.Netplay.java
boolean sendToNet(ToNetMsgType what, int arg1, Object obj) { if (connection != null) { Handler handler = connection.toNetHandler; return handler.sendMessage(handler.obtainMessage(what.ordinal(), arg1, 0, obj)); } else {/*from ww w .j a v a 2s . c o m*/ return false; } }
From source file:org.microg.gms.gcm.McsService.java
private void sendOutputStream(int what, int arg, Object obj) { McsOutputStream os = outputStream;//from www . j a v a2 s . c o m if (os != null && os.isAlive()) { Handler outputHandler = os.getHandler(); if (outputHandler != null) outputHandler.sendMessage(outputHandler.obtainMessage(what, arg, 0, obj)); } }
From source file:com.nachiket.titan.LibraryPagerAdapter.java
@Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_RUN_QUERY: { LibraryAdapter adapter = (LibraryAdapter) message.obj; int index = adapter.getMediaType(); Handler handler = mUiHandler; handler.sendMessage(handler.obtainMessage(MSG_COMMIT_QUERY, index, 0, adapter.query())); break;//from w w w .ja v a 2s. co m } case MSG_COMMIT_QUERY: { int index = message.arg1; mAdapters[index].commitQuery(message.obj); int pos; if (mSavedPositions == null) { pos = 0; } else { pos = mSavedPositions[index]; mSavedPositions[index] = 0; } mLists[index].setSelection(pos); break; } case MSG_SAVE_SORT: { MediaAdapter adapter = (MediaAdapter) message.obj; SharedPreferences.Editor editor = PlaybackService.getSettings(mActivity).edit(); editor.putInt(String.format("sort_%d_%d", adapter.getMediaType(), adapter.getLimiterType()), adapter.getSortMode()); editor.commit(); break; } case MSG_REQUEST_REQUERY: requestRequery((LibraryAdapter) message.obj); break; default: return false; } return true; }
From source file:mp.teardrop.LibraryPagerAdapter.java
@Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_RUN_QUERY: { //we are on the worker thread here LibraryAdapter adapter = (LibraryAdapter) message.obj; Handler handler = mUiHandler; handler.sendMessage(//from w w w .j av a2s.c o m handler.obtainMessage(MSG_COMMIT_QUERY, adapter.getMediaType(), 0, adapter.query())); break; } case MSG_COMMIT_QUERY: { //we are on the UI thread here int index = message.arg1; if (index == MediaUtils.TYPE_UNIFIED) { //MediaInfoHolder mih = (MediaInfoHolder) message.obj; mAdapters[index].commitQuery(message.obj); //showInLocalLibrary(mih); } else { mAdapters[index].commitQuery(message.obj); int pos; if (mSavedPositions == null) { pos = 0; } else { pos = mSavedPositions[index]; mSavedPositions[index] = 0; } ListView listView = (ListView) mContainingLayouts[index].findViewById(R.id.actual_list_view); listView.setSelection(pos); } ((ListView) mContainingLayouts[getCurrentType()].findViewById(R.id.actual_list_view)) .smoothScrollToPosition(0); ; break; } case MSG_SAVE_SORT: { MediaAdapter adapter = (MediaAdapter) message.obj; SharedPreferences.Editor editor = PlaybackService.getSettings(mActivity).edit(); editor.putInt(String.format("sort_%d_%d", adapter.getMediaType(), adapter.getLimiterType()), adapter.getSortMode()); editor.commit(); break; } case MSG_REQUEST_REQUERY: requestRequery((LibraryAdapter) message.obj); break; default: return false; } return true; }
From source file:ch.teamuit.android.soundplusplus.LibraryPagerAdapter.java
@Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_RUN_QUERY: { LibraryAdapter adapter = (LibraryAdapter) message.obj; int index = adapter.getMediaType(); Handler handler = mUiHandler; handler.sendMessage(handler.obtainMessage(MSG_COMMIT_QUERY, index, 0, adapter.query())); break;//www . j av a2 s . co m } case MSG_COMMIT_QUERY: { int index = message.arg1; mAdapters[index].commitQuery(message.obj); // Restore scrolling position if present and valid Integer curPos = sLruAdapterPos.popPosition(mAdapters[index]); if (curPos != null && curPos < mLists[index].getCount()) mLists[index].setSelection(curPos); break; } case MSG_SAVE_SORT: { MediaAdapter adapter = (MediaAdapter) message.obj; SharedPreferences.Editor editor = PlaybackService.getSettings(mActivity).edit(); editor.putInt(String.format("sort_%d_%d", adapter.getMediaType(), adapter.getLimiterType()), adapter.getSortMode()); editor.apply(); break; } case MSG_REQUEST_REQUERY: requestRequery((LibraryAdapter) message.obj); break; default: return false; } return true; }
From source file:ch.blinkenlights.android.vanilla.LibraryPagerAdapter.java
@Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_RUN_QUERY: { LibraryAdapter adapter = (LibraryAdapter) message.obj; int index = adapter.getMediaType(); Handler handler = mUiHandler; handler.sendMessage(handler.obtainMessage(MSG_COMMIT_QUERY, index, 0, adapter.query())); break;/* w ww . j a v a 2 s . c o m*/ } case MSG_COMMIT_QUERY: { int index = message.arg1; mAdapters[index].commitQuery(message.obj); restorePosition(index); break; } case MSG_SAVE_SORT: { SortableAdapter adapter = (SortableAdapter) message.obj; SharedPreferences.Editor editor = PlaybackService.getSettings(mActivity).edit(); editor.putInt(adapter.getSortSettingsKey(), adapter.getSortMode()); editor.apply(); break; } case MSG_REQUEST_REQUERY: requestRequery((LibraryAdapter) message.obj); break; default: return false; } return true; }