List of usage examples for android.widget RelativeLayout getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
private void updateSearchView(final String query) { View view = getView();/*from ww w . ja v a 2 s . co m*/ if (view == null) { logger.error("No view created yet!!! query: " + query); return; } RelativeLayout callSearchLayout = (RelativeLayout) view.findViewById(R.id.callSearchLayout); if (StringUtils.isNullOrEmpty(query)) { if (callSearchLayout != null) { callSearchLayout.setVisibility(View.INVISIBLE); callSearchLayout.getLayoutParams().height = 0; } } else { if (callSearchLayout != null) { TextView searchContactView = (TextView) callSearchLayout.findViewById(R.id.callSearchContact); searchContactView.setText(query); callSearchLayout.getLayoutParams().height = searchContactView.getResources() .getDimensionPixelSize(R.dimen.account_list_row_height); callSearchLayout.setVisibility(View.VISIBLE); final ImageButton callButton = (ImageButton) callSearchLayout.findViewById(R.id.contactCallButton); callButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AndroidCallUtil.createAndroidCall(getActivity(), callButton, query); } }); } } }
From source file:org.ale.scanner.zotero.MainActivity.java
private void redrawPendingList() { /* Pretty terrible hack, Android doesn't like my ListView inside a * relative layout as a header in an expandable list view. Go figure. * It wasn't getting the height of said element correctly. */ int count = mPendingAdapter.getCount(); RelativeLayout r = ((RelativeLayout) findViewById(R.id.pending_item_holder)); AbsListView.LayoutParams params = (AbsListView.LayoutParams) r.getLayoutParams(); params.height = count * mPendingAdapter._hack_childSize; r.setLayoutParams(params);//from w w w .j av a 2 s . co m }
From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java
public void init() { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(getApplicationContext()); mMediaPlayer.setScreenOnWhilePlaying(true); }//from w w w . j a va 2s . co m mHandler = new Handler(); mDecorView = getWindow().getDecorView(); mSeekbar = (SeekBar) findViewById(R.id.activity_main_seekbar); mSeekbar.setMax(1000); mPlayPauseButton = (ImageView) findViewById(R.id.activity_main_playpause_button); mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer); mTopLayout = (RelativeLayout) findViewById(R.id.activity_main_mainlayout); mTrackDialog = new AudioSubtitleTrackDialog(this); mAudioPos = mSubPos = 0; mTimeView = (TextView) findViewById(R.id.activity_main_time); mDurationView = (TextView) findViewById(R.id.activity_main_duration); mTimeLayout = (LinearLayout) findViewById(R.id.activity_main_timelayout); mTimeTracker = new TimeTracker(mMediaPlayer, mTimeView); mSubtitleView = (TextView) findViewById(R.id.activity_main_subtitleView); mSubtitleRenderer = new SubtitleRenderer(mSubtitleView, Looper.myLooper(), mMediaPlayer); mSubtitleLayoutAboveTimeView = (RelativeLayout.LayoutParams) mSubtitleView.getLayoutParams(); mSubtitleLayoutBottom = (RelativeLayout.LayoutParams) ((TextView) findViewById( R.id.activity_main_subtitleView_params)).getLayoutParams(); mTimeSeekView = (TextView) findViewById(R.id.activity_main_time_seek); mMediaPlayer.setOnInfoListener(this); RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); ExpandableListView elv = (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view); ListView lv = (ListView) browsingL.findViewById(R.id.file_browsing_listview); RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view); LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setScrimColor(Color.TRANSPARENT); mDrawerLayout.setDrawerListener(this); mFileBrowser = new MediaBrowser(this, elv, lv, mMediaPlayer, (MainActivity) this, mDrawerLayout, debugLinearLayout); mIsFileBrowsing = false; mPreview = (SurfaceView) findViewById(R.id.mSurfaceView); mPreview.setOnTouchListener(this); mTopLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); mPreview.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); mSubtitleTracker = new HashMap<Integer, Integer>(); mAudioTracker = new HashMap<Integer, Integer>(); findViewById(R.id.activity_main_loading_panel).bringToFront(); findViewById(R.id.activity_main_browsing_layout).bringToFront(); mUpperControls = (RelativeLayout) findViewById(R.id.UpperButtonLayout); mBottomControls = (RelativeLayout) findViewById(R.id.ButtonLayout); mSlideInAnimation = AnimationUtils.loadAnimation(this, R.anim.in_top); mSlideInAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mUpperControls.setVisibility(View.VISIBLE); Runnable r = new Runnable() { @Override public void run() { mBottomControls.setVisibility(View.INVISIBLE); } }; mHandler.postDelayed(r, 3500); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mBottomControls.setVisibility(View.INVISIBLE); } }); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mFadeOutRunnable = new Runnable() { @Override public void run() { mSeekbar.setEnabled(false); Animation fadeoutBottom = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_bottom); fadeoutBottom.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mOngoingAnimation) { mOngoingAnimation = false; mBottomControls.setVisibility(View.INVISIBLE); mUpperControls.setVisibility(View.INVISIBLE); mSeekbar.setVisibility(View.GONE); mTimeLayout.setVisibility(View.GONE); mSubtitleView.setLayoutParams(mSubtitleLayoutBottom); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mOngoingAnimation = true; } }); Animation fadeoutTop = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_top); mBottomControls.startAnimation(fadeoutBottom); mUpperControls.startAnimation(fadeoutTop); mSeekbar.startAnimation(fadeoutBottom); mTimeLayout.startAnimation(fadeoutBottom); } }; mHideNavigationRunnable = new Runnable() { @Override public void run() { mPreview.setSystemUiVisibility(mUiOptions); } }; mDecorView.setOnSystemUiVisibilityChangeListener(this); mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer)); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnSubtitleDataListener(this); RelativeLayout browsingLayout = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) browsingLayout.getLayoutParams(); Resources resources = getResources(); int top = 0; int bottom = 0; RelativeLayout.LayoutParams tempParams; int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { top = resources.getDimensionPixelSize(resourceId); } resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottom = resources.getDimensionPixelSize(resourceId); } if (navigationBarAtBottom()) { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.bottomMargin += bottom; mBottomControls.setLayoutParams(tempParams); tempParams = (RelativeLayout.LayoutParams) mSeekbar.getLayoutParams(); tempParams.bottomMargin += bottom; mSeekbar.setLayoutParams(tempParams); params.setMargins(0, top, 0, bottom); } else { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.rightMargin += bottom; mBottomControls.setLayoutParams(tempParams); params.setMargins(0, top, 0, 0); } browsingLayout.setLayoutParams(params); mDrawerLayout.openDrawer(Gravity.START); mMediaPlayer.setOnOutputControlListener(this); }
From source file:com.z3r0byte.magistify.DashboardActivity.java
private void setupChangeCard() { ScheduleChangeDB db = new ScheduleChangeDB(this); Appointment[] rawAppointments = db.getChanges(); /*rawAppointments = new Appointment[4]; /*from ww w .ja v a 2 s. com*/ rawAppointments[0] = new Appointment(); rawAppointments[0].description = "Roosterwijziging 1"; rawAppointments[0].startDate = new Date(); rawAppointments[0].endDate = rawAppointments[0].startDate; rawAppointments[0].location = "Lokatie 1"; rawAppointments[0].periodFrom = 2; rawAppointments[1] = new Appointment(); rawAppointments[1].description = "Roosterwijziging 2"; rawAppointments[1].startDate = new Date(); rawAppointments[1].endDate = rawAppointments[1].startDate; rawAppointments[1].location = "Lokatie 2"; rawAppointments[1].periodFrom = 6; rawAppointments[2] = new Appointment(); rawAppointments[2].description = "Roosterwijziging 3"; rawAppointments[2].startDate = DateUtils.addDays(new Date(),1); rawAppointments[2].endDate = rawAppointments[2].startDate; rawAppointments[2].location = "Lokatie 3"; rawAppointments[2].periodFrom = 4; rawAppointments[3] = new Appointment(); rawAppointments[3].description = "Roosterwijziging 4"; rawAppointments[3].startDate = new Date(); rawAppointments[3].endDate = rawAppointments[3].startDate; rawAppointments[3].location = "Lokatie 4"; rawAppointments[3].periodFrom = 9;*/ Appointment[] appointments = null; if (rawAppointments != null && rawAppointments.length > 0) { if (rawAppointments.length == 1) { appointments = new Appointment[1]; appointments[0] = rawAppointments[0]; } else if (rawAppointments.length == 2) { appointments = new Appointment[2]; appointments[0] = rawAppointments[0]; appointments[1] = rawAppointments[1]; } else { appointments = new Appointment[3]; appointments[0] = rawAppointments[0]; appointments[1] = rawAppointments[1]; appointments[2] = rawAppointments[2]; } } scheduleChangeMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(getApplicationContext(), ScheduleChangeActivity.class)); } }); if (appointments != null && appointments.length > 0) { findViewById(R.id.layout_no_schedule_changes).setVisibility(View.GONE); ListView listView = (ListView) findViewById(R.id.list_scheduleChanges); ScheduleChangeAdapter adapter = new ScheduleChangeAdapter(this, appointments); RelativeLayout rootView = (RelativeLayout) findViewById(R.id.card_schedulechanges_layout); listView.setVisibility(View.VISIBLE); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { startActivity(new Intent(DashboardActivity.this, ScheduleChangeActivity.class)); } }); final float scale = this.getResources().getDisplayMetrics().density; rootView.getLayoutParams().height = (int) (90 * appointments.length * scale + 160f); } else { findViewById(R.id.layout_schedule_changes).setVisibility(View.GONE); findViewById(R.id.layout_no_schedule_changes).setVisibility(View.VISIBLE); } }
From source file:com.lastsoft.plog.PlaysFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_plays, container, false); rootView.setTag(TAG);// w ww . jav a2s.c o m // BEGIN_INCLUDE(initializeRecyclerView) mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background)); RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller); // Connect the recycler to the scroller (to let the scroller scroll the list) fastScroller.attachRecyclerView(mRecyclerView); addPlay = (FloatingActionButton) rootView.findViewById(R.id.add_play); if (fromDrawer && playListType != 2) { addPlay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int viewXY[] = new int[2]; v.getLocationOnScreen(viewXY); /*if (mListener != null) { mListener.onFragmentInteraction("add_play", viewXY[0], viewXY[1]); }*/ ((MainActivity) mActivity).usedFAB = true; ((MainActivity) mActivity).openGames("", true, 0, getString(R.string.title_games), MainActivity.CurrentYear); } }); } else { addPlay.setVisibility(View.GONE); } fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); mRecyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { addPlay.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { addPlay.animate().translationY(addPlay.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle) //mRecyclerView.addOnScrollListener(fastScroller.getOnScrollListener()); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(mActivity); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); //mAdapter = new PlayAdapter(mActivity, this); /*if (((MainActivity)mActivity).mPlayAdapter != null) { mAdapter = ((MainActivity) mActivity).mPlayAdapter; }else{*/ mAdapter = ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); //} // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); // END_INCLUDE(initializeRecyclerView) if (mSearch != null) { mSearch.setHint( getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_plays)); } /*boolean pauseOnScroll = true; // or true boolean pauseOnFling = true; // or false NewPauseOnScrollListener listener = new NewPauseOnScrollListener(ImageLoader.getInstance(), pauseOnScroll, pauseOnFling); mRecyclerView.addOnScrollListener(listener);*/ if (!fromDrawer) { RelativeLayout playsLayout = (RelativeLayout) rootView.findViewById(R.id.playsLayout); final SwipeDismissBehavior<LinearLayout> behavior = new SwipeDismissBehavior(); behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END); behavior.setStartAlphaSwipeDistance(1.0f); behavior.setSensitivity(0.15f); behavior.setListener(new SwipeDismissBehavior.OnDismissListener() { @Override public void onDismiss(final View view) { PlaysFragment myFragC1 = (PlaysFragment) getFragmentManager().findFragmentByTag("plays"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.remove(myFragC1); transaction.commitAllowingStateLoss(); getFragmentManager().executePendingTransactions(); mActivity.onBackPressed(); } @Override public void onDragStateChanged(int i) { } }); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) playsLayout.getLayoutParams(); params.setBehavior(behavior); } if (mSearch != null) { mSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text if (mActivity != null) { mSearchQuery = cs.toString(); //initDataset(); //mAdapter = new GameAdapter(PlaysFragment.this, mActivity,mSearchQuery); mAdapter = ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); } } @Override public void afterTextChanged(Editable editable) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!mSearch.getText().toString().equals("")) { mSearchQuery = ""; ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); mSearch.setText(mSearchQuery); //mActivity.onBackPressed(); } InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mSearch.clearFocus(); mRecyclerView.requestFocus(); refreshDataset(); } }); } return rootView; }
From source file:com.lastsoft.plog.GamesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_games, container, false); rootView.setTag(TAG);//from w ww . j a v a2 s .c om // BEGIN_INCLUDE(initializeRecyclerView) mCoordinatorLayout = (CoordinatorLayout) rootView.findViewById(R.id.coordinatorLayout); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background)); pullToRefreshView = (SwipeRefreshLayout) rootView.findViewById(R.id.pull_to_refresh_listview); pullToRefreshView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { initDataset(true); } }); RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller); fastScroller.attachRecyclerView(mRecyclerView); //fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller); // Connect the recycler to the scroller (to let the scroller scroll the list) //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView); // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle) //mRecyclerView.setOnScrollListener(fastScroller.getOnScrollListener()); addPlayer = (FloatingActionButton) rootView.findViewById(R.id.add_game); if (fromDrawer && playListType != 2) { //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView); mRecyclerView.setOnScrollListener(new OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); boolean enable = false; boolean firstItemVisiblePull = recyclerView.getChildPosition(recyclerView.getChildAt(0)) == 0; boolean topOfFirstItemVisiblePull = recyclerView.getChildAt(0).getTop() == recyclerView .getChildAt(0).getTop(); ; enable = firstItemVisiblePull && topOfFirstItemVisiblePull; pullToRefreshView.setEnabled(enable); } }); addPlayer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int viewXY[] = new int[2]; v.getLocationOnScreen(viewXY); if (mListener != null) { mListener.onFragmentInteraction("add_game", viewXY[0], viewXY[1]); } } }); } else { if (!fromDrawer) { RelativeLayout gamesLayout = (RelativeLayout) rootView.findViewById(R.id.gamesLayout); final SwipeDismissBehavior<LinearLayout> behavior = new SwipeDismissBehavior(); behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END); behavior.setStartAlphaSwipeDistance(1.0f); behavior.setSensitivity(0.15f); behavior.setListener(new SwipeDismissBehavior.OnDismissListener() { @Override public void onDismiss(final View view) { GamesFragment myFragC1 = (GamesFragment) getFragmentManager().findFragmentByTag("games"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.remove(myFragC1); transaction.commitAllowingStateLoss(); getFragmentManager().executePendingTransactions(); mActivity.onBackPressed(); } @Override public void onDragStateChanged(int i) { } }); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) gamesLayout .getLayoutParams(); params.setBehavior(behavior); } //fastScroller.setRecyclerView(mRecyclerView, null); pullToRefreshView.setEnabled(false); addPlayer.setVisibility(View.GONE); } mProgress = (LinearLayout) rootView.findViewById(R.id.progressContainer); mText = (TextView) rootView.findViewById(R.id.LoadingText); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(mActivity); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); //mAdapter = new CustomAdapter(mDataset, mDataset_Thumb); mAdapter = new GameAdapter(this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); if (mSearch != null) { mSearch.setHint( getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); mRecyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { addPlayer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { addPlayer.animate().translationY(addPlayer.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); if (mSearch != null) { mSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text mSearchQuery = cs.toString(); //initDataset(); mAdapter = new GameAdapter(GamesFragment.this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); if (mSearch != null) { mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } } @Override public void afterTextChanged(Editable editable) { } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!mSearch.getText().toString().equals("")) { mSearchQuery = ""; mSearch.setText(mSearchQuery); //mActivity.onBackPressed(); } //fastScroller.scrollHider(); InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mSearch.clearFocus(); mRecyclerView.requestFocus(); initDataset(false); if (mSearch != null) { mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games)); } } }); } Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); if (Game.findBaseGames("", sortType, year).size() == 0) { initDataset(false); } else { mText.setVisibility(View.GONE); mProgress.setVisibility(View.GONE); mRecyclerView.setVisibility(View.VISIBLE); } // END_INCLUDE(initializeRecyclerView) return rootView; }
From source file:org.de.jmg.learn._MainActivity.java
private void resize() { RelativeLayout.LayoutParams params;/*from w w w .j a va 2 s. co m*/ Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); int height = metrics.heightPixels; width = metrics.widthPixels; int viewTop = _main.findViewById(Window.ID_ANDROID_CONTENT).getTop(); height = height - viewTop; scale = (double) height / (double) 950; double ratio = Math.pow((double) width / (double) height, .5d); boolean blnHorizontal = width > height; if (scale < .5f) { _isSmallDevice = true; _main.isSmallDevice = true; if (scale < .4f) { scale = .4f; } } /* * lib.ShowMessage(this, "Meaning3 Bottom: " +_txtMeaning3.getBottom() + * "\nbtnRight.Top: " + _btnRight.getTop() + "\nDisplayHeight: " + * height); */ if (scale != 1) { // lib.ShowToast(_main, "Scaling font by " + scale + " Screenheight = " //+ height); float tSize = _txtMeaning1.getTextSize(); if (tSize == 40 || (_vok.getCardMode() && tSize == 25)) { _txtMeaning1.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtMeaning1.getTextSize() * scale)); } params = (android.widget.RelativeLayout.LayoutParams) _txtMeaning1.getLayoutParams(); if (params.topMargin == 120) { if (!_isSmallDevice) { params.topMargin = (int) (params.topMargin * scale); } else { params.topMargin = (int) (params.topMargin * .1f); } _txtMeaning1.setLayoutParams(params); } if (_txtMeaning2.getTextSize() == 40) { _txtMeaning2.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtMeaning2.getTextSize() * scale)); } params = (android.widget.RelativeLayout.LayoutParams) _txtMeaning2.getLayoutParams(); if (params.topMargin == 56) { params.topMargin = (int) (params.topMargin * scale); _txtMeaning2.setLayoutParams(params); } if (_txtMeaning3.getTextSize() == 40) { _txtMeaning3.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtMeaning3.getTextSize() * scale)); } params = (android.widget.RelativeLayout.LayoutParams) _txtMeaning3.getLayoutParams(); if (params.topMargin == 56) { params.topMargin = (int) (params.topMargin * scale); _txtMeaning3.setLayoutParams(params); } float size = _txtWord.getTextSize(); if (size == 60) { size *= scale; _txtWord.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); } if (_txtKom.getTextSize() == 35) { _txtKom.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtKom.getTextSize() * scale)); } if (_txtedWord.getTextSize() == 60) { _txtedWord.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtedWord.getTextSize() * scale)); } if (_txtedKom.getTextSize() == 35) { _txtedKom.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtedKom.getTextSize() * scale)); } if (_vok != null && _vok.getCardMode()) { SetViewsToCardmode(); } else { SetViewsToVokMode(); } /* * _txtMeaning1.setOnFocusChangeListener(new * View.OnFocusChangeListener() { * * @Override public void onFocusChange(View v, boolean hasFocus) { * if (_firstFocus && hasFocus) { * hideKeyboard(); _firstFocus = false; } } }); */ } if (scale != 1) { int widthButtons = _btnEdit.getRight() - _btnSkip.getLeft(); int allButtonsWidth = 520; /*_btnEdit.getWidth() +_btnRight.getWidth() +_btnView.getWidth() +_btnWrong.getWidth() +_btnEdit.getWidth(); */ if (widthButtons < allButtonsWidth) { widthButtons = allButtonsWidth; blnWrongWidth = true; } ScaleWidth = (width - 50) / (double) widthButtons; if (ScaleWidth < .7) { _btnEdit.setVisibility(View.GONE); _btnSkip.setVisibility(View.GONE); widthButtons = _btnWrong.getRight() - _btnRight.getLeft(); if (widthButtons < 330) { widthButtons = 330; blnWrongWidth = true; } ScaleWidth = ((double) (_txtMeaning1.getRight() - _txtMeaning1.getLeft())) / (double) widthButtons; if (ScaleWidth < .4d) ScaleWidth = .4d; ScaleTextButtons = ((scale > ScaleWidth) ? scale : ScaleWidth); } else { ScaleTextButtons = ((scale < ScaleWidth) ? scale : ScaleWidth); } RelativeLayout layoutButtons = (RelativeLayout) findViewById(R.id.layoutButtonsInner); params = (android.widget.RelativeLayout.LayoutParams) layoutButtons.getLayoutParams(); if (!blnWrongWidth) { params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.bottomMargin = (int) (0 * ScaleWidth); } layoutButtons.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _btnRight.getLayoutParams(); if (!blnWrongWidth) { params.height = (int) (params.height * scale); params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.height = (int) (60 * ScaleWidth); params.bottomMargin = (int) (0 * ScaleWidth); _btnRight.setPadding((int) (_btnRight.getPaddingLeft() * ScaleWidth), (int) (_btnRight.getPaddingTop() * ScaleWidth), (int) (_btnRight.getPaddingRight() * ScaleWidth), (int) (_btnRight.getPaddingBottom() * ScaleWidth)); } params.width = (int) (params.width * ScaleWidth); double ScaleTextButtonsOrig = ScaleTextButtons; if (blnHorizontal) { params.height *= ratio; ScaleTextButtons *= ratio; } _btnRight.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _btnWrong.getLayoutParams(); if (!blnWrongWidth) { params.height = (int) (params.height * scale); params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.height = (int) (60 * ScaleWidth); params.bottomMargin = (int) (0 * ScaleWidth); _btnWrong.setPadding((int) (_btnWrong.getPaddingLeft() * ScaleWidth), (int) (_btnWrong.getPaddingTop() * ScaleWidth), (int) (_btnWrong.getPaddingRight() * ScaleWidth), (int) (_btnWrong.getPaddingBottom() * ScaleWidth)); } params.width = (int) (params.width * ScaleWidth); if (blnHorizontal) params.height *= ratio; _btnWrong.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _btnSkip.getLayoutParams(); if (!blnWrongWidth) { params.height = (int) (params.height * scale); params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.height = (int) (60 * ScaleWidth); params.bottomMargin = (int) (0 * ScaleWidth); } params.width = (int) (params.width * ScaleWidth); if (blnHorizontal) params.height *= ratio; _btnSkip.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _btnView.getLayoutParams(); if (!blnWrongWidth) { params.height = (int) (params.height * scale); params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.height = (int) (60 * ScaleWidth); params.bottomMargin = (int) (0 * ScaleWidth); _btnView.setPadding((int) (_btnView.getPaddingLeft() * ScaleWidth), (int) (_btnView.getPaddingTop() * ScaleWidth), (int) (_btnView.getPaddingRight() * ScaleWidth), (int) (_btnView.getPaddingBottom() * ScaleWidth)); } params.width = (int) (params.width * ScaleWidth); if (blnHorizontal) params.height *= ratio; _btnView.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _btnEdit.getLayoutParams(); if (!blnWrongWidth) { params.height = (int) (params.height * scale); params.bottomMargin = (int) (params.bottomMargin * scale); } else { params.height = (int) (60 * ScaleWidth); params.bottomMargin = (int) (0 * ScaleWidth); } params.width = (int) (params.width * ScaleWidth); if (blnHorizontal) params.height *= ratio; _btnEdit.setLayoutParams(params); params = (android.widget.RelativeLayout.LayoutParams) _txtStatus.getLayoutParams(); if (!blnWrongWidth) { params.topMargin = (int) (params.topMargin * scale); } else { params.topMargin = (int) (0 * ScaleWidth); } _txtStatus.setLayoutParams(params); _btnRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_btnRight.getTextSize() * ScaleTextButtons)); _btnSkip.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_btnSkip.getTextSize() * ScaleTextButtons)); _btnView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_btnView.getTextSize() * ScaleTextButtons)); _btnWrong.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_btnWrong.getTextSize() * ScaleTextButtons)); _btnEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_btnEdit.getTextSize() * ScaleTextButtons)); _txtStatus.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) (_txtStatus.getTextSize() * ScaleTextButtonsOrig)); //_main.ActionBarOriginalTextSize = 0; resizeActionbar(0); Runnable r = new resetLayoutTask(null); rFlashs.add(r); handler.post(r); } }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
@Override public void onResume() { super.onResume(); int[] screenSize = Utils.getScreenSize(context, getWindow()); screenWidth = screenSize[0];/*from ww w . j av a 2 s .c o m*/ screenHeight = screenSize[1]; final RelativeLayout listRL = (RelativeLayout) findViewById(R.id.listContainer); final RelativeLayout listRLContainer = (RelativeLayout) findViewById(R.id.rlListViewContent); final RelativeLayout shadowRL = (RelativeLayout) findViewById(R.id.shadowContainer); RelativeLayout.LayoutParams menuListLP = (LayoutParams) listRL.getLayoutParams(); // Setting the ListView width as the container width without the shadow // RelativeLayout menuListLP.width = (int) (screenWidth * menuWidth); listRL.setLayoutParams(menuListLP); RelativeLayout.LayoutParams listP = (LayoutParams) listRLContainer.getLayoutParams(); listP.width = (int) (screenWidth * menuWidth) - shadowRL.getLayoutParams().width; listRLContainer.setLayoutParams(listP); }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); // In both cases whether the action is accepted or cancelled, the temporary stored files need to be deleted List<File> tempFiles = annotateImageView.getCroppedImageLists(); for (int i = 1; i < tempFiles.size(); ++i) { tempFiles.get(i).delete();//from ww w. j a va 2s .co m } tempFiles.clear(); if (id == R.id.supersede_feedbacklibrary_action_annotate_cancel) { super.onBackPressed(); return true; } if (id == R.id.supersede_feedbacklibrary_action_annotate_accept) { RelativeLayout relativeLayout = (RelativeLayout) findViewById( R.id.supersede_feedbacklibrary_annotate_image_layout); if (relativeLayout != null) { // Remove all the annotation which are out of bounds removeOutOfBoundsAnnotations(); // Hide all control items hideAllControlItems(relativeLayout); // Process all the sticker annotations HashMap<Integer, String> allStickerAnnotations = processStickerAnnotations(relativeLayout); // Process all the text annotations HashMap<Integer, String> allTextAnnotations = processTextAnnotations(relativeLayout); String annotatedImagePathWithoutStickers = null; if (allStickerAnnotations.size() > 0 || allTextAnnotations.size() > 0) { // Get the bitmap (image without stickers if there are any) Bitmap annotatedBitmapWithoutStickers = annotateImageView.getBitmap(); annotatedImagePathWithoutStickers = Utils.saveBitmapToInternalStorage(getApplicationContext(), "imageDir", mechanismViewId + FeedbackActivity.ANNOTATED_IMAGE_NAME_WITHOUT_STICKERS, annotatedBitmapWithoutStickers, Context.MODE_PRIVATE, Bitmap.CompressFormat.PNG, 100); } // Convert the ViewGroup, i.e., the supersede_feedbacklibrary_annotate_picture_layout into a bitmap (image with stickers) relativeLayout.measure( View.MeasureSpec.makeMeasureSpec(annotateImageView.getBitmapWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(annotateImageView.getBitmapHeight(), View.MeasureSpec.EXACTLY)); relativeLayout.layout(0, 0, relativeLayout.getMeasuredWidth(), relativeLayout.getMeasuredHeight()); Bitmap annotatedBitmapWithStickers = Bitmap.createBitmap(relativeLayout.getLayoutParams().width, relativeLayout.getLayoutParams().height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(annotatedBitmapWithStickers); relativeLayout.draw(canvas); Bitmap croppedBitmap = Bitmap.createBitmap(annotatedBitmapWithStickers, 0, 0, annotateImageView.getBitmapWidth(), annotateImageView.getBitmapHeight()); String annotatedImagePathWithStickers = Utils.saveBitmapToInternalStorage(getApplicationContext(), "imageDir", mechanismViewId + FeedbackActivity.ANNOTATED_IMAGE_NAME_WITH_STICKERS, croppedBitmap, Context.MODE_PRIVATE, Bitmap.CompressFormat.PNG, 100); Intent intent = new Intent(); intent.putExtra(Utils.EXTRA_KEY_MECHANISM_VIEW_ID, mechanismViewId); intent.putExtra(Utils.EXTRA_KEY_ANNOTATED_IMAGE_PATH_WITHOUT_STICKERS, annotatedImagePathWithoutStickers); intent.putExtra(Utils.EXTRA_KEY_ANNOTATED_IMAGE_PATH_WITH_STICKERS, annotatedImagePathWithStickers); intent.putExtra(Utils.EXTRA_KEY_HAS_STICKER_ANNOTATIONS, allStickerAnnotations.size() > 0); intent.putExtra(Utils.EXTRA_KEY_ALL_STICKER_ANNOTATIONS, allStickerAnnotations); intent.putExtra(Utils.EXTRA_KEY_HAS_TEXT_ANNOTATIONS, allTextAnnotations.size() > 0); intent.putExtra(Utils.EXTRA_KEY_ALL_TEXT_ANNOTATIONS, allTextAnnotations); setResult(RESULT_OK, intent); } super.onBackPressed(); return true; } return super.onOptionsItemSelected(item); }
From source file:org.cafemember.ui.LaunchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Date now = new Date(); /*int year = now.getYear(); int month = now.getMonth();/* w w w . j a v a2s . co m*/ int day = now.getDay(); now.getDate(); long curr = 147083220000l; if(System.currentTimeMillis() > curr ){ Toast.makeText(this," . ? ",Toast.LENGTH_LONG).show(); finish(); }*/ ApplicationLoader.postInitApplication(); NativeCrashManager.handleDumpFiles(this); if (!UserConfig.isClientActivated()) { Intent intent = getIntent(); if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { super.onCreate(savedInstanceState); finish(); return; } if (intent != null && !intent.getBooleanExtra("fromIntro", false)) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("logininfo2", MODE_PRIVATE); Map<String, ?> state = preferences.getAll(); if (state.isEmpty()) { Intent intent2 = new Intent(this, IntroActivity.class); startActivity(intent2); super.onCreate(savedInstanceState); finish(); return; } } } requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages); getWindow().setBackgroundDrawableResource(R.drawable.transparent); super.onCreate(savedInstanceState); Theme.loadRecources(this); if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) { UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime(); } int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId); } actionBarLayout = new ActionBarLayout(this); drawerLayoutContainer = new DrawerLayoutContainer(this); setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (AndroidUtilities.isTablet()) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); RelativeLayout launchLayout = new RelativeLayout(this); drawerLayoutContainer.addView(launchLayout); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; launchLayout.setLayoutParams(layoutParams1); backgroundTablet = new ImageView(this); backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP); backgroundTablet.setImageResource(R.drawable.cats); launchLayout.addView(backgroundTablet); RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet .getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; backgroundTablet.setLayoutParams(relativeLayoutParams); launchLayout.addView(actionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout = new ActionBarLayout(this); launchLayout.addView(rightActionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(320); relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; rightActionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout.init(rightFragmentsStack); rightActionBarLayout.setDelegate(this); shadowTabletSide = new FrameLayout(this); shadowTabletSide.setBackgroundColor(0x40295274); launchLayout.addView(shadowTabletSide); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(1); relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTabletSide.setLayoutParams(relativeLayoutParams); shadowTablet = new FrameLayout(this); shadowTablet.setVisibility(View.GONE); shadowTablet.setBackgroundColor(0x7F000000); launchLayout.addView(shadowTablet); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTablet.setLayoutParams(relativeLayoutParams); shadowTablet.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) { float x = event.getX(); float y = event.getY(); int location[] = new int[2]; layersActionBarLayout.getLocationOnScreen(location); int viewX = location[0]; int viewY = location[1]; if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) { return false; } else { if (!layersActionBarLayout.fragmentsStack.isEmpty()) { for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) { layersActionBarLayout .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0)); a--; } layersActionBarLayout.closeLastFragment(true); } return true; } } return false; } }); shadowTablet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); layersActionBarLayout = new ActionBarLayout(this); layersActionBarLayout.setRemoveActionBarExtraHeight(true); layersActionBarLayout.setBackgroundView(shadowTablet); layersActionBarLayout.setUseAlphaAnimations(true); layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow); launchLayout.addView(layersActionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(530); relativeLayoutParams.height = AndroidUtilities.dp(528); layersActionBarLayout.setLayoutParams(relativeLayoutParams); layersActionBarLayout.init(layerFragmentsStack); layersActionBarLayout.setDelegate(this); layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); layersActionBarLayout.setVisibility(View.GONE); } else { drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } ListView listView = new ListView(this) { @Override public boolean hasOverlappingRendering() { return false; } }; listView.setBackgroundColor(0xffffffff); listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this)); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); drawerLayoutContainer.setDrawerLayout(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); Point screenSize = AndroidUtilities.getRealScreenSize(); layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56); layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if (position == 12) { presentFragment(new SettingsActivity()); drawerLayoutContainer.closeDrawer(false); } else if (position == 11) { try { RulesActivity his = new RulesActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 2) { Defaults def = Defaults.getInstance(); boolean open = def.openOnJoin(); def.setOpenOnJoin(!open); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!open); } } else if (position == 4) { try { HistoryActivity his = new HistoryActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 3) { Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/cafemember")); startActivity(telegram); drawerLayoutContainer.closeDrawer(false); } else if (position == 5) { try { FAQActivity his = new FAQActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 6) { Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/" + Defaults.getInstance().getSupport())); startActivity(telegram); drawerLayoutContainer.closeDrawer(false); } else if (position == 7) { try { HelpActivity his = new HelpActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 8) { try { AddRefActivity his = new AddRefActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 9) { try { Log.d("TAB", "Triggering"); ShareActivity his = new ShareActivity(); Log.d("TAB", "Triggered"); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 10) { try { // TransfareActivity his = new TransfareActivity(); // presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } } }); drawerLayoutContainer.setParentActionBarLayout(actionBarLayout); actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); actionBarLayout.init(mainFragmentsStack); actionBarLayout.setDelegate(this); ApplicationLoader.loadWallpaper(); passcodeView = new PasscodeView(this); drawerLayoutContainer.addView(passcodeView); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; passcodeView.setLayoutParams(layoutParams1); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this); currentConnectionState = ConnectionsManager.getInstance().getConnectionState(); NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert); NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation); if (Build.VERSION.SDK_INT < 14) { NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged); } if (actionBarLayout.fragmentsStack.isEmpty()) { if (!UserConfig.isClientActivated()) { actionBarLayout.addFragmentToStack(new LoginActivity()); drawerLayoutContainer.setAllowOpenDrawer(false, false); } else { dialogsFragment = new DialogsActivity(null); actionBarLayout.addFragmentToStack(dialogsFragment); drawerLayoutContainer.setAllowOpenDrawer(true, false); } try { if (savedInstanceState != null) { String fragmentName = savedInstanceState.getString("fragment"); if (fragmentName != null) { Bundle args = savedInstanceState.getBundle("args"); switch (fragmentName) { case "chat": if (args != null) { ChatActivity chat = new ChatActivity(args); if (actionBarLayout.addFragmentToStack(chat)) { chat.restoreSelfArgs(savedInstanceState); } } break; case "settings": { SettingsActivity settings = new SettingsActivity(); actionBarLayout.addFragmentToStack(settings); settings.restoreSelfArgs(savedInstanceState); break; } case "group": if (args != null) { GroupCreateFinalActivity group = new GroupCreateFinalActivity(args); if (actionBarLayout.addFragmentToStack(group)) { group.restoreSelfArgs(savedInstanceState); } } break; case "channel": if (args != null) { ChannelCreateActivity channel = new ChannelCreateActivity(args); if (actionBarLayout.addFragmentToStack(channel)) { channel.restoreSelfArgs(savedInstanceState); } } break; case "edit": if (args != null) { ChannelEditActivity channel = new ChannelEditActivity(args); if (actionBarLayout.addFragmentToStack(channel)) { channel.restoreSelfArgs(savedInstanceState); } } break; case "chat_profile": if (args != null) { ProfileActivity profile = new ProfileActivity(args); if (actionBarLayout.addFragmentToStack(profile)) { profile.restoreSelfArgs(savedInstanceState); } } break; case "wallpapers": { WallpapersActivity settings = new WallpapersActivity(); actionBarLayout.addFragmentToStack(settings); settings.restoreSelfArgs(savedInstanceState); break; } } } } } catch (Exception e) { FileLog.e("tmessages", e); } } else { boolean allowOpen = true; if (AndroidUtilities.isTablet()) { allowOpen = actionBarLayout.fragmentsStack.size() <= 1 && layersActionBarLayout.fragmentsStack.isEmpty(); if (layersActionBarLayout.fragmentsStack.size() == 1 && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) { allowOpen = false; } } if (actionBarLayout.fragmentsStack.size() == 1 && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) { allowOpen = false; } drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false); } handleIntent(getIntent(), false, savedInstanceState != null, false); needLayout(); final View view = getWindow().getDecorView().getRootView(); view.getViewTreeObserver() .addOnGlobalLayoutListener(onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int height = view.getMeasuredHeight(); if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) { AndroidUtilities.displaySize.y = height; FileLog.e("tmessages", "fix display size y to " + AndroidUtilities.displaySize.y); } } }); }