@android.support.annotation.StringRes

Here are the examples of the java api @android.support.annotation.StringRes taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

79 Examples 7

19 Source : SectionsPagerAdapter.java
with GNU General Public License v3.0
from zhoorta

/**
 * A [FragmentPagerAdapter] that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public clreplaced SectionsPagerAdapter extends FragmentPagerAdapter {

    @StringRes
    private static final int[] TAB_replacedLES = new int[] { R.string.tab_config_text_1, R.string.tab_config_text_2 };

    private final Context mContext;

    public SectionsPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        mContext = context;
    }

    @Override
    public Fragment gereplacedem(int position) {
        switch(position) {
            case 0:
                ServerConfigFragment serverConfig = new ServerConfigFragment();
                return serverConfig;
            case 1:
                SignatureConfigFragment signatureConfig = new SignatureConfigFragment();
                return signatureConfig;
            default:
                return null;
        }
    }

    @Nullable
    @Override
    public CharSequence getPagereplacedle(int position) {
        return mContext.getResources().getString(TAB_replacedLES[position]);
    }

    @Override
    public int getCount() {
        // Show 2 total pages.
        return 2;
    }
}

19 Source : Drawer.java
with MIT License
from yaa110

public clreplaced Drawer {

    public static final int TYPE_SPLITTER = 0;

    public static final int TYPE_ABOUT = 1;

    public static final int TYPE_BACKUP = 2;

    public static final int TYPE_RESTORE = 3;

    public static final int TYPE_SETTINGS = 4;

    public int type;

    @DrawableRes
    public int resId;

    @StringRes
    public int replacedle;

    public Drawer() {
    }

    public Drawer(int type, @DrawableRes int resId, @StringRes int replacedle) {
        this.type = type;
        this.resId = resId;
        this.replacedle = replacedle;
    }

    public static Drawer divider() {
        Drawer splitter = new Drawer();
        splitter.type = TYPE_SPLITTER;
        return splitter;
    }
}

19 Source : SaveDialog.java
with MIT License
from yaa110

public clreplaced SaveDialog extends DialogFragment {

    @StringRes
    private int replacedle;

    private String filename_prefix;

    private String extension;

    private String current_path;

    private SaveListener listener;

    private ArrayList<Folder> items;

    private FolderAdapter adapter = null;

    private FixedHeightRecyclerView recyclerView;

    private boolean isWorking = false;

    private boolean canceled = true;

    public static SaveDialog newInstance(@StringRes int replacedle, String filename_prefix, String extension, SaveListener listener) {
        SaveDialog dialog = new SaveDialog();
        dialog.replacedle = replacedle;
        dialog.filename_prefix = filename_prefix;
        dialog.extension = extension;
        dialog.listener = listener;
        return dialog;
    }

    public SaveDialog() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_replacedLE);
        getDialog().setCanceledOnTouchOutside(true);
        return inflater.inflate(R.layout.dialog_save, container);
    }

    @SuppressWarnings("ResultOfMethodCallIgnored")
    private boolean isDirWritable() throws Exception {
        File temp_file = new File(current_path, "temp.tmp");
        if (temp_file.exists())
            temp_file.delete();
        if (temp_file.createNewFile()) {
            temp_file.delete();
            return true;
        }
        return false;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            new Thread() {

                @Override
                public void run() {
                    isWorking = true;
                    current_path = getContext().getFilesDir().getAbsolutePath();
                    try {
                        if (isDirWritable())
                            pathSelected();
                    } catch (Exception ignored) {
                        listener.onError();
                    } finally {
                        new Handler(Looper.getMainLooper()).post(new Runnable() {

                            @Override
                            public void run() {
                                dismiss();
                            }
                        });
                        interrupt();
                    }
                }
            }.start();
        } else {
            ((TextView) view.findViewById(R.id.replacedle_txt)).setText(getString(replacedle));
            current_path = App.last_path != null ? App.last_path : Environment.getExternalStorageDirectory().getAbsolutePath();
            recyclerView = (FixedHeightRecyclerView) view.findViewById(R.id.recyclerView);
            items = new ArrayList<>();
            reload();
            view.findViewById(R.id.positive_btn).setOnClickListener(new View.OnClickListener() {

                @SuppressWarnings("ResultOfMethodCallIgnored")
                @Override
                public void onClick(View view) {
                    if (isWorking)
                        return;
                    isWorking = true;
                    new Thread() {

                        @SuppressWarnings("ConstantConditions")
                        @Override
                        public void run() {
                            try {
                                try {
                                    if (isDirWritable()) {
                                        App.last_path = current_path;
                                        App.instance.putPrefs(App.LAST_PATH_KEY, current_path);
                                        pathSelected();
                                    }
                                } catch (Exception ignored) {
                                    try {
                                        current_path = getContext().getExternalFilesDir(null).getAbsolutePath();
                                        if (isDirWritable())
                                            pathSelected();
                                    } catch (Exception ignored2) {
                                        current_path = getContext().getFilesDir().getAbsolutePath();
                                        try {
                                            if (isDirWritable())
                                                pathSelected();
                                        } catch (Exception e) {
                                            listener.onError();
                                        }
                                    }
                                }
                            } finally {
                                new Handler(Looper.getMainLooper()).post(new Runnable() {

                                    @Override
                                    public void run() {
                                        canceled = false;
                                        dismiss();
                                    }
                                });
                                interrupt();
                            }
                        }
                    }.start();
                }
            });
            view.findViewById(R.id.negative_btn).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (isWorking)
                        return;
                    canceled = true;
                    dismiss();
                }
            });
            view.findViewById(R.id.new_btn).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    ContentDialog.newInstance(R.string.new_folder, R.string.create, R.string.cancel, -1, R.layout.dialog_new_folder, new ContentDialog.DialogListener() {

                        private EditText name_txt;

                        private boolean isCreating = false;

                        @Override
                        public void onPositive(ContentDialog dialog, View content) {
                            if (isCreating || !dialog.checkEditText(name_txt))
                                return;
                            isCreating = true;
                            try {
                                String folder_name = name_txt.getText().toString();
                                File folder = new File(current_path, folder_name);
                                int counter = 2;
                                while (folder.exists()) {
                                    folder = new File(current_path, String.format(Locale.US, "%s(%d)", folder_name, counter));
                                    counter++;
                                }
                                // noinspection ResultOfMethodCallIgnored
                                folder.mkdirs();
                                reload();
                            } catch (Exception ignored) {
                            } finally {
                                dialog.dismiss();
                            }
                        }

                        @Override
                        public void onNegative(ContentDialog dialog, View content) {
                            if (isCreating)
                                return;
                            dialog.dismiss();
                        }

                        @Override
                        public void onNeutral(ContentDialog dialog, View content) {
                        }

                        @Override
                        public void onInit(View content) {
                            name_txt = (EditText) content.findViewById(R.id.name_txt);
                        }
                    }).show(getFragmentManager(), "");
                }
            });
        }
    }

    private void pathSelected() {
        Calendar calendar = Calendar.getInstance(Locale.US);
        filename_prefix = String.format(Locale.US, "%s-%d-%02d-%02d", filename_prefix, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        File save_path = new File(current_path, String.format("%s.%s", filename_prefix, extension));
        int i = 2;
        while (save_path.exists()) {
            save_path = new File(current_path, String.format(Locale.US, "%s(%d).%s", filename_prefix, i, extension));
            i++;
        }
        listener.onSelect(save_path.getAbsolutePath());
    }

    private void reload() {
        new Thread() {

            @Override
            public void run() {
                items.clear();
                File folder = new File(current_path);
                if (!folder.exists())
                    folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
                File[] folders = folder.listFiles(new FileFilter() {

                    @Override
                    public boolean accept(File file) {
                        return file.isDirectory();
                    }
                });
                Arrays.sort(folders, new Comparator<File>() {

                    @Override
                    public int compare(File f1, File f2) {
                        return f1.getName().compareToIgnoreCase(f2.getName());
                    }
                });
                if (!folder.getAbsolutePath().equals(Environment.getExternalStorageDirectory().getAbsolutePath())) {
                    File parent = folder.getParentFile();
                    items.add(new Folder("../" + parent.getName(), parent.getAbsolutePath(), true));
                }
                for (File file : folders) {
                    items.add(new Folder(file.getName(), file.getAbsolutePath(), false));
                }
                new Handler(Looper.getMainLooper()).post(new Runnable() {

                    @Override
                    public void run() {
                        if (adapter == null) {
                            adapter = new FolderAdapter(items, new FolderAdapter.ClickListener() {

                                @Override
                                public void onClick(Folder item) {
                                    if (isWorking)
                                        return;
                                    current_path = item.path;
                                    reload();
                                }
                            });
                            recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
                            recyclerView.setAdapter(adapter);
                        } else {
                            adapter.notifyDataSetChanged();
                        }
                    }
                });
                interrupt();
            }
        }.start();
    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        if (canceled)
            listener.onCancel();
        super.onDismiss(dialog);
    }

    public interface SaveListener {

        void onSelect(String path);

        void onError();

        void onCancel();
    }
}

19 Source : ImportDialog.java
with MIT License
from yaa110

public clreplaced ImportDialog extends DialogFragment {

    @StringRes
    private int replacedle;

    @Nullable
    private String[] extensions;

    private String current_path;

    private ImportListener listener;

    private ArrayList<Folder> items;

    private FolderAdapter adapter = null;

    private FixedHeightRecyclerView recyclerView;

    public ImportDialog() {
    }

    public static ImportDialog newInstance(@StringRes int replacedle, @Nullable String[] extensions, ImportListener listener) {
        ImportDialog dialog = new ImportDialog();
        dialog.replacedle = replacedle;
        dialog.extensions = extensions;
        dialog.listener = listener;
        return dialog;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_replacedLE);
        getDialog().setCanceledOnTouchOutside(true);
        return inflater.inflate(R.layout.dialog_import, container);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            listener.onError(getString(R.string.no_mounted_sd));
            dismiss();
        } else {
            ((TextView) view.findViewById(R.id.replacedle_txt)).setText(replacedle);
            current_path = App.last_path != null ? App.last_path : Environment.getExternalStorageDirectory().getAbsolutePath();
            recyclerView = (FixedHeightRecyclerView) view.findViewById(R.id.recyclerView);
            items = new ArrayList<>();
            reload();
            view.findViewById(R.id.positive_btn).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    dismiss();
                }
            });
        }
    }

    private void reload() {
        new Thread() {

            @Override
            public void run() {
                items.clear();
                File folder = new File(current_path);
                if (!folder.exists())
                    folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
                File[] folders = folder.listFiles(new FileFilter() {

                    @Override
                    public boolean accept(File file) {
                        if (extensions == null)
                            return true;
                        if (file.isDirectory())
                            return true;
                        for (String extension : extensions) {
                            if (file.getName().endsWith(extension))
                                return true;
                        }
                        return false;
                    }
                });
                Arrays.sort(folders, new Comparator<File>() {

                    @Override
                    public int compare(File f1, File f2) {
                        if (f1.isDirectory() && !f2.isDirectory())
                            return -1;
                        if (!f1.isDirectory() && f2.isDirectory())
                            return 1;
                        return f1.getName().compareToIgnoreCase(f2.getName());
                    }
                });
                if (!folder.getAbsolutePath().equals(Environment.getExternalStorageDirectory().getAbsolutePath())) {
                    File parent = folder.getParentFile();
                    items.add(new Folder("../" + parent.getName(), parent.getAbsolutePath(), true));
                }
                for (File file : folders) {
                    items.add(new Folder(file.getName(), file.getAbsolutePath(), false, file.isDirectory()));
                }
                new Handler(Looper.getMainLooper()).post(new Runnable() {

                    @Override
                    public void run() {
                        if (adapter == null) {
                            adapter = new FolderAdapter(items, new FolderAdapter.ClickListener() {

                                @Override
                                public void onClick(Folder item) {
                                    if (item.isDirectory) {
                                        current_path = item.path;
                                        reload();
                                    } else {
                                        App.last_path = current_path;
                                        App.instance.putPrefs(App.LAST_PATH_KEY, current_path);
                                        listener.onSelect(item.path);
                                        dismiss();
                                    }
                                }
                            });
                            recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
                            recyclerView.setAdapter(adapter);
                        } else {
                            adapter.notifyDataSetChanged();
                        }
                    }
                });
                interrupt();
            }
        }.start();
    }

    public interface ImportListener {

        void onSelect(String path);

        void onError(String msg);
    }
}

19 Source : BlogPostLayout2.java
with MIT License
from vipulyaara

/**
 * This model clreplaced gives an example of how to use a view holder pattern with your models.
 */
@EpoxyModelClreplaced(layout = R.layout.item_blog_layout_2)
public abstract clreplaced BlogPostLayout2 extends EpoxyModelWithHolder<BlogPostLayout2.BlogPost2Holder> {

    @EpoxyAttribute
    @StringRes
    int text;

    @EpoxyAttribute(hash = false)
    OnClickListener clickListener;

    @Override
    public int getSpanSize(int totalSpanCount, int position, int itemCount) {
        return totalSpanCount;
    }

    @Override
    public void bind(BlogPost2Holder holder) {
        holder.button.setText(text);
        holder.button.setOnClickListener(clickListener);
    }

    static clreplaced BlogPost2Holder extends BaseEpoxyHolder {

        @BindView(R.id.tv_location)
        Button button;
    }
}

19 Source : BlogPostLayout1.java
with MIT License
from vipulyaara

/**
 * This model clreplaced gives an example of how to use a view holder pattern with your models.
 */
@EpoxyModelClreplaced(layout = R.layout.item_blog_layout_1)
public abstract clreplaced BlogPostLayout1 extends EpoxyModelWithHolder<BlogPostLayout1.BlogPost1Holder> {

    @EpoxyAttribute
    @StringRes
    int text;

    @EpoxyAttribute(hash = false)
    OnClickListener clickListener;

    @Override
    public int getSpanSize(int totalSpanCount, int position, int itemCount) {
        return totalSpanCount;
    }

    @Override
    public void bind(BlogPost1Holder holder) {
        holder.button.setText(text);
        holder.button.setOnClickListener(clickListener);
    }

    static clreplaced BlogPost1Holder extends BaseEpoxyHolder {

        @BindView(R.id.tv_location)
        Button button;
    }
}

19 Source : BasePresenter.java
with Apache License 2.0
from triline3

@StringRes
private int getPrettifiedErrorMessage(@Nullable Throwable throwable) {
    int resId = R.string.network_error;
    if (throwable instanceof HttpException) {
        resId = R.string.network_error;
    } else if (throwable instanceof IOException) {
        resId = R.string.request_error;
    } else if (throwable instanceof TimeoutException) {
        resId = R.string.unexpected_error;
    }
    return resId;
}

19 Source : Command.java
with MIT License
from tranquvis

/**
 * Created by Andreas Kaltenleitner on 29.08.2016.
 */
public abstract clreplaced Command {

    protected static final String PATTERN_MULTI_PARAMS = "(?i)(?<!$)(?:(?:\\s+)?(.*?)(?:\\s+)?(?:and|,|$))";

    protected static final String PATTERN_TEMPLATE_SET_STATE_ON_OFF = "(?i)^\\s*((enable|disable)\\s+(%1$s))" + "|(turn\\s+(%1$s)\\s+(on|off))|(turn\\s+(on|off)\\s+(%1$s))" + "|(set\\s+(%1$s)(\\s+state)?\\s+to)\\s*(on|off|enabled|disabled)$";

    protected static final String PATTERN_TEMPLATE_GET_STATE_ON_OFF = "(?i)^\\s*(((is\\s+)?(%1$s)\\s+(enabled|disabled|on|off)(\\?)?)" + "|((get|fetch|retrieve)\\s+(%1$s)\\s+state))\\s*$";

    private static final List<Command> commands = new ArrayList<>();

    protected String typeId = getClreplaced().getName();

    @StringRes
    protected int replacedleRes;

    /*
    static
    {
        DISPLAY_GET_BRIGHTNESS = new Command("get brightness");
        DISPLAY_SET_BRIGHTNESS = new Command("set brightness to [" + PARAM_BRIGHTNESS + "]");
        DISPLAY_GET_OFF_TIMEOUT = new Command("get display off timeout");
        DISPLAY_SET_OFF_TIMEOUT = new Command("set display off timeout to ["
                + PARAM_DISPLAY_OFF_TIMEOUT + "]");
        DISPLAY_TURN_OFF = new Command("turn display off");
    }
*/
    protected String[] syntaxDescList;

    protected PatternTreeNode patternTree;

    protected Module module;

    /**
     * Create and register command.
     *
     * @param module related module
     */
    protected Command(@NonNull Module module) {
        this.module = module;
        commands.add(this);
    }

    protected static String GetPatternFromTemplate(String template, String... values) {
        return String.format(template, (Object[]) values);
    }

    protected static String AdaptSimplePattern(String pattern) {
        return "(?i)^\\s*" + pattern.replace(" ", "\\s+") + "\\s*$";
    }

    /**
     * Get all registered commands.
     *
     * @param sortComparator This comparator is used to sort the list.
     * @return (sorted) list of all commands
     * @see Comparator
     */
    public static List<Command> GetAllCommands(@Nullable Comparator<Command> sortComparator) {
        Instances.InitCommands();
        List<Command> commandsSorted = new ArrayList<>(commands);
        if (sortComparator != null)
            Collections.sort(commandsSorted, sortComparator);
        return commands;
    }

    public int getreplacedleRes() {
        return replacedleRes;
    }

    public String[] getSyntaxDescList() {
        return syntaxDescList;
    }

    public PatternTreeNode getPatternTree() {
        return patternTree;
    }

    public Module getModule() {
        return module;
    }

    public abstract void execute(Context context, CommandInstance commandInstance, CommandExecResult result) throws Exception;

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof Command))
            return false;
        Command command = (Command) o;
        return typeId != null ? typeId.equals(command.typeId) : command.typeId == null;
    }

    @Override
    public int hashCode() {
        return typeId != null ? typeId.hashCode() : 0;
    }
}

19 Source : SettingsParentFragment.java
with GNU General Public License v3.0
from timusus

public clreplaced SettingsParentFragment extends BaseNavigationController implements DrawerLockManager.DrawerLock, MiniPlayerLockManager.MiniPlayerLock {

    public static String ARG_PREFERENCE_RESOURCE = "preference_resource";

    public static String ARG_replacedLE = "replacedle";

    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @XmlRes
    int preferenceResource;

    @StringRes
    int replacedleResId;

    private Unbinder unbinder;

    public static SettingsParentFragment newInstance(@XmlRes int preferenceResource, @StringRes int replacedleResId) {
        Bundle args = new Bundle();
        args.putInt(ARG_PREFERENCE_RESOURCE, preferenceResource);
        args.putInt(ARG_replacedLE, replacedleResId);
        SettingsParentFragment fragment = new SettingsParentFragment();
        fragment.setArguments(args);
        return fragment;
    }

    public SettingsParentFragment() {
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        replacedleResId = getArguments().getInt(ARG_replacedLE);
        preferenceResource = getArguments().getInt(ARG_PREFERENCE_RESOURCE);
    }

    @Override
    public FragmentInfo getRootViewControllerInfo() {
        return SettingsFragment.getFragmentInfo(preferenceResource);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_settings, container, false);
        unbinder = ButterKnife.bind(this, rootView);
        toolbar.setreplacedle(replacedleResId);
        toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
        return rootView;
    }

    @Override
    public void onResume() {
        super.onResume();
        DrawerLockManager.getInstance().addDrawerLock(this);
        MiniPlayerLockManager.getInstance().addMiniPlayerLock(this);
    }

    @Override
    public void onPause() {
        DrawerLockManager.getInstance().removeDrawerLock(this);
        MiniPlayerLockManager.getInstance().removeMiniPlayerLock(this);
        super.onPause();
    }

    @Override
    public void onDestroyView() {
        unbinder.unbind();
        super.onDestroyView();
    }

    public static clreplaced SettingsFragment extends PreferenceFragmentCompat implements Controller, SupportView, SettingsView, ColorChooserDialog.ColorCallback {

        @XmlRes
        int preferenceResource;

        @Inject
        SupportPresenter supportPresenter;

        @Inject
        SettingsPresenter settingsPresenter;

        @Inject
        BillingManager billingManager;

        @Inject
        replacedyticsManager replacedyticsManager;

        @Inject
        SettingsManager settingsManager;

        private ColorChooserDialog primaryColorDialog;

        private ColorChooserDialog accentColorDialog;

        private Disposable aestheticDisposable;

        public static FragmentInfo getFragmentInfo(@XmlRes int preferenceResource) {
            Bundle args = new Bundle();
            args.putInt(ARG_PREFERENCE_RESOURCE, preferenceResource);
            return new FragmentInfo(SettingsFragment.clreplaced, args, "settingsRoot");
        }

        public static SettingsFragment newInstance(@XmlRes int preferenceResource) {
            Bundle args = new Bundle();
            args.putInt(ARG_PREFERENCE_RESOURCE, preferenceResource);
            SettingsFragment settingsFragment = new SettingsFragment();
            settingsFragment.setArguments(args);
            return settingsFragment;
        }

        public SettingsFragment() {
        }

        @Override
        public void onAttach(Context context) {
            super.onAttach(context);
            preferenceResource = getArguments().getInt(ARG_PREFERENCE_RESOURCE);
        }

        @Override
        public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
            addPreferencesFromResource(preferenceResource);
        }

        @Override
        public void onCreate(Bundle savedInstanceState) {
            AndroidSupportInjection.inject(this);
            super.onCreate(savedInstanceState);
            // Support Preferences
            Preference changelogPreference = findPreference(SettingsManager.KEY_PREF_CHANGELOG);
            if (changelogPreference != null) {
                changelogPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.changelogClicked();
                    return true;
                });
            }
            Preference faqPreference = findPreference(SettingsManager.KEY_PREF_FAQ);
            if (faqPreference != null) {
                faqPreference.setOnPreferenceClickListener(preference -> {
                    supportPresenter.faqClicked();
                    return true;
                });
            }
            Preference helpPreference = findPreference(SettingsManager.KEY_PREF_HELP);
            if (helpPreference != null) {
                helpPreference.setOnPreferenceClickListener(preference -> {
                    supportPresenter.helpClicked();
                    return true;
                });
            }
            Preference ratePreference = findPreference(SettingsManager.KEY_PREF_RATE);
            if (ratePreference != null) {
                ratePreference.setOnPreferenceClickListener(preference -> {
                    supportPresenter.rateClicked();
                    return true;
                });
            }
            Preference restorePurchasesPreference = findPreference(SettingsManager.KEY_PREF_RESTORE_PURCHASES);
            if (restorePurchasesPreference != null) {
                if (ShuttleUtils.isAmazonBuild() || ShuttleUtils.isUpgraded((ShuttleApplication) getContext().getApplicationContext(), settingsManager)) {
                    restorePurchasesPreference.setVisible(false);
                }
                restorePurchasesPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.restorePurchasesClicked();
                    return true;
                });
            }
            // Display
            Preference chooseTabsPreference = findPreference(SettingsManager.KEY_PREF_TAB_CHOOSER);
            if (chooseTabsPreference != null) {
                chooseTabsPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.chooseTabsClicked();
                    return true;
                });
            }
            Preference defaultPagePreference = findPreference(SettingsManager.KEY_PREF_DEFAULT_PAGE);
            if (defaultPagePreference != null) {
                defaultPagePreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.chooseDefaultPageClicked(getContext());
                    return true;
                });
            }
            // Themes
            Preference baseThemePreference = findPreference(SettingsManager.KEY_PREF_THEME_BASE);
            if (baseThemePreference != null) {
                baseThemePreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.baseThemeClicked(getContext());
                    return true;
                });
            }
            Preference primaryColorPreference = findPreference(SettingsManager.KEY_PREF_PRIMARY_COLOR);
            if (primaryColorPreference != null) {
                primaryColorPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.primaryColorClicked(getContext());
                    return true;
                });
            }
            Preference accentColorColorPreference = findPreference(SettingsManager.KEY_PREF_ACCENT_COLOR);
            if (accentColorColorPreference != null) {
                accentColorColorPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.accentColorClicked(getContext());
                    return true;
                });
            }
            SwitchPreferenceCompat tintNavBarColorPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_PREF_NAV_BAR);
            if (tintNavBarColorPreference != null) {
                tintNavBarColorPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.tintNavBarClicked(getContext(), (Boolean) newValue);
                    return true;
                });
            }
            SwitchPreferenceCompat usePalettePreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_PREF_PALETTE);
            if (usePalettePreference != null) {
                usePalettePreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.usePaletteClicked(getContext(), (Boolean) newValue);
                    return true;
                });
            }
            SwitchPreferenceCompat usePaletteNowPlayingOnlyPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_PREF_PALETTE_NOW_PLAYING_ONLY);
            if (usePaletteNowPlayingOnlyPreference != null) {
                usePaletteNowPlayingOnlyPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.usePaletteNowPlayingOnlyClicked(getContext(), (Boolean) newValue);
                    return true;
                });
            }
            // Artwork
            Preference downloadArtworkPreference = findPreference(SettingsManager.KEY_PREF_DOWNLOAD_ARTWORK);
            if (downloadArtworkPreference != null) {
                downloadArtworkPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.downloadArtworkClicked(getContext());
                    return true;
                });
            }
            Preference deleteArtworkPreference = findPreference(SettingsManager.KEY_PREF_DELETE_ARTWORK);
            if (deleteArtworkPreference != null) {
                deleteArtworkPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.deleteArtworkClicked(getContext());
                    return true;
                });
            }
            SwitchPreferenceCompat ignoreEmbeddedArtworkPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_IGNORE_EMBEDDED_ARTWORK);
            if (ignoreEmbeddedArtworkPreference != null) {
                ignoreEmbeddedArtworkPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.changeArtworkPreferenceClicked(getContext());
                    return true;
                });
            }
            SwitchPreferenceCompat ignoreFolderArtworkPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_IGNORE_FOLDER_ARTWORK);
            if (ignoreFolderArtworkPreference != null) {
                ignoreFolderArtworkPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.changeArtworkPreferenceClicked(getContext());
                    return true;
                });
            }
            SwitchPreferenceCompat preferEmbeddedArtworkPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_PREFER_EMBEDDED_ARTWORK);
            if (preferEmbeddedArtworkPreference != null) {
                preferEmbeddedArtworkPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.changeArtworkPreferenceClicked(getContext());
                    return true;
                });
            }
            SwitchPreferenceCompat ignoreMediaStoreArtworkPreference = (SwitchPreferenceCompat) findPreference(SettingsManager.KEY_IGNORE_MEDIASTORE_ART);
            if (ignoreMediaStoreArtworkPreference != null) {
                ignoreMediaStoreArtworkPreference.setOnPreferenceChangeListener((preference, newValue) -> {
                    settingsPresenter.changeArtworkPreferenceClicked(getContext());
                    return true;
                });
            }
            // Headset/Bluetooth
            // Scrobbling
            Preference downloadScrobblerPreference = findPreference(SettingsManager.KEY_PREF_DOWNLOAD_SCROBBLER);
            if (downloadScrobblerPreference != null) {
                if (ShuttleUtils.isAmazonBuild()) {
                    // Amazon don't allow links to the Play Store
                    downloadScrobblerPreference.setVisible(false);
                }
                downloadScrobblerPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.downloadScrobblerClicked();
                    return true;
                });
            }
            // Whitelist/Blacklist
            Preference viewBlacklistPreference = findPreference(SettingsManager.KEY_PREF_BLACKLIST);
            if (viewBlacklistPreference != null) {
                viewBlacklistPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.viewBlacklistClicked();
                    return true;
                });
            }
            Preference viewWhitelistPreference = findPreference(SettingsManager.KEY_PREF_WHITELIST);
            if (viewWhitelistPreference != null) {
                viewWhitelistPreference.setOnPreferenceClickListener(preference -> {
                    settingsPresenter.viewWhitelistClicked();
                    return true;
                });
            }
            // Upgrade preference
            Preference upgradePreference = findPreference(SettingsManager.KEY_PREF_UPGRADE);
            if (upgradePreference != null) {
                if (ShuttleUtils.isUpgraded((ShuttleApplication) getContext().getApplicationContext(), settingsManager)) {
                    upgradePreference.setVisible(false);
                }
            }
        }

        @Override
        public void onResume() {
            super.onResume();
            supportPresenter.bindView(this);
            settingsPresenter.bindView(this);
            aestheticDisposable = Aesthetic.get(getContext()).colorAccent().compose(Rx.distinctToMainThread()).subscribe(this::invalidateColors);
        }

        @Override
        public void onPause() {
            supportPresenter.unbindView(this);
            settingsPresenter.unbindView(this);
            aestheticDisposable.dispose();
            super.onPause();
        }

        @Override
        public boolean onPreferenceTreeClick(Preference preference) {
            if (preference.getKey() != null) {
                switch(preference.getKey()) {
                    case "pref_display":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_display), "DisplaySettings");
                        break;
                    case "pref_themes":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_themes), "ThemeSettings");
                        break;
                    case "pref_artwork":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_artwork), "ArtworkSettings");
                        break;
                    case "pref_playback":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_playback), "PlaybackSettings");
                        break;
                    case "pref_headset":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_headset), "HeadsetSettings");
                        break;
                    case "pref_scrobbling":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_scrobbling), "ScrobblingSettings");
                        break;
                    case "pref_blacklist":
                        getNavigationController().pushViewController(SettingsFragment.newInstance(R.xml.settings_blacklist), "BlacklistSettings");
                        break;
                    case "pref_upgrade":
                        settingsPresenter.upgradeClicked();
                        break;
                }
            }
            return true;
        }

        void invalidateColors(int color) {
            int preferenceCount = getPreferenceScreen().getPreferenceCount();
            for (int i = 0; i < preferenceCount; i++) {
                tintPreferenceIcon(getPreferenceScreen().getPreference(i), color);
            }
        }

        void tintPreferenceIcon(Preference preference, int color) {
            if (preference != null) {
                Drawable icon = preference.getIcon();
                if (icon != null) {
                    icon = DrawableCompat.wrap(icon);
                    DrawableCompat.setTint(icon, color);
                    preference.setIcon(icon);
                }
            }
        }

        @Override
        public void onColorSelection(@NonNull ColorChooserDialog dialog, int selectedColor) {
            if (dialog == primaryColorDialog) {
                settingsPresenter.changePrimaryColor(getContext(), selectedColor);
            } else if (dialog == accentColorDialog) {
                settingsPresenter.changeAccentColor(getContext(), selectedColor);
            }
        }

        @Override
        public void onColorChooserDismissed(@NonNull ColorChooserDialog dialog) {
        }

        // Support View
        @Override
        public void setVersion(String version) {
            final Preference versionPreference = findPreference("pref_version");
            if (versionPreference != null) {
                versionPreference.setSummary(version);
            }
        }

        @Override
        public void showFaq(Intent intent) {
            startActivity(intent);
        }

        @Override
        public void showHelp(Intent intent) {
            startActivity(intent);
        }

        @Override
        public void showRate(Intent intent) {
            startActivity(intent);
        }

        @NonNull
        @Override
        public NavigationController<Fragment> getNavigationController() {
            return BaseController.findNavigationController(this);
        }

        // Settings View
        // Support
        @Override
        public void showChangelog() {
            ChangelogDialog.Companion.newInstance().show(getChildFragmentManager());
        }

        @Override
        public void showUpgradeDialog() {
            new UpgradeDialog().show(getChildFragmentManager());
        }

        @Override
        public void showRestorePurchasesMessage(int messageResId) {
            Toast.makeText(getContext(), messageResId, Toast.LENGTH_LONG).show();
        }

        @Override
        public void showTabChooserDialog() {
            new TabChooserDialog().show(getChildFragmentManager());
        }

        @Override
        public void showDefaultPageDialog(MaterialDialog dialog) {
            dialog.show();
        }

        // Themes
        @Override
        public void showBaseThemeDialog(MaterialDialog dialog) {
            dialog.show();
        }

        @Override
        public void showPrimaryColorDialog(ColorChooserDialog dialog) {
            primaryColorDialog = dialog.show(getChildFragmentManager());
        }

        @Override
        public void showAccentColorDialog(ColorChooserDialog dialog) {
            accentColorDialog = dialog.show(getChildFragmentManager());
        }

        // Artwork
        @Override
        public void showDownloadArtworkDialog(MaterialDialog dialog) {
            dialog.show();
        }

        @Override
        public void showDeleteArtworkDialog(MaterialDialog dialog) {
            dialog.show();
        }

        @Override
        public void showArtworkPreferenceChangeDialog(MaterialDialog dialog) {
            dialog.show();
        }

        // Scrobbling
        @Override
        public void launchDownloadScrobblerIntent(Intent intent) {
            startActivity(intent);
        }

        // Blacklist/Whitelist
        @Override
        public void showBlacklistDialog() {
            InclExclDialog.Companion.newInstance(InclExreplacedem.Type.EXCLUDE).show(getChildFragmentManager());
        }

        @Override
        public void showWhitelistDialog() {
            InclExclDialog.Companion.newInstance(InclExreplacedem.Type.INCLUDE).show(getChildFragmentManager());
        }
    }
}

19 Source : ShuffleView.java
with GNU General Public License v3.0
from timusus

public clreplaced ShuffleView extends BaseViewModel<ShuffleView.ViewHolder> {

    public interface ShuffleClickListener {

        void onShuffleItemClick();
    }

    @StringRes
    private int replacedleResId = R.string.shuffle_all;

    public void setreplacedleResId(int replacedleResId) {
        this.replacedleResId = replacedleResId;
    }

    @Nullable
    private ShuffleClickListener listener;

    public void setClickListener(@Nullable ShuffleClickListener listener) {
        this.listener = listener;
    }

    @Override
    public int getViewType() {
        return ViewType.SHUFFLE;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.list_item_shuffle;
    }

    @Override
    public ViewHolder createViewHolder(ViewGroup parent) {
        return new ViewHolder(createView(parent));
    }

    @Override
    public void bindView(ViewHolder holder) {
        super.bindView(holder);
        holder.replacedle.setText(replacedleResId);
    }

    void onItemClick() {
        if (listener != null) {
            listener.onShuffleItemClick();
        }
    }

    public static clreplaced ViewHolder extends BaseViewHolder<ShuffleView> {

        @BindView(R.id.replacedle)
        TextView replacedle;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(v -> viewModel.onItemClick());
        }

        @Override
        public String toString() {
            return "ShuffleView.ViewHolder";
        }
    }
}

19 Source : DeleteDialog.java
with GNU General Public License v3.0
from timusus

public clreplaced DeleteDialog extends DialogFragment implements SafManager.SafDialog.SafResultListener {

    public @interface Type {

        int ARTISTS = 0;

        int ALBUMS = 1;

        int SONGS = 2;
    }

    private static final String TAG = "DeleteDialog";

    private static final String ARG_TYPE = "type";

    private static final String ARG_DELETE_MESSAGE_ID = "delete_message_id";

    private static final String ARG_ARTISTS = "artists";

    private static final String ARG_ALBUMS = "artists";

    private static final String ARG_SONGS = "songs";

    private static final String BUNDLE_SONGS_FOR_NORMAL_DELETION = "songs_for_normal_deletion";

    private static final String BUNDLE_SONGS_FOR_SAF_DELETION = "songs_for_saf_deletion";

    @Type
    private int type;

    @StringRes
    private int deleteMessageId;

    @Inject
    MediaManager mediaManager;

    @Inject
    Repository.SongsRepository songsRepository;

    @Inject
    SettingsManager settingsManager;

    private List<AlbumArtist> artists;

    private List<Album> albums;

    private List<Song> songs;

    private List<Song> songsForNormalDeletion = new ArrayList<>();

    private List<DoreplacedentFile> doreplacedentFilesForDeletion = new ArrayList<>();

    private List<Song> songsForSafDeletion = new ArrayList<>();

    private CompositeDisposable disposables = new CompositeDisposable();

    public interface ListArtistsRef extends Supplier<List<AlbumArtist>> {
    }

    public static DeleteDialog newInstance(@NonNull ListArtistsRef artists) {
        Bundle args = new Bundle();
        args.putInt(ARG_TYPE, Type.ARTISTS);
        args.putInt(ARG_DELETE_MESSAGE_ID, artists.get().size() == 1 ? R.string.delete_album_artist_desc : R.string.delete_album_artist_desc_multiple);
        args.putSerializable(ARG_ARTISTS, (Serializable) artists.get());
        DeleteDialog fragment = new DeleteDialog();
        fragment.setArguments(args);
        return fragment;
    }

    public interface ListAlbumsRef extends Supplier<List<Album>> {
    }

    public static DeleteDialog newInstance(@NonNull ListAlbumsRef albums) {
        Bundle args = new Bundle();
        args.putInt(ARG_TYPE, Type.ALBUMS);
        args.putInt(ARG_DELETE_MESSAGE_ID, albums.get().size() == 1 ? R.string.delete_album_desc : R.string.delete_album_desc_multiple);
        args.putSerializable(ARG_ALBUMS, (Serializable) albums.get());
        DeleteDialog fragment = new DeleteDialog();
        fragment.setArguments(args);
        return fragment;
    }

    public interface ListSongsRef extends Supplier<List<Song>> {
    }

    public static DeleteDialog newInstance(@NonNull ListSongsRef songs) {
        Bundle args = new Bundle();
        args.putInt(ARG_TYPE, Type.SONGS);
        args.putInt(ARG_DELETE_MESSAGE_ID, songs.get().size() == 1 ? R.string.delete_song_desc : R.string.delete_song_desc_multiple);
        args.putSerializable(ARG_SONGS, (Serializable) songs.get());
        DeleteDialog fragment = new DeleteDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        AndroidSupportInjection.inject(this);
        super.onCreate(savedInstanceState);
        deleteMessageId = getArguments().getInt(ARG_DELETE_MESSAGE_ID);
        type = getArguments().getInt(ARG_TYPE);
        switch(type) {
            case Type.ARTISTS:
                artists = (List<AlbumArtist>) getArguments().getSerializable(ARG_ARTISTS);
                break;
            case Type.ALBUMS:
                albums = (List<Album>) getArguments().getSerializable(ARG_ALBUMS);
                break;
            case Type.SONGS:
                songs = (List<Song>) getArguments().getSerializable(ARG_SONGS);
                break;
        }
        if (savedInstanceState != null) {
            songsForNormalDeletion = (List<Song>) savedInstanceState.getSerializable(BUNDLE_SONGS_FOR_NORMAL_DELETION);
            songsForSafDeletion = (List<Song>) savedInstanceState.getSerializable(BUNDLE_SONGS_FOR_SAF_DELETION);
        }
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        List<String> names = new ArrayList<>();
        switch(type) {
            case Type.ARTISTS:
                names = Stream.of(artists).map(albumArtist -> albumArtist.name).toList();
                break;
            case Type.ALBUMS:
                names = Stream.of(albums).map(album -> album.name).toList();
                break;
            case Type.SONGS:
                names = Stream.of(songs).map(song -> song.name).toList();
                break;
        }
        String message;
        if (names.isEmpty()) {
            message = getString(R.string.delete_songs_unknown);
        } else {
            if (names.size() > 1) {
                message = String.format(getString(deleteMessageId), Stream.of(names).map(itemName -> "\n\u2022 " + itemName).collect(Collectors.joining()) + "\n");
            } else {
                message = String.format(getString(deleteMessageId), names.get(0));
            }
        }
        return new MaterialDialog.Builder(getContext()).iconRes(R.drawable.ic_warning_24dp).replacedle(R.string.delete_item).content(message).positiveText(R.string.button_ok).onPositive((materialDialog, dialogAction) -> deleteSongsOrShowSafDialog()).negativeText(R.string.cancel).onNegative((materialDialog, dialogAction) -> dismiss()).autoDismiss(false).build();
    }

    @Override
    public void onPause() {
        super.onPause();
        disposables.clear();
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putSerializable(BUNDLE_SONGS_FOR_NORMAL_DELETION, (Serializable) songsForNormalDeletion);
        outState.putSerializable(BUNDLE_SONGS_FOR_SAF_DELETION, (Serializable) songsForSafDeletion);
        super.onSaveInstanceState(outState);
    }

    @NonNull
    Single<List<Song>> getSongs() {
        switch(type) {
            case Type.ARTISTS:
                return Observable.fromIterable(artists).flatMapSingle(albumArtist -> albumArtist.getSongsSingle(songsRepository)).reduce(Collections.<Song>emptyList(), (songs, songs2) -> Stream.concat(Stream.of(songs), Stream.of(songs2)).toList()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
            case Type.ALBUMS:
                return Observable.fromIterable(albums).flatMapSingle(album -> AlbumExtKt.getSongsSingle(album, songsRepository)).reduce(Collections.<Song>emptyList(), (songs, songs2) -> Stream.concat(Stream.of(songs), Stream.of(songs2)).toList()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
            case Type.SONGS:
                return Single.just(songs);
        }
        return Single.just(Collections.emptyList());
    }

    public void show(FragmentManager fragmentManager) {
        show(fragmentManager, TAG);
    }

    @SuppressLint("CheckResult")
    void deleteSongsOrShowSafDialog() {
        disposables.add(getSongs().map(songs -> {
            // Keep track of the songs we want to delete, for later.
            Stream.of(songs).forEach(song -> {
                if (SafManager.getInstance(getContext(), settingsManager).requiresPermission(new File(song.path))) {
                    songsForSafDeletion.add(song);
                } else {
                    songsForNormalDeletion.add(song);
                }
            });
            boolean requiresSafDialog = false;
            if (!songsForSafDeletion.isEmpty()) {
                // We're gonna need SAF access to delete some songs.
                // We may be able to build a list of doreplacedent files if the user has been here before..
                List<DoreplacedentFile> doreplacedentFiles = SafManager.getInstance(getContext(), settingsManager).getWriteableDoreplacedentFiles(Stream.of(songsForSafDeletion).map(song -> new File(song.path)).toList());
                if (doreplacedentFiles.size() == songsForSafDeletion.size()) {
                    // We have all the doreplacedent files we need. No need to show SAF dialog.
                    this.doreplacedentFilesForDeletion.addAll(doreplacedentFiles);
                } else {
                    // We'll have to show the SAF dialog
                    requiresSafDialog = true;
                }
            }
            return requiresSafDialog;
        }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(requiresSafDialog -> {
            if (requiresSafDialog) {
                if (DeleteDialog.this.isAdded()) {
                    SafManager.SafDialog.show(DeleteDialog.this);
                } else {
                    LogUtils.logException(TAG, "Failed to delete songs.. Couldn't show SAFDialog", null);
                    Toast.makeText(getContext(), getString(R.string.delete_songs_failure_toast), Toast.LENGTH_SHORT).show();
                }
            } else {
                disposables.add(deleteSongs().observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(deletedSongs -> {
                    if (DeleteDialog.this.isAdded()) {
                        if (deletedSongs > 0) {
                            Toast.makeText(getContext(), getString(R.string.delete_songs_success_toast, deletedSongs), Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(getContext(), getString(R.string.delete_songs_failure_toast), Toast.LENGTH_SHORT).show();
                        }
                        dismiss();
                    }
                }, error -> {
                    LogUtils.logException(TAG, "Failed to delete songs", error);
                    if (DeleteDialog.this.isAdded()) {
                        Toast.makeText(getContext(), getString(R.string.delete_songs_failure_toast), Toast.LENGTH_SHORT).show();
                    }
                }));
            }
        }, error -> LogUtils.logException(TAG, "Failed to delete songs", error)));
    }

    @SuppressLint("CheckResult")
    Single<Integer> deleteSongs() {
        return Single.fromCallable(() -> {
            int deletedSongs = 0;
            if (!doreplacedentFilesForDeletion.isEmpty()) {
                deletedSongs += Stream.of(doreplacedentFilesForDeletion).filter(DoreplacedentFile::delete).count();
                tidyUp(songsForSafDeletion);
                doreplacedentFilesForDeletion.clear();
                songsForSafDeletion.clear();
            }
            if (!songsForNormalDeletion.isEmpty()) {
                deletedSongs += Stream.of(songsForNormalDeletion).filter(SongExtKt::delete).count();
                tidyUp(songsForNormalDeletion);
                songsForNormalDeletion.clear();
            }
            return deletedSongs;
        });
    }

    void tidyUp(@NonNull List<Song> deletedSongs) {
        if (deletedSongs.isEmpty()) {
            return;
        }
        // Remove songs from current play queue
        mediaManager.removeSongsFromQueue(deletedSongs);
        // Remove songs from play count table
        ArrayList<ContentProviderOperation> operations = Stream.of(deletedSongs).map(song -> ContentProviderOperation.newDelete(PlayCountTable.URI).withSelection(PlayCountTable.COLUMN_ID + "=" + song.id, null).build()).collect(Collectors.toCollection(ArrayList::new));
        try {
            getContext().getContentResolver().applyBatch(PlayCountTable.AUTHORITY, operations);
        } catch (RemoteException | OperationApplicationException e) {
            e.printStackTrace();
        }
        CustomMediaScanner.scanFiles(getContext(), Stream.of(deletedSongs).map(song -> song.path).toList(), null);
    }

    @SuppressLint("CheckResult")
    @Override
    public void onResult(@Nullable Uri treeUri) {
        if (treeUri != null) {
            disposables.add(Completable.fromAction(() -> doreplacedentFilesForDeletion = SafManager.getInstance(getContext(), settingsManager).getWriteableDoreplacedentFiles(Stream.of(songsForSafDeletion).map(song -> new File(song.path)).toList())).andThen(deleteSongs()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(deletedSongs -> {
                if (deletedSongs > 0) {
                    Toast.makeText(getContext(), getString(R.string.delete_songs_success_toast, deletedSongs), Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getContext(), getString(R.string.delete_songs_failure_toast), Toast.LENGTH_SHORT).show();
                }
                dismiss();
            }, error -> LogUtils.logException(TAG, "Failed to delete songs", error)));
        } else {
            Toast.makeText(getContext(), R.string.delete_songs_failure_toast, Toast.LENGTH_LONG).show();
            dismiss();
        }
    }
}

19 Source : CategoryItem.java
with GNU General Public License v3.0
from timusus

@StringRes
public int getreplacedleResId() {
    switch(type) {
        case Type.GENRES:
            return R.string.genres_replacedle;
        case Type.SUGGESTED:
            return R.string.suggested_replacedle;
        case Type.ARTISTS:
            return R.string.artists_replacedle;
        case Type.ALBUMS:
            return R.string.albums_replacedle;
        case Type.SONGS:
            return R.string.tracks_replacedle;
        case Type.FOLDERS:
            return R.string.folders_replacedle;
        case Type.PLAYLISTS:
            return R.string.playlists_replacedle;
    }
    return -1;
}

19 Source : ColorChooserDialog.java
with GNU General Public License v3.0
from ThirtyDegreesRay

@StringRes
public int getreplacedle() {
    Builder builder = getBuilder();
    int replacedle;
    if (isInSub()) {
        replacedle = builder.replacedleSub;
    } else {
        replacedle = builder.replacedle;
    }
    if (replacedle == 0) {
        replacedle = builder.replacedle;
    }
    return replacedle;
}

19 Source : MarkdownEditorActivity.java
with GNU General Public License v3.0
from ThirtyDegreesRay

/**
 * Created by ThirtyDegreesRay on 2017/9/29 11:43:25
 */
public clreplaced MarkdownEditorActivity extends PagerActivity implements MarkdownEditorCallback {

    public static void show(@NonNull Activity activity, @StringRes int replacedle, int requestCode) {
        show(activity, replacedle, requestCode, null);
    }

    public static void show(@NonNull Activity activity, @StringRes int replacedle, int requestCode, @Nullable String text) {
        show(activity, replacedle, requestCode, text, null);
    }

    public static void show(@NonNull Activity activity, @StringRes int replacedle, int requestCode, @Nullable String text, @Nullable ArrayList<String> mentionUsers) {
        Intent intent = new Intent(activity, MarkdownEditorActivity.clreplaced);
        intent.putExtra("text", text);
        intent.putExtra("replacedle", replacedle);
        intent.putExtra("mentionUsers", mentionUsers);
        activity.startActivityForResult(intent, requestCode);
    }

    @AutoAccess
    String text;

    @AutoAccess
    @StringRes
    int replacedle;

    @AutoAccess
    ArrayList<String> mentionUsers;

    private MarkdownEditorCallback markdownEditorCallback;

    private boolean isKeyBoardShow = true;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
    }

    @Override
    protected void initActivity() {
        super.initActivity();
        pagerAdapter = new FragmentViewPagerAdapter(getSupportFragmentManager());
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        setToolbarBackEnable();
        setToolbarreplacedle(getString(replacedle));
        pagerAdapter.setPagerList(FragmentPagerModel.createMarkdownEditorPagerList(getActivity(), text, getFragments(), mentionUsers));
        tabLayout.setVisibility(View.VISIBLE);
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setAdapter(pagerAdapter);
    }

    @Override
    public void onAttachFragment(Fragment fragment) {
        super.onAttachFragment(fragment);
        if (fragment instanceof MarkdownEditorFragment) {
            markdownEditorCallback = (MarkdownEditorCallback) fragment;
        }
    }

    @Override
    public int getPagerSize() {
        return 2;
    }

    @Override
    protected int getFragmentPosition(Fragment fragment) {
        if (fragment instanceof MarkdownEditorFragment) {
            return 0;
        } else if (fragment instanceof MarkdownPreviewFragment) {
            return 1;
        } else
            return -1;
    }

    @Nullable
    @Override
    protected int getContentView() {
        return R.layout.activity_view_pager;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_confirm, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.gereplacedemId() == R.id.action_commit) {
            commit();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private void commit() {
        if (StringUtils.isBlank(getText())) {
            Toasty.warning(getActivity(), getString(R.string.comment_null_warning)).show();
            return;
        }
        Intent data = new Intent();
        data.putExtra("text", getText());
        setResult(RESULT_OK, data);
        finish();
    }

    @Override
    public String getText() {
        return markdownEditorCallback.getText();
    }

    @Override
    public boolean isTextChanged() {
        return markdownEditorCallback.isTextChanged();
    }
}

19 Source : DownloadService.java
with GNU General Public License v2.0
from TelePlusDev

/**
 * A {@link Service} for downloading media.
 */
public abstract clreplaced DownloadService extends Service {

    /**
     * Starts a download service without adding a new {@link DownloadAction}.
     */
    public static final String ACTION_INIT = "com.google.android.exoplayer.downloadService.action.INIT";

    /**
     * Starts a download service, adding a new {@link DownloadAction} to be executed.
     */
    public static final String ACTION_ADD = "com.google.android.exoplayer.downloadService.action.ADD";

    /**
     * Reloads the download requirements.
     */
    public static final String ACTION_RELOAD_REQUIREMENTS = "com.google.android.exoplayer.downloadService.action.RELOAD_REQUIREMENTS";

    /**
     * Like {@link #ACTION_INIT}, but with {@link #KEY_FOREGROUND} implicitly set to true.
     */
    private static final String ACTION_RESTART = "com.google.android.exoplayer.downloadService.action.RESTART";

    /**
     * Key for the {@link DownloadAction} in an {@link #ACTION_ADD} intent.
     */
    public static final String KEY_DOWNLOAD_ACTION = "download_action";

    /**
     * Invalid foreground notification id which can be used to run the service in the background.
     */
    public static final int FOREGROUND_NOTIFICATION_ID_NONE = 0;

    /**
     * Key for a boolean flag in any intent to indicate whether the service was started in the
     * foreground. If set, the service is guaranteed to call {@link #startForeground(int,
     * Notification)}.
     */
    public static final String KEY_FOREGROUND = "foreground";

    /**
     * Default foreground notification update interval in milliseconds.
     */
    public static final long DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL = 1000;

    private static final String TAG = "DownloadService";

    private static final boolean DEBUG = false;

    // Keep the requirements helper for each DownloadService as long as there are tasks (and the
    // process is running). This allows tasks to resume when there's no scheduler. It may also allow
    // tasks the resume more quickly than when relying on the scheduler alone.
    private static final HashMap<Clreplaced<? extends DownloadService>, RequirementsHelper> requirementsHelpers = new HashMap<>();

    private static final Requirements DEFAULT_REQUIREMENTS = new Requirements(Requirements.NETWORK_TYPE_ANY, false, false);

    @Nullable
    private final ForegroundNotificationUpdater foregroundNotificationUpdater;

    @Nullable
    private final String channelId;

    @StringRes
    private final int channelName;

    private DownloadManager downloadManager;

    private DownloadManagerListener downloadManagerListener;

    private int lastStartId;

    private boolean startedInForeground;

    private boolean taskRemoved;

    /**
     * Creates a DownloadService.
     *
     * <p>If {@code foregroundNotificationId} is {@link #FOREGROUND_NOTIFICATION_ID_NONE} (value
     * {@value #FOREGROUND_NOTIFICATION_ID_NONE}) then the service runs in the background. No
     * foreground notification is displayed and {@link #getScheduler()} isn't called.
     *
     * <p>If {@code foregroundNotificationId} isn't {@link #FOREGROUND_NOTIFICATION_ID_NONE} (value
     * {@value #FOREGROUND_NOTIFICATION_ID_NONE}) the service runs in the foreground with {@link
     * #DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL}. In that case {@link
     * #getForegroundNotification(TaskState[])} should be overridden in the subclreplaced.
     *
     * @param foregroundNotificationId The notification id for the foreground notification, or {@link
     *     #FOREGROUND_NOTIFICATION_ID_NONE} (value {@value #FOREGROUND_NOTIFICATION_ID_NONE})
     */
    protected DownloadService(int foregroundNotificationId) {
        this(foregroundNotificationId, DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL);
    }

    /**
     * Creates a DownloadService which will run in the foreground. {@link
     * #getForegroundNotification(TaskState[])} should be overridden in the subclreplaced.
     *
     * @param foregroundNotificationId The notification id for the foreground notification, must not
     *     be 0.
     * @param foregroundNotificationUpdateInterval The maximum interval to update foreground
     *     notification, in milliseconds.
     */
    protected DownloadService(int foregroundNotificationId, long foregroundNotificationUpdateInterval) {
        this(foregroundNotificationId, foregroundNotificationUpdateInterval, /* channelId= */
        null, /* channelName= */
        0);
    }

    /**
     * Creates a DownloadService which will run in the foreground. {@link
     * #getForegroundNotification(TaskState[])} should be overridden in the subclreplaced.
     *
     * @param foregroundNotificationId The notification id for the foreground notification. Must not
     *     be 0.
     * @param foregroundNotificationUpdateInterval The maximum interval between updates to the
     *     foreground notification, in milliseconds.
     * @param channelId An id for a low priority notification channel to create, or {@code null} if
     *     the app will take care of creating a notification channel if needed. If specified, must be
     *     unique per package and the value may be truncated if it is too long.
     * @param channelName A string resource identifier for the user visible name of the channel, if
     *     {@code channelId} is specified. The recommended maximum length is 40 characters; the value
     *     may be truncated if it is too long.
     */
    protected DownloadService(int foregroundNotificationId, long foregroundNotificationUpdateInterval, @Nullable String channelId, @StringRes int channelName) {
        foregroundNotificationUpdater = foregroundNotificationId == 0 ? null : new ForegroundNotificationUpdater(foregroundNotificationId, foregroundNotificationUpdateInterval);
        this.channelId = channelId;
        this.channelName = channelName;
    }

    /**
     * Builds an {@link Intent} for adding an action to be executed by the service.
     *
     * @param context A {@link Context}.
     * @param clazz The concrete download service being targeted by the intent.
     * @param downloadAction The action to be executed.
     * @param foreground Whether this intent will be used to start the service in the foreground.
     * @return Created Intent.
     */
    public static Intent buildAddActionIntent(Context context, Clreplaced<? extends DownloadService> clazz, DownloadAction downloadAction, boolean foreground) {
        return getIntent(context, clazz, ACTION_ADD).putExtra(KEY_DOWNLOAD_ACTION, downloadAction.toByteArray()).putExtra(KEY_FOREGROUND, foreground);
    }

    /**
     * Starts the service, adding an action to be executed.
     *
     * @param context A {@link Context}.
     * @param clazz The concrete download service to be started.
     * @param downloadAction The action to be executed.
     * @param foreground Whether the service is started in the foreground.
     */
    public static void startWithAction(Context context, Clreplaced<? extends DownloadService> clazz, DownloadAction downloadAction, boolean foreground) {
        Intent intent = buildAddActionIntent(context, clazz, downloadAction, foreground);
        if (foreground) {
            Util.startForegroundService(context, intent);
        } else {
            context.startService(intent);
        }
    }

    /**
     * Starts the service without adding a new action. If there are any not finished actions and the
     * requirements are met, the service resumes executing actions. Otherwise it stops immediately.
     *
     * @param context A {@link Context}.
     * @param clazz The concrete download service to be started.
     * @see #startForeground(Context, Clreplaced)
     */
    public static void start(Context context, Clreplaced<? extends DownloadService> clazz) {
        context.startService(getIntent(context, clazz, ACTION_INIT));
    }

    /**
     * Starts the service in the foreground without adding a new action. If there are any not finished
     * actions and the requirements are met, the service resumes executing actions. Otherwise it stops
     * immediately.
     *
     * @param context A {@link Context}.
     * @param clazz The concrete download service to be started.
     * @see #start(Context, Clreplaced)
     */
    public static void startForeground(Context context, Clreplaced<? extends DownloadService> clazz) {
        Intent intent = getIntent(context, clazz, ACTION_INIT).putExtra(KEY_FOREGROUND, true);
        Util.startForegroundService(context, intent);
    }

    @Override
    public void onCreate() {
        logd("onCreate");
        if (channelId != null) {
            NotificationUtil.createNotificationChannel(this, channelId, channelName, NotificationUtil.IMPORTANCE_LOW);
        }
        downloadManager = getDownloadManager();
        downloadManagerListener = new DownloadManagerListener();
        downloadManager.addListener(downloadManagerListener);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        lastStartId = startId;
        taskRemoved = false;
        String intentAction = null;
        if (intent != null) {
            intentAction = intent.getAction();
            startedInForeground |= intent.getBooleanExtra(KEY_FOREGROUND, false) || ACTION_RESTART.equals(intentAction);
        }
        // intentAction is null if the service is restarted or no action is specified.
        if (intentAction == null) {
            intentAction = ACTION_INIT;
        }
        logd("onStartCommand action: " + intentAction + " startId: " + startId);
        switch(intentAction) {
            case ACTION_INIT:
            case ACTION_RESTART:
                // Do nothing.
                break;
            case ACTION_ADD:
                byte[] actionData = intent.getByteArrayExtra(KEY_DOWNLOAD_ACTION);
                if (actionData == null) {
                    Log.e(TAG, "Ignoring ADD action with no action data");
                } else {
                    try {
                        downloadManager.handleAction(actionData);
                    } catch (IOException e) {
                        Log.e(TAG, "Failed to handle ADD action", e);
                    }
                }
                break;
            case ACTION_RELOAD_REQUIREMENTS:
                stopWatchingRequirements();
                break;
            default:
                Log.e(TAG, "Ignoring unrecognized action: " + intentAction);
                break;
        }
        Requirements requirements = getRequirements();
        if (requirements.checkRequirements(this)) {
            downloadManager.startDownloads();
        } else {
            downloadManager.stopDownloads();
        }
        maybeStarreplacedchingRequirements(requirements);
        if (downloadManager.isIdle()) {
            stop();
        }
        return START_STICKY;
    }

    @Override
    public void onTaskRemoved(Intent rootIntent) {
        logd("onTaskRemoved rootIntent: " + rootIntent);
        taskRemoved = true;
    }

    @Override
    public void onDestroy() {
        logd("onDestroy");
        if (foregroundNotificationUpdater != null) {
            foregroundNotificationUpdater.stopPeriodicUpdates();
        }
        downloadManager.removeListener(downloadManagerListener);
        maybeStopWatchingRequirements();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    /**
     * Returns a {@link DownloadManager} to be used to downloaded content. Called only once in the
     * life cycle of the service. The service will call {@link DownloadManager#startDownloads()} and
     * {@link DownloadManager#stopDownloads} as necessary when requirements returned by {@link
     * #getRequirements()} are met or stop being met.
     */
    protected abstract DownloadManager getDownloadManager();

    /**
     * Returns a {@link Scheduler} to restart the service when requirements allowing downloads to take
     * place are met. If {@code null}, the service will only be restarted if the process is still in
     * memory when the requirements are met.
     */
    @Nullable
    protected abstract Scheduler getScheduler();

    /**
     * Returns requirements for downloads to take place. By default the only requirement is that the
     * device has network connectivity.
     */
    protected Requirements getRequirements() {
        return DEFAULT_REQUIREMENTS;
    }

    /**
     * Should be overridden in the subclreplaced if the service will be run in the foreground.
     *
     * <p>Returns a notification to be displayed when this service running in the foreground.
     *
     * <p>This method is called when there is a task state change and periodically while there are
     * active tasks. The periodic update interval can be set using {@link #DownloadService(int,
     * long)}.
     *
     * <p>On API level 26 and above, this method may also be called just before the service stops,
     * with an empty {@code taskStates} array. The returned notification is used to satisfy system
     * requirements for foreground services.
     *
     * @param taskStates The states of all current tasks.
     * @return The foreground notification to display.
     */
    protected Notification getForegroundNotification(TaskState[] taskStates) {
        throw new IllegalStateException(getClreplaced().getName() + " is started in the foreground but getForegroundNotification() is not implemented.");
    }

    /**
     * Called when the state of a task changes.
     *
     * @param taskState The state of the task.
     */
    protected void onTaskStateChanged(TaskState taskState) {
    // Do nothing.
    }

    private void maybeStarreplacedchingRequirements(Requirements requirements) {
        if (downloadManager.getDownloadCount() == 0) {
            return;
        }
        Clreplaced<? extends DownloadService> clazz = getClreplaced();
        RequirementsHelper requirementsHelper = requirementsHelpers.get(clazz);
        if (requirementsHelper == null) {
            requirementsHelper = new RequirementsHelper(this, requirements, getScheduler(), clazz);
            requirementsHelpers.put(clazz, requirementsHelper);
            requirementsHelper.start();
            logd("started watching requirements");
        }
    }

    private void maybeStopWatchingRequirements() {
        if (downloadManager.getDownloadCount() > 0) {
            return;
        }
        stopWatchingRequirements();
    }

    private void stopWatchingRequirements() {
        RequirementsHelper requirementsHelper = requirementsHelpers.remove(getClreplaced());
        if (requirementsHelper != null) {
            requirementsHelper.stop();
            logd("stopped watching requirements");
        }
    }

    private void stop() {
        if (foregroundNotificationUpdater != null) {
            foregroundNotificationUpdater.stopPeriodicUpdates();
            // Make sure startForeground is called before stopping. Workaround for [Internal: b/69424260].
            if (startedInForeground && Util.SDK_INT >= 26) {
                foregroundNotificationUpdater.showNotificationIfNotAlready();
            }
        }
        if (Util.SDK_INT < 28 && taskRemoved) {
            // See [Internal: b/74248644].
            stopSelf();
            logd("stopSelf()");
        } else {
            boolean stopSelfResult = stopSelfResult(lastStartId);
            logd("stopSelf(" + lastStartId + ") result: " + stopSelfResult);
        }
    }

    private void logd(String message) {
        if (DEBUG) {
            Log.d(TAG, message);
        }
    }

    private static Intent getIntent(Context context, Clreplaced<? extends DownloadService> clazz, String action) {
        return new Intent(context, clazz).setAction(action);
    }

    private final clreplaced DownloadManagerListener implements DownloadManager.Listener {

        @Override
        public void onInitialized(DownloadManager downloadManager) {
            maybeStarreplacedchingRequirements(getRequirements());
        }

        @Override
        public void onTaskStateChanged(DownloadManager downloadManager, TaskState taskState) {
            DownloadService.this.onTaskStateChanged(taskState);
            if (foregroundNotificationUpdater != null) {
                if (taskState.state == TaskState.STATE_STARTED) {
                    foregroundNotificationUpdater.startPeriodicUpdates();
                } else {
                    foregroundNotificationUpdater.update();
                }
            }
        }

        @Override
        public final void onIdle(DownloadManager downloadManager) {
            stop();
        }
    }

    private final clreplaced ForegroundNotificationUpdater implements Runnable {

        private final int notificationId;

        private final long updateInterval;

        private final Handler handler;

        private boolean periodicUpdatesStarted;

        private boolean notificationDisplayed;

        public ForegroundNotificationUpdater(int notificationId, long updateInterval) {
            this.notificationId = notificationId;
            this.updateInterval = updateInterval;
            this.handler = new Handler(Looper.getMainLooper());
        }

        public void startPeriodicUpdates() {
            periodicUpdatesStarted = true;
            update();
        }

        public void stopPeriodicUpdates() {
            periodicUpdatesStarted = false;
            handler.removeCallbacks(this);
        }

        public void update() {
            TaskState[] taskStates = downloadManager.getAllTaskStates();
            startForeground(notificationId, getForegroundNotification(taskStates));
            notificationDisplayed = true;
            if (periodicUpdatesStarted) {
                handler.removeCallbacks(this);
                handler.postDelayed(this, updateInterval);
            }
        }

        public void showNotificationIfNotAlready() {
            if (!notificationDisplayed) {
                update();
            }
        }

        @Override
        public void run() {
            update();
        }
    }

    private static final clreplaced RequirementsHelper implements RequirementsWatcher.Listener {

        private final Context context;

        private final Requirements requirements;

        @Nullable
        private final Scheduler scheduler;

        private final Clreplaced<? extends DownloadService> serviceClreplaced;

        private final RequirementsWatcher requirementsWatcher;

        private RequirementsHelper(Context context, Requirements requirements, @Nullable Scheduler scheduler, Clreplaced<? extends DownloadService> serviceClreplaced) {
            this.context = context;
            this.requirements = requirements;
            this.scheduler = scheduler;
            this.serviceClreplaced = serviceClreplaced;
            requirementsWatcher = new RequirementsWatcher(context, this, requirements);
        }

        public void start() {
            requirementsWatcher.start();
        }

        public void stop() {
            requirementsWatcher.stop();
            if (scheduler != null) {
                scheduler.cancel();
            }
        }

        @Override
        public void requirementsMet(RequirementsWatcher requirementsWatcher) {
            try {
                notifyService();
            } catch (Exception e) {
                /* If we can't notify the service, don't stop the scheduler. */
                return;
            }
            if (scheduler != null) {
                scheduler.cancel();
            }
        }

        @Override
        public void requirementsNotMet(RequirementsWatcher requirementsWatcher) {
            try {
                notifyService();
            } catch (Exception e) {
            /* Do nothing. The service isn't running anyway. */
            }
            if (scheduler != null) {
                String servicePackage = context.getPackageName();
                boolean success = scheduler.schedule(requirements, servicePackage, ACTION_RESTART);
                if (!success) {
                    Log.e(TAG, "Scheduling downloads failed.");
                }
            }
        }

        private void notifyService() throws Exception {
            Intent intent = getIntent(context, serviceClreplaced, DownloadService.ACTION_INIT);
            try {
                context.startService(intent);
            } catch (IllegalStateException e) {
                /* startService will fail if the app is in the background and the service isn't running. */
                throw new Exception(e);
            }
        }
    }
}

19 Source : WriteOrEmulateCardDataOperation.java
with GNU General Public License v3.0
from TeamWalrus

@Override
@StringRes
public int getWaitingStringId() {
    return write ? R.string.writing_card : R.string.emulating_card;
}

19 Source : WriteOrEmulateCardDataOperation.java
with GNU General Public License v3.0
from TeamWalrus

@Override
@StringRes
public int getStopStringId() {
    return write ? R.string.cancel_button : R.string.stop_button;
}

19 Source : WriteOrEmulateCardDataOperation.java
with GNU General Public License v3.0
from TeamWalrus

@Override
@StringRes
public int getErrorStringId() {
    return write ? R.string.failed_to_write : R.string.failed_to_emulate;
}

19 Source : ReadCardDataOperation.java
with GNU General Public License v3.0
from TeamWalrus

@Override
@StringRes
public int getErrorStringId() {
    return R.string.failed_to_read;
}

19 Source : ReadCardDataOperation.java
with GNU General Public License v3.0
from TeamWalrus

@Override
@StringRes
public int getWaitingStringId() {
    return R.string.waiting_for_card;
}

19 Source : CardDataIOOperation.java
with GNU General Public License v3.0
from TeamWalrus

@StringRes
public int getWaitingStringId() {
    return R.string.performing_operation;
}

19 Source : CardDataIOOperation.java
with GNU General Public License v3.0
from TeamWalrus

@StringRes
public int getErrorStringId() {
    return R.string.failed_to_perform_operation;
}

19 Source : CardDataIOOperation.java
with GNU General Public License v3.0
from TeamWalrus

@StringRes
public int getStopStringId() {
    return R.string.cancel_button;
}

19 Source : CalculatedElement.java
with GNU General Public License v3.0
from TeamWalrus

abstract clreplaced CalculatedElement extends BinaryFormat.Element {

    @StringRes
    private final int errorMessageId;

    public CalculatedElement(String id, String name, int startPos, Integer length, @StringRes int errorMessageId) {
        super(id, name, startPos, length);
        this.errorMessageId = errorMessageId;
    }

    @Override
    public Set<String> getProblems(BigInteger source) {
        Set<String> problems = new HashSet<>();
        if (!extractValueAtMyPos(source).equals(extractValue(source))) {
            problems.add(WalrusApplication.getContext().getString(errorMessageId));
        }
        return problems;
    }

    @Override
    public Component createComponent(final Context context, final BigInteger value, final boolean editable) {
        return new Component(context, name) {

            @Override
            public Set<String> getProblems() {
                return !editable ? CalculatedElement.this.getProblems(value) : new HashSet<String>();
            }
        };
    }

    @Override
    public BigInteger applyComponent(BigInteger value, Component component) {
        return applyAtMyPos(value, extractValue(value));
    }
}

19 Source : Setting.java
with Apache License 2.0
from t28hub

@StringRes
public int name() {
    return name;
}

19 Source : KeepActivitiesToggle.java
with Apache License 2.0
from Stocard

@StringRes
static int getLabel(boolean keepActivities) {
    if (keepActivities) {
        return R.string.keep_activities_yes;
    } else {
        return R.string.keep_activities_no;
    }
}

19 Source : ActivityLifeCycleDashboardFragment.java
with Apache License 2.0
from starscryer

@StringRes
public int getPagereplacedle() {
    return 0;
}

19 Source : DozeEventHistoryViewerActivity.java
with Apache License 2.0
from starscryer

@StringRes
private int failCodeToStringRes(int code) {
    switch(code) {
        case DozeEvent.FAIL_DEVICE_INTERACTIVE:
            return R.string.replacedle_doze_fail_device_interactive;
        case DozeEvent.FAIL_POWER_CHARGING:
            return R.string.replacedle_doze_fail_device_charging;
        case DozeEvent.FAIL_RETRY_TIMEOUT:
            return R.string.replacedle_doze_fail_device_max;
        case DozeEvent.FAIL_GENERIC_FAILURE:
            return R.string.replacedle_doze_fail_generic_failure;
        case DozeEvent.FAIL_UNKNOWN:
            return R.string.replacedle_doze_res_unknown;
    }
    return R.string.replacedle_doze_res_unknown;
}

19 Source : DozeEventHistoryViewerActivity.java
with Apache License 2.0
from starscryer

@StringRes
private int resultToStringRes(int res) {
    switch(res) {
        case DozeEvent.RESULT_FAIL:
            return R.string.replacedle_doze_res_fail;
        case DozeEvent.RESULT_SUCCESS:
            return R.string.replacedle_doze_res_success;
        case DozeEvent.RESULT_UNKNOWN:
            return R.string.replacedle_doze_res_unknown;
        case DozeEvent.RESULT_PENDING:
            return R.string.replacedle_doze_res_pending;
    }
    return R.string.replacedle_doze_res_unknown;
}

19 Source : FancyWalkthroughFragment.java
with Apache License 2.0
from Shashank02051997

public clreplaced FancyWalkthroughFragment extends Fragment {

    private static final String FANCY_PAGE_replacedLE = "ahoy_page_replacedle";

    private static final String FANCY_PAGE_replacedLE_RES_ID = "ahoy_page_replacedle_res_id";

    private static final String FANCY_PAGE_replacedLE_COLOR = "ahoy_page_replacedle_color";

    private static final String FANCY_PAGE_replacedLE_TEXT_SIZE = "ahoy_page_replacedle_text_size";

    private static final String FANCY_PAGE_DESCRIPTION = "ahoy_page_description";

    private static final String FANCY_PAGE_DESCRIPTION_RES_ID = "ahoy_page_description_res_id";

    private static final String FANCY_PAGE_DESCRIPTION_COLOR = "ahoy_page_description_color";

    private static final String FANCY_PAGE_DESCRIPTION_TEXT_SIZE = "ahoy_page_description_text_size";

    private static final String FANCY_PAGE_IMAGE_RES_ID = "ahoy_page_image_res_id";

    private static final String FANCY_PAGE_BACKGROUND_COLOR = "ahoy_page_background_color";

    private static final String FANCY_PAGE_ICON_WIDTH = "ahoy_page_icon_width";

    private static final String FANCY_PAGE_ICON_HEIGHT = "ahoy_page_icon_height";

    private static final String FANCY_PAGE_MARGIN_LEFT = "ahoy_page_margin_left";

    private static final String FANCY_PAGE_MARGIN_RIGHT = "ahoy_page_margin_right";

    private static final String FANCY_PAGE_MARGIN_TOP = "ahoy_page_margin_top";

    private static final String FANCY_PAGE_MARGIN_BOTTOM = "ahoy_page_margin_bottom";

    private String replacedle;

    private String description;

    @StringRes
    private int replacedleResId;

    @ColorRes
    private int replacedleColor;

    @StringRes
    private int descriptionResId;

    @ColorRes
    private int backgroundColor;

    @ColorRes
    private int descriptionColor;

    private int imageResId;

    private float replacedleTextSize;

    private float descriptionTextSize;

    private View view, view1;

    private ImageView ivOnboarderImage;

    private TextView tvOnboarderreplacedle;

    private TextView tvOnboarderDescription;

    private CardView cardView;

    private int iconHeight, iconWidth;

    private int marginTop, marginBottom, marginLeft, marginRight;

    public FancyWalkthroughFragment() {
    }

    public static FancyWalkthroughFragment newInstance(FancyWalkthroughCard card) {
        Bundle args = new Bundle();
        args.putString(FANCY_PAGE_replacedLE, card.getreplacedle());
        args.putString(FANCY_PAGE_DESCRIPTION, card.getDescription());
        args.putInt(FANCY_PAGE_replacedLE_RES_ID, card.getreplacedleResourceId());
        args.putInt(FANCY_PAGE_DESCRIPTION_RES_ID, card.getDescriptionResourceId());
        args.putInt(FANCY_PAGE_replacedLE_COLOR, card.getreplacedleColor());
        args.putInt(FANCY_PAGE_DESCRIPTION_COLOR, card.getDescriptionColor());
        args.putInt(FANCY_PAGE_IMAGE_RES_ID, card.getImageResourceId());
        args.putFloat(FANCY_PAGE_replacedLE_TEXT_SIZE, card.getreplacedleTextSize());
        args.putFloat(FANCY_PAGE_DESCRIPTION_TEXT_SIZE, card.getDescriptionTextSize());
        args.putInt(FANCY_PAGE_BACKGROUND_COLOR, card.getBackgroundColor());
        args.putInt(FANCY_PAGE_ICON_HEIGHT, card.getIconHeight());
        args.putInt(FANCY_PAGE_ICON_WIDTH, card.getIconWidth());
        args.putInt(FANCY_PAGE_MARGIN_LEFT, card.getMarginLeft());
        args.putInt(FANCY_PAGE_MARGIN_RIGHT, card.getMarginRight());
        args.putInt(FANCY_PAGE_MARGIN_TOP, card.getMarginTop());
        args.putInt(FANCY_PAGE_MARGIN_BOTTOM, card.getMarginBottom());
        FancyWalkthroughFragment fragment = new FancyWalkthroughFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        replacedle = bundle.getString(FANCY_PAGE_replacedLE, null);
        replacedleResId = bundle.getInt(FANCY_PAGE_replacedLE_RES_ID, 0);
        replacedleColor = bundle.getInt(FANCY_PAGE_replacedLE_COLOR, 0);
        replacedleTextSize = bundle.getFloat(FANCY_PAGE_replacedLE_TEXT_SIZE, 0f);
        description = bundle.getString(FANCY_PAGE_DESCRIPTION, null);
        descriptionResId = bundle.getInt(FANCY_PAGE_DESCRIPTION_RES_ID, 0);
        descriptionColor = bundle.getInt(FANCY_PAGE_DESCRIPTION_COLOR, 0);
        descriptionTextSize = bundle.getFloat(FANCY_PAGE_DESCRIPTION_TEXT_SIZE, 0f);
        imageResId = bundle.getInt(FANCY_PAGE_IMAGE_RES_ID, 0);
        backgroundColor = bundle.getInt(FANCY_PAGE_BACKGROUND_COLOR, 0);
        iconWidth = bundle.getInt(FANCY_PAGE_ICON_WIDTH, (int) dpToPixels(128, getActivity()));
        iconHeight = bundle.getInt(FANCY_PAGE_ICON_HEIGHT, (int) dpToPixels(128, getActivity()));
        marginTop = bundle.getInt(FANCY_PAGE_MARGIN_TOP, (int) dpToPixels(80, getActivity()));
        marginBottom = bundle.getInt(FANCY_PAGE_MARGIN_BOTTOM, (int) dpToPixels(0, getActivity()));
        marginLeft = bundle.getInt(FANCY_PAGE_MARGIN_LEFT, (int) dpToPixels(0, getActivity()));
        marginRight = bundle.getInt(FANCY_PAGE_MARGIN_RIGHT, (int) dpToPixels(0, getActivity()));
        view = inflater.inflate(R.layout.fragment_ahoy, container, false);
        ivOnboarderImage = (ImageView) view.findViewById(R.id.iv_image);
        tvOnboarderreplacedle = (TextView) view.findViewById(R.id.tv_replacedle);
        tvOnboarderDescription = (TextView) view.findViewById(R.id.tv_description);
        cardView = (CardView) view.findViewById(R.id.cv_cardview);
        view1 = (View) view.findViewById(R.id.view1);
        if (replacedle != null) {
            tvOnboarderreplacedle.setText(replacedle);
        }
        if (replacedleResId != 0) {
            tvOnboarderreplacedle.setText(getResources().getString(replacedleResId));
        }
        if (description != null) {
            tvOnboarderDescription.setText(description);
        }
        if (descriptionResId != 0) {
            tvOnboarderDescription.setText(getResources().getString(descriptionResId));
        }
        if (replacedleColor != 0) {
            tvOnboarderreplacedle.setTextColor(ContextCompat.getColor(getActivity(), replacedleColor));
        }
        if (descriptionColor != 0) {
            tvOnboarderDescription.setTextColor(ContextCompat.getColor(getActivity(), descriptionColor));
        }
        if (imageResId != 0) {
            ivOnboarderImage.setImageDrawable(ContextCompat.getDrawable(getActivity(), imageResId));
        }
        if (replacedleTextSize != 0f) {
            tvOnboarderreplacedle.setTextSize(replacedleTextSize);
        }
        if (descriptionTextSize != 0f) {
            tvOnboarderDescription.setTextSize(descriptionTextSize);
        }
        if (backgroundColor != 0) {
            cardView.setCardBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorTransparent));
            GradientDrawable bgShape = (GradientDrawable) view1.getBackground();
            bgShape.setColor(ContextCompat.getColor(getActivity(), backgroundColor));
        }
        if (iconWidth != 0 && iconHeight != 0) {
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(iconWidth, iconHeight);
            layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
            layoutParams.setMargins(marginLeft, marginTop, marginRight, marginBottom);
            ivOnboarderImage.setLayoutParams(layoutParams);
        }
        return view;
    }

    public float dpToPixels(int dp, Context context) {
        return dp * (context.getResources().getDisplayMetrics().density);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    public CardView getCardView() {
        return cardView;
    }

    public TextView getreplacedleView() {
        return tvOnboarderreplacedle;
    }

    public TextView getDescriptionView() {
        return tvOnboarderDescription;
    }
}

19 Source : FancyWalkthroughCard.java
with Apache License 2.0
from Shashank02051997

public clreplaced FancyWalkthroughCard {

    public String replacedle;

    public String description;

    public Drawable imageResource;

    @StringRes
    public int replacedleResourceId;

    @StringRes
    public int descriptionResourceId;

    @DrawableRes
    public int imageResourceId;

    @ColorRes
    public int replacedleColor;

    @ColorRes
    public int descriptionColor;

    @ColorRes
    public int backgroundColor;

    public float replacedleTextSize;

    public float descriptionTextSize;

    public int iconWidth, iconHeight, marginTop, marginLeft, marginRight, marginBottom;

    public FancyWalkthroughCard(String replacedle, String description) {
        this.replacedle = replacedle;
        this.description = description;
    }

    public FancyWalkthroughCard(int replacedle, int description) {
        this.replacedleResourceId = replacedle;
        this.descriptionResourceId = description;
    }

    public FancyWalkthroughCard(String replacedle, String description, int imageResourceId) {
        this.replacedle = replacedle;
        this.description = description;
        this.imageResourceId = imageResourceId;
    }

    public FancyWalkthroughCard(String replacedle, String description, Drawable imageResource) {
        this.replacedle = replacedle;
        this.description = description;
        this.imageResource = imageResource;
    }

    public FancyWalkthroughCard(int replacedle, int description, int imageResourceId) {
        this.replacedleResourceId = replacedle;
        this.descriptionResourceId = description;
        this.imageResourceId = imageResourceId;
    }

    public FancyWalkthroughCard(int replacedle, int description, Drawable imageResource) {
        this.replacedleResourceId = replacedle;
        this.descriptionResourceId = description;
        this.imageResource = imageResource;
    }

    public String getreplacedle() {
        return replacedle;
    }

    public int getreplacedleResourceId() {
        return replacedleResourceId;
    }

    public String getDescription() {
        return description;
    }

    public int getDescriptionResourceId() {
        return descriptionResourceId;
    }

    public int getreplacedleColor() {
        return replacedleColor;
    }

    public int getDescriptionColor() {
        return descriptionColor;
    }

    public void setreplacedleColor(int color) {
        this.replacedleColor = color;
    }

    public void setDescriptionColor(int color) {
        this.descriptionColor = color;
    }

    public void setImageResourceId(int imageResourceId) {
        this.imageResourceId = imageResourceId;
    }

    public int getImageResourceId() {
        return imageResourceId;
    }

    public float getreplacedleTextSize() {
        return replacedleTextSize;
    }

    public void setreplacedleTextSize(float replacedleTextSize) {
        this.replacedleTextSize = replacedleTextSize;
    }

    public float getDescriptionTextSize() {
        return descriptionTextSize;
    }

    public void setDescriptionTextSize(float descriptionTextSize) {
        this.descriptionTextSize = descriptionTextSize;
    }

    public int getBackgroundColor() {
        return backgroundColor;
    }

    public void setBackgroundColor(int backgroundColor) {
        this.backgroundColor = backgroundColor;
    }

    public int getIconWidth() {
        return iconWidth;
    }

    public void setIconLayoutParams(int iconWidth, int iconHeight, int marginTop, int marginLeft, int marginRight, int marginBottom) {
        this.iconWidth = iconWidth;
        this.iconHeight = iconHeight;
        this.marginLeft = marginLeft;
        this.marginRight = marginRight;
        this.marginTop = marginTop;
        this.marginBottom = marginBottom;
    }

    public int getIconHeight() {
        return iconHeight;
    }

    public int getMarginTop() {
        return marginTop;
    }

    public int getMarginLeft() {
        return marginLeft;
    }

    public int getMarginRight() {
        return marginRight;
    }

    public int getMarginBottom() {
        return marginBottom;
    }
}

19 Source : SubmissionSwipeActionsProvider.java
with Apache License 2.0
from saket

/**
 * Controls gesture actions on submissions.
 */
public clreplaced SubmissionSwipeActionsProvider implements SwipeableLayout.SwipeActionIconProvider {

    @StringRes
    private static final int ACTION_NAME_OPTIONS = R.string.subreddit_submission_swipe_action_options;

    @StringRes
    private static final int ACTION_NAME_NEW_TAB = R.string.subreddit_submission_swipe_action_new_tab;

    @StringRes
    private static final int ACTION_NAME_SAVE = R.string.subreddit_submission_swipe_action_save;

    @StringRes
    private static final int ACTION_NAME_UNSAVE = R.string.subreddit_submission_swipe_action_unsave;

    @StringRes
    private static final int ACTION_NAME_UPVOTE = R.string.subreddit_submission_swipe_action_upvote;

    @StringRes
    private static final int ACTION_NAME_DOWNVOTE = R.string.subreddit_submission_swipe_action_downvote;

    private final Lazy<VotingManager> votingManager;

    private final Lazy<BookmarksRepository> bookmarksRepository;

    private final Lazy<UserSessionRepository> userSessionRepository;

    private final Lazy<OnLoginRequireListener> onLoginRequireListener;

    private final SwipeActions swipeActionsWithUnSave;

    private final SwipeActions swipeActionsWithSave;

    public final PublishRelay<SwipeEvent> swipeEvents = PublishRelay.create();

    @Inject
    public SubmissionSwipeActionsProvider(Lazy<VotingManager> votingManager, Lazy<BookmarksRepository> bookmarksRepository, Lazy<UserSessionRepository> userSessionRepository, Lazy<OnLoginRequireListener> onLoginRequireListener) {
        this.votingManager = votingManager;
        this.bookmarksRepository = bookmarksRepository;
        this.userSessionRepository = userSessionRepository;
        this.onLoginRequireListener = onLoginRequireListener;
        SwipeAction moreOptionsSwipeAction = SwipeAction.create(ACTION_NAME_OPTIONS, R.color.list_item_swipe_more_options, 0.5f);
        // SwipeAction newTabSwipeAction = SwipeAction.create(ACTION_NAME_NEW_TAB, R.color.list_item_swipe_new_tab, 0.5f);
        SwipeAction saveSwipeAction = SwipeAction.create(ACTION_NAME_SAVE, R.color.list_item_swipe_save, 0.5f);
        SwipeAction unSaveSwipeAction = SwipeAction.create(ACTION_NAME_UNSAVE, R.color.list_item_swipe_save, 0.5f);
        SwipeAction downvoteSwipeAction = SwipeAction.create(ACTION_NAME_DOWNVOTE, R.color.list_item_swipe_downvote, 0.4f);
        SwipeAction upvoteSwipeAction = SwipeAction.create(ACTION_NAME_UPVOTE, R.color.list_item_swipe_upvote, 0.6f);
        // Actions on both sides are aligned from left to right.
        SwipeActionsHolder endActions = SwipeActionsHolder.builder().add(upvoteSwipeAction).add(downvoteSwipeAction).build();
        swipeActionsWithUnSave = SwipeActions.builder().startActions(SwipeActionsHolder.builder().add(moreOptionsSwipeAction).add(unSaveSwipeAction).build()).endActions(endActions).build();
        swipeActionsWithSave = SwipeActions.builder().startActions(SwipeActionsHolder.builder().add(moreOptionsSwipeAction).add(saveSwipeAction).build()).endActions(endActions).build();
    }

    public SwipeActions actionsFor(Submission submission) {
        boolean isSubmissionSaved = bookmarksRepository.get().isSaved(submission);
        return isSubmissionSaved ? swipeActionsWithUnSave : swipeActionsWithSave;
    }

    public SwipeActions actionsWithSave() {
        return swipeActionsWithSave;
    }

    @Override
    public void showSwipeActionIcon(SwipeActionIconView imageView, @Nullable SwipeAction oldAction, SwipeAction newAction) {
        switch(newAction.labelRes()) {
            case ACTION_NAME_OPTIONS:
                resetIconRotation(imageView);
                imageView.setImageResource(R.drawable.ic_more_horiz_24dp);
                break;
            case ACTION_NAME_NEW_TAB:
                resetIconRotation(imageView);
                imageView.setImageResource(R.drawable.ic_open_in_new_tab_24dp);
                break;
            case ACTION_NAME_SAVE:
                resetIconRotation(imageView);
                imageView.setImageResource(R.drawable.ic_save_24dp);
                break;
            case ACTION_NAME_UNSAVE:
                resetIconRotation(imageView);
                imageView.setImageResource(R.drawable.ic_unsave_24dp);
                break;
            case ACTION_NAME_UPVOTE:
                if (oldAction != null && ACTION_NAME_DOWNVOTE == oldAction.labelRes()) {
                    // We want to play a circular animation if the user keeps switching between upvote and downvote.
                    imageView.setRotation(180);
                    imageView.animate().rotationBy(180).setInterpolator(Animations.INTERPOLATOR).setDuration(200).start();
                } else {
                    resetIconRotation(imageView);
                    imageView.setImageResource(R.drawable.ic_arrow_upward_24dp);
                }
                break;
            case ACTION_NAME_DOWNVOTE:
                if (oldAction != null && ACTION_NAME_UPVOTE == oldAction.labelRes()) {
                    imageView.setRotation(0);
                    imageView.animate().rotationBy(180).setInterpolator(Animations.INTERPOLATOR).setDuration(200).start();
                } else {
                    resetIconRotation(imageView);
                    imageView.setImageResource(R.drawable.ic_arrow_downward_24dp);
                }
                break;
            default:
                throw new UnsupportedOperationException("Unknown swipe action: " + newAction);
        }
    }

    public void performSwipeAction(SwipeAction swipeAction, Submission submission, SwipeableLayout swipeableLayout) {
        if (needsLogin(swipeAction, submission)) {
            // Delay because showing LoginActivity for the first time stutters SwipeableLayout's reset animation.
            swipeableLayout.postDelayed(() -> onLoginRequireListener.get().onLoginRequired(), SwipeableLayout.ANIMATION_DURATION_FOR_SETTLING_BACK_TO_POSITION);
            return;
        }
        boolean isUndoAction;
        switch(swipeAction.labelRes()) {
            case ACTION_NAME_OPTIONS:
                swipeEvents.accept(SubmissionOptionSwipeEvent.create(submission, swipeableLayout));
                isUndoAction = false;
                break;
            case ACTION_NAME_NEW_TAB:
                swipeEvents.accept(SubmissionOpenInNewTabSwipeEvent.create(submission, swipeableLayout));
                isUndoAction = false;
                break;
            case ACTION_NAME_SAVE:
                bookmarksRepository.get().markreplacedaved(submission);
                isUndoAction = false;
                break;
            case ACTION_NAME_UNSAVE:
                bookmarksRepository.get().markAsUnsaved(submission);
                isUndoAction = true;
                break;
            case ACTION_NAME_UPVOTE:
                {
                    VoteDirection currentVoteDirection = votingManager.get().getPendingOrDefaultVote(submission, submission.getVote());
                    VoteDirection newVoteDirection = currentVoteDirection == VoteDirection.UP ? VoteDirection.NONE : VoteDirection.UP;
                    swipeEvents.accept(ContributionVoteSwipeEvent.create(submission, newVoteDirection));
                    isUndoAction = newVoteDirection == VoteDirection.NONE;
                    break;
                }
            case ACTION_NAME_DOWNVOTE:
                {
                    VoteDirection currentVoteDirection = votingManager.get().getPendingOrDefaultVote(submission, submission.getVote());
                    VoteDirection newVoteDirection = currentVoteDirection == VoteDirection.DOWN ? VoteDirection.NONE : VoteDirection.DOWN;
                    swipeEvents.accept(ContributionVoteSwipeEvent.create(submission, newVoteDirection));
                    isUndoAction = newVoteDirection == VoteDirection.NONE;
                    break;
                }
            default:
                throw new UnsupportedOperationException("Unknown swipe action: " + swipeAction);
        }
        swipeableLayout.playRippleAnimation(swipeAction, isUndoAction ? RippleType.UNDO : RippleType.REGISTER);
    }

    private boolean needsLogin(SwipeAction swipeAction, Submission submission) {
        if (SyntheticData.Companion.isSynthetic(submission)) {
            return false;
        }
        switch(swipeAction.labelRes()) {
            case ACTION_NAME_OPTIONS:
            case ACTION_NAME_NEW_TAB:
                return false;
            case ACTION_NAME_SAVE:
            case ACTION_NAME_UNSAVE:
            case ACTION_NAME_UPVOTE:
            case ACTION_NAME_DOWNVOTE:
                return !userSessionRepository.get().isUserLoggedIn();
            default:
                throw new UnsupportedOperationException("Unknown swipe action: " + swipeAction);
        }
    }

    private void resetIconRotation(SwipeActionIconView imageView) {
        imageView.animate().cancel();
        imageView.setRotation(0);
    }
}

19 Source : CommentSwipeActionsProvider.java
with Apache License 2.0
from saket

/**
 * Controls gesture actions on comments and submission details.
 */
public clreplaced CommentSwipeActionsProvider {

    @StringRes
    private static final int ACTION_NAME_REPLY = R.string.submission_comment_swipe_action_reply;

    @StringRes
    private static final int ACTION_NAME_OPTIONS = R.string.submission_comment_swipe_action_options;

    @StringRes
    private static final int ACTION_NAME_UPVOTE = R.string.submission_comment_swipe_action_upvote;

    @StringRes
    private static final int ACTION_NAME_DOWNVOTE = R.string.submission_comment_swipe_action_downvote;

    private final Lazy<VotingManager> votingManager;

    private final Lazy<UserSessionRepository> userSessionRepository;

    private final Lazy<OnLoginRequireListener> onLoginRequireListener;

    private final SwipeActions commentSwipeActions;

    private final SwipeActionIconProvider swipeActionIconProvider;

    public final PublishRelay<SwipeEvent> swipeEvents = PublishRelay.create();

    @Inject
    public CommentSwipeActionsProvider(Lazy<VotingManager> votingManager, Lazy<UserSessionRepository> userSessionRepository, Lazy<OnLoginRequireListener> loginRequireListener) {
        this.votingManager = votingManager;
        this.userSessionRepository = userSessionRepository;
        this.onLoginRequireListener = loginRequireListener;
        // Actions on both sides are aligned from left to right.
        commentSwipeActions = SwipeActions.builder().startActions(SwipeActionsHolder.builder().add(SwipeAction.create(ACTION_NAME_REPLY, R.color.list_item_swipe_reply, 0.5f)).add(SwipeAction.create(ACTION_NAME_OPTIONS, R.color.list_item_swipe_more_options, 0.5f)).build()).endActions(SwipeActionsHolder.builder().add(SwipeAction.create(ACTION_NAME_UPVOTE, R.color.list_item_swipe_upvote, 0.4f)).add(SwipeAction.create(ACTION_NAME_DOWNVOTE, R.color.list_item_swipe_downvote, 0.6f)).build()).build();
        swipeActionIconProvider = createActionIconProvider();
    }

    public SwipeActions actions() {
        return commentSwipeActions;
    }

    public SwipeActionIconProvider iconProvider() {
        return swipeActionIconProvider;
    }

    public SwipeActionIconProvider createActionIconProvider() {
        return (imageView, oldAction, newAction) -> {
            switch(newAction.labelRes()) {
                case ACTION_NAME_OPTIONS:
                    resetIconRotation(imageView);
                    imageView.setImageResource(R.drawable.ic_more_horiz_24dp);
                    break;
                case ACTION_NAME_REPLY:
                    resetIconRotation(imageView);
                    imageView.setImageResource(R.drawable.ic_reply_24dp);
                    break;
                case ACTION_NAME_UPVOTE:
                    if (oldAction != null && ACTION_NAME_DOWNVOTE == oldAction.labelRes()) {
                        imageView.setRotation(180);
                        imageView.animate().rotationBy(180).setInterpolator(Animations.INTERPOLATOR).setDuration(200).start();
                    } else {
                        resetIconRotation(imageView);
                        imageView.setImageResource(R.drawable.ic_arrow_upward_24dp);
                    }
                    break;
                case ACTION_NAME_DOWNVOTE:
                    if (oldAction != null && ACTION_NAME_UPVOTE == oldAction.labelRes()) {
                        imageView.setRotation(0);
                        imageView.animate().rotationBy(180).setInterpolator(Animations.INTERPOLATOR).setDuration(200).start();
                    } else {
                        resetIconRotation(imageView);
                        imageView.setImageResource(R.drawable.ic_arrow_downward_24dp);
                    }
                    break;
                default:
                    throw new UnsupportedOperationException("Unknown swipe action: " + newAction);
            }
        };
    }

    private void resetIconRotation(SwipeActionIconView imageView) {
        imageView.animate().cancel();
        imageView.setRotation(0);
    }

    public void performSwipeAction(SwipeAction swipeAction, Comment comment, SwipeableLayout swipeableLayout) {
        if (needsLogin(swipeAction, comment)) {
            // Delay because showing LoginActivity for the first time stutters SwipeableLayout's reset animation.
            swipeableLayout.postDelayed(() -> onLoginRequireListener.get().onLoginRequired(), SwipeableLayout.ANIMATION_DURATION_FOR_SETTLING_BACK_TO_POSITION);
            return;
        }
        boolean isUndoAction;
        switch(swipeAction.labelRes()) {
            case ACTION_NAME_OPTIONS:
                swipeEvents.accept(new CommentOptionSwipeEvent(comment, swipeableLayout));
                isUndoAction = false;
                break;
            case ACTION_NAME_REPLY:
                swipeEvents.accept(InlineReplyRequestEvent.create(comment));
                isUndoAction = false;
                break;
            case ACTION_NAME_UPVOTE:
                {
                    VoteDirection currentVoteDirection = votingManager.get().getPendingOrDefaultVote(comment, comment.getVote());
                    VoteDirection newVoteDirection = currentVoteDirection == VoteDirection.UP ? VoteDirection.NONE : VoteDirection.UP;
                    swipeEvents.accept(ContributionVoteSwipeEvent.create(comment, newVoteDirection));
                    isUndoAction = newVoteDirection == VoteDirection.NONE;
                    break;
                }
            case ACTION_NAME_DOWNVOTE:
                {
                    VoteDirection currentVoteDirection = votingManager.get().getPendingOrDefaultVote(comment, comment.getVote());
                    VoteDirection newVoteDirection = currentVoteDirection == VoteDirection.DOWN ? VoteDirection.NONE : VoteDirection.DOWN;
                    swipeEvents.accept(ContributionVoteSwipeEvent.create(comment, newVoteDirection));
                    isUndoAction = newVoteDirection == VoteDirection.NONE;
                    break;
                }
            default:
                throw new UnsupportedOperationException("Unknown swipe action: " + swipeAction);
        }
        swipeableLayout.playRippleAnimation(swipeAction, isUndoAction ? RippleType.UNDO : RippleType.REGISTER);
    }

    private boolean needsLogin(SwipeAction swipeAction, Comment comment) {
        if (SyntheticData.Companion.isSynthetic(comment)) {
            return false;
        }
        switch(swipeAction.labelRes()) {
            case ACTION_NAME_OPTIONS:
                return false;
            case ACTION_NAME_REPLY:
            case ACTION_NAME_UPVOTE:
            case ACTION_NAME_DOWNVOTE:
                return !userSessionRepository.get().isUserLoggedIn();
            default:
                throw new UnsupportedOperationException("Unknown swipe action: " + swipeAction);
        }
    }
}

19 Source : AppShortcutSwipeActionsProvider.java
with Apache License 2.0
from saket

/**
 * Controls gesture actions on {@link AppShortcut}.
 */
public clreplaced AppShortcutSwipeActionsProvider {

    @StringRes
    private static final int ACTION_NAME_DELETE = R.string.appshrotcuts_swipe_action_delete;

    private final SwipeActions swipeActions;

    private final SwipeActionIconProvider swipeActionIconProvider;

    public final PublishRelay<AppShortcut> deleteSwipeActions = PublishRelay.create();

    @Inject
    public AppShortcutSwipeActionsProvider() {
        SwipeAction deleteAction = SwipeAction.create(ACTION_NAME_DELETE, R.color.appshortcut_swipe_delete, 1);
        swipeActions = SwipeActions.builder().startActions(SwipeActionsHolder.builder().add(deleteAction).build()).endActions(SwipeActionsHolder.builder().add(deleteAction).build()).build();
        swipeActionIconProvider = createActionIconProvider();
    }

    public SwipeActions actions() {
        return swipeActions;
    }

    public SwipeActionIconProvider iconProvider() {
        return swipeActionIconProvider;
    }

    public SwipeActionIconProvider createActionIconProvider() {
        return (imageView, oldAction, newAction) -> {
            if (newAction.labelRes() == ACTION_NAME_DELETE) {
                imageView.setImageResource(R.drawable.ic_delete_20dp);
            } else {
                throw new replacedertionError("Unknown swipe action: " + newAction);
            }
        };
    }

    public void performSwipeAction(SwipeAction swipeAction, AppShortcut shortcut, SwipeableLayout swipeableLayout) {
        switch(swipeAction.labelRes()) {
            case ACTION_NAME_DELETE:
                deleteSwipeActions.accept(shortcut);
                break;
            default:
                throw new replacedertionError("Unknown swipe action: " + swipeAction);
        }
        swipeableLayout.playRippleAnimation(swipeAction, RippleType.REGISTER);
    }
}

19 Source : ResAnnotation.java
with Apache License 2.0
from RealMoMo

/**
 * @author Realmo
 * @version 1.0.0
 * @name Res Annotation
 * @email [email protected]
 * @time 2018/7/11 17:36
 * @describe
 */
public clreplaced ResAnnotation {

    // 任何资源类型
    @AnyRes
    private int anyRes = R.mipmap.ic_launcher;

    // 动画
    @AnimRes
    private int animRes = R.anim.anim_test;

    // TODO
    // animator资源类型
    @AnimatorRes
    private int animatorRes;

    // 数组资源类型
    @ArrayRes
    private int arrayRes = R.array.arrayRes;

    // 自定义属性资源类型
    @AttrRes
    private int attrRes = R.attr.actionBarDivider;

    // bool类型资源类型
    @BoolRes
    private int boolRes = R.bool.boolRes;

    // Color资源类型
    @ColorRes
    private int colorRes = R.color.colorAccent;

    // dimen资源类型
    @DimenRes
    private int dimenRes = R.dimen.dimenRes;

    // 图片资源类型
    @DrawableRes
    private int drawableRes = R.mipmap.ic_launcher;

    // id资源
    @IdRes
    private int idRes = R.id.all;

    // TODO
    // 动画插值器资源
    @InterpolatorRes
    private int interpolatorRes;

    // layout资源
    @LayoutRes
    private int layoutRes = R.layout.activity_main;

    // TODO
    // menu资源
    @MenuRes
    private int menuRes;

    // TODO
    // Raw资源
    @RawRes
    private int rawRes;

    // 字符串资源
    @StringRes
    private int strRes = R.string.app_name;

    // Style资源
    @StyleRes
    private int styleRes = R.style.AppTheme;

    // StyleableRes
    @StyleableRes
    private int styleableRes = R.styleable.attrRes_test1;

    // TODO
    // TransitionRes资源
    @TransitionRes
    private int transitionRes;

    // TODO
    // Xml资源
    private int xmlRes;
}

19 Source : DurationUtils.java
with GNU General Public License v3.0
from philliphsu

@StringRes
private static int getStringRes(long numDays, long numHours, long numMins) {
    int res;
    if (numDays == 0) {
        if (numHours == 0) {
            if (numMins == 0) {
                res = R.string.less_than_one_minute;
            } else if (numMins == 1) {
                res = R.string.minute;
            } else {
                res = R.string.minutes;
            }
        } else if (numHours == 1) {
            if (numMins == 0) {
                res = R.string.hour;
            } else if (numMins == 1) {
                res = R.string.hour_and_minute;
            } else {
                res = R.string.hour_and_minutes;
            }
        } else {
            if (numMins == 0) {
                res = R.string.hours;
            } else if (numMins == 1) {
                res = R.string.hours_and_minute;
            } else {
                res = R.string.hours_and_minutes;
            }
        }
    } else if (numDays == 1) {
        if (numHours == 0) {
            if (numMins == 0) {
                res = R.string.day;
            } else if (numMins == 1) {
                res = R.string.day_and_minute;
            } else {
                res = R.string.day_and_minutes;
            }
        } else if (numHours == 1) {
            if (numMins == 0) {
                res = R.string.day_and_hour;
            } else if (numMins == 1) {
                res = R.string.day_hour_and_minute;
            } else {
                res = R.string.day_hour_and_minutes;
            }
        } else {
            if (numMins == 0) {
                res = R.string.day_and_hours;
            } else if (numMins == 1) {
                res = R.string.day_hours_and_minute;
            } else {
                res = R.string.day_hours_and_minutes;
            }
        }
    } else {
        if (numHours == 0) {
            if (numMins == 0) {
                res = R.string.days;
            } else if (numMins == 1) {
                res = R.string.days_and_minute;
            } else {
                res = R.string.days_and_minutes;
            }
        } else if (numHours == 1) {
            if (numMins == 0) {
                res = R.string.days_and_hour;
            } else if (numMins == 1) {
                res = R.string.days_hour_and_minute;
            } else {
                res = R.string.days_hour_and_minutes;
            }
        } else {
            if (numMins == 0) {
                res = R.string.days_and_hours;
            } else if (numMins == 1) {
                res = R.string.days_hours_and_minute;
            } else {
                res = R.string.days_hours_and_minutes;
            }
        }
    }
    return res;
}

19 Source : DurationUtils.java
with GNU General Public License v3.0
from philliphsu

@StringRes
private static int getAbbreviatedStringRes(long numDays, long numHours, long numMins) {
    int res;
    if (numDays == 0) {
        if (numHours == 0) {
            if (numMins == 0) {
                res = R.string.abbrev_less_than_one_minute;
            } else {
                res = R.string.abbrev_minutes;
            }
        } else {
            if (numMins == 0) {
                res = R.string.abbrev_hours;
            } else {
                res = R.string.abbrev_hours_and_minutes;
            }
        }
    } else {
        if (numHours == 0) {
            if (numMins == 0) {
                res = R.string.abbrev_days;
            } else {
                res = R.string.abbrev_days_and_minutes;
            }
        } else {
            if (numMins == 0) {
                res = R.string.abbrev_days_and_hours;
            } else {
                res = R.string.abbrev_days_hours_and_minutes;
            }
        }
    }
    return res;
}

19 Source : RecyclerViewFragment.java
with GNU General Public License v3.0
from philliphsu

/**
 * @return a resource to a String that will be displayed when the list is empty
 */
@StringRes
protected int emptyMessage() {
    // The reason this isn't abstract is so we don't require subclreplacedes that
    // don't have an empty view to implement this.
    return 0;
}

19 Source : DrawerPresenter.java
with Apache License 2.0
from Nilhcem

public clreplaced DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter {

    @State
    @StringRes
    int toolbarreplacedle;

    @State
    @IdRes
    int selectedItemId;

    public DrawerPresenter(DrawerMvp.View view) {
        super(view);
    }

    @Override
    public void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        if (savedInstanceState == null) {
            onNavigationItemSelected(R.id.drawer_nav_schedule);
        }
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        view.updateToolbarreplacedle(toolbarreplacedle);
    }

    @Override
    public void onNavigationItemSelected(@IdRes int itemId) {
        if (itemId != selectedItemId) {
            switch(itemId) {
                case R.id.drawer_nav_schedule:
                    view.showFragment(new SchedulePagerFragmentBuilder(false).build());
                    toolbarreplacedle = R.string.drawer_nav_schedule;
                    break;
                case R.id.drawer_nav_agenda:
                    view.showFragment(new SchedulePagerFragmentBuilder(true).build());
                    toolbarreplacedle = R.string.drawer_nav_agenda;
                    break;
                case R.id.drawer_nav_speakers:
                    view.showFragment(new SpeakersListFragment());
                    toolbarreplacedle = R.string.drawer_nav_speakers;
                    break;
                case R.id.drawer_nav_venue:
                    view.showFragment(new VenueFragment());
                    toolbarreplacedle = R.string.drawer_nav_venue;
                    break;
                case R.id.drawer_nav_settings:
                    view.showFragment(new SettingsFragment());
                    toolbarreplacedle = R.string.drawer_nav_settings;
                    break;
                default:
                    throw new IllegalArgumentException();
            }
            view.hideTabLayout();
            view.updateToolbarreplacedle(toolbarreplacedle);
            selectedItemId = itemId;
        }
        view.closeNavigationDrawer();
    }

    @Override
    public boolean onBackPressed() {
        if (view.isNavigationDrawerOpen()) {
            view.closeNavigationDrawer();
            return true;
        } else if (toolbarreplacedle != R.string.drawer_nav_schedule) {
            int firsreplacedem = R.id.drawer_nav_schedule;
            onNavigationItemSelected(firsreplacedem);
            view.selectDrawerMenuItem(firsreplacedem);
            return true;
        }
        return false;
    }
}

19 Source : PopUpCoachMarkPresenterTest.java
with Apache License 2.0
from myntra

@RunWith(PowerMockRunner.clreplaced)
@PrepareForTest({ PopUpCoachMarkPresenter.clreplaced, Log.clreplaced })
public clreplaced PopUpCoachMarkPresenterTest {

    @Mock
    CoachMarkBuilder mCoachMarkBuilder;

    @Mock
    IPopUpCoachMarkPresentation mPopUpCoachMarkPresentation;

    @Mock
    IStringResourceProvider mStringResourceProvider;

    @Mock
    IDimensionResourceProvider mDimensionResourceProvider;

    @Mock
    IScreenInfoProvider mScreenInfoProvider;

    @Mock
    ITypeFaceProvider mTypeFaceProvider;

    @Mock
    @StringRes
    int mockedStringRes;

    @Mock
    @ColorRes
    int mockedColorRes;

    @Mock
    @DrawableRes
    int mockedDrawableRes;

    @Mock
    CoachMarkLayoutMargin mCoachMarkLayoutMargin;

    @Mock
    ImageLayoutInformation mImageLayoutInformation;

    @Mock
    @DimenRes
    int mockedDimenRes;

    private PopUpCoachMarkPresenter mPopUpCoachMarkPresenter;

    private CoachMarkPixelInfo mCoachMarkPixelInfo;

    @Before
    public void setUp() throws Exception {
        mPopUpCoachMarkPresenter = new PopUpCoachMarkPresenter(mStringResourceProvider, mDimensionResourceProvider, mTypeFaceProvider, mScreenInfoProvider);
        mPopUpCoachMarkPresenter.onCreate(mCoachMarkBuilder);
        mPopUpCoachMarkPresenter.onCreateView(mPopUpCoachMarkPresentation);
        mCoachMarkPixelInfo = CoachMarkPixelInfo.create().setMarginRectInPixels(new Rect(10, 10, 10, 10)).setPopUpHeightInPixels(50).setPopUpHeightInPixelsWithOffset(70).setPopUpWidthInPixels(150).setPopUpWidthInPixelsWithOffset(170).setWidthHeightOffsetForCoachMarkPopUp(10).setActionBarHeightPixels(10).setFooterHeightPixels(10).setNotchDimenInPixels(25).setMarginOffsetForNotchInPixels(5).setImageHeightInPixels(30).setImageWidthInPixels(30).setScreenHeightInPixels(1024).setScreenWidthInPixels(768).build();
    }

    @Test
    public void onCreateTest() {
        PopUpCoachMarkPresenter popUpCoachMarkPresenter = Mockito.mock(PopUpCoachMarkPresenter.clreplaced);
        popUpCoachMarkPresenter.onCreate(mCoachMarkBuilder);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onCreateViewTest() {
        PopUpCoachMarkPresenter popUpCoachMarkPresenter = Mockito.mock(PopUpCoachMarkPresenter.clreplaced);
        popUpCoachMarkPresenter.onCreateView(mPopUpCoachMarkPresentation);
        Mockito.verify(popUpCoachMarkPresenter, Mockito.times(1)).onCreateView(mPopUpCoachMarkPresentation);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onDestroyTest() {
        PopUpCoachMarkPresenter popUpCoachMarkPresenter = Mockito.mock(PopUpCoachMarkPresenter.clreplaced);
        popUpCoachMarkPresenter.onDestroy();
        Mockito.verify(popUpCoachMarkPresenter, Mockito.times(1)).onDestroy();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onDestroyViewTest() {
        PopUpCoachMarkPresenter popUpCoachMarkPresenter = Mockito.mock(PopUpCoachMarkPresenter.clreplaced);
        popUpCoachMarkPresenter.onDestroyView();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onOkButtonClicked() throws Exception {
        mPopUpCoachMarkPresenter.onOkButtonClicked();
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).closeCoachMarkDialog();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onShimClicked() throws Exception {
        mPopUpCoachMarkPresenter.onShimClicked();
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).closeCoachMarkDialog();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setMessageForCoachMarkTextTest() {
        Mockito.when(mStringResourceProvider.getStringFromResource(mockedStringRes)).thenReturn("MockedString");
        mPopUpCoachMarkPresenter.setMessageForCoachMarkText(mockedStringRes);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setCoachMarkMessage("MockedString");
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setTypeFaceForDismissButtonNullFontFileTest() {
        mPopUpCoachMarkPresenter.setTypeFaceForDismissButton(null);
        Mockito.verify(mTypeFaceProvider, Mockito.times(0)).getTypeFaceFromreplacedets(Matchers.anyString());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setTypeFaceForDismissButton((Typeface) Matchers.anyObject());
    }

    @Test
    public void setTypeFaceForDismissButtonNullTypeFaceTest() {
        Mockito.when(mTypeFaceProvider.getTypeFaceFromreplacedets(Matchers.anyString())).thenReturn(null);
        mPopUpCoachMarkPresenter.setTypeFaceForDismissButton(Matchers.anyString());
        Mockito.verify(mTypeFaceProvider, Mockito.times(1)).getTypeFaceFromreplacedets(Matchers.anyString());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setTypeFaceForDismissButton((Typeface) Matchers.anyObject());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setTypeFaceForDismissButtonTest() {
        Typeface typeface = Mockito.mock(Typeface.clreplaced);
        Mockito.when(mTypeFaceProvider.getTypeFaceFromreplacedets(Matchers.anyString())).thenReturn(typeface);
        mPopUpCoachMarkPresenter.setTypeFaceForDismissButton("fontFilePath");
        Mockito.verify(mTypeFaceProvider, Mockito.times(1)).getTypeFaceFromreplacedets(Matchers.anyString());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setTypeFaceForDismissButton(typeface);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setTypeFaceForCoachMarkTextNullFontFileTest() {
        mPopUpCoachMarkPresenter.setTypeFaceForCoachMarkText(null);
        Mockito.verify(mTypeFaceProvider, Mockito.times(0)).getTypeFaceFromreplacedets(Matchers.anyString());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setTypeFaceForPopUpText((Typeface) Matchers.anyObject());
    }

    @Test
    public void setTypeFaceForCoachMarkTextNullTypefaceTest() {
        Mockito.when(mTypeFaceProvider.getTypeFaceFromreplacedets(Matchers.anyString())).thenReturn(null);
        mPopUpCoachMarkPresenter.setTypeFaceForCoachMarkText("fontFilePath");
        Mockito.verify(mTypeFaceProvider, Mockito.times(1)).getTypeFaceFromreplacedets("fontFilePath");
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setTypeFaceForPopUpText((Typeface) Matchers.anyObject());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setTypeFaceForCoachMarkTextTest() {
        Typeface typeface = Mockito.mock(Typeface.clreplaced);
        Mockito.when(mTypeFaceProvider.getTypeFaceFromreplacedets(Matchers.anyString())).thenReturn(typeface);
        mPopUpCoachMarkPresenter.setTypeFaceForCoachMarkText("fontFilePath");
        Mockito.verify(mTypeFaceProvider, Mockito.times(1)).getTypeFaceFromreplacedets(Matchers.anyString());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setTypeFaceForPopUpText(typeface);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setGravityForCoachMarkTextLeftGravityTest() {
        mPopUpCoachMarkPresenter.setGravityForCoachMarkText(CoachMarkTextGravity.CENTER);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setUpGravityForCoachMarkText(CoachMarkTextGravity.CENTER);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setGravityForCoachMarkTextRightGravityTest() {
        mPopUpCoachMarkPresenter.setGravityForCoachMarkText(CoachMarkTextGravity.RIGHT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setUpGravityForCoachMarkText(CoachMarkTextGravity.RIGHT);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setGravityForCoachMarkTextCenterGravityTest() {
        mPopUpCoachMarkPresenter.setGravityForCoachMarkText(CoachMarkTextGravity.LEFT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setUpGravityForCoachMarkText(CoachMarkTextGravity.LEFT);
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void getMarginLeftForNotchTest() {
        replacedertEquals(140, mPopUpCoachMarkPresenter.getMarginLeftForNotch(.75, 190, 50));
        replacedertEquals(25, mPopUpCoachMarkPresenter.getMarginLeftForNotch(.25, 100, 25));
    }

    @Test
    public void detectAndCreateShimOutViewsNullShimOutViewListTest() {
        mPopUpCoachMarkPresenter.detectAndCreateShimOutViews(null);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).createViewToBeMaskedOut(Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void detectAndCreateShimOutViewsTest() {
        int listSize = 2;
        List<InfoForViewToMask> infoForViewToMaskList = new ArrayList<>(listSize);
        InfoForViewToMask infoForViewToMask = InfoForViewToMask.create(new Point(0, 0), 100, 100).build();
        for (int i = 0; i < listSize; i++) {
            infoForViewToMaskList.add(infoForViewToMask);
        }
        mPopUpCoachMarkPresenter.detectAndCreateShimOutViews(infoForViewToMaskList);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(listSize)).createViewToBeMaskedOut(Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setImageParamsAndPositionTest() {
        Point anchorTop = new Point(0, 0);
        Point anchorBotom = new Point(100, 100);
        mPopUpCoachMarkPresenter.setImageParamsAndPosition(anchorTop, anchorBotom, 30, 30, mockedColorRes, mockedDrawableRes);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setImageInformation(Matchers.anyDouble(), Matchers.anyDouble(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionLeftTest() {
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.LEFT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_RIGHT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setDismissButtonPositionLeft();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionRightTest() {
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.RIGHT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_LEFT);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setDismissButtonPositionLeft();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionTopTest() {
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.TOP);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_BOTTOM);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setDismissButtonPositionLeft();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionBottomTest() {
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.BOTTOM);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_TOP);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setDismissButtonPositionLeft();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionNoneTest() {
        PowerMockito.mockStatic(Log.clreplaced);
        PowerMockito.when(Log.wtf(Matchers.anyString(), Matchers.anyString())).thenReturn(1);
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.NONE);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_TOP);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)).setDismissButtonPositionLeft();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void showCoachMarkPositionTopDialogDismissButtonRightTest() {
        mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.RIGHT, PopUpPosition.TOP);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_BOTTOM);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setDismissButtonPositionRight();
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void checkIfLeftPossibleTest() {
        MockedPoint point = new MockedPoint(600, 300);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfLeftPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfLeftPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(100, 200);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfLeftPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(700, 700);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfLeftPossible(point, mCoachMarkPixelInfo));
    }

    @Test
    public void checkIfRightPossibleTest() {
        MockedPoint point = new MockedPoint(600, 300);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfRightPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfRightPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(100, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfRightPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(700, 700);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfRightPossible(point, mCoachMarkPixelInfo));
    }

    @Test
    public void checkIfTopPossibleTest() {
        MockedPoint point = new MockedPoint(600, 300);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(100, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(700, 700);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 50);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(0, 50);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfTopPossible(point, mCoachMarkPixelInfo));
    }

    @Test
    public void checkIfBottomPossibleTest() {
        MockedPoint point = new MockedPoint(600, 300);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(100, 200);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(700, 700);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(400, 50);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(0, 50);
        replacedertEquals(true, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(0, 1000);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
        point = new MockedPoint(700, 1020);
        replacedertEquals(false, mPopUpCoachMarkPresenter.checkIfBottomPossible(point, mCoachMarkPixelInfo));
    }

    @Test
    public void getCorrectPositionOfCoachMarkIfDefaultFailsRightPositionTest() {
        MockedPoint point = new MockedPoint(400, 200);
        replacedertEquals(PopUpPosition.RIGHT, mPopUpCoachMarkPresenter.getCorrectPositionOfCoachMarkIfDefaultFails(point, mCoachMarkPixelInfo));
    }

    @Test
    public void getCorrectPositionOfCoachMarkIfDefaultFailsLeftPositionTest() {
        MockedPoint point = new MockedPoint(700, 1020);
        replacedertEquals(PopUpPosition.LEFT, mPopUpCoachMarkPresenter.getCorrectPositionOfCoachMarkIfDefaultFails(point, mCoachMarkPixelInfo));
    }

    @Test
    public void getCorrectPositionOfCoachMarkIfDefaultFailsBottomPositionTest() {
        MockedPoint point = new MockedPoint(700, 820);
        replacedertEquals(PopUpPosition.BOTTOM, mPopUpCoachMarkPresenter.getCorrectPositionOfCoachMarkIfDefaultFails(point, mCoachMarkPixelInfo));
    }

    @Test
    public void getActualTopMarginTest() {
        replacedertEquals(100, mPopUpCoachMarkPresenter.getActualTopMargin(100, mCoachMarkPixelInfo));
        replacedertEquals(900, mPopUpCoachMarkPresenter.getActualTopMargin(900, mCoachMarkPixelInfo));
    }

    @Test
    public void getActualLeftMarginTest() {
        replacedertEquals(400, mPopUpCoachMarkPresenter.getActualTopMargin(400, mCoachMarkPixelInfo));
        replacedertEquals(800, mPopUpCoachMarkPresenter.getActualTopMargin(800, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionLeftDefaultPreplacedTest() {
        MockedPoint point = new MockedPoint(600, 300);
        replacedertEquals(PopUpPosition.LEFT, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.LEFT, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionLeftDefaultFailTest() {
        MockedPoint point = new MockedPoint(0, 300);
        replacedertEquals(PopUpPosition.RIGHT, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.LEFT, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionRightDefaultPreplacedTest() {
        MockedPoint point = new MockedPoint(400, 300);
        replacedertEquals(PopUpPosition.RIGHT, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.RIGHT, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionRightDefaultFailTest() {
        MockedPoint point = new MockedPoint(760, 300);
        replacedertEquals(PopUpPosition.BOTTOM, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.RIGHT, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionTopDefaultPreplacedTest() {
        MockedPoint point = new MockedPoint(400, 300);
        replacedertEquals(PopUpPosition.TOP, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.TOP, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionTopDefaultFailTest() {
        MockedPoint point = new MockedPoint(760, 10);
        replacedertEquals(PopUpPosition.BOTTOM, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.TOP, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionBottomDefaultPreplacedTest() {
        MockedPoint point = new MockedPoint(400, 300);
        replacedertEquals(PopUpPosition.BOTTOM, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.BOTTOM, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionBottomDefaultFailTest() {
        MockedPoint point = new MockedPoint(760, 1000);
        replacedertEquals(PopUpPosition.LEFT, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.BOTTOM, mCoachMarkPixelInfo));
    }

    @Test
    public void getDisplayPositionNoneDefaultPositionTest() {
        MockedPoint point = new MockedPoint(760, 1000);
        replacedertEquals(PopUpPosition.LEFT, mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.NONE, mCoachMarkPixelInfo));
    }

    @Test
    public void createCoachMarkPixelInfoTest() {
        Mockito.when(mCoachMarkBuilder.getCoachMarkLayoutMargin()).thenReturn(mCoachMarkLayoutMargin);
        Mockito.when(mCoachMarkBuilder.getImageLayoutInformation()).thenReturn(mImageLayoutInformation);
        Mockito.when(mCoachMarkLayoutMargin.getBottomMarginForCoachMark()).thenReturn(mockedDimenRes);
        Mockito.when(mCoachMarkLayoutMargin.getLeftMarginForCoachMark()).thenReturn(mockedDimenRes);
        Mockito.when(mCoachMarkLayoutMargin.getRightMarginForCoachMark()).thenReturn(mockedDimenRes);
        Mockito.when(mCoachMarkLayoutMargin.getTopMarginForCoachMark()).thenReturn(mockedDimenRes);
        Mockito.when(mCoachMarkBuilder.getActionBarHeight()).thenReturn(mockedDimenRes);
        Mockito.when(mCoachMarkBuilder.getFooterHeight()).thenReturn(mockedDimenRes);
        Mockito.when(mImageLayoutInformation.getImageHeight()).thenReturn(mockedDimenRes);
        Mockito.when(mImageLayoutInformation.getImageWidth()).thenReturn(mockedDimenRes);
        Mockito.when(mDimensionResourceProvider.getDimensionInPixel(Matchers.anyInt())).thenReturn(10);
        CoachMarkPixelInfo coachMarkPixelInfo = mPopUpCoachMarkPresenter.createCoachMarkPixelInfo();
        replacedertEquals(10, coachMarkPixelInfo.getImageHeightInPixels());
        replacedertEquals(10, coachMarkPixelInfo.getImageWidthInPixels());
        replacedertEquals(30, coachMarkPixelInfo.getPopUpHeightInPixelsWithOffset());
        replacedertEquals(30, coachMarkPixelInfo.getPopUpWidthInPixelsWithOffset());
        replacedertEquals(10, coachMarkPixelInfo.getWidthHeightOffsetForCoachMarkPopUp());
        replacedertEquals(10, coachMarkPixelInfo.getNotchDimenInPixels());
        replacedertEquals(10, coachMarkPixelInfo.getActionBarHeightPixels());
        replacedertEquals(10, coachMarkPixelInfo.getFooterHeightPixels());
    }

    @Test
    public void findCoachMarkTextPopUpDisplayPositionTest() {
        MockedPoint pointTop = new MockedPoint(400, 0);
        MockedPoint pointBottom = new MockedPoint(600, 600);
        replacedertEquals(PopUpPosition.RIGHT, mPopUpCoachMarkPresenter.findCoachMarkTextPopUpDisplayPosition(pointTop, pointBottom, PopUpPosition.RIGHT, mCoachMarkPixelInfo));
    }

    @Test
    public void setNotchDisplayEdgePopUpPositionLeftTest() {
        mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.LEFT, 600, 0, 600, mCoachMarkPixelInfo);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewTopLeft((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpTopLeft((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setNotchDisplayEdgePopUpPositionTopTest() {
        mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.TOP, 600, 0, 600, mCoachMarkPixelInfo);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewTopLeft((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpTopLeft((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setNotchDisplayEdgePopUpPositionBottomTest() {
        mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.BOTTOM, 600, 0, 600, mCoachMarkPixelInfo);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewBottomRight((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpBottomRight((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).uiAdjustmentForNotchIfPopUpBottom((Rect) Matchers.anyObject());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void setNotchDisplayEdgePopUpPositionRightTest() {
        mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.RIGHT, 600, 0, 600, mCoachMarkPixelInfo);
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewBottomRight((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpBottomRight((Rect) Matchers.anyObject(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).uiAdjustmentForNotchIfPopUpRight((Rect) Matchers.anyObject());
        Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
    }

    @Test
    public void onViewCreatedTest() {
        PopUpCoachMarkPresenter spiedPopUpCoachMarkPresenter = Mockito.spy(new PopUpCoachMarkPresenter(mStringResourceProvider, mDimensionResourceProvider, mTypeFaceProvider, mScreenInfoProvider));
        MockedPoint pointTop = new MockedPoint(400, 0);
        MockedPoint pointBottom = new MockedPoint(600, 600);
        CoachMarkBuilder coachMarkBuilder = CoachMarkBuilder.create(pointTop, pointBottom, mockedStringRes).build();
        spiedPopUpCoachMarkPresenter.onCreate(coachMarkBuilder);
        spiedPopUpCoachMarkPresenter.onCreateView(mPopUpCoachMarkPresentation);
        Mockito.doReturn(mCoachMarkPixelInfo).when(spiedPopUpCoachMarkPresenter).createCoachMarkPixelInfo();
        spiedPopUpCoachMarkPresenter.onViewCreated();
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).displayCoachMark();
    }

    @Test
    public void displayCoachMarkTest() {
        PopUpCoachMarkPresenter spiedPopUpCoachMarkPresenter = Mockito.spy(new PopUpCoachMarkPresenter(mStringResourceProvider, mDimensionResourceProvider, mTypeFaceProvider, mScreenInfoProvider));
        MockedPoint pointTop = new MockedPoint(400, 0);
        MockedPoint pointBottom = new MockedPoint(600, 600);
        CoachMarkBuilder coachMarkBuilder = CoachMarkBuilder.create(pointTop, pointBottom, mockedStringRes).build();
        spiedPopUpCoachMarkPresenter.onCreate(coachMarkBuilder);
        spiedPopUpCoachMarkPresenter.onCreateView(mPopUpCoachMarkPresentation);
        Mockito.doReturn(mCoachMarkPixelInfo).when(spiedPopUpCoachMarkPresenter).createCoachMarkPixelInfo();
        spiedPopUpCoachMarkPresenter.displayCoachMark();
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).createCoachMarkPixelInfo();
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).findCoachMarkTextPopUpDisplayPosition((Point) Matchers.anyObject(), (Point) Matchers.anyObject(), Matchers.anyInt(), (CoachMarkPixelInfo) Matchers.anyObject());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setTypeFaceForDismissButton(Matchers.anyString());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setTypeFaceForCoachMarkText(Matchers.anyString());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setGravityForCoachMarkText(Matchers.anyInt());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setMessageForCoachMarkText(Matchers.anyInt());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setNotchDisplayEdge(Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), (CoachMarkPixelInfo) Matchers.anyObject());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).detectAndCreateShimOutViews(Matchers.anyList());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).setImageParamsAndPosition((Point) Matchers.anyObject(), (Point) Matchers.anyObject(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt());
        Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)).showCoachMark(Matchers.anyInt(), Matchers.anyInt());
        Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).startAnimationOnImage(Matchers.anyInt());
    }

    // Fake clreplaced to mock Point behaviour for junit tests
    public static clreplaced MockedPoint extends Point {

        MockedPoint(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}

19 Source : DefaultStringResourceProviderTest.java
with Apache License 2.0
from myntra

@RunWith(MockitoJUnitRunner.clreplaced)
public clreplaced DefaultStringResourceProviderTest {

    private static final String MOCKED_STRING = "This is a mocked string";

    private static final String MOCK_TEST = "mocked";

    @StringRes
    private static final int MOCKED_STRING_RES = 1;

    @Mock
    Context mMockContext;

    IStringResourceProvider mStringResourceProvider;

    @Before
    public void setUp() throws Exception {
        mStringResourceProvider = new DefaultStringResourceProvider(mMockContext);
    }

    @Test
    public void getStringFromResourceTest() throws Exception {
        when(mMockContext.getString(MOCKED_STRING_RES)).thenReturn(MOCKED_STRING);
        replacedert (mStringResourceProvider.getStringFromResource(MOCKED_STRING_RES).equals(MOCKED_STRING));
        verify(mMockContext, times(1)).getString(anyInt());
        verifyNoMoreInteractions(mMockContext);
    }

    @Test
    public void getStringFromResourceWithArgsTest() throws Exception {
        when(mMockContext.getString(MOCKED_STRING_RES, MOCK_TEST)).thenReturn(MOCKED_STRING);
        replacedert (mStringResourceProvider.getStringFromResource(MOCKED_STRING_RES, MOCK_TEST).equals(MOCKED_STRING));
        verify(mMockContext, times(1)).getString(anyInt(), Matchers.any());
        verifyNoMoreInteractions(mMockContext);
    }
}

19 Source : BaseCalendarConfigurationBuilder.java
with MIT License
from memfis19

/**
 * Created by memfis on 7/21/16.
 */
public abstract clreplaced BaseCalendarConfigurationBuilder<T> {

    protected Locale locale = Locale.getDefault();

    protected Calendar initialDay = DateUtils.getCalendarInstance();

    protected boolean eventProcessingEnabled = false;

    protected EventCalculator eventCalculator = new CadarEventCalculator();

    protected EventFactory eventFactory;

    @CadarSettings.PeriodType
    protected int periodType = Calendar.YEAR;

    protected int periodValue = 1;

    protected boolean weekDayreplacedleTranslationEnabled = false;

    @StringRes
    protected int mondayreplacedle, tuesdayreplacedle, wednesdayreplacedle, thursdayreplacedle, fridayreplacedle, saturdayreplacedle, sundayreplacedle;

    public BaseCalendarConfigurationBuilder() {
    }

    public BaseCalendarConfigurationBuilder setLocale(Locale locale) {
        this.locale = locale;
        return this;
    }

    public BaseCalendarConfigurationBuilder setInitialDay(Calendar initialDay) {
        this.initialDay = initialDay;
        return this;
    }

    public BaseCalendarConfigurationBuilder setEventProcessingEnabled(boolean enabled) {
        this.eventProcessingEnabled = enabled;
        return this;
    }

    public BaseCalendarConfigurationBuilder setEventCalculator(EventCalculator eventCalculator) {
        this.eventCalculator = eventCalculator;
        return this;
    }

    public BaseCalendarConfigurationBuilder setEventFactory(@NonNull EventFactory eventFactory) {
        this.eventFactory = eventFactory;
        return this;
    }

    public BaseCalendarConfigurationBuilder setDisplayPeriod(@CadarSettings.PeriodType int periodType, int periodValue) {
        this.periodType = periodType;
        this.periodValue = periodValue;
        return this;
    }

    public BaseCalendarConfigurationBuilder setWeekreplacedlesSystemTranslationsEnabled(boolean enabled) {
        this.weekDayreplacedleTranslationEnabled = enabled;
        return this;
    }

    public BaseCalendarConfigurationBuilder setMondayreplacedle(@StringRes int mondayreplacedle) {
        this.mondayreplacedle = mondayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setTuesdayreplacedle(@StringRes int tuesdayreplacedle) {
        this.tuesdayreplacedle = tuesdayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setWednesdayreplacedle(@StringRes int wednesdayreplacedle) {
        this.wednesdayreplacedle = wednesdayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setThursdayreplacedle(@StringRes int thursdayreplacedle) {
        this.thursdayreplacedle = thursdayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setFridayreplacedle(@StringRes int fridayreplacedle) {
        this.fridayreplacedle = fridayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setSaturdayreplacedle(@StringRes int saturdayreplacedle) {
        this.saturdayreplacedle = saturdayreplacedle;
        return this;
    }

    public BaseCalendarConfigurationBuilder setSundayreplacedle(@StringRes int sundayreplacedle) {
        this.sundayreplacedle = sundayreplacedle;
        return this;
    }

    public abstract T build();
}

19 Source : BaseCalendarConfiguration.java
with MIT License
from memfis19

/**
 * Created by memfis on 7/21/16.
 */
public clreplaced BaseCalendarConfiguration {

    private Locale locale = Locale.getDefault();

    protected Calendar initialDay = DateUtils.getCalendarInstance();

    @CadarSettings.PeriodType
    protected int periodType = Calendar.YEAR;

    protected int periodValue = 1;

    protected boolean eventProcessingEnabled = false;

    protected EventCalculator eventCalculator = new CadarEventCalculator();

    protected EventFactory eventFactory;

    protected boolean weekDayreplacedleTranslationEnabled = false;

    @StringRes
    protected int mondayreplacedle, tuesdayreplacedle, wednesdayreplacedle, thursdayreplacedle, fridayreplacedle, saturdayreplacedle, sundayreplacedle;

    protected BaseCalendarConfiguration() {
    }

    public Locale getLocale() {
        return locale;
    }

    @CadarSettings.PeriodType
    public int getPeriodType() {
        return periodType;
    }

    public int getPeriodValue() {
        return periodValue;
    }

    public Calendar getInitialDay() {
        return initialDay;
    }

    public boolean isEventProcessingEnabled() {
        return eventProcessingEnabled;
    }

    public EventCalculator getEventCalculator() {
        return eventCalculator;
    }

    public EventFactory getEventFactory() {
        return eventFactory;
    }

    public boolean isWeekDayreplacedleTranslationEnabled() {
        return weekDayreplacedleTranslationEnabled;
    }

    public int getMondayreplacedle() {
        return mondayreplacedle;
    }

    public int getTuesdayreplacedle() {
        return tuesdayreplacedle;
    }

    public int getWednesdayreplacedle() {
        return wednesdayreplacedle;
    }

    public int getThursdayreplacedle() {
        return thursdayreplacedle;
    }

    public int getFridayreplacedle() {
        return fridayreplacedle;
    }

    public int getSaturdayreplacedle() {
        return saturdayreplacedle;
    }

    public int getSundayreplacedle() {
        return sundayreplacedle;
    }
}

19 Source : Utils.java
with Apache License 2.0
from maoruibin

@StringRes
public static int getIndexDescription(int aqiIndex) {
    switch(aqiIndex) {
        case LEVEL_AQI_1:
            return R.string.pm_describe_1;
        case LEVEL_AQI_2:
            return R.string.pm_describe_2;
        case LEVEL_AQI_3:
            return R.string.pm_describe_3;
        case LEVEL_AQI_4:
            return R.string.pm_describe_4;
        case LEVEL_AQI_5:
            return R.string.pm_describe_5;
        case LEVEL_AQI_6:
            return R.string.pm_describe_6;
        default:
            return R.string.pm_describe_1;
    }
}

19 Source : SheimiAsyncTask.java
with GNU General Public License v3.0
from maks

/**
 * This method is to be overridden and should return the resource that
 * is used as the replacedle as the
 * {@link com.manichord.mgit.dialogs.ErrorDialog} replacedle when the
 * task fails with an exception.
 */
@StringRes
public int getErrorreplacedleRes() {
    return R.string.dialog_error_replacedle;
}

19 Source : CloneTask.java
with GNU General Public License v3.0
from maks

@Override
@StringRes
public int getErrorreplacedleRes() {
    return R.string.error_clone_failed;
}

19 Source : BaseFragment.java
with Apache License 2.0
from Lazyeraser

@StringRes
public int getreplacedle() {
    return replacedle;
}

19 Source : SharedLauncherPrefs.java
with Apache License 2.0
from KeikaiLauncher

/**
 * This is the string resource of the default order of the launchables.
 *
 * @return The string resource of the default order of the launchables.
 */
@StringRes
private static int getDefaultLauncherOrder() {
    return R.string.pref_app_preferred_order_entries_alphabetical;
}

19 Source : SharedLauncherPrefs.java
with Apache License 2.0
from KeikaiLauncher

/**
 * This is the string resource of the default notification priority.
 *
 * @return The string resource of the default notification priority.
 */
@StringRes
private static int getDefaultNotificationPriority() {
    return R.string.pref_value_notification_priority_min;
}

19 Source : ColorChooserDialog.java
with MIT License
from jianliaoim

@StringRes
public int getreplacedle() {
    Builder builder = getBuilder();
    int replacedle;
    if (isInSub())
        replacedle = builder.mreplacedleSub;
    else
        replacedle = builder.mreplacedle;
    if (replacedle == 0)
        replacedle = builder.mreplacedle;
    return replacedle;
}

See More Examples