-
-
Save LAHomieJob/aa81ae68309d73e2fa73319c1b46c5d5 to your computer and use it in GitHub Desktop.
Cicerone problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SplashActivity extends BaseActivity implements SplashActivityView { | |
private ProgressBar progressBar; | |
@Inject | |
@InjectPresenter | |
SplashActivityPresenter presenter; | |
@ProvidePresenter | |
SplashActivityPresenter providePresenter() { | |
return presenter; | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_splash); | |
progressBar = findViewById(R.id.progressBar); | |
DI.INSTANCE.componentManager().appComponent().inject(this); | |
// устанавливает задержку экрана заставки на 1 секунду | |
presenter.onForwardWithDelayCommandClick(); | |
} | |
@Override | |
public void showProgressBar() { | |
progressBar.setVisibility(View.VISIBLE); | |
} | |
@NotNull | |
@Override | |
protected Navigator getNavigator() { | |
return new Navigator() { | |
@Override | |
public void applyCommands(Command[] commands) { | |
for (Command command : commands) { | |
applyCommand(command); | |
} | |
} | |
private void applyCommand(Command command) { | |
if (command instanceof Replace) { | |
switch (((Replace) command).getScreenKey()) { | |
case Constants.BOTTOM_NAVIGATION_SCREEN: | |
startActivity(new Intent(SplashActivity.this, | |
BottomNavigationActivity.class)); | |
break; | |
} | |
} | |
} | |
}; | |
} | |
} | |
@InjectViewState | |
class SplashActivityPresenter(private val router: Router) : BasePresenter<SplashActivityView>(router) { | |
private val executorService: ScheduledExecutorService = | |
Executors.newSingleThreadScheduledExecutor() | |
private lateinit var future: ScheduledFuture<*> | |
/** | |
* Переход на главный экран с нижней навигацией | |
* */ | |
fun onForwardWithDelayCommandClick() { | |
viewState.showProgressBar() | |
future = executorService.schedule({ | |
Handler(Looper.getMainLooper()).post( | |
Runnable { router.replaceScreen(Constants.BOTTOM_NAVIGATION_SCREEN) } | |
) | |
}, 1, TimeUnit.SECONDS) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment