Skip to content

Commit 234aa83

Browse files
author
Talha
committed
Implemented info layout
(if list != 0) show info else show list
1 parent 052c80d commit 234aa83

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/icode/easynote/activities/MainActivity.java

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.widget.EditText;
2727
import android.widget.ImageView;
2828
import android.widget.LinearLayout;
29+
import android.widget.RelativeLayout;
2930
import android.widget.TextView;
3031
import android.widget.Toast;
3132

@@ -58,6 +59,8 @@ public class MainActivity extends AppCompatActivity implements INoteFragmentList
5859
private static final int REQUEST_CODE_EXTERNAL_PERMISSION = 2;
5960
SharedPreferences sharedPreferences;
6061

62+
RelativeLayout layout_info;
63+
6164
TextView myName;
6265
CircleImageView myPhoto;
6366
FloatingActionButton addNote;
@@ -88,6 +91,7 @@ protected void onCreate(Bundle savedInstanceState) {
8891
initViews();
8992
url = "";
9093
fillRecyclerView();
94+
showLayoutNoteInfo();
9195
addNote.setOnClickListener(v -> openNoteFragment(null, null));
9296
layoutProfile.setOnClickListener(v -> {
9397
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this, R.style.BottomSheetDialogTheme);
@@ -133,6 +137,8 @@ public void afterTextChanged(Editable s) {
133137
}
134138

135139
void initViews() {
140+
layout_info = findViewById(R.id.layout_info);
141+
136142
myName = findViewById(R.id.textMyName);
137143
myPhoto = findViewById(R.id.imagePhoto);
138144
addNote = findViewById(R.id.floatingAction_AddNote);
@@ -205,6 +211,14 @@ public void fillRecyclerView() {
205211
noteAdapter.notifyDataSetChanged();
206212
}
207213

214+
private void showLayoutNoteInfo() {
215+
if (notes.size() == 0) {
216+
layout_info.setVisibility(View.VISIBLE);
217+
} else {
218+
layout_info.setVisibility(View.GONE);
219+
}
220+
}
221+
208222
private void openNoteFragment(Note note, String action) {
209223
AddNoteFragment dialogFragment = AddNoteFragment.Instance();
210224
if (note != null && action.equalsIgnoreCase("update")) {
@@ -256,11 +270,13 @@ private String getPathFromUri(Uri uri) {
256270
@Override
257271
public void onNoteInserted() {
258272
fillRecyclerView();
273+
showLayoutNoteInfo();
259274
}
260275

261276
@Override
262277
public void onNoteDeleted() {
263278
fillRecyclerView();
279+
showLayoutNoteInfo();
264280
}
265281

266282
private void showUrlDialog() {
27.6 KB
Loading

app/src/main/res/layout/activity_main.xml

+45
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,51 @@
130130
app:layout_constraintBottom_toTopOf="@+id/layoutActions"
131131
app:layout_constraintTop_toBottomOf="@+id/layoutSearch" />
132132

133+
<RelativeLayout
134+
android:id="@+id/layout_info"
135+
android:layout_width="match_parent"
136+
android:layout_height="0dp"
137+
android:layout_marginStart="@dimen/_2sdp"
138+
android:layout_marginLeft="@dimen/_2sdp"
139+
android:layout_marginEnd="@dimen/_2sdp"
140+
android:layout_marginRight="@dimen/_2sdp"
141+
android:clipToPadding="false"
142+
android:gravity="center"
143+
android:paddingStart="0dp"
144+
android:paddingLeft="0dp"
145+
android:paddingEnd="@dimen/_12sdp"
146+
android:paddingRight="@dimen/_12sdp"
147+
android:paddingBottom="@dimen/_12sdp"
148+
app:layout_constraintBottom_toTopOf="@+id/layoutActions"
149+
app:layout_constraintTop_toBottomOf="@+id/layoutSearch">
150+
151+
<ImageView
152+
android:id="@+id/imageNoteInfo"
153+
android:layout_width="@dimen/_80sdp"
154+
android:layout_height="@dimen/_80sdp"
155+
android:layout_centerHorizontal="true"
156+
android:layout_marginBottom="@dimen/_22sdp"
157+
android:clickable="false"
158+
android:contentDescription="@string/app_name"
159+
android:focusable="false"
160+
android:src="@drawable/notes_info" />
161+
162+
<TextView
163+
android:layout_width="match_parent"
164+
android:layout_height="wrap_content"
165+
android:layout_below="@+id/imageNoteInfo"
166+
android:layout_centerHorizontal="true"
167+
android:layout_marginStart="@dimen/_12sdp"
168+
android:layout_marginLeft="@dimen/_12sdp"
169+
android:layout_marginEnd="@dimen/_12sdp"
170+
android:layout_marginRight="@dimen/_12sdp"
171+
android:gravity="center_horizontal"
172+
android:text="@string/notes_you_add_appear_here"
173+
android:textColor="@color/colorAccent"
174+
android:textSize="@dimen/_12ssp" />
175+
176+
</RelativeLayout>
177+
133178
<LinearLayout
134179
android:id="@+id/layoutActions"
135180
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
<string name="cancel">CANCEL</string>
1212
<string name="delete_note">Delete Note</string>
1313
<string name="are_you_sure_you_want_to_delete_this_note">Are you sure you want to delete this note?</string>
14+
<string name="notes_you_add_appear_here">Notes you add appear here</string>
1415
</resources>

0 commit comments

Comments
 (0)