当前位置: 首页>>代码示例>>Java>>正文


Java Pref.getInstance方法代码示例

本文整理汇总了Java中com.jecelyin.editor.v2.Pref.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Pref.getInstance方法的具体用法?Java Pref.getInstance怎么用?Java Pref.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jecelyin.editor.v2.Pref的用法示例。


在下文中一共展示了Pref.getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onOptionsItemSelected

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Pref pref = Pref.getInstance(this);
    int id = item.getItemId();
    if (id == R.id.show_hidden_files_menu) {
        item.setChecked(!item.isChecked());
        pref.setShowHiddenFiles(item.isChecked());
    } else if (id == R.id.sort_by_name_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_NAME);
    } else if (id == R.id.sort_by_datetime_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_DATE);
    } else if (id == R.id.sort_by_size_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_SIZE);
    } else if (id == R.id.sort_by_type_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_TYPE);
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:FileExplorerActivity.java

示例2: onCreateOptionsMenu

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.explorer_menu, menu);

    Pref pref = Pref.getInstance(this);
    menu.findItem(R.id.show_hidden_files_menu).setChecked(pref.isShowHiddenFiles());
    pasteMenu = menu.findItem(R.id.paste_menu);

    int sortId;
    switch (pref.getFileSortType()) {
        case FileListSorter.SORT_DATE:
            sortId = R.id.sort_by_datetime_menu;
            break;
        case FileListSorter.SORT_SIZE:
            sortId = R.id.sort_by_size_menu;
            break;
        case FileListSorter.SORT_TYPE:
            sortId = R.id.sort_by_type_menu;
            break;
        default:
            sortId = R.id.sort_by_name_menu;
            break;
    }

    menu.findItem(sortId).setChecked(true);

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:29,代码来源:FileExplorerActivity.java

示例3: onRun

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
@Override
protected void onRun(final TaskResult<JecFile[]> taskResult, Void... params) throws Exception {
    Pref pref = Pref.getInstance(context);
    final boolean showHiddenFiles = pref.isShowHiddenFiles();
    final int sortType = pref.getFileSortType();
    if (isRoot && !(path instanceof RootFile) && !path.getPath().startsWith(Environment.getExternalStorageDirectory().getPath())) {
        path = new RootFile(path.getPath());
    }
    updateRootInfo.onUpdate(path);
    path.listFiles(new FileListResultListener() {
        @Override
        public void onResult(JecFile[] result) {
            if (result.length == 0) {
                taskResult.setResult(result);
                return;
            }
            if (!showHiddenFiles) {
                List<JecFile> list = new ArrayList<>(result.length);
                for (JecFile file : result) {
                    if (file.getName().charAt(0) == '.') {
                        continue;
                    }
                    list.add(file);
                }
                result = new JecFile[list.size()];
                list.toArray(result);
            }
            Arrays.sort(result, new FileListSorter(true, sortType, true));
            taskResult.setResult(result);
        }
    });
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:33,代码来源:FileListPagerFragment.java

示例4: Document

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
public Document(Context context, EditorDelegate EditorDelegate) {
    this.editorDelegate = EditorDelegate;
    this.context = context;
    pref = Pref.getInstance(context);
    root = false;

    this.saveTask = new SaveTask(context, EditorDelegate, this);
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:9,代码来源:Document.java

示例5: dependBindPreference

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
private static void dependBindPreference(PreferenceGroup pg) {
        int count = pg.getPreferenceCount();
        Preference preference;
        String key;
        Object value;

        Pref pref = Pref.getInstance(pg.getContext());

        for(int i = 0; i < count; i++) {
            preference = pg.getPreference(i);
            key = preference.getKey();

            if(preference instanceof PreferenceGroup) {
                dependBindPreference((PreferenceGroup) preference);
                continue;
            }

            Class<? extends Preference> cls = preference.getClass();
            if(cls.equals(Preference.class))
                continue;

            value = pref.getValue(key);

            if(preference instanceof JecListPreference) {
//                if("pref_font_size".equals(key)) {
//                    new FontSizePreference((JecListPreference)preference);
//                } else if("pref_cursor_width".equals(key)) {
//                    new CursorWidthPreference((JecListPreference)preference);
//                }
            } else if(preference instanceof EditTextPreference) {
                ((EditTextPreference)preference).setText(String.valueOf(value));
            } else if(preference instanceof CheckBoxPreference) {
                ((CheckBoxPreference)preference).setChecked((boolean)value);
            }

            if (!Pref.KEY_SYMBOL.equals(key))
                bindPreferenceSummaryToValue(preference);
        }
    }
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:40,代码来源:SettingsFragment.java

示例6: updateList

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
private void updateList(final TaskResult<JecFile[]> taskResult) {
    Pref pref = Pref.getInstance(context);
    final boolean showHiddenFiles = pref.isShowHiddenFiles();
    final int sortType = pref.getFileSortType();
    updateRootInfo.onUpdate(path);
    path.listFiles(new FileListResultListener() {
        @Override
        public void onResult(JecFile[] result) {
            if (result == null || result.length == 0) {
                taskResult.setResult(result);
                return;
            }
            if (!showHiddenFiles) {
                List<JecFile> list = new ArrayList<>(result.length);
                for (JecFile file : result) {
                    if (file.getName().charAt(0) == '.') {
                        continue;
                    }
                    list.add(file);
                }
                result = new JecFile[list.size()];
                list.toArray(result);
            }
            Arrays.sort(result, new FileListSorter(true, sortType, true));
            taskResult.setResult(result);
        }

        @Override
        public void onError(String error) {
            taskResult.setError(new Exception(error));
        }
    });
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:34,代码来源:FileListPagerFragment.java

示例7: onCreate

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    pref = Pref.getInstance(this);
    MenuManager.init(this);

    setContentView(R.layout.main_activity);

    L.d(TAG, "onCreate");
    CrashDbHelper.getInstance(this).close(); //初始化一下

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mLoadingLayout = (LinearLayout) findViewById(R.id.loading_layout);
    mTabPager = (TabViewPager) findViewById(R.id.tab_pager);
    mMenuRecyclerView = (RecyclerView) findViewById(R.id.menuRecyclerView);
    mDrawerLayout = (TranslucentDrawerLayout) findViewById(R.id.drawer_layout);
    mTabRecyclerView = (RecyclerView) findViewById(R.id.tabRecyclerView);
    mVersionTextView = (TextView) findViewById(R.id.versionTextView);

    mSymbolBarLayout = (SymbolBarLayout) findViewById(R.id.symbolBarLayout);
    mSymbolBarLayout.setOnSymbolCharClickListener(new SymbolBarLayout.OnSymbolCharClickListener() {
        @Override
        public void onClick(View v, String text) {
            insertText(text);
        }
    });

    if(!AppUtils.verifySign(getContext())) {
        UIUtils.showConfirmDialog(getContext(), getString(R.string.verify_sign_failure), new UIUtils.OnClickCallback() {
            @Override
            public void onOkClick() {
                SysUtils.startWebView(getContext(), "https://github.com/jecelyin/920-text-editor-v2/releases");
            }
        });
    }

    setStatusBarColor(mDrawerLayout);

    bindPreferences();
    setScreenOrientation();

    mDrawerLayout.setEnabled(false);
    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    final String version = SysUtils.getVersionName(this);
    mVersionTextView.setText(version);

    if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED
            || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED
            ) {
        requestWriteExternalStoragePermission();
    } else {
        start();

        if (savedInstanceState == null && pref.isAutoCheckUpdates()) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    new CheckUpgradeTask(getContext()).checkVersion(version);
                }
            }, 3000);
        }
    }
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:65,代码来源:MainActivity.java

示例8: EditAreaView

import com.jecelyin.editor.v2.Pref; //导入方法依赖的package包/类
public EditAreaView(Context context, AttributeSet attrs) {
        super(context, attrs);

        if (L.debug) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                setWebContentsDebuggingEnabled(true);
            }
        }

        setLongClickable(false);
        setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return true;
            }
        });

        WebSettings ws = getSettings();
        ws.setDefaultZoom(WebSettings.ZoomDensity.FAR);
        ws.setAllowContentAccess(true);
        ws.setAllowFileAccess(true);
        ws.setBuiltInZoomControls(false);
        ws.setDefaultTextEncodingName("utf-8");
        ws.setDisplayZoomControls(false);
        ws.setSupportZoom(false);
        ws.setLoadWithOverviewMode(false);

        ws.setJavaScriptEnabled(true);
        ws.setAppCacheEnabled(false);
        ws.setDomStorageEnabled(true);
        ws.setAppCacheMaxSize(1024*1024*80);
        ws.setAppCachePath(context.getCacheDir().getPath());
//        ws.setAllowFileAccess(true);
        ws.setCacheMode(WebSettings.LOAD_DEFAULT);

        addJavascriptInterface(new JavascriptApi(), "AndroidEditor");

        setWebViewClient(new EditorViewClient());
        setWebChromeClient(new EditorViewChromeClient());

        pref = Pref.getInstance(getContext());
        ThemeList.Theme theme = pref.getThemeInfo();
        boolean isDark = false;
        if (theme != null) {
            isDark = theme.isDark;
        }

        String html = null;

        try {
            InputStream is = getContext().getAssets().open("editor.html");
            html = IOUtils.readFile(is, "utf-8");
            is.close();
        } catch (Exception e) {
            L.e(e);
            UIUtils.toast(getContext(), R.string.editor_create_unknown_exception);
            return;
        }

        if (!isDark)
            html = html.replaceAll("<\\!\\-\\-\\{DARK\\-START\\}\\-\\->[\\w\\W]+?<\\!\\-\\-\\{DARK\\-END\\}\\-\\->", "");

        loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", "file:///android_asset/");
        //fix dark theme background spark
        setBackgroundColor(Color.TRANSPARENT);

        pref.registerOnSharedPreferenceChangeListener(this);
        onSharedPreferenceChanged(null, Pref.KEY_FONT_SIZE);
        onSharedPreferenceChanged(null, Pref.KEY_CURSOR_WIDTH);
        onSharedPreferenceChanged(null, Pref.KEY_SHOW_LINE_NUMBER);
        onSharedPreferenceChanged(null, Pref.KEY_WORD_WRAP);
        onSharedPreferenceChanged(null, Pref.KEY_SHOW_WHITESPACE);
        onSharedPreferenceChanged(null, Pref.KEY_TAB_SIZE);
        onSharedPreferenceChanged(null, Pref.KEY_AUTO_INDENT);
        onSharedPreferenceChanged(null, Pref.KEY_AUTO_CAPITALIZE);
        onSharedPreferenceChanged(null, Pref.KEY_INSERT_SPACE_FOR_TAB);
        onSharedPreferenceChanged(null, Pref.KEY_THEME);
        onSharedPreferenceChanged(null, Pref.KEY_TOUCH_TO_ADJUST_TEXT_SIZE);
        enableHighlight(pref.isHighlight());
        setReadOnly(pref.isReadOnly());
    }
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:82,代码来源:EditAreaView.java


注:本文中的com.jecelyin.editor.v2.Pref.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。