List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.ubuntuone.android.files.activity.PreferencesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mContext = this; mTracker = GoogleAnalyticsTracker.getInstance(); mTracker.start(Analytics.U1F_ACCOUNT, this); mTracker.trackPageView(TAG);/* w w w . j av a 2 s.c o m*/ super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Account category. final Preference username = findPreference(Preferences.USERNAME_KEY); final String usernameSummary = Preferences.getString(Preferences.USERNAME_KEY, "(?)"); username.setSummary(usernameSummary); setupOnClickPreference(Pref.INVITE_FRIEND, this); final Preference purchaseStorage = findPreference(Pref.PURCHASE_STORAGE); purchaseStorage.setOnPreferenceClickListener(mPurchaseStorageListener); final Preference upgradePlan = findPreference(Pref.UPGRADE_PLAN); upgradePlan.setOnPreferenceClickListener(mLinkListener); // Options category. final PreferenceScreen mediaUploadScreen = (PreferenceScreen) findPreference(Pref.MEDIA_UPLOAD); mediaUploadScreen.setOnPreferenceClickListener(whiteHackClick); // Photo Auto Upload final CheckBoxPreference photosAutoUploadToggle = (CheckBoxPreference) findPreference( Preferences.PHOTO_UPLOAD_ENABLED_KEY); photosAutoUploadToggle.setOnPreferenceClickListener(mPhotosAutoUploadToggleListener); final Preference photosAutoUploadSources = findPreference(Pref.PHOTOS_AUTO_UPLOAD_SOURCES); photosAutoUploadSources.setOnPreferenceClickListener(mPhotosAutoUploadSourcesListener); mPhotosAutoUploadDir = (Preference) findPreference(Preferences.PHOTO_UPLOAD_DIR_KEY); mPhotosAutoUploadDir.setOnPreferenceClickListener(mPhotosAutoUploadDirListener); final String photosAutoUploadDirectory = Preferences.getPhotoUploadDirectory(); mPhotosAutoUploadDir.setDefaultValue(photosAutoUploadDirectory); mPhotosAutoUploadDir.setSummary(photosAutoUploadDirectory); final Preference uploadPhotosNow = findPreference(Pref.UPLOAD_PHOTOS_NOW); uploadPhotosNow.setOnPreferenceClickListener(mUploadPhotosNowListener); final Preference cancelAllUploads = findPreference(Pref.CANCEL_ALL_UPLOADS); cancelAllUploads.setOnPreferenceClickListener(mCancelAllUploadsListener); // General final PreferenceScreen advancedOptionsScreen = (PreferenceScreen) findPreference(Pref.ADVANCED_OPTIONS); advancedOptionsScreen.setOnPreferenceClickListener(whiteHackClick); final Preference autoRetry = findPreference(Preferences.AUTO_RETRY_FAILED); autoRetry.setOnPreferenceChangeListener(mAutoRetryListener); final Preference clearPreviewCache = findPreference(Pref.CLEAR_PREVIEW_CACHE); clearPreviewCache.setOnPreferenceClickListener(mClearPreviewCacheListener); final Preference clearThumbCache = findPreference(Pref.CLEAR_THUMB_CACHE); clearThumbCache.setOnPreferenceClickListener(mClearThumbCacheListener); final Preference removeDevice = findPreference(Pref.REMOVE_DEVICE); removeDevice.setOnPreferenceClickListener(mRemoveDeviceListener); mRetryFailed = findPreference(Pref.RETRY_FAILED); mRetryFailed.setOnPreferenceClickListener(mRetryFailedListener); mCancelFailed = findPreference(Pref.CANCEL_FAILED); mCancelFailed.setOnPreferenceClickListener(mCancelFailedListener); // Manage category. final Preference manageAccount = findPreference(Pref.MANAGE_ACCOUNT); manageAccount.setOnPreferenceClickListener(mLinkListener); final Preference supportOptions = findPreference(Pref.SUPPORT_OPTIONS); supportOptions.setOnPreferenceClickListener(mLinkListener); final Preference feedback = findPreference(Pref.FEEDBACK); feedback.setOnPreferenceClickListener(mFeedbackListener); final PreferenceScreen reportScreen = (PreferenceScreen) findPreference(Pref.REPORT_PROBLEM); reportScreen.setOnPreferenceClickListener(whiteHackClick); mCollectLogs = (CheckBoxPreference) findPreference(Pref.COLLECT_LOGS); mCollectLogs.setOnPreferenceClickListener(mCollectLogsListener); mReviewLogs = findPreference(Pref.REVIEW_LOGS); mReviewLogs.setOnPreferenceClickListener(mReviewLogsListener); mSendLogs = findPreference(Pref.SEND_LOGS); mSendLogs.setOnPreferenceClickListener(mSendLogsListener); final PreferenceScreen about = (PreferenceScreen) findPreference(Pref.ABOUT); about.setSummary(UbuntuOneFiles.getVersion()); about.setOnPreferenceClickListener(whiteHackClick); final Preference license = findPreference(Pref.LICENSE); license.setOnPreferenceClickListener(mLinkListener); final Preference changelog = findPreference(Pref.CHANGELOG); changelog.setOnPreferenceClickListener(mChangelogListener); final Preference author = findPreference(Pref.AUTHORS); author.setOnPreferenceClickListener(mLinkListener); final Preference webpage = findPreference(Pref.WEBPAGE); webpage.setOnPreferenceClickListener(mLinkListener); final Preference greendroid = findPreference(Pref.GREENDROID); greendroid.setOnPreferenceClickListener(mLinkListener); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (UpDownService.BROADCAST_UPLOAD_INFO.equals(action)) { final String info = intent.getStringExtra(Intent.EXTRA_TEXT); if (info != null) { runOnUiThread(new Runnable() { @Override public void run() { adjustTransferPreferencesState(); Preference p = findPreference(Pref.UPLOAD_PHOTOS_NOW); if (p != null) { p.setSummary(info); } } }); } } } }; registerAutoUploadInfoReceiver(receiver); Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(AUTOUPLOAD_SCREEN)) { openPreference(Pref.MEDIA_UPLOAD); } else if (intent.hasExtra(PURCHASE_STORAGE_SCREEN)) { openPreference(Pref.PURCHASE_STORAGE); } else if (intent.hasExtra(SHOW_RETRY_FAILED)) { // Simply shows top screen. Hilight retry failed pref? } } }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected SafeBroadcastReceiver getBroadcastReceiver() { return new SafeBroadcastReceiver() { @Override//from w ww . j a va 2s . co m public String[] onSafeReceive(Context context, Intent intent) { T.UI(); String action = intent.getAction(); if (MessagingPlugin.MESSAGE_MEMBER_STATUS_UPDATE_RECEIVED_INTENT.equals(action) || MessagingPlugin.MESSAGE_LOCKED_INTENT.equals(action) || MessagingPlugin.MESSAGE_PROCESSED_INTENT.equals(action)) { if (mCurrentMessage != null && intent.hasExtra("message") && intent.getStringExtra("message").equals(mCurrentMessage.key)) { updateView(true); return UPDATE_VIEW_INTENT_ACTIONS; } } if (FriendsPlugin.FRIEND_UPDATE_INTENT.equals(action) || IdentityStore.IDENTITY_CHANGED_INTENT.equals(action) || FriendsPlugin.FRIENDS_LIST_REFRESHED.equals(action) || FriendsPlugin.FRIEND_AVATAR_CHANGED_INTENT.equals(action)) { updateView(true); return UPDATE_VIEW_INTENT_ACTIONS; } if (MessagingPlugin.NEW_MESSAGE_RECEIVED_INTENT.equals(action)) { String trasferFailedMessage = "DASHBOARD_" + mCurrentMessage.key; if (mTransfering && trasferFailedMessage.equals(intent.getStringExtra("context"))) { final Intent i = new Intent(context, ServiceMessageDetailActivity.class); i.putExtra("message", intent.getStringExtra("message")); startActivity(i); overridePendingTransition(R.anim.slide_in_bottom, R.anim.slide_out_up); dismissTransferingDialog(); finish(); return new String[] { action }; } if (mContext != null && mContext.equals(intent.getStringExtra("context"))) { L.d("Showing broadcast flow"); } else { if (mExpectNextTimer == null) // Not interested in NEW_MESSAGE_RECEIVED_INTENTS at this moment return new String[] { action }; // We are expecting a reply on this thread! String pKey = mCurrentMessage.getThreadKey(); if (!pKey.equals(intent.getStringExtra("parent"))) { L.d("New message is from another thread"); return null; // New message is from another thread } // We received the reply! mExpectNextTimer.cancel(); mExpectNextTimer = null; } final Intent i = new Intent(context, ServiceMessageDetailActivity.class); i.putExtra("message", intent.getStringExtra("message")); startActivity(i); overridePendingTransition(R.anim.slide_in_bottom, R.anim.slide_out_up); dismissTransferingDialog(); finish(); return new String[] { action }; } if (MessagingPlugin.MESSAGE_JSMFR_ERROR.equals(action)) { if (mExpectNextTimer == null) // Not interested in MESSAGE_JSMFR_ERROR at this moment return new String[] { action }; String threadKey = mCurrentMessage.getThreadKey(); if (!threadKey.equals(intent.getStringExtra("parent_message_key")) && !threadKey.equals(intent.getStringExtra("message_key"))) { return null; // Intent is for another thread } mExpectNextTimer.cancel(); mExpectNextTimer = null; dismissTransferingDialog(); Bundle extras = new Bundle(); extras.putBoolean(ServiceActionMenuActivity.SHOW_ERROR_POPUP, true); jumpToServiceHomeScreen(null, extras); updateView(false); return new String[] { action }; } if (MessagingPlugin.MESSAGE_FLOW_ENDED_INTENT.equals(action)) { if (mExpectNextTimer == null) // Not interested in MESSAGE_JSMFR_ERROR at this moment return new String[] { action }; String threadKey = mCurrentMessage.getThreadKey(); if (!threadKey.equals(intent.getStringExtra("parent_message_key"))) { return null; // Intent is for another thread } if (intent.getBooleanExtra("wait_for_followup", false)) { return null; // We must keep on waiting } mExpectNextTimer.cancel(); mExpectNextTimer = null; dismissTransferingDialog(); jumpToServiceHomeScreen(null, null); return new String[] { action }; } if (BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT.equals(intent.getAction())) { if (intent.getStringExtra(BrandingMgr.BRANDING_KEY).equals(mCurrentMessage.branding)) { updateView(false); return new String[] { action }; } } if (MessagingPlugin.MESSAGE_SUBMIT_PHOTO_UPLOAD.equals(action)) { L.d("MessagingPlugin.MESSAGE_SUBMIT_PHOTO_UPLOAD.equals(action)"); if (intent.hasExtra("submitToJSMFR")) messageSubmitToJsMfr(intent, action); String messageKey = intent.getStringExtra("message_key"); if (mCurrentMessage.key.equals(messageKey)) { transferComplete(); } return null; } return null; } }; }
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_feed_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w . j av a2 s . c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); setResult(RESULT_CANCELED); Intent intent = getIntent(); mTabHost = (TabHost) findViewById(R.id.tabHost); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View tabWidget = findViewById(android.R.id.tabs); mTabHost.setup(); mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title)) .setContent(R.id.feed_tab)); mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title)) .setContent(R.id.filters_tab)); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { invalidateOptionsMenu(); } }); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB)); } if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); mUrlEditText.setText(intent.getDataString()); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); mFiltersCursorAdapter = new FiltersCursorAdapter(this, Constants.EMPTY_CURSOR); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startSupportActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (savedInstanceState == null) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor != null && cursor.moveToNext()) { mNameEditText.setText(cursor.getString(0)); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); if (cursor.getInt(3) == 1) { // if it's a group, we cannot edit it finish(); } } else { UiUtils.showMessage(EditFeedActivity.this, R.string.error); finish(); } if (cursor != null) { cursor.close(); } } } }
From source file:com.stockita.stockitapointofsales.activities.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { /**//from ww w .j a v a2 s .c o m * Credit card scanner, this is coming from * {@link #onPayButton(String, SalesHeaderModel, ArrayList, String, String)} ()} */ case MY_SCAN_REQUEST_CODE: String number = ""; String expMonth = ""; String expYear = ""; if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); number = scanResult.getFormattedCardNumber(); expMonth = String.valueOf(scanResult.expiryMonth); expYear = String.valueOf(scanResult.expiryYear); } else { Toast.makeText(this, "scan cancel", Toast.LENGTH_SHORT).show(); } /** * Pass the data again with credit card information, this is IntentService * {@link SalesPendingPayButtonIntentService#insertPay(Context, String, SalesHeaderModel, ArrayList, String, String, String, String)} */ SalesPendingPayButtonIntentService.insertPay(this, qqUserUid, qqSalesHeaderModel, qqSalesDetailModelList, number, expMonth + "/" + expYear, qqCashPaid, qqChangeCash); // break break; /** * Result of image from the gallery then upload to firebase storage */ case GET_FROM_GALLERY_REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { // The image Uri Uri selectedImage = data.getData(); // Convert the image Uri into real file path String realFilePath = null; try { realFilePath = Utility.convertMediaUriToPath(selectedImage, this); } catch (Exception e) { e.printStackTrace(); } // This helper method is to upload image to server saveImageIntoRealDatabaseAndStorage(realFilePath); } else { Toast.makeText(this, "System failed", Toast.LENGTH_SHORT).show(); } break; /** * Result from the camera */ case TAKE_PHOTO: if (resultCode == Activity.RESULT_OK) { // The image Uri Uri selectedImage = data.getData(); // Convert the image Uri into real file path String realFilePath = selectedImage.getPath(); // This helper method is to upload image to server saveImageIntoRealDatabaseAndStorage(realFilePath); } else { // Image capture failed, advise user Toast.makeText(this, "System failed", Toast.LENGTH_SHORT).show(); } } }
From source file:com.honglang.zxing.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); // resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;// w ww. j a va 2 s. c om lastResult = null; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); } beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); decodeHints = DecodeHintManager.parseDecodeHints(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); // scanFromWebPageManager = new // ScanFromWebPageManager(inputUri); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); // Allow a sub-set of the hints to be specified by the caller. decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
From source file:com.carlrice.reader.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_feed_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//w w w. j av a 2s . c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); setResult(RESULT_CANCELED); Intent intent = getIntent(); mTabHost = (TabHost) findViewById(R.id.tabHost); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View tabWidget = findViewById(android.R.id.tabs); View buttonLayout = findViewById(R.id.button_layout); mTabHost.setup(); mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title)) .setContent(R.id.feed_tab)); mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title)) .setContent(R.id.filters_tab)); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { invalidateOptionsMenu(); } }); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB)); } if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, Constants.EMPTY_CURSOR); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startSupportActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (savedInstanceState == null) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mNameEditText.setText(cursor.getString(0)); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }
From source file:com.studyjams.mdvideo.PlayerModule.ExoPlayerV2.PlayerActivityV2.java
/**debug?**/ // @Override//from w w w . j a v a2 s .c o m // public void onClick(View view) { // if (view == retryButton) { // initializePlayer(); // } else if (view.getParent() == debugRootView) { // trackSelectionHelper.showSelectionDialog(this, ((Button) view).getText(), // trackSelector.getCurrentSelections().info, (int) view.getTag()); // } // } // PlaybackControlView.VisibilityListener implementation // // @Override // public void onVisibilityChange(int visibility) { // debugRootView.setVisibility(visibility); // } // Internal methods private void initializePlayer() { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); String intentType = intent.getStringExtra(CONTENT_TYPE_INTENT); if (Intent.ACTION_SEND.equals(action) && type.equals("video/*")) { mContentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); mContentId = ""; mContentPosition = C.TIME_UNSET; mSubtitleUri = null; } else if (intentType.equals(D.TYPE_VIDEO)) { mContentUri = intent.getData(); mContentId = intent.getStringExtra(CONTENT_ID_EXTRA); mContentPosition = intent.getLongExtra(CONTENT_POSITION_EXTRA, 0); String subtitle = intent.getStringExtra(CONTENT_SUBTITLE_EXTRA); if (!TextUtils.isEmpty(subtitle)) { mSubtitleUri = Uri.parse(subtitle); } else { mSubtitleUri = null; } playerPosition = mContentPosition; } else if (intentType.equals(D.TYPE_SUBTITLE)) { mSubtitleUri = intent.getData(); } if (player == null) { boolean preferExtensionDecoders = intent.getBooleanExtra(PREFER_EXTENSION_DECODERS, false); UUID drmSchemeUuid = intent.hasExtra(DRM_SCHEME_UUID_EXTRA) ? UUID.fromString(intent.getStringExtra(DRM_SCHEME_UUID_EXTRA)) : null; DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null; if (drmSchemeUuid != null) { String drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL); String[] keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES); Map<String, String> keyRequestProperties; if (keyRequestPropertiesArray == null || keyRequestPropertiesArray.length < 2) { keyRequestProperties = null; } else { keyRequestProperties = new HashMap<>(); for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) { keyRequestProperties.put(keyRequestPropertiesArray[i], keyRequestPropertiesArray[i + 1]); } } try { drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl, keyRequestProperties); } catch (UnsupportedDrmException e) { int errorStringId = Util.SDK_INT < 18 ? R.string.error_drm_not_supported : (e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown); showToast(errorStringId); return; } } eventLogger = new EventLogger(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory( BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory); trackSelector.addListener(this); trackSelector.addListener(eventLogger); trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager, preferExtensionDecoders); player.addListener(this); player.addListener(eventLogger); player.setAudioDebugListener(eventLogger); player.setVideoDebugListener(eventLogger); player.setId3Output(eventLogger); simpleExoPlayerView.setPlayer(player); //?mediaController controller.setPlayer(player); controller.setTitle(mContentUri.getLastPathSegment()); // if (isTimelineStatic) { if (playerPosition == C.TIME_UNSET) { player.seekToDefaultPosition(playerWindow); } else { player.seekTo(playerWindow, playerPosition); } // } player.setPlayWhenReady(shouldAutoPlay); /**? debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.start();**/ playerNeedsSource = true; } if (playerNeedsSource) { // String action = intent.getAction(); Uri[] uris; String[] extensions; if (ACTION_VIEW.equals(action)) { // uris = new Uri[]{intent.getData()}; uris = new Uri[] { mContentUri }; extensions = new String[] { intent.getStringExtra(EXTENSION_EXTRA) }; } else if (ACTION_VIEW_LIST.equals(action)) { String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA); uris = new Uri[uriStrings.length]; for (int i = 0; i < uriStrings.length; i++) { uris[i] = Uri.parse(uriStrings[i]); } extensions = intent.getStringArrayExtra(EXTENSION_LIST_EXTRA); if (extensions == null) { extensions = new String[uriStrings.length]; } } else { showToast(getString(R.string.unexpected_intent_action, action)); return; } if (Util.maybeRequestReadExternalStoragePermission(this, uris)) { // The player will be reinitialized if the permission is granted. return; } MediaSource[] mediaSources = new MediaSource[uris.length]; for (int i = 0; i < uris.length; i++) { mediaSources[i] = buildMediaSource(uris[i], extensions[i]); } MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); player.prepare(mediaSource, !isTimelineStatic, !isTimelineStatic); playerNeedsSource = false; // updateButtonVisibilities(); } }
From source file:com.app.uafeed.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_feed_edit); setResult(RESULT_CANCELED);// www . ja v a 2 s . c o m Intent intent = getIntent(); mTabHost = (TabHost) findViewById(R.id.tabHost); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View tabWidget = findViewById(android.R.id.tabs); View buttonLayout = findViewById(R.id.button_layout); mTabHost.setup(); mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title)) .setContent(R.id.feed_tab)); mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title)) .setContent(R.id.filters_tab)); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { invalidateOptionsMenu(); } }); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB)); } if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (savedInstanceState == null) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }