|
2 | 2 | import com.contentstack.sdk.*; |
3 | 3 | import com.contentstack.sdk.Error; |
4 | 4 |
|
| 5 | +import java.util.List; |
| 6 | + |
5 | 7 |
|
6 | 8 | public class NewsMain { |
7 | 9 |
|
8 | 10 | private static String TAG = NewsMain.class.getSimpleName(); |
9 | 11 | public static void main(String[] args) throws Exception { |
10 | 12 |
|
11 | | - Stack stack = Contentstack.stack("blt920bb7e90248f607", "blt0c4300391e033d4a59eb2857", "production"); |
12 | | - ContentType contentType = stack.contentType("news"); |
13 | | - contentType.fetch(new ContentTypesCallback() { |
| 13 | + Stack stack = Contentstack.stack("bltdd99f24e8a94d536", "blt22ef89e3652f3a44", "dev"); |
| 14 | + Query query_banner = stack.contentType("banner_codes").query(); |
| 15 | + query_banner.addParam("code", "snipsnapfy14"); |
| 16 | + query_banner.language(Language.ENGLISH_UNITED_STATES); |
| 17 | + query_banner.find(new QueryResultsCallBack() { |
14 | 18 | @Override |
15 | | - public void onCompletion(ContentTypesModel contentTypesModel, Error error) { |
16 | | - Stack.log(TAG, contentTypesModel.getResponse().toString()); |
| 19 | + public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { |
| 20 | + if (error==null){ |
| 21 | + List<Entry> entryList = queryresult.getResultObjects(); |
| 22 | + entryList.forEach(entry -> { |
| 23 | + Stack.log("query_banner", entry.toJSON().toString()); |
| 24 | + }); |
| 25 | + } |
17 | 26 | } |
18 | 27 | }); |
19 | 28 |
|
| 29 | + |
| 30 | + |
| 31 | + Query query_header = stack.contentType("header").query(); |
| 32 | + query_header.addParam("code", "snipsnapfy14"); |
| 33 | + query_header.language(Language.ENGLISH_UNITED_STATES); |
| 34 | + query_header.find(new QueryResultsCallBack() { |
| 35 | + @Override |
| 36 | + public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { |
| 37 | + if (error==null){ |
| 38 | + List<Entry> entryList = queryresult.getResultObjects(); |
| 39 | + entryList.forEach(entry -> { |
| 40 | + Stack.log("query_banner", entry.toJSON().toString()); |
| 41 | + }); |
| 42 | + } |
| 43 | + } |
| 44 | + }); |
| 45 | + |
| 46 | + |
| 47 | + |
20 | 48 | } |
21 | 49 |
|
22 | 50 | } |
|
0 commit comments