Example usage for android.view ContextThemeWrapper ContextThemeWrapper

List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper

Introduction

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

Prototype

public ContextThemeWrapper(Context base, Resources.Theme theme) 

Source Link

Document

Creates a new context wrapper with the specified theme.

Usage

From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java

@SuppressLint("RtlHardcoded")
private void drawOverlay(AccessibilityNodeInfo node, View.OnClickListener onClickListener) {

    mOverlay = new FrameLayout(this);

    // must be encapsulated into FrameLayout for animation
    FrameLayout mAnimatedChild = new FrameLayout(this);
    LayoutInflater systemInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.FixedBottomSheetTheme);
    LayoutInflater inflater = systemInflater.cloneInContext(contextThemeWrapper);

    View child = inflater.inflate(R.layout.fixed_bottom_sheet, null);
    mAnimatedChild.addView(child);//from w ww .  j  a  v  a  2s  .c o  m

    Button b = (Button) child.findViewById(R.id.fixed_bottom_sheet_button);
    b.setText(R.string.decrypt_with_openkeychain);
    b.setOnClickListener(onClickListener);

    ImageButton close = (ImageButton) child.findViewById(R.id.fixed_bottom_sheet_close);
    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            closeOverlay();
        }
    });

    Rect webviewRect = new Rect();
    node.getBoundsInScreen(webviewRect);

    Display display = mWindowManager.getDefaultDisplay();
    Rect displayRect = new Rect();
    display.getRectSize(displayRect);

    int xpos = webviewRect.left;
    int ypos = webviewRect.top - getStatusBarHeight() < getToolbarHeight() ? getToolbarHeight()
            : webviewRect.top - getStatusBarHeight();

    int width = webviewRect.width();
    int height = webviewRect.bottom < displayRect.height()
            ? webviewRect.bottom - getToolbarHeight() - getStatusBarHeight()
            : displayRect.height() - ypos - getStatusBarHeight();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, xpos, ypos,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.windowAnimations = R.style.OverlayAnimation;
    mWindowManager.addView(mOverlay, params);
    mOverlay.addView(mAnimatedChild);
}

From source file:com.jtechme.apphub.privileged.install.InstallExtensionDialogActivity.java

/**
 * first time/*from   w  w w  . j av  a 2s.co  m*/
 */
private void firstTime() {
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    String message = getString(R.string.system_install_first_time_message) + "<br/><br/>"
            + getString(R.string.system_install_question);

    AlertDialog.Builder builder = new AlertDialog.Builder(theme).setMessage(Html.fromHtml(message))
            .setPositiveButton(R.string.system_install_button_open, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    // Open details of F-Droid Privileged
                    Intent intent = new Intent(InstallExtensionDialogActivity.this, AppDetails.class);
                    intent.putExtra(AppDetails.EXTRA_APPID,
                            PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME);
                    startActivity(intent);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                    InstallExtensionDialogActivity.this.finish();
                }
            });
    builder.create().show();
}

From source file:com.appsimobile.appsii.module.home.YahooLocationChooserDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context layoutContext = new ContextThemeWrapper(getActivity(), R.style.Appsi_Sidebar_Material_Teal);

    LayoutInflater layoutInflater = LayoutInflater.from(layoutContext);
    View rootView = layoutInflater.inflate(R.layout.fragment_location_chooser, null);
    mSearchView = (TextView) rootView.findViewById(R.id.location_query);

    mCurrentLocationContainer = rootView.findViewById(R.id.location_search);
    mApplyCurrentLocationButton = (Button) rootView.findViewById(R.id.apply_current_location_button);
    mCancelCurrentLocationButton = (Button) rootView.findViewById(R.id.cancel_current_location_button);

    mEnableLocationContainer = rootView.findViewById(R.id.location_unavailable);
    mCancelUseLocationButton = (Button) rootView.findViewById(R.id.cancel_enable_location_button);
    mConfirmUseLocationButton = (Button) rootView.findViewById(R.id.enable_location_button);

    mGrantAccessContainer = rootView.findViewById(R.id.location_permission_denied);
    mCancelGrantLocationAccessButton = (Button) rootView.findViewById(R.id.cancel_grant_location_access_button);
    mConfirmGrantLocationAccessButton = (Button) rootView.findViewById(R.id.grant_location_access_button);

    mHeaderTextView = (TextView) rootView.findViewById(R.id.your_location_title);

    mSearchView.addTextChangedListener(this);

    mApplyCurrentLocationButton.setOnClickListener(this);
    mCancelCurrentLocationButton.setOnClickListener(this);
    mCancelUseLocationButton.setOnClickListener(this);
    mConfirmUseLocationButton.setOnClickListener(this);
    mCancelGrantLocationAccessButton.setOnClickListener(this);
    mConfirmGrantLocationAccessButton.setOnClickListener(this);

    // Set up apps
    mSearchResultsList = (ListView) rootView.findViewById(android.R.id.list);
    mSearchResultsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override//from   ww  w  .  ja v  a 2s .com
        public void onItemClick(AdapterView<?> listView, View view, int position, long itemId) {
            YahooWeatherApiClient.LocationSearchResult value = (YahooWeatherApiClient.LocationSearchResult) mSearchResultsAdapter
                    .getItem(position);
            mLocationResultListener.onLocationSearchResult(value);
            dismiss();
        }
    });

    tryBindList();

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setView(rootView).create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return dialog;
}

From source file:com.mishiranu.dashchan.content.service.PostingService.java

@Override
public void run() {
    boolean interrupted = false;
    while (true) {
        TaskState taskState = null;// w w  w . j av a  2  s . c  om
        if (!interrupted) {
            try {
                taskState = notificationsQueue.take();
            } catch (InterruptedException e) {
                interrupted = true;
            }
        }
        if (interrupted) {
            taskState = notificationsQueue.poll();
        }
        if (taskState == null) {
            return;
        }
        if (taskState.cancel) {
            notificationManager.cancel(taskState.notificationId);
        } else {
            Notification.Builder builder = taskState.builder;
            if (taskState.first) {
                builder.setOngoing(true);
                builder.setSmallIcon(android.R.drawable.stat_sys_upload);
                PendingIntent cancelIntent = PendingIntent.getService(
                        this, taskState.notificationId, new Intent(this, PostingService.class)
                                .setAction(ACTION_CANCEL_POSTING).putExtra(EXTRA_KEY, taskState.key),
                        PendingIntent.FLAG_UPDATE_CURRENT);
                Context themedContext = new ContextThemeWrapper(this, R.style.Theme_Special_Notification);
                ViewUtils.addNotificationAction(builder, this,
                        ResourceUtils.getResourceId(themedContext, R.attr.notificationCancel, 0),
                        getString(android.R.string.cancel), cancelIntent);
                if (C.API_LOLLIPOP) {
                    setNotificationColor(builder);
                }
            }
            boolean progressMode = taskState.task.isProgressMode();
            switch (taskState.progressState) {
            case CONNECTING: {
                if (progressMode) {
                    builder.setProgress(1, 0, true);
                }
                builder.setContentTitle(getString(R.string.message_sending));
                break;
            }
            case SENDING: {
                if (progressMode) {
                    builder.setProgress(taskState.progressMax, taskState.progress, taskState.progressMax <= 0);
                    builder.setContentTitle(getString(R.string.message_sending_index_format,
                            taskState.attachmentIndex + 1, taskState.attachmentsCount));
                } else {
                    builder.setContentTitle(getString(R.string.message_sending));
                }
                break;
            }
            case PROCESSING: {
                if (progressMode) {
                    builder.setProgress(1, 1, false);
                }
                builder.setContentTitle(getString(R.string.message_processing_data));
                break;
            }
            }
            builder.setContentText(taskState.text);
            notificationManager.notify(taskState.notificationId, builder.build());
        }
    }
}

From source file:com.granita.tasks.QuickAddDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // create ContextThemeWrapper from the original Activity Context with the custom theme
    final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(),
            R.style.ThemeOverlay_AppCompat_Light);
    final Context contextThemeWrapperDark = new ContextThemeWrapper(getActivity(),
            R.style.Base_Theme_AppCompat);

    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight);
    View view = localInflater.inflate(R.layout.fragment_quick_add_dialog, container);

    ViewGroup headerContainer = (ViewGroup) view.findViewById(R.id.header_container);
    localInflater = inflater.cloneInContext(contextThemeWrapperDark);
    localInflater.inflate(R.layout.fragment_quick_add_dialog_header, headerContainer);

    if (savedInstanceState == null) {
        if (mListId >= 0) {
            mSelectedListId = mListId;/*  w  ww .  j av a 2s  .c o  m*/
        }
    }

    mColorBackground = view.findViewById(R.id.color_background);
    mColorBackground.setBackgroundColor(mLastColor);

    mListSpinner = (Spinner) view.findViewById(R.id.task_list_spinner);
    mTaskListAdapter = new TasksListCursorSpinnerAdapter(getActivity(),
            R.layout.list_spinner_item_selected_quick_add, R.layout.list_spinner_item_dropdown);
    mListSpinner.setAdapter(mTaskListAdapter);
    mListSpinner.setOnItemSelectedListener(this);

    mEditText = (EditText) view.findViewById(android.R.id.input);
    mEditText.requestFocus();
    getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    mEditText.setOnEditorActionListener(this);
    mEditText.addTextChangedListener(this);

    mConfirmation = view.findViewById(R.id.created_confirmation);
    mContent = view.findViewById(R.id.content);

    mSaveButton = view.findViewById(android.R.id.button1);
    mSaveButton.setOnClickListener(this);
    mSaveAndNextButton = view.findViewById(android.R.id.button2);
    mSaveAndNextButton.setOnClickListener(this);
    view.findViewById(android.R.id.edit).setOnClickListener(this);

    mAuthority = getString(R.string.org_dmfs_tasks_authority);

    afterTextChanged(mEditText.getEditableText());

    setListUri(TaskLists.getContentUri(mAuthority), LIST_LOADER_VISIBLE_LISTS_FILTER);

    return view;
}

From source file:com.kkbox.toolkit.dialog.KKDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
        @Override/*from   ww w  . j  av a 2 s.c  o m*/
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onPositive();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNeutral();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNegative();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    switch (dialogType) {
    case Type.PROGRESSING_DIALOG:
        ProgressDialog progressDialog;
        if (theme != -1) {
            progressDialog = new ProgressDialog(getActivity(), theme);
        } else {
            progressDialog = new ProgressDialog(getActivity());
        }
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage(message);
        progressDialog.setIndeterminate(true);
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(listener != null);
        return progressDialog;
    case Type.ALERT_DIALOG:
        AlertDialog.Builder builder;
        AlertDialog alertDialog;
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.THREE_CHOICE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNeutralButton(neutralButtonText, neutralListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.YES_OR_NO_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.SELECT_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setSingleChoiceItems(entries, selectedIndex, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (!isDismissed) {
                    if (listener != null) {
                        listener.onEvent(id);
                    }
                    dismiss();
                    onDialogFinishedByUser();
                    isDismissed = true;
                }
            }
        });
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        builder.setView(customizeView);

        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }
        if (!TextUtils.isEmpty(positiveButtonText)) {
            builder.setPositiveButton(positiveButtonText, positiveListener);
        }
        if (!TextUtils.isEmpty(neutralButtonText)) {
            builder.setNeutralButton(neutralButtonText, neutralListener);
        }
        if (!TextUtils.isEmpty(negativeButtonText)) {
            builder.setNegativeButton(negativeButtonText, negativeListener);
        }
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_FULLSCREEN_DIALOG:
        Dialog dialog;
        if (theme != -1) {
            dialog = new Dialog(getActivity(), theme);
        } else {
            dialog = new Dialog(getActivity(), android.R.style.Theme_NoTitleBar);
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        dialog.setContentView(customizeView);
        return dialog;
    }
    return null;
}

From source file:id.ridon.keude.Keude.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.action_update_repo:
        updateRepos();/*from  ww w  .j a v  a2  s  . c o  m*/
        return true;

    case R.id.action_manage_repos:
        Intent i = new Intent(this, ManageReposActivity.class);
        startActivityForResult(i, REQUEST_MANAGEREPOS);
        return true;

    case R.id.action_settings:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

    case R.id.action_swap:
        startActivity(new Intent(this, SwapActivity.class));
        return true;

    case R.id.action_search:
        onSearchRequested();
        return true;

    case R.id.action_bluetooth_apk:
        /*
         * If Bluetooth has not been enabled/turned on, then enabling
         * device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    case R.id.action_about:
        View view = null;
        if (Build.VERSION.SDK_INT >= 11) {
            LayoutInflater li = LayoutInflater.from(this);
            view = li.inflate(R.layout.about, null);
        } else {
            view = View.inflate(new ContextThemeWrapper(this, R.style.AboutDialogLight), R.layout.about, null);
        }

        // Fill in the version...
        try {
            PackageInfo pi = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0);
            ((TextView) view.findViewById(R.id.version)).setText(pi.versionName);
        } catch (Exception e) {
        }

        Builder p = null;
        if (Build.VERSION.SDK_INT >= 11) {
            p = new AlertDialog.Builder(this).setView(view);
        } else {
            p = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AboutDialogLight)).setView(view);
        }
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.ic_launcher);
        alrt.setTitle(getString(R.string.about_title));
        alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Uri uri = Uri.parse("https://f-droid.org");
                        startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    }
                });
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.gh4a.IssueMilestoneEditActivity.java

@Override
public boolean setMenuOptionItemSelected(MenuItem item) {
    final EditText tvTitle = (EditText) findViewById(R.id.et_title);
    final EditText tvDesc = (EditText) findViewById(R.id.et_desc);

    switch (item.getItemId()) {
    case android.R.id.home:
        getApplicationContext().openIssueListActivity(this, mRepoOwner, mRepoName,
                Constants.Issue.ISSUE_STATE_OPEN, Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return true;
    case R.id.accept:
        String desc = null;/*  w  ww  . j ava 2  s  .  c o  m*/

        if (tvDesc.getText() != null) {
            desc = tvDesc.getText().toString();
        }

        if (tvTitle.getText() == null || StringUtils.isBlank(tvTitle.getText().toString())) {
            showMessage(getResources().getString(R.string.issue_error_milestone_title), false);
        } else {
            new EditIssueMilestonesTask(IssueMilestoneEditActivity.this).execute(tvTitle.getText().toString(),
                    desc);
        }
        return true;

    case R.id.delete:
        AlertDialog.Builder builder = new AlertDialog.Builder(
                new ContextThemeWrapper(IssueMilestoneEditActivity.this, android.R.style.Theme));
        builder.setTitle("Delete " + mMilestone.getTitle() + "?");
        builder.setMessage("Are you sure?");
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
                new DeleteIssueMilestoneTask(IssueMilestoneEditActivity.this).execute();
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
            }
        }).create();

        builder.show();
        return true;

    default:
        return true;
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockNative.java

@Override
protected Context getThemedContext() {
    Context context = mActivity;/*from w ww.j av  a2  s  .  c o  m*/
    TypedValue outValue = new TypedValue();
    mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true);
    if (outValue.resourceId != 0) {
        //We are unable to test if this is the same as our current theme
        //so we just wrap it and hope that if the attribute was specified
        //then the user is intentionally specifying an alternate theme.
        context = new ContextThemeWrapper(context, outValue.resourceId);
    }
    return context;
}

From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java

@Override
protected void onCreate() {
    Activity activity = getActivity();//from www.  j av  a2s  . c o m
    PullableListView listView = getListView();
    PageHolder pageHolder = getPageHolder();
    UiManager uiManager = getUiManager();
    hidePerformer = new HidePerformer();
    PostsExtra extra = getExtra();
    listView.setDivider(ResourceUtils.getDrawable(activity, R.attr.postsDivider, 0));
    ChanConfiguration.Board board = getChanConfiguration().safe().obtainBoard(pageHolder.boardName);
    if (board.allowPosting) {
        replyable = data -> getUiManager().navigator().navigatePosting(pageHolder.chanName,
                pageHolder.boardName, pageHolder.threadNumber, data);
    }
    PostsAdapter adapter = new PostsAdapter(activity, pageHolder.chanName, pageHolder.boardName, uiManager,
            replyable, hidePerformer, extra.userPostNumbers, listView);
    initAdapter(adapter, adapter);
    ImageLoader.getInstance().observable().register(this);
    listView.getWrapper().setPullSides(PullableWrapper.Side.BOTH);
    uiManager.observable().register(this);
    hidePerformer.setPostsProvider(adapter);

    Context darkStyledContext = new ContextThemeWrapper(activity, R.style.Theme_General_Main_Dark);
    searchController = new LinearLayout(darkStyledContext);
    searchController.setOrientation(LinearLayout.HORIZONTAL);
    searchController.setGravity(Gravity.CENTER_VERTICAL);
    float density = ResourceUtils.obtainDensity(getResources());
    int padding = (int) (10f * density);
    searchTextResult = new Button(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    searchTextResult.setTextSize(11f);
    if (!C.API_LOLLIPOP) {
        searchTextResult.setTypeface(null, Typeface.BOLD);
    }
    searchTextResult.setPadding((int) (14f * density), 0, (int) (14f * density), 0);
    searchTextResult.setMinimumWidth(0);
    searchTextResult.setMinWidth(0);
    searchTextResult.setOnClickListener(v -> showSearchDialog());
    searchController.addView(searchTextResult, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    ImageView backButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    backButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    backButtonView.setImageResource(obtainIcon(R.attr.actionBack));
    backButtonView.setPadding(padding, padding, padding, padding);
    backButtonView.setOnClickListener(v -> findBack());
    searchController.addView(backButtonView, (int) (48f * density), (int) (48f * density));
    ImageView forwardButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    forwardButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    forwardButtonView.setImageResource(obtainIcon(R.attr.actionForward));
    forwardButtonView.setPadding(padding, padding, padding, padding);
    forwardButtonView.setOnClickListener(v -> findForward());
    searchController.addView(forwardButtonView, (int) (48f * density), (int) (48f * density));
    if (C.API_LOLLIPOP) {
        for (int i = 0, last = searchController.getChildCount() - 1; i <= last; i++) {
            View view = searchController.getChildAt(i);
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            if (i == 0) {
                layoutParams.leftMargin = (int) (-6f * density);
            }
            if (i == last) {
                layoutParams.rightMargin = (int) (6f * density);
            } else {
                layoutParams.rightMargin = (int) (-6f * density);
            }
        }
    }

    scrollToPostNumber = pageHolder.initialPostNumber;
    FavoritesStorage.getInstance().getObservable().register(this);
    LocalBroadcastManager.getInstance(activity).registerReceiver(galleryPagerReceiver,
            new IntentFilter(C.ACTION_GALLERY_NAVIGATE_POST));
    boolean hasNewPostDatas = handleNewPostDatas();
    extra.forceRefresh = hasNewPostDatas || !pageHolder.initialFromCache;
    if (extra.cachedPosts != null && extra.cachedPostItems.size() > 0) {
        onDeserializePostsCompleteInternal(true, extra.cachedPosts, new ArrayList<>(extra.cachedPostItems),
                true);
    } else {
        deserializeTask = new DeserializePostsTask(this, pageHolder.chanName, pageHolder.boardName,
                pageHolder.threadNumber, extra.cachedPosts);
        deserializeTask.executeOnExecutor(DeserializePostsTask.THREAD_POOL_EXECUTOR);
        getListView().getWrapper().startBusyState(PullableWrapper.Side.BOTH);
        switchView(ViewType.PROGRESS, null);
    }
    pageHolder.setInitialPostsData(false, null);
}