Skip to content

Instantly share code, notes, and snippets.

View DanishAmjad12's full-sized avatar
🎯
Focusing

Danish DanishAmjad12

🎯
Focusing
View GitHub Profile
public class MyInstanceIDListenerService extends FirebaseMessagingService {
}
result.addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
@Override
public void onComplete(@NonNull Task<LocationSettingsResponse> task) {
try {
LocationSettingsResponse response = task.getResult(ApiException.class);
// All location settings are satisfied. The client can initialize location
// requests here.
setupLocationListener();
} catch (ApiException exception) {
Task<LocationSettingsResponse> result = LocationServices.getSettingsClient(this)
.checkLocationSettings(builder.build());
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(10000);
locationRequest.setFastestInterval(10000 / 2);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
private void setupValuesInWidgets(MyViewHolder itemHolder,
Model settingsModel, int pos) {
if (settingsModel != null) {
itemHolder.ivLogo.setBackgroundResource(settingsModel.getImage());
itemHolder.ivLogo.getLayoutParams().height = getPixelFromDips(mContext, SMALL_BOX_HEIGHT_IN_DP);
if (modelArrayList.size() == SIZE_1) {
cellForItemOne(itemHolder);
} else {
if (isEven) {
private boolean checkEvenOrOdd(int n) {
if ((n % 2) == 0) {
// number is even
return true;
} else {
// number is odd
return false;
}
}
private void setSpanValue() {
StaggeredGridLayoutManager staggeredGridLayoutManager;
if (modelArrayList.size() == 1) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else if (modelArrayList.size() == 2) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.HORIZONTAL);
btnThree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
modelArrayList.clear();
modelArrayList.add(new Model(R.drawable.what_hot));
modelArrayList.add(new Model(R.drawable.what_hot));
modelArrayList.add(new Model(R.drawable.what_hot));
setSpanValue();
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
Notification notification = new NotificationCompat.Builder(this);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notification.setSmallIcon(R.drawable.icon_transperent);
notification.setColor(getResources().getColor(R.color.notification_color));
} else {
notification.setSmallIcon(R.drawable.icon);
}