Browse Source

Crafting NewsFeed Layout[25%]

master
Defend 7 years ago
parent
commit
4ef20e1f7d
  1. 16
      app/app.iml
  2. 57
      app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java
  3. 2
      app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java
  4. BIN
      app/src/main/res/drawable/Thumbs.db
  5. 25
      app/src/main/res/layout/cabinet_newsfeed.xml
  6. 44
      app/src/main/res/layout/cabinet_newsfeed_item.xml

16
app/app.iml

@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />

57
app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java

@ -3,10 +3,15 @@ package ru.defend.defdevteam.tstu;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Image;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.LinearLayoutCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -25,10 +30,14 @@ import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@ -149,7 +158,7 @@ public class CabinetActivity extends AppCompatActivity
studentRate = (TextView) findViewById(R.id.studentRate);
studentGroup = (TextView) findViewById(R.id.studentGroup);
positionFaculty = (TextView) findViewById(R.id.positionFaculty);
newsTextView = (TextView) findViewById(R.id.newsTextView);
//newsTextView = (TextView) findViewById(R.id.newsTextView);
positionGroup = (TextView) findViewById(R.id.positionGroup);
profileLayout = (RelativeLayout) findViewById(R.id.profileLayout);
journalLayout = (RelativeLayout) findViewById(R.id.journalList);
@ -171,6 +180,9 @@ public class CabinetActivity extends AppCompatActivity
AuthURL = "http://web-iais.admin.tstu.ru:7777/zion/f?p=stud_main";
loadSite(AuthURL);
addNewsItem(null);
addNewsItem(null);
}
@Override
@ -270,7 +282,50 @@ public class CabinetActivity extends AppCompatActivity
return true;
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
public void addNewsItem (View v) {
//Это всего лишь тестовая функция
LinearLayout mainLayer = (LinearLayout) findViewById(R.id.newsfeed_scroll);
LayoutInflater inflater = getLayoutInflater();
mainLayer.addView(inflater.inflate(R.layout.cabinet_newsfeed_item, null));
View layout = inflater.inflate(R.layout.cabinet_newsfeed_item, null);
mainLayer.addView(layout);
TextView text = (TextView) layout.findViewById(R.id.newsfeed_item_title);
text.setText("В ТГТУ прошел региональный этап Всероссийской олимпиады школьников по информатике и ИКТ");
TextView text2 = (TextView) layout.findViewById(R.id.newsfeed_item_text);
new DownloadImageTask((ImageView) layout.findViewById(R.id.newsfeed_item_image))
.execute("http://press.tstu.ru/photo/News/2017/0000494857574.jpg");
mainLayer.addView(inflater.inflate(R.layout.cabinet_newsfeed_item, null));
}
public void loadSite (String url) {
browser.loadUrl(url);

2
app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java

@ -50,7 +50,7 @@ public class FeedController {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
activity.newsTextView.setText(result);
//activity.newsTextView.setText(result);
}
});
}

BIN
app/src/main/res/drawable/Thumbs.db

Binary file not shown.

25
app/src/main/res/layout/cabinet_newsfeed.xml

@ -5,9 +5,24 @@
android:layout_height="match_parent"
tools:showIn="@layout/content_cabinet">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/newsTextView" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nav_newsfeed">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/newsfeed_scroll">
<include layout="@layout/cabinet_newsfeed_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/newsfeed_item_1"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

44
app/src/main/res/layout/cabinet_newsfeed_item.xml

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/cabinet_newsfeed"
android:background="@android:color/darker_gray">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@android:color/background_light"
android:layout_marginBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp">
<TextView
android:text="Lorem Ipsum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:layout_marginLeft="5dp"
android:id="@+id/newsfeed_item_title"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/newsfeed_item_image"/>
<TextView
android:text="TEXT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
android:id="@+id/newsfeed_item_text" />
</LinearLayout>
</RelativeLayout>
Loading…
Cancel
Save