Giter Club home page Giter Club logo

xcricheditor's Introduction

XCRichEditor

An Android Rich Text Editor which uses RecyclerView- 一个Android 图片混排富文本编辑器控件(仿兴趣部落)

效果演示图:

iamge

使用方法:

public class MainActivity extends Activity {

private XCRichEditor mRichEditor;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Fresco.initialize(this);
    findViewById(R.id.add_pic).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addPic();
        }
    });
    mRichEditor = (XCRichEditor) findViewById(R.id.richEditor);
}

private void addPic() {
    Intent intent = new Intent(MainActivity.this, LocalAlbum.class);
    startActivityForResult(intent, ImageUtils.REQUEST_CODE_GETIMAGE_BYCROP);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.e("czm","requestCode="+requestCode);
    

    switch (requestCode) {
        case ImageUtils.REQUEST_CODE_GETIMAGE_BYCROP:
            if (LocalImageHelper.getInstance().isResultOk()) {
                LocalImageHelper.getInstance().setResultOk(false);
                //获取选中的图片
                List<LocalImageHelper.LocalFile> files = LocalImageHelper.getInstance().getCheckedItems();
                Log.e("czm","file size="+files.size());
                List<EditItem> items = new ArrayList<>();
                for (int i = 0; i < files.size(); i++) {
                    Log.e("czm","file uri="+files.get(i).getOriginalUri());
                    Log.e("czm","file getThumbnailUri="+files.get(i).getThumbnailUri());
                    EditItem item = new EditItem();
                    item.setUri(Uri.parse(files.get(i).getOriginalUri()));
                    item.setType(1);
                    item.setContent(files.get(i).getOriginalUri());
                    items.add(item);
                }
                mRichEditor.addImage(items);
                //清空选中的图片
                files.clear();
                //设置当前选中的图片数量
                LocalImageHelper.getInstance().setCurrentSize(files.size());
            }
            //清空选中的图片
            LocalImageHelper.getInstance().getCheckedItems().clear();
            break;
        default:
            break;
    }
}

}

xcricheditor's People

Contributors

jczmdeveloper avatar

Watchers

James Cloos avatar ZYLiang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.