Commit e467b7b7 authored by Xinghaoxiang's avatar Xinghaoxiang

完成weex插件

parent 02433c29
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 Romain Lespinasse <romain.lespinasse@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
\ No newline at end of file
......@@ -16,17 +16,33 @@
- speechRecognition 语音识别
- ocrRecognition OCR识别
- documentScan 文档扫描
- shareFolder 共享文件夹
- myselfNetDisk 个人网盘
- documentManager 文档管理
- shareFolder 共享文件夹(nextCloud)
- myselfNetDisk 个人网盘 (nextCloud)
- documentManager 文档管理 (nextCloud)
#### Weex端调用方法。
- 添加依赖webfile
- 方法还未提供,暂不能用
- 把sample模块中的 weex包下的文件复制到自己工程下的位置。
- 将下面代码放到WXApplication中onCreate方法内
```
try {
WXSDKEngine.registerModule("chooseNetFile", NetFileChooseModule.class);
} catch (WXException e) {
e.printStackTrace();
}
```
#### 调用方法
```
const choose = requireModule('chooseNetFile')
// 传入 userId, 模块名称(参考上面的类型值), 是否是nextCloudFile true属于 false 不属于, 回调
choose.chooseNetFile(userId,moduleName,isNextCloudFile,function(data){
// TODO
})
```
#### TODO
- 还没有提供出来weex的方法,但是可以先添加webfile进入依赖
- nextCloud三个模块的文件还不可用,后期还需要提供。
......@@ -26,6 +26,19 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile'com.taobao.android:weex_sdk:0.16.0'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
compile 'com.squareup.okio:okio:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.taobao.android:weex_inspector:0.10.0.5'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
compile 'com.taobao.android:weexplugin-loader:1.3'
compile 'com.taobao.android:weexplugin-processor:1.3'
compile 'com.taobao.android:weexplugin-annotation:1.3'
compile "com.alibaba:fastjson:1.1.46.android"
testCompile 'junit:junit:4.12'
compile project(path: ':webfile')
}
......@@ -4,9 +4,9 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".WXApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
......
......@@ -7,7 +7,6 @@ import android.util.Log;
import android.view.View;
import com.bril.webfile.FileActivity;
import com.bril.webfile.NextCloudActivity;
public class MainActivity extends AppCompatActivity {
public static final int FILE_CHOOSE = 0x012;
......@@ -98,21 +97,21 @@ public class MainActivity extends AppCompatActivity {
}
public void shareFolder(View view) {
Intent intent = new Intent(this, NextCloudActivity.class);
Intent intent = new Intent(this, FileActivity.class);
intent.putExtra("userId", "716");
intent.putExtra("moduleName", "shareFolder");
startActivityForResult(intent,FILE_NEXTCLOUD);
}
public void myselfNetDisk(View view) {
Intent intent = new Intent(this, NextCloudActivity.class);
Intent intent = new Intent(this, FileActivity.class);
intent.putExtra("userId", "716");
intent.putExtra("moduleName", "myselfNetDisk");
startActivityForResult(intent,FILE_NEXTCLOUD);
}
public void documentManager(View view) {
Intent intent = new Intent(this, NextCloudActivity.class);
Intent intent = new Intent(this, FileActivity.class);
intent.putExtra("userId", "716");
intent.putExtra("moduleName", "documentManager");
startActivityForResult(intent,FILE_NEXTCLOUD);
......
package com.bril.webfilemodule;
import android.app.Application;
import com.bril.webfilemodule.weex.NetFileChooseModule;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.common.WXException;
/**
* Created by Xinghx on 2018/6/26 0026.
*/
public class WXApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
try {
WXSDKEngine.registerModule("chooseNetFile", NetFileChooseModule.class);
} catch (WXException e) {
e.printStackTrace();
}
}
}
package com.bril.webfilemodule.weex;
import android.content.Intent;
/**
* Created by Xinghx on 2018/6/26 0026.
*/
public interface INetFileChoose {
void notifyActivityResult(int requestCode, int resultCode, Intent data);
void onChooseFile(String userId,String moduleName,boolean isNextCloud,
OnFileNetChooseListener onFileNetChooseListener);
interface OnFileNetChooseListener {
void onNetFileChoose(String fileId,String fileName,String filePath);
void onNextCloudFileChoose(String absolutePath,String filePath);
}
}
package com.bril.webfilemodule.weex;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.bril.webfile.FileActivity;
/**
* Created by Xinghx on 2018/6/26 0026.
*/
public class NetFileChoose implements INetFileChoose{
public static final int FILE_CHOOSE = 0x012;
public static final int FILE_NEXTCLOUD= 0x013;
private Context mContext;
private OnFileNetChooseListener mCallback;
public NetFileChoose(Context mContext) {
this.mContext = mContext;
}
@Override
public void notifyActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
switch (requestCode) {
case FILE_CHOOSE:
String filePath = data.getStringExtra("filePath");
String fileName = data.getStringExtra("fileName");
String fileId = data.getStringExtra("fileId");
mCallback.onNetFileChoose(fileId,fileName,filePath);
break;
case FILE_NEXTCLOUD:
String absolutePath = data.getStringExtra("absolutePath");
String filePaths = data.getStringExtra("filePaths");
mCallback.onNextCloudFileChoose(absolutePath, filePaths);
break;
}
}
}
@Override
public void onChooseFile(String userId,String moduleName,boolean isNextCloud,OnFileNetChooseListener listener) {
mCallback = listener;
Intent intent = new Intent(mContext, FileActivity.class);
intent.putExtra("userId", userId);
intent.putExtra("moduleName", moduleName);
if (isNextCloud) {
((Activity) mContext).startActivityForResult(intent, FILE_NEXTCLOUD);
} else {
((Activity) mContext).startActivityForResult(intent, FILE_CHOOSE);
}
}
}
package com.bril.webfilemodule.weex;
import android.content.Intent;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXModule;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Xinghx on 2018/6/26 0026.
*/
public class NetFileChooseModule extends WXModule {
private INetFileChoose netFileChoose;
@JSMethod
public void chooseNetFile(String userId, String moduleName, boolean isNextCloud, final JSCallback jsCallback) {
netFileChoose = new NetFileChoose(mWXSDKInstance.getContext());
final Map<String, Object> ret = new HashMap<>();
netFileChoose.onChooseFile(userId, moduleName, isNextCloud, new INetFileChoose.OnFileNetChooseListener() {
@Override
public void onNetFileChoose(String fileId, String fileName, String filePath) {
ret.put("fileId", fileId);
ret.put("fileName", fileName);
ret.put("filePath", filePath);
jsCallback.invoke(ret);
}
@Override
public void onNextCloudFileChoose(String absolutePath, String filePath) {
ret.put("fileId", absolutePath);
ret.put("filePath", filePath);
jsCallback.invoke(ret);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
netFileChoose.notifyActivityResult(requestCode, resultCode, data);
}
}
......@@ -5,7 +5,6 @@
<application
android:supportsRtl="true">
<activity android:name=".FileActivity" />
<activity android:name=".NextCloudActivity" />
</application>
</manifest>
......@@ -9,16 +9,26 @@ import android.view.Window;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.bril.webfile.adapter.FileAdapter;
import com.bril.webfile.net.client.FileClient;
import com.bril.webfile.response.ChildrenBeans;
import com.bril.webfile.response.FileResponse;
import com.bril.webfile.response.NextCloudResponse;
import com.bril.webfile.treeview.adapter.SimpleTreeListViewAdapter;
import com.bril.webfile.treeview.adapter.TreeViewAdapter;
import com.bril.webfile.treeview.node.Node;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/6/14
......@@ -32,6 +42,9 @@ public class FileActivity extends AppCompatActivity implements AdapterView.OnIte
private LinearLayout file_img_backs;
private ListView fileLv;
private FileAdapter fileAdapter;
private FileClient fileClient = new FileClient();
private NextCloudResponse cloudResponse;
List<ChildrenBeans> childrenBeansList = new ArrayList<>();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
......@@ -47,9 +60,84 @@ public class FileActivity extends AppCompatActivity implements AdapterView.OnIte
finish();
}
});
launcherMethod();
}
private void launcherMethod() {
String userId = getIntent().getStringExtra("userId");
String moduleName = getIntent().getStringExtra("moduleName");
FileClient fileClient = new FileClient();
String realType = "";
switch (moduleName) {
case "myselfNetDisk":
realType = "1";
chooseNextCloudModule(userId, realType);
break;
case "shareFolder":
realType = "2";
chooseNextCloudModule(userId,realType);
break;
case "documentManager":
realType = "3";
chooseNextCloudModule(userId,realType);
break;
default:
chooseSwaggerModule(userId, moduleName);
break;
}
}
private void chooseNextCloudModule(String userId, String moduleName) {
fileClient.nextCloud(userId, moduleName).enqueue(new Callback<NextCloudResponse>() {
@Override
public void onResponse(Call<NextCloudResponse> call, Response<NextCloudResponse> response) {
try {
cloudResponse = response.body();
List<NextCloudResponse.ListBean> list = response.body().getList();
for (NextCloudResponse.ListBean listBean : list) {
ChildrenBeans childrenBeans = new ChildrenBeans();
String type = listBean.getType();
String name = listBean.getName();
childrenBeans.setName(name);
childrenBeans.setType(type);
childrenBeansList.add(childrenBeans);
addData(listBean.getChildren());
}
SimpleTreeListViewAdapter simpleTreeListViewAdapter
= new SimpleTreeListViewAdapter(fileLv, FileActivity.this, childrenBeansList, 0);
fileLv.setAdapter(simpleTreeListViewAdapter);
simpleTreeListViewAdapter.setOnNodeClickListener(new TreeViewAdapter.OnTreeNodeClickListener() {
@Override
public void onClick(Node node, int position) {
if (node.isFile()) {
Toast.makeText(FileActivity.this, node.getName(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.putExtra("absolutePath", cloudResponse.getAbsolutePath());
intent.putExtra("filePaths", node.getName());
setResult(0x013, intent);
finish();
}
}
});
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<NextCloudResponse> call, Throwable t) {
t.printStackTrace();
}
});
}
private void chooseSwaggerModule(String userId, String moduleName) {
fileClient.fileList(userId, moduleName)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
......@@ -67,42 +155,23 @@ public class FileActivity extends AppCompatActivity implements AdapterView.OnIte
throwable.printStackTrace();
}
});
// fileClient.nextCloud(userId, "2")
// .observeOn(AndroidSchedulers.mainThread())
// .subscribeOn(Schedulers.io())
// .subscribe(new Consumer<NextCloudResponse>() {
// @Override
// public void accept(NextCloudResponse nextCloudResponses) throws Exception {
// List<NextCloudResponse.ListBean> list = nextCloudResponses.getList();
// for (NextCloudResponse.ListBean listBean : list) {
// ChildrenBeans childrenBeans = new ChildrenBeans();
// String type = listBean.getType();
// String name = listBean.getName();
// childrenBeans.setName(name);
// childrenBeans.setType(type);
// childrenBeansList.add(childrenBeans);
// addData(listBean.getChildren());
// }
// Log.d(TAG, "" + childrenBeansList.size());
// for (ChildrenBeans childrenBeans : childrenBeansList) {
// Log.e(TAG, childrenBeans.toString() );
// }
//
// SimpleTreeListViewAdapter simpleTreeListViewAdapter
// = new SimpleTreeListViewAdapter(fileLv, FileActivity.this, childrenBeansList, 1);
// fileLv.setAdapter(simpleTreeListViewAdapter);
//
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// }
// });
}
private void addData(List<NextCloudResponse.ListBean.ChildrenBean> mList) {
for (NextCloudResponse.ListBean.ChildrenBean childrenBean : mList) {
if (childrenBean == null) return;
ChildrenBeans childrenBeans = new ChildrenBeans();
String name = childrenBean.getName();
String type = childrenBean.getType();
childrenBeans.setName(name);
childrenBeans.setType(type);
childrenBeansList.add(childrenBeans);
if (childrenBean.getChildrenBeen() != null) {
addData(childrenBean.getChildrenBeen());
}
}
}
@Override
......
package com.bril.webfile;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.bril.webfile.net.client.FileClient;
import com.bril.webfile.response.ChildrenBeans;
import com.bril.webfile.response.NextCloudResponse;
import com.bril.webfile.treeview.adapter.SimpleTreeListViewAdapter;
import com.bril.webfile.treeview.adapter.TreeViewAdapter;
import com.bril.webfile.treeview.node.Node;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/6/26 0026.
*/
public class NextCloudActivity extends AppCompatActivity {
ListView mTree;
List<ChildrenBeans> childrenBeansList = new ArrayList<>();
private String userId;
private static final String TAG = "NextCloudActivity";
private String moduleName;
private LinearLayout file_img_backs;
private NextCloudResponse cloudResponse;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_layout);
userId = getIntent().getStringExtra("userId");
moduleName = getIntent().getStringExtra("moduleName");
mTree = (ListView) findViewById(R.id.file_lv);
file_img_backs = (LinearLayout) findViewById(R.id.file_img_backs);
file_img_backs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
initData();
}
public void initData() {
String realType = "";
switch (moduleName) {
case "myselfNetDisk":
realType = "1";
break;
case "shareFolder":
realType = "2";
break;
case "documentManager":
realType = "3";
break;
}
FileClient fileClient = new FileClient();
fileClient.nextCloud(userId, realType).enqueue(new Callback<NextCloudResponse>() {
@Override
public void onResponse(Call<NextCloudResponse> call, Response<NextCloudResponse> response) {
try {
cloudResponse = response.body();
List<NextCloudResponse.ListBean> list = response.body().getList();
for (NextCloudResponse.ListBean listBean : list) {
ChildrenBeans childrenBeans = new ChildrenBeans();
String type = listBean.getType();
String name = listBean.getName();
childrenBeans.setName(name);
childrenBeans.setType(type);
childrenBeansList.add(childrenBeans);
addData(listBean.getChildren());
}
for (ChildrenBeans childrenBeans : childrenBeansList) {
Log.e(TAG, childrenBeans.toString() );
}
SimpleTreeListViewAdapter simpleTreeListViewAdapter
= new SimpleTreeListViewAdapter(mTree, NextCloudActivity.this, childrenBeansList, 0);
mTree.setAdapter(simpleTreeListViewAdapter);
simpleTreeListViewAdapter.setOnNodeClickListener(new TreeViewAdapter.OnTreeNodeClickListener() {
@Override
public void onClick(Node node, int position) {
if (node.isFile()) {
Toast.makeText(NextCloudActivity.this, node.getName(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.putExtra("absolutePath",cloudResponse.getAbsolutePath());
intent.putExtra("filePaths", node.getName());
setResult(0x013, intent);
finish();
}
}
});
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<NextCloudResponse> call, Throwable t) {
t.printStackTrace();
}
});
}
private void addData(List<NextCloudResponse.ListBean.ChildrenBean> mList) {
for (NextCloudResponse.ListBean.ChildrenBean childrenBean : mList) {
if (childrenBean == null) return;
ChildrenBeans childrenBeans = new ChildrenBeans();
String name = childrenBean.getName();
String type = childrenBean.getType();
childrenBeans.setName(name);
childrenBeans.setType(type);
childrenBeansList.add(childrenBeans);
if (childrenBean.getChildrenBeen() != null) {
addData(childrenBean.getChildrenBeen());
}
}
}
}
......@@ -14,7 +14,7 @@ import java.util.List;
/**
* Created by Xinghx on 2018/4/11 0011.
* Created by Xinghx on 2018/4/11
*/
public class FileAdapter extends BaseAdapter {
......@@ -66,10 +66,10 @@ public class FileAdapter extends BaseAdapter {
return convertView;
}
class ViewHolder{
private class ViewHolder{
TextView fileName,fileTime;
ImageView file_icon;
public ViewHolder(View view) {
ViewHolder(View view) {
fileName = view.findViewById(R.id.file_name);
fileTime = view.findViewById(R.id.file_time);
file_icon = view.findViewById(R.id.file_icon);
......
......@@ -4,7 +4,7 @@ import com.bril.webfile.treeview.annotation.NodeName;
import com.bril.webfile.treeview.annotation.NodeType;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
public class ChildrenBeans {
......
package com.bril.webfile.response;
/**
* Created by Xinghx on 2018/6/14 0014.
* Created by Xinghx on 2018/6/14
*/
public class FileResponse {
......
package com.bril.webfile.response;
/**
* Created by Xinghx on 2018/6/14 0014.
*/
public class Files {
private String file_content;
private String file_path;
public Files() {
}
public String getFile_content() {
return file_content;
}
public void setFile_content(String file_content) {
this.file_content = file_content;
}
public String getFile_path() {
return file_path;
}
public void setFile_path(String file_path) {
this.file_path = file_path;
}
}
......@@ -13,7 +13,7 @@ import com.bril.webfile.treeview.node.Node;
import java.util.List;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
public class SimpleTreeListViewAdapter extends TreeViewAdapter {
......@@ -45,11 +45,7 @@ public class SimpleTreeListViewAdapter extends TreeViewAdapter {
int i = name.lastIndexOf("/");
String realName = name.substring(i + 1, name.length());
viewHolder.mText.setText(realName);
// if (i == -1) {
// viewHolder.mText.setText(name);
// } else {
//
// }
return convertView;
}
......
......@@ -14,7 +14,7 @@ import com.bril.webfile.treeview.node.Node;
import java.util.List;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
public abstract class TreeViewAdapter<T> extends BaseAdapter{
......@@ -84,7 +84,7 @@ public abstract class TreeViewAdapter<T> extends BaseAdapter{
Node node = mVisiableNodes.get(position);
convertView = getConvertView(node, position, convertView, parent);
// 设置内边距
convertView.setPadding(node.getLevel() * 50 ,3 , 3 ,3);
convertView.setPadding(node.getLevel() * 40 ,3 , 3 ,3);
return convertView;
}
......
......@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
@Target(ElementType.FIELD)
......
package com.bril.webfile.treeview.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Xinghx on 2018/6/25 0025.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface NodePID {
}
......@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
@Target(ElementType.FIELD)
......
......@@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
public class TreeHelper {
......@@ -20,8 +20,6 @@ public class TreeHelper {
/**
* 把用户提供的数据 转为NODE
*
* @param <T>
* @return
*/
public static <T> List<Node> convertData2Nodes(List<T> datas) throws IllegalAccessException {
List<Node> nodes = new ArrayList<>();
......@@ -54,18 +52,15 @@ public class TreeHelper {
for (int j = i + 1; j < nodes.size(); j++) {
Node m = nodes.get(j);
Log.d(TAG, "" + m.getName() + " " + n.getName());
String aaa = m.getName();
String bbb = n.getName();
if (aaa.lastIndexOf("/") != -1) {
aaa = aaa.substring(0, aaa.lastIndexOf("/"));
String mName = m.getName();
if (mName.lastIndexOf("/") != -1) {
mName = mName.substring(0, mName.lastIndexOf("/"));
}
if (aaa.equals(n.getName()) && n.isFolder()) {
Log.d(TAG, "convertData2Nodes: " + m.getName() + " " + n.getName());
if (mName.equals(n.getName()) && n.isFolder()) {
n.getChildren().add(m);
m.setParent(n);
} else if (n.getName().equals(aaa) && m.isFolder()) {
Log.d(TAG, "convertData2Nodes else : " + m.getName() + " " + n.getName());
} else if (n.getName().equals(mName) && m.isFolder()) {
m.getChildren().add(n);
n.setParent(m);
}
......@@ -75,38 +70,13 @@ public class TreeHelper {
for (Node n : nodes) {
setNodeIcons(n);
}
//方法2
// for (int i = 0; i < datas.size(); i++) {
// Node n = nodes.get(i);
// for (int j = i + 1; j < nodes.size(); j++) {
// Node m = nodes.get(j);
// if (m.getpId() instanceof String) {
// if (m.getpId().equals(n.getId())) {
// n.getChildren().add(m);
// m.setParent(n);
// } else if (m.getId().equals(n.getpId())) {
// m.getChildren().add(n);
// n.setParent(m);
// }
// } else {
// if (m.getpId() == n.getId()) {
// n.getChildren().add(m);
// m.setParent(n);
// } else if (m.getId() == n.getpId()) {
// m.getChildren().add(n);
// n.setParent(m);
// }
// }
// }
return nodes;
}
/**
* 为node设置图标
*
* @param n
* @param n 节点
*/
public static void setNodeIcons(Node n) {
if (n.getChildren().size() > 0 && n.isExpand() && n.isFolder()) {
......@@ -119,9 +89,9 @@ public class TreeHelper {
}
}
public static <T> List<Node> getSortedNodes(List<T> datas,int defaultExpandLevel) throws IllegalAccessException {
public static <T> List<Node> getSortedNodes(List<T> data,int defaultExpandLevel) throws IllegalAccessException {
List<Node> result = new ArrayList<>();
List<Node> nodes = convertData2Nodes(datas);
List<Node> nodes = convertData2Nodes(data);
List<Node> rootNodes = getRootNodes(nodes);
......@@ -138,11 +108,11 @@ public class TreeHelper {
/**
* 从所有节点中过滤出根节点
*
* @param nodes
* @param nodes 节点
* @return
*/
private static List<Node> getRootNodes(List<Node> nodes) {
List<Node> root = new ArrayList<Node>();
List<Node> root = new ArrayList<>();
for (Node node : nodes) {
if (node.isRoot()) {
root.add(node);
......@@ -171,11 +141,11 @@ public class TreeHelper {
/**
* 过滤出可见的节点
*
* @param nodes
* @param nodes 节点
* @return
*/
public static List<Node> filterVisibleNodes(List<Node> nodes) {
List<Node> result = new ArrayList<Node>();
List<Node> result = new ArrayList<>();
for (Node node : nodes) {
if (node.isRoot() || node.isParentExpand()) {
......
......@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Xinghx on 2018/6/25 0025.
* Created by Xinghx on 2018/6/25
*/
public class Node {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment