Skip to content

Commit

Permalink
add the fastclick button
Browse files Browse the repository at this point in the history
  • Loading branch information
airlink committed Dec 11, 2023
1 parent e08b407 commit 0b6e1ec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package me.longluo.android.ui.fragment;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;

import io.github.longluo.util.ToastUtils;
import io.github.longluo.util.helpers.OnClickEvent;
import me.longluo.android.R;
import me.longluo.android.aop.Permissions;
import me.longluo.android.aop.SingleClick;
Expand All @@ -20,6 +24,8 @@ public final class MessageFragment extends TitleBarFragment<HomeActivity> {

private ImageView mImageView;

private Button mBtnFastClick;

public static MessageFragment newInstance() {
return new MessageFragment();
}
Expand All @@ -32,14 +38,18 @@ protected int getLayoutId() {
@Override
protected void initView() {
mImageView = findViewById(R.id.iv_message_image);

setOnClickListener(R.id.btn_message_image1, R.id.btn_message_image2, R.id.btn_message_image3,
R.id.btn_message_toast, R.id.btn_message_permission, R.id.btn_message_setting,
R.id.btn_message_black, R.id.btn_message_white, R.id.btn_message_tab);

mBtnFastClick = findViewById(R.id.btn_fast_click);
}

@Override
protected void initData() {

mBtnFastClick.setOnClickListener(new MySingleClickListener(1500));
}

@Override
Expand Down Expand Up @@ -104,11 +114,24 @@ public void onClick(View view) {
} else if (viewId == R.id.btn_message_tab) {

HomeActivity.start(getActivity(), HomeFragment.class);

}
}

@Permissions(Permission.CAMERA)
private void requestPermission() {
toast("获取摄像头权限成功");
}

public class MySingleClickListener extends OnClickEvent {

public MySingleClickListener(long delay) {
super(delay);
}

@Override
public void singleClick(View v) {
ToastUtils.showToast(getContext(), "A Click");
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/res/layout/message_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
android:layout_marginVertical="@dimen/dp_30"
android:text="切换到首页 Tab" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_fast_click"
style="@style/ButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/dp_30"
android:text="No Fast Click" />

</LinearLayout>

</androidx.core.widget.NestedScrollView>
Expand Down

0 comments on commit 0b6e1ec

Please sign in to comment.