Android Swipe for older APIs

I could use http://developer.android.com/reference/android/support/v4/view/ViewPager.html but I need something much simplier like:
https://github.com/fry15/uk.co.jasonfry.android.tools. For my small static gallery there is only one tag in xml:


and in Java:

SwipeView sv = (SwipeView) findViewById(R.id.swipe_gallery);
ArrayList imagesList = (ArrayList) Cache.getInstance().readFromCache(GalleryService.IMAGES_CACHE_FORMAT);
if(imagesList != null) {
    for(HashMap imageData : imagesList) {
        Bitmap bitmap = BitmapUtils.fetchCachedImage((String) imageData.get("path"));
        ImageView imageView = new ImageView(this);
        imageView.setPadding(10, 8, 10, 10);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(250, 250);
        imageView.setLayoutParams(params);
        imageView.setImageBitmap(bitmap);
        imageView.setBackgroundResource(R.drawable.under_big_photo);
        LinearLayout layout = new LinearLayout(this);
        layout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
        layout.addView(imageView);
        sv.addView(layout);
    }
}

Simple QR code checking

This is scanning through the Intent – you need zxing library from http://code.google.com/p/zxing/ and Barcode Scanner from Market installed. After clicking button you are redirected to Barcode Scanner, which returns scanning result to Activity.

package com.example;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

public class QRCodeTestActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button qrButton = (Button) findViewById(R.id.qr_button);
        View.OnClickListener l;
        qrButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                IntentIntegrator integrator = new IntentIntegrator(QRCodeTestActivity.this);
                integrator.initiateScan();
            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
        if (scanResult != null) {
            Toast.makeText(getApplicationContext(), "resultCode: " + resultCode + " -> " + scanResult.getContents() + " " + scanResult.getFormatName(), Toast.LENGTH_LONG).show();
        }
    }
}

Setup

public class TestHighlight {

	public void highlight() {
		System.out.println("Highlighted");
	}

}

	

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress