Skip to content

Commit da0a8d1

Browse files
committed
close all tab method
1 parent 9c7f206 commit da0a8d1

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib-n-ide/src/main/java/com/duy/ide/core/IdeActivity.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,20 @@ public void onClick(View v, String text) {
183183
versionView.setText(SysUtils.getVersionName(this));
184184

185185
initMenuView();
186+
initEditorView();
186187
intiDiagnosticView();
187-
188+
initLeftNavigationView((NavigationView) findViewById(R.id.left_navigation_view));
189+
//final, create editor
190+
processIntent();
188191

189192
//attach listener hide/show keyboard
190193
mKeyBoardListener = new KeyBoardEventListener(this);
191194
mDrawerLayout.getViewTreeObserver().addOnGlobalLayoutListener(mKeyBoardListener);
195+
}
192196

193-
initLeftNavigationView((NavigationView) findViewById(R.id.left_navigation_view));
194-
195-
//final, create editor
197+
private void initEditorView() {
196198
mTabManager = new TabManager(this, (ViewPager) findViewById(R.id.editor_view_pager));
197-
198-
processIntent();
199+
mTabManager.createEditor();
199200
}
200201

201202

lib-n-ide/src/main/java/com/jecelyin/editor/v2/manager/TabManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ public TabManager(@NonNull IdeActivity activity, @NonNull ViewPager viewPager) {
6767
if (mTabLayout != null) {
6868
mTabLayout.setCustomTabView(this);
6969
}
70-
initEditor();
7170
}
7271

73-
private void initEditor() {
72+
public void createEditor() {
7473
mPagerAdapter = new EditorFragmentPagerAdapter(mActivity);
7574
mViewPager.setAdapter(mPagerAdapter);
7675

@@ -152,6 +151,12 @@ public void setCurrentTab(int index) {
152151
updateToolbar();
153152
}
154153

154+
public void closeAllTab() {
155+
while (getTabCount() > 0) {
156+
closeTab(0);
157+
}
158+
}
159+
155160
private void closeTab(int position) {
156161
mPagerAdapter.removeEditor(position, new TabCloseListener() {
157162
@Override

0 commit comments

Comments
 (0)