@ -0,0 +1,62 @@ |
|||||
|
package gr.thmmy.mthmmy.activities; |
||||
|
|
||||
|
import android.os.Bundle; |
||||
|
import android.support.v7.widget.Toolbar; |
||||
|
import android.widget.LinearLayout; |
||||
|
import android.widget.ProgressBar; |
||||
|
import android.widget.TextView; |
||||
|
|
||||
|
import gr.thmmy.mthmmy.R; |
||||
|
import gr.thmmy.mthmmy.base.BaseActivity; |
||||
|
import gr.thmmy.mthmmy.model.Bookmark; |
||||
|
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
||||
|
|
||||
|
public class BookmarkActivity extends BaseActivity { |
||||
|
ProgressBar progressBar; |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_bookmark); |
||||
|
|
||||
|
//Initialize toolbar
|
||||
|
toolbar = (Toolbar) findViewById(R.id.toolbar); |
||||
|
toolbar.setTitle("Bookmarks"); |
||||
|
setSupportActionBar(toolbar); |
||||
|
if (getSupportActionBar() != null) { |
||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||
|
getSupportActionBar().setDisplayShowHomeEnabled(true); |
||||
|
} |
||||
|
|
||||
|
createDrawer(); |
||||
|
drawer.setSelection(BOOKMARKS_ID); |
||||
|
|
||||
|
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); |
||||
|
|
||||
|
LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container); |
||||
|
|
||||
|
TextView tmp = new TextView(this); |
||||
|
tmp.setText("Your bookmarked boards:"); |
||||
|
bookmarksLinearView.addView(tmp); |
||||
|
|
||||
|
for (Bookmark bookmarkedBoard : getBoardsBookmarked()) { |
||||
|
if (bookmarkedBoard != null && bookmarkedBoard.getTitle() != null) { |
||||
|
TextView bookmarkedBoardView = new TextView(this); |
||||
|
bookmarkedBoardView.setText(bookmarkedBoard.getTitle()); |
||||
|
bookmarksLinearView.addView(bookmarkedBoardView); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
tmp = new TextView(this); |
||||
|
tmp.setText("Your bookmarked topics:"); |
||||
|
bookmarksLinearView.addView(tmp); |
||||
|
|
||||
|
for (Bookmark bookmarkedTopic : getTopicsBookmarked()) { |
||||
|
if (bookmarkedTopic != null && bookmarkedTopic.getTitle() != null) { |
||||
|
TextView bookmarkedTopicView = new TextView(this); |
||||
|
bookmarkedTopicView.setText(bookmarkedTopic.getTitle()); |
||||
|
bookmarksLinearView.addView(bookmarkedTopicView); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package gr.thmmy.mthmmy.model; |
||||
|
|
||||
|
public class Bookmark { |
||||
|
private final String title, id; |
||||
|
|
||||
|
public Bookmark(String title, String id) { |
||||
|
this.title = title; |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getTitle() { |
||||
|
return title; |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package gr.thmmy.mthmmy.utils; |
||||
|
/* |
||||
|
* Licensed to the Apache Software Foundation (ASF) under one |
||||
|
* or more contributor license agreements. See the NOTICE file |
||||
|
* distributed with this work for additional information |
||||
|
* regarding copyright ownership. The ASF licenses this file |
||||
|
* to you under the Apache License, Version 2.0 (the |
||||
|
* "License"); you may not use this file except in compliance |
||||
|
* with the License. You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
|
||||
|
//copied from http://github.com/apache/pig/blob/89c2e8e76c68d0d0abe6a36b4e08ddc56979796f/src/org/apache/pig/impl/util/ObjectSerializer.java
|
||||
|
//package org.apache.pig.impl.util;
|
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.io.ObjectInputStream; |
||||
|
import java.io.ObjectOutputStream; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
public class ObjectSerializer { |
||||
|
|
||||
|
public static String serialize(Serializable obj) throws IOException { |
||||
|
if (obj == null) return ""; |
||||
|
ByteArrayOutputStream serialObj = new ByteArrayOutputStream(); |
||||
|
ObjectOutputStream objStream = new ObjectOutputStream(serialObj); |
||||
|
objStream.writeObject(obj); |
||||
|
objStream.close(); |
||||
|
return encodeBytes(serialObj.toByteArray()); |
||||
|
} |
||||
|
|
||||
|
public static Object deserialize(String str) throws IOException, ClassNotFoundException { |
||||
|
if (str == null || str.length() == 0) return null; |
||||
|
ByteArrayInputStream serialObj = new ByteArrayInputStream(decodeBytes(str)); |
||||
|
ObjectInputStream objStream = new ObjectInputStream(serialObj); |
||||
|
return objStream.readObject(); |
||||
|
} |
||||
|
|
||||
|
public static String encodeBytes(byte[] bytes) { |
||||
|
StringBuffer strBuf = new StringBuffer(); |
||||
|
|
||||
|
for (int i = 0; i < bytes.length; i++) { |
||||
|
strBuf.append((char) (((bytes[i] >> 4) & 0xF) + ((int) 'a'))); |
||||
|
strBuf.append((char) (((bytes[i]) & 0xF) + ((int) 'a'))); |
||||
|
} |
||||
|
|
||||
|
return strBuf.toString(); |
||||
|
} |
||||
|
|
||||
|
public static byte[] decodeBytes(String str) { |
||||
|
byte[] bytes = new byte[str.length() / 2]; |
||||
|
for (int i = 0; i < str.length(); i += 2) { |
||||
|
char c = str.charAt(i); |
||||
|
bytes[i / 2] = (byte) ((c - 'a') << 4); |
||||
|
c = str.charAt(i + 1); |
||||
|
bytes[i / 2] += (c - 'a'); |
||||
|
} |
||||
|
return bytes; |
||||
|
} |
||||
|
} |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 336 B |
After Width: | Height: | Size: 261 B |
After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 362 B |
After Width: | Height: | Size: 620 B |
After Width: | Height: | Size: 473 B |
@ -0,0 +1,57 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<android.support.design.widget.CoordinatorLayout |
||||
|
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||
|
android:id="@+id/main_content" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:fitsSystemWindows="true" |
||||
|
tools:context=".activities.topic.TopicActivity"> |
||||
|
|
||||
|
<android.support.design.widget.AppBarLayout |
||||
|
android:id="@+id/appbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:paddingTop="@dimen/appbar_padding_top" |
||||
|
android:theme="@style/ToolbarTheme"> |
||||
|
|
||||
|
<android.support.v7.widget.Toolbar |
||||
|
android:id="@+id/toolbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="?attr/actionBarSize" |
||||
|
android:background="?attr/colorPrimary" |
||||
|
app:popupTheme="@style/ToolbarTheme"> |
||||
|
</android.support.v7.widget.Toolbar> |
||||
|
</android.support.design.widget.AppBarLayout> |
||||
|
|
||||
|
<android.support.v4.widget.NestedScrollView |
||||
|
android:id="@+id/bookmarks_nested_scroll" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:layout_gravity="top|start" |
||||
|
android:layout_marginTop="64dp" |
||||
|
android:background="@color/background" |
||||
|
android:scrollbars="none"> |
||||
|
|
||||
|
<LinearLayout |
||||
|
android:id="@+id/bookmarks_container" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:orientation="vertical"/> |
||||
|
</android.support.v4.widget.NestedScrollView> |
||||
|
|
||||
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar |
||||
|
android:id="@+id/progressBar" |
||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="@dimen/progress_bar_height" |
||||
|
android:indeterminate="true" |
||||
|
android:visibility="invisible" |
||||
|
app:layout_anchor="@id/appbar" |
||||
|
app:layout_anchorGravity="bottom|center" |
||||
|
app:mpb_indeterminateTint="@color/accent" |
||||
|
app:mpb_progressStyle="horizontal"/> |
||||
|
</android.support.design.widget.CoordinatorLayout> |
||||
|
|
||||
|
|