This file contains 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 CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { | |
private Activity context; | |
public CustomInfoWindowAdapter(Activity context){ | |
this.context = context; | |
} | |
@Override |
This file contains 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 TheBackupAgent extends BackupAgentHelper { | |
private static final String DB_NAME = "test.db"; // db name | |
@Override | |
public void onCreate() { | |
FileBackupHelper dbs = new FileBackupHelper(this, DB_NAME); | |
addHelper("dbs", dbs); | |
} |
This file contains 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 RealmMigration { | |
private final static String TAG = RealmMigration.class.getName(); | |
private Context context; | |
private Realm realm; | |
public RealmMigration(Context context) { | |
this.realm = Realm.getInstance(BaseApplication.realmConfiguration); | |
this.context = context; |
This file contains 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 TabFragment extends Fragment { | |
private static final String ARG_POSITION = "position"; | |
private int position; | |
public static TabFragment newInstance(int position) { | |
TabFragment f = new TabFragment(); | |
Bundle b = new Bundle(); | |
b.putInt(ARG_POSITION, position); |
This file contains 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 ViewPagerAdapter extends FragmentPagerAdapter { | |
private final String[] tabTitles = { "Tab1", "Tab2", "Tab3" }; | |
public ViewPagerAdapter(FragmentManager fm) { | |
super(fm); | |
} | |
@Override | |
public CharSequence getPageTitle(int position) { |
This file contains 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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
toolbar = (Toolbar) findViewById(R.id.tool_bar); | |
setSupportActionBar(toolbar); | |
pager = (ViewPager) findViewById(R.id.pager); | |
pager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager())); |
This file contains 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
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<android.support.design.widget.TabLayout | |
android:id="@+id/tabs" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" |
This file contains 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
OkHttpClient client = new OkHttpClient(); | |
String url = "http://www.google.com"; | |
Request request = new Request.Builder() | |
.url(url) | |
.build(); | |
Call call = client.newCall(request); | |
call.enqueue(new Callback() { | |
@Override |
This file contains 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
OkHttpClient client = new OkHttpClient(); | |
String url = "http://www.google.com"; | |
Request request = new Request.Builder() | |
.url(url) | |
.build(); | |
Response response = client.newCall(request).execute(); | |
//Response |
This file contains 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
String html = "<div> | |
An <a href='http://example.com/'><b>example</b></a> link.</div> | |
"; | |
Document doc = Jsoup.parse(html); | |
Element link = doc.select("div > a").text(); //example | |
Element link = doc.select("div > a").html(); //<b>example</b> | |
Element link = doc.select("div > a").get(0).text(); //get first link | |
Element link = doc.select("div").text(); //example link. |