-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3313488
commit 22f136e
Showing
9 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/example/lab/android/nuc/materialtest/FruitActivity.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 1,60 @@ | ||
package com.example.lab.android.nuc.materialtest; | ||
|
||
import android.content.Intent; | ||
import android.support.design.widget.CollapsingToolbarLayout; | ||
import android.support.v7.app.ActionBar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.MenuItem; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
public class FruitActivity extends AppCompatActivity { | ||
|
||
public static final String FRUIT_NAME = "fruit_name"; | ||
|
||
public static final String FRUIT_IMAGE_ID = "fruit_image_id"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_fruit); | ||
Intent intent = getIntent(); | ||
String fruitName = intent.getStringExtra(FRUIT_NAME); | ||
int fruitImageId = intent.getIntExtra(FRUIT_IMAGE_ID,0); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); | ||
ImageView fruitImageView = (ImageView) findViewById(R.id.fruit_image_view); | ||
TextView fruitContentText = (TextView) findViewById(R.id.fruit_content_text); | ||
setSupportActionBar(toolbar); | ||
ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar != null){ | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
} | ||
collapsingToolbar.setTitle(fruitName); | ||
Glide.with(this).load(fruitImageId).into(fruitImageView); | ||
String fruitContent = gennerateFruitContent(fruitName); | ||
fruitContentText.setText(fruitContent); | ||
} | ||
|
||
private String gennerateFruitContent(String fruitName){ | ||
StringBuilder fruitContent = new StringBuilder(); | ||
for (int i = 0; i < 500; i ) { | ||
fruitContent.append(fruitName); | ||
} | ||
return fruitContent.toString(); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()){ | ||
case android.R.id.home: | ||
finish(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(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
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#ffffff" | ||
android:pathData="M21.99,4c0,-1.1 -0.89,-2 -1.99,-2L4,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4 -0.01,-18zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="FruitActivityTheme" parent="AppTheme"> | ||
<item name="android:statusBarColor">@android:color/transparent</item> | ||
</style> | ||
</resources> |
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