Search in sources :

Example 66 with ActionBar

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());
}
Also used : MainAdapter(com.yanzhenjie.recyclerview.sample.adapter.MainAdapter) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 67 with ActionBar

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();
}
Also used : MainAdapter(com.yanzhenjie.recyclerview.sample.adapter.MainAdapter) DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 68 with ActionBar

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)))));
    });
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Projection(org.thoughtcrime.securesms.util.Projection) Uri(android.net.Uri) ColorizerView(org.thoughtcrime.securesms.conversation.colors.ColorizerView) View(android.view.View) ImageEditorView(org.signal.imageeditor.core.ImageEditorView) TextView(android.widget.TextView) TextView(android.widget.TextView) ColorizerView(org.thoughtcrime.securesms.conversation.colors.ColorizerView) ActionBar(androidx.appcompat.app.ActionBar) SwitchCompat(androidx.appcompat.widget.SwitchCompat) Toolbar(androidx.appcompat.widget.Toolbar)

Example 69 with ActionBar

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();
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 70 with ActionBar

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();
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)139 View (android.view.View)30 Toolbar (androidx.appcompat.widget.Toolbar)29 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)26 TextView (android.widget.TextView)18 Intent (android.content.Intent)11 Bundle (android.os.Bundle)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 ImageView (android.widget.ImageView)7 Uri (android.net.Uri)6 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)6 SharedPreferences (android.content.SharedPreferences)5 ListView (android.widget.ListView)5 Spinner (android.widget.Spinner)5 Typeface (com.mta.tehreer.graphics.Typeface)5 File (java.io.File)5 MenuItem (android.view.MenuItem)4 Button (android.widget.Button)4