private void saveStats(String slidesName, float totalAccessTime2, Float[] accessTimeFloats2) { PptBean temp = null; if (MainActivity.pptBeanMap != null) { temp = (PptBean) MainActivity.pptBeanMap.get(docId); if (temp != null) { UploadBean upTemp = (UploadBean) MainActivity.uploadBeanMap.get(docId); if (upTemp == null) { upTemp = new UploadBean(); upTemp.setPptName(slidesName); } temp.setTotalViewTime(temp.getTotalViewTime() + totalAccessTime2); upTemp.setTotalViewTime(upTemp.getTotalViewTime() + totalAccessTime2); ArrayList<ArrayList<Float>> accessTimesList = temp.getAccessTimes(); accessTimesList.add(new ArrayList<Float>(Arrays.asList(accessTimeFloats2))); temp.setDocId(docId); temp.setAccessTimes(accessTimesList); temp.setTotalViewTime(totalAccessTime); MainActivity.pptBeanMap.put(docId, temp); ArrayList<ArrayList<Float>> accessTimesListUp = upTemp.getAccessTimes(); accessTimesListUp.add(new ArrayList<Float>(Arrays.asList(accessTimeFloats2))); upTemp.setDocId(docId); upTemp.setAccessTimes(accessTimesListUp); upTemp.setTotalViewTime(totalAccessTime); MainActivity.uploadBeanMap.put(docId, upTemp); } } }
// Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_slides); currentSlideNum = 0; lastSlideNum = 0; // TODO: show stats on home page lastAccessDate = Calendar.getInstance().getTime(); // Get URL from called intent Intent myIntent = getIntent(); // gets the previously created intent slides = myIntent.getStringArrayExtra("imagearray"); docId = myIntent.getIntExtra("clicked", 0); PptBean temp = (PptBean) MainActivity.pptBeanMap.get(docId); if (temp != null) { slidesName = temp.getPptName(); totalAccessTime = temp.getTotalViewTime(); } /* SLIDE UP MENU */ thumbNailUrlArray = myIntent.getStringArrayExtra("thumbnailurlarray"); addSlideUpMenu(); if (slides != null) { image = (ImageView) findViewById(R.id.image); image.setImageBitmap(CacheManager.getImage(slides[currentSlideNum])); accessTimes = new Date[slides.length]; for (int i = 0; i < slides.length; i++) accessTimes[i] = now; accessTimeFloats = new Float[slides.length]; for (int j = 0; j < slides.length; j++) accessTimeFloats[j] = (float) 0.0; } addHomeButtonListener(); addGestureListener(); }