Example usage for android.view View setBackgroundColor

List of usage examples for android.view View setBackgroundColor

Introduction

In this page you can find the example usage for android.view View setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.anurag.fragments.RootPanel.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    list = (ListView) view.findViewById(R.id.list_view_hd);
    list.setBackgroundColor(Color.WHITE);
    empty = (LinearLayout) view.findViewById(R.id.empty);
    empty.setBackgroundColor(Color.WHITE);
    list.setSelector(R.drawable.list_selector_hd);
    list_anim_helper = new JazzyHelper(getActivity(), null);
    setAnim(list);/*from   w ww  .  ja  v  a2  s .com*/
    if (load == null) {
        load = new LoadList();
        load.execute();
    }

    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            // TODO Auto-generated method stub
            item = adapter_list.get(position);
            if (Constants.LONG_CLICK[1]) {

                if (ITEMS[position] != 1) {
                    ITEMS[position] = 1;
                    arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                    ++counter;

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count++;
                    else
                        file_count++;

                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                } else if (ITEMS[position] == 1) {
                    ITEMS[position] = 0;
                    arg1.setBackgroundColor(Color.WHITE);

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count--;
                    else
                        file_count--;

                    if (--counter == 0)
                        getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                    else
                        getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                }

                return;
            }

            if (item.isLocked()) {
                new MasterPassword(getActivity(), item, null, Constants.MODES.OPEN, null);
                return;
            }

            open_locked_item();
        }
    });

    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub

            //long pressing ability disabled inside archive....
            //may be get removed in next update
            if (manager.isArchiveOpened())
                return true;

            boolean sendBroadcast = false;
            item = adapter_list.get(arg2);
            if (ITEMS == null) {
                ITEMS = new int[adapter_list.size()];
                sendBroadcast = true;
            }

            if (ITEMS[arg2] != 1) {
                arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                ITEMS[arg2] = 1;
                ++counter;

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count++;
                else
                    file_count++;

                getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            } else if (ITEMS[arg2] == 1) {
                ITEMS[arg2] = 0;
                arg1.setBackgroundColor(Color.WHITE);

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count--;
                else
                    file_count--;

                if (--counter == 0)
                    getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                else
                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            }

            if (sendBroadcast)
                getActivity().sendBroadcast(new Intent("inflate_long_click_menu"));
            return true;
        }
    });

}

From source file:com.fa.mastodon.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        View view = this.getWindow().getDecorView();
        view.setBackgroundColor(Color.parseColor("#EEEEEE"));
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        View view = this.getWindow().getDecorView();
        view.setBackgroundColor(Color.parseColor("#000000"));
    }/*from w  w  w  .  j a  v  a 2s .  c  o m*/
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pageHistory = new Stack<>();
    if (savedInstanceState != null) {
        List<Integer> restoredHistory = savedInstanceState.getIntegerArrayList("pageHistory");
        if (restoredHistory != null) {
            pageHistory.addAll(restoredHistory);
        }
    }

    ButterKnife.bind(this);

    floatingBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSheetLayout.expandFab();
        }
    });

    TypedArray array = getTheme().obtainStyledAttributes(new int[] { android.R.attr.colorBackground, });
    int backgroundColor = array.getColor(0, 0xFF00FF);
    array.recycle();

    mSheetLayout.setFab(floatingBtn);
    mSheetLayout.setFabAnimationEndListener(this);
    mSheetLayout.setColor(backgroundColor);

    setupDrawer();
    setupSearchView();

    /* Fetch user info while we're doing other things. This has to be after setting up the
     * drawer, though, because its callback touches the header in the drawer. */
    fetchUserInfo();

    // Setup the tabs and timeline pager.
    TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager());

    int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
    viewPager.setPageMargin(pageMargin);
    Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable,
            R.drawable.tab_page_margin_dark);
    viewPager.setPageMarginDrawable(pageMarginDrawable);
    viewPager.setAdapter(adapter);

    int[] tabIcons = { R.drawable.ic_home_24dp, R.drawable.ic_notifications_24dp, R.drawable.ic_local_24dp,
            R.drawable.ic_public_24dp, };
    String[] pageTitles = { getString(R.string.title_home), getString(R.string.title_notifications),
            getString(R.string.title_public_local), getString(R.string.title_public_federated), };

    Intent intent = getIntent();

    bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);

    AHBottomNavigationItem item1 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_timeline_black_36dp, R.color.colorPrimaryDark);
    AHBottomNavigationItem item2 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_notifications_24dp, R.color.colorPrimaryDark);
    AHBottomNavigationItem item3 = new AHBottomNavigationItem(R.string.app_name, R.drawable.ic_face_black_36dp,
            R.color.colorPrimaryDark);
    AHBottomNavigationItem item4 = new AHBottomNavigationItem(R.string.app_name,
            R.drawable.ic_language_black_36dp, R.color.colorPrimaryDark);

    bottomNavigation.addItem(item1);
    bottomNavigation.addItem(item2);
    bottomNavigation.addItem(item3);
    bottomNavigation.addItem(item4);

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#FFFFFF"));
        bottomNavigation.setInactiveColor(Color.parseColor("#727272"));
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#000000"));
        bottomNavigation.setInactiveColor(Color.parseColor("#DDDDDD"));
    } else {
        bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#363c4b"));
        bottomNavigation.setInactiveColor(Color.parseColor("#68738f"));
    }

    bottomNavigation.setBehaviorTranslationEnabled(false);

    bottomNavigation.setAccentColor(Color.parseColor("#2b90d9"));

    bottomNavigation.setForceTint(true);

    bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_HIDE);

    bottomNavigation.setColored(false);
    bottomNavigation.setUseElevation(true);

    bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
        @Override
        public boolean onTabSelected(int position, boolean wasSelected) {
            viewPager.setCurrentItem(position);

            if (pageHistory.isEmpty()) {
                pageHistory.push(0);
            }

            if (pageHistory.contains(position)) {
                pageHistory.remove(pageHistory.indexOf(position));
            }

            pageHistory.push(position);
            return true;
        }
    });

    bottomNavigation.setCurrentItem(0);

    int tabSelected = 0;
    if (intent != null) {
        int tabPosition = intent.getIntExtra("tab_position", 0);
        if (tabPosition != 0) {
            if (bottomNavigation.getItem(tabPosition) != null) {
                bottomNavigation.setCurrentItem(tabPosition);
            }
        }
    }

    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            bottomNavigation.setCurrentItem(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    // Setup push notifications
    if (arePushNotificationsEnabled()) {
        enablePushNotifications();
    } else {
        disablePushNotifications();
    }

    composeButton = floatingBtn;

    if (!DonateActivity.isPlus(this)) {
        // Initialize the Mobile Ads SDK.
        MobileAds.initialize(this, "ca-app-pub-8245120186869512~8307608980");

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-8245120186869512/2261075384");

        requestNewInterstitial();

        mInterstitialAd.setAdListener(new AdListener() {
            public void onAdLoaded() {
                mInterstitialAd.show();
            }
        });
    }
}

From source file:com.simas.vc.nav_drawer.NavDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *///from www  .  j a  v  a  2s  . co  m
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // Set a custom shadow that overlays the main content when the drawer opens
    getDrawerLayout().setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // Unlock the drawer
    getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

    // Enable drawer arrow
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), getDrawerLayout(), getToolbar(),
            R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            mDrawerState = DrawerState.CLOSED;

            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerClosed(drawerView);
            }
            getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            // Set the choice mode ONLY IF IT'S NOT SINGLE
            // Otherwise, will cause the AbsListView to reset its mCheckState array!!!
            if (getListView().getChoiceMode() != ListView.CHOICE_MODE_SINGLE) {
                getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            }
            if (!isAdded()) {
                return;
            }

            getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mDrawerState = DrawerState.OPEN;

            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerOpened(drawerView);
            }
            if (!isAdded()) {
                return;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerSlide(drawerView, slideOffset);
            }
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerStateChanged(newState);
            }
        }
    };

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        setDrawerOpen(true);
    }

    // Defer code dependent on restoration of previous instance state.
    getDrawerLayout().post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    getDrawerLayout().setDrawerListener(mDrawerToggle);

    // The adapter needs a reference to the list its connected to
    mAdapter = new NavAdapter(getActivity(), getListView());
    getListView().setAdapter(mAdapter);

    // Select either the default item (0) or the last selected item.
    if (mPreviousSelection != ListView.INVALID_POSITION) {
        selectItem(mPreviousSelection);
    }

    if (mNavCAB == null) {
        // Newly created CAB
        mNavCAB = new NavCAB(this);
    } else {
        // Previous CAB
        mNavCAB.mNavDrawerFragment = this;
        getListView().post(new Runnable() {
            @Override
            public void run() {
                // Update list if CAB has checked items
                if (mNavCAB.checkedPositions != null && mNavCAB.checkedPositions.size() > 0) {
                    // Copy the array, because it will be modified when checking the LV items
                    List<Integer> positions = new ArrayList<>();
                    positions.addAll(mNavCAB.checkedPositions);

                    // Update the LV's item checked state
                    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
                    for (Integer position : positions) {
                        getListView().setItemChecked(position, true);
                    }
                }
            }
        });
    }

    getListView().setMultiChoiceModeListener(mNavCAB);

    // Click listeners
    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Make sure it's not the header
            if (position != 0) {
                selectItem(position);
                // Change the item's background based on its checked state
                if (getListView().isItemChecked(position)) {
                    view.setBackgroundColor(Color.DKGRAY);
                } else {
                    view.setBackgroundColor(Color.TRANSPARENT);
                }
            } else {
                ((MainActivity) getActivity()).showFileChooser(false);
            }
        }
    });

    getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Make sure it's not the header that's been clicked
            if (position == 0) {
                return false;
            } else {
                // Make sure a valid item has been clicked
                boolean valid = (mAdapter.getItem(position - 1).getState() == NavItem.State.VALID);
                if (!valid)
                    return false;

                // Need to enable multiple mode and force-check manually, so CAB is called
                getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
                getListView().setItemChecked(position, true);
                return true;
            }
        }
    });

    //      // Scroll to previous ScrollY
    //      Log.e(TAG, "selection: " + mPreviousSelection);
    //      if (mFromSavedInstanceState && mPreviousSelection != ListView.INVALID_POSITION) {
    //         getListView().setSelection(mPreviousSelection);
    //      }
}

From source file:com.rks.musicx.misc.utils.Helper.java

/**
 * Set color to nav and status bar//w w w. j a va 2  s .  c om
 * @param activity
 * @param v
 */
public static void setColor(@NonNull Activity activity, int color, View v) {
    if (activity.getWindow() == null) {
        return;
    }
    if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
        activity.getWindow().setStatusBarColor(color);
        v.setBackgroundColor(color);
        activity.getWindow().setNavigationBarColor(color);
    } else {
        activity.getWindow().setStatusBarColor(color);
        v.setBackgroundColor(color);
        activity.getWindow().setNavigationBarColor(color);
    }
}

From source file:com.ijiaban.yinxiang.MainActivity.java

/**
 * Changes the color of the action bar and status bar
 * @param color ARGB Color to apply//from  w ww  .  ja va2  s  . c om
 */
@SuppressLint("NewApi")
private void setColor(int color) {
    View mainView = findViewById(R.id.rootView);
    if (mainView == null) {
        Log.e("MainActivity:setColor()", "WARNING: Did not find root view.");
    } else {
        mainView.setBackgroundColor(color);
    }

    /*
    Set the action bar colour to the average colour of the generated image and
    the status bar colour for Android Version >= 5.0 accordingly.
    */
    try {
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
    } catch (NullPointerException nullError) {
        Log.e("MainActivity:generateImageTask()", nullError.toString());
    } catch (NoSuchMethodError methodError) {
        Log.e("MainActivity:generateImageTask()", methodError.toString());
    }

    Log.d("MainActivity:generateImageTask()", "Changing status bar & action bar colour.");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Get the window through a reference to the activity.
        Activity parent = (Activity) mContext;
        Window window = parent.getWindow();
        // Set the status bar colour of this window.
        int statusColor = ColorUtilities.getDarkenedColor(color);
        window.setStatusBarColor(statusColor);
    }
}

From source file:com.todoroo.astrid.adapter.FilterAdapter.java

@NonNull
@Override//from   w ww. jav a  2 s .c om
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    FilterListItem item = getItem(position);

    convertView = newView(convertView, parent, item.getItemType());
    ViewHolder viewHolder = (ViewHolder) convertView.getTag();
    viewHolder.item = getItem(position);
    switch (item.getItemType()) {
    case ITEM:
        populateItem(viewHolder);

        if (activity instanceof TaskListActivity) {
            Filter selected = ((TaskListActivity) activity).getCurrentFilter();

            if (selected != null && selected.equals(viewHolder.item)) {
                convertView.setBackgroundColor(getColor(activity, R.color.drawer_color_selected));
            }
        }
        break;
    case SUBHEADER:
        populateHeader(viewHolder);
        break;
    case SEPARATOR:
        break;
    }

    return convertView;
}

From source file:at.bitfire.davdroid.ui.CreateCalendarActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    account = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.activity_create_calendar);
    final View colorSquare = findViewById(R.id.color);
    colorSquare.setOnClickListener(new View.OnClickListener() {
        @Override/*w ww  .  j  a va2 s  .com*/
        public void onClick(View v) {
            new AmbilWarnaDialog(CreateCalendarActivity.this,
                    ((ColorDrawable) colorSquare.getBackground()).getColor(), true,
                    new AmbilWarnaDialog.OnAmbilWarnaListener() {
                        @Override
                        public void onCancel(AmbilWarnaDialog dialog) {
                        }

                        @Override
                        public void onOk(AmbilWarnaDialog dialog, int color) {
                            colorSquare.setBackgroundColor(color);
                        }
                    }).show();
        }
    });

    getSupportLoaderManager().initLoader(0, null, this);
}

From source file:org.awesomeapp.messenger.ui.ConversationDetailActivity.java

public void applyStyleForToolbar() {

    getSupportActionBar().setTitle(mConvoView.getTitle());

    if (mConvoView.getLastSeen() != null) {
        getSupportActionBar().setSubtitle(new PrettyTime().format(mConvoView.getLastSeen()));
    }/*from ww  w .ja  v  a  2  s .co  m*/

    //first set font
    Typeface typeface = CustomTypefaceManager.getCurrentTypeface(this);

    if (typeface != null) {
        for (int i = 0; i < mToolbar.getChildCount(); i++) {
            View view = mToolbar.getChildAt(i);
            if (view instanceof TextView) {
                TextView tv = (TextView) view;
                tv.setTypeface(typeface);
                break;
            }
        }
    }

    //not set color
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    int themeColorHeader = settings.getInt("themeColor", -1);
    int themeColorText = settings.getInt("themeColorText", -1);
    int themeColorBg = settings.getInt("themeColorBg", -1);

    if (themeColorHeader != -1) {

        if (themeColorText == -1)
            themeColorText = getContrastColor(themeColorHeader);

        if (Build.VERSION.SDK_INT >= 21) {
            getWindow().setNavigationBarColor(themeColorHeader);
            getWindow().setStatusBarColor(themeColorHeader);
            getWindow().setTitleColor(themeColorText);
        }

        //      appBarLayout.setBackgroundColor(themeColorHeader);
        //   collapsingToolbar.setBackgroundColor(themeColorHeader);
        mToolbar.setBackgroundColor(themeColorHeader);
        mToolbar.setTitleTextColor(themeColorText);

    }

    if (themeColorBg != -1) {
        if (mRootLayout != null)
            mRootLayout.setBackgroundColor(themeColorBg);

        View viewInput = findViewById(R.id.inputLayout);
        viewInput.setBackgroundColor(themeColorBg);

        if (themeColorText != -1) {
            mConvoView.mComposeMessage.setTextColor(themeColorText);
            mConvoView.mComposeMessage.setHintTextColor(themeColorText);
        }
    }

}

From source file:chaitanya.im.searchforreddit.LauncherActivity.java

private void showMessageInSnackbar(String message) {
    launcherRefresh.setRefreshing(false);
    snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_INDEFINITE);
    View snackbarView = snackbar.getView();
    TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTypeface(fontAwesome);/*  w  w  w . j  ava2 s .c  o  m*/
    snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.blue_tint));
    snackbar.show();
}

From source file:com.ryan.ryanreader.activities.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {

    // //from  w w w.j av a2 s .  com
    PrefsUtility.applyTheme(this);

    OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name));

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    //
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    //
    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    super.onCreate(savedInstanceState);

    twoPane = General.isTablet(this, sharedPreferences);

    final View layout;

    // ?
    if (twoPane)
        layout = getLayoutInflater().inflate(R.layout.main_double);
    else
        layout = getLayoutInflater().inflate(R.layout.main_single);

    if (solidblack)
        layout.setBackgroundColor(Color.BLACK);

    setContentView(layout);

    // ?
    doRefresh(RefreshableFragment.MAIN, false);

    RedditAccountManager.getInstance(this).addUpdateListener(this);

    PackageInfo pInfo = null;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException(e);
    }

    final int appVersion = pInfo.versionCode;

    if (!sharedPreferences.contains("firstRunMessageShown")) {

        new AlertDialog.Builder(this).setTitle(R.string.firstrun_login_title)
                .setMessage(R.string.firstrun_login_message)
                .setPositiveButton(R.string.firstrun_login_button_now, new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int which) {
                        new AccountListDialog().show(MainActivity.this);
                    }
                }).setNegativeButton(R.string.accounts_anon, null).show();

        final SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("firstRunMessageShown", "true");
        edit.commit();

    } else if (sharedPreferences.contains("lastVersion")) {

        if (sharedPreferences.getInt("lastVersion", 0) != appVersion) {

            General.quickToast(this, "Updated to version " + pInfo.versionName);

            sharedPreferences.edit().putInt("lastVersion", appVersion).commit();
            ChangelogDialog.newInstance().show(this);
        }

    } else {
        sharedPreferences.edit().putInt("lastVersion", appVersion).commit();
        ChangelogDialog.newInstance().show(this);
    }
    Globals.NETWORK_ENABLE = Globals.isConnect(this);// 
    if (Globals.AD_MODE && Globals.NETWORK_ENABLE) {
        // 
        initADView();
    }
}