mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-11-04 11:34:06 +00:00 
			
		
		
		
	Determine post type
This commit is contained in:
		@@ -16,6 +16,7 @@ public class Post {
 | 
			
		||||
    private int userID;
 | 
			
		||||
    private int post_time;
 | 
			
		||||
    private String content;
 | 
			
		||||
    private PostTypes type;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //Set and get the ID of the post
 | 
			
		||||
@@ -56,5 +57,15 @@ public class Post {
 | 
			
		||||
    public String getContent() {
 | 
			
		||||
        return content;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Set and get the type of the post
 | 
			
		||||
 | 
			
		||||
    public void setType(PostTypes type) {
 | 
			
		||||
        this.type = type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PostTypes getType() {
 | 
			
		||||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package org.communiquons.android.comunic.client.data.posts;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Posts types enum
 | 
			
		||||
 *
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 * Created by pierre on 1/28/18.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public enum PostTypes {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Text post
 | 
			
		||||
     */
 | 
			
		||||
    TEXT,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Image post
 | 
			
		||||
     */
 | 
			
		||||
    IMAGE,
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Unknown type
 | 
			
		||||
     */
 | 
			
		||||
    UNKNOWN
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -2,6 +2,7 @@ package org.communiquons.android.comunic.client.data.posts;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.support.annotation.Nullable;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
 | 
			
		||||
import org.communiquons.android.comunic.client.api.APIRequest;
 | 
			
		||||
import org.communiquons.android.comunic.client.api.APIRequestParameters;
 | 
			
		||||
@@ -86,6 +87,22 @@ public class PostsHelper {
 | 
			
		||||
        post.setPost_time(json.getInt("post_time"));
 | 
			
		||||
        post.setContent(json.getString("content"));
 | 
			
		||||
 | 
			
		||||
        //Determine the type of the post
 | 
			
		||||
        switch (json.getString("kind")){
 | 
			
		||||
 | 
			
		||||
            case "text":
 | 
			
		||||
                post.setType(PostTypes.TEXT);
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case "image":
 | 
			
		||||
                post.setType(PostTypes.IMAGE);
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                post.setType(PostTypes.UNKNOWN);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return post;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user