Java Code Examples for android.support.v7.app.AppCompatActivity
The following examples show how to use
android.support.v7.app.AppCompatActivity. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: MeiZiNews Source File: RxBusMeunIView.java License: MIT License | 5 votes |
public void initColorful(AppCompatActivity appCompatActivity) { mColorful = new Colorful.Builder(appCompatActivity) // 设置view的背景 .backgroundColor(navigationView.getHeaderView(0), R.attr.side_nav_bar) .backgroundColor(R.id.nav_view, R.attr.root_view_bg) .backgroundColor(R.id.toolbar, R.attr.colorPrimary) .backgroundColor(R.id.tabLayout, R.attr.colorPrimary) .backgroundColor(R.id.rl_main, R.attr.root_view_bg) .navigationViewItemColor(R.id.nav_view, R.attr.text_color) .drawerLayoutStatusBarBackgroundSetter(R.id.drawer_layout, R.attr.colorPrimaryDark) .create(); boolean isDay = MyProfile.getInstance(appCompatActivity).getTheme().equals(ConstantData.MY_PROFILE_THEME_DAY); setTheme(isDay); }
Example 2
Source Project: AppPlus Source File: AppFileListFragment.java License: MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(initLayout(), container, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name); toolbar.setSubtitle(R.string.tab_exported); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); ab.setDisplayHomeAsUpEnabled(true); setupSwipeLayout(rootView); setupRecyclerView(rootView); return rootView; }
Example 3
Source Project: VCL-Android Source File: MRLPanelFragment.java License: Apache License 2.0 | 5 votes |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.open_mrl_dialog_title); View v = inflater.inflate(R.layout.mrl_panel, container, false); mRootView = v.findViewById(R.id.mrl_root); mEditText = (TextInputLayout) v.findViewById(R.id.mrl_edit); mEditText.getEditText().setOnKeyListener(this); mEditText.getEditText().setOnEditorActionListener(this); mEditText.setHint(getString(R.string.open_mrl_dialog_msg)); mRecyclerView = (RecyclerView) v.findViewById(R.id.mrl_list); mLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MRLAdapter(mHistory); mRecyclerView.setAdapter(mAdapter); return v; }
Example 4
Source Project: mua Source File: EditorAction.java License: MIT License | 5 votes |
/** * Toggle keyboard according flag. If flag equals 0, hide or close keyboard. Otherwise, open. * @param flag A flag which indicate it should open keyboard or not. */ public void toggleKeyboard(int flag) { InputMethodManager inputMethodManager = (InputMethodManager) (context.getSystemService(Context.INPUT_METHOD_SERVICE)); if (inputMethodManager != null) { if (flag == 0) { View currentFocus = ((AppCompatActivity) context).getCurrentFocus(); if (currentFocus != null) { inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); } } else { inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } } }
Example 5
Source Project: AndroidMaterialDesign Source File: BaseFragment.java License: Apache License 2.0 | 5 votes |
protected void showTitleBack(View view, String title) { Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); if (toolbar != null) { //toolbar.setNavigationIcon(R.mipmap.ic_back_white); //or //change gray icon to white Drawable icon = getResources().getDrawable(R.mipmap.ic_back_gray); Drawable drawable = getTintedDrawable(icon, 0xffffffff); toolbar.setNavigationIcon(drawable); if (title != null) { toolbar.setTitle(title); } AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } }
Example 6
Source Project: AppPlus Source File: AppListFragment.java License: MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(initLayout(), container, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name_inner); toolbar.setSubtitle(getTitleString(mType)); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); ab.setDisplayHomeAsUpEnabled(true); setupSwipeLayout(rootView); setupRecyclerView(rootView); return rootView; }
Example 7
Source Project: ShaderEditor Source File: SystemBarMetrics.java License: MIT License | 5 votes |
public static void initSystemBars(AppCompatActivity activity, Rect insets) { View mainLayout; if (activity != null && (mainLayout = activity.findViewById(R.id.main_layout)) != null && setSystemBarColor( activity.getWindow(), ShaderEditorApp.preferences.getSystemBarColor(), true)) { setWindowInsets(mainLayout, insets); } }
Example 8
Source Project: dapp-wallet-demo Source File: BaseDialog.java License: Apache License 2.0 | 5 votes |
public void show(AppCompatActivity activity){ activity .getSupportFragmentManager() .beginTransaction() .add(this,this.getTag()) .commitAllowingStateLoss(); }
Example 9
Source Project: APlayer Source File: ColorChooserDialog.java License: GNU General Public License v3.0 | 5 votes |
@NonNull public ColorChooserDialog show(AppCompatActivity context) { String tag; Builder builder = getBuilder(); if (builder.mColorsTop != null) { tag = TAG_CUSTOM; } else if (builder.mAccentMode) { tag = TAG_ACCENT; } else { tag = TAG_PRIMARY; } dismissIfNecessary(context, tag); show(context.getSupportFragmentManager(), tag); return this; }
Example 10
Source Project: IslamicLibraryAndroid Source File: AppRateController.java License: GNU General Public License v3.0 | 5 votes |
public void showChangeLogDialog(AppCompatActivity activity) { if (!activity.isFinishing()) { DialogFragment donationReminderDialogFragment = new ChangeLogDialogFragment(); donationReminderDialogFragment.show(activity.getSupportFragmentManager(), "donationReminderDialogFragment"); PreferenceHelper.updateLastViewdChangeLog(activity); } }
Example 11
Source Project: mobikul-standalone-pos Source File: CustomerHandler.java License: MIT License | 5 votes |
public void openAddCustomerFragment(Customer customer) { FragmentManager fragmentManager = ((AppCompatActivity) context).getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); Fragment fragment; fragment = fragmentManager.findFragmentByTag(AddCustomerFragment.class.getSimpleName()); if (fragment == null) fragment = new AddCustomerFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("customer", customer); // bundle.putBoolean("edit", false); fragment.setArguments(bundle); fragmentTransaction.add(((CustomerActivity) context).binding.customerFl.getId(), fragment, fragment.getClass().getSimpleName()); fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName()).commit(); }
Example 12
Source Project: android-permission-checker-app Source File: PermissionListFragment.java License: Apache License 2.0 | 5 votes |
private void setUpToolBar() { Toolbar toolbar = getActivity().findViewById(R.id.toolbar); TextView titleTextView = toolbar.findViewById(R.id.toolbar_title); titleTextView.setText("Permission Groups"); toolbar.setTitle(""); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); }
Example 13
Source Project: MxVideoPlayer Source File: MxUtils.java License: Apache License 2.0 | 5 votes |
static AppCompatActivity getAppComptActivity(Context context) { if (context == null) { return null; } if (context instanceof AppCompatActivity) { return (AppCompatActivity) context; } else if (context instanceof ContextThemeWrapper) { return getAppComptActivity(((ContextThemeWrapper)context).getBaseContext()); } return null; }
Example 14
Source Project: DismissibleImageView Source File: DismissibleImageView.java License: Apache License 2.0 | 5 votes |
@CallSuper @Override public void onClick(View v) { FragmentManager fragmentManager = null; if (this.fragmentManager != null) { fragmentManager = this.fragmentManager; } else if (getContext() instanceof FragmentActivity) { fragmentManager = ((AppCompatActivity) getContext()).getSupportFragmentManager(); } if (fragmentManager != null) { FullScreenImageFragment fragment; if (TextUtils.isEmpty(finalUrl)) { fragment = new FullScreenImageFragment.Builder(getDrawingCache(true)) .withLoadingBlur(blurOnLoading).build(); } else { fragment = new FullScreenImageFragment.Builder(finalUrl) .withLoadingBitmap(getDrawingCache(true)) .withLoadingBlur(blurOnLoading).build(); } fragment.show(fragmentManager); } }
Example 15
Source Project: ShoppingList Source File: ErrorFragment.java License: Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); Bundle b = getArguments(); this.errorDescription = b.getString("error_code"); if(((AppCompatActivity)getActivity()).getSupportActionBar() != null) { ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(getResources().getString(R.string.title_main)); } }
Example 16
Source Project: FriendBook Source File: ScreenUtils.java License: GNU General Public License v3.0 | 5 votes |
/** * 获取整个手机屏幕的大小(包括虚拟按钮) * 必须在onWindowFocus方法之后使用 * * @param activity * @return */ public static int[] getScreenSize(AppCompatActivity activity) { int[] size = new int[2]; View decorView = activity.getWindow().getDecorView(); size[0] = decorView.getWidth(); size[1] = decorView.getHeight(); return size; }
Example 17
Source Project: Walrus Source File: Proxmark3Device.java License: GNU General Public License v3.0 | 5 votes |
@Override @UiThread public void createReadCardDataOperation(final AppCompatActivity activity, Class<? extends CardData> cardDataClass, final int callbackId) { ensureOperationCreatedCallbackSupported(activity); if (cardDataClass == HIDCardData.class) { ((OnOperationCreatedCallback) activity).onOperationCreated(new ReadHIDOperation(this), callbackId); } else if (cardDataClass == MifareCardData.class) { MifareReadSetupDialogFragment dialog = MifareReadSetupDialogFragment.create(callbackId); dialog.show(activity.getSupportFragmentManager(), "proxmark3_device_mifare_read_setup_dialog"); activity.getSupportFragmentManager().executePendingTransactions(); dialog.getViewModel().getSelectedReadSteps().observeForever( new Observer<List<MifareReadStep>>() { @Override public void onChanged(@Nullable List<MifareReadStep> readSteps) { ((OnOperationCreatedCallback) activity).onOperationCreated( new ReadMifareOperation(Proxmark3Device.this, readSteps), callbackId); } }); } else { throw new RuntimeException("Invalid card data class"); } }
Example 18
Source Project: actionbarextras Source File: DropdownProxy.java License: MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { final ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar(); final boolean keepTitle; if (options.containsKey("keepTitle")) { keepTitle = options.getBoolean("keepTitle"); }else{ keepTitle = false; } add(keepTitle); if (options.containsKey("titles")) { final String[] dropdownValues = options.getStringArray("titles"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(adapter, navigationListener); } if (options.containsKey("index")) { int activeItem = options.getInt("index"); setActiveItem(activeItem); } super.handleCreationDict(options); }
Example 19
Source Project: mua Source File: SettingsFragment.java License: MIT License | 5 votes |
@Override public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences, rootKey); context = (AppCompatActivity) getContext(); sharedPref = PreferenceManager.getDefaultSharedPreferences(context); settingPreferences(); }
Example 20
Source Project: playa Source File: SignInFragment.java License: MIT License | 5 votes |
@OnClick(R.id.link_signup) public void switchToSignup() { ((AppCompatActivity) context).getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, new SignUpFragment()) .commit(); }
Example 21
Source Project: homeassist Source File: BaseFragment.java License: Apache License 2.0 | 5 votes |
public void setSubtitle(String title) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setSubtitle(title); } } }
Example 22
Source Project: JZVideoDemo Source File: JZVideoPlayer.java License: MIT License | 5 votes |
public void init(Context context) { View.inflate(context, getLayoutId(), this); startButton = findViewById(R.id.start); fullscreenButton = findViewById(R.id.fullscreen); currentTimeTextView = findViewById(R.id.current); totalTimeTextView = findViewById(R.id.total); progressBar = findViewById(R.id.bottom_seek_progress); bottomContainer = findViewById(R.id.layout_bottom); textureViewContainer = findViewById(R.id.surface_container); topContainer = findViewById(R.id.layout_top); startButton.setOnClickListener(this); fullscreenButton.setOnClickListener(this); progressBar.setOnSeekBarChangeListener(this); bottomContainer.setOnClickListener(this); textureViewContainer.setOnClickListener(this); textureViewContainer.setOnTouchListener(this); mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels; mScreenHeight = getContext().getResources().getDisplayMetrics().heightPixels; mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); try { if (isCurrentPlay()) { NORMAL_ORIENTATION = ((AppCompatActivity) context).getRequestedOrientation(); } } catch (Exception e) { e.printStackTrace(); } }
Example 23
Source Project: privacy-friendly-shopping-list Source File: SortListsDialog.java License: Apache License 2.0 | 4 votes |
public static SortListsDialog newInstance(AppCompatActivity activity) { SortListsDialog sortListsDialog = new SortListsDialog(); sortListsDialog.setActivity(activity); return sortListsDialog; }
Example 24
Source Project: Muzesto Source File: SongsListAdapter.java License: GNU General Public License v3.0 | 4 votes |
public SongsListAdapter(AppCompatActivity context, List<Song> arraylist , boolean isPlaylistSong) { this.arraylist = arraylist; this.mContext = context; this.isPlaylist = isPlaylistSong; this.songIDs = getSongIds(); this.ateKey = Helpers.getATEKey(context); this.slideUpNowPlayingFragment = slideUpNowPlayingFragment; }
Example 25
Source Project: APlayer Source File: ColorChooserDialog.java License: GNU General Public License v3.0 | 4 votes |
private void dismissIfNecessary(AppCompatActivity context, String tag) { Fragment frag = context.getSupportFragmentManager().findFragmentByTag(tag); if (frag != null) { ((DialogFragment) frag).dismiss(); context.getSupportFragmentManager().beginTransaction() .remove(frag).commit(); } }
Example 26
Source Project: stynico Source File: l.java License: MIT License | 4 votes |
private void initView() { toolbar = (android.support.v7.widget.Toolbar)findViewById(R.id.toolbar); setSupportActionBar(toolbar); ediContent = (AppCompatEditText) findViewById(R.id.id_lxw_push_content); scrollPicContent = (HorizontalScrollView) findViewById(R.id.id_lxw_push_scrollPicContent); layPicContent = (LinearLayout) findViewById(R.id.id_lxw_push_layPicContent); btnCamera = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnCamera); btnEmotion = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnEmotion); btnSend = (LinearLayout) findViewById(R.id.btnSend); emojPager = (ViewPager) findViewById(R.id.id_lxw_push_emoj_viewpager); SharedPreferences sharedPreferencesb = getSharedPreferences("fba", AppCompatActivity.MODE_PRIVATE); String r = sharedPreferencesb.getString("stytoolpro", ""); ediContent.setText(r); }
Example 27
Source Project: incubator-weex-playground Source File: ScreenUtil.java License: Apache License 2.0 | 4 votes |
private static int getSmartBarHeight(AppCompatActivity activity) { ActionBar actionbar = activity.getSupportActionBar(); if (actionbar != null) try { Class c = Class.forName("com.android.internal.R$dimen"); Object obj = c.newInstance(); Field field = c.getField("mz_action_button_min_height"); int height = Integer.parseInt(field.get(obj).toString()); return activity.getResources().getDimensionPixelSize(height); } catch (Exception e) { e.printStackTrace(); actionbar.getHeight(); } return 0; }
Example 28
Source Project: SteamGifts Source File: SearchableListFragment.java License: MIT License | 4 votes |
protected void startSearch(String query) { Log.d(TAG, "Starting Search for " + query); AppCompatActivity activity = ((AppCompatActivity) getActivity()); FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.fragment_container, newSearchingInstance(query), CommonActivity.FRAGMENT_TAG); transaction.addToBackStack(TAG); transaction.commit(); }
Example 29
Source Project: wallpaperboard Source File: LicenseCallbackHelper.java License: Apache License 2.0 | 4 votes |
private void showRetryDialog() { new MaterialDialog.Builder(mContext) .typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext)) .title(R.string.license_check) .content(R.string.license_check_retry) .positiveText(R.string.close) .cancelable(false) .canceledOnTouchOutside(false) .onPositive((dialog, which) -> ((AppCompatActivity) mContext).finish()) .show(); }
Example 30
Source Project: TitanjumNote Source File: NavigationDrawerFragment.java License: Apache License 2.0 | 4 votes |
private ActionBar getActionBar() { return ((AppCompatActivity) getActivity()).getSupportActionBar(); }