百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
返回工具页/返回 Issues 列表
#585·subsampling-scale-image-view

图像平滑滚动

作者: sermyagin创建于 2024年8月28日更新于 2024年8月28日

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_viewer); if (savedInstanceState != null) { isDialogShowing = savedInstanceState.getBoolean(DIALOG_STATE_KEY, false); } sharedPreferences = getSharedPreferences(KEY.PREFS_NAME, MODE_PRIVATE); if (sharedPreferences.getBoolean(KEY.KEY_BRIGHTNESS, false)) { setBrightnessToMax(); } photoButtonBar = findViewById(R.id.photo_button_bar); imageView = findViewById(R.id.image_view); backButton = findViewById(R.id.imageback); backButton.setOnClickListener(v -> finish()); // Initialize GestureDetector and set onTouchListener for the imageView gestureDetector = new GestureDetector(this, new SwipeGestureDetector()); imageView.setOnTouchListener((v, event) -> gestureDetector.onTouchEvent(event)); // Retrieve the list of media paths from the Intent mediaPaths2 = getIntent().getStringArrayListExtra("MEDIA_PATHS"); if (mediaPaths2 == null || mediaPaths2.isEmpty()) { Toast.makeText(this, "No media paths provided", Toast.LENGTH_SHORT).show(); finish(); return; } // Get the current media file path mediaPath = getIntent().getStringExtra("MEDIA_PATH"); if (mediaPath != null) { currentIndex = mediaPaths2.indexOf(mediaPath); if (currentIndex == -1) { Toast.makeText(this, "Media path not found in list", Toast.LENGTH_SHORT).show(); finish(); return; } } else { Toast.makeText(this, "Media path not provided", Toast.LENGTH_SHORT).show(); finish(); return; } // Continue with loading the image mediaUri = getMediaUri(mediaPath); if (mediaUri == null) { Toast.makeText(this, "Media file not found", Toast.LENGTH_SHORT).show(); finish(); return; } // Load the image using the mediaUri imageView.setImageURI(mediaUri); }

内容来源: davemorrissey/subsampling-scale-image-view

查看 GitHub 原文在 GitHub 查看讨论