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
| package com.example.sontbv.retrofittutorial.adapter; | |
| import android.content.Context; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.widget.TextView; | |
| import com.example.sontbv.retrofittutorial.R; |
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 xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:orientation="vertical" | |
| android:padding="12dp"> | |
| <TextView | |
| android:id="@+id/title" | |
| android:layout_width="wrap_content" |
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
| package com.example.sontbv.retrofittutorial; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.support.v7.widget.LinearLayoutManager; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.util.Log; | |
| import com.example.sontbv.retrofittutorial.adapter.MoviesAdapter; | |
| import com.example.sontbv.retrofittutorial.model.Movie; |
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
| package com.example.sontbv.retrofittutorial.webservice; | |
| import com.google.gson.Gson; | |
| import com.google.gson.GsonBuilder; | |
| import okhttp3.OkHttpClient; | |
| import okhttp3.logging.HttpLoggingInterceptor; | |
| import retrofit2.Retrofit; | |
| import retrofit2.converter.gson.GsonConverterFactory; |
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
| package com.example.sontbv.retrofittutorial.webservice; | |
| import com.example.sontbv.retrofittutorial.model.Movie; | |
| import java.util.List; | |
| import retrofit2.Call; | |
| import retrofit2.http.GET; | |
| /** |
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
| package com.example.sontbv.retrofittutorial.model; | |
| import com.google.gson.annotations.SerializedName; | |
| /** | |
| * Created by sontbv on 3/7/18. | |
| */ | |
| public class Movie { | |
| @SerializedName("id") |
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
| # in controller | |
| # for local files | |
| send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment' | |
| # for remote files | |
| require 'open-uri' | |
| url = 'http://someserver.com/path/../filename.jpg' | |
| data = open(url).read | |
| send_data data, :disposition => 'attachment', :filename=>"photo.jpg" |
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
| class Api::V1::RegistrationsController < Devise::RegistrationsController | |
| before_action :ensure_params_exist, only: :create | |
| # sign up | |
| def create | |
| user = User.new user_params | |
| if user.save | |
| render json: { | |
| messages: "Sign Up Successfully", | |
| is_success: true, | |
| data: {user: user} |
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
| Chart.pluginService.register({ | |
| beforeDraw: function (chart) { | |
| if (chart.config.options.elements.center) { | |
| //Get ctx from string | |
| var ctx = chart.chart.ctx; | |
| //Get options from the center object in options | |
| var centerConfig = chart.config.options.elements.center; | |
| var fontStyle = centerConfig.fontStyle || 'Arial'; | |
| var txt = centerConfig.text; |
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
| <%# Put this code snippet between the <head></head>-tags in your application layout and %> | |
| <%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %> | |
| <%# ... %> | |
| <head> | |
| <%# ... %> | |
| <% if Rails.env.production? %> | |
| <script type="text/javascript"> | |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |