use of androidx.appcompat.app.ActionBar in project SwipeRecyclerView by yanzhenjie.
the class HeaderViewActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scroll);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
SwipeRecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setOnItemClickListener(this);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
// HeaderView。
View headerView = getLayoutInflater().inflate(R.layout.layout_header, recyclerView, false);
headerView.findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "HeaderView", Toast.LENGTH_SHORT).show();
}
});
recyclerView.addHeaderView(headerView);
// FooterView。
View footerView = getLayoutInflater().inflate(R.layout.layout_footer, recyclerView, false);
footerView.findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "FooterView", Toast.LENGTH_SHORT).show();
}
});
recyclerView.addFooterView(footerView);
MainAdapter mainAdapter = new MainAdapter(this);
recyclerView.setAdapter(mainAdapter);
mainAdapter.notifyDataSetChanged(createDataList());
}
use of androidx.appcompat.app.ActionBar in project SwipeRecyclerView by yanzhenjie.
the class DefineActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_refresh_loadmore);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
mRefreshLayout = findViewById(R.id.refresh_layout);
// 刷新监听。
mRefreshLayout.setOnRefreshListener(mRefreshListener);
mRecyclerView = findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
mRecyclerView.setOnItemClickListener(mItemClickListener);
// 自定义的核心就是DefineLoadMoreView类。
DefineLoadMoreView loadMoreView = new DefineLoadMoreView(this);
// 添加为Footer。
mRecyclerView.addFooterView(loadMoreView);
// 设置LoadMoreView更新监听。
mRecyclerView.setLoadMoreView(loadMoreView);
// 加载更多的监听。
mRecyclerView.setLoadMoreListener(mLoadMoreListener);
mAdapter = new MainAdapter(this);
mRecyclerView.setAdapter(mAdapter);
// 请求服务器加载数据。
loadData();
}
use of androidx.appcompat.app.ActionBar in project Signal-Android by WhisperSystems.
the class WallpaperCropActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dynamicTheme.onCreate(this);
setContentView(R.layout.chat_wallpaper_crop_activity);
RecipientId recipientId = getIntent().getParcelableExtra(EXTRA_RECIPIENT_ID);
Uri inputImage = Objects.requireNonNull(getIntent().getParcelableExtra(EXTRA_IMAGE_URI));
Log.i(TAG, "Cropping wallpaper for " + (recipientId == null ? "default wallpaper" : recipientId));
WallpaperCropViewModel.Factory factory = new WallpaperCropViewModel.Factory(recipientId);
viewModel = ViewModelProviders.of(this, factory).get(WallpaperCropViewModel.class);
imageEditor = findViewById(R.id.image_editor);
View sentBubble = findViewById(R.id.preview_bubble_2);
TextView bubble2Text = findViewById(R.id.chat_wallpaper_bubble2_text);
View setWallPaper = findViewById(R.id.preview_set_wallpaper);
SwitchCompat blur = findViewById(R.id.preview_blur);
ColorizerView colorizerView = findViewById(R.id.colorizer);
setupImageEditor(inputImage);
setWallPaper.setOnClickListener(v -> setWallpaper());
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar supportActionBar = Objects.requireNonNull(getSupportActionBar());
supportActionBar.setHomeAsUpIndicator(ContextCompat.getDrawable(this, R.drawable.ic_arrow_left_24));
supportActionBar.setDisplayHomeAsUpEnabled(true);
blur.setOnCheckedChangeListener((v, checked) -> viewModel.setBlur(checked));
viewModel.getBlur().observe(this, blurred -> {
setBlurred(blurred);
if (blurred != blur.isChecked()) {
blur.setChecked(blurred);
}
});
viewModel.getRecipient().observe(this, r -> {
if (r.getId().isUnknown()) {
bubble2Text.setText(R.string.WallpaperCropActivity__set_wallpaper_for_all_chats);
} else {
bubble2Text.setText(getString(R.string.WallpaperCropActivity__set_wallpaper_for_s, r.getDisplayName(this)));
sentBubble.getBackground().setColorFilter(r.getChatColors().getChatBubbleColorFilter());
colorizerView.setBackground(r.getChatColors().getChatBubbleMask());
}
});
sentBubble.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
colorizerView.setProjections(Collections.singletonList(Projection.relativeToViewWithCommonRoot(sentBubble, colorizerView, new Projection.Corners(ViewUtil.dpToPx(18)))));
});
}
use of androidx.appcompat.app.ActionBar in project Conversations by siacs.
the class ManageAccountActivity method refreshUiReal.
@Override
protected void refreshUiReal() {
synchronized (this.accountList) {
accountList.clear();
accountList.addAll(xmppConnectionService.getAccounts());
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);
}
invalidateOptionsMenu();
mAccountAdapter.notifyDataSetChanged();
}
use of androidx.appcompat.app.ActionBar in project Conversations by siacs.
the class TrustKeysActivity method showCameraToast.
private void showCameraToast() {
mUseCameraHintToast = Toast.makeText(this, R.string.use_camera_icon_to_scan_barcode, Toast.LENGTH_LONG);
ActionBar actionBar = getSupportActionBar();
mUseCameraHintToast.setGravity(Gravity.TOP | Gravity.END, 0, actionBar == null ? 0 : actionBar.getHeight());
mUseCameraHintToast.show();
}
Aggregations