Android Open Source - african-art-talent-discovery Portfolio






From Project

Back to project page african-art-talent-discovery.

License

The source code is released under:

GNU General Public License

If you think the Android project african-art-talent-discovery 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

package com.ekoconnect.afriphotos;
/*from   w  w  w.j  a v  a 2s  .  c  om*/

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;

import com.appsng.adapters.PortfolioAdapter;
import com.appsng.connectors.AppUtility;
import com.appsng.connectors.LocalDataBase;
import com.appsng.models.PhotoList;
import com.appsng.reusables.TransparentDialog;
import com.appsng.reusables.Utilities;
import com.ekoconnect.afriphoto.fragments.Register;

public class Portfolio extends Activity {
  
  static GridView listView;
  static ArrayList<com.appsng.models.Portfolio> portfolios = new ArrayList<com.appsng.models.Portfolio>();
  static LocalDataBase localDataBase;
  static ArrayList<PhotoList> photolist = new ArrayList<PhotoList>();
  static PortfolioAdapter adapter;
  static EditText name;
  static Button create;
  boolean haveAccount = false;
  static SharedPreferences sharedPreferences;
  static Context context;
  String userid;
  
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        context = this;
        setContentView(R.layout.portfolio);        
        listView = (GridView)findViewById(R.id.portfolio);
        
        name = (EditText)findViewById(R.id.name);
        create = (Button)findViewById(R.id.create);
        
        localDataBase = new LocalDataBase(this);
    setTitle("Portfolio");
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    loadDataFromDb();
    
        userid = sharedPreferences.getString("userid", "");
    if(userid != "") {
      haveAccount = true;
      showUploadButtons(haveAccount);
    }else {
      showUploadButtons(false);
      Utilities.showAlert(this, "Need an account", "Hi there, you need to create an account to upload your art photos.");
      Utilities.newFragment = new Register();
      startActivity(new Intent(this, ActivityFragment.class));
      overridePendingTransition(R.anim.slide_in_left_, R.anim.slide_out_left_);
    }
    }
    
    
    private void showUploadButtons(boolean show) {
      if(show) {
          ((Button)findViewById(R.id.create)).setVisibility(View.VISIBLE);
          ((EditText)findViewById(R.id.name)).setVisibility(View.VISIBLE);
      }else {
        ((Button)findViewById(R.id.create)).setVisibility(View.GONE);
        ((EditText)findViewById(R.id.name)).setVisibility(View.GONE);
      }
  }

    

    @Override
    protected void onResume() {
      // TODO Auto-generated method stub
        userid = sharedPreferences.getString("userid", "");
      if(userid != "") {
      showUploadButtons(true);
    }else {
      showUploadButtons(false);
    }
      super.onResume();
    }



  public static void loadDataFromDb() {
    portfolios = localDataBase.getPortfolios();
        setUpListView();
        localDataBase.close();
  }

  private static void setUpListView() {
    adapter = new PortfolioAdapter(context, portfolios);
    listView.setAdapter(adapter);    
    setClickListener();
  }

  private static void setClickListener() {
    create.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        if(name.getText().toString().length() < 3) {
          Utilities.Toaster(context, "Invalid name");
        }else {
          TransparentDialog dialog = new TransparentDialog(context, R.drawable.ajax_loader);
          AppUtility appUtility = new AppUtility(context);
          appUtility.createPortfolio(name.getText().toString(), sharedPreferences.getString("userid", ""), dialog);
          name.setText("");
        }
      }
    });
    
  }
  
  
  
   
}




Java Source Code List

com.appsng.adapters.CommentAdapter.java
com.appsng.adapters.ImagePagerAdapter.java
com.appsng.adapters.NotificationAdapter.java
com.appsng.adapters.PhotoGridAdapter.java
com.appsng.adapters.PhotoItemAdapter.java
com.appsng.adapters.PortfolioAdapter.java
com.appsng.connectors.AppUtility.java
com.appsng.connectors.CustomHttpClient2.java
com.appsng.connectors.CustomHttpClient.java
com.appsng.connectors.HttpFileUpload.java
com.appsng.connectors.LocalDataBase.java
com.appsng.models.Comment.java
com.appsng.models.Notification.java
com.appsng.models.PhotoList.java
com.appsng.models.Photo.java
com.appsng.models.Portfolio.java
com.appsng.reusables.Base64.java
com.appsng.reusables.CropOptionAdapter.java
com.appsng.reusables.CropOption.java
com.appsng.reusables.ImageHelper.java
com.appsng.reusables.TransparentDialog.java
com.appsng.reusables.Utilities.java
com.appsng.reusables.WakeLocker.java
com.appsng.reusables.ZoomImage.java
com.ekoconnect.afriphoto.fragments.BaseFragment.java
com.ekoconnect.afriphoto.fragments.Comments.java
com.ekoconnect.afriphoto.fragments.FragmentImageView.java
com.ekoconnect.afriphoto.fragments.Home.java
com.ekoconnect.afriphoto.fragments.Index.java
com.ekoconnect.afriphoto.fragments.Notifications.java
com.ekoconnect.afriphoto.fragments.Register.java
com.ekoconnect.afriphotos.ActivityFragment.java
com.ekoconnect.afriphotos.AwesomeActivity.java
com.ekoconnect.afriphotos.CameraActivity.java
com.ekoconnect.afriphotos.CopyOfMainActivity.java
com.ekoconnect.afriphotos.GCMIntentService.java
com.ekoconnect.afriphotos.GCM.java
com.ekoconnect.afriphotos.HomeActivity.java
com.ekoconnect.afriphotos.ImageViewActivity.java
com.ekoconnect.afriphotos.ImageViewPager.java
com.ekoconnect.afriphotos.MainActivity.java
com.ekoconnect.afriphotos.MyPhotos.java
com.ekoconnect.afriphotos.NotificationActivity.java
com.ekoconnect.afriphotos.Portfolio.java
com.ekoconnect.afriphotos.RefreshListView.java
com.ekoconnect.afriphotos.SplashScreen.java
com.ekokonnect.aada.MainActivity.java