新增 市场界面
删除 无用资源
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import org.autojs.autojs.R;
|
||||
@@ -40,6 +41,7 @@ public class NodeBB {
|
||||
.setLenient()
|
||||
.create()))
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addCallAdapterFactory(CoroutineCallAdapterFactory.create())
|
||||
.client(new OkHttpClient.Builder()
|
||||
.cookieJar(new WebkitCookieManagerProxy())
|
||||
.build())
|
||||
|
||||
23
app/src/main/java/org/autojs/autojs/network/TopicService.kt
Normal file
23
app/src/main/java/org/autojs/autojs/network/TopicService.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.autojs.autojs.network
|
||||
|
||||
import org.autojs.autojs.network.api.TopicApi
|
||||
import org.autojs.autojs.network.entity.topic.Topic
|
||||
|
||||
object TopicService {
|
||||
|
||||
private const val CID_SCRIPTS = 9L
|
||||
private val mRetrofit = NodeBB.getInstance().retrofit
|
||||
private val mTopicApi = mRetrofit.create(TopicApi::class.java)
|
||||
|
||||
suspend fun getTopics(cid: Long): List<Topic> {
|
||||
val category = mTopicApi.getCategory(cid).await()
|
||||
return category.topics.filter {
|
||||
it.appInfo != null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getScriptsTopics(): List<Topic> {
|
||||
return getTopics(CID_SCRIPTS)
|
||||
}
|
||||
|
||||
}
|
||||
17
app/src/main/java/org/autojs/autojs/network/api/TopicApi.kt
Normal file
17
app/src/main/java/org/autojs/autojs/network/api/TopicApi.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
package org.autojs.autojs.network.api
|
||||
|
||||
import kotlinx.coroutines.Deferred
|
||||
import org.autojs.autojs.network.entity.topic.Category
|
||||
import org.autojs.autojs.network.entity.topic.Topic
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Path
|
||||
|
||||
interface TopicApi {
|
||||
|
||||
@GET("/api/category/{cid}")
|
||||
fun getCategory(@Path("cid") cid: Long): Deferred<Category>
|
||||
|
||||
@GET("/api/topic/{tid}")
|
||||
fun getTopic(@Path("tid") cid: Long): Deferred<Topic>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AppInfo {
|
||||
|
||||
@SerializedName("details")
|
||||
private String mDetails;
|
||||
@SerializedName("email")
|
||||
private String mEmail;
|
||||
@SerializedName("file")
|
||||
private String mFile;
|
||||
@SerializedName("minSdkVersion")
|
||||
private long mMinSdkVersion;
|
||||
@SerializedName("name")
|
||||
private String mName;
|
||||
@SerializedName("package")
|
||||
private String mPackage;
|
||||
@SerializedName("permissions")
|
||||
private List<String> mPermissions;
|
||||
@SerializedName("qq")
|
||||
private String mQq;
|
||||
@SerializedName("releaseNotes")
|
||||
private String mReleaseNotes;
|
||||
@SerializedName("screenshots")
|
||||
private List<String> mScreenshots;
|
||||
@SerializedName("summary")
|
||||
private String mSummary;
|
||||
@SerializedName("userGuide")
|
||||
private String mUserGuide;
|
||||
@SerializedName("version")
|
||||
private String mVersion;
|
||||
@SerializedName("versionCode")
|
||||
private long mVersionCode;
|
||||
|
||||
public String getDetails() {
|
||||
return mDetails;
|
||||
}
|
||||
|
||||
public void setDetails(String details) {
|
||||
mDetails = details;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return mEmail;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
mEmail = email;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
public long getMinSdkVersion() {
|
||||
return mMinSdkVersion;
|
||||
}
|
||||
|
||||
public void setMinSdkVersion(long minSdkVersion) {
|
||||
mMinSdkVersion = minSdkVersion;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public String getPackage() {
|
||||
return mPackage;
|
||||
}
|
||||
|
||||
public void setPackage(String packageName) {
|
||||
mPackage = packageName;
|
||||
}
|
||||
|
||||
public List<String> getPermissions() {
|
||||
return mPermissions;
|
||||
}
|
||||
|
||||
public void setPermissions(List<String> permissions) {
|
||||
mPermissions = permissions;
|
||||
}
|
||||
|
||||
public String getQq() {
|
||||
return mQq;
|
||||
}
|
||||
|
||||
public void setQq(String qq) {
|
||||
mQq = qq;
|
||||
}
|
||||
|
||||
public String getReleaseNotes() {
|
||||
return mReleaseNotes;
|
||||
}
|
||||
|
||||
public void setReleaseNotes(String releaseNotes) {
|
||||
mReleaseNotes = releaseNotes;
|
||||
}
|
||||
|
||||
public List<String> getScreenshots() {
|
||||
return mScreenshots;
|
||||
}
|
||||
|
||||
public void setScreenshots(List<String> screenshots) {
|
||||
mScreenshots = screenshots;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return mSummary;
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
mSummary = summary;
|
||||
}
|
||||
|
||||
public String getUserGuide() {
|
||||
return mUserGuide;
|
||||
}
|
||||
|
||||
public void setUserGuide(String userGuide) {
|
||||
mUserGuide = userGuide;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
mVersion = version;
|
||||
}
|
||||
|
||||
public long getVersionCode() {
|
||||
return mVersionCode;
|
||||
}
|
||||
|
||||
public void setVersionCode(long versionCode) {
|
||||
mVersionCode = versionCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScriptApp{" +
|
||||
"mDetails='" + mDetails + '\'' +
|
||||
", mEmail='" + mEmail + '\'' +
|
||||
", mFile='" + mFile + '\'' +
|
||||
", mMinSdkVersion=" + mMinSdkVersion +
|
||||
", mName='" + mName + '\'' +
|
||||
", mPackage='" + mPackage + '\'' +
|
||||
", mPermissions=" + mPermissions +
|
||||
", mQq='" + mQq + '\'' +
|
||||
", mReleaseNotes='" + mReleaseNotes + '\'' +
|
||||
", mScreenshots=" + mScreenshots +
|
||||
", mSummary='" + mSummary + '\'' +
|
||||
", mUserGuide='" + mUserGuide + '\'' +
|
||||
", mVersion='" + mVersion + '\'' +
|
||||
", mVersionCode=" + mVersionCode +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Category {
|
||||
|
||||
@SerializedName("cid")
|
||||
private String mCid;
|
||||
@SerializedName("description")
|
||||
private String mDescription;
|
||||
@SerializedName("descriptionParsed")
|
||||
private String mDescriptionParsed;
|
||||
@SerializedName("link")
|
||||
private String mLink;
|
||||
@SerializedName("loggedIn")
|
||||
private Boolean mLoggedIn;
|
||||
@SerializedName("name")
|
||||
private String mName;
|
||||
@SerializedName("nextStart")
|
||||
private Long mNextStart;
|
||||
@SerializedName("numRecentReplies")
|
||||
private String mNumRecentReplies;
|
||||
@SerializedName("pagination")
|
||||
private Pagination mPagination;
|
||||
@SerializedName("parentCid")
|
||||
private String mParentCid;
|
||||
@SerializedName("post_count")
|
||||
private String mPostCount;
|
||||
@SerializedName("privileges")
|
||||
private Privileges mPrivileges;
|
||||
@SerializedName("slug")
|
||||
private String mSlug;
|
||||
@SerializedName("title")
|
||||
private String mTitle;
|
||||
@SerializedName("topic_count")
|
||||
private String mTopicCount;
|
||||
@SerializedName("topics")
|
||||
private List<Topic> mTopics;
|
||||
@SerializedName("totalPostCount")
|
||||
private Long mTotalPostCount;
|
||||
@SerializedName("totalTopicCount")
|
||||
private Long mTotalTopicCount;
|
||||
@SerializedName("url")
|
||||
private String mUrl;
|
||||
|
||||
public String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
public String getDescriptionParsed() {
|
||||
return mDescriptionParsed;
|
||||
}
|
||||
|
||||
public void setDescriptionParsed(String descriptionParsed) {
|
||||
mDescriptionParsed = descriptionParsed;
|
||||
}
|
||||
public String getLink() {
|
||||
return mLink;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
mLink = link;
|
||||
}
|
||||
|
||||
public Boolean getLoggedIn() {
|
||||
return mLoggedIn;
|
||||
}
|
||||
|
||||
public void setLoggedIn(Boolean loggedIn) {
|
||||
mLoggedIn = loggedIn;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public Long getNextStart() {
|
||||
return mNextStart;
|
||||
}
|
||||
|
||||
public void setNextStart(Long nextStart) {
|
||||
mNextStart = nextStart;
|
||||
}
|
||||
|
||||
public String getNumRecentReplies() {
|
||||
return mNumRecentReplies;
|
||||
}
|
||||
|
||||
public void setNumRecentReplies(String numRecentReplies) {
|
||||
mNumRecentReplies = numRecentReplies;
|
||||
}
|
||||
|
||||
public String getParentCid() {
|
||||
return mParentCid;
|
||||
}
|
||||
|
||||
public void setParentCid(String parentCid) {
|
||||
mParentCid = parentCid;
|
||||
}
|
||||
|
||||
public String getPostCount() {
|
||||
return mPostCount;
|
||||
}
|
||||
|
||||
public void setPostCount(String postCount) {
|
||||
mPostCount = postCount;
|
||||
}
|
||||
|
||||
public Privileges getPrivileges() {
|
||||
return mPrivileges;
|
||||
}
|
||||
|
||||
public void setPrivileges(Privileges privileges) {
|
||||
mPrivileges = privileges;
|
||||
}
|
||||
|
||||
public String getSlug() {
|
||||
return mSlug;
|
||||
}
|
||||
|
||||
public void setSlug(String slug) {
|
||||
mSlug = slug;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
public String getTopicCount() {
|
||||
return mTopicCount;
|
||||
}
|
||||
|
||||
public void setTopicCount(String topicCount) {
|
||||
mTopicCount = topicCount;
|
||||
}
|
||||
|
||||
public List<Topic> getTopics() {
|
||||
return mTopics;
|
||||
}
|
||||
|
||||
public void setTopics(List<Topic> topics) {
|
||||
mTopics = topics;
|
||||
}
|
||||
|
||||
public Long getTotalPostCount() {
|
||||
return mTotalPostCount;
|
||||
}
|
||||
|
||||
public void setTotalPostCount(Long totalPostCount) {
|
||||
mTotalPostCount = totalPostCount;
|
||||
}
|
||||
|
||||
public Long getTotalTopicCount() {
|
||||
return mTotalTopicCount;
|
||||
}
|
||||
|
||||
public void setTotalTopicCount(Long totalTopicCount) {
|
||||
mTotalTopicCount = totalTopicCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Page {
|
||||
|
||||
@SerializedName("active")
|
||||
private boolean mActive;
|
||||
@SerializedName("page")
|
||||
private long mPage;
|
||||
|
||||
public boolean getActive() {
|
||||
return mActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
mActive = active;
|
||||
}
|
||||
|
||||
public long getPage() {
|
||||
return mPage;
|
||||
}
|
||||
|
||||
public void setPage(long page) {
|
||||
mPage = page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Pagination {
|
||||
|
||||
@SerializedName("currentPage")
|
||||
private Long mCurrentPage;
|
||||
@SerializedName("next")
|
||||
private Page mNext;
|
||||
@SerializedName("pageCount")
|
||||
private Long mPageCount;
|
||||
@SerializedName("pages")
|
||||
private List<Object> mPages;
|
||||
@SerializedName("prev")
|
||||
private Page mPrev;
|
||||
@SerializedName("rel")
|
||||
private List<Object> mRel;
|
||||
|
||||
public Long getCurrentPage() {
|
||||
return mCurrentPage;
|
||||
}
|
||||
|
||||
public void setCurrentPage(Long currentPage) {
|
||||
mCurrentPage = currentPage;
|
||||
}
|
||||
|
||||
public Page getNext() {
|
||||
return mNext;
|
||||
}
|
||||
|
||||
public void setNext(Page next) {
|
||||
mNext = next;
|
||||
}
|
||||
|
||||
public Long getPageCount() {
|
||||
return mPageCount;
|
||||
}
|
||||
|
||||
public void setPageCount(Long pageCount) {
|
||||
mPageCount = pageCount;
|
||||
}
|
||||
|
||||
public List<Object> getPages() {
|
||||
return mPages;
|
||||
}
|
||||
|
||||
public void setPages(List<Object> pages) {
|
||||
mPages = pages;
|
||||
}
|
||||
|
||||
public Page getPrev() {
|
||||
return mPrev;
|
||||
}
|
||||
|
||||
public void setPrev(Page prev) {
|
||||
mPrev = prev;
|
||||
}
|
||||
|
||||
public List<Object> getRel() {
|
||||
return mRel;
|
||||
}
|
||||
|
||||
public void setRel(List<Object> rel) {
|
||||
mRel = rel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.autojs.autojs.network.entity.user.User;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Post {
|
||||
|
||||
@SerializedName("content")
|
||||
private String mContent;
|
||||
@SerializedName("downvoted")
|
||||
private boolean mDownvoted;
|
||||
@SerializedName("downvotes")
|
||||
private long mDownvotes;
|
||||
@SerializedName("edited")
|
||||
private String mEdited;
|
||||
@SerializedName("editedISO")
|
||||
private String mEditedISO;
|
||||
@SerializedName("index")
|
||||
private long mIndex;
|
||||
@SerializedName("pid")
|
||||
private String mPid;
|
||||
@SerializedName("replies")
|
||||
private Replies mReplies;
|
||||
@SerializedName("selfPost")
|
||||
private boolean mSelfPost;
|
||||
@SerializedName("tid")
|
||||
private String mTid;
|
||||
@SerializedName("timestamp")
|
||||
private String mTimestamp;
|
||||
@SerializedName("timestampISO")
|
||||
private String mTimestampISO;
|
||||
@SerializedName("uid")
|
||||
private String mUid;
|
||||
@SerializedName("upvoted")
|
||||
private boolean mUpvoted;
|
||||
@SerializedName("upvotes")
|
||||
private long mUpvotes;
|
||||
@SerializedName("user")
|
||||
private User mUser;
|
||||
@SerializedName("votes")
|
||||
private long mVotes;
|
||||
|
||||
public String getContent() {
|
||||
return mContent;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
mContent = content;
|
||||
}
|
||||
|
||||
public boolean getDownvoted() {
|
||||
return mDownvoted;
|
||||
}
|
||||
|
||||
public void setDownvoted(boolean downvoted) {
|
||||
mDownvoted = downvoted;
|
||||
}
|
||||
|
||||
public long getDownvotes() {
|
||||
return mDownvotes;
|
||||
}
|
||||
|
||||
public void setDownvotes(long downvotes) {
|
||||
mDownvotes = downvotes;
|
||||
}
|
||||
|
||||
public String getEdited() {
|
||||
return mEdited;
|
||||
}
|
||||
|
||||
public void setEdited(String edited) {
|
||||
mEdited = edited;
|
||||
}
|
||||
|
||||
public String getEditedISO() {
|
||||
return mEditedISO;
|
||||
}
|
||||
|
||||
public void setEditedISO(String editedISO) {
|
||||
mEditedISO = editedISO;
|
||||
}
|
||||
|
||||
public long getIndex() {
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
public void setIndex(long index) {
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return mPid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
mPid = pid;
|
||||
}
|
||||
|
||||
public Replies getReplies() {
|
||||
return mReplies;
|
||||
}
|
||||
|
||||
public void setReplies(Replies replies) {
|
||||
mReplies = replies;
|
||||
}
|
||||
|
||||
public boolean getSelfPost() {
|
||||
return mSelfPost;
|
||||
}
|
||||
|
||||
public void setSelfPost(boolean selfPost) {
|
||||
mSelfPost = selfPost;
|
||||
}
|
||||
|
||||
public String getTid() {
|
||||
return mTid;
|
||||
}
|
||||
|
||||
public void setTid(String tid) {
|
||||
mTid = tid;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getTimestampISO() {
|
||||
return mTimestampISO;
|
||||
}
|
||||
|
||||
public void setTimestampISO(String timestampISO) {
|
||||
mTimestampISO = timestampISO;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return mUid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
mUid = uid;
|
||||
}
|
||||
|
||||
public boolean getUpvoted() {
|
||||
return mUpvoted;
|
||||
}
|
||||
|
||||
public void setUpvoted(boolean upvoted) {
|
||||
mUpvoted = upvoted;
|
||||
}
|
||||
|
||||
public long getUpvotes() {
|
||||
return mUpvotes;
|
||||
}
|
||||
|
||||
public void setUpvotes(long upvotes) {
|
||||
mUpvotes = upvotes;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return mUser;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
mUser = user;
|
||||
}
|
||||
|
||||
public long getVotes() {
|
||||
return mVotes;
|
||||
}
|
||||
|
||||
public void setVotes(long votes) {
|
||||
mVotes = votes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Privileges {
|
||||
|
||||
@SerializedName("cid")
|
||||
private String mCid;
|
||||
@SerializedName("editable")
|
||||
private Boolean mEditable;
|
||||
@SerializedName("isAdminOrMod")
|
||||
private Boolean mIsAdminOrMod;
|
||||
@SerializedName("read")
|
||||
private Boolean mRead;
|
||||
@SerializedName("topics:create")
|
||||
private Boolean mTopicsCreate;
|
||||
@SerializedName("topics:read")
|
||||
private Boolean mTopicsRead;
|
||||
@SerializedName("topics:tag")
|
||||
private Boolean mTopicsTag;
|
||||
@SerializedName("uid")
|
||||
private Long mUid;
|
||||
@SerializedName("view_deleted")
|
||||
private Boolean mViewDeleted;
|
||||
|
||||
public String getCid() {
|
||||
return mCid;
|
||||
}
|
||||
|
||||
public void setCid(String cid) {
|
||||
mCid = cid;
|
||||
}
|
||||
|
||||
public Boolean getEditable() {
|
||||
return mEditable;
|
||||
}
|
||||
|
||||
public void setEditable(Boolean editable) {
|
||||
mEditable = editable;
|
||||
}
|
||||
|
||||
public Boolean getIsAdminOrMod() {
|
||||
return mIsAdminOrMod;
|
||||
}
|
||||
|
||||
public void setIsAdminOrMod(Boolean isAdminOrMod) {
|
||||
mIsAdminOrMod = isAdminOrMod;
|
||||
}
|
||||
|
||||
public Boolean getRead() {
|
||||
return mRead;
|
||||
}
|
||||
|
||||
public void setRead(Boolean read) {
|
||||
mRead = read;
|
||||
}
|
||||
|
||||
public Boolean getTopicsCreate() {
|
||||
return mTopicsCreate;
|
||||
}
|
||||
|
||||
public void setTopicsCreate(Boolean topicsCreate) {
|
||||
mTopicsCreate = topicsCreate;
|
||||
}
|
||||
|
||||
public Boolean getTopicsRead() {
|
||||
return mTopicsRead;
|
||||
}
|
||||
|
||||
public void setTopicsRead(Boolean topicsRead) {
|
||||
mTopicsRead = topicsRead;
|
||||
}
|
||||
|
||||
public Boolean getTopicsTag() {
|
||||
return mTopicsTag;
|
||||
}
|
||||
|
||||
public void setTopicsTag(Boolean topicsTag) {
|
||||
mTopicsTag = topicsTag;
|
||||
}
|
||||
|
||||
public Long getUid() {
|
||||
return mUid;
|
||||
}
|
||||
|
||||
public void setUid(Long uid) {
|
||||
mUid = uid;
|
||||
}
|
||||
|
||||
public Boolean getViewDeleted() {
|
||||
return mViewDeleted;
|
||||
}
|
||||
|
||||
public void setViewDeleted(Boolean viewDeleted) {
|
||||
mViewDeleted = viewDeleted;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.autojs.autojs.network.entity.user.User;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Replies {
|
||||
|
||||
@SerializedName("count")
|
||||
private long mCount;
|
||||
@SerializedName("hasMore")
|
||||
private boolean mHasMore;
|
||||
@SerializedName("text")
|
||||
private String mText;
|
||||
@SerializedName("users")
|
||||
private List<User> mUsers;
|
||||
|
||||
public long getCount() {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
public boolean getHasMore() {
|
||||
return mHasMore;
|
||||
}
|
||||
|
||||
public void setHasMore(boolean hasMore) {
|
||||
mHasMore = hasMore;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return mText;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
mText = text;
|
||||
}
|
||||
|
||||
public List<User> getUsers() {
|
||||
return mUsers;
|
||||
}
|
||||
|
||||
public void setUsers(List<User> users) {
|
||||
mUsers = users;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
|
||||
package org.autojs.autojs.network.entity.topic;
|
||||
|
||||
import android.text.Html;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.autojs.autojs.network.entity.user.User;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Topic {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
@SerializedName("category")
|
||||
private Category mCategory;
|
||||
@SerializedName("cid")
|
||||
private String mCid;
|
||||
@SerializedName("deleted")
|
||||
private boolean mDeleted;
|
||||
@SerializedName("downvotes")
|
||||
private long mDownvotes;
|
||||
@SerializedName("icons")
|
||||
private List<Object> mIcons;
|
||||
@SerializedName("ignored")
|
||||
private boolean mIgnored;
|
||||
@SerializedName("index")
|
||||
private long mIndex;
|
||||
@SerializedName("isOwner")
|
||||
private boolean mIsOwner;
|
||||
@SerializedName("lastposttime")
|
||||
private String mLastposttime;
|
||||
@SerializedName("lastposttimeISO")
|
||||
private String mLastposttimeISO;
|
||||
@SerializedName("locked")
|
||||
private boolean mLocked;
|
||||
@SerializedName("mainPid")
|
||||
private String mMainPid;
|
||||
@SerializedName("pinned")
|
||||
private boolean mPinned;
|
||||
@SerializedName("postcount")
|
||||
private String mPostcount;
|
||||
@SerializedName("slug")
|
||||
private String mSlug;
|
||||
@SerializedName("tags")
|
||||
private List<Object> mTags;
|
||||
@SerializedName("thumb")
|
||||
private String mThumb;
|
||||
@SerializedName("tid")
|
||||
private String mTid;
|
||||
@SerializedName("timestamp")
|
||||
private String mTimestamp;
|
||||
@SerializedName("timestampISO")
|
||||
private String mTimestampISO;
|
||||
@SerializedName("title")
|
||||
private String mTitle;
|
||||
@SerializedName("titleRaw")
|
||||
private String mTitleRaw;
|
||||
@SerializedName("uid")
|
||||
private String mUid;
|
||||
@SerializedName("unread")
|
||||
private boolean mUnread;
|
||||
@SerializedName("unreplied")
|
||||
private boolean mUnreplied;
|
||||
@SerializedName("upvotes")
|
||||
private long mUpvotes;
|
||||
@SerializedName("user")
|
||||
private User mUser;
|
||||
@SerializedName("viewcount")
|
||||
private String mViewcount;
|
||||
@SerializedName("votes")
|
||||
private long mVotes;
|
||||
@SerializedName("posts")
|
||||
private List<Post> mPosts = new ArrayList<>();
|
||||
@SerializedName("teaser")
|
||||
private Post mTeaser;
|
||||
|
||||
private AppInfo mAppInfo;
|
||||
|
||||
public Category getCategory() {
|
||||
return mCategory;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
mCategory = category;
|
||||
}
|
||||
|
||||
public String getCid() {
|
||||
return mCid;
|
||||
}
|
||||
|
||||
public void setCid(String cid) {
|
||||
mCid = cid;
|
||||
}
|
||||
|
||||
public boolean getDeleted() {
|
||||
return mDeleted;
|
||||
}
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
mDeleted = deleted;
|
||||
}
|
||||
|
||||
public long getDownvotes() {
|
||||
return mDownvotes;
|
||||
}
|
||||
|
||||
public void setDownvotes(long downvotes) {
|
||||
mDownvotes = downvotes;
|
||||
}
|
||||
|
||||
public List<Object> getIcons() {
|
||||
return mIcons;
|
||||
}
|
||||
|
||||
public void setIcons(List<Object> icons) {
|
||||
mIcons = icons;
|
||||
}
|
||||
|
||||
public boolean getIgnored() {
|
||||
return mIgnored;
|
||||
}
|
||||
|
||||
public void setIgnored(boolean ignored) {
|
||||
mIgnored = ignored;
|
||||
}
|
||||
|
||||
public long getIndex() {
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
public void setIndex(long index) {
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
public boolean getIsOwner() {
|
||||
return mIsOwner;
|
||||
}
|
||||
|
||||
public void setIsOwner(boolean isOwner) {
|
||||
mIsOwner = isOwner;
|
||||
}
|
||||
|
||||
public String getLastposttime() {
|
||||
return mLastposttime;
|
||||
}
|
||||
|
||||
public void setLastposttime(String lastposttime) {
|
||||
mLastposttime = lastposttime;
|
||||
}
|
||||
|
||||
public String getLastposttimeISO() {
|
||||
return mLastposttimeISO;
|
||||
}
|
||||
|
||||
public void setLastposttimeISO(String lastposttimeISO) {
|
||||
mLastposttimeISO = lastposttimeISO;
|
||||
}
|
||||
|
||||
public boolean getLocked() {
|
||||
return mLocked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
mLocked = locked;
|
||||
}
|
||||
|
||||
public String getMainPid() {
|
||||
return mMainPid;
|
||||
}
|
||||
|
||||
public void setMainPid(String mainPid) {
|
||||
mMainPid = mainPid;
|
||||
}
|
||||
|
||||
public boolean getPinned() {
|
||||
return mPinned;
|
||||
}
|
||||
|
||||
public void setPinned(boolean pinned) {
|
||||
mPinned = pinned;
|
||||
}
|
||||
|
||||
public String getPostcount() {
|
||||
return mPostcount;
|
||||
}
|
||||
|
||||
public void setPostcount(String postcount) {
|
||||
mPostcount = postcount;
|
||||
}
|
||||
|
||||
public String getSlug() {
|
||||
return mSlug;
|
||||
}
|
||||
|
||||
public void setSlug(String slug) {
|
||||
mSlug = slug;
|
||||
}
|
||||
|
||||
public List<Object> getTags() {
|
||||
return mTags;
|
||||
}
|
||||
|
||||
public void setTags(List<Object> tags) {
|
||||
mTags = tags;
|
||||
}
|
||||
|
||||
public String getThumb() {
|
||||
return mThumb;
|
||||
}
|
||||
|
||||
public void setThumb(String thumb) {
|
||||
mThumb = thumb;
|
||||
}
|
||||
|
||||
public String getTid() {
|
||||
return mTid;
|
||||
}
|
||||
|
||||
public void setTid(String tid) {
|
||||
mTid = tid;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getTimestampISO() {
|
||||
return mTimestampISO;
|
||||
}
|
||||
|
||||
public void setTimestampISO(String timestampISO) {
|
||||
mTimestampISO = timestampISO;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
public String getTitleRaw() {
|
||||
return mTitleRaw;
|
||||
}
|
||||
|
||||
public void setTitleRaw(String titleRaw) {
|
||||
mTitleRaw = titleRaw;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return mUid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
mUid = uid;
|
||||
}
|
||||
|
||||
public boolean getUnread() {
|
||||
return mUnread;
|
||||
}
|
||||
|
||||
public void setUnread(boolean unread) {
|
||||
mUnread = unread;
|
||||
}
|
||||
|
||||
public boolean getUnreplied() {
|
||||
return mUnreplied;
|
||||
}
|
||||
|
||||
public void setUnreplied(boolean unreplied) {
|
||||
mUnreplied = unreplied;
|
||||
}
|
||||
|
||||
public long getUpvotes() {
|
||||
return mUpvotes;
|
||||
}
|
||||
|
||||
public void setUpvotes(long upvotes) {
|
||||
mUpvotes = upvotes;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return mUser;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
mUser = user;
|
||||
}
|
||||
|
||||
public String getViewcount() {
|
||||
return mViewcount;
|
||||
}
|
||||
|
||||
public void setViewcount(String viewcount) {
|
||||
mViewcount = viewcount;
|
||||
}
|
||||
|
||||
public long getVotes() {
|
||||
return mVotes;
|
||||
}
|
||||
|
||||
public void setVotes(long votes) {
|
||||
mVotes = votes;
|
||||
}
|
||||
|
||||
public List<Post> getPosts() {
|
||||
return mPosts;
|
||||
}
|
||||
|
||||
public void setPosts(List<Post> posts) {
|
||||
mPosts = posts;
|
||||
}
|
||||
|
||||
public AppInfo getAppInfo() {
|
||||
if (mAppInfo != null) {
|
||||
return mAppInfo;
|
||||
}
|
||||
if (mTeaser == null || mTeaser.getContent() == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String decoded = Html.fromHtml(mTeaser.getContent()).toString();
|
||||
AppInfo appInfo = GSON.fromJson(decoded, AppInfo.class);
|
||||
mAppInfo = appInfo;
|
||||
return appInfo;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Topic{" +
|
||||
"mCategory=" + mCategory +
|
||||
", mCid='" + mCid + '\'' +
|
||||
", mDeleted=" + mDeleted +
|
||||
", mDownvotes=" + mDownvotes +
|
||||
", mIcons=" + mIcons +
|
||||
", mIgnored=" + mIgnored +
|
||||
", mIndex=" + mIndex +
|
||||
", mIsOwner=" + mIsOwner +
|
||||
", mLastposttime='" + mLastposttime + '\'' +
|
||||
", mLastposttimeISO='" + mLastposttimeISO + '\'' +
|
||||
", mLocked=" + mLocked +
|
||||
", mMainPid='" + mMainPid + '\'' +
|
||||
", mPinned=" + mPinned +
|
||||
", mPostcount='" + mPostcount + '\'' +
|
||||
", mSlug='" + mSlug + '\'' +
|
||||
", mTags=" + mTags +
|
||||
", mThumb='" + mThumb + '\'' +
|
||||
", mTid='" + mTid + '\'' +
|
||||
", mTimestamp='" + mTimestamp + '\'' +
|
||||
", mTimestampISO='" + mTimestampISO + '\'' +
|
||||
", mTitle='" + mTitle + '\'' +
|
||||
", mTitleRaw='" + mTitleRaw + '\'' +
|
||||
", mUid='" + mUid + '\'' +
|
||||
", mUnread=" + mUnread +
|
||||
", mUnreplied=" + mUnreplied +
|
||||
", mUpvotes=" + mUpvotes +
|
||||
", mUser=" + mUser +
|
||||
", mViewcount='" + mViewcount + '\'' +
|
||||
", mVotes=" + mVotes +
|
||||
", mPosts=" + mPosts +
|
||||
", mTeaser=" + mTeaser +
|
||||
", mAppInfo=" + mAppInfo +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||
import org.autojs.autojs.ui.log.LogActivity_;
|
||||
import org.autojs.autojs.ui.main.community.CommunityFragment;
|
||||
import org.autojs.autojs.ui.main.community.CommunityFragment_;
|
||||
import org.autojs.autojs.ui.main.sample.MarketFragment_;
|
||||
import org.autojs.autojs.ui.main.market.MarketFragment;
|
||||
import org.autojs.autojs.ui.main.scripts.MyScriptListFragment_;
|
||||
import org.autojs.autojs.ui.main.task.TaskManagerFragment_;
|
||||
import org.autojs.autojs.ui.settings.SettingsActivity_;
|
||||
@@ -172,7 +172,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
.add(new MyScriptListFragment_(), R.string.text_file)
|
||||
.add(new DocsFragment_(), R.string.text_tutorial)
|
||||
.add(new CommunityFragment_(), R.string.text_community)
|
||||
.add(new MarketFragment_(), R.string.text_market)
|
||||
.add(new MarketFragment(), R.string.text_market)
|
||||
.add(new TaskManagerFragment_(), R.string.text_manage)
|
||||
.build();
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.autojs.autojs.ui.main.market
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.stardust.autojs.workground.WrapContentLinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.fragment_market.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.autojs.autojs.R
|
||||
import org.autojs.autojs.network.TopicService
|
||||
import org.autojs.autojs.network.entity.topic.Topic
|
||||
import org.autojs.autojs.ui.main.ViewPagerFragment
|
||||
import org.autojs.autojs.ui.widget.AvatarView
|
||||
import org.joda.time.format.DateTimeFormat
|
||||
|
||||
class MarketFragment : ViewPagerFragment(0) {
|
||||
|
||||
private val mTopics = ArrayList<Topic>()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_market, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
topicsView.layoutManager = WrapContentLinearLayoutManager(context)
|
||||
topicsView.adapter = Adapter()
|
||||
swipeRefreshLayout.setOnRefreshListener {
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
private fun refresh() {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
swipeRefreshLayout.isRefreshing = true
|
||||
val topics = TopicService.getScriptsTopics()
|
||||
mTopics.clear()
|
||||
mTopics.addAll(topics)
|
||||
topicsView.adapter!!.notifyDataSetChanged()
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed(activity: Activity): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onFabClick(fab: FloatingActionButton) {
|
||||
|
||||
}
|
||||
|
||||
inner class TopicViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
val rootView: TextView = itemView.findViewById(R.id.root)
|
||||
val titleView: TextView = itemView.findViewById(R.id.title)
|
||||
val avatarView: AvatarView = itemView.findViewById(R.id.avatar)
|
||||
val usernameView: TextView = itemView.findViewById(R.id.username)
|
||||
val dateView: TextView = itemView.findViewById(R.id.date)
|
||||
|
||||
}
|
||||
|
||||
inner class Adapter : RecyclerView.Adapter<TopicViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopicViewHolder {
|
||||
return TopicViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_topic, parent, false))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mTopics.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TopicViewHolder, position: Int) {
|
||||
|
||||
val topic = mTopics[position]
|
||||
holder.run {
|
||||
val root = topic.appInfo.permissions.contains("root")
|
||||
rootView.text = if (root) {
|
||||
"Root"
|
||||
} else {
|
||||
"免Root"
|
||||
}
|
||||
titleView.text = topic.title
|
||||
avatarView.setUser(topic.user)
|
||||
usernameView.text = topic.user.username
|
||||
|
||||
dateView.text = DateTimeFormat.mediumDateTime().print(topic.timestamp.toLong())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.autojs.autojs.ui.main.sample;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.ui.main.QueryEvent;
|
||||
import org.autojs.autojs.ui.main.ViewPagerFragment;
|
||||
|
||||
import com.stardust.util.BackPressedHandler;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EFragment;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/10/28.
|
||||
*/
|
||||
@EFragment(R.layout.fragment_market)
|
||||
public class MarketFragment extends ViewPagerFragment implements BackPressedHandler {
|
||||
|
||||
|
||||
public MarketFragment() {
|
||||
super(ROTATION_GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
((BackPressedHandler.HostActivity) getActivity())
|
||||
.getBackPressedObserver()
|
||||
.registerHandlerAtFront(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
((BackPressedHandler.HostActivity) getActivity())
|
||||
.getBackPressedObserver()
|
||||
.unregisterHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFabClick(FloatingActionButton fab) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed(Activity activity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onQuerySummit(QueryEvent event) {
|
||||
if (!isShown()) {
|
||||
return;
|
||||
}
|
||||
if (event == QueryEvent.CLEAR) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user