use of android.support.design.widget.CoordinatorLayout in project MaterialLibrary by DeveloperPaul123.
the class BaseRecyclerFabActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
coordinatorLayout = new CoordinatorLayout(this);
coordinatorLayout.setLayoutParams(params);
CoordinatorLayout.LayoutParams coorLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
coorLayoutParams.setBehavior(new MaterialFabDefaultBehavior());
coorLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
materialFloatingActionButton = new MaterialFloatingActionButton(this);
materialFloatingActionButton.setLayoutParams(coorLayoutParams);
coordinatorLayout.addView(materialFloatingActionButton);
getHomeLayout().addView(coordinatorLayout);
ScrollListener scrollListener = new ScrollListener();
scrollListener.setRecyclerView(getRecyclerView());
scrollListener.setScrollThreshold(getResources().getDimensionPixelOffset(R.dimen.material_library_scroll_threshold));
getRecyclerView().addOnScrollListener(scrollListener);
materialFloatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onActionButtonClicked();
}
});
isShowing = true;
}
use of android.support.design.widget.CoordinatorLayout in project smooth-app-bar-layout by henrytao-me.
the class BaseBehavior method getSupportedScrollTarget.
private View getSupportedScrollTarget(View target) {
if (target instanceof SwipeRefreshLayout && ((SwipeRefreshLayout) target).getChildCount() > 0) {
SwipeRefreshLayout parent = (SwipeRefreshLayout) target;
View child;
int n = parent.getChildCount();
for (int i = 0; i < n; i++) {
child = parent.getChildAt(i);
if (child instanceof NestedScrollView || child instanceof RecyclerView) {
return child;
}
}
return ((SwipeRefreshLayout) target).getChildAt(0);
} else if (target instanceof CoordinatorLayout) {
Stack<View> stack = new Stack<>();
stack.add(target);
while (stack.size() > 0) {
View view = stack.pop();
if (view instanceof NestedScrollView || view instanceof RecyclerView) {
return view;
}
if (view instanceof ViewGroup) {
int n = ((ViewGroup) view).getChildCount();
for (int i = 0; i < n; i++) {
stack.add(((ViewGroup) view).getChildAt(i));
}
}
}
}
return target;
}
use of android.support.design.widget.CoordinatorLayout in project AgileDev by LZ9.
the class StatusBarUtil method setColorForSwipeBack.
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
use of android.support.design.widget.CoordinatorLayout in project TicktockMusic by Lauzy.
the class StatusBarUtil method setColorForSwipeBack.
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
use of android.support.design.widget.CoordinatorLayout in project mintube by imshyam.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mainAct = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewStub = (ViewStub) findViewById(R.id.view_stub);
if (isInternetAvailable(mainAct)) {
viewStub.setLayoutResource(R.layout.content_main);
viewStub.inflate();
exit = false;
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Swipe Refresh WebView
swipeRefreshLayout = (CustomSwipeRefresh) findViewById(R.id.swipe_refresh);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeRefreshLayout.setRefreshing(true);
new Handler().post(new Runnable() {
@Override
public void run() {
youtubeView.loadUrl(youtubeView.getUrl());
}
});
}
});
// after initialization
swipeRefreshLayout.setCanChildScrollUpCallback(new CustomSwipeRefresh.CanChildScrollUpCallback() {
@Override
public boolean canSwipeRefreshChildScrollUp() {
return youtubeView.getScrollY() > 0;
}
});
youtubeView = (WebView) findViewById(R.id.youtube_view);
youtubeView.getSettings().setJavaScriptEnabled(true);
youtubeView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String str, Bitmap bitmap) {
super.onPageStarted(view, str, bitmap);
Log.d("Main Page Loading ", str);
swipeRefreshLayout.setRefreshing(true);
currUrl = str;
}
@Override
public void onPageFinished(WebView view, String str) {
super.onPageFinished(view, str);
swipeRefreshLayout.setRefreshing(false);
Log.d("Main Page Finished", str);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("?app=desktop") && !url.contains("signin?app=desktop")) {
Log.d("Url stopped to load : ", url);
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
final Snackbar snackbar = Snackbar.make(coordinatorLayout, "Desktop View Unavailable", Snackbar.LENGTH_LONG);
// Changing Text Color
View snkBar = snackbar.getView();
TextView tv = (TextView) snkBar.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.parseColor("#e52d27"));
snackbar.show();
return true;
}
return false;
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (String.valueOf(request.getUrl()).contains("http://m.youtube.com/watch?") || String.valueOf(request.getUrl()).contains("https://m.youtube.com/watch?")) {
String url = String.valueOf(request.getUrl());
Log.d("Yay Catches!!!! ", url);
// Video Id
VID = url.substring(url.indexOf("&v=") + 3, url.length());
Log.d("VID ", VID);
// Playlist Id
final String listID = url.substring(url.indexOf("&list=") + 6, url.length());
Pattern pattern = Pattern.compile("([A-Za-z0-9_-]+)&[\\w]+=.*", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(listID.toString());
Log.d("ListID", listID);
PID = "";
if (matcher.matches()) {
PID = matcher.group(1);
}
if (listID.contains("m.youtube.com")) {
Log.d("Not a ", "Playlist.");
PID = null;
} else {
Constants.linkType = 1;
Log.d("PlaylistID ", PID);
}
Handler handler = new Handler(getMainLooper());
final String finalPID = PID;
handler.post(new Runnable() {
@Override
public void run() {
youtubeView.stopLoading();
youtubeView.goBack();
if (isServiceRunning(PlayerService.class)) {
Log.d("Service : ", "Already Running!");
PlayerService.startVid(VID, finalPID);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(MainActivity.this)) {
Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(i, OVERLAY_PERMISSION_REQ);
} else {
Intent i = new Intent(MainActivity.this, PlayerService.class);
i.putExtra("VID_ID", VID);
i.putExtra("PLAYLIST_ID", finalPID);
i.setAction(Constants.ACTION.STARTFOREGROUND_WEB_ACTION);
startService(i);
}
// Intent i = new Intent(MainActivity.this, PlayerService.class);
// i.putExtra("VID_ID", VID);
// i.putExtra("PLAYLIST_ID", finalPID);
// i.setAction(Constants.ACTION.STARTFOREGROUND_WEB_ACTION);
// startService(i);
}
}
});
}
}
return super.shouldInterceptRequest(view, request);
}
});
youtubeView.canGoBack();
currUrl = "https://m.youtube.com/";
youtubeView.loadUrl(currUrl);
} else {
viewStub.setLayoutResource(R.layout.content_main_no_internet);
viewStub.inflate();
exit = true;
retry = (Button) findViewById(R.id.retry_internet);
changeSettings = (Button) findViewById(R.id.change_settings);
exitApp = (Button) findViewById(R.id.exit_app);
retry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mainAct.recreate();
}
});
changeSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(Settings.ACTION_SETTINGS), 0);
}
});
exitApp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
Aggregations