List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key, boolean defaultValue)
From source file:at.wada811.android.dialogfragments.AlertDialogFragment.java
private void setView(AlertDialog.Builder builder) { final Bundle args = getArguments(); boolean useView = args.getBoolean(VIEW, false); if (!useView) { return;// w w w .java 2 s . c o m } DialogFragmentCallback listener = getDialogFragmentCallback(); if (listener == null) { throw new RuntimeException("DialogEventListenerPovider has not implemented."); } View view = listener.getView(this); if (view == null) { throw new NullPointerException("DialogEventListener#getView returns null."); } builder.setView(view); }
From source file:cn.ucai.superwechat.ui.MainActivity.java
private void checkAccount(Bundle savedInstanceState) { //make sure activity will not in background if user is logged into another device or removed if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) { SuperWeChatDemoHelper.getInstance().logout(false, null); finish();/*from ww w . jav a 2 s . c o m*/ startActivity(new Intent(this, LoginActivity.class)); return; } else if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) { finish(); startActivity(new Intent(this, LoginActivity.class)); return; } }
From source file:cn.ucai.superwechat.fragment.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from ww w . j av a 2 s . c om*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(cn.ucai.superwechat.R.id.list); sidebar = (Sidebar) getView().findViewById(cn.ucai.superwechat.R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); mContactList = new ArrayList<Contact>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(cn.ucai.superwechat.R.id.query); query.setHint(cn.ucai.superwechat.R.string.search); clearSearch = (ImageButton) getView().findViewById(cn.ucai.superwechat.R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), cn.ucai.superwechat.R.layout.row_contact, mContactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getMContactCname(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? EMUser user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? // startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? // startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getMContactCname())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(cn.ucai.superwechat.R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(cn.ucai.superwechat.R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } registerContactListChangedReceiver(); }
From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/* w w w.ja v a 2 s . c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); getView().findViewById(R.id.back).setOnClickListener(this); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } // else if(Constant.CHAT_ROBOT.equals(username)){ // //Robot? // startActivity(new Intent(getActivity(), RobotsActivity.class)); // } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:cn.ucai.superwechart.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from www .ja v a 2s. c o m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:cn.ucai.superwechat.fragments.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from ww w . ja v a 2 s . c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(cn.ucai.superwechat.R.id.list); sidebar = (Sidebar) getView().findViewById(cn.ucai.superwechat.R.id.sidebar); sidebar.setListView(listView); //// ? addContactView = (ImageView) getView().findViewById(cn.ucai.superwechat.R.id.iv_new_contact); // registerContactListChangedReceiver(); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); //contactList = new ArrayList<EMUser>(); mContactList = new ArrayList<Contact>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(cn.ucai.superwechat.R.id.query); query.setHint(cn.ucai.superwechat.R.string.search); clearSearch = (ImageButton) getView().findViewById(cn.ucai.superwechat.R.id.search_clear); // adapter //adapter = new ContactAdapter(getActivity(), cn.ucai.superwechat.R.layout.row_contact, contactList); adapter = new ContactAdapter(getActivity(), cn.ucai.superwechat.R.layout.row_contact, mContactList); listView.setAdapter(adapter); setListener(); registerForContextMenu(listView); progressBar = (View) getView().findViewById(cn.ucai.superwechat.R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.actionbarsherlock.plus.SherlockDialogPlusFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mShowsDialog = getContainerId() == 0; if (savedInstanceState != null) { mStyle = savedInstanceState.getInt(SAVED_STYLE, STYLE_NORMAL); mTheme = savedInstanceState.getInt(SAVED_THEME, 0); mCancelable = savedInstanceState.getBoolean(SAVED_CANCELABLE, true); mShowsDialog = savedInstanceState.getBoolean(SAVED_SHOWS_DIALOG, mShowsDialog); mBackStackId = savedInstanceState.getInt(SAVED_BACK_STACK_ID, -1); }//from w w w .jav a 2 s. c om }
From source file:com.neusou.bioroid.restful.RestfulClient.java
/** * Executes HTTP method/*w w w . java 2s.c o m*/ * @param <T> Http Request Method class * @param <V> Restful response class * @param <M> restful method class * @param <R> response handler class * @param httpMethod http request method * @param rh response handler * @param data extra invocation data */ public <T extends HttpRequestBase, V extends IRestfulResponse<?>, M extends RestfulMethod, R extends RestfulResponseHandler<V, M>> void execute( final T httpMethod, R rh, final Bundle data) { Logger.l(Logger.DEBUG, LOG_TAG, "execute() " + httpMethod.getRequestLine().toString()); DefaultHttpClient httpClient = new DefaultHttpClient(); V response = null; String exceptionMessage = null; String cachedResponse = null; boolean isResponseCached = data.getBoolean(KEY_USE_CACHE, mUseCacheByDefault); String requestUrl = httpMethod.getRequestLine().getUri().toString(); Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # useCache? " + isResponseCached); if (mResponseCacheInitialized && isResponseCached) { httpMethod.getParams().setBooleanParameter("param1", true); //Log.d(LOG_TAG, "paramstring: "+paramString); cachedResponse = mCacheResponseDbHelper.getResponse(requestUrl, httpMethod.getMethod()); Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # cached response: " + cachedResponse); response = rh.createResponse(cachedResponse); response.set(new StringReader(cachedResponse)); } if (cachedResponse == null) { try { response = httpClient.execute(httpMethod, rh); } catch (ClientProtocolException e) { e.printStackTrace(); exceptionMessage = e.getMessage(); httpMethod.abort(); } catch (UnknownHostException e) { e.printStackTrace(); exceptionMessage = "not connected to the internet"; httpMethod.abort(); } catch (IOException e) { e.printStackTrace(); exceptionMessage = "connection error. please try again."; httpMethod.abort(); } // cache the response if (exceptionMessage == null && mResponseCacheInitialized && isResponseCached) { Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # inserting response to cache: " + response); M method = data.getParcelable(XTRA_METHOD); BufferedReader br = new BufferedReader(response.get()); StringBuilder sb = new StringBuilder(); char[] buffer = new char[51200]; try { while (true) { int bytesRead; bytesRead = br.read(buffer); if (bytesRead == -1) { break; } sb.append(buffer, 0, bytesRead); } mCacheResponseDbHelper.insertResponse(requestUrl, sb.toString(), Calendar.getInstance().getTime().getTime(), httpMethod.getMethod(), method.getCallId()); } catch (IOException e) { e.printStackTrace(); } } } // process response //Logger.l(Logger.DEBUG, LOG_TAG, "starting service with action: "+INTENT_PROCESS_RESPONSE); Intent processIntent = new Intent(); processIntent.setAction(INTENT_PROCESS_RESPONSE); processIntent.putExtra(XTRA_RESPONSE, response); processIntent.putExtra(XTRA_ERROR, exceptionMessage); processIntent.putExtra(XTRA_REQUEST, data); mContext.startService(processIntent); boolean imcallback = data.getBoolean(KEY_IMMEDIATECALLBACK, false); if (imcallback) { Bundle callbackData = new Bundle(); callbackData.putBundle(XTRA_REQUEST, data); callbackData.putParcelable(XTRA_RESPONSE, response); callbackData.putString(XTRA_ERROR, exceptionMessage); broadcastCallback(mContext, callbackData, generateKey(mContext.getPackageName(), mName, RestfulClient.KEY_CALLBACK_INTENT)); } }
From source file:com.google.android.apps.muzei.api.MuzeiArtSource.java
private void processHandleCommand(int commandId, Bundle extras) { Log.d(TAG, "Received handle command intent, command ID: " + commandId + ", id=" + mName); if (commandId == BUILTIN_COMMAND_ID_NEXT_ARTWORK) { int reason = extras.getBoolean(EXTRA_SCHEDULED, false) ? UPDATE_REASON_SCHEDULED : UPDATE_REASON_USER_NEXT; if (reason == UPDATE_REASON_SCHEDULED) { unscheduleUpdate();//from w ww . java2 s . c o m } onUpdate(reason); } else { onCustomCommand(commandId); } }
From source file:fr.cph.chicago.activity.MainActivity.java
@Override protected final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!isFinishing()) { // Handle onStop event where bus data has been switched to null if (savedInstanceState != null) { boolean first = savedInstanceState.getBoolean("first", false); if (!first) { DataHolder dataHolder = DataHolder.getInstance(); BusData busData = BusData.getInstance(); if (busData.readAllBusStops() == null || busData.readAllBusStops().size() == 0) { busData.readBusStops(); dataHolder.setBusData(busData); }/* w w w . j a va 2s .c o m*/ TrainData trainData = new TrainData(); if (trainData.isStationNull() || trainData.isStopsNull()) { trainData.read(); dataHolder.setTrainData(trainData); } } } new LoadData().execute(); setContentView(R.layout.activity_main); ChicagoTracker.container = (FrameLayout) findViewById(R.id.container); ChicagoTracker.container.getForeground().setAlpha(0); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); displayUpdatePanel(); } }