Android Open Source - links Subscribed Group Card






From Project

Back to project page links.

License

The source code is released under:

MIT License

If you think the Android project links 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 org.iiitb.se.links.home.cards;
//from   w w w. j av a2 s  . c  o m
import it.gmariotti.cardslib.library.internal.Card;
import it.gmariotti.cardslib.library.internal.CardHeader;
import it.gmariotti.cardslib.library.internal.base.BaseCard;

import org.iiitb.se.links.GroupActivity;
import org.iiitb.se.links.R;
import org.iiitb.se.links.utils.StringConstants;
import org.iiitb.se.links.utils.network.MyProperties;
import org.iiitb.se.links.utils.network.groups.subscribed.GroupUnsubscriber;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.content.Intent;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;

public class SubscribedGroupCard extends AbstractGroupCard {
  private MenuItem unsubscribe = null;
  private GroupUnsubscriber groupUnsubscriber;

  public SubscribedGroupCard(Context context, JSONObject group) {
    super(context, group);
    groupUnsubscriber = new GroupUnsubscriber(context, this);
  }

  /**
   * Init
   */
  protected void init() {
    header = new CardHeader(context);
    // Add a popup menu. This method set OverFlow button to visible
    header.setButtonOverflowVisible(true);
    header
        .setPopupMenuListener(new CardHeader.OnClickCardHeaderPopupMenuListener() {
          @Override
          public void onMenuItemClick(BaseCard card, MenuItem item) {
            initData();
            if (item == unsubscribe) {
              groupUnsubscriber.unsubscribeToGroup();
            }
          }
        });
    // Add a PopupMenuPrepareListener to add dynamically a menu entry it is
    // optional.
    header
        .setPopupMenuPrepareListener(new CardHeader.OnPrepareCardHeaderPopupMenuListener() {
          @Override
          public boolean onPreparePopupMenu(BaseCard card, PopupMenu popupMenu) {
            unsubscribe = popupMenu.getMenu().add(
                context.getString(R.string.unsubscribe_group));
            return true;
          }
        });
    addCardHeader(header);

    this.setOnClickListener(new OnCardClickListener() {
      @Override
      public void onClick(Card card, View view) {
        loadGroupBookmarksActivity();
      }
    });
  }

  /**
   * Change the Activity
   */
  protected void loadGroupBookmarksActivity() {
    String groupId = null;
    try {
      groupId = group.getString(StringConstants.ID);
    } catch (JSONException e) {
      e.printStackTrace();
    }
    Intent intent = new Intent(context, GroupActivity.class);
    MyProperties.getInstance().groupId = groupId;
    context.startActivity(intent);
  }

}




Java Source Code List

org.iiitb.se.links.GroupActivity.java
org.iiitb.se.links.MainActivity.java
org.iiitb.se.links.custom.ExpandableHeightGridView.java
org.iiitb.se.links.group.fragments.AddBookmarkInGroupFragment.java
org.iiitb.se.links.group.fragments.BookmarkSearchInGroupsFragment.java
org.iiitb.se.links.group.fragments.GroupLinkFragment.java
org.iiitb.se.links.home.ResourceLoader.java
org.iiitb.se.links.home.cards.AbstractGroupCard.java
org.iiitb.se.links.home.cards.BookmarkCard.java
org.iiitb.se.links.home.cards.RequestsGroupCard.java
org.iiitb.se.links.home.cards.ShareGroupCard.java
org.iiitb.se.links.home.cards.SubscribedGroupCard.java
org.iiitb.se.links.home.cards.expand.BookmarkCardExpand.java
org.iiitb.se.links.home.cards.expand.adapter.TagViewAdapter.java
org.iiitb.se.links.home.fragments.AddBookmarkFragment.java
org.iiitb.se.links.home.fragments.BookmarkSearchFragment.java
org.iiitb.se.links.home.fragments.EditBookmarkFragment.java
org.iiitb.se.links.home.fragments.LinkFragment.java
org.iiitb.se.links.home.fragments.RequestsGroupFragment.java
org.iiitb.se.links.home.fragments.SubscribedGroupFragment.java
org.iiitb.se.links.home.fragments.adapter.AbstractGroupsAdapter.java
org.iiitb.se.links.home.fragments.adapter.BookmarksAdapter.java
org.iiitb.se.links.home.fragments.adapter.RequestsGroupsAdapter.java
org.iiitb.se.links.home.fragments.adapter.ShareGroupsAdapter.java
org.iiitb.se.links.home.fragments.adapter.SubscribedGroupsAdapter.java
org.iiitb.se.links.utils.AuthorizationClient.java
org.iiitb.se.links.utils.BookmarkLoadType.java
org.iiitb.se.links.utils.BookmarkOperations.java
org.iiitb.se.links.utils.DomainExtractor.java
org.iiitb.se.links.utils.FragmentTypes.java
org.iiitb.se.links.utils.StringConstants.java
org.iiitb.se.links.utils.URLConstants.java
org.iiitb.se.links.utils.network.AbstractResourceDownloader.java
org.iiitb.se.links.utils.network.MyProperties.java
org.iiitb.se.links.utils.network.WebpageLoader.java
org.iiitb.se.links.utils.network.bookmarks.BookmarkAdder.java
org.iiitb.se.links.utils.network.bookmarks.BookmarkDeleter.java
org.iiitb.se.links.utils.network.bookmarks.BookmarkEditor.java
org.iiitb.se.links.utils.network.bookmarks.BookmarkGroupAdder.java
org.iiitb.se.links.utils.network.bookmarks.BookmarkSharer.java
org.iiitb.se.links.utils.network.bookmarks.Logout.java
org.iiitb.se.links.utils.network.bookmarks.TimelineLoader.java
org.iiitb.se.links.utils.network.bookmarks.search.BookmarkInGroupsSearchLoader.java
org.iiitb.se.links.utils.network.bookmarks.search.BookmarkSearchLoader.java
org.iiitb.se.links.utils.network.groups.GroupTimelineLoader.java
org.iiitb.se.links.utils.network.groups.requests.GroupRequestsDecider.java
org.iiitb.se.links.utils.network.groups.requests.RequestsGroupsLoader.java
org.iiitb.se.links.utils.network.groups.subscribed.GroupUnsubscriber.java
org.iiitb.se.links.utils.network.groups.subscribed.SubscribedGroupsLoader.java