Android Open Source - GalDroid Gallery Listing Activitiy






From Project

Back to project page GalDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project GalDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * GalDroid - a webgallery frontend for android
 * Copyright (C) 2011  Raptor 2101 [raptor2101@gmx.de]
 *    /*from  w  ww.ja v a2s.  c  o m*/
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.  
 */

package de.raptor2101.GalDroid.Activities;

import java.security.NoSuchAlgorithmException;
import java.util.List;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import de.raptor2101.GalDroid.R;
import de.raptor2101.GalDroid.Config.GalDroidPreference;
import de.raptor2101.GalDroid.WebGallery.ImageCache;
import de.raptor2101.GalDroid.WebGallery.Tasks.CleanUpCacheTask;
import de.raptor2101.GalDroid.WebGallery.Tasks.SyncronizeCacheTask;
import de.raptor2101.GalDroid.WebGallery.Tasks.CacheTaskListener;

public class GalleryListingActivitiy extends ListActivity implements CacheTaskListener {
  private ProgressDialog mProgressDialog;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    registerForContextMenu(getListView());
  }

  @Override
  public boolean onContextItemSelected(MenuItem item) {

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    TextView view = (TextView) info.targetView;

    String galleryName = view.getText().toString();
    if (item.getItemId() == R.id.item_edit_gallery) {
      Intent intent = new Intent(this, EditGalleryActivity.class);
      intent.putExtra(GalDroidApp.INTENT_EXTRA_GALLERY_PROVIDER, galleryName);
      this.startActivity(intent);
    } else {
      GalDroidPreference.deleteGallery(galleryName);
      recreate();
    }
    return true;
  }

  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.gallery_context_menu, menu);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.gallery_menu, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.item_create_new) {
      Intent intent = new Intent(this, EditGalleryActivity.class);
      this.startActivity(intent);
    } else {
      CreateProgressDialog(R.string.menu_synchronize_cache);
      GalDroidApp app = (GalDroidApp) getApplication();
      SyncronizeCacheTask task = new SyncronizeCacheTask(app.getImageCache(), this);
      task.execute();
    }
    return true;
  }

  private void CreateProgressDialog(int titleRecouceId) {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setTitle(titleRecouceId);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(false);
    mProgressDialog.dismiss();
  }

  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    TextView view = (TextView) v;
    String galleryName = view.getText().toString();

    Intent intent = new Intent(this, GridViewActivity.class);
    intent.putExtra(GalDroidApp.INTENT_EXTRA_GALLERY_PROVIDER, galleryName);

    this.startActivity(intent);
  }

  @Override
  protected void onResume() {
    try {
      GalDroidApp app = (GalDroidApp) getApplication();
      app.Initialize(this);
      List<String> names = GalDroidPreference.getGalleryNames();
      
      if(names.size() == 0) {
        Intent intent = new Intent(this, EditGalleryActivity.class);
        this.startActivity(intent);
      }
      else
      {
        showNames(app, names);
      }
      
      
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }

    super.onResume();
  }
  
  private void showNames(GalDroidApp app, List<String> names) {
    setListAdapter(new ArrayAdapter<String>(this, R.layout.gallery_listing_activity, GalDroidPreference.getGalleryNames()));

    ImageCache cache = app.getImageCache();
    if (cache.isCleanUpNeeded()) {
      CreateProgressDialog(R.string.menu_cleanup_cache);
      CleanUpCacheTask task = new CleanUpCacheTask(cache, this);
      task.execute();
    }
  }

  public void onCacheOperationStart(int elementCount) {
    mProgressDialog.setMax(elementCount);
    mProgressDialog.setProgress(0);
    mProgressDialog.show();

  }

  public void onCacheOperationProgress(int elementCount) {
    mProgressDialog.setProgress(elementCount);

  }

  public void onCacheOperationDone() {
    mProgressDialog.dismiss();
    mProgressDialog = null;
  }
}




Java Source Code List

de.raptor2101.GalDroid.Activities.EditGalleryActivity.java
de.raptor2101.GalDroid.Activities.GalDroidApp.java
de.raptor2101.GalDroid.Activities.GalleryActivity.java
de.raptor2101.GalDroid.Activities.GalleryListingActivitiy.java
de.raptor2101.GalDroid.Activities.GridViewActivity.java
de.raptor2101.GalDroid.Activities.ImageViewActivity.java
de.raptor2101.GalDroid.Activities.Helpers.ActionBarHider.java
de.raptor2101.GalDroid.Activities.Helpers.ImageAdapter.java
de.raptor2101.GalDroid.Activities.Listeners.ImageViewOnTouchListener.java
de.raptor2101.GalDroid.Activities.Views.GalleryImageViewListener.java
de.raptor2101.GalDroid.Activities.Views.GalleryImageView.java
de.raptor2101.GalDroid.Activities.Views.ImageInformationView.java
de.raptor2101.GalDroid.Config.GalDroidPreference.java
de.raptor2101.GalDroid.Config.GalleryConfig.java
de.raptor2101.GalDroid.WebGallery.DegMinSec.java
de.raptor2101.GalDroid.WebGallery.GalleryFactory.java
de.raptor2101.GalDroid.WebGallery.ImageCache.java
de.raptor2101.GalDroid.WebGallery.ImageInformation.java
de.raptor2101.GalDroid.WebGallery.Stream.java
de.raptor2101.GalDroid.WebGallery.TitleConfig.java
de.raptor2101.GalDroid.WebGallery.Gallery3.DownloadObject.java
de.raptor2101.GalDroid.WebGallery.Gallery3.Gallery3Imp.java
de.raptor2101.GalDroid.WebGallery.Gallery3.ProgressListener.java
de.raptor2101.GalDroid.WebGallery.Gallery3.RestCall.java
de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.AlbumEntity.java
de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.CommentEntity.java
de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.EntityFactory.java
de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.Entity.java
de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.PictureEntity.java
de.raptor2101.GalDroid.WebGallery.Gallery3.Tasks.JSONArrayLoaderTask.java
de.raptor2101.GalDroid.WebGallery.Interfaces.GalleryDownloadObject.java
de.raptor2101.GalDroid.WebGallery.Interfaces.GalleryObjectComment.java
de.raptor2101.GalDroid.WebGallery.Interfaces.GalleryObject.java
de.raptor2101.GalDroid.WebGallery.Interfaces.GalleryProgressListener.java
de.raptor2101.GalDroid.WebGallery.Interfaces.WebGallery.java
de.raptor2101.GalDroid.WebGallery.Tasks.CacheTaskListener.java
de.raptor2101.GalDroid.WebGallery.Tasks.CleanUpCacheTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.GalleryLoaderTaskListener.java
de.raptor2101.GalDroid.WebGallery.Tasks.GalleryLoaderTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.GalleryVerifyTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.ImageInformationLoaderTaskListener.java
de.raptor2101.GalDroid.WebGallery.Tasks.ImageInformationLoaderTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.ImageLoaderTaskListener.java
de.raptor2101.GalDroid.WebGallery.Tasks.ImageLoaderTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.Progress.java
de.raptor2101.GalDroid.WebGallery.Tasks.RepeatingTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.SyncronizeCacheTask.java
de.raptor2101.GalDroid.WebGallery.Tasks.TaskInterface.java