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 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 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 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 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 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 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 CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { | |
| private Activity context; | |
| public CustomInfoWindowAdapter(Activity context){ | |
| this.context = context; | |
| } | |
| @Override |
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
| [{"number":"1","district":"板橋區","village":"中山里","no":"01-001","name":"林爽","address":"板橋區大觀路2段37巷280號","tel":"02-82752345","recycle_address":"板橋區大觀路2段37巷280號","open_time":"每週六早上 06:00--10:00","state":"營運中","twd97X":"295382.67","twd97Y":"2765962.44","wgs84aX":"121.449601129258","wgs84aY":"25.0009896915842"},{"number":"2","district":"板橋區","village":"廣德里","no":"01-002","name":"周建和","address":"板橋區重慶路283號","tel":"02-29643797","recycle_address":"同里辦及新北市板橋區廣德里5鄰重慶路353巷7號對面","open_time":"每週一至日9~12點+15~18點","state":"營運中","twd97X":"296817.42","twd97Y":"2765792.68","wgs84aX":"121.463808943393","wgs84aY":"24.9994134533018"},{"number":"3","district":"板橋區","village":"景星里","no":"01-003","name":"林志成","address":"板橋區景福路11號","tel":"02-29531072","recycle_address":"新北市板橋區景星里3鄰景福路11號","open_time":"每週四 09:00~16:00","state":"營運中","twd97X":"296532.5","twd97Y":"2766464.62","wgs84aX":"121.461009012507","wgs84aY":"25.0054885651095"},{"number":"4","district":"板橋區","village":"滿翠里","no":"01-004","name":"林重光","address":"板橋區四維路266巷5弄16號","tel |
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
| import requests | |
| from bs4 import BeautifulSoup | |
| urlRoot = 'http://book.tpml.edu.tw/webpac/' | |
| dateRange = '2016-08-01%2C2016-08-31' | |
| rows = '1000' | |
| link = urlRoot + 'newbooknotftdList.do?sortfield=MarcInsertDate&sorttype=1&showtuple=' + rows + '&newbookdatebet='+ dateRange +'&pubyear=all&language=chi&classtype=all&classno=all&classno10=all&keepsiteid=all&type=&categoraycode=-1&bookstatus=all&collection=all&viewmode=0' | |
| res = requests.get(link) | |
| soup = BeautifulSoup(res.text.encode('utf-8'), 'html.parser') |
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
| private PlaceAutocompleteAdapter adapter; | |
| private AutoCompleteTextView autocompleteView; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| buildGoogleApiClient(); |
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
| import android.app.Application; | |
| import io.realm.RealmConfiguration; | |
| public class MyApplication extends Application { | |
| public static RealmConfiguration realmConfiguration; | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| realmConfiguration = new RealmConfiguration.Builder(this) |
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 void addPerson() { | |
| final Realm realm = Realm.getDefaultInstance(); | |
| //It automatically handles begin/commit, and cancel if an error happens | |
| realm.executeTransactionAsync(new Realm.Transaction() { | |
| @Override | |
| public void execute(Realm realm) { | |
| Person p = realm.createObject(City.class); | |
| p.setId("00002"); | |
| c.setName("Steve Jobs"); |
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 Observable<List<Person>> getPersons() { | |
| final Realm realm = Realm.getDefaultInstance(); | |
| return realm.where(Person.class).findAll() //get Persons from DB | |
| .asObservable() | |
| .map(new Func1<RealmResults<Person>, List<Person>>() { | |
| @Override | |
| public List<Person> call(RealmResults<Person> person) { | |
| return realm.copyToRealm(person); //Convert RealmResults to List | |
| } |