use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.
the class StatsSingleItemDetailsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.stats_activity_single_post_details);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
// pull to refresh setup
mSwipeToRefreshHelper = new SwipeToRefreshHelper(this, (CustomSwipeRefreshLayout) findViewById(R.id.ptr_layout), new SwipeToRefreshHelper.RefreshListener() {
@Override
public void onRefreshStarted() {
if (!NetworkUtils.checkConnection(getBaseContext())) {
mSwipeToRefreshHelper.setRefreshing(false);
return;
}
refreshStats();
}
});
TextView mStatsForLabel = (TextView) findViewById(R.id.stats_summary_title);
mGraphContainer = (LinearLayout) findViewById(R.id.stats_bar_chart_fragment_container);
mStatsViewsLabel = (TextView) findViewById(R.id.stats_views_label);
mStatsViewsTotals = (TextView) findViewById(R.id.stats_views_totals);
mMonthsAndYearsModule = (LinearLayout) findViewById(R.id.stats_months_years_module);
mMonthsAndYearsHeader = (RelativeLayout) findViewById(R.id.stats_months_years_header);
mMonthsAndYearsList = (LinearLayout) findViewById(R.id.stats_months_years_list_linearlayout);
mMonthsAndYearsEmptyPlaceholder = (LinearLayout) findViewById(R.id.stats_months_years_empty_module_placeholder);
mAveragesModule = (LinearLayout) findViewById(R.id.stats_averages_module);
mAveragesHeader = (RelativeLayout) findViewById(R.id.stats_averages_list_header);
mAveragesList = (LinearLayout) findViewById(R.id.stats_averages_list_linearlayout);
mAveragesEmptyPlaceholder = (LinearLayout) findViewById(R.id.stats_averages_empty_module_placeholder);
mRecentWeeksModule = (LinearLayout) findViewById(R.id.stats_recent_weeks_module);
mRecentWeeksHeader = (RelativeLayout) findViewById(R.id.stats_recent_weeks_list_header);
mRecentWeeksList = (LinearLayout) findViewById(R.id.stats_recent_weeks_list_linearlayout);
mRecentWeeksEmptyPlaceholder = (LinearLayout) findViewById(R.id.stats_recent_weeks_empty_module_placeholder);
mYearsIdToExpandedMap = new SparseBooleanArray();
mAveragesIdToExpandedMap = new SparseBooleanArray();
mRecentWeeksIdToExpandedMap = new SparseBooleanArray();
setTitle(R.string.stats);
mOuterScrollView = (ScrollViewExt) findViewById(R.id.scroll_view_stats);
if (savedInstanceState != null) {
mRemoteItemID = savedInstanceState.getString(ARG_REMOTE_ITEM_ID);
mRemoteBlogID = savedInstanceState.getLong(ARG_REMOTE_BLOG_ID, 0);
mRemoteItemType = savedInstanceState.getString(ARG_REMOTE_ITEM_TYPE);
mItemTitle = savedInstanceState.getString(ARG_ITEM_TITLE);
mItemURL = savedInstanceState.getString(ARG_ITEM_URL);
mRestResponseParsed = (PostViewsModel) savedInstanceState.getSerializable(ARG_REST_RESPONSE);
mSelectedBarGraphIndex = savedInstanceState.getInt(ARG_SELECTED_GRAPH_BAR, -1);
mPrevNumberOfBarsGraph = savedInstanceState.getInt(ARG_PREV_NUMBER_OF_BARS, -1);
final int yScrollPosition = savedInstanceState.getInt(SAVED_STATS_SCROLL_POSITION);
if (yScrollPosition != 0) {
mOuterScrollView.postDelayed(new Runnable() {
public void run() {
if (!isFinishing()) {
mOuterScrollView.scrollTo(0, yScrollPosition);
}
}
}, StatsConstants.STATS_SCROLL_TO_DELAY);
}
if (savedInstanceState.containsKey(ARG_AVERAGES_EXPANDED_ROWS)) {
mAveragesIdToExpandedMap = savedInstanceState.getParcelable(ARG_AVERAGES_EXPANDED_ROWS);
}
if (savedInstanceState.containsKey(ARG_RECENT_EXPANDED_ROWS)) {
mRecentWeeksIdToExpandedMap = savedInstanceState.getParcelable(ARG_RECENT_EXPANDED_ROWS);
}
if (savedInstanceState.containsKey(ARG_YEARS_EXPANDED_ROWS)) {
mYearsIdToExpandedMap = savedInstanceState.getParcelable(ARG_YEARS_EXPANDED_ROWS);
}
} else if (getIntent() != null && getIntent().getExtras() != null) {
Bundle extras = getIntent().getExtras();
mRemoteItemID = extras.getString(ARG_REMOTE_ITEM_ID);
mRemoteBlogID = extras.getLong(ARG_REMOTE_BLOG_ID, 0);
mRemoteItemType = extras.getString(ARG_REMOTE_ITEM_TYPE);
mItemTitle = extras.getString(ARG_ITEM_TITLE);
mItemURL = extras.getString(ARG_ITEM_URL);
mRestResponseParsed = (PostViewsModel) extras.getSerializable(ARG_REST_RESPONSE);
mSelectedBarGraphIndex = extras.getInt(ARG_SELECTED_GRAPH_BAR, -1);
}
if (mRemoteBlogID == 0 || mRemoteItemID == null) {
Toast.makeText(this, R.string.stats_generic_error, Toast.LENGTH_LONG).show();
finish();
return;
}
if (savedInstanceState == null) {
AnalyticsUtils.trackWithSiteId(AnalyticsTracker.Stat.STATS_SINGLE_POST_ACCESSED, mRemoteBlogID);
}
// Setup the main top label that opens the post in the Reader where possible
if (mItemTitle != null || mItemURL != null) {
mStatsForLabel.setVisibility(View.VISIBLE);
mStatsForLabel.setText(mItemTitle != null ? mItemTitle : mItemURL);
// make the label clickable if the URL is available
if (mItemURL != null) {
mStatsForLabel.setTextColor(getResources().getColor(R.color.stats_link_text_color));
mStatsForLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Context ctx = v.getContext();
StatsUtils.openPostInReaderOrInAppWebview(ctx, mRemoteBlogID, mRemoteItemID, mRemoteItemType, mItemURL);
}
});
} else {
mStatsForLabel.setTextColor(getResources().getColor(R.color.grey_darken_20));
}
} else {
mStatsForLabel.setVisibility(View.GONE);
}
}
use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.
the class ImageSettingsDialogFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
ActionBar actionBar = getActionBar();
if (actionBar == null) {
return;
}
actionBar.show();
mPreviousActionBarTitle = actionBar.getTitle();
mPreviousCustomView = actionBar.getCustomView();
final int displayOptions = actionBar.getDisplayOptions();
mPreviousHomeAsUpEnabled = (displayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
actionBar.setTitle(R.string.image_settings);
actionBar.setDisplayHomeAsUpEnabled(true);
if (getResources().getBoolean(R.bool.show_extra_side_padding)) {
actionBar.setHomeAsUpIndicator(R.drawable.ic_close_padded);
} else {
actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
}
// Show custom view with padded Save button
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.image_settings_formatbar);
actionBar.getCustomView().findViewById(R.id.menu_save).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mImageMeta = extractMetaDataFromFields(mImageMeta);
String imageRemoteId = "";
try {
imageRemoteId = mImageMeta.getString("attachment_id");
} catch (JSONException e) {
AppLog.e(AppLog.T.EDITOR, "Unable to retrieve featured image id from meta data");
}
Intent intent = new Intent();
intent.putExtra("imageMeta", mImageMeta.toString());
mIsFeatured = mFeaturedCheckBox.isChecked();
intent.putExtra("isFeatured", mIsFeatured);
if (!imageRemoteId.isEmpty()) {
intent.putExtra("imageRemoteId", Integer.parseInt(imageRemoteId));
}
getTargetFragment().onActivityResult(getTargetRequestCode(), getTargetRequestCode(), intent);
restorePreviousActionBar();
getFragmentManager().popBackStack();
ToastUtils.showToast(getActivity(), R.string.image_settings_save_toast);
}
});
}
use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.
the class ImageSettingsDialogFragment method onConfigurationChanged.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.show();
}
}
use of android.support.v7.app.ActionBar in project Hummingbird-for-Android by xiprox.
the class MainActivity method restoreActionBar.
public void restoreActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.
the class ThemeBrowserActivity method showToolbar.
protected void showToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.themes);
findViewById(R.id.toolbar).setVisibility(View.VISIBLE);
findViewById(R.id.toolbar_search).setVisibility(View.GONE);
}
Aggregations