Search in sources :

Example 1 with EhApplication

use of com.hippo.ehviewer.EhApplication in project EhViewer by seven332.

the class MainActivity method onCreate2.

@Override
protected void onCreate2(@Nullable Bundle savedInstanceState) {
    setContentView(R.layout.activity_main);
    mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(this, R.id.draw_view);
    mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
    mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
    View headerLayout = mNavView.getHeaderView(0);
    mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
    mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
    mChangeTheme = (Button) ViewUtils.$$(this, R.id.change_theme);
    mDrawerLayout.setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    // Pre-L need shadow drawable
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_right, Gravity.RIGHT);
    }
    updateProfile();
    if (mNavView != null) {
        mNavView.setNavigationItemSelectedListener(this);
    }
    mChangeTheme.setText(getThemeText());
    mChangeTheme.setOnClickListener(v -> {
        Settings.putTheme(getNextTheme());
        ((EhApplication) getApplication()).recreate();
    });
    if (savedInstanceState == null) {
        onInit();
        CommonOperations.checkUpdate(this, false);
        checkDownloadLocation();
        if (Settings.getCellularNetworkWarning()) {
            checkCellularNetwork();
        }
    } else {
        onRestore(savedInstanceState);
    }
    EhTagDatabase.update(this);
}
Also used : EhApplication(com.hippo.ehviewer.EhApplication) View(android.view.View) LoadImageView(com.hippo.widget.LoadImageView) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView)

Example 2 with EhApplication

use of com.hippo.ehviewer.EhApplication in project EhViewer by seven332.

the class GalleryDetailScene method prepareData.

private boolean prepareData() {
    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    if (mGalleryDetail != null) {
        return true;
    }
    long gid = getGid();
    if (gid == -1) {
        return false;
    }
    // Get from cache
    mGalleryDetail = EhApplication.getGalleryDetailCache(context).get(gid);
    if (mGalleryDetail != null) {
        return true;
    }
    EhApplication application = (EhApplication) context.getApplicationContext();
    if (application.containGlobalStuff(mRequestId)) {
        // request exist
        return true;
    }
    // Do request
    return request();
}
Also used : Context(android.content.Context) EhApplication(com.hippo.ehviewer.EhApplication)

Example 3 with EhApplication

use of com.hippo.ehviewer.EhApplication in project EhViewer by seven332.

the class TaskPreference method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state == null || !state.getClass().equals(SavedState.class)) {
        // Didn't save state for us in onSaveInstanceState
        super.onRestoreInstanceState(state);
        return;
    }
    SavedState myState = (SavedState) state;
    mTaskId = myState.asyncTaskId;
    if (IntIdGenerator.INVALID_ID != mTaskId) {
        Object o = ((EhApplication) getContext().getApplicationContext()).getGlobalStuff(mTaskId);
        if (o instanceof Task) {
            mTask = (Task) o;
            mTask.setPreference(this);
        }
    }
    if (null == mTask) {
        mTaskId = IntIdGenerator.INVALID_ID;
    }
    // TODO if not task, show not reopen dialog
    super.onRestoreInstanceState(myState.getSuperState());
}
Also used : AbsSavedState(androidx.customview.view.AbsSavedState) AsyncTask(android.os.AsyncTask) EhApplication(com.hippo.ehviewer.EhApplication)

Example 4 with EhApplication

use of com.hippo.ehviewer.EhApplication in project EhViewer by seven332.

the class SpiderQueen method obtainSpiderQueen.

@UiThread
public static SpiderQueen obtainSpiderQueen(@NonNull Context context, @NonNull GalleryInfo galleryInfo, @Mode int mode) {
    OSUtils.checkMainLoop();
    SpiderQueen queen = sQueenMap.get(galleryInfo.gid);
    if (queen == null) {
        EhApplication application = (EhApplication) context.getApplicationContext();
        queen = new SpiderQueen(application, galleryInfo);
        sQueenMap.put(galleryInfo.gid, queen);
        // Set mode
        queen.setMode(mode);
        queen.start();
    } else {
        // Set mode
        queen.setMode(mode);
    }
    return queen;
}
Also used : EhApplication(com.hippo.ehviewer.EhApplication) UiThread(androidx.annotation.UiThread)

Example 5 with EhApplication

use of com.hippo.ehviewer.EhApplication in project EhViewer by seven332.

the class SignInScene method onCreateView2.

@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_login, container, false);
    View loginForm = ViewUtils.$$(view, R.id.login_form);
    mProgress = ViewUtils.$$(view, R.id.progress);
    mUsernameLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.username_layout);
    mUsername = mUsernameLayout.getEditText();
    AssertUtils.assertNotNull(mUsername);
    mPasswordLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.password_layout);
    mPassword = mPasswordLayout.getEditText();
    AssertUtils.assertNotNull(mPassword);
    mRegister = ViewUtils.$$(loginForm, R.id.register);
    mSignIn = ViewUtils.$$(loginForm, R.id.sign_in);
    mSignInViaWebView = (TextView) ViewUtils.$$(loginForm, R.id.sign_in_via_webview);
    mSignInViaCookies = (TextView) ViewUtils.$$(loginForm, R.id.sign_in_via_cookies);
    mSkipSigningIn = (TextView) ViewUtils.$$(loginForm, R.id.skip_signing_in);
    mSignInViaWebView.setPaintFlags(mSignInViaWebView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    mSignInViaCookies.setPaintFlags(mSignInViaCookies.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    mSkipSigningIn.setPaintFlags(mSignInViaCookies.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    mPassword.setOnEditorActionListener(this);
    mRegister.setOnClickListener(this);
    mSignIn.setOnClickListener(this);
    mSignInViaWebView.setOnClickListener(this);
    mSignInViaCookies.setOnClickListener(this);
    mSkipSigningIn.setOnClickListener(this);
    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    EhApplication application = (EhApplication) context.getApplicationContext();
    if (application.containGlobalStuff(mRequestId)) {
        mSigningIn = true;
        // request exist
        showProgress(false);
    }
    return view;
}
Also used : Context(android.content.Context) EhApplication(com.hippo.ehviewer.EhApplication) View(android.view.View) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable)

Aggregations

EhApplication (com.hippo.ehviewer.EhApplication)5 Context (android.content.Context)2 View (android.view.View)2 TextView (android.widget.TextView)2 AsyncTask (android.os.AsyncTask)1 Nullable (androidx.annotation.Nullable)1 UiThread (androidx.annotation.UiThread)1 AbsSavedState (androidx.customview.view.AbsSavedState)1 NavigationView (com.google.android.material.navigation.NavigationView)1 LoadImageView (com.hippo.widget.LoadImageView)1