use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.
the class LibraryController method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_library, container, false);
unbinder = ButterKnife.bind(this, rootView);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
setupViewPager();
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow());
compositeDisposable.add(Aesthetic.get(getContext()).colorPrimary().compose(distinctToMainThread()).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow()));
return rootView;
}
use of android.support.v7.app.AppCompatActivity in project MadMax by deviz92.
the class BarDetailFragment method initCollapsingToolbar.
/* */
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
/*
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}*/
// Initializing collapsing toolbar: it will show and hide the toolbar title on scroll
private void initCollapsingToolbar() {
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) ((AppCompatActivity) getActivity()).findViewById(R.id.collapsingToolbar);
collapsingToolbar.setTitle(" ");
AppBarLayout appBarLayout = (AppBarLayout) ((AppCompatActivity) getActivity()).findViewById(R.id.app_bar);
appBarLayout.setExpanded(true);
// hiding & showing the title when toolbar expanded & collapsed
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean isShow = false;
int scrollRange = -1;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (scrollRange == -1) {
scrollRange = appBarLayout.getTotalScrollRange();
}
if (scrollRange + verticalOffset == 0) {
collapsingToolbar.setTitle(nameTextView.getText());
isShow = true;
} else if (isShow) {
collapsingToolbar.setTitle(" ");
isShow = false;
}
}
});
}
use of android.support.v7.app.AppCompatActivity in project WilliamChart by diogobernardino.
the class ChartsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.charts, container, false);
((AppCompatActivity) getActivity()).setSupportActionBar((Toolbar) layout.findViewById(R.id.toolbar));
((TextView) layout.findViewById(R.id.title)).setTypeface(Typeface.createFromAsset(getContext().getAssets(), "Ponsi-Regular.otf"));
RecyclerView mRecyclerView = (RecyclerView) layout.findViewById(R.id.recycler_view);
GridLayoutManager mLayoutManager = new GridLayoutManager(getContext(), FULL_SPAN);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch(mAdapter.getItemViewType(position)) {
case 0:
return FULL_SPAN;
case 1:
return MULTI_SPAN;
case 2:
return SINGLE_SPAN;
case 3:
return FULL_SPAN;
case 4:
return FULL_SPAN;
case 5:
return SINGLE_SPAN;
case 6:
return MULTI_SPAN;
case 7:
return FULL_SPAN;
case 8:
return FULL_SPAN;
default:
return SINGLE_SPAN;
}
}
});
mAdapter = new ChartAdapter(getContext());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
return layout;
}
use of android.support.v7.app.AppCompatActivity in project T-MVP by north2016.
the class SysPermissionAspect method aroundJoinPoint.
@Around("execution(@com.app.annotation.aspect.Permission * *(..)) && @annotation(permission)")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint, Permission permission) throws Throwable {
AppCompatActivity ac = (AppCompatActivity) App.getAppContext().getCurActivity();
new AlertDialog.Builder(ac).setTitle("提示").setMessage("为了应用可以正常使用,请您点击确认申请权限。").setNegativeButton("取消", null).setPositiveButton("允许", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MPermissionUtils.requestPermissionsResult(ac, 1, permission.value(), new MPermissionUtils.OnPermissionListener() {
@Override
public void onPermissionGranted() {
try {
// 获得权限,执行原方法
joinPoint.proceed();
} catch (Throwable e) {
e.printStackTrace();
}
}
@Override
public void onPermissionDenied() {
MPermissionUtils.showTipsDialog(ac);
}
});
}
}).create().show();
}
use of android.support.v7.app.AppCompatActivity in project WeexErosFramework by bmfe.
the class BaseCommonUtil method getSmartBarHeight.
public 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;
}
Aggregations