Skip to content

Instantly share code, notes, and snippets.

View amit-bhandari's full-sized avatar
💻
Writing code, duhhh

Amit Bhandari amit-bhandari

💻
Writing code, duhhh
View GitHub Profile
@amit-bhandari
amit-bhandari / smart_contract.sol
Created February 22, 2019 06:27
eLocations Smart Contract
contract AgreementContract {
struct PaidRent {
uint id;
uint value;
}
PaidRent[] public paidrents;
uint public lastRentPaidTimestamp;
public class Quote{
private String quote;
private String author;
private String category;
public String getQuote() {
return quote;
}
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 ;
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);
<?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"
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();
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’
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);
{
"quote": "Oh, no, it wasn’t the airplanes. It was Beauty killed the Beast.",
"author": "King Kong",
"category": "Movies"
}
public class Quote{
private String quote;
private String author;
private String category;
public String getQuote() {
return quote;
}