Search in sources :

Example 11 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class HomeOtherGroupTimeLineDBTask method updateCount.

static void updateCount(String msgId, int commentCount, int repostCount) {
    String sql = "select * from " + HomeOtherGroupTable.HomeOtherGroupDataTable.TABLE_NAME + " where " + HomeOtherGroupTable.HomeOtherGroupDataTable.MBLOGID + "  = " + msgId + " order by " + HomeOtherGroupTable.HomeOtherGroupDataTable.ID + " asc limit 50";
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String id = c.getString(c.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.ID));
        String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.JSONDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                MessageBean value = gson.fromJson(json, MessageBean.class);
                value.setComments_count(commentCount);
                value.setReposts_count(repostCount);
                String[] args = { id };
                ContentValues cv = new ContentValues();
                cv.put(HomeOtherGroupTable.HomeOtherGroupDataTable.JSONDATA, gson.toJson(value));
                getWsd().update(HomeOtherGroupTable.HomeOtherGroupDataTable.TABLE_NAME, cv, HomeOtherGroupTable.HomeOtherGroupDataTable.ID + "=?", args);
            } catch (JsonSyntaxException e) {
            }
        }
    }
}
Also used : ContentValues(android.content.ContentValues) MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

Example 12 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class FriendsTimeLineDBTask method getHomeLineMsgList.

private static MessageListBean getHomeLineMsgList(String accountId, int limitCount) {
    Gson gson = new Gson();
    MessageListBean result = new MessageListBean();
    int limit = limitCount > AppConfig.DEFAULT_MSG_COUNT_50 ? limitCount : AppConfig.DEFAULT_MSG_COUNT_50;
    List<MessageBean> msgList = new ArrayList<MessageBean>();
    String sql = "select * from " + HomeTable.HomeDataTable.TABLE_NAME + " where " + HomeTable.HomeDataTable.ACCOUNTID + "  = " + accountId + " order by " + HomeTable.HomeDataTable.ID + " asc limit " + limit;
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeTable.HomeDataTable.JSONDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                MessageBean value = gson.fromJson(json, MessageBean.class);
                if (!value.isMiddleUnreadItem() && !TextUtils.isEmpty(value.getText())) {
                    value.getListViewSpannableString();
                }
                msgList.add(value);
            } catch (JsonSyntaxException e) {
                AppLogger.e(e.getMessage());
            }
        } else {
            msgList.add(null);
        }
    }
    //delete the null flag at the head positon and the end position
    for (int i = msgList.size() - 1; i >= 0; i--) {
        if (msgList.get(i) == null) {
            msgList.remove(i);
        } else {
            break;
        }
    }
    for (int i = 0; i < msgList.size(); i++) {
        if (msgList.get(i) == null) {
            msgList.remove(i);
        } else {
            break;
        }
    }
    result.setStatuses(msgList);
    c.close();
    return result;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

Example 13 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class HomeOtherGroupTimeLineDBTask method get.

static MessageListBean get(String accountId, String groupId, int limitCount) {
    Gson gson = new Gson();
    MessageListBean result = new MessageListBean();
    int limit = limitCount > AppConfig.DEFAULT_MSG_COUNT_50 ? limitCount : AppConfig.DEFAULT_MSG_COUNT_50;
    List<MessageBean> msgList = new ArrayList<MessageBean>();
    String sql = "select * from " + HomeOtherGroupTable.HomeOtherGroupDataTable.TABLE_NAME + " where " + HomeOtherGroupTable.HomeOtherGroupDataTable.ACCOUNTID + "  = " + accountId + " and " + HomeOtherGroupTable.HomeOtherGroupDataTable.GROUPID + " =  " + groupId + " order by " + HomeOtherGroupTable.HomeOtherGroupDataTable.ID + " asc limit " + limit;
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.JSONDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                MessageBean value = gson.fromJson(json, MessageBean.class);
                if (!value.isMiddleUnreadItem()) {
                    value.getListViewSpannableString();
                }
                msgList.add(value);
            } catch (JsonSyntaxException e) {
                AppLogger.e(e.getMessage());
            }
        } else {
            msgList.add(null);
        }
    }
    //delete the null flag at the head positon and the end position
    for (int i = msgList.size() - 1; i >= 0; i--) {
        if (msgList.get(i) == null) {
            msgList.remove(i);
        } else {
            break;
        }
    }
    for (int i = 0; i < msgList.size(); i++) {
        if (msgList.get(i) == null) {
            msgList.remove(i);
        } else {
            break;
        }
    }
    result.setStatuses(msgList);
    c.close();
    return result;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

Example 14 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class GalleryActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.galleryactivity_layout);
    animationView = (ImageView) findViewById(R.id.animation);
    currentViewPositionLayout = findViewById(R.id.position_layout);
    position = (TextView) findViewById(R.id.position);
    TextView sum = (TextView) findViewById(R.id.sum);
    //        rect = ((AnimationRect) getIntent().getParcelableArrayListExtra("rect")).scaledBitmapRect;
    MessageBean msg = getIntent().getParcelableExtra("msg");
    ArrayList<String> tmp = msg.getThumbnailPicUrls();
    for (int i = 0; i < tmp.size(); i++) {
        urls.add(tmp.get(i).replace("thumbnail", "large"));
    }
    sum.setText(String.valueOf(urls.size()));
    //jump to new gallery animation activity
    if (urls.size() < 10 && ImageUtility.isThisBitmapCanRead(FileManager.getFilePathFromUrl(urls.get(0), FileLocationMethod.picture_large))) {
        Intent intent = new Intent(this, GalleryAnimationActivity.class);
        intent.putExtra("msg", getIntent().getParcelableExtra("msg"));
        intent.putExtra("rect", getIntent().getParcelableArrayListExtra("rect"));
        intent.putExtra("position", getIntent().getIntExtra("position", 0));
        startActivity(intent);
        overridePendingTransition(0, 0);
        finish();
        return;
    }
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter());
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            GalleryActivity.this.position.setText(String.valueOf(position + 1));
        }
    });
    pager.setCurrentItem(getIntent().getIntExtra("position", 0));
    pager.setOffscreenPageLimit(1);
    pager.setPageTransformer(true, new ZoomOutPageTransformer());
    pager.setPadding(0, Utility.dip2px(STATUS_BAR_HEIGHT_DP_UNIT), 0, 0);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) TextView(android.widget.TextView) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) Point(android.graphics.Point)

Example 15 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class GalleryAnimationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.galleryactivity_animation_layout);
    rectList = getIntent().getParcelableArrayListExtra("rect");
    MessageBean msg = getIntent().getParcelableExtra("msg");
    ArrayList<String> tmp = msg.getThumbnailPicUrls();
    for (int i = 0; i < tmp.size(); i++) {
        urls.add(tmp.get(i).replace("thumbnail", "large"));
    }
    boolean disableHardwareLayerType = false;
    for (String url : urls) {
        if (url.contains(".gif")) {
            disableHardwareLayerType = true;
            break;
        }
    }
    position = (TextView) findViewById(R.id.position);
    initPosition = getIntent().getIntExtra("position", 0);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(getSupportFragmentManager()));
    final boolean finalDisableHardwareLayerType = disableHardwareLayerType;
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            GalleryAnimationActivity.this.position.setText(String.valueOf(position + 1));
        }

        @Override
        public void onPageScrollStateChanged(int scrollState) {
            if (scrollState != ViewPager.SCROLL_STATE_IDLE && finalDisableHardwareLayerType) {
                final int childCount = pager.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View child = pager.getChildAt(i);
                    if (child.getLayerType() != View.LAYER_TYPE_NONE) {
                        child.setLayerType(View.LAYER_TYPE_NONE, null);
                    }
                }
            }
        }
    });
    pager.setCurrentItem(getIntent().getIntExtra("position", 0));
    pager.setOffscreenPageLimit(1);
    pager.setPageTransformer(true, new ZoomOutPageTransformer());
    TextView sum = (TextView) findViewById(R.id.sum);
    sum.setText(String.valueOf(urls.size()));
    background = AnimationUtility.getAppContentView(this);
    if (savedInstanceState != null) {
        showBackgroundImmediately();
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) TextView(android.widget.TextView) ViewPager(android.support.v4.view.ViewPager) TextView(android.widget.TextView) View(android.view.View)

Aggregations

MessageBean (org.qii.weiciyuan.bean.MessageBean)52 Gson (com.google.gson.Gson)21 JsonSyntaxException (com.google.gson.JsonSyntaxException)16 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)8 Cursor (android.database.Cursor)7 Intent (android.content.Intent)6 CommentBean (org.qii.weiciyuan.bean.CommentBean)6 UserBean (org.qii.weiciyuan.bean.UserBean)6 DatabaseUtils (android.database.DatabaseUtils)4 SQLException (android.database.SQLException)4 View (android.view.View)4 PendingIntent (android.app.PendingIntent)3 Drawable (android.graphics.drawable.Drawable)3 SpannableString (android.text.SpannableString)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 RelativeLayout (android.widget.RelativeLayout)3 TextView (android.widget.TextView)3