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
| package com.template.test.testmvptemplate; // your application package | |
| public interface BaseContract { | |
| interface View<T extends Presenter> { | |
| void setPresenter(T presenter); | |
| } | |
| interface Presenter { | |
| void start(); | |
| void stop(); | |
| } |
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
| package com.template.test.testmvptemplate; // your application package | |
| import android.content.Context; | |
| import android.support.annotation.NonNull; | |
| public class BasePresenter { | |
| protected Context mContext; | |
| public void subscribe(@NonNull Context context) { | |
| this.mContext = context; | |
| public boolean isSubscribed() { |
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 class AppIndexingUtil { | |
| private static final String STICKER_URL_PATTERN = "mystickers://sticker/%s"; | |
| private static final String STICKER_PACK_URL_PATTERN = "mystickers://sticker/pack/%s"; | |
| private static final String CONTENT_PROVIDER_STICKER_PACK_NAME = "Firebase Storage Content Pack"; | |
| private static final String TAG = "AppIndexingUtil"; | |
| public static final String FAILED_TO_INSTALL_STICKERS = "Failed to install stickers"; | |
| public static void setStickers(final Context context, FirebaseAppIndex firebaseAppIndex) { | |
| try { | |
| List<Indexable> stickers = getIndexableStickers(); |
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 class AppIndexingUpdateService extends JobIntentService { | |
| // Job-ID must be unique across your whole app. | |
| private static final int UNIQUE_JOB_ID = 42; | |
| public static void enqueueWork(Context context) { | |
| enqueueWork(context, AppIndexingUpdateService.class, UNIQUE_JOB_ID, new Intent()); | |
| } | |
| @Override | |
| protected void onHandleWork(@NonNull Intent intent) { |
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
| Glide.with(mContext) | |
| .load(imageURL) | |
| .asBitmap() | |
| .transcode(new PaletteBitmapTranscoder(mContext), PaletteBitmap.class) | |
| .fitCenter() | |
| .placeholder(R.drawable.placeholder) | |
| .error(R.drawable.placeholder_error) | |
| .diskCacheStrategy(DiskCacheStrategy.ALL) | |
| .into(new ImageViewTarget<PaletteBitmap>(holder.imageView) { | |
| @Override |
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 class PaletteBitmap { | |
| public final Palette palette; | |
| public final Bitmap bitmap; | |
| public PaletteBitmap(@NonNull Bitmap bitmap, @NonNull Palette palette) { | |
| this.bitmap = bitmap; | |
| this.palette = palette; | |
| } | |
| } |
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
| GlideApp.with(context) | |
| .asBitmap() | |
| .load(imageURL) | |
| .diskCacheStrategy(DiskCacheStrategy.ALL) | |
| .placeholder(R.mipmap.ic_launcher) | |
| .listener(new RequestListener<Bitmap>() { | |
| @Override | |
| public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) { | |
| mParentActivity.startPostponedEnterTransition(); | |
| return false; |
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
| // Show the Up button in the action bar. | |
| ActionBar actionBar = getSupportActionBar(); | |
| if (actionBar != null) { | |
| actionBar.setDisplayHomeAsUpEnabled(true); | |
| //set color action bar | |
| actionBar.setBackgroundDrawable(new ColorDrawable(ColorUtils.manipulateColor(mPaletteColor, 0.62f))); | |
| //set color status bar | |
| getWindow().setStatusBarColor(ColorUtils.manipulateColor(mPaletteColor, 0.32f)); | |
| } |
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/33072365/how-to-darken-a-given-color-int | |
| * @param color color provided | |
| * @param factor factor to make color darker | |
| * @return int as darker color | |
| */ | |
| public static int manipulateColor(int color, float factor) { | |
| int a = Color.alpha(color); | |
| int r = Math.round(Color.red(color) * factor); | |
| int g = Math.round(Color.green(color) * factor); |
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
| if ((mColorPalette != 0)) { | |
| mViewBackground.setBackgroundColor(mColorPalette); | |
| } else { | |
| if (getActivity() != null) { | |
| mViewBackground.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.movieDetailTitleBg)); | |
| } | |
| } |