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
{ | |
"lastUpdated": 1706052674298, | |
"data": [ | |
{ | |
"team": "CEO", | |
"name": "Joel", | |
"role": "CEO", | |
"location": "Boulder, CO, USA", | |
"salary": "$298,958", | |
"avatar": "Joel_40.jpg", |
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
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:drawable="@drawable/button_bfr_round_light_disabled" android:state_enabled="false" /> | |
<item android:drawable="@drawable/button_bfr_round_light_unfocused" android:state_focused="false" android:state_pressed="false" android:state_selected="false" /> | |
<item android:drawable="@drawable/button_bfr_round_light_unfocused" android:state_focused="false" android:state_pressed="false" android:state_selected="true" /> | |
<item android:drawable="@drawable/button_bfr_round_light_pressed" android:state_pressed="true" /> | |
</selector> |
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
<style name="RoundedButtonStyle" parent="Widget.MaterialComponents.Button"> | |
<item name="shapeAppearance">@style/RoundedButtonShapeAppearance</item> | |
... | |
</style> | |
<style name="RoundedButtonShapeAppearance"> | |
<item name="cornerFamilyTopLeft">rounded</item> | |
<item name="cornerFamilyBottomLeft">rounded</item> | |
<item name="cornerFamilyTopRight">rounded</item> | |
<item name="cornerFamilyBottomRight">rounded</item> |
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 Post { | |
public Long id; | |
public String by; | |
public Long time; | |
public ArrayList<Long> kids; | |
public String url; | |
public Long score; | |
public String title; | |
public String text; |
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 PostAdapter extends RecyclerView.Adapter<PostAdapter.BindingHolder> { | |
private List<Post> mPosts; | |
private Context mContext; | |
private boolean mIsUserPosts; | |
public PostAdapter(Context context, boolean isUserPosts) { | |
mContext = context; | |
mIsUserPosts = isUserPosts; | |
mPosts = new ArrayList<>(); | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
<data> | |
<variable name="viewModel" type="com.hitherejoe.mvvm_hackernews.viewModel.PostViewModel" /> | |
</data> | |
<android.support.v7.widget.CardView | |
xmlns:card_view="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/card_view" |
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
@RunWith(RobolectricTestRunner.class) | |
@Config(constants = BuildConfig.class, sdk = DefaultConfig.EMULATE_SDK, manifest = DefaultConfig.MANIFEST) | |
public class PostViewModelTest { | |
private Context mContext; | |
private PostViewModel mPostViewModel; | |
private Post mPost; | |
@Before | |
public void setUp() { |
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 PostViewModel extends BaseObservable { | |
private Context context; | |
private Post post; | |
private Boolean isUserPosts; | |
public PostViewModel(Context context, Post post, boolean isUserPosts) { | |
this.context = context; | |
this.post = post; | |
this.isUserPosts = isUserPosts; |
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
private void requestMultiplePermissions() { | |
String locationPermission = Manifest.permission.ACCESS_FINE_LOCATION; | |
String calendarPermission = Manifest.permission.WRITE_CALENDAR; | |
int hasLocPermission = checkSelfPermission(locationPermission); | |
int hasCalPermission = checkSelfPermission(calendarPermission); | |
List<String> permissions = new ArrayList<String>(); | |
if (hasLocPermission != PackageManager.PERMISSION_GRANTED) { | |
permissions.add(locationPermission); | |
} | |
if (hasCalPermission != PackageManager.PERMISSION_GRANTED) { |
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 | |
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | |
switch (requestCode) { | |
case REQUEST_LOCATION: | |
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
// Handle permission granted | |
} else { | |
// Handle permission denied | |
} | |
break; |
NewerOlder