ImageSwitcher
An Android library allowing for easy, configuration-less, touch view switching.
Install / Use
/learn @Mithrandir21/ImageSwitcherREADME
ImageSwitcher
An Android library allowing for easy, configuration-less, touch view switching.
Usage
The functionality can be added to both Views and ViewGroups, but the touch makes most sense on a <b>Transparent ViewGroup</b>.
Example
Activity / Fragment - Setup
ViewGroup touchViewGroup = [Get the Transparent ViewGroup]
DraweeView imageA = [Get ImageA];
DraweeView imageB = [Get ImageB];
DraweeView imageC = [Get ImageC];
ArrayList<Uri> imageUri = [Get Image URIs]
// 1. Create the (convenience class) containing the switching functions.
ImageSwitcher imageSwitcher = new ImageSwitcher(imageUri, imageA, imageB, imageC);
// 2. Create Touch listener.
SwitchListener switchListener = new SwitchListener(context, imageSwitcher.viewTracker, imageSwitcher);
// 3. Add the Touch listener .
touchViewGroup.setOnTouchListener(switchListener);
Layout
<FrameLayout
android:id="@+id/transparent_touch_area"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/media_image_A"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="gone"/>
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/media_image_B"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/media_image_C"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="gone"/>
</FrameLayout>
Change Log
Version 0.3
- Added Boolean parameters to Switcher functions to indicate whether function called because of user action or because of some system action.
Version 0.2
- Made some internal SwitchListener functions public for easier access and functionality.
- Updated from Fresco 0.7 to 0.8.
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
