Created
July 16, 2012 11:14
-
-
Save JavaDeveloper/3122179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.android.filechooser.example; | |
| import android.app.Activity; | |
| import android.content.Intent; | |
| import android.os.Bundle; | |
| import android.util.Log; | |
| import com.iusenko.filechooser.FileChooserActivity; | |
| public class MainActivity extends Activity { | |
| private static final String TAG = MainActivity.class.getSimpleName(); | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| startActivityForResult(new Intent(this, FileChooserActivity.class), FileChooserActivity.PICK_UP_FILE_REQUEST); | |
| } | |
| @Override | |
| protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
| Log.d(TAG, "onActivityResult(" + requestCode + ", " + resultCode + ",...)"); | |
| if (FileChooserActivity.FILE_SELECTED_RESULT != resultCode) { | |
| return; | |
| } | |
| String path = data.getStringExtra(FileChooserActivity.SELECTED_FILE_KEY); | |
| Log.d(TAG, "Selected file: " + path); | |
| super.onActivityResult(requestCode, resultCode, data); | |
| } | |
| } |
<script src="https://gist.github.com/JavaDeveloper/3122179.js"></script>
<script src="https://gist.github.com/JavaDeveloper/3122179.js"></script>
<script src="https://gist.github.com/JavaDeveloper/3122179.js"></script>https://gist.github.com/JavaDeveloper/3122179.js
Clear the codes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import { useState } from 'react'
import { Button } from "/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "/components/ui/card"
import { Input } from "/components/ui/input"
import { Label } from "/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Plus, Trash2, Upload, X, Eye } from 'lucide-react'
interface Coin {
id: string
code: string
name: string
country: string
year: number
continent: string
metal: string
value: number
observations: string
obverseImage?: string
reverseImage?: string
flagImage?: string
}
const continents = [
'Africa',
'Asia',
'Europe',
'North America',
'South America',
'Oceania',
'Antarctica'
]
const metals = [
'Gold',
'Silver',
'Copper',
'Bronze',
'Nickel',
'Aluminum',
'Zinc',
'Steel',
'Bi-metal',
'Other'
]
export default function CoinArchiver() {
const [coins, setCoins] = useState<Coin[]>([])
const [formData, setFormData] = useState({
code: '',
name: '',
country: '',
year: new Date().getFullYear(),
continent: '',
metal: '',
value: 0,
observations: ''
})
const [images, setImages] = useState({
obverse: '',
reverse: '',
flag: ''
})
const [selectedCoin, setSelectedCoin] = useState<Coin | null>(null)
const handleInputChange = (field: string, value: string | number) => {
setFormData(prev => ({ ...prev, [field]: value }))
}
const handleImageUpload = (type: 'obverse' | 'reverse' | 'flag', file: File) => {
const reader = new FileReader()
reader.onload = (e) => {
setImages(prev => ({ ...prev, [type]: e.target?.result as string }))
}
reader.readAsDataURL(file)
}
const addCoin = () => {
if (!formData.code || !formData.name || !formData.country || !formData.continent || !formData.metal) {
alert('Please fill in all required fields')
return
}
}
const removeCoin = (id: string) => {
setCoins(prev => prev.filter(coin => coin.id !== id))
if (selectedCoin?.id === id) {
setSelectedCoin(null)
}
}
const totalCoins = coins.length
const totalValue = coins.reduce((sum, coin) => sum + coin.value, 0)
return (
Coin Archiver
)
}
Share
Refresh