This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract AgreementContract { | |
| struct PaidRent { | |
| uint id; | |
| uint value; | |
| } | |
| PaidRent[] public paidrents; | |
| uint public lastRentPaidTimestamp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Quote{ | |
| private String quote; | |
| private String author; | |
| private String category; | |
| public String getQuote() { | |
| return quote; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class QuoteViewModel extends ViewModel { | |
| private LiveData<Quote> quote; //pojo object | |
| private String category; //quote category | |
| private int count; //number of quotes | |
| private QuoteRepository quoteRepository; //data fetching object | |
| public void init(String category, int count){ | |
| //make sure quote object should be created only once | |
| if(this.quote!=null){ | |
| return ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FragmentQuote extends LifecycleFragment{ | |
| private QuoteViewModel quoteViewModel; | |
| private TextView quotetv; | |
| private TextView authortv; | |
| @Nullable | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| View view = inflater.inflate(R.layout.fragment_quote,container,false); | |
| quotetv = (TextView) view.findViewById(R.id.quote); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout | |
| android:layout_gravity="center" | |
| android:gravity="center" | |
| android:orientation="vertical" android:layout_width="match_parent" | |
| android:layout_height="match_parent"> | |
| <TextView | |
| android:id="@+id/quote" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Connection connection = Jsoup.connect(queryURL.toExternalForm()) | |
| .header(headers_if_any) | |
| .timeout(0) | |
| .ignoreContentType(true); | |
| Document document = connection.userAgent(Net.USER_AGENT).get(); | |
| response = new JsonParser().parse(document.text()).getAsJsonObject(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| compile ‘com.google.code.gson:gson:2.8.0’ | |
| compile ‘com.squareup.retrofit2:retrofit:2.1.0’ | |
| compile ‘com.squareup.retrofit2:converter-gson:2.1.0’ | |
| compile ‘com.squareup.okhttp3:logging-interceptor:3.3.1’ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface QuoteAPI { | |
| @Headers({ | |
| "X-Mashape-Key:your_api_key", | |
| "Content-Type: application/x-www-form-urlencoded", | |
| "Accept: application/json" | |
| }) | |
| @GET("/") | |
| Call<Quote> getQuote(@Query("cat") String category, @Query("count") int count); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "quote": "Oh, no, it wasn’t the airplanes. It was Beauty killed the Beast.", | |
| "author": "King Kong", | |
| "category": "Movies" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Quote{ | |
| private String quote; | |
| private String author; | |
| private String category; | |
| public String getQuote() { | |
| return quote; | |
| } |
OlderNewer