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


Java Pref类代码示例

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


Pref类属于com.jecelyin.editor.v2包,在下文中一共展示了Pref类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MenuFactory

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
private MenuFactory(Context context) {
    initAllMenuItem();
    groups = new EnumMap<>(MenuGroup.class);
    List<MenuItemInfo> topList = new ArrayList<>();
    groups.put(MenuGroup.TOP, topList);
    Integer[] toolbarIcons = Pref.getInstance(context).getToolbarIcons();
    if (toolbarIcons == null) {
        toolbarIcons = new Integer[]{R.id.m_new, R.id.m_open, R.id.m_save, R.id.m_undo, R.id.m_redo};
    }

    List<MenuItemInfo> items;
    for (MenuItemInfo item : menuItemInfos) {
        if (isToolbarMenu(toolbarIcons, item.getItemId())) {
            topList.add(item);
            toolbarMenus.put(item.getItemId(), item.getGroupId());
        } else {
            items = groups.get(item.getGroup());
            if(items == null) {
                items = new ArrayList<>();
                groups.put(item.getGroup(), items);
            }
            items.add(item);
        }
    }
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:26,代码来源:MenuFactory.java

示例3: onSharedPreferenceChanged

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
/**
 * 注意registerOnSharedPreferenceChangeListener的listeners是使用WeakHashMap引用的
 * 不能直接registerOnSharedPreferenceChangeListener(new ...) 否则可能监听不起作用
 * @param sharedPreferences
 * @param key
 */
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (mToolbar == null)
        return;
    switch(key) {
        case Pref.KEY_KEEP_SCREEN_ON:
            mToolbar.setKeepScreenOn(sharedPreferences.getBoolean(key, false));
            break;
        case Pref.KEY_ENABLE_HIGHLIGHT:
            Command command = new Command(Command.CommandEnum.ENABLE_HIGHLIGHT);
            command.object = pref.isHighlight();
            doClusterCommand(command);
            break;
        case Pref.KEY_SCREEN_ORIENTATION:
            setScreenOrientation();
            break;
        case Pref.KEY_PREF_ENABLE_DRAWERS:
            mDrawerLayout.setDrawerLockMode(pref.isEnabledDrawers() ? TranslucentDrawerLayout.LOCK_MODE_UNDEFINED : TranslucentDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
            break;
        case Pref.KEY_READ_ONLY:
            mSymbolBarLayout.setVisibility(pref.isReadOnly() ? View.GONE : View.VISIBLE);
            break;
    }
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:31,代码来源:MainActivity.java

示例4: onSaveInstanceState

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
public Parcelable onSaveInstanceState() {
    SavedState ss = savedState;
    if (document != null) {
        document.onSaveInstanceState(ss);
    }

    if (loaded && !disableAutoSave && document != null && document.getFile() != null && Pref.getInstance(context).isAutoSave()) {
        int newOrientation = context.getResources().getConfiguration().orientation;
        if (orientation != newOrientation) {
            orientation = newOrientation;
        } else {
            document.save();
        }
    }

    return ss;
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:18,代码来源:EditorDelegate.java

示例5: closeAllTabAndExitApp

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
public boolean closeAllTabAndExitApp() {
    EditorDelegate.setDisableAutoSave(true);
    exitApp = true;
    if (mainActivity.mTabPager != null) {
        Pref.getInstance(mainActivity).setLastTab(getCurrentTab());
    }
    return editorAdapter.removeAll(new TabCloseListener() {
        @Override
        public void onClose(String path, String encoding, int line, int column) {
            DBHelper.getInstance(mainActivity).updateRecentFile(path, encoding, line, column);
            int count = getTabCount();
            if (count == 0) {
                mainActivity.finish();
            } else {
                editorAdapter.removeAll(this);
            }
        }
    });
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:20,代码来源:TabManager.java

示例6: onCreate

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Pref.getInstance(this).setReadOnly(false);
    setPref(Pref.KEY_PREF_KEEP_BACKUP_FILE, false);

}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:8,代码来源:Editor920Activity.java

示例7: setPref

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
private void setPref(String key, Object value) {
    try {
        Field field = Pref.class.getDeclaredField("map");
        field.setAccessible(true);
        ((Map) field.get(Pref.getInstance(this))).put(key, value);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:10,代码来源:Editor920Activity.java

示例8: 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

示例9: onDestroyView

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
@Override
public void onDestroyView() {
    super.onDestroyView();
    Pref.getInstance(getContext()).unregisterOnSharedPreferenceChangeListener(this);
    if (action != null) {
        action.destroy();
    }

}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:FileListPagerFragment.java

示例10: 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

示例11: isChecked

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
public static boolean isChecked(Context context, int id) {
    switch (id) {
        case R.id.m_readonly:
            return Pref.getInstance(context).isReadOnly();
        case R.id.m_fullscreen:
            return Pref.getInstance(context).isFullScreenMode();
    }
    return false;
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:10,代码来源:MenuFactory.java

示例12: 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

示例13: bindPreferences

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
private void bindPreferences() {
    mDrawerLayout.setKeepScreenOn(pref.isKeepScreenOn());
    mSymbolBarLayout.setVisibility(pref.isReadOnly() ? View.GONE : View.VISIBLE);

    onSharedPreferenceChanged(null, Pref.KEY_PREF_ENABLE_DRAWERS);
    pref.registerOnSharedPreferenceChangeListener(this);
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:8,代码来源:MainActivity.java

示例14: setScreenOrientation

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
private void setScreenOrientation() {
    int orgi = pref.getScreenOrientation();

    if (Pref.SCREEN_ORIENTATION_AUTO == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if(Pref.SCREEN_ORIENTATION_LANDSCAPE == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if(Pref.SCREEN_ORIENTATION_PORTRAIT == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:12,代码来源:MainActivity.java

示例15: init

import com.jecelyin.editor.v2.Pref; //导入依赖的package包/类
private void init() {
        if (document != null)
            return;

        document = new Document(context, this);
        mEditText.setReadOnly(Pref.getInstance(context).isReadOnly());
        mEditText.setCustomSelectionActionModeCallback(new EditorSelectionActionModeCallback());

        //还原文本时,onTextChange事件触发高亮
//        if (savedState.editorState != null) {
//            document.onRestoreInstanceState(savedState);
//            mEditText.onRestoreInstanceState(savedState.editorState);
//        } else
        if (savedState.file != null) {
            document.loadFile(savedState.file, savedState.encoding);
        } else if (!TextUtils.isEmpty(savedState.text)) {
            mEditText.setText(null, savedState.text);
        }

        mEditText.addTextChangedListener(this);

        // 更新标题
        noticeDocumentChanged();

        if (!AppUtils.verifySign(context)) {
            mEditText.setText(null, context.getString(R.string.verify_sign_failure));
        }

        if (savedState.object != null) {
            EditorObjectProcessor.process(savedState.object, this);
        }
    }
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:33,代码来源:EditorDelegate.java


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