Android Open Source - kluster-android User Profile Fragment






From Project

Back to project page kluster-android.

License

The source code is released under:

Apache License

If you think the Android project kluster-android 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.cs446.kluster.views.fragments;
/*w w  w .  j a v a  2s .  c  om*/
import android.app.Activity;
import android.app.Fragment;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;

import com.cs446.kluster.R;
import com.cs446.kluster.data.PhotoProvider;
import com.cs446.kluster.net.AuthKlusterRestAdapter;
import com.cs446.kluster.net.KlusterService;
import com.cs446.kluster.net.PhotosCallback;

public class UserProfileFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
  PhotoGridAdapter mAdapter;
  
  @Override
  public void onAttach(Activity activity) {
    // TODO Auto-generated method stub
    super.onAttach(activity);
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.userprofile_page , container, false);
    
    String[] cols = new String[] { "location" };
    int[]   views = new int[]   { R.id.photogrid_imgBackground };
    
    mAdapter = new PhotoGridAdapter(getActivity(), R.layout.photogridcell_layout, null, cols, views, 0);
    
    GridView gridView=(GridView)view.findViewById(R.id.profilePagePhotoGrid);
    gridView.setAdapter(mAdapter);
    
    gridView.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        PhotoViewerFragment fragment = new PhotoViewerFragment();    
        Bundle bundle = new Bundle();
        bundle.putString("url", (String)parent.getItemAtPosition(position));
        fragment.setArguments(bundle);
        
        getFragmentManager().beginTransaction().replace(R.id.main_container, fragment).addToBackStack(fragment.toString()).commit();
      }
    });
    
      /* Start loader */  
        getLoaderManager().initLoader(0, null, this);  
    
    RestAdapter restAdapter = new AuthKlusterRestAdapter().build();  
    KlusterService service = restAdapter.create(KlusterService.class);  
    Log.w("UserProfileFragment", "UserId: "+ getArguments().getString("userid"));
    service.getPhotosByUserIds(getArguments().getString("userid"), new PhotosCallback(getActivity()));    
    getActivity().getActionBar().setTitle(getArguments().getString("username"));
    
    return view;
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    
    if (getActivity().getFragmentManager().getBackStackEntryCount() > 0) {
      getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
    }

  }

  @Override
  public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {
        String[] selectionArgs = {getArguments().getString("userid")};
    return new CursorLoader(getActivity(), PhotoProvider.CONTENT_URI, null, "userid = ?", selectionArgs, null);
  }
    
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    Log.w("UserProfileFragment", Integer.toString(mAdapter.getCount()));
    mAdapter.changeCursor(cursor);
  }
  
  @Override
  public void onLoaderReset(Loader<Cursor> loader) {
    mAdapter.changeCursor(null);
  }
}




Java Source Code List

android.app.GridFragment.java
android.app.NonSwipeableViewPager.java
android.app.ScaleImageView.java
com.cs446.kluster.ConfigManager.java
com.cs446.kluster.KlusterApplication.java
com.cs446.kluster.cache.CacheUtils.java
com.cs446.kluster.cache.DiskLruCache.java
com.cs446.kluster.cache.DiskLruImageCache.java
com.cs446.kluster.cache.KlusterCache.java
com.cs446.kluster.data.AbstractContentStorageAdapter.java
com.cs446.kluster.data.EventProvider.java
com.cs446.kluster.data.EventStorageAdapter.java
com.cs446.kluster.data.PhotoProvider.java
com.cs446.kluster.data.PhotoStorageAdapter.java
com.cs446.kluster.data.SearchProvider.java
com.cs446.kluster.data.SearchStorageAdapter.java
com.cs446.kluster.data.StorageAdapter.java
com.cs446.kluster.data.StorageConstants.java
com.cs446.kluster.data.serialize.AuthUserAdapter.java
com.cs446.kluster.data.serialize.EventAdapter.java
com.cs446.kluster.data.serialize.PhotoAdapter.java
com.cs446.kluster.data.serialize.SerializerUtils.java
com.cs446.kluster.data.serialize.UserAdapter.java
com.cs446.kluster.map.MapUtils.java
com.cs446.kluster.models.AuthUser.java
com.cs446.kluster.models.Event.java
com.cs446.kluster.models.Photo.java
com.cs446.kluster.models.User.java
com.cs446.kluster.net.AuthInterceptor.java
com.cs446.kluster.net.AuthKlusterRestAdapter.java
com.cs446.kluster.net.EventsCallback.java
com.cs446.kluster.net.KlusterRestAdapter.java
com.cs446.kluster.net.KlusterService.java
com.cs446.kluster.net.NetworkUtils.java
com.cs446.kluster.net.PhotosCallback.java
com.cs446.kluster.net.UploadService.java
com.cs446.kluster.views.activities.LoginActivity.java
com.cs446.kluster.views.activities.MainActivity.java
com.cs446.kluster.views.activities.PhotoFactory.java
com.cs446.kluster.views.activities.PhotoGridActivity.java
com.cs446.kluster.views.fragments.DiscoverFragment.java
com.cs446.kluster.views.fragments.EventDialogFragment.java
com.cs446.kluster.views.fragments.EventGridAdapter.java
com.cs446.kluster.views.fragments.EventGridFragment.java
com.cs446.kluster.views.fragments.EventMapFragment.java
com.cs446.kluster.views.fragments.FilterDialogFragment.java
com.cs446.kluster.views.fragments.PhotoGridAdapter.java
com.cs446.kluster.views.fragments.PhotoGridFragment.java
com.cs446.kluster.views.fragments.PhotoViewerFragment.java
com.cs446.kluster.views.fragments.SearchFragment.java
com.cs446.kluster.views.fragments.SearchGridFragment.java
com.cs446.kluster.views.fragments.SearchMapFragment.java
com.cs446.kluster.views.fragments.SignupFragment.java
com.cs446.kluster.views.fragments.UserProfileFragment.java
com.cs446.kluster.views.map.PhotoInfoWindowAdapter.java