List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.digi.android.wva.fragments.EndpointOptionsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (mConfig == null && savedInstanceState == null) { Log.e(TAG, "mConfig is null, not showing dialog!"); return null; }/* w w w . j a v a 2 s .c om*/ LayoutInflater inf = getActivity().getLayoutInflater(); View v = inf.inflate(R.layout.dialog_endpoint_options, null); // Suppresses warnings, and ensures the layout exists. assert v != null; final TextView subIntervalTV = (TextView) v.findViewById(R.id.textView_interval); final TextView alarmInfoTV = (TextView) v.findViewById(R.id.alarm_info); final CheckBox subscribedCB = (CheckBox) v.findViewById(R.id.subscribedCheckbox); final CheckBox alarmCB = (CheckBox) v.findViewById(R.id.alarmCheckbox); final EditText subInterval = (EditText) v.findViewById(R.id.subscriptionInterval); final EditText alarmThreshold = (EditText) v.findViewById(R.id.alarmThreshold); final Spinner typeSpinner = (Spinner) v.findViewById(R.id.alarmTypeSpinner); final LinearLayout makeAlarmSection = (LinearLayout) v.findViewById(R.id.section_make_alarm); final LinearLayout showAlarmSection = (LinearLayout) v.findViewById(R.id.section_show_alarm); final CheckBox dcSendCB = (CheckBox) v.findViewById(R.id.dcPushCheckbox); String alarmInfo = "No alarm yet"; boolean isSubscribed = false; String endpointName = "UNKNOWN"; int sinterval = 10; boolean alarmCreated = false; double threshold = 0; int alarmtypeidx = 0; boolean isSendingToDC = false; if (savedInstanceState != null && savedInstanceState.containsKey("config")) { mConfig = savedInstanceState.getParcelable("config"); } if (mConfig != null) { endpointName = mConfig.getEndpoint(); alarmInfo = mConfig.getAlarmSummary(); if (mConfig.getSubscriptionConfig() != null) { isSubscribed = mConfig.getSubscriptionConfig().isSubscribed(); sinterval = mConfig.getSubscriptionConfig().getInterval(); isSendingToDC = mConfig.shouldBePushedToDeviceCloud(); } else { // Not subscribed; default interval value from preferences. String i = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString("pref_default_interval", "0"); try { sinterval = Integer.parseInt(i); } catch (NumberFormatException e) { Log.d(TAG, "Failed to parse default interval from preferences: " + i); sinterval = 0; } } if (mConfig.getAlarmConfig() != null) { alarmCreated = mConfig.getAlarmConfig().isCreated(); threshold = mConfig.getAlarmConfig().getThreshold(); String typestr = AlarmType.makeString(mConfig.getAlarmConfig().getType()); for (int i = 0; i < alarmTypes.length; i++) { if (alarmTypes[i].toLowerCase(Locale.US).equals(typestr)) alarmtypeidx = i; } } } // Set up event listeners on EditText and CheckBox items subscribedCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { subInterval.setEnabled(isChecked); subIntervalTV.setEnabled(isChecked); } }); alarmCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { typeSpinner.setEnabled(isChecked); alarmThreshold.setEnabled(false); // If type spinner is set to Change, we want threshold disabled again if (isChecked) { alarmThreshold.setEnabled(!shouldDisableAlarmThreshold(typeSpinner.getSelectedItemPosition())); } } }); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { if (alarmCB.isChecked() && shouldDisableAlarmThreshold(position)) alarmThreshold.setEnabled(false); else if (!alarmCB.isChecked()) alarmThreshold.setEnabled(false); else alarmThreshold.setEnabled(true); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); subIntervalTV.setEnabled(false); subInterval.setEnabled(false); alarmThreshold.setEnabled(false); typeSpinner.setEnabled(false); alarmInfoTV.setText(alarmInfo); // Click checkboxes, show data depending on if subscription or alarm // has been added already if (isSubscribed) subscribedCB.performClick(); if (alarmCreated) { showAlarmSection.setVisibility(View.VISIBLE); makeAlarmSection.setVisibility(View.GONE); alarmCB.setText("Remove alarm"); } else { makeAlarmSection.setVisibility(View.VISIBLE); showAlarmSection.setVisibility(View.GONE); alarmCB.setText("Create alarm"); } dcSendCB.setChecked(isSendingToDC); subInterval.setText(Integer.toString(sinterval)); alarmThreshold.setText(Double.toString(threshold)); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.alarm_types, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); typeSpinner.setAdapter(adapter); typeSpinner.setSelection(alarmtypeidx); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { // Fetch the EndpointsAdapter's configuration for this endpoint. // (We might have gotten mConfig from the saved instance bundle) EndpointConfiguration cfg = EndpointsAdapter.getInstance() .findEndpointConfiguration(mConfig.getEndpoint()); // Set whether this endpoint's data should be pushed to Device Cloud if (cfg != null) { cfg.setPushToDeviceCloud(dcSendCB.isChecked()); } // Handle (un)subscribing if (isUnsubscribing(subscribedCB.isChecked())) { unsubscribe(mConfig.getEndpoint()); } else if (subscribedCB.isChecked()) { if (handleMakingSubscription(subInterval)) { // Subscription was successful... most likely. Log.d(TAG, "Probably subscribed to endpoint."); } else { // Invalid interval. Toast.makeText(getActivity(), getString(R.string.configure_endpoints_toast_invalid_sub_interval), Toast.LENGTH_SHORT).show(); } } // Handle adding/removing alarm as necessary if (isRemovingAlarm(alarmCB.isChecked())) { removeAlarm(mConfig.getEndpoint(), mConfig.getAlarmConfig().getType()); } else if (alarmCB.isChecked()) { Editable thresholdText = alarmThreshold.getText(); String thresholdString; if (thresholdText == null) thresholdString = ""; else thresholdString = thresholdText.toString(); double threshold; try { threshold = Double.parseDouble(thresholdString); } catch (NumberFormatException e) { Toast.makeText(getActivity(), getString(R.string.configure_endpoints_invalid_threshold), Toast.LENGTH_SHORT).show(); return; } int alarmidx = typeSpinner.getSelectedItemPosition(); if (alarmidx == -1) { // But... how? Log.wtf(TAG, "alarm type index -1 ?"); return; } String type = alarmTypes[alarmidx]; AlarmType atype = AlarmType.fromString(type); createAlarm(mConfig.getEndpoint(), atype, threshold); } dialog.dismiss(); } }; return new AlertDialog.Builder(getActivity()).setView(v).setTitle("Endpoint: " + endpointName) .setPositiveButton("Save", clickListener) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Cancel means just dismiss the dialog. dialog.dismiss(); } }).create(); }
From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor./*from w w w .j ava2 s .co m*/ * * @see Activity#onCreate */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CookieSyncManager.createInstance(getApplicationContext()); mSettings.loadRedditPreferences(this, mClient); setRequestedOrientation(mSettings.getRotation()); setTheme(mSettings.getTheme()); requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.inbox_list_content); registerForContextMenu(getListView()); if (mSettings.isLoggedIn()) { if (savedInstanceState != null) { mReplyTargetName = savedInstanceState.getString(Constants.REPLY_TARGET_NAME_KEY); mAfter = savedInstanceState.getString(Constants.AFTER_KEY); mBefore = savedInstanceState.getString(Constants.BEFORE_KEY); mCount = savedInstanceState.getInt(Constants.THREAD_COUNT_KEY); mLastAfter = savedInstanceState.getString(Constants.LAST_AFTER_KEY); mLastBefore = savedInstanceState.getString(Constants.LAST_BEFORE_KEY); mLastCount = savedInstanceState.getInt(Constants.THREAD_LAST_COUNT_KEY); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); mWhichInbox = savedInstanceState.getString(Constants.WHICH_INBOX_KEY); restoreLastNonConfigurationInstance(); if (mMessagesList == null) { // Load previous view of threads if (mLastAfter != null) { new DownloadMessagesTask(mWhichInbox, mLastAfter, null, mLastCount) .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } else if (mLastBefore != null) { new DownloadMessagesTask(mWhichInbox, null, mLastBefore, mLastCount) .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } else { new DownloadMessagesTask(mWhichInbox).execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } } else { // Orientation change. Use prior instance. resetUI(new MessagesListAdapter(this, mMessagesList)); } } else { Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(Constants.WHICH_INBOX_KEY)) mWhichInbox = extras.getString(Constants.WHICH_INBOX_KEY); } new DownloadMessagesTask(mWhichInbox).execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } } else { showDialog(Constants.DIALOG_LOGIN); } setTitle(String.format(getResources().getString(R.string.inbox_title), mSettings.getUsername())); }
From source file:cgeo.geocaching.CacheListActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme();/* w w w.j a va2 s . c o m*/ setContentView(R.layout.cacheslist_activity); // get parameters Bundle extras = getIntent().getExtras(); if (extras != null) { type = Intents.getListType(getIntent()); coords = extras.getParcelable(Intents.EXTRA_COORDS); } else { extras = new Bundle(); } if (isInvokedFromAttachment()) { type = CacheListType.OFFLINE; if (coords == null) { coords = Geopoint.ZERO; } } if (type == CacheListType.NEAREST) { coords = Sensors.getInstance().currentGeo().getCoords(); } setTitle(title); // Check whether we're recreating a previously destroyed instance if (savedInstanceState != null) { // Restore value of members from saved state currentFilter = savedInstanceState.getParcelable(STATE_FILTER); currentInverseSort = savedInstanceState.getBoolean(STATE_INVERSE_SORT); type = CacheListType.values()[savedInstanceState.getInt(STATE_LIST_TYPE, type.ordinal())]; listId = savedInstanceState.getInt(STATE_LIST_ID); } initAdapter(); prepareFilterBar(); if (type.canSwitch) { initActionBarSpinner(); } currentLoader = (AbstractSearchLoader) getSupportLoaderManager().initLoader(type.getLoaderId(), extras, this); // init if (CollectionUtils.isNotEmpty(cacheList)) { // currentLoader can be null if this activity is created from a map, as onCreateLoader() will return null. if (currentLoader != null && currentLoader.isStarted()) { showFooterLoadingCaches(); } else { showFooterMoreCaches(); } } if (isInvokedFromAttachment()) { listNameMemento.rememberTerm(extras.getString(Intents.EXTRA_NAME)); importGpxAttachement(); } }
From source file:android.support.v7.preference.PreferenceDialogFragmentCompat.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Fragment rawFragment = getTargetFragment(); if (!(rawFragment instanceof DialogPreference.TargetFragment)) { throw new IllegalStateException("Target fragment must implement TargetFragment" + " interface"); }//from ww w .j av a 2 s .co m final DialogPreference.TargetFragment fragment = (DialogPreference.TargetFragment) rawFragment; final String key = getArguments().getString(ARG_KEY); if (savedInstanceState == null) { mPreference = (DialogPreference) fragment.findPreference(key); mDialogTitle = mPreference.getDialogTitle(); mPositiveButtonText = mPreference.getPositiveButtonText(); mNegativeButtonText = mPreference.getNegativeButtonText(); mDialogMessage = mPreference.getDialogMessage(); mDialogLayoutRes = mPreference.getDialogLayoutResource(); final Drawable icon = mPreference.getDialogIcon(); if (icon == null || icon instanceof BitmapDrawable) { mDialogIcon = (BitmapDrawable) icon; } else { final Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.draw(canvas); mDialogIcon = new BitmapDrawable(getResources(), bitmap); } } else { mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE); mPositiveButtonText = savedInstanceState.getCharSequence(SAVE_STATE_POSITIVE_TEXT); mNegativeButtonText = savedInstanceState.getCharSequence(SAVE_STATE_NEGATIVE_TEXT); mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE); mDialogLayoutRes = savedInstanceState.getInt(SAVE_STATE_LAYOUT, 0); final Bitmap bitmap = savedInstanceState.getParcelable(SAVE_STATE_ICON); if (bitmap != null) { mDialogIcon = new BitmapDrawable(getResources(), bitmap); } } }
From source file:com.android.deskclock.AlarmClockFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { // Inflate the layout for this fragment final View v = inflater.inflate(R.layout.alarm_clock, container, false); long expandedId = INVALID_ID; long[] repeatCheckedIds = null; long[] selectedAlarms = null; Bundle previousDayMap = null;/* ww w.j a v a 2 s .co m*/ if (savedState != null) { expandedId = savedState.getLong(KEY_EXPANDED_ID); repeatCheckedIds = savedState.getLongArray(KEY_REPEAT_CHECKED_IDS); mRingtoneTitleCache = savedState.getBundle(KEY_RINGTONE_TITLE_CACHE); mDeletedAlarm = savedState.getParcelable(KEY_DELETED_ALARM); mUndoShowing = savedState.getBoolean(KEY_UNDO_SHOWING); selectedAlarms = savedState.getLongArray(KEY_SELECTED_ALARMS); previousDayMap = savedState.getBundle(KEY_PREVIOUS_DAY_MAP); mSelectedAlarm = savedState.getParcelable(KEY_SELECTED_ALARM); } mExpandInterpolator = new DecelerateInterpolator(EXPAND_DECELERATION); mCollapseInterpolator = new DecelerateInterpolator(COLLAPSE_DECELERATION); if (USE_TRANSITION_FRAMEWORK) { mAddRemoveTransition = new AutoTransition(); mAddRemoveTransition.setDuration(ANIMATION_DURATION); /// M: Scrap the views in ListView and request layout again, then alarm item will be /// attached correctly. This is to avoid the case when some items are not correctly /// attached after animation end @{ mAddRemoveTransition.addListener(new Transition.TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { mAlarmsList.clearScrapViewsIfNeeded(); } }); /// @} mRepeatTransition = new AutoTransition(); mRepeatTransition.setDuration(ANIMATION_DURATION / 2); mRepeatTransition.setInterpolator(new AccelerateDecelerateInterpolator()); mEmptyViewTransition = new TransitionSet().setOrdering(TransitionSet.ORDERING_SEQUENTIAL) .addTransition(new Fade(Fade.OUT)).addTransition(new Fade(Fade.IN)) .setDuration(ANIMATION_DURATION); } boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; View menuButton = v.findViewById(R.id.menu_button); if (menuButton != null) { if (isLandscape) { menuButton.setVisibility(View.GONE); } else { menuButton.setVisibility(View.VISIBLE); setupFakeOverflowMenuButton(menuButton); } } mEmptyView = v.findViewById(R.id.alarms_empty_view); mMainLayout = (FrameLayout) v.findViewById(R.id.main); mAlarmsList = (ListView) v.findViewById(R.id.alarms_list); mUndoBar = (ActionableToastBar) v.findViewById(R.id.undo_bar); mUndoFrame = v.findViewById(R.id.undo_frame); mUndoFrame.setOnTouchListener(this); mFooterView = v.findViewById(R.id.alarms_footer_view); mFooterView.setOnTouchListener(this); mAdapter = new AlarmItemAdapter(getActivity(), expandedId, repeatCheckedIds, selectedAlarms, previousDayMap, mAlarmsList); mAdapter.registerDataSetObserver(new DataSetObserver() { private int prevAdapterCount = -1; @Override public void onChanged() { final int count = mAdapter.getCount(); if (mDeletedAlarm != null && prevAdapterCount > count) { showUndoBar(); } if (USE_TRANSITION_FRAMEWORK && ((count == 0 && prevAdapterCount > 0) || /* should fade in */ (count > 0 && prevAdapterCount == 0) /* should fade out */)) { TransitionManager.beginDelayedTransition(mMainLayout, mEmptyViewTransition); } mEmptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE); // Cache this adapter's count for when the adapter changes. prevAdapterCount = count; super.onChanged(); } }); if (mRingtoneTitleCache == null) { mRingtoneTitleCache = new Bundle(); } mAlarmsList.setAdapter(mAdapter); mAlarmsList.setVerticalScrollBarEnabled(true); mAlarmsList.setOnCreateContextMenuListener(this); if (mUndoShowing) { showUndoBar(); } return v; }
From source file:com.cdvdev.subscriptiondemo.helpers.IabHelper.java
/** * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, * which will involve bringing up the Google Play screen. The calling activity will be paused * while the user interacts with Google Play, and the result will be delivered via the * activity's {@link android.app.Activity#onActivityResult} method, at which point you must call * this object's {@link #handleActivityResult} method to continue the purchase flow. This method * MUST be called from the UI thread of the Activity. * * @param act The calling activity.//from w w w . j av a 2 s. c om * @param sku The sku of the item to purchase. * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or * ITEM_TYPE_SUBS) * @param oldSkus A list of SKUs which the new SKU is replacing or null if there are none * @param requestCode A request code (to differentiate from other responses -- as in * {@link android.app.Activity#startActivityForResult}). * @param listener The listener to notify when the purchase process finishes * @param extraData Extra data (developer payload), which will be returned with the purchase * data when the purchase completes. This extra data will be permanently bound to that * purchase and will always be returned when the purchase is queried. */ public void launchPurchaseFlow(Activity act, String sku, String itemType, List<String> oldSkus, int requestCode, OnIabPurchaseFinishedListener listener, String extraData) { checkNotDisposed(); checkSetupDone("launchPurchaseFlow"); flagStartAsync("launchPurchaseFlow"); IabResult result; if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) { IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, "Subscriptions are not available."); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(r, null); return; } try { logDebug("Constructing buy intent for " + sku + ", item type: " + itemType); Bundle buyIntentBundle; if (oldSkus == null || oldSkus.isEmpty()) { // Purchasing a new item or subscription re-signup buyIntentBundle = mIInAppBillingService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData); } else { // Subscription upgrade/downgrade if (!mSubscriptionUpdateSupported) { IabResult r = new IabResult(IABHELPER_SUBSCRIPTION_UPDATE_NOT_AVAILABLE, "Subscription updates are not available."); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(r, null); return; } buyIntentBundle = mIInAppBillingService.getBuyIntentToReplaceSkus(5, mContext.getPackageName(), oldSkus, sku, itemType, extraData); } int response = getResponseCodeFromBundle(buyIntentBundle); if (response != BILLING_RESPONSE_RESULT_OK) { logError("Unable to buy item, Error response: " + getResponseDesc(response)); flagEndAsync(); result = new IabResult(response, "Unable to buy item"); if (listener != null) listener.onIabPurchaseFinished(result, null); return; } PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT); logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode); mRequestCode = requestCode; mPurchaseListener = listener; mPurchasingItemType = itemType; act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } catch (IntentSender.SendIntentException e) { logError("SendIntentException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent."); if (listener != null) listener.onIabPurchaseFinished(result, null); } catch (RemoteException e) { logError("RemoteException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow"); if (listener != null) listener.onIabPurchaseFinished(result, null); } }
From source file:com.androzic.MapActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); Log.e(TAG, "onRestoreInstanceState()"); lastKnownLocation = savedInstanceState.getParcelable("lastKnownLocation"); lastRenderTime = savedInstanceState.getLong("lastRenderTime"); lastMagnetic = savedInstanceState.getLong("lastMagnetic"); lastDim = savedInstanceState.getLong("lastDim"); lastGeoid = savedInstanceState.getBoolean("lastGeoid"); waypointSelected = savedInstanceState.getInt("waypointSelected"); routeSelected = savedInstanceState.getInt("routeSelected"); mapObjectSelected = savedInstanceState.getLong("mapObjectSelected"); /*//from www . ja va2 s.c o m * double[] distAncor = savedInstanceState.getDoubleArray("distAncor"); * if (distAncor != null) * { * application.distanceOverlay = new DistanceOverlay(this); * application.distanceOverlay.setAncor(distAncor); * } */ }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log_OC.v(TAG, "onCreate() start"); super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account // is valid /// grant that FileObserverService is watching favorite files if (savedInstanceState == null) { Intent initObserversIntent = FileObserverService.makeInitIntent(this); startService(initObserversIntent); }//from w w w .j a v a 2 s .c om /// Load of saved instance state if (savedInstanceState != null) { mWaitingToPreview = (OCFile) savedInstanceState .getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW); mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS); mWaitingToSend = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND); } else { mWaitingToPreview = null; mSyncInProgress = false; mWaitingToSend = null; } /// USER INTERFACE // Inflate and set the layout view setContentView(R.layout.files); // Navigation Drawer initDrawer(); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mProgressBar.setIndeterminateDrawable( ContextCompat.getDrawable(this, R.drawable.actionbar_progress_indeterminate_horizontal)); mDualPane = getResources().getBoolean(R.bool.large_land_layout); mLeftFragmentContainer = findViewById(R.id.left_fragment_container); mRightFragmentContainer = findViewById(R.id.right_fragment_container); // Action bar setup getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, // according to the official // documentation // enable ActionBar app icon to behave as action to toggle nav drawer //getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Log_OC.v(TAG, "onCreate() end"); }
From source file:antiboring.game.controller.appBilling.util.IabHelper.java
/** * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, * which will involve bringing up the Google Play screen. The calling activity will be paused * while the user interacts with Google Play, and the result will be delivered via the * activity's {@link android.app.Activity#onActivityResult} method, at which point you must call * this object's {@link #handleActivityResult} method to continue the purchase flow. This method * MUST be called from the UI thread of the Activity. * * @param act The calling activity.//www . j ava 2 s. co m * @param sku The sku of the item to purchase. * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or * ITEM_TYPE_SUBS) * @param oldSkus A list of SKUs which the new SKU is replacing or null if there are none * @param requestCode A request code (to differentiate from other responses -- as in * {@link android.app.Activity#startActivityForResult}). * @param listener The listener to notify when the purchase process finishes * @param extraData Extra data (developer payload), which will be returned with the purchase * data when the purchase completes. This extra data will be permanently bound to that * purchase and will always be returned when the purchase is queried. */ public void launchPurchaseFlow(Activity act, String sku, String itemType, List<String> oldSkus, int requestCode, OnIabPurchaseFinishedListener listener, String extraData) { checkNotDisposed(); checkSetupDone("launchPurchaseFlow"); flagStartAsync("launchPurchaseFlow"); IabResult result; if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) { IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, "Subscriptions are not available."); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(r, null); return; } try { logDebug("Constructing buy intent for " + sku + ", item type: " + itemType); Bundle buyIntentBundle; if (oldSkus == null || oldSkus.isEmpty()) { // Purchasing a new item or subscription re-signup buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData); } else { // Subscription upgrade/downgrade if (!mSubscriptionUpdateSupported) { IabResult r = new IabResult(IABHELPER_SUBSCRIPTION_UPDATE_NOT_AVAILABLE, "Subscription updates are not available."); flagEndAsync(); if (listener != null) listener.onIabPurchaseFinished(r, null); return; } buyIntentBundle = mService.getBuyIntentToReplaceSkus(5, mContext.getPackageName(), oldSkus, sku, itemType, extraData); } int response = getResponseCodeFromBundle(buyIntentBundle); if (response != BILLING_RESPONSE_RESULT_OK) { logError("Unable to buy item, Error response: " + getResponseDesc(response)); flagEndAsync(); result = new IabResult(response, "Unable to buy item"); if (listener != null) listener.onIabPurchaseFinished(result, null); return; } PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT); logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode); mRequestCode = requestCode; mPurchaseListener = listener; mPurchasingItemType = itemType; act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } catch (SendIntentException e) { logError("SendIntentException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent."); if (listener != null) listener.onIabPurchaseFinished(result, null); } catch (RemoteException e) { logError("RemoteException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow"); if (listener != null) listener.onIabPurchaseFinished(result, null); } }
From source file:net.naonedbus.activity.impl.CommentaireActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comment); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mLigneManager = LigneManager.getInstance(); mSensManager = SensManager.getInstance(); mArretManager = ArretManager.getInstance(); mAllLignes = Ligne.buildAllLigneItem(this); mAllSens = new Sens(-1, getString(R.string.target_tous_sens)); mAllArrets = new Arret.Builder().setId(-1).setNomArret(getString(R.string.target_tous_arrets)).build(); mLignesAdapter = getLignesAdapter(); mCommentText = (EditText) findViewById(android.R.id.input); mTextLigne = (TextView) findViewById(R.id.commentaireLigne); mTextSens = (TextView) findViewById(R.id.commentaireSens); mTextArret = (TextView) findViewById(R.id.commentaireArret); mBtnChangeLigne = findViewById(R.id.commentaireLigneSpinner); mBtnChangeLigne.setOnClickListener(new OnClickListener() { @Override// w w w . j a v a 2s . co m public void onClick(final View v) { showSelectLigneDialog(); } }); mBtnChangeSens = findViewById(R.id.commentaireSens); mBtnChangeSens.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { showSelectSensDialog(mLigne.getCode()); } }); mBtnChangeArret = findViewById(R.id.commentaireArret); mBtnChangeArret.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { showSelectArretDialog(mLigne.getCode(), mSens.code); } }); Ligne ligne; Sens sens; Arret arret; if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_KEY_LIGNE)) { ligne = (Ligne) savedInstanceState.getParcelable(BUNDLE_KEY_LIGNE); sens = (Sens) savedInstanceState.getParcelable(BUNDLE_KEY_SENS); arret = (Arret) savedInstanceState.getParcelable(BUNDLE_KEY_ARRET); } else { ligne = getIntent().getParcelableExtra(PARAM_LIGNE); sens = getIntent().getParcelableExtra(PARAM_SENS); arret = getIntent().getParcelableExtra(PARAM_ARRET); } if (ligne != null) { setLigne(ligne); } if (sens != null) { setSens(sens); } if (arret != null) { setArret(arret); } }