package uk.co.blatech.blaupload; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import uk.co.blatech.blaupload.ui.ImagePagerAdapter; import uk.co.blatech.blaupload.ui.ZoomViewPager; import uk.co.blatech.blaupload.util.EventBus; public class ImagePager extends Activity { private ZoomViewPager mViewPager; private JSONArray json; private ArrayList urls; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_pager); mViewPager = (ZoomViewPager) findViewById(R.id.imagePager); EventBus.getInstance().register(this); urls = new ArrayList(); String jsonText = getIntent().getStringExtra("json"); int id = getIntent().getIntExtra("position", 0); try { json = new JSONArray(jsonText); } catch (JSONException e) { //TODO: Error handling if we got something other than JSON Log.e(ImagePager.class.toString(), "Failed to parse JSON"); e.printStackTrace(); } for (int i = 0; i < json.length(); i++) { try { JSONObject item = json.getJSONObject(i); urls.add("http://www.lc8n.com/bla500/"+item.getString("filename")); } catch (JSONException e) { e.printStackTrace(); } } ImagePagerAdapter adapter = new ImagePagerAdapter(ImagePager.this, urls); mViewPager.setAdapter(adapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.image_pager, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }