cmupdaterapp.ui.ScreenshotActivity Source Code | www.androidadb.com

.Souce Code of cmupdaterapp.ui.

package cmupdaterapp.ui;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.KeyEvent;

import android.view.View;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.GridView;

import cmupdaterapp.customTypes.Screenshot;

import cmupdaterapp.customTypes.UpdateInfo;

import cmupdaterapp.listadapters.ScreenshotGridViewAdapter;

import cmupdaterapp.misc.Constants;

import cmupdaterapp.tasks.DownloadImageTask;

import cmupdaterapp.utils.Preferences;

public class ScreenshotActivity extends Activity {

private static ScreenshotGridViewAdapter imageAdapter;

private DownloadImageTask downloadImageTask;

public static void NotifyChange() {

imageAdapter.notifyDataSetChanged();

}

public static Screenshot getItem(int position) {

return (Screenshot) imageAdapter.getItem(position);

}

public static int getScreenshotSize() {

return imageAdapter.getCount();

}

public static void AddScreenshot(Screenshot s) {

imageAdapter.AddScreenshot(s);

}

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.screenshots);

Intent i = getIntent();

Bundle b = i.getExtras();

UpdateInfo ui = (UpdateInfo) b.get(Constants.SCREENSHOTS_UPDATE);

GridView gridview = (GridView) findViewById(R.id.gridview);

imageAdapter = new ScreenshotGridViewAdapter(this, ui.screenshots.size());

gridview.setAdapter(imageAdapter);

gridview.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView parent, View v, int position, long id) {

//Only start the Activity, when the Image is loaded

if (imageAdapter.GetRealScreenshotSize() > position) {

Intent i = new Intent(ScreenshotActivity.this, ScreenshotDetailActivity.class);

i.putExtra(Constants.SCREENSHOTS_POSITION, position);

startActivity(i);

}

}

});

//In onCreate, cause when pressing back from Detail, the old Screenshots remain in the List

downloadImageTask = new DownloadImageTask(this, new Preferences(this).displayDebugOutput());

downloadImageTask.execute(ui);

}

@Override

protected void onDestroy() {

super.onDestroy();

//Stop image downloading

downloadImageTask.cancel(true);

imageAdapter.Destroy();

imageAdapter.ClearScreenshots();

}

@Override

public boolean dispatchKeyEvent(KeyEvent event) {

int keyCode = event.getKeyCode();

//We need the ACTION_DOWN here, cause otherwise when you press back on the screenshotdetailactivity,

//the ACTION_UP event is sent to this activity, and this will result in going back twice

if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN) {

//Stop the Activity on BackKey

onDestroy();

finish();

return true;

} else

return super.dispatchKeyEvent(event);

}

}

Related Class of cmupdaterapp.ui.ScreenshotActivity

Copyright © 2011 www.androidadb.com. All rights reserved. All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc. Contact . See also:

|

|

|

Read More Post

STAY CONNECTED

Most Popular

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know
17 Dec

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know

If you’re heading to Singapore for a few weeks or many months, maybe for work or study or just to

Manifesting Your Dream Career: Finding Your Passion And Purpose
01 Aug

Manifesting Your Dream Career: Finding Your Passion And Purpose

Are you passionate about finding your dream career? Manifesting can help you align your career with your passions and purpose.

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service
27 Feb

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service

Finding a reliable auto service provider is paramount in the bustling world of vehicle maintenance and repair. That's where Carolina

Floratam: The Robust Grass Solution From Council Growers SOD
25 Jan

Floratam: The Robust Grass Solution From Council Growers SOD

Floratam grass, a popular St. Augustine variety, has become a go-to choice for homeowners and landscapers seeking a lush, durable

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair
25 Jan

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair

For vehicle owners, the braking system is among the most critical components for safety and performance. Carolina Mobile Autoservice, a

Safeguarding Your Property: Expert Water Damage Services By MBC Capital
24 Jan

Safeguarding Your Property: Expert Water Damage Services By MBC Capital

Water damage can significantly impact homes and businesses, often leaving a trail of destruction and disruption in its wake. Understanding