Search in sources :

Example 1 with DiaryAdapter

use of cn.snowt.diary.adapter.DiaryAdapter in project Diary by HibaraAi.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 禁止截屏设置
    boolean notAllowScreenshot = BaseUtils.getDefaultSharedPreferences().getBoolean("notAllowScreenshot", true);
    if (notAllowScreenshot) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
    }
    setContentView(R.layout.activity_main);
    // 导航栏透明
    // 设置状态栏和导航栏颜色为透明
    View decorView = getWindow().getDecorView();
    int option = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    decorView.setSystemUiVisibility(option);
    // 设置导航栏颜色为透明
    getWindow().setNavigationBarColor(Color.TRANSPARENT);
    // 设置通知栏颜色为透明
    getWindow().setStatusBarColor(Color.TRANSPARENT);
    // 读取往年今日等提醒
    new Thread(() -> {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        LoginService loginService = new LoginServiceImpl();
        if (MyConfiguration.getInstance().isNeedFirstLoginNotice() && loginService.isFirstLoginInTheDay()) {
            loginService.doFirstLoginOfTheDay();
        }
    }).start();
    bindViewAndSetListener();
    getDiaryForFirstShow();
    diaryAdapter = new DiaryAdapter(voList);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(diaryAdapter);
}
Also used : DiaryAdapter(cn.snowt.diary.adapter.DiaryAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView) SuppressLint(android.annotation.SuppressLint) LoginService(cn.snowt.diary.service.LoginService) LoginServiceImpl(cn.snowt.diary.service.impl.LoginServiceImpl)

Example 2 with DiaryAdapter

use of cn.snowt.diary.adapter.DiaryAdapter in project Diary by HibaraAi.

the class DiaryDetailActivity method showDiaryDetail.

private void showDiaryDetail() {
    if (-1 != diaryId) {
        SimpleResult result = diaryService.getDiaryVoById(diaryId);
        if (result.getSuccess()) {
            DiaryVo diaryVo = (DiaryVo) result.getData();
            List<DiaryVo> diaryVos = new ArrayList<>();
            diaryVos.add(diaryVo);
            adapter = new DiaryAdapter(diaryVos);
            LinearLayoutManager layoutManager = new LinearLayoutManager(this);
            recyclerView.setAdapter(adapter);
            recyclerView.setLayoutManager(layoutManager);
        } else {
            toolbar.setTitle(result.getMsg());
        }
    } else {
        BaseUtils.shortTipInCoast(this, "日记貌似找不到呢...");
        finish();
    }
}
Also used : DiaryAdapter(cn.snowt.diary.adapter.DiaryAdapter) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SimpleResult(cn.snowt.diary.util.SimpleResult) DiaryVo(cn.snowt.diary.vo.DiaryVo)

Example 3 with DiaryAdapter

use of cn.snowt.diary.adapter.DiaryAdapter in project Diary by HibaraAi.

the class TimeAscActivity method onCreate.

@SuppressLint("NotifyDataSetChanged")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 禁止截屏设置
    boolean notAllowScreenshot = BaseUtils.getDefaultSharedPreferences().getBoolean("notAllowScreenshot", true);
    if (notAllowScreenshot) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
    }
    setContentView(R.layout.activity_time_asc);
    bindViewAndSetListener();
    Intent intent = getIntent();
    int intExtra = intent.getIntExtra(OPEN_FROM_TYPE, -1);
    switch(intExtra) {
        case OPEN_FROM_FORMER_YEARS:
            {
                actionBar.setTitle("往年今日");
                stopRefreshLayout();
                showForMerYears();
                break;
            }
        case OPEN_FROM_SIMPLE_DIARY_LIST:
            {
                actionBar.setTitle("临时信息流");
                stopRefreshLayout();
                showByIds(intent.getIntegerArrayListExtra("ids"), intent.getIntExtra("sortType", 1));
                break;
            }
        default:
            {
                getDiaryForFirstShow();
                break;
            }
    }
    diaryAdapter = new DiaryAdapter(voList);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(diaryAdapter);
}
Also used : DiaryAdapter(cn.snowt.diary.adapter.DiaryAdapter) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 DiaryAdapter (cn.snowt.diary.adapter.DiaryAdapter)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 LoginService (cn.snowt.diary.service.LoginService)1 LoginServiceImpl (cn.snowt.diary.service.impl.LoginServiceImpl)1 SimpleResult (cn.snowt.diary.util.SimpleResult)1 DiaryVo (cn.snowt.diary.vo.DiaryVo)1 NavigationView (com.google.android.material.navigation.NavigationView)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1 ArrayList (java.util.ArrayList)1