mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
ブクマ作成・保存機能
This commit is contained in:
parent
7beecca0da
commit
cf79581638
|
@ -1,10 +1,11 @@
|
||||||
package one.nem.lacerta.component.viewer;
|
package one.nem.lacerta.component.viewer;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.GestureDetector;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -15,9 +16,12 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
// BookMarkFragment.java
|
// BookMarkFragment.java
|
||||||
public class BookMarkFragment extends Fragment {
|
public class BookMarkFragment extends Fragment {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BookmarkRepository bookmarkRepository;
|
BookmarkRepository bookmarkRepository;
|
||||||
|
|
||||||
|
private GestureDetector gestureDetector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.fragment_bookmark, container, false);
|
return inflater.inflate(R.layout.fragment_bookmark, container, false);
|
||||||
|
@ -27,14 +31,30 @@ public class BookMarkFragment extends Fragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
// ブックマーク追加ボタンがクリックされた時の処理
|
gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||||
view.findViewById(R.id.AddBookmark).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
|
// ダブルタップが検出された時の処理
|
||||||
|
handleDoubleTap();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ブックマークボタンがダブルタップされた時の処理
|
||||||
|
view.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
return gestureDetector.onTouchEvent(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDoubleTap() {
|
||||||
|
// ダブルタップが検出された時の処理
|
||||||
|
// ブックマークを作成
|
||||||
String pageId = "current_page_id";
|
String pageId = "current_page_id";
|
||||||
String title = "current_page_title";
|
String title = "current_page_title";
|
||||||
|
|
||||||
// ブックマークを作成
|
|
||||||
Bookmark bookmark = new Bookmark(
|
Bookmark bookmark = new Bookmark(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
title,
|
title,
|
||||||
|
@ -46,8 +66,6 @@ public class BookMarkFragment extends Fragment {
|
||||||
bookmarkRepository.addBookmark(bookmark);
|
bookmarkRepository.addBookmark(bookmark);
|
||||||
|
|
||||||
// ユーザーに成功メッセージを表示
|
// ユーザーに成功メッセージを表示
|
||||||
Toast.makeText(getContext(), "ブックマークが追加されました", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "ダブルタップでブックマークが追加されました", Toast.LENGTH_SHORT).show();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user