Skip to content

Offers‐Tab

Abdul Mueed | AM Dev edited this page Jun 29, 2026 · 3 revisions

🎁 Offers Tab

The Offers tab allows users to view and complete CPA (Cost Per Action) offers from multiple API sources to earn rewards.


📁 File Locations

File Path Purpose
Main Fragment ui/offers/OffersFragment.kt Main offers list UI and logic
Detail Fragment ui/offers/OfferDetailFragment.kt Individual offer detail view
ViewModel ui/offers/OffersViewModel.kt API calls and data management
Adapter ui/offers/OffersAdapter.kt RecyclerView adapter
Data Models ui/offers/model/CpaOffer.kt Offer data classes
Main Layout res/layout/fragment_offers.xml Main offers screen layout
Detail Layout res/layout/fragment_offer_detail.xml Offer detail screen layout
Item Layout res/layout/item_offer.xml Individual offer item layout
GitHub Config https://cdn.jsdelivr.net/gh/am-abdulmueed/offers@main/offers.json Dynamic API config

🔌 API Integration

The Offers tab fetches from two different APIs in parallel:

1. CPALead API (Primary)

  • URL fetched dynamically from GitHub config
  • No authentication required
  • Returns ranked offers

2. OGAds API (Secondary)

  • Endpoint: https://authenticateapp.online/api/v2
  • Method: GET
  • Auth: Bearer token in headers
  • Parameters: ip, user_agent, max (default: 10)
  • Uses IP-based geo-targeting

GitHub Config Structure

{
  "offer": "https://cpalead.com/dashboard/reports/campaigns/list.json?api_key=YOUR_API_KEY"
}

🗃️ Data Models

CpaOffer

data class CpaOffer(
    val id: Int,
    val title: String,
    val description: String?,
    val conversion: String?,
    val device: String?,
    val dailyCap: Int?,
    val isFastPay: Boolean?,
    val link: String,
    val previewLink: String?,
    val amount: Double,
    val payoutCurrency: String?,
    val payoutType: String?,
    val countries: List<String>?,
    val epc: Double?,
    val creatives: OfferCreatives?,
    val offerRank: Int?,
    val payoutsPerCountry: Map<String, Double>?
)

OfferCreatives

data class OfferCreatives(
    val url: String?   // Image URL for offer
)

🖥️ UI Components

Main Offers Screen (OffersFragment)

  • RecyclerView with offer cards
  • Swipe-to-refresh functionality
  • Loading / Empty / Offline states
  • Debug Panel (visible in debug builds only)
    • Live API logs with timestamps
    • Copy logs to clipboard

Layout Structure

  1. Debug Panel (toggleable FAB)
  2. Loading State (progress indicator)
  3. Empty State (gift icon + message)
  4. Offers List (RecyclerView + SwipeRefreshLayout)
  5. Offline Screen (shimmer effect + retry button)

Offer Detail Screen (OfferDetailFragment)

Displays full offer info:

  • Offer image
  • Payout amount and currency
  • Supported countries with flag emojis
  • Device compatibility icons
  • Conversion requirements
  • Description

Offer Card (OffersAdapter)

Each card shows:

  • Offer image
  • Offer title
  • Payout amount (2 decimal places)
  • Currency symbol
  • Payout type label

Payout Type Mapping

Code Label
CPI Install
CPE Action
CPR Registration

🔄 API Flow

OffersFragment.onCreate()
  └─ ViewModel.fetchOffers()
       └─ Check cache
            ├─ Cache fresh → Return cached data
            └─ Cache expired → Fetch from APIs (parallel)
                  ├─ fetchPublicIP() → OGAds API
                  └─ CPALead API (via GitHub config URL)
                        └─ Combine → Cache → Update UI

💾 Caching System

Setting Value
Cache Duration 30 minutes
Storage In-memory (ViewModel)

Cache is skipped and refreshed if forceRefresh = true or cache has expired.


🐛 Debug Panel

Only visible in debug builds (hidden in release).

  • Toggle via floating bug icon button
  • Shows real-time logs with timestamps:
    • [CPALead] — CPALead API operations
    • [OGAds] — OGAds API operations

Sample Log

[14:30:15] Starting offers fetch...
[14:30:16] Got public IP: 192.168.1.1
[14:30:18] [CPALead] Success! Got 15 offers
[14:30:19] [OGAds] Success! Got 8 offers
[14:30:19] Total offers: 23

⚠️ Error Handling

Scenario Behavior
Network error Show offline screen with retry
CPALead fails Continue with OGAds only
OGAds fails Continue with CPALead only
No offers Show empty state with gift icon

📤 Share Functionality

When a user shares an offer, the message format is:

🎁 *Offer Title*

🤖 *Supported Device:* Android
🇺🇸 *Available in:* United States

📝 *Description:*
Complete this offer to earn reward.

🔗 *Get this offer:*
https://offer-link.com

──────────────
📲 Download from PluginStream Max
🌐 https://pluginstream.pages.dev

🌍 Supported Countries

US, CA, GB, AU, NZ, DE, FR, IN, BR, MX


📡 API Response Examples

CPALead Response

{
  "status": "success",
  "number_offers": 15,
  "offers": [
    {
      "id": 1234,
      "title": "Game App Install",
      "amount": 1.50,
      "payout_currency": "USD",
      "payout_type": "CPI",
      "offer_rank": 1
    }
  ]
}

OGAds Response

{
  "success": true,
  "offers": [
    {
      "offerid": 5678,
      "name_short": "Survey App",
      "payout": "2.00",
      "link": "https://offer-link.com",
      "country": "US,CA,GB"
    }
  ]
}