Skip to content

Instantly share code, notes, and snippets.

View passiondroid's full-sized avatar
🏠
Working from home

Arif Khan passiondroid

🏠
Working from home
View GitHub Profile
private List<Movies> movies = new ArrayList<>();
movieService.getMovies()
.flatMap(new Function<List<Movie>, ObservableSource<Movie>>() {
@Override
public ObservableSource<Movie> apply(List<Movie> movies)
throws Exception {
return Observable.fromIterable(movies);
}
})
public interface MoviesService {
@GET("v2/movies/trending")
Observable<List<Movie>> getMovies();
@GET("v2/movies/{movieId}/casts")
Observable<List<Cast>> getCasts(@Path(movieId) String movieId);
}
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
private void getMovies() {
MoviesService service = retrofit.create(MoviesService.class);
Call<List<Movie>> call = service.getMovies();
call.enqueue(new Callback<List<Movie>>() {
@Override
public void onResponse(Response<List<Movie>> response, Retrofit retrofit) {
saveMovies(response.body())
getMovieCasts(response.body())
}
android {
 defaultConfig {
 }
 signingConfigs {
 release {
  storeFile file(“app.keystore”) // Your Keystore file path
  storePassword “password” // Your Keystore password
@Override
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder,
@NonNull RecyclerView.ViewHolder newHolder,
@NonNull ItemHolderInfo preInfo,
@NonNull ItemHolderInfo postInfo) {
if (preInfo instanceof CharacterItemHolderInfo) {
CharacterItemHolderInfo recipesItemHolderInfo = (CharacterItemHolderInfo) preInfo;
CharacterRVAdapter.CharacterViewHolder holder = (CharacterRVAdapter.CharacterViewHolder) newHolder;
if (CharacterRVAdapter.ACTION_LIKE_IMAGE_DOUBLE_CLICKED.equals(recipesItemHolderInfo.updateAction)) {
public ItemHolderInfo recordPreLayoutInformation(@NonNull RecyclerView.State state, @NonNull RecyclerView.ViewHolder viewHolder, int changeFlags, @NonNull List<Object> payloads) {
if (changeFlags == FLAG_CHANGED) {
for (Object payload : payloads) {
if (payload instanceof String) {
return new CharacterItemHolderInfo((String) payload);
}
}
}
return super.recordPreLayoutInformation(state, viewHolder, changeFlags, payloads);
}
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
return true;
}
mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
mLayoutManager.getOrientation());
recyclerView.addItemDecoration(mDividerItemDecoration);
@passiondroid
passiondroid / OpacityHex.markdown
Last active March 1, 2024 21:49
Opacity percentage in a Hex color code

Android uses hexadecimal ARGB values, which are formatted as #AARRGGBB. That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value. Here are the steps:

Alpha Hex Value Process

  • Take your opacity as a decimal value and multiply it by 255. So, if you have a block that is 50% opaque the decimal value would be .5. For example: .5 x 255 = 127.5

  • The fraction won't convert to hexadecimal, so you must round your number up or down to the nearest whole number. For example: 127.5 rounds up to 128; 55.25 rounds down to 55.

  • Enter your decimal value in a decimal-to-hexadecimal converter, like http://www.binaryhexconverter.com/decimal-to-hex-converter, and convert your values.