Java Code Examples for android.content.res.Configuration#UI_MODE_NIGHT_MASK

The following examples show how to use android.content.res.Configuration#UI_MODE_NIGHT_MASK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinphonePreferences.java    From linphone-android with GNU General Public License v3.0 6 votes vote down vote up
public boolean isDarkModeEnabled() {
    if (getConfig() == null) return false;
    if (!mContext.getResources().getBoolean(R.bool.allow_dark_mode)) return false;

    boolean useNightModeDefault =
            AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES;
    if (mContext != null) {
        int nightMode =
                mContext.getResources().getConfiguration().uiMode
                        & Configuration.UI_MODE_NIGHT_MASK;
        if (nightMode == Configuration.UI_MODE_NIGHT_YES) {
            useNightModeDefault = true;
        }
    }

    return getConfig().getBool("app", "dark_mode", useNightModeDefault);
}
 
Example 2
Source File: MainActivity.java    From SkinSprite with MIT License 6 votes vote down vote up
@Override
public void onClick(View view) {
    int currentNightMode = getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_NIGHT_MASK;
    switch (currentNightMode) {
        case Configuration.UI_MODE_NIGHT_NO: {
            setDayNightMode(AppCompatDelegate.MODE_NIGHT_YES);
            // Night mode is not active, we're in day time
            break;
        }
        case Configuration.UI_MODE_NIGHT_YES:{
            setDayNightMode(AppCompatDelegate.MODE_NIGHT_NO);
            // Night mode is active, we're at night!
            break;
        }
        case Configuration.UI_MODE_NIGHT_UNDEFINED: {
            // We don't know what mode we're in, assume notnight
        }
    }
}
 
Example 3
Source File: StoreTabWidgetsGridRecyclerFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
public Observable<List<Displayable>> parseDisplayables(GetStoreWidgets getStoreWidgets) {
  int currentNightMode = getContext().getResources()
      .getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;

  boolean isDarkTheme = currentNightMode == Configuration.UI_MODE_NIGHT_YES;

  return Observable.from(getStoreWidgets.getDataList()
      .getList())
      .concatMapEager(wsWidget -> {
        AptoideApplication application =
            (AptoideApplication) getContext().getApplicationContext();
        return DisplayablesFactory.parse(marketName, wsWidget, storeTheme, storeRepository,
            storeCredentialsProvider, storeContext, getContext(), accountManager, storeUtilsProxy,
            (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE),
            getContext().getResources(), installedRepository, storeAnalytics, storeTabNavigator,
            navigationTracker, new BadgeDialogFactory(getActivity(), themeManager),
            ((ActivityResultNavigator) getContext()).getFragmentNavigator(),
            application.getBodyInterceptorPoolV7(), application.getDefaultClient(),
            WebService.getDefaultConverter(), application.getTokenInvalidator(),
            application.getDefaultSharedPreferences(), themeManager);
      })
      .toList()
      .first();
}
 
Example 4
Source File: MainActivity.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    int uiMode = getResources().getConfiguration().uiMode;
    int dayNightUiMode = uiMode & Configuration.UI_MODE_NIGHT_MASK;
    if (dayNightUiMode == Configuration.UI_MODE_NIGHT_NO) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    } else if (dayNightUiMode == Configuration.UI_MODE_NIGHT_YES) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
    }
}
 
Example 5
Source File: MainActivity.java    From Toutiao with Apache License 2.0 5 votes vote down vote up
@Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        int id = item.getItemId();
        switch (id) {
//            case R.id.nav_account:
//                drawer_layout.closeDrawers();
//                return false;

            case R.id.nav_switch_night_mode:
                int mode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
                if (mode == Configuration.UI_MODE_NIGHT_YES) {
                    SettingUtil.getInstance().setIsNightMode(false);
                    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
                } else {
                    SettingUtil.getInstance().setIsNightMode(true);
                    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                }
                getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
                recreate();
                return false;

            case R.id.nav_setting:
                startActivity(new Intent(this, SettingActivity.class));
                drawer_layout.closeDrawers();
                return false;

            case R.id.nav_share:
                Intent shareIntent = new Intent()
                        .setAction(Intent.ACTION_SEND)
                        .setType("text/plain")
                        .putExtra(Intent.EXTRA_TEXT, getString(R.string.share_app_text) + getString(R.string.source_code_url));
                startActivity(Intent.createChooser(shareIntent, getString(R.string.share_to)));
                drawer_layout.closeDrawers();
                return false;
        }
        return false;
    }
 
Example 6
Source File: ApplicationPreferences.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
static String applicationTheme(Context context, boolean useNightMode) {
    synchronized (PPApplication.applicationPreferencesMutex) {
        if (applicationTheme == null)
            applicationTheme(context);
        String _applicationTheme = applicationTheme;
        if (_applicationTheme.equals("light") ||
                _applicationTheme.equals("material") ||
                _applicationTheme.equals("color") ||
                _applicationTheme.equals("dlight")) {
            String defaultValue = "white";
            if (Build.VERSION.SDK_INT >= 28)
                defaultValue = "night_mode";
            _applicationTheme = defaultValue;
            SharedPreferences.Editor editor = ApplicationPreferences.getSharedPreferences(context).edit();
            editor.putString(ApplicationPreferences.PREF_APPLICATION_THEME, _applicationTheme);
            editor.apply();
            applicationTheme = _applicationTheme;
        }
        if (_applicationTheme.equals("night_mode") && useNightMode) {
            int nightModeFlags =
                    context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
            switch (nightModeFlags) {
                case Configuration.UI_MODE_NIGHT_YES:
                    _applicationTheme = "dark";
                    break;
                case Configuration.UI_MODE_NIGHT_NO:
                case Configuration.UI_MODE_NIGHT_UNDEFINED:
                    _applicationTheme = "white";
                    break;
            }
        }
        return _applicationTheme;
    }
}
 
Example 7
Source File: ThemeManager.java    From zephyr with MIT License 5 votes vote down vote up
@Theme
@Override
public int getCurrentTheme() {
    int currentNightMode = mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
    switch (currentNightMode) {
        case Configuration.UI_MODE_NIGHT_NO:
            return Theme.LIGHT;
        case Configuration.UI_MODE_NIGHT_YES:
        case Configuration.UI_MODE_NIGHT_UNDEFINED:
        default:
            return Theme.DARK;
    }
}
 
Example 8
Source File: SearchPostSortTypeBottomSheetFragment.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false);
    ButterKnife.bind(this, rootView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
            && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
        rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
    }

    relevanceTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name());
        dismiss();
    });

    hotTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name());
        dismiss();
    });

    topTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
        dismiss();
    });

    newTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW));
        dismiss();
    });

    commentsTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.COMMENTS.name());
        dismiss();
    });

    return rootView;
}
 
Example 9
Source File: PostTypeBottomSheetFragment.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_post_type_bottom_sheet, container, false);
    ButterKnife.bind(this, rootView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
            && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
        rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
    }

    textTypeTextView.setOnClickListener(view -> {
        ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT);
        dismiss();
    });

    linkTypeTextView.setOnClickListener(view -> {
        ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_LINK);
        dismiss();
    });

    imageTypeTextView.setOnClickListener(view -> {
        ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_IMAGE);
        dismiss();
    });

    videoTypeTextView.setOnClickListener(view -> {
        ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO);
        dismiss();
    });

    return rootView;
}
 
Example 10
Source File: EmbeddedNavigationActivity.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
private int getCurrentNightMode() {
  return getResources().getConfiguration().uiMode
    & Configuration.UI_MODE_NIGHT_MASK;
}
 
Example 11
Source File: BaseActivity.java    From OneText_For_Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sharedPreferences = getSharedPreferences("setting", MODE_PRIVATE);
    editor = sharedPreferences.edit();
    //Q导航栏沉浸
    rootview = findViewById(android.R.id.content);

    /*ViewCompat.setOnApplyWindowInsetsListener(getWindow().getDecorView(), new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            v.setPadding(0,0,0,insets.getSystemWindowInsetBottom());
            return insets;
        }
    });*/
    //状态栏icon黑色
    int mode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
    if (mode == Configuration.UI_MODE_NIGHT_NO) {
        this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
    }
    rootview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    ViewCompat.setOnApplyWindowInsetsListener(rootview, new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            rootview.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0);
            return insets;
        }
    });
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        //rootView.setFitsSystemWindows(true);
        //rootView.setPadding(0,0,0,getNavigationBarHeight());
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
    //rootView.setFitsSystemWindows(true);
    /*if ((Build.VERSION.SDK_INT<Build.VERSION_CODES.Q)|(getNavigationBarHeight()>dp2px(16))) {
        //rootView.setPadding(0,0,0,getNavigationBarHeight());
        if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O){
            //rootView.setFitsSystemWindows(true);
            rootView.setPadding(0,0,0,getNavigationBarHeight());
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }else {
            //rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            //rootView.setFitsSystemWindows(true);
        }
    }else {
        rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }*/
    //设置为miui主题
    //setMiuiTheme(BaseActivity.this,0,mode);
    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    //全局自定义字体
    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath(sharedPreferences.getString("font_path", null))
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());
}
 
Example 12
Source File: Theme.java    From SAI with GNU General Public License v3.0 4 votes vote down vote up
private boolean shouldUseDarkThemeForAutoMode() {
    return (mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}
 
Example 13
Source File: SortTypeBottomSheetFragment.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_sort_type_bottom_sheet, container, false);
    ButterKnife.bind(this, rootView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
            && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
        rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
    }

    if (getArguments() == null || getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) {
        bestTypeTextView.setVisibility(View.GONE);
    } else {
        bestTypeTextView.setOnClickListener(view -> {
            ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST));
            dismiss();
        });
    }

    hotTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
        dismiss();
    });

    newTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW));
        dismiss();
    });

    if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) {
        randomTypeTextView.setVisibility(View.GONE);
    } else {
        randomTypeTextView.setOnClickListener(view -> {
            ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM));
            dismiss();
        });
    }

    risingTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
        dismiss();
    });

    topTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
        dismiss();
    });

    controversialTypeTextView.setOnClickListener(view -> {
        ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name());
        dismiss();
    });

    return rootView;
}
 
Example 14
Source File: NotesApplication.java    From nextcloud-notes with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isDarkThemeActive(Context context) {
    int uiMode = context.getResources().getConfiguration().uiMode;
    return (uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}
 
Example 15
Source File: PostImage.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_post_image);

    imagesList=getIntent().getParcelableArrayListExtra("imagesList");

    if(imagesList.isEmpty()){
        finish();
    }

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("New Image Post");

    int nightModeFlags=getResources().getConfiguration().uiMode& Configuration.UI_MODE_NIGHT_MASK;
    if(nightModeFlags==UI_MODE_NIGHT_NO){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int flags=getWindow().getDecorView().getSystemUiVisibility();
            flags|=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDarkk));
    }

    try {
        getSupportActionBar().setTitle("New Image Post");
    } catch (Exception e) {
        e.printStackTrace();
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    postMap = new HashMap<>();

    pager=findViewById(R.id.pager);
    indicator=findViewById(R.id.indicator);
    indicator_holder=findViewById(R.id.indicator_holder);

    indicator.setDotsClickable(true);
    adapter=new PagerPhotosAdapter(this,imagesList);
    pager.setAdapter(adapter);

    if(imagesList.size()>1){
        indicator_holder.setVisibility(View.VISIBLE);
        indicator.setViewPager(pager);
    }else{
        indicator_holder.setVisibility(GONE);
    }

    mFirestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();
    mCurrentUser = mAuth.getCurrentUser();

    sharedPreferences=getSharedPreferences("uploadservice",MODE_PRIVATE);
    serviceCount=sharedPreferences.getInt("count",0);

    mEditText = findViewById(R.id.text);

    compressor=new Compressor(this)
            .setQuality(85)
            .setCompressFormat(Bitmap.CompressFormat.PNG);

    mDialog = new ProgressDialog(this);
    mStorage=FirebaseStorage.getInstance().getReference();

}
 
Example 16
Source File: CommentsActivity.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_post_comments);

    mFirestore = FirebaseFirestore.getInstance();
    mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();

    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Comments");
    int nightModeFlags=getResources().getConfiguration().uiMode& Configuration.UI_MODE_NIGHT_MASK;
    if(nightModeFlags==UI_MODE_NIGHT_NO){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int flags=getWindow().getDecorView().getSystemUiVisibility();
            flags|=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDarkk));
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle("Comments");

    user_image=findViewById(R.id.comment_admin);
    post_desc=findViewById(R.id.comment_post_desc);

    Cursor rs = new UserHelper(this).getData(1);
    rs.moveToFirst();

    String image = rs.getString(rs.getColumnIndex(UserHelper.CONTACTS_COLUMN_IMAGE));

    if (!rs.isClosed()) {
        rs.close();
    }

    Glide.with(this)
            .setDefaultRequestOptions(new RequestOptions().placeholder(R.drawable.default_profile_picture))
            .load(image)
            .into(user_image);

    setupCommentView();

}
 
Example 17
Source File: FragmentSingleIllust.java    From Pixiv-Shaft with MIT License 4 votes vote down vote up
private void loadImage() {
    int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
    switch (currentNightMode) {
        case Configuration.UI_MODE_NIGHT_NO:
        case Configuration.UI_MODE_NIGHT_UNDEFINED:
            Glide.with(mContext)
                    .load(GlideUtil.getSquare(illust))
                    .apply(bitmapTransform(new BlurTransformation(25, 3)))
                    .transition(withCrossFade())
                    .into(baseBind.bgImage);
            break;
        case Configuration.UI_MODE_NIGHT_YES:
            baseBind.bgImage.setImageResource(R.color.black);
            break;
    }


    mDetailAdapter = new IllustDetailAdapter(illust, mActivity);
    mDetailAdapter.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(View v, int position, int viewType) {
            if (viewType == 0) {
                Intent intent = new Intent(mContext, ImageDetailActivity.class);
                intent.putExtra("illust", illust);
                intent.putExtra("dataType", "二级详情");
                intent.putExtra("index", position);
                if (Shaft.sSettings.isFirstImageSize()) {
                    mActivity.startActivity(intent);
                } else {
                    if (mDetailAdapter.getHasLoad().get(position)) {
                        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(mActivity,
                                v, "big_image_" + position).toBundle();
                        startActivity(intent, bundle);
                    } else {
                        mActivity.startActivity(intent);
                    }
                }
            } else if (viewType == 1) {

            }
        }
    });
    baseBind.recyclerView.setAdapter(mDetailAdapter);
}
 
Example 18
Source File: DynamicTheme.java    From dynamic-support with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSystemNightMode() {
    return (getContext().getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}
 
Example 19
Source File: DisplayUtils.java    From GeometricWeather with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean isDarkMode(Context context) {
    return (context.getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}
 
Example 20
Source File: MiscUtils.java    From BottomBar with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if the current UI Mode is Night Mode.
 *
 * @param context Context to get the configuration.
 * @return true if the night mode is enabled, otherwise false.
 */
protected static boolean isNightMode(@NonNull Context context) {
    int currentNightMode = context.getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_NIGHT_MASK;
    return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
}