Search in sources :

Example 16 with BasePresenter

use of com.mxt.anitrend.presenter.base.BasePresenter in project anitrend-app by AniTrend.

the class WebTokenRequest method getToken.

/**
 * Request a new token if the application has not been authenticated,
 * other wise request a new refresh token and replace the current token
 * retaining the refresh token key
 */
public static void getToken(Context context) {
    synchronized (lock) {
        if (new ApplicationPref(context).isAuthenticated()) {
            BasePresenter presenter = new BasePresenter(context);
            if (token == null || token.getExpires() < (System.currentTimeMillis() / 1000L)) {
                token = presenter.getDatabase().getWebToken();
                checkTokenState(context, presenter);
            }
        }
    }
}
Also used : ApplicationPref(com.mxt.anitrend.util.ApplicationPref) BasePresenter(com.mxt.anitrend.presenter.base.BasePresenter)

Example 17 with BasePresenter

use of com.mxt.anitrend.presenter.base.BasePresenter in project anitrend-app by AniTrend.

the class NotificationSyncTask method onHandleInit.

private void onHandleInit(Context context) {
    presenter = new BasePresenter(context);
    if (presenter.getApplicationPref().isAuthenticated()) {
        UserModel requestModel = WebFactory.createService(UserModel.class, context);
        checkNotificationCount(requestModel);
    } else {
        JobSchedulerUtil.cancelJob(context);
        Log.e(TAG, "JobDispatcher has been unscheduled to avoid posting of notification while the user is not authenticated.");
    }
}
Also used : UserModel(com.mxt.anitrend.model.api.retro.anilist.UserModel) BasePresenter(com.mxt.anitrend.presenter.base.BasePresenter)

Example 18 with BasePresenter

use of com.mxt.anitrend.presenter.base.BasePresenter in project anitrend-app by AniTrend.

the class BottomSheetBase method onCreate.

/**
 * Set up your custom bottom sheet and check for arguments if any
 */
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    TAG = this.toString();
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mTitle = getArguments().getInt(KeyUtil.arg_title);
        mText = getArguments().getInt(KeyUtil.arg_text);
        mPositive = getArguments().getInt(KeyUtil.arg_positive_text);
        mNegative = getArguments().getInt(KeyUtil.arg_negative_text);
    }
    presenter = new BasePresenter(getContext());
}
Also used : BasePresenter(com.mxt.anitrend.presenter.base.BasePresenter)

Example 19 with BasePresenter

use of com.mxt.anitrend.presenter.base.BasePresenter in project anitrend-app by AniTrend.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    setPresenter(new BasePresenter(getApplicationContext()));
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    if (savedInstanceState == null)
        redirectShortcut = getIntent().getIntExtra(KeyUtil.arg_redirect, 0);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) BasePresenter(com.mxt.anitrend.presenter.base.BasePresenter)

Example 20 with BasePresenter

use of com.mxt.anitrend.presenter.base.BasePresenter in project anitrend-app by AniTrend.

the class SplashActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    ButterKnife.bind(this);
    setPresenter(new BasePresenter(this));
    setViewModel(true);
}
Also used : BasePresenter(com.mxt.anitrend.presenter.base.BasePresenter)

Aggregations

BasePresenter (com.mxt.anitrend.presenter.base.BasePresenter)39 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 CommonPresenter (com.mxt.anitrend.base.custom.presenter.CommonPresenter)1 BaseModel (com.mxt.anitrend.model.api.retro.anilist.BaseModel)1 UserModel (com.mxt.anitrend.model.api.retro.anilist.UserModel)1 Genre (com.mxt.anitrend.model.entity.anilist.Genre)1 ApplicationPref (com.mxt.anitrend.util.ApplicationPref)1 IOException (java.io.IOException)1 List (java.util.List)1