List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:org.easyrpg.player.player.EasyRpgPlayerActivity.java
public void updateScreenPosition() { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);//from w ww.j av a 2s .co m params.leftMargin = 0; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { params.topMargin = -(getWindowManager().getDefaultDisplay().getHeight() / 2); } else { params.topMargin = 0; } surface.setLayoutParams(params); }
From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java
/** * Used to set the selected day and week of the sprint in the activity. * @param dayInMillis/*from w ww . j a va2 s. c o m*/ */ public void setSelectedDay(long dayInMillis) { // Calculate the selected day position in the viewpager mSelectedDay = (int) TimeUnit.DAYS.convert(dayInMillis - mSprintStartDateInMillis, TimeUnit.MILLISECONDS); Calendar selectedDayAsCalendar = Calendar.getInstance(); selectedDayAsCalendar.setFirstDayOfWeek(Calendar.MONDAY); selectedDayAsCalendar.setTimeInMillis(dayInMillis); // Calculate the selected day position as week in the viewpager mSelectedWeek = selectedDayAsCalendar.get(Calendar.WEEK_OF_YEAR) - mStartDate.get(Calendar.WEEK_OF_YEAR); // Take into account change of year. if (mSelectedWeek < 0) { mSelectedWeek = 52 - mStartDate.get(Calendar.WEEK_OF_YEAR) + selectedDayAsCalendar.get(Calendar.WEEK_OF_YEAR); } else { } // Set the day or week depending on orientation. if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mViewPager.setCurrentItem(mSelectedDay); } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mViewPager.setCurrentItem(mSelectedWeek); } }
From source file:com.android.gallery3d.v5.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;//from w w w.jav a 2s. c o m } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { Log.i("Test", "showEditor"); EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java
private boolean shouldUseMultipleColumns() { boolean useMultiple = false; if (getResources() != null) { android.content.res.Configuration config = getResources().getConfiguration(); if (config != null) { switch (config.orientation) { case android.content.res.Configuration.ORIENTATION_LANDSCAPE: useMultiple = mPrefUtilities.useMultipleColumnsLandscape(); break; case android.content.res.Configuration.ORIENTATION_PORTRAIT: useMultiple = mPrefUtilities.useMultipleColumnsPortrait(); break; }//w w w .j a va 2 s . c o m } } else { useMultiple = mPrefUtilities.useMultipleColumnsPortrait(); } return useMultiple; }
From source file:net.quduo.pixel.interfaces.android.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // #?//from ww w . ja va 2 s. c o m // getWindow().requestFeature(Window.FEATURE_PROGRESS); // // ? // this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // // // ??? // // this.requestWindowFeature(Window.FEATURE_NO_TITLE); // // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // setContentView(R.layout.activity_main); // this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_title); setContentView(R.layout.activity_main); // #Application mApp = (MainApplication) getApplication(); // ????? if (DEBUG) Log.d(TAG, "Application ?:" + mApp.getValue()); // ? mApp.setValue("Harvey Ren"); // ????? if (DEBUG) Log.d(TAG, "Application ?:" + mApp.getValue()); // #???, // a.? String able = getResources().getConfiguration().locale.getCountry(); // b.able.equals("CN") // c.? Configuration config = getResources().getConfiguration(); DisplayMetrics dm = getResources().getDisplayMetrics(); config.locale = Locale.SIMPLIFIED_CHINESE; getResources().updateConfiguration(config, dm); // # NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(0); // #?/? if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { // TODO ?...... } else { // TODO ?...... } // setupActionBar(); /* // #drawer mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); */ initViews(); if (savedInstanceState != null && savedInstanceState.containsKey("main_status")) { mSelectPosition = savedInstanceState.getInt("main_status"); } preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); /* // ???? SharedPreferences.Editor editor = preferences.edit(); // ? editor.putInt("main_toolbar_selected_index", 0); // ?? editor.commit(); */ mPopupWindowListItem = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> map1 = new HashMap<String, Object>(); // map1.put("item_image", R.drawable.icon_message); map1.put("item_icon", R.string.icon_chat_add_group); // map1.put("item_text", "" + i + ""); map1.put("item_title", "??"); mPopupWindowListItem.add(map1); HashMap<String, Object> map2 = new HashMap<String, Object>(); // map2.put("item_image", R.drawable.icon_message); map2.put("item_icon", R.string.icon_friend_add); // map2.put("item_text", "" + i + ""); map2.put("item_title", "?"); mPopupWindowListItem.add(map2); HashMap<String, Object> map3 = new HashMap<String, Object>(); // map3.put("item_image", R.drawable.icon_message); map3.put("item_icon", R.string.icon_scan); // map3.put("item_text", "" + i + ""); // map3.put("item_title", "???"); mPopupWindowListItem.add(map3); HashMap<String, Object> map4 = new HashMap<String, Object>(); // map4.put("item_image", R.drawable.icon_message); map4.put("item_icon", R.string.icon_mail); // map4.put("item_text", "" + i + ""); map4.put("item_title", "??"); mPopupWindowListItem.add(map4); }
From source file:com.android.calendar.AllInOneActivity.java
@Override protected void onCreate(Bundle icicle) { if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) { setTheme(R.style.CalendarTheme_WithActionBarWallpaper); }//www . ja v a 2 s . c om super.onCreate(icicle); dynamicTheme.onCreate(this); if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) { mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS); } // Launch add google account if this is first time and there are no // accounts yet if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) { mHandler = new QueryHandler(this.getContentResolver()); mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null, null /* selection args */, null /* sort order */); } // This needs to be created before setContentView mController = CalendarController.getInstance(this); // Check and ask for most needed permissions checkAppPermissions(); // Get time from intent or icicle long timeMillis = -1; int viewType = -1; final Intent intent = getIntent(); if (icicle != null) { timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME); viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1); } else { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { // Open EventInfo later timeMillis = parseViewAction(intent); } if (timeMillis == -1) { timeMillis = Utils.timeFromIntentInMillis(intent); } } if (viewType == -1 || viewType > ViewType.MAX_VALUE) { viewType = Utils.getViewTypeFromIntentAndSharedPref(this); } mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater); Time t = new Time(mTimeZone); t.set(timeMillis); if (DEBUG) { if (icicle != null && intent != null) { Log.d(TAG, "both, icicle:" + icicle.toString() + " intent:" + intent.toString()); } else { Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent); } } Resources res = getResources(); mHideString = res.getString(R.string.hide_controls); mShowString = res.getString(R.string.show_controls); mOrientation = res.getConfiguration().orientation; if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) { mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width); if (mControlsParams == null) { mControlsParams = new LayoutParams(mControlsAnimateWidth, 0); } mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else { // Make sure width is in between allowed min and max width values mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100, (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width)); mControlsAnimateWidth = Math.min(mControlsAnimateWidth, (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width)); } mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height); mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config); mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month); mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen); mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen); mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time); Utils.setAllowWeekForDetailView(mIsMultipane); // setContentView must be called before configureActionBar setContentView(R.layout.all_in_one_material); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mNavigationView = (NavigationView) findViewById(R.id.navigation_view); mFab = (FloatingActionButton) findViewById(R.id.floating_action_button); if (mIsTabletConfig) { mDateRange = (TextView) findViewById(R.id.date_bar); mWeekTextView = (TextView) findViewById(R.id.week_num); } else { mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null); } setupToolbar(viewType); setupNavDrawer(); setupFloatingActionButton(); mHomeTime = (TextView) findViewById(R.id.home_time); mMiniMonth = findViewById(R.id.mini_month); if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) { mMiniMonth.setLayoutParams( new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight)); } mCalendarsList = findViewById(R.id.calendar_list); mMiniMonthContainer = findViewById(R.id.mini_month_container); mSecondaryPane = findViewById(R.id.secondary_pane); // Must register as the first activity because this activity can modify // the list of event handlers in it's handle method. This affects who // the rest of the handlers the controller dispatches to are. mController.registerFirstEventHandler(HANDLER_KEY, this); initFragments(timeMillis, viewType, icicle); // Listen for changes that would require this to be refreshed SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); mContentResolver = getContentResolver(); }
From source file:com.secbro.qark.filebrowser.FileBrowserFragment.java
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.d(LOGTAG, "ORIENTATION_LANDSCAPE"); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d(LOGTAG, "ORIENTATION_PORTRAIT"); }/*from ww w. j a va2 s. co m*/ // Layout apparently changes itself, only have to provide good onMeasure // in custom components // TODO: check with keyboard // if(newConfig.keyboard == Configuration.KEYBOARDHIDDEN_YES) }
From source file:github.daneren2005.dsub.fragments.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay();/* w w w . jav a 2 s. co m*/ swipeDistance = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; swipeVelocity = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; gestureScanner = new GestureDetector(this); playlistFlipper = (ViewFlipper) rootView.findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) rootView.findViewById(R.id.download_empty); songTitleTextView = (TextView) rootView.findViewById(R.id.download_song_title); albumArtImageView = (ImageView) rootView.findViewById(R.id.download_album_art_image); positionTextView = (TextView) rootView.findViewById(R.id.download_position); durationTextView = (TextView) rootView.findViewById(R.id.download_duration); statusTextView = (TextView) rootView.findViewById(R.id.download_status); progressBar = (SeekBar) rootView.findViewById(R.id.download_progress_bar); previousButton = (AutoRepeatButton) rootView.findViewById(R.id.download_previous); nextButton = (AutoRepeatButton) rootView.findViewById(R.id.download_next); pauseButton = rootView.findViewById(R.id.download_pause); stopButton = rootView.findViewById(R.id.download_stop); startButton = rootView.findViewById(R.id.download_start); repeatButton = (ImageButton) rootView.findViewById(R.id.download_repeat); bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark); rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad); rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good); toggleListButton = rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView) rootView.findViewById(R.id.download_list); FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new DownloadFileItemHelperCallback(this, true)); touchHelper.attachToRecyclerView(playlistView); starButton = (ImageButton) rootView.findViewById(R.id.download_star); if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) { starButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DownloadFile currentDownload = getDownloadService().getCurrentPlaying(); if (currentDownload != null) { final Entry currentSong = currentDownload.getSong(); toggleStarred(currentSong, new OnStarChange() { @Override void starChange(boolean starred) { if (currentSong.isStarred()) { starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); } else { starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); } } } }); } } }); } else { starButton.setVisibility(View.GONE); } View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); startButton.setOnTouchListener(touchListener); bookmarkButton.setOnTouchListener(touchListener); rateBadButton.setOnTouchListener(touchListener); rateGoodButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().previous(); return null; } }.execute(); setControlsVisible(true); } }); previousButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(-INCREMENT_TIME); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Boolean>(context) { @Override protected Boolean doInBackground() throws Throwable { getDownloadService().next(); return true; } }.execute(); setControlsVisible(true); } }); nextButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(INCREMENT_TIME); } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().pause(); return null; } }.execute(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().reset(); return null; } }.execute(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { start(); return null; } }.execute(); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); switch (repeatMode) { case OFF: Util.toast(context, R.string.download_repeat_off); break; case ALL: Util.toast(context, R.string.download_repeat_all); break; case SINGLE: Util.toast(context, R.string.download_repeat_single); break; default: break; } updateRepeatButton(); setControlsVisible(true); } }); bookmarkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { createBookmark(); } }); rateBadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 1, already set so unset if (entry.getRating() == 1) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } else { // Immediately skip to the next song downloadService.next(true); // Otherwise set rating to 1 setRating(entry, 1); rateBadButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_bad_selected)); // Make sure good rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } } }); rateGoodButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 5, already set so unset if (entry.getRating() == 5) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } else { // Otherwise set rating to maximum setRating(entry, 5); rateGoodButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_good_selected)); // Make sure bad rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } } }); toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); setControlsVisible(true); } }); View overlay = rootView.findViewById(R.id.download_overlay_buttons); final int overlayHeight = overlay != null ? overlay.getHeight() : -1; albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(final SeekBar seekBar) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().seekTo(progressBar.getProgress()); return null; } @Override protected void done(Void result) { seekInProgress = false; } }.execute(); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; } @Override public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { positionTextView.setText(Util.formatDuration(position / 1000)); setControlsVisible(true); } } }); if (Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) { View slider = rootView.findViewById(R.id.download_slider); slider.setPadding(0, 0, 0, 0); } return rootView; }
From source file:com.czh.testmpeg.videorecord.CameraActivity.java
private boolean prepareMediaRecorder() { mediaRecorder = new MediaRecorder(); mCamera.unlock();/*w w w . j a v a 2 s. com*/ mediaRecorder.setCamera(mCamera); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { if (cameraFront) { mediaRecorder.setOrientationHint(270); } else { mediaRecorder.setOrientationHint(90); } } mediaRecorder.setProfile(CamcorderProfile.get(quality)); File file = new File("/mnt/sdcard/videokit"); if (!file.exists()) { file.mkdirs(); } Date d = new Date(); String timestamp = String.valueOf(d.getTime()); // url_file = Environment.getExternalStorageDirectory().getPath() + "/videoKit" + timestamp + ".mp4"; url_file = "/mnt/sdcard/videokit/in.mp4"; // url_file = "/mnt/sdcard/videokit/" + timestamp + ".mp4"; File file1 = new File(url_file); if (file1.exists()) { file1.delete(); } mediaRecorder.setOutputFile(url_file); // https://developer.android.com/reference/android/media/MediaRecorder.html#setMaxDuration(int) ?? // mediaRecorder.setMaxDuration(CameraConfig.MAX_DURATION_RECORD); // 60s. // https://developer.android.com/reference/android/media/MediaRecorder.html#setMaxFileSize(int) ?? // mediaRecorder.setMaxFileSize(CameraConfig.MAX_FILE_SIZE_RECORD); //size 1G try { mediaRecorder.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); releaseMediaRecorder(); return false; } catch (IOException e) { e.printStackTrace(); releaseMediaRecorder(); return false; } return true; }
From source file:com.murrayc.galaxyzoo.app.QuestionFragment.java
private void update() { final FragmentActivity activity = getActivity(); if (activity == null) return;//w ww. j a v a 2 s . c o m if (mRootView == null) { //This can happen when update() is called by the parent fragment //after this fragment has been instantiated after an orientation change, //but before onCreateView() has been called. It's not a problem //because onCreateView() will call this method again after setting mRootView. //Log.error("QuestionFragment.update(): mRootView is null."); return; } //Wipe the question details, //to ensure that we don't have old question details if somethng goes wrong when we //try to get and show the correct question details. final TextView textViewTitle = (TextView) mRootView.findViewById(R.id.textViewTitle); if (textViewTitle == null) { Log.error("update(): textViewTitle is null."); return; } textViewTitle.setText(""); //Show the text: final TextView textViewText = (TextView) mRootView.findViewById(R.id.textViewText); if (textViewText == null) { Log.error("update(): textViewText is null."); return; } textViewText.setText(""); final TableLayout layoutAnswers = (TableLayout) mRootView.findViewById(R.id.layoutAnswers); if (layoutAnswers == null) { Log.error("update(): layoutAnswers is null."); return; } layoutAnswers.removeAllViews(); if (getSingleton() == null) { //The parent fragment's onSingletonInitialized has been called //but this fragment's onSingletonInitialized hasn't been called yet. //That's OK. update() will be called, indirectly, later by this fragment's onSingletonInitialized(). return; } final DecisionTree.Question question = getQuestion(); if (question == null) { Log.error("update(): question is null."); return; } //Show the title: textViewTitle.setText(question.getTitle()); //Show the text: textViewText.setText(question.getText()); layoutAnswers.setShrinkAllColumns(true); layoutAnswers.setStretchAllColumns(true); //Checkboxes: mCheckboxButtons.clear(); final int COL_COUNT = 4; int col = 1; int rows = 0; TableRow row = null; final LayoutInflater inflater = LayoutInflater.from(activity); for (final DecisionTree.Checkbox checkbox : question.getCheckboxes()) { //Start a new row if necessary: if (row == null) { row = addRowToTable(activity, layoutAnswers); rows++; } final ToggleButton button = (ToggleButton) inflater.inflate(R.layout.question_answer_checkbox, null); //Use just the highlighting (line, color, etc) to show that it's selected, //instead of On/Off, so we don't need a separate label. //TODO: Use the icon. See http://stackoverflow.com/questions/18598255/android-create-a-toggle-button-with-image-and-no-text //TODO: Avoid the highlight bar thing at the bottom being drawn over the text. final String text = checkbox.getText(); button.setText(text); button.setTextOn(text); button.setTextOff(text); insertButtonInRow(activity, row, button); final BitmapDrawable icon = getIcon(activity, checkbox); button.setCompoundDrawables(null, icon, null, null); mCheckboxButtons.put(checkbox.getId(), button); if (col < COL_COUNT) { col++; } else { col = 1; row = null; } } //Answers: for (final DecisionTree.Answer answer : question.getAnswers()) { //Start a new row if necessary: if (row == null) { row = addRowToTable(activity, layoutAnswers); rows++; } final Button button = createAnswerButton(activity, answer); insertButtonInRow(activity, row, button); final String questionId = question.getId(); final String answerId = answer.getId(); button.setOnClickListener(new View.OnClickListener() { public void onClick(final View v) { // Perform action on click onAnswerButtonClicked(questionId, answerId); } }); if (col < COL_COUNT) { col++; } else { col = 1; row = null; } } //Add empty remaining cells, to avoid the other cells from expanding to fill the space, //because we want them to line up with the same cells above and below. if ((row != null) && (rows > 1)) { final int remaining_in_row = COL_COUNT - col + 1; for (int i = 0; i < remaining_in_row; i++) { //TODO: We could use Space instead of FrameLayout when using API>14. final FrameLayout placeholder = new FrameLayout(activity); insertButtonInRow(activity, row, placeholder); } } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { /* This wastes even more space to be even more consistent: //Make sure there are always at least 2 rows, //so we request roughly the same amount of space each time: if (rows < 2) { row = addRowToTable(activity, layoutAnswers); final DecisionTree.Answer answer = new DecisionTree.Answer("bogus ID", "bogus title", getArbitraryIconId(), null, 0); final Button button = createAnswerButton(activity, answer); button.setVisibility(View.INVISIBLE); //It won't be seen, but it's size will be used. insertButtonInRow(activity, row, button); } */ //This will be used in a later onLayout(), //so we will know the correct height at least during the second classification, mRootView.setRowsCountForMaxHeightExperienced(rows); //Try to keep the height consistent, to avoid the user seeing everything moving about. final int min = mRootView.getMaximumHeightExperienced(rows); if (min > 0) { mRootView.setMinimumHeight(min); } } else { //Ignore any previously-set minimum height, //to stop the portrait-mode's layout from affecting the layout-mode's layout: mRootView.setMinimumHeight(0); } }