Java 类android.support.v7.app.AppCompatActivity 实例源码
项目:Android-Demo_ImageCroper
文件:MainActivity.java
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == AppCompatActivity.RESULT_OK) {
Uri imageUri = CropImage.getPickImageResultUri(this, data);
// For API >= 23 we need to check specifically that we have permissions to read external storage,
// but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
boolean requirePermissions = false;
if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
// request permissions and handle the result in onRequestPermissionsResult()
requirePermissions = true;
mCropImageUri = imageUri;
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
} else {
mCurrentFragment.setImageUri(imageUri);
}
}
}
项目:BLE-Indoor-Positioning
文件:BeaconViewFragment.java
public BeaconViewFragment() {
deviceLocationListener = createDeviceLocationListener();
beaconUpdateListener = createBeaconUpdateListener();
closestGateChangeListener = new ClosestGateChangeListener() {
@Override
public void onClosestGateDistanceChanged(GateGroup gateGroup, Gate gate, float distance) {
Log.v("Gate", "Closest gate distance changed to: " + String.format("%.2f", distance) + " meters");
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Gate " + gate.getIndex() + " - " + String.format("%.2f", distance) + "m");
}
@Override
public void onClosestGateChanged(GateGroup gateGroup, Gate gate, float distance) {
Log.d("Gate", "Closest gate changed to: " + gate);
}
@Override
public void onClosestGateGroupChanged(GateGroup gateGroup, Gate gate, float distance) {
Log.d("Gate", "Closest gate group changed to: " + gateGroup);
}
};
}
项目:quickblox-android
文件:ImagePickHelperFragment.java
@Override
public void onAttach(Context context) {
super.onAttach(context);
Fragment fragment = ((AppCompatActivity) context).getSupportFragmentManager()
.findFragmentByTag(getArguments().getString(ARG_PARENT_FRAGMENT));
if (fragment != null) {
if (fragment instanceof OnImagePickedListener) {
listener = (OnImagePickedListener) fragment;
}
} else {
if (context instanceof OnImagePickedListener) {
listener = (OnImagePickedListener) context;
}
}
if (listener == null) {
throw new IllegalStateException("Either activity or fragment should implement OnImagePickedListener");
}
}
项目:mobile-store
文件:SettingsView.java
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
AppCompatActivity activity = (AppCompatActivity) getContext();
if (activity == null) {
throw new IllegalArgumentException("Cannot add a SettingsView to activities which are not an AppCompatActivity");
}
Fragment existingFragment = activity.getSupportFragmentManager().findFragmentByTag("preferences-fragment");
if (existingFragment == null) {
return;
}
if (currentTransaction == null) {
currentTransaction = activity.getSupportFragmentManager().beginTransaction();
}
currentTransaction.remove(existingFragment);
currentTransaction.commitAllowingStateLoss();
currentTransaction = null;
activity.getSupportFragmentManager().executePendingTransactions();
}
项目:weex-3d-map
文件:ScreenUtil.java
private static int getStatusBarHeight(AppCompatActivity activity) {
Class<?> c;
Object obj;
Field field;
int x;
int statusBarHeight = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
statusBarHeight = activity.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
return statusBarHeight;
}
项目:MovieApp
文件:GenreFragment.java
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(title);
}
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(activity, layoutManager.getOrientation()));
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(genreAdapter);
}
项目:qvod
文件:TitleLayout.java
public TitleLayout(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.include_title_layout, this);
//
toolbar = (Toolbar) findViewById(R.id.toolbar);
//
((AppCompatActivity) getContext()).setSupportActionBar(toolbar);
ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
if (actionBar != null) {
//是否显示默认Title
actionBar.setDisplayShowTitleEnabled(true);
//是否显示返回键
actionBar.setDisplayHomeAsUpEnabled(true);
//监听返回键
toolbar.setNavigationOnClickListener(view -> ((AppCompatActivity) getContext()).onBackPressed());
}
}
项目:GSoC-Info-Android
文件:OrgAdapter.java
public OrgHolder(View itemView) {
super(itemView);
orgImage = itemView.findViewById(R.id.org_image);
orgCard = itemView.findViewById(R.id.card_view_org);
orgName = itemView.findViewById(R.id.org_name);
orgTagline = itemView.findViewById(R.id.org_tagline);
orgCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, OrgDetailActivity.class);
i.putExtra(ORG_TAG, getItem(getAdapterPosition()));
i.putExtra("EXTRA_TRANSITION_NAME", ViewCompat.getTransitionName(orgImage));
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((AppCompatActivity) context,
orgImage,
ViewCompat.getTransitionName(orgImage));
i.putExtra("ORG_ID", getItem(getAdapterPosition()).getOrgID());
context.startActivity(i, optionsCompat.toBundle());
}
});
}
项目:MovieApp
文件:PeopleDetailFragment.java
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
animation = AnimationUtils.loadAnimation(activity, R.anim.fade_in);
animation.setDuration(1000);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
tryAgainBtn.setOnClickListener(v -> presenter.onPersonDetailRequested(personId));
}
项目:Neuronizer
文件:RadioDialogs.java
public static void showIntroDialog(final AppCompatActivity activity) {
RadioDialogCallback callback = new RadioDialogCallback() {
@Override
public void which(int position) {
if (position == 0) {
activity.startActivity(IntroActivity.previewIntroInstance(activity));
activity.finish();
} else {
activity.startActivity(IntroActivity.todoListIntroInstance(activity, null, null));
activity.finish();
}
}
};
CharSequence[] items = new CharSequence[]{
getString(activity, R.string.intro_preview),
getString(activity, R.string.intro_todo_list),
};
showRadioDialog(activity, getString(activity, R.string.intro_dialog), items, callback);
}
项目:wallpaperboard
文件:WallpaperPropertiesLoaderTask.java
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (aBoolean && mContext.get() != null && !((AppCompatActivity) mContext.get()).isFinishing()) {
if (mWallpaper.getSize() <= 0) {
File target = ImageLoader.getInstance().getDiskCache().get(mWallpaper.getUrl());
if (target.exists()) {
mWallpaper.setSize((int) target.length());
}
}
}
if (mCallback != null && mCallback.get() != null) {
mCallback.get().onPropertiesReceived(mWallpaper);
}
}
项目:simple-stack
文件:ViewModelLifecycleHelper.java
@NonNull
public static <T> T getViewModel(AppCompatActivity activity, String viewModelTag) {
ViewModelHolder viewModelHolder = (ViewModelHolder) activity.getSupportFragmentManager().findFragmentByTag(viewModelTag);
if(viewModelHolder == null) {
throw new IllegalStateException("View model holder for [" + viewModelTag + "] does not exist");
}
T viewModel = viewModelHolder.getViewModel();
if(viewModel == null) {
throw new IllegalStateException("View model for [" + viewModelTag + "] does not exist");
}
return viewModel;
}
项目:Guanajoven
文件:RVRegionAdapter.java
RegionViewHolder(View itemView) {
super(itemView);
tvNombreRegion = (TextView) itemView.findViewById(R.id.tv_nombre_region);
tvDireccionRegion = (TextView) itemView.findViewById(R.id.tv_direccion_region);
itemView.setOnClickListener(v -> {
DetalleRegionFragment f = DetalleRegionFragment.newInstance(regiones.get(getAdapterPosition()).getIdRegion());
FragmentManager fragmentManager = ((AppCompatActivity)context).getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.segunda_fragment_container, f).addToBackStack(null).commit();
});
}
项目:Guanajoven
文件:PromocionFragment.java
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity = ((AppCompatActivity) getActivity());
toolbar = (Toolbar) activity.findViewById(R.id.toolbar2);
cToolBar = (CollapsingToolbarLayout) activity.findViewById(R.id.collapsing_toolbar);
}
项目:DailyStudy
文件:ShareTractionActivity.java
private void launch(AppCompatActivity activity, View transitionView, int resId) {
Pair squareParticipant = new Pair<>(transitionView, ViewCompat.getTransitionName(transitionView));
ActivityOptionsCompat transitionActivityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(
activity, squareParticipant);
Intent intent = new Intent(
activity, ViewerActivity.class);
intent.putExtra("resId", resId);
startActivity(intent, transitionActivityOptions.toBundle());
}
项目:FragmentRigger
文件:_Rigger.java
static _Rigger create(@NonNull Object object) {
if (object instanceof AppCompatActivity) {
return new _ActivityRigger((AppCompatActivity) object);
} else if (object instanceof Fragment) {
return new _FragmentRigger((Fragment) object);
} else {
throw new RiggerException(
"Puppet Annotation class can only used on android.app.Activity or android.support.v4.app.Fragment");
}
}
项目:KomaMusic
文件:PlaylistAdapter.java
@OnClick(R.id.iv_my_favorite)
void launchMyFavoriteDetail() {
Intent intent = new Intent();
intent.putExtra(Constants.WHICH_DETAIL_PAGE, Constants.MY_FAVORITE);
ComponentName componentName = new ComponentName(Constants.MUSIC_PACKAGE_NAME,
Constants.DETAIL_PACKAGE_NAME);
intent.setComponent(componentName);
mContext.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(
((AppCompatActivity) mContext), new Pair<View, String>(mFavorite,
"transition_album")).toBundle());
}
项目:MusicX-music-player
文件:ATE.java
@SuppressWarnings("unchecked")
public static void postApply(@NonNull Activity activity, @Nullable String key) {
if (didPreApply == null)
preApply(activity, key);
performMainTheming(activity, key);
final View rootView = getRootView(activity);
final boolean rootSetsToolbarColor = rootView != null && rootView instanceof ViewInterface &&
((ViewInterface) rootView).setsToolbarColor();
if (!rootSetsToolbarColor && Config.coloredActionBar(activity, key)) {
if (activity instanceof AppCompatActivity) {
final AppCompatActivity aca = (AppCompatActivity) activity;
if (aca.getSupportActionBar() != null) {
ViewProcessor toolbarViewProcessor = getViewProcessor(Toolbar.class);
if (toolbarViewProcessor != null) {
// The processor handles retrieving the toolbar from the support action bar
toolbarViewProcessor.process(activity, key, null, null);
}
}
} else if (activity.getActionBar() != null) {
activity.getActionBar().setBackgroundDrawable(new ColorDrawable(Config.toolbarColor(activity, key, null)));
}
}
if (mPostInflationApply != null) {
synchronized (IGNORE_TAG) {
for (View view : mPostInflationApply) {
if (view instanceof PostInflationApplier)
((PostInflationApplier) view).postApply();
else ATE.themeView(activity, view, key);
}
}
}
if (ATEUtil.isInClassPath(MDUtil.MAIN_CLASS))
MDUtil.initMdSupport(activity, key);
}
项目:Phoenix-for-VK
文件:AbsOwnersListFragment.java
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(mHasToolbar ? R.layout.fragment_abs_friends_with_toolbar : R.layout.fragment_abs_friends, container, false);
if(mHasToolbar){
((AppCompatActivity)getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar));
}
mRecyclerView = root.findViewById(R.id.list);
mSwipeRefreshLayout = root.findViewById(R.id.refresh);
mSwipeRefreshLayout.setOnRefreshListener(() -> getPresenter().fireRefresh());
ViewUtils.setupSwipeRefreshLayoutWithCurrentTheme(getActivity(), mSwipeRefreshLayout);
mLinearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
mRecyclerView.addOnScrollListener(new PicassoPauseOnScrollListener(Constants.PICASSO_TAG));
mRecyclerView.addOnScrollListener(new EndlessRecyclerOnScrollListener() {
@Override
public void onScrollToLastElement() {
getPresenter().fireScrollToEnd();
}
});
mOwnersAdapter = new OwnersAdapter(getActivity(), Collections.emptyList());
mOwnersAdapter.setClickListener(owner -> getPresenter().fireOwnerClick(owner));
mRecyclerView.setAdapter(mOwnersAdapter);
return root;
}
项目:wallpaperboard
文件:LicenseCallbackHelper.java
private void onLicenseChecked(LicenseHelper.Status status) {
Preferences.get(mContext).setFirstRun(false);
if (status == LicenseHelper.Status.SUCCESS) {
Preferences.get(mContext).setLicensed(true);
} else if (status == LicenseHelper.Status.FAILED) {
Preferences.get(mContext).setLicensed(false);
((AppCompatActivity) mContext).finish();
}
}
项目:dkplayer
文件:WindowUtil.java
/**
* 显示ActionBar,StatusBar,NavigationBar
*/
@SuppressLint("RestrictedApi")
public static void showSystemBar(final Context context) {
scanForActivity(context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
showNavigationBar(context);
AppCompatActivity appCompatActivity = getAppCompActivity(context);
if (appCompatActivity != null) {
ActionBar ab = appCompatActivity.getSupportActionBar();
if (ab != null) {
ab.setShowHideAnimationEnabled(false);
ab.show();
}
}
}
项目:GitHub
文件:InnerBrowserFragment.java
private void initViews(View view) {
progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
webView = (WebView) view.findViewById(R.id.web_view);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
textView = (TextView) view.findViewById(R.id.text_view);
imageView = (ImageView) view.findViewById(R.id.image_view);
}
项目:Cable-Android
文件:ConversationFragment.java
@Override
public void onItemLongClick(MessageRecord messageRecord) {
if (actionMode == null) {
((ConversationAdapter) list.getAdapter()).toggleSelection(messageRecord);
list.getAdapter().notifyDataSetChanged();
actionMode = ((AppCompatActivity)getActivity()).startSupportActionMode(actionModeCallback);
}
}
项目:Hello-Music-droid
文件:ArtistDetailFragment.java
private void setupToolbar() {
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayHomeAsUpEnabled(true);
}
项目:MyAnimeViewer
文件:FavoritesFragment.java
@Override
public void onListItemLongClick(int position) {
if (mActionMode == null) {
mActionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(new RecordOptions((AppCompatActivity) getActivity()));
}
toggleSelection(position);
}
项目:MyAnimeViewer
文件:OfflineHistoryMaterialFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
AppCompatActivity activity = (AppCompatActivity) getActivity();
setHasOptionsMenu(true);
if (activity != null) {
mAdapter = new OfflineHistoryRecyclerAdapter(mList, getActivity(), mClickListener);
mRecyclerView.setAdapter(mAdapter);
//if (mAdapter == null)mAdapter = new HistoryRecyclerAdapter(mList)
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
getLoaderManager().initLoader(0, null, this);
}
//Restore previous state
if (savedInstanceState != null) {
//Selection
mAdapter.onRestoreInstanceState(savedInstanceState);
if (mAdapter.getSelectedItemCount() > 0) {
mActionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(new RecordOptions((AppCompatActivity) getActivity()));
}
//Previously serialized activated item position
if (savedInstanceState.containsKey(STATE_ACTIVATED_POSITION))
setSelection(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
}
}
项目:MyAnimeViewer
文件:FavoritesFragment.java
public void refresh() {
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null) {
if (mHasChanged) {
//WriteLog.appendLog("Refreshing Favorites");
getLoaderManager().restartLoader(0, null, this);
mHasChanged = false;
}
}
}
项目:TreebolicLib
文件:Statusbar.java
@TargetApi(Build.VERSION_CODES.M)
@SuppressWarnings({"WeakerAccess"})
protected Statusbar(@NonNull final AppCompatActivity activity0)
{
super(activity0);
this.activity = activity0;
// determine orientation
final WindowManager windowManager = (WindowManager) this.activity.getSystemService(Context.WINDOW_SERVICE);
assert windowManager != null;
final Display display = windowManager.getDefaultDisplay();
final Point size = new Point();
display.getSize(size);
final boolean isHorizontalScreen = size.x >= size.y;
this.isHorizontal = !isHorizontalScreen;
// inflate
final LayoutInflater inflater = (LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
final ViewGroup wrappedView = (ViewGroup) inflater.inflate(isHorizontalScreen ? R.layout.status_h : R.layout.status_v, this);
this.statusView = wrappedView.findViewById(R.id.status);
this.contentView = wrappedView.findViewById(R.id.content);
this.contentView.setFocusable(false);
// colors
final int[] colors = Utils.fetchColors(this.activity, R.attr.treebolic_statusbar_background, R.attr.treebolic_statusbar_foreground, R.attr.treebolic_statusbar_foreground_icon);
this.background = colors[0];
this.foreground = colors[1];
this.iconTint = colors[2];
this.contentView.setBackgroundColor(this.background);
}
项目:DebugOverlay-Android
文件:ToolbarSupport.java
public static void addTo(@NonNull final AppCompatActivity activity, @StringRes int toolBarTitle,
@ColorRes int toolBarBgColor) {
Toolbar toolbar = getToolbar(activity);
if (toolBarTitle != 0) {
toolbar.setTitle(toolBarTitle);
}
if (toolBarBgColor != 0) {
toolbar.setBackgroundColor(ContextCompat.getColor(activity, toolBarBgColor));
}
activity.setSupportActionBar(toolbar);
if (hasParentActivity(activity)) {
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent upIntent = NavUtils.getParentActivityIntent(activity);
if (NavUtils.shouldUpRecreateTask(activity, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(activity)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to the logical parent activity.
NavUtils.navigateUpTo(activity, upIntent);
}
}
});
}
}
项目:MoligyMvpArms
文件:ActivityLifecycleCallbacksImpl.java
@Override
public void onActivityStarted(Activity activity) {
Timber.w(activity + " - onActivityStarted");
if (!activity.getIntent().getBooleanExtra("isInitToolbar", false)) {
//由于加强框架的兼容性,故将 setContentView 放到 onActivityCreated 之后,onActivityStarted 之前执行
//而 findViewById 必须在 Activity setContentView() 后才有效,所以将以下代码从之前的 onActivityCreated 中移动到 onActivityStarted 中执行
activity.getIntent().putExtra("isInitToolbar", true);
//这里全局给Activity设置toolbar和title,你想象力有多丰富,这里就有多强大,以前放到BaseActivity的操作都可以放到这里
if (activity.findViewById(R.id.toolbar) != null) {
if (activity instanceof AppCompatActivity) {
((AppCompatActivity) activity).setSupportActionBar((Toolbar) activity.findViewById(R.id.toolbar));
((AppCompatActivity) activity).getSupportActionBar().setDisplayShowTitleEnabled(false);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.setActionBar((android.widget.Toolbar) activity.findViewById(R.id.toolbar));
activity.getActionBar().setDisplayShowTitleEnabled(false);
}
}
}
if (activity.findViewById(R.id.toolbar_title) != null) {
((TextView) activity.findViewById(R.id.toolbar_title)).setText(activity.getTitle());
}
if (activity.findViewById(R.id.toolbar_back) != null) {
activity.findViewById(R.id.toolbar_back).setOnClickListener(v -> {
activity.onBackPressed();
});
}
}
}
项目:AndroidUtility
文件:GoogleSignIn.java
public GoogleSignIn(AppCompatActivity activity, GoogleLoginInterface googleLoginInterface) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(activity)
.enableAutoManage(activity, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
this.activity = activity;
this.googleLoginInterface = googleLoginInterface;
}
项目:Cable-Android
文件:ColorPreference.java
@Override
protected void onClick() {
super.onClick();
ColorDialogFragment fragment = ColorDialogFragment.newInstance();
fragment.setPreference(this);
((AppCompatActivity) getContext()).getSupportFragmentManager().beginTransaction()
.add(fragment, getFragmentTag())
.commit();
}
项目:Task-Reminder
文件:MainActivity.java
@Override
public boolean onLongClick(View v) {
AppCompatActivity activity = MainActivity.this;
activity.startSupportActionMode(mDeleteMode);
mMultiSelector.setSelected(this, true);
return true;
}
项目:Phoenix-for-VK
文件:LogsFragement.java
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_logs, container, false);
((AppCompatActivity)getActivity()).setSupportActionBar((Toolbar) root.findViewById(R.id.toolbar));
mSwipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.refresh);
mSwipeRefreshLayout.setOnRefreshListener(() -> getPresenter().fireRefresh());
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.events_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
View headerView = inflater.inflate(R.layout.header_logs, recyclerView, false);
RecyclerView typesRecyclerView = (RecyclerView) headerView.findViewById(R.id.types_recycler_view);
typesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
mTypesAdapter = new HorizontalOptionsAdapter<>(Collections.emptyList());
mTypesAdapter.setListener(this);
typesRecyclerView.setAdapter(mTypesAdapter);
mLogsAdapter = new LogsAdapter(Collections.emptyList(), this);
mLogsAdapter.addHeader(headerView);
recyclerView.setAdapter(mLogsAdapter);
mEmptyText = (TextView) root.findViewById(R.id.empty_text);
return root;
}
项目:simple-stack
文件:ViewModelLifecycleHelper.java
public static <T> T bindViewModel(AppCompatActivity activity, ViewModelCreator<T> viewModelCreator, String viewModelTag) {
ViewModelHolder viewModelHolder = (ViewModelHolder) activity.getSupportFragmentManager().findFragmentByTag(viewModelTag);
if(viewModelHolder == null) {
viewModelHolder = new ViewModelHolder();
activity.getSupportFragmentManager().beginTransaction().add(viewModelHolder, viewModelTag).commitNow();
}
if(viewModelHolder.getViewModel() == null) {
T t = viewModelCreator.create();
viewModelHolder.setViewModel(t);
}
return viewModelHolder.getViewModel();
}
项目:Guanajoven
文件:ConvocatoriaFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Instancias de la API
retrofit = ((MyApplication) getActivity().getApplication()).getRetrofitInstance();
convocatoriaAPI = retrofit.create(ConvocatoriaAPI.class);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplication());
realm = MyApplication.getRealmInstance();
activity = ((AppCompatActivity) getActivity());
toolbar = (Toolbar) activity.findViewById(R.id.toolbar2);
cToolbar = (CollapsingToolbarLayout) activity.findViewById(R.id.collapsing_toolbar);
}
项目:garras
文件:NavigationFragment.java
@Override
public void bindEvenListener(@Nullable Bundle savedInstanceState) {
super.bindEvenListener(savedInstanceState);
allowSwipeBack(false);
unbinder = ButterKnife.bind(this, viewDelegate.getRootView());
if (getActivity() != null) {
((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (null != actionBar) actionBar.setTitle("");
mToolbar.setTitle("");
setTranslate(mToolbar, DELAY * 2);
if (UserUtils.isAuthorized()) {
Me me = UserUtils.getMeProfile();
if (null != me) {
setupUserAvatar(mUserAvatar, me.profile_image);
} else {
setupUserAvatar(mUserAvatar, null);
}
} else {
RxView.clicks(mUserAvatar).compose(NavigationFragment.this.bindUntilEvent(FragmentEvent.DESTROY_VIEW)).throttleFirst(1, TimeUnit.SECONDS).subscribe(new Consumer<Object>() {
@SuppressLint("InflateParams")
@Override
public void accept(Object o) throws Exception {
startActivity(new Intent(getActivity(), LoginActivity.class));
}
});
}
setTranslate(mUserAvatar, DELAY * 2);
mFragmentManager = getChildFragmentManager();
setupFragments();
mBottomNavigation.setOnMenuItemClickListener(this);
setTranslate(mBottomNavigation, DELAY * 3);
}
}
项目:FriendBook
文件:ToolbarHelper.java
public static Toolbar initToolbar(@NonNull final AppCompatActivity activity, @IdRes int toolbarId, boolean canBack, @Nullable CharSequence title) {
Toolbar toolbar = (Toolbar) activity.findViewById(toolbarId);
if (toolbar == null) {
throw new IllegalStateException(
"The subclass of ToolbarActivity must contain a toolbar.");
}
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
if (canBack) {
actionBar.setDisplayHomeAsUpEnabled(true);
if (title != null) {
actionBar.setTitle(title);
} else {
actionBar.setDisplayShowTitleEnabled(false);
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.onBackPressed();
}
});
}
}
return toolbar;
}
项目:gigreminder
文件:RetainedStateHolderTest.java
@Test
public void createFromActivityWhenNoState() throws Exception {
AppCompatActivity activity = mock(AppCompatActivity.class);
when(activity.getLastCustomNonConfigurationInstance()).thenReturn(null);
RetainedStateHolder stateHolder = RetainedStateHolder.create(activity);
assertThat(stateHolder).isNotNull();
}
项目:BAStatusBarLib
文件:BAStatusBar.java
/**
* @return
* @throws
* @fuction 扩展到状态栏显示只能在安卓5.0以上,能用的布局也有限
* coordinatorLayout,AppBarLayout,CollapsingToolbarLayout这种布局才有效
* @parm
*/
@TargetApi(21)
public void setfitsSystemWindowsBar(AppCompatActivity activity) {
if (Build.VERSION.SDK_INT >= 21) {
request = BarStytleBulider.getStytleBuilder(activity).setTrans().build();
addBar();
}
}