Search in sources :

Example 1 with Entity

use of com.androidquery.simplefeed.data.Entity in project simplefacebook by androidquery.

the class MenuActivity method initActionBar.

private void initActionBar() {
    ActionBar bar = getActionBar();
    if (bar == null)
        return;
    bar.setCustomView(R.layout.action_custom);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    PQuery aq = aq2.recycle(bar.getCustomView());
    currentMode = getMode();
    AQUtility.debug("mode", currentMode);
    if (currentMode != null) {
        List<FeedMode> modes = Arrays.asList(FeedMode.values());
        ArrayAdapter<FeedMode> adapter = new ArrayAdapter<FeedMode>(this, R.layout.action_modes, modes);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        currentIndex = modes.indexOf(currentMode);
        aq.id(R.id.spinner_action_bar).adapter(adapter).setSelection(currentIndex).visible().itemSelected(this, "modeSelected");
        if (!isTablet()) {
            aq.id(R.id.text_action_title).gone();
        } else {
            aq.id(R.id.text_action_title).visible();
        }
    } else {
        aq.id(R.id.text_action_title).visible();
        aq.id(R.id.spinner_action_bar).gone();
    }
    Entity entity = getSource();
    if (entity != null) {
        String tb = entity.getTb(handle);
        if (tb != null) {
            aq.id(R.id.image_action_bar).image(tb);
        }
        aq.id(R.id.text_action_title).text(entity.getName());
    } else {
        aq.id(R.id.text_action_title).gone();
    }
}
Also used : Entity(com.androidquery.simplefeed.data.Entity) PQuery(com.androidquery.simplefeed.PQuery) FeedMode(com.androidquery.simplefeed.enums.FeedMode) ActionBar(android.app.ActionBar) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with Entity

use of com.androidquery.simplefeed.data.Entity in project simplefacebook by androidquery.

the class NotificationFragment method itemClicked.

public void itemClicked(AdapterView<?> parent, View v, int pos, long id) {
    FeedItem item = (FeedItem) notis.getItem(pos);
    if (item == null)
        return;
    //TODO debug
    if (PrefUtility.isTestDevice()) {
    //item.setLink("http://www.facebook.com/groups/av8dbuy/");
    //item.setLink("http://www.facebook.com/events/248459785218011/");
    //item.setLink("http://www.facebook.com/hsu.mingchin/posts/10150431527981089?cmntid=10150431631416089");
    //item.setLink("http://www.facebook.com/event.php?eid=257399824315939&view=wall");
    //https://graph.facebook.com/0_276142965771432?locale=fr_FR
    //item.setLink("http://www.facebook.com/photo.php?fbid=101s50467124669668&set=a.287473759667.144316.208428464667&type=1");
    //item.setLink("http://www.facebook.com/photo.php?v=10150448332401110");
    }
    String link = item.getLink();
    if (link == null)
        return;
    Uri uri = Uri.parse(link);
    String fbId = extractItemId(item, link, uri);
    AQUtility.debug(item.getLink(), fbId);
    AQUtility.debug(item.getTo(), item.getTo().getName());
    ajaxRead(item);
    if (fbId != null) {
        CommentActivity.start(act, fbId);
        return;
    }
    fbId = extractUserId(item, link, uri);
    AQUtility.debug("userid", fbId);
    if (fbId != null) {
        Entity source = new Entity();
        source.setId(fbId);
        source.setName(fbId);
        FeedActivity.start(act, source);
        return;
    }
    if (openBrowser(item, link, uri)) {
        IntentUtility.openBrowser(act, link);
        return;
    }
    act.showToast(getString(R.string.marked_read));
    if (shouldIgnore(item, link, uri)) {
        return;
    }
    ErrorReporter.report("can't open:" + item.getType() + ":" + item.getLink() + ":" + item.getDesc());
}
Also used : Entity(com.androidquery.simplefeed.data.Entity) FeedItem(com.androidquery.simplefeed.data.FeedItem) Uri(android.net.Uri)

Example 3 with Entity

use of com.androidquery.simplefeed.data.Entity in project simplefacebook by androidquery.

the class FriendsActivity method filter.

private List<Entity> filter(CharSequence s, List<Entity> items) {
    String str = null;
    if (s != null) {
        str = s.toString();
    } else {
        str = aq.id(R.id.edit_input).getEditable().toString();
    }
    String[] terms = str.split("[\\s]+");
    List<Entity> result = new ArrayList<Entity>();
    for (Entity item : items) {
        String name = item.getName().toLowerCase();
        boolean miss = false;
        for (String term : terms) {
            if (!name.contains(term)) {
                miss = true;
                break;
            }
        }
        if (!miss) {
            result.add(item);
        }
    }
    return result;
}
Also used : Entity(com.androidquery.simplefeed.data.Entity) ArrayList(java.util.ArrayList)

Example 4 with Entity

use of com.androidquery.simplefeed.data.Entity in project simplefacebook by androidquery.

the class AllDataActivity method itemClicked.

public void itemClicked(AdapterView<?> list, View view, int pos, long id) {
    FeedMode item = items.getItem(pos);
    AQUtility.debug(item.getDisplay(), item.getHandler());
    if (FeedMode.NEWS.equals(item) || FeedMode.WALL.equals(item)) {
        Entity source = AppUtility.getDefaultSource(item);
        FeedActivity.start(this, source);
    } else {
        start(this, item.getHandler());
    }
}
Also used : Entity(com.androidquery.simplefeed.data.Entity) FeedMode(com.androidquery.simplefeed.enums.FeedMode)

Example 5 with Entity

use of com.androidquery.simplefeed.data.Entity in project simplefacebook by androidquery.

the class PostActivity method putPhotoTags.

private void putPhotoTags(Map<String, Object> params, List<Entity> tags) {
    if (tags == null || tags.size() == 0)
        return;
    try {
        JSONArray ja = new JSONArray();
        for (Entity tag : tags) {
            JSONObject jo = new JSONObject();
            jo.putOpt("tag_uid", tag.getId());
            jo.putOpt("x", 0);
            jo.putOpt("y", 0);
            ja.put(jo);
        }
        AQUtility.debug("tags", ja);
        params.put("tags", ja.toString());
    } catch (Exception e) {
        AQUtility.report(e);
    }
}
Also used : Entity(com.androidquery.simplefeed.data.Entity) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Aggregations

Entity (com.androidquery.simplefeed.data.Entity)15 PQuery (com.androidquery.simplefeed.PQuery)4 FeedMode (com.androidquery.simplefeed.enums.FeedMode)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 ActionBar (android.app.ActionBar)1 PendingIntent (android.app.PendingIntent)1 Uri (android.net.Uri)1 WebView (android.webkit.WebView)1 ArrayAdapter (android.widget.ArrayAdapter)1 FeedItem (com.androidquery.simplefeed.data.FeedItem)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1