-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityPostDetail.java
More file actions
102 lines (84 loc) · 3.29 KB
/
Copy pathActivityPostDetail.java
File metadata and controls
102 lines (84 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.app.yourrestaurantapp.activities;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.app.yourrestaurantapp.BuildConfig;
import com.app.yourrestaurantapp.R;
import com.app.yourrestaurantapp.utilities.Tools;
import com.squareup.picasso.Picasso;
public class ActivityPostDetail extends AppCompatActivity {
TextView post_title;
ImageView post_image;
WebView post_description;
TextView toolbar_title;
String title, image, description;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post_detail);
Tools.lightNavigation(this);
Intent intent = getIntent();
title = intent.getStringExtra("title");
image = intent.getStringExtra("image");
description = intent.getStringExtra("description");
initView();
displayData();
initToolbar();
}
private void initView() {
post_title = findViewById(R.id.post_title);
post_image = findViewById(R.id.post_image);
post_description = findViewById(R.id.post_description);
toolbar_title = findViewById(R.id.toolbar_title);
}
private void displayData() {
post_title.setText(title);
Picasso.with(this)
.load(image.replace(" ", "%20"))
.placeholder(R.drawable.ic_loading)
.into(post_image);
post_image.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), ActivityImageDetail.class);
intent.putExtra("title", title);
intent.putExtra("image", image);
startActivity(intent);
});
Tools.showContentDescription(this, post_description, description);
}
private void initToolbar() {
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
findViewById(R.id.btn_share).setOnClickListener(view -> {
String share_text = Html.fromHtml(getResources().getString(R.string.share_app)).toString();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, share_text + "\n\n" + "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID);
intent.setType("text/plain");
startActivity(intent);
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}