This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
property?.let { | |
//if 'property' is not null | |
fancyPrint(it) //'it' refers to 'property' | |
} ?: run { | |
//'else' clause - property is null | |
showError() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MODEL CLASS | |
interface Model{ | |
void init(Gson gson); | |
public Single<List<ImgAlbum>> getPhotos(); | |
} | |
/** | |
* @author Hilfritz Camallere on 6/11/18 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rxPermissions | |
https://stackoverflow.com/questions/32854169/does-checking-the-never-ask-again-box-when-asking-for-a-runtime-permission-disab | |
final String[] objects = new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}; | |
findViewById(R.id.enableCamera).setOnClickListener( | |
view -> rxPermissions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final ArrayList<DateTime> getAllDateTimeInMonth(int month, int year, String timezoneID){ | |
Log.d(TAG, "getAllDateTimeInMonth: month:"+month); | |
DateTimeZone dateTimeZone = DateTimeZone.forID(timezoneID); | |
DateTime dateTime = new DateTime(year, month, 1,0, 0, dateTimeZone); | |
Log.d(TAG, "getAllDateTimeInMonth: month:"+month+" year:"+year); | |
ArrayList<DateTime> daysInMonthLabels = new ArrayList<DateTime>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//from https://gist.github.com/jk2K/67502e1744e081dcfef5 | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Matrix; | |
import android.support.annotation.NonNull; | |
import android.util.AttributeSet; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.view.ScaleGestureDetector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//issue happens one pre lolipop devices | |
//https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working | |
//must use NestedScrollView | |
fix: | |
mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { | |
@Override | |
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { | |
int action = e.getAction(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/questions/25457737/how-to-create-an-observable-from-onclick-event-android | |
Observable<View> clickEventObservable = Observable.create(new Observable.OnSubscribe<View>() { | |
@Override | |
public void call(final Subscriber<? super View> subscriber) { | |
viewIWantToMonitorForClickEvents.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (subscriber.isUnsubscribed()) return; | |
subscriber.onNext(v); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Find the longest String in an array of Strings | |
//ANSWER: | |
public String getLongestStringInArray(String[] array){ | |
int index = 0; | |
int elementLength = array[0].length(); | |
int arraySize = array.length; | |
for(int i=1; i< arraySize; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/questions/7189948/full-screen-dialogfragment-in-android | |
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
//val dialog = super.onCreateDialog(savedInstanceState) | |
// request a window without the title | |
//dialog.window!!.requestFeature(Window.FEATURE_NO_TITLE) | |
// the content | |
val root = RelativeLayout(activity) | |
root.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) |