Skip to content

Commit

Permalink
fix: Fix FragmentAdapter component
Browse files Browse the repository at this point in the history
fixed FragmentAdapter component that duplicates when it is used more than once.
  • Loading branch information
hasrat-ali committed Dec 2, 2021
1 parent 3395666 commit 60aa166
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/a/a/a/Lx.java
Expand Up @@ -1154,6 +1154,9 @@ public static String b(String componentNameId, String componentName, String... p

case "RewardedVideoAd":
return componentName + " = MobileAds.getRewardedVideoAdInstance(this);";

case "FragmentStatePagerAdapter":
return componentName + " = new " + a(componentName + "Fragment") + "(getApplicationContext(), getSupportFragmentManager());";

default:
return ManageEventComponent.b(componentNameId, componentName);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/a/a/a/mq.java
Expand Up @@ -141,7 +141,7 @@ public static String a(int componentId) {
return "Notification";

case 27:
return "#";
return "FragmentStatePagerAdapter";

case 28:
return "PhoneAuthProvider.OnVerificationStateChangedCallbacks";
Expand Down Expand Up @@ -849,7 +849,6 @@ public static String e(String typeName) {
return "Notification";

case "FragmentAdapter":
//Why was Hash (#) here?
return "FragmentStatePagerAdapter";

case "Context":
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/mod/agus/jcoderz/editor/event/ManageEvent.java
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;

import a.a.a.Gx;
import a.a.a.Lx;
import mod.hilal.saif.events.EventsHandler;

public class ManageEvent {
Expand Down Expand Up @@ -1103,15 +1104,20 @@ public static String g(String listenerName, String targetId, String listenerLogi
"};";

case "FragmentStatePagerAdapter":
return "public class MyFragmentAdapter extends FragmentStatePagerAdapter {\r\n" +
String className = Lx.a(targetId + "Fragment");
return "public class " + className +" extends FragmentStatePagerAdapter {\r\n" +
"// This class is deprecated, you should migrate to ViewPager2:\r\n" +
"// https://developer.android.com/reference/androidx/viewpager2/widget/ViewPager2\r\n" +
"Context context;\r\n" +
"int tabCount;\r\n" +
"\r\n" +
"public MyFragmentAdapter(Context context, FragmentManager manager, int tabCount) {\r\n" +
"public " + className + "(Context context, FragmentManager manager) {\r\n" +
"super(manager);\r\n" +
"this.context = context;\r\n" +
"}\r\n" +
"\r\n" +
"@Override\r\n" +
"public int setTabCount(int tabCount) {\r\n" +
"this.tabCount = tabCount;\r\n" +
"}\r\n" +
"\r\n" +
Expand Down

2 comments on commit 60aa166

@Poissac9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After installing the last Sk Pro release
Errors :

The method setTabCount(int) is undefined for the type FragmentStatePagerAdapter

MyFragmentAdapter cannot be resolved to a type

@rexluciano
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest builds change it's method. The new method is:

FaFragmentAdapter fa = new FaFragmentAdapter(getApplicationContext(), getSupportFragmentManager());
viewpager1.setAdapter(fa);
fa.setTabCount(3);
//fa is your FragmentManager Component name.

Please sign in to comment.