Skip to content

Commit

Permalink
code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ig-v-k committed Apr 7, 2024
1 parent 58469ac commit 695da16
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 1 deletion.
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added libs/classes.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion rroute.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/home/iw/Android/Sdk/platforms/android-34/android.jar!/" />
<root url="jar://$MODULE_DIR$/libs/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/iw/rroute/Facet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.iw.rroute;

import androidx.fragment.app.Fragment;

public interface Facet {
Fragment fragment();
String tag();
}
7 changes: 7 additions & 0 deletions src/main/java/com/iw/rroute/Route.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.iw.rroute;

public interface Route {
void forward(final Facet facet);
void back();
void replace(final Facet facet);
}
38 changes: 38 additions & 0 deletions src/main/java/com/iw/rroute/route/BaseRoute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.iw.rroute.route;

import androidx.fragment.app.FragmentManager;
import com.iw.rroute.Facet;
import com.iw.rroute.Route;

public final class BaseRoute implements Route {
private final FragmentManager manager;
private final int container;

public BaseRoute(FragmentManager manager, int container) {
this.manager = manager;
this.container = container;
}

@Override
public void forward(Facet facet) {
manager.beginTransaction()
.setReorderingAllowed(true)
.addToBackStack(facet.tag())
.add(container, facet.fragment(), facet.tag())
.commit();
}

@Override
public void back() {
manager.popBackStack();
}

@Override
public void replace(Facet facet) {
manager.popBackStack();
manager.beginTransaction()
.setReorderingAllowed(false)
.replace(container, facet.fragment(), facet.tag())
.commit();
}
}

0 comments on commit 695da16

Please sign in to comment.